-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.cs
More file actions
49 lines (43 loc) · 1.33 KB
/
Player.cs
File metadata and controls
49 lines (43 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System.Collections.Generic;
namespace GoFish {
public abstract class Player {
public Hand Hand { get; protected set; }
/// <summary>
/// Gets the guess from this player.
/// </summary>
/// <returns>The Card the player guessed.</returns>
public abstract Card GetGuess();
/// <summary>
/// Handles the guess of the opposite player.
/// </summary>
/// <param name="guess">The Card the player guessed.</param>
/// <returns>The Cards retrieved from our hand.</returns>
public abstract List<Card> HandleGuess(Card guess);
/// <summary>
/// Draw a card from the given deck.
/// </summary>
/// <param name="deck">The deck of cards to pull from</param>
/// <returns>The card that was drawn</returns>
public Card DrawCard(Deck deck) {
Card card = deck.GetCard();
if (card != null) {
this.Hand.Add(card);
}
return card;
}
/// <summary>
/// Determines if the player has more cards in their hand.
/// </summary>
/// <returns>Whether or not the count of cards in the player's hand is > 0.</returns>
public bool HasMoreCards() {
return this.Hand.Count > 0;
}
/// <summary>
/// Receives cards from some previous guess.
/// </summary>
/// <param name="cards">The cards to add to the player's hand.</param>
public virtual void ReceiveCards(List<Card> cards) {
this.Hand.Add(cards);
}
}
}