Ejemplo n.º 1
0
        public IEnumerable <EffectCall> MakeTurn(Phase phase)
        {
            var globalEffectMakers = new List <EffectMaker> {
                this.GlobalEffects(), this.GlobalEffects()
            };

            var effects = new EffectSequence();

            bool changed = true;
            int  count   = 0;

            while (changed & count < 1000) // TODO
            {
                ++count;
                changed = false;
                foreach (bool buff in buffOrder)
                {
                    for (int i = 0; i < Players.Count; ++i)
                    {
                        bool changed2 = true;
                        while (changed2)
                        {
                            changed2 = false;
                            var player            = Players[i];
                            var globalPerspective = new EffectMakerPerspective(phase, player, effects);
                            if (effects.AddFromEffectMaker(globalEffectMakers[i], globalPerspective, buff))
                            {
                                yield return(effects.Effects.Last());

                                changed  = true;
                                changed2 = true;
                                continue;
                            }
                            foreach (var card in Players[i].AllCards().ToList()) // TODO Order could be better
                            {
                                var perspective = new EffectMakerPerspective(phase, player, effects, card);
                                if (effects.AddFromEffectMaker(card.Effects, perspective, buff))
                                {
                                    yield return(effects.Effects.Last());

                                    changed  = true;
                                    changed2 = true;
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            if (phase == Phase.End)
            {
                FinishTurn();
            }
        }
Ejemplo n.º 2
0
 public EffectMakerPerspective(Phase phase, PlayerState player, EffectSequence prefEffects, CardState card = null)
 {
     Phase       = phase;
     Game        = player.Game;
     playerIndex = Game.Players.IndexOf(player);
     if (playerIndex == -1)
     {
         throw new ArgumentException();
     }
     PrevEffects = prefEffects;
     if (card != null && card.Owner != player)
     {
         throw new ArgumentException();
     }
     Card = card;
 }