Ejemplo n.º 1
0
        private void DealAssignedCombatDamage()
        {
            Combat.DealAssignedDamage();

            if (Combat.AnyCreaturesWithFirstStrike() && Turn.Step == Step.FirstStrikeCombatDamage)
            {
                Publish(new AssignedDamageDealtEvent(Turn.Step));
            }

            if (Combat.AnyCreaturesWithNormalStrike() && Turn.Step == Step.CombatDamage)
            {
                Publish(new AssignedDamageDealtEvent(Turn.Step));
            }
        }
Ejemplo n.º 2
0
        private List <StepNode> CreateStepNodes()
        {
            StepNode gameStart               = null,
                     mulligan                = null,
                     untap                   = null,
                     upkeep                  = null,
                     draw                    = null,
                     firstMain               = null,
                     beginOfCombat           = null,
                     declareAttackers        = null,
                     declareBlockers         = null,
                     firstStrikeCombatDamage = null,
                     combatDamage            = null,
                     endofCombat             = null,
                     secondMain              = null,
                     endOfTurn               = null,
                     cleanup                 = null;

            gameStart = NewStep(Step.GameStart,
                                new Action[]
            {
                SelectStartingPlayer,
                ShuffleLibraries,
                DrawStartingHands,
            },
                                next: () => mulligan,
                                getsPriority: false);

            mulligan = NewStep(Step.Mulligan,
                               new Action[] { TakeMulligans },
                               next: () => Players.AnotherMulliganRound ? mulligan : untap,
                               getsPriority: false);

            untap = NewStep(Step.Untap,
                            new Action[]
            {
                () => Turn.NextTurn(),
                () =>
                {
                    foreach (var permanent in Players.Active.Battlefield)
                    {
                        permanent.HasSummoningSickness = false;

                        if (permanent.Has().DoesNotUntap)
                        {
                            continue;
                        }

                        if (permanent.MayChooseNotToUntap)
                        {
                            Enqueue(new ChooseToUntap(
                                        Players.Active,
                                        permanent));
                        }
                        else
                        {
                            permanent.Untap();
                        }
                    }

                    Players.Active.LandsPlayedCount = 0;
                }
            },
                            next: () => upkeep,
                            getsPriority: false);

            upkeep = NewStep(Step.Upkeep,
                             next: () => draw,
                             getsPriority: true);


            draw = NewStep(Step.Draw,
                           new Action[]
            {
                () =>
                {
                    if (Turn.TurnCount != 1)
                    {
                        Players.Active.DrawCard();
                    }
                }
            },
                           next: () => firstMain,
                           getsPriority: true);

            firstMain = NewStep(Step.FirstMain,
                                next: () => beginOfCombat,
                                getsPriority: true);

            beginOfCombat = NewStep(Step.BeginningOfCombat,
                                    next: () => declareAttackers,
                                    getsPriority: true);

            declareAttackers = NewStep(Step.DeclareAttackers,
                                       new Action[]
            {
                DeclareAttackers
            },
                                       next: () => declareBlockers,
                                       getsPriority: true);

            declareBlockers = NewStep(Step.DeclareBlockers,
                                      new Action[]
            {
                DeclareBlockers,
                SetDamageAssignmentOrder,
            },
                                      next: () => Combat.AnyCreaturesWithFirstStrike()
          ? firstStrikeCombatDamage
          : combatDamage,
                                      getsPriority: true);


            firstStrikeCombatDamage = NewStep(Step.FirstStrikeCombatDamage,
                                              new Action[]
            {
                () => Combat.AssignCombatDamage(firstStrike: true),
                DealAssignedCombatDamage,
                () => Players.MoveDeadCreaturesToGraveyard()
            },
                                              next: () => Combat.AnyCreaturesWithNormalStrike()
          ? combatDamage
          : endofCombat,
                                              getsPriority: true);

            combatDamage = NewStep(Step.CombatDamage,
                                   new Action[]
            {
                () => Combat.AssignCombatDamage(),
                DealAssignedCombatDamage,
                () => Players.MoveDeadCreaturesToGraveyard()
            },
                                   next: () => endofCombat,
                                   getsPriority: true);

            endofCombat = NewStep(Step.EndOfCombat,
                                  new Action[]
            {
                () => Combat.RemoveAll()
            },
                                  next: () => secondMain,
                                  getsPriority: true);

            secondMain = NewStep(Step.SecondMain,
                                 next: () => endOfTurn,
                                 getsPriority: true);

            endOfTurn = NewStep(Step.EndOfTurn,
                                next: () => cleanup,
                                getsPriority: true);

            cleanup = NewStep(Step.CleanUp,
                              new Action[]
            {
                () =>
                {
                    Players.RemoveDamageFromPermanents();
                    Players.RemoveRegenerationFromPermanents();

                    DiscardToMaximumHandSize();
                    Publish(new EndOfTurnEvent());
                },
                () => Players.ChangeActivePlayer(),
            },
                              next: () => untap,
                              getsPriority: false);


            var all = new List <StepNode>
            {
                gameStart,
                mulligan,
                untap,
                upkeep,
                draw,
                firstMain,
                beginOfCombat,
                declareAttackers,
                declareBlockers,
                firstStrikeCombatDamage,
                combatDamage,
                endofCombat,
                secondMain,
                endOfTurn,
                cleanup
            };

            return(all);
        }