In card games, a "mulligan" is a mechanism that allows players to redraw their initial cards before the game begins. This gives them the chance to improve their hand by exchanging unwanted cards or all cards in hand.
`GameStateType` is an enumeration (enum) that defines different states of the game. Each state represents a specific moment or phase in the course of the game.
`mulliganDraw` is one of these states, indicating that the player is in the mulligan phase, where they the game choose for the player to redraw certain cards.
The logic within this case is responsible for managing the actions that need to occur when the game is in the mulligan state.
This may include operations such as:
Shuffling the deck: Before allowing the game to redraw, the game ensures that the deck is shuffled correctly to guarantee the randomness of the new cards.
Modifying the state of cards: Ensuring that the cards being redrawn are handled correctly within the system.
This does not include:
Updating the user interface: Indicating to the player if they can declare "Mulligan" after the shuffle and allowing the selection of all or some cards to redraw.

| |
|
|---|---|
|
|
| | |
| |
| | |
| This code is a collection of all the functions involved in the shuffle mechanic, though it doesn't exist as a single block in any one file. | |
// GameManager.cs public enum MoveTypeEnum { mulligan, // other move types... } // PlayerController.cs public void Mulligan() { if (clickedCard == null && !GraveyardListDisplay.isShowingGraveYard && !DeckListDisplay.isShowingDeck) { GameManager.PressedGUIButton(); GameManager.RecordMove(GameManager.MoveTypeEnum.mulligan, null); GameController.Mulligan(null); gameplay.ShowButton(gameplay.buttonBR2Red, "Mulligan"); if (gameplay.button2Pressed) { GameManager.PressedGUIButton(); GameManager.RecordMove(GameManager.MoveTypeEnum.mulligan, GameModel.GetHero()); GameController.Mulligan(GameModel.GetHero()); } } } // GameController.cs public void Mulligan(ShadowEraCard card) { if (card == null) { DebugLogger.Log("GameController Mulligan Skipped - curSide " + GameModel.CurSide() + " turnCounter " + GameModel.turnCounter); GameModel.SetCurSide(1 - GameModel.CurSide()); GameModel.turnCounter++; } else { DebugLogger.Log("GameController Mulligan - curSide " + GameModel.CurSide() + " turnCounter " + GameModel.turnCounter); GameModel.DiscardCard(card); // Discard the selected card GameModel.ShuffleDeck(); // Shuffle the deck after discarding GameModel.GameStateActivate(GameState.GameStateType.mulliganDraw); // Transition to mulligan draw state } } // GameModel.cs public int HandCount() { // Returns the number of cards in the player's hand } public void DiscardCard(ShadowEraCard card) { // Logic to remove the specified card from the player's hand } public void ShuffleDeck() { // Logic to shuffle the player's deck } public void GameStateActivate(GameState.GameStateType newState) { // Logic to change the game state } // Gameplay.cs public void Update(float deltaTime) { switch (GameModel.CurGameState()) { case GameState.GameStateType.mulligan: // Handle actions specific to the mulligan state break; case GameState.GameStateType.mulliganDraw: if (stateTime == deltaTime) { for (int i = 0; i < 5; i++) { GameModel.Draw(GameModel.CurSide()); // Draw new cards for the player } } break; } } // GameState.cs public enum GameStateType { pre, draw, mulligan, mulliganDraw, sacrifice, action, // other states... } | |
