Example #1
0
        public TurnResult Resolve()
        {
            IPlayer    fastPlayer, slowPlayer;
            TurnResult result = new TurnResult(this);

            int numPhases = Math.Max(P1.Hand.Count, P2.Hand.Count);

            for (int i = 0; i < numPhases && !_stopTurn; i++)
            {
                var phase = new Phase(i);
                Phases.Add(phase);

                P1.ActiveCard = P1.Hand.ElementAtOrDefault(i);
                P2.ActiveCard = P2.Hand.ElementAtOrDefault(i);

                // Figure out who goes first
                fastPlayer = (P1.SPD >= P2.SPD) ? P1 : P2;
                slowPlayer = (P1.SPD >= P2.SPD) ? P2 : P1;

                phase.CombatResults.Add(ResolveCombat(fastPlayer, slowPlayer));
                if (_stopTurn)
                {
                    return(result.SetGameOver(_winner, _loser));
                }

                phase.CombatResults.Add(ResolveCombat(slowPlayer, fastPlayer));
                if (_stopTurn)
                {
                    return(result.SetGameOver(_winner, _loser));
                }
            }
            return(result);
        }
Example #2
0
        public void GameDone(TurnResult turnResult)
        {
            GameResult gameResult = new GameResult(this, turnResult);

            if (turnResult.Loser.IsUser)
            {
                Console.WriteLine("You Lose!");

                GameOverEventArgs args = new GameOverEventArgs(gameResult);
                OnGameOver(args);
            }
            else
            {
                Console.WriteLine("You Win!");
                GameOverEventArgs args = new GameOverEventArgs(gameResult);
                OnGameOver(args);
            }
        }
Example #3
0
 public GameResult(Game game, TurnResult lastTurnResult)
 {
     Game           = game;
     LastTurnResult = lastTurnResult;
 }