Example #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();
            }
        }
Example #2
0
        public bool AddFromEffectMaker(EffectMaker effectMaker, EffectMakerPerspective perspective, bool buff)
        {
            if (effectMaker == null)
            {
                return(false);
            }
            var effect = effectMaker.GetEffect(perspective, buff);

            if (effect != null)
            {
                var effectCall = new EffectCall(effect, perspective.Player, perspective.Card, buff);
                effects.Add(effectCall);
                return(true);
            }
            return(false);
        }
Example #3
0
 public abstract Effect GetEffect(EffectMakerPerspective perspective, bool buff);