示例#1
0
        /// <summary>
        /// Update the auras on each zone (which can be influenced by entities from the
        /// <see cref="Zone.PLAY"/> zone.
        /// </summary>
        public void AuraUpdate()
        {
            Enchants.ForEach(p => p.IsEnabled());
            Triggers.ForEach(p => p.IsEnabled());

            CurrentPlayer.Hero.Enchants.ForEach(p => p.IsEnabled());
            CurrentPlayer.Hero.Triggers.ForEach(p => p.IsEnabled());

            //CurrentPlayer.Hero.Weapon?.Enchants.ForEach(p => p.IsEnabled());
            //CurrentPlayer.Hero.Weapon?.Triggers.ForEach(p => p.IsEnabled());

            CurrentPlayer.BoardZone.Enchants.ForEach(p => p.IsEnabled());
            CurrentPlayer.BoardZone.Triggers.ForEach(p => p.IsEnabled());

            CurrentPlayer.GraveyardZone.Enchants.ForEach(p => p.IsEnabled());
            CurrentPlayer.GraveyardZone.Triggers.ForEach(p => p.IsEnabled());

            CurrentOpponent.Hero.Enchants.ForEach(p => p.IsEnabled());
            CurrentOpponent.Hero.Triggers.ForEach(p => p.IsEnabled());

            //CurrentOpponent.Hero.Weapon?.Enchants.ForEach(p => p.IsEnabled());
            //CurrentOpponent.Hero.Weapon?.Triggers.ForEach(p => p.IsEnabled());

            CurrentOpponent.BoardZone.Enchants.ForEach(p => p.IsEnabled());
            CurrentOpponent.BoardZone.Triggers.ForEach(p => p.IsEnabled());

            CurrentOpponent.GraveyardZone.Enchants.ForEach(p => p.IsEnabled());
            CurrentOpponent.GraveyardZone.Triggers.ForEach(p => p.IsEnabled());

            Characters.ForEach(p1 => p1.Enchants.ForEach(p2 => p2.IsEnabled()));
            Characters.ForEach(p1 => p1.Triggers.ForEach(p2 => p2.IsEnabled()));

            LazyRemoves.ToList().ForEach(p => p.Remove());
            LazyRemoves.Clear();
        }
示例#2
0
        /// <summary>Process the specified task.
        /// The game will execute the desired task and all effects coupled either
        /// directly or indirectly in synchronous manner.
        ///
        /// Call <see cref="Controller.Options(bool)"/> on the <see cref="CurrentPlayer"/>
        /// instance for tasks which are accepted as arguments.
        /// After this method returns, check <see cref="Controller.Options(bool)"/>
        /// again until only <see cref="EndTurnTask"/> remains, which will
        /// start the turn of <see cref="CurrentOpponent"/>.
        /// </summary>
        /// <param name="gameTask">The game task to execute.</param>
        public void Process(PlayerTask gameTask)
        {
            // start with no splits ...
            Splits = new List <Game>();

            Log(LogLevel.INFO, BlockType.PLAY, "Game", gameTask.FullPrint());

            // clear last power history
            PowerHistory.Last.Clear();

            // make sure that we only use task for this game ...
            gameTask.Game = this;
            gameTask.Process();

            // add enchantment and buff tag changes
            if (History)
            {
                Enchants.ForEach(p =>
                                 p.Effects.Keys.ToList().ForEach(t =>
                                                                 IdEntityDic.Values.ToList().ForEach(o =>
                                                                                                     PowerHistory.Add(PowerHistoryBuilder.TagChange(o.Id, t, o[t])))));

                foreach (var controller in _players)
                {
                    controller.Hero.Enchants.ForEach(p =>
                                                     p.Effects.Keys.ToList().ForEach(t =>
                                                                                     PowerHistory.Add(PowerHistoryBuilder.TagChange(Game.CurrentPlayer.Hero.Id, t, Game.CurrentPlayer.Hero[t]))));

                    //CurrentPlayer.Hero.Weapon?.Enchants.ForEach(p => p.IsEnabled());
                    //CurrentPlayer.Hero.Weapon?.Triggers.ForEach(p => p.IsEnabled());
                    //CurrentOpponent.Hero.Weapon?.Enchants.ForEach(p => p.IsEnabled());
                    //CurrentOpponent.Hero.Weapon?.Triggers.ForEach(p => p.IsEnabled());

                    controller.ControlledZones.Where(z => z != null).ToList().ForEach(z =>
                                                                                      z.Enchants.ForEach(p =>
                                                                                                         p.Effects.Keys.ToList().ForEach(t =>
                                                                                                                                         z.GetAll.ForEach(o =>
                                                                                                                                                          PowerHistory.Add(PowerHistoryBuilder.TagChange(o.Id, t, o[t]))))));
                }

                Characters.ForEach(c =>
                                   c.Enchants.ForEach(p =>
                                                      p.Effects.Keys.ToList().ForEach(t =>
                                                                                      PowerHistory.Add(PowerHistoryBuilder.TagChange(c.Id, t, c[t])))));
            }

            if (Splitting)
            {
                var finalSplits = SplitNode.GetSolutions(this, 10, 10000);
                Dump("Split", $"found {finalSplits.Count} final splits of {finalSplits.Sum(p => p.SameState + 1)}!");
                finalSplits.GroupBy(p => p.SameState)
                .Select(i => new { Word = i.Key, Count = i.Count() })
                .ToList().ForEach(p => Dump("Split", $" {p.Count},  with {p.Word} same states"));
                FinalSplits = finalSplits;
            }
        }
示例#3
0
        public virtual string Hash(params GameTag[] ignore)
        {
            var str = _data.Hash(ignore);

            str.Append("[O:");
            str.Append(OrderOfPlay.ToString());
            str.Append($"][EN:{Enchants.Count}");
            Enchants.ForEach(p => str.Append(p.Hash));
            str.Append($"][TR:{Triggers.Count}");
            Triggers.ForEach(p => str.Append(p.Hash));
            str.Append("]");
            return(str.ToString());
        }
示例#4
0
        public int this[GameTag t]
        {
            get
            {
                //if (Card.Name.Equals("Angry Chicken"))
                //Game?.Log(LogLevel.DEBUG, BlockType.TRIGGER, "Entity", $"{this} get org. data {t} = {_data[t]}");

                var value = _data[t];

                // cumulative enchanment calculation ... priorizing game, zone, entity
                Game?.Enchants.ForEach(p => value = p.Apply(this, t, value));
                Zone?.Enchants.ForEach(p => value = p.Apply(this, t, value));
                Enchants.ForEach(p => value       = p.Apply(this, t, value));

                return(value);
            }
            set
            {
                var oldValue = _data[t];
                Game.Log(LogLevel.DEBUG, BlockType.TRIGGER, "Entity", $"{this} set data {t} to {value} oldvalue {oldValue}");
                //if (oldValue == value && t != GameTag.ZONE_POSITION)
                //{
                //    Game.Log(LogLevel.DEBUG, BlockType.TRIGGER, "Entity", $"{this} set data {t} to {value} obsolet as value is already that value.");
                //    return;
                //}

                SetNativeGameTag(t, value);

                Game.OnEntityChanged(this, t, oldValue, value);


                // don't trigger on explicit turned off heals or predamage changes ....
                if ((t == GameTag.DAMAGE || t == GameTag.PREDAMAGE) && IsIgnoreDamage)
                {
                    return;
                }

                // trigger here
                Game?.Triggers.ForEach(p => p.Change(this, t, oldValue, value));
                Zone?.Triggers.ForEach(p => p.Change(this, t, oldValue, value));
                Triggers.ForEach(p => p.Change(this, t, oldValue, value));
            }
        }
示例#5
0
        public string Hash(params GameTag[] ignore)
        {
            var str = new StringBuilder();

            str.Append("[Z:");
            str.Append($"{Type}");
            str.Append("][E:");
            List <IPlayable> list = GetAll;

            if (Type != Zone.PLAY)
            {
                list = list.OrderBy(p => p.Id).ToList();
                Array.Resize(ref ignore, ignore.Length + 1);
                ignore[ignore.Length - 1] = GameTag.ZONE_POSITION;
            }
            list.ForEach(p => str.Append(p.Hash(ignore)));
            str.Append($"][EN:{Enchants.Count}");
            Enchants.ForEach(p => str.Append(p.Hash));
            str.Append($"][TR:{Triggers.Count}");
            Triggers.ForEach(p => str.Append(p.Hash));
            str.Append("]");
            return(str.ToString());
        }