commit 23839d9c0fa66c9ced8b87e4bdb0fd51a3f56373 parent 60bb5b013d88417b5de2d34753e4129fd6c29c03 Author: Michael Neuper <73108749+michaelneuper@users.noreply.github.com> Date: Sat, 8 Oct 2022 09:16:01 +0200 add hit method Diffstat:
| M | src/model/Person.java | | | 16 | +++++++++++++++- |
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/model/Person.java b/src/model/Person.java @@ -53,8 +53,22 @@ public abstract class Person { System.out.println(this.name + "'s hand:\n" + this.hand + "[" + this.hand.calculateValue() + "]"); } + /** + * Checks if the deck has cards and reloads the deck if it ran out + * + * @param deck deck to draw from + * @param discard deck to discard to + */ public void hit(Deck deck, Deck discard) { - // TODO + + //If there's no cards left in the deck + if (!deck.hasCards()) { + deck.reloadDeckFromDiscard(discard); + } + + this.hand.takeCardFromDeck(deck); + System.out.println(this.name + " gets a card"); + this.printHand(); } }