m |
m |
||
| Line 74: | Line 74: | ||
|} | |} | ||
<center><img src="https://www.shadowera.com/landing/img/blog-separator-2.png" ></center><br> | <center><img src="https://www.shadowera.com/landing/img/blog-separator-2.png" ></center><br> | ||
| + | |||
| + | ==== Mulligan ==== | ||
| + | {| class="wikitable" code-table" | ||
| + | |- | ||
| + | !*Explanation of `case GameStateType.mulliganDraw:`<br> | ||
| + | In card games, a "[[:Category_talk:Mulligan|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.<br> | ||
| + | `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.<br> | ||
| + | `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''.<br><br> | ||
| + | The logic within this case is responsible for managing the actions that need to occur when the game is in the mulligan state.<br> | ||
| + | This may include operations such as:<br> | ||
| + | '''Shuffling the deck''': Before allowing the game to redraw, the game ensures that the deck is shuffled correctly to guarantee the [[:Category_talk:Randomization|randomness]] of the new cards.<br> | ||
| + | '''Modifying the state of cards''': Ensuring that the cards being redrawn are handled correctly within the system.<br> | ||
| + | This does not include:<br> | ||
| + | '''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.<br> | ||
| + | |} | ||
<br><br> | <br><br> | ||
[[Category:Shuffle]] | [[Category:Shuffle]] | ||

| |
|
|---|---|
|
|
| | |
| |
| | |
| 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. The complete shuffle logic is primarily found in GameModel.cs. | |
// GameModel.cs public static void ShuffleDeck(int side) { // Logic for shuffling the deck for the specified player side Random.State state = Random.state; // Save the current random state Random.InitState(num); // Initialize random state with a seed int index = Random.Range(0, model.players[side].deck.Count); // Get a random index OnDeckShuffled(side); // Call deck shuffled event gameData.shuffledDeckThisTurn[side]++; // Increment the shuffle counter Random.state = state; // Restore the previous random state Debug.Log("Shuffled deck for side " + side + ", seed " + num); // Log shuffle info } public static void ShuffleDeck() { ShuffleDeck(CurSide()); // Calls the shuffle method for the current player side } // Additional functions related to deck manipulation public static void RemoveDeck(ShadowEraCard card) { // Logic for removing a card from the deck } // GameController.cs GameModel.ShuffleDeck(); // Called to trigger the shuffle process GameModel.GameStateActivate(GameState.GameStateType.mulliganDraw); // Changes the game state for a mulligan // Gameplay.cs GameModel.ShuffleDeck(1); // Executes the shuffle for player 1 // GameState.cs case GameStateType.draw: { // Logic for handling the draw state after a shuffle } case GameStateType.mulliganDraw: { // Logic for handling the mulligan draw state, ensuring shuffle occurs correctly } | |

| *Explanation of `case GameStateType.mulliganDraw:` 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. |
|---|