developmaunt #3
14
Mau/Game.cs
14
Mau/Game.cs
@@ -102,7 +102,7 @@ public class Game : RoomType
|
|||||||
// Change the turn if the player that left was the current player
|
// Change the turn if the player that left was the current player
|
||||||
if (player == _turnManager.CurrentPlayer)
|
if (player == _turnManager.CurrentPlayer)
|
||||||
{
|
{
|
||||||
_turnManager.ChangeTurn();
|
_turnManager.ChangeTurnTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the player from the game
|
// Remove the player from the game
|
||||||
@@ -144,7 +144,7 @@ public class Game : RoomType
|
|||||||
_deck.CurrentCard = new Card(cardType, CardValue.JACK);
|
_deck.CurrentCard = new Card(cardType, CardValue.JACK);
|
||||||
|
|
||||||
// Change the turns
|
// Change the turns
|
||||||
_turnManager.ChangeTurn(nextPlayer);
|
_turnManager.ChangeTurnTo(nextPlayer);
|
||||||
|
|
||||||
// Broadcast new game state
|
// Broadcast new game state
|
||||||
SendGameState();
|
SendGameState();
|
||||||
@@ -172,7 +172,7 @@ public class Game : RoomType
|
|||||||
// Change the player if the drawn card cannot be played
|
// Change the player if the drawn card cannot be played
|
||||||
if (!drawnCard.CanBePlayedOn(_deck.CurrentCard))
|
if (!drawnCard.CanBePlayedOn(_deck.CurrentCard))
|
||||||
{
|
{
|
||||||
_turnManager.ChangeTurn();
|
_turnManager.ChangeTurnTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Broadcast new game state
|
// Broadcast new game state
|
||||||
@@ -258,20 +258,20 @@ public class Game : RoomType
|
|||||||
case CardValue.TWO:
|
case CardValue.TWO:
|
||||||
{
|
{
|
||||||
_turnManager.GetNextPlayer().GiveCards(_deck.DrawCards(2));
|
_turnManager.GetNextPlayer().GiveCards(_deck.DrawCards(2));
|
||||||
_turnManager.ChangeTurn(_turnManager.GetNextPlayer(2));
|
_turnManager.ChangeTurnTo(_turnManager.GetNextPlayer(2));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CardValue.SEVEN:
|
case CardValue.SEVEN:
|
||||||
case CardValue.KING:
|
case CardValue.KING:
|
||||||
break;
|
break;
|
||||||
case CardValue.EIGHT:
|
case CardValue.EIGHT:
|
||||||
_turnManager.ChangeTurn(_turnManager.GetNextPlayer(2));
|
_turnManager.ChangeTurnTo(_turnManager.GetNextPlayer(2));
|
||||||
break;
|
break;
|
||||||
case CardValue.ACE:
|
case CardValue.ACE:
|
||||||
if (_turnManager.Players.Count > 2)
|
if (_turnManager.Players.Count > 2)
|
||||||
{
|
{
|
||||||
_turnManager.ChangeDirection();
|
_turnManager.ChangeDirection();
|
||||||
_turnManager.ChangeTurn();
|
_turnManager.ChangeTurnTo();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CardValue.JACK:
|
case CardValue.JACK:
|
||||||
@@ -285,7 +285,7 @@ public class Game : RoomType
|
|||||||
case CardValue.TEN:
|
case CardValue.TEN:
|
||||||
case CardValue.QUEEN:
|
case CardValue.QUEEN:
|
||||||
default:
|
default:
|
||||||
_turnManager.ChangeTurn();
|
_turnManager.ChangeTurnTo();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,14 +39,14 @@ public class TurnManager
|
|||||||
* Change the turn to another player.
|
* Change the turn to another player.
|
||||||
* If no player is given, the next player in the current direction is chosen.
|
* If no player is given, the next player in the current direction is chosen.
|
||||||
* </summary>
|
* </summary>
|
||||||
* <param name="nextPlayer">The player to change the turn to. Defaults to the next player in the current direction.</param>
|
* <param name="playerayer">The player to change the turn to. Defaults to the next player in the current direction.</param>
|
||||||
*/
|
*/
|
||||||
public void ChangeTurn(Player? nextPlayer = null)
|
public void ChangeTurnTo(Player? player = null, PlayerState nextPlayerState = PlayerState.TURN)
|
||||||
{
|
{
|
||||||
var player = nextPlayer ?? GetNextPlayer();
|
var nextPlayer = player ?? GetNextPlayer();
|
||||||
CurrentPlayer.State = PlayerState.WAIT;
|
CurrentPlayer.State = PlayerState.WAIT;
|
||||||
player.State = PlayerState.TURN;
|
nextPlayer.State = nextPlayerState;
|
||||||
CurrentPlayer = player;
|
CurrentPlayer = nextPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,5 +4,6 @@ public enum PlayerState
|
|||||||
{
|
{
|
||||||
TURN,
|
TURN,
|
||||||
CHOOSE,
|
CHOOSE,
|
||||||
WAIT
|
WAIT,
|
||||||
|
POST_DRAW
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user