Added the ability to choose your cardtype when playing a jack or the newly added joker
This commit is contained in:
35
Mau/Game.cs
35
Mau/Game.cs
@@ -46,6 +46,17 @@ public class Game
|
||||
PlayCard(player, card);
|
||||
break;
|
||||
}
|
||||
case "CHOOSE":
|
||||
var choice = action.Data;
|
||||
if (!Enum.TryParse(choice, out CardType cardType))
|
||||
{
|
||||
break;
|
||||
}
|
||||
CurrentCard = new Card(cardType, CardValue.JACK);
|
||||
CurrentPlayer.State = PlayerState.WAIT;
|
||||
CurrentPlayer = CurrentCard.CardType == CardType.JOKER ? GetNextPlayer() : GetNextPlayer(2);
|
||||
CurrentPlayer.State = PlayerState.TURN;
|
||||
break;
|
||||
case "DRAW":
|
||||
DrawCard(player);
|
||||
break;
|
||||
@@ -66,6 +77,18 @@ public class Game
|
||||
{
|
||||
switch (card.CardValue)
|
||||
{
|
||||
case CardValue.RED:
|
||||
case CardValue.BLACK:
|
||||
{
|
||||
var nextPlayer = GetNextPlayer();
|
||||
var cardsToDraw = Deck.DrawCards(5);
|
||||
foreach (var drawnCard in cardsToDraw)
|
||||
{
|
||||
nextPlayer.Hand.Add(drawnCard);
|
||||
}
|
||||
CurrentPlayer.State = PlayerState.CHOOSE;
|
||||
break;
|
||||
}
|
||||
case CardValue.TWO:
|
||||
{
|
||||
var nextPlayer = GetNextPlayer();
|
||||
@@ -74,14 +97,18 @@ public class Game
|
||||
{
|
||||
nextPlayer.Hand.Add(drawnCard);
|
||||
}
|
||||
CurrentPlayer.State = PlayerState.WAIT;
|
||||
CurrentPlayer = GetNextPlayer(2);
|
||||
CurrentPlayer.State = PlayerState.TURN;
|
||||
break;
|
||||
}
|
||||
case CardValue.SEVEN:
|
||||
case CardValue.KING:
|
||||
break;
|
||||
case CardValue.EIGHT:
|
||||
CurrentPlayer.State = PlayerState.WAIT;
|
||||
CurrentPlayer = GetNextPlayer(2);
|
||||
CurrentPlayer.State = PlayerState.TURN;
|
||||
break;
|
||||
case CardValue.ACE:
|
||||
if (Players.Count > 2)
|
||||
@@ -90,13 +117,15 @@ public class Game
|
||||
CurrentPlayer = GetNextPlayer();
|
||||
}
|
||||
break;
|
||||
case CardValue.JACK:
|
||||
CurrentPlayer.State = PlayerState.CHOOSE;
|
||||
break;
|
||||
case CardValue.THREE:
|
||||
case CardValue.FOUR:
|
||||
case CardValue.FIVE:
|
||||
case CardValue.SIX:
|
||||
case CardValue.NINE:
|
||||
case CardValue.TEN:
|
||||
case CardValue.JACK:
|
||||
case CardValue.QUEEN:
|
||||
default:
|
||||
CurrentPlayer = GetNextPlayer();
|
||||
@@ -108,6 +137,8 @@ public class Game
|
||||
{
|
||||
player.Hand.Add(Deck.DrawCard());
|
||||
CurrentPlayer = GetNextPlayer();
|
||||
player.State = PlayerState.WAIT;
|
||||
CurrentPlayer.State = PlayerState.TURN;
|
||||
}
|
||||
|
||||
private Player GetNextPlayer(int numberOfPlayers = 1)
|
||||
@@ -135,7 +166,7 @@ public class Game
|
||||
|
||||
private static bool IsCardPlayable(Card currentCard, Card playedCard)
|
||||
{
|
||||
return IsSameCardType(currentCard, playedCard) || IsSameCardValue(currentCard, playedCard);
|
||||
return IsSameCardType(currentCard, playedCard) || IsSameCardValue(currentCard, playedCard) || playedCard.CardType == CardType.JOKER;
|
||||
}
|
||||
|
||||
private static bool IsCardInHand(IEnumerable<Card> hand, Card card)
|
||||
|
||||
Reference in New Issue
Block a user