public override void ProcessAction(InGameAction inGameAction, XmlGame game) { ClaimVictoryAction claimVictory = inGameAction as ClaimVictoryAction; if (claimVictory != null) { _TurnPhase.ProcessAction(inGameAction, game); return; } PlacementDoneAction placementDone = inGameAction as PlacementDoneAction; if (placementDone != null) { _TurnPhase.ProcessAction(inGameAction, game); return; } EndTurnAction endTurn = inGameAction as EndTurnAction; if (endTurn != null) { _TurnPhase = new BeforeDiceRollTurnPhase(); endTurn.PerformTurnAction(game); return; } // Process the actual in the current turnphase TurnPhase next = _TurnPhase.ProcessAction(inGameAction, game); // If return phase does not match current phase, we have to switch phases and process the action // again if (_TurnPhase != next) { _TurnPhase = next; _TurnPhase = _TurnPhase.ProcessAction(inGameAction, game); } // When the incoming action is not valid, check if it's valid in the next phase. // If so, switch phases if (!_TurnPhase.AllowedAction(inGameAction, game)) { if (_TurnPhase.Next().AllowedAction(inGameAction, game)) { _TurnPhase = _TurnPhase.Next(); } } }
public void SetStatus(TurnPhase turnPhase) { if (turnPhase is BeforeDiceRollTurnPhase) { SetBeforeDiceRoll(); dices.Visibility = Visibility.Visible; } if (turnPhase is RollDiceTurnPhase) { dices.Visibility = Visibility.Hidden; SetAfterDiceRoll(); } if (turnPhase is TradingTurnPhase) { dices.Visibility = Visibility.Hidden; SetAfterDiceRoll(); } if (turnPhase is BuildTurnPhase) { dices.Visibility = Visibility.Hidden; SetAfterDiceRoll(); } }