### Question:
ConsoleInputStrategy extends Strategy { @Override public Move nextMove(int availableMana, int currentHealth, List<Card> availableCards) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in, Charset.defaultCharset())); Integer card = -1; Action action = Action.DAMAGE; while (card < 0 || card > 8 || card > availableMana || !availableCards.contains(new Card(card))) { try { String input = br.readLine(); if (input.endsWith("h")) { action = Action.HEALING; input = input.replace("h", ""); } card = Integer.decode(input); } catch (NumberFormatException e) { logger.warning("Invalid input: " + e.getMessage()); } } return new Move(Optional.of(new Card(card)), action); } catch (IOException e) { logger.severe("Could not read console input: " + e.getMessage()); e.printStackTrace(); } return new Move(Optional.empty(), null); }  @Override Move nextMove(int availableMana, int currentHealth, List<Card> availableCards);  }### Answer:
@Test public void shouldPlayCardsSelectedOnSystemConsole() { player().enters("2").finished(); assertThat(strategy.nextMove(withMana(10), andHealth(30), fromCards(0, 2, 3)), isAttackingWithCard(2)); }
@Test public void willRejectTooExpensiveCardsUntilAffordableCardIsChosen() { player().enters("8").enters("7").enters("6").finished(); assertThat(strategy.nextMove(withMana(6), andHealth(30), fromCards(6, 7, 8)), isAttackingWithCard(6)); }
@Test public void willRejectCardsNotPresentInHandUntilHandCardIsChosen() { player().enters("1").enters("2").enters("3").finished(); assertThat(strategy.nextMove(withMana(5), andHealth(30), fromCards(3, 4, 5)), isAttackingWithCard(3)); }
@Test public void willUseChosenCardForHealingWhenInputIsSuffixedWithLetterH() { player().enters("5h").finished(); assertThat(strategy.nextMove(withMana(10), andHealth(30), fromCards(5)), isHealingWithCard(5)); }
@Test public void invalidInputWillBeRejectedUntilValidChoiceIsMade() { player().enters("xxx").enters("§$%").enters("2").finished(); assertThat(strategy.nextMove(withMana(10), andHealth(30), fromCards(2)), isAttackingWithCard(2)); }