Пример #1
0
        public InspectItemData(Item item, byte index)
        {
            CreatorGUID = item.GetGuidValue(ItemFields.Creator);

            Item   = new ItemInstance(item);
            Index  = index;
            Usable = true; // @todo

            for (EnchantmentSlot enchant = 0; enchant < EnchantmentSlot.Max; ++enchant)
            {
                uint enchId = item.GetEnchantmentId(enchant);
                if (enchId != 0)
                {
                    Enchants.Add(new InspectEnchantData(enchId, (byte)enchant));
                }
            }

            byte i = 0;

            foreach (ItemDynamicFieldGems gemData in item.GetGems())
            {
                if (gemData.ItemId != 0)
                {
                    ItemGemData gem = new ItemGemData();
                    gem.Slot = i;
                    gem.Item = new ItemInstance(gemData);
                    Gems.Add(gem);
                }
                ++i;
            }
        }
Пример #2
0
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member

        public virtual void Stamp(Entity entity)
        {
            OrderOfPlay = entity.OrderOfPlay;
            _data.Stamp(entity._data);
            entity.Enchants.ForEach(p => Enchants.Add(p.Copy(p.SourceId, Game, p.Turn, Enchants, p.Owner, p.RemoveTriggers)));
            entity.Triggers.ForEach(p => Triggers.Add(p.Copy(p.SourceId, Game, p.Turn, Triggers, p.Owner)));
        }
Пример #3
0
        public ItemTag GenerateArmor(ArmorSlot slot)
        {
            ItemTag subItem = new ItemTag(this.Item, this.Amount);

            //Set the item type based on the slot
            subItem.Item = $"{ArmorType.ToString()}_{slot.ToString()}".ToLower();
            subItem.Name = Name.Replace("{slot}", $"{slot}");
            List <string> loreList = new List <string>();

            if (Lore != null)
            {
                foreach (var loreItem in Lore)
                {
                    loreList.Add(loreItem.Replace("{slot}", $"{slot}"));
                }
                subItem.Lore = loreList;
            }
            if (ColorData != null)
            {
                subItem.Colors = ColorData.GetColorForSlot(slot);
            }

            subItem.Enchants = Enchants?.Where(e => e.getEnchantCompatabilityWithSlot(slot)).ToList();
            return(subItem);
        }
Пример #4
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();
        }
Пример #5
0
        public MailAttachedItem(Item item, byte pos)
        {
            Position      = pos;
            AttachID      = (int)item.GetGUID().GetCounter();
            Item          = new ItemInstance(item);
            Count         = item.GetCount();
            Charges       = item.GetSpellCharges();
            MaxDurability = item.GetUInt32Value(ItemFields.MaxDurability);
            Durability    = item.GetUInt32Value(ItemFields.Durability);
            Unlocked      = !item.IsLocked();

            for (EnchantmentSlot slot = 0; slot < EnchantmentSlot.MaxInspected; slot++)
            {
                if (item.GetEnchantmentId(slot) == 0)
                {
                    continue;
                }

                Enchants.Add(new ItemEnchantData((int)item.GetEnchantmentId(slot), item.GetEnchantmentDuration(slot), (int)item.GetEnchantmentCharges(slot), (byte)slot));
            }

            byte i = 0;

            foreach (ItemDynamicFieldGems gemData in item.GetGems())
            {
                if (gemData.ItemId != 0)
                {
                    ItemGemData gem = new ItemGemData();
                    gem.Slot = i;
                    gem.Item = new ItemInstance(gemData);
                    Gems.Add(gem);
                }
                ++i;
            }
        }
Пример #6
0
        public InspectItemData(Item item, byte index)
        {
            CreatorGUID = item.GetCreator();

            Item   = new ItemInstance(item);
            Index  = index;
            Usable = true; // @todo

            for (EnchantmentSlot enchant = 0; enchant < EnchantmentSlot.Max; ++enchant)
            {
                uint enchId = item.GetEnchantmentId(enchant);
                if (enchId != 0)
                {
                    Enchants.Add(new InspectEnchantData(enchId, (byte)enchant));
                }
            }

            byte i = 0;

            foreach (SocketedGem gemData in item.m_itemData.Gems)
            {
                if (gemData.ItemId != 0)
                {
                    ItemGemData gem = new();
                    gem.Slot = i;
                    gem.Item = new ItemInstance(gemData);
                    Gems.Add(gem);
                }
                ++i;
            }

            AzeriteItem azeriteItem = item.ToAzeriteItem();

            if (azeriteItem != null)
            {
                SelectedAzeriteEssences essences = azeriteItem.GetSelectedAzeriteEssences();
                if (essences != null)
                {
                    for (byte slot = 0; slot < essences.AzeriteEssenceID.GetSize(); ++slot)
                    {
                        AzeriteEssenceData essence = new();
                        essence.Index            = slot;
                        essence.AzeriteEssenceID = essences.AzeriteEssenceID[slot];
                        if (essence.AzeriteEssenceID != 0)
                        {
                            essence.Rank         = azeriteItem.GetEssenceRank(essence.AzeriteEssenceID);
                            essence.SlotUnlocked = true;
                        }
                        else
                        {
                            essence.SlotUnlocked = azeriteItem.HasUnlockedEssenceSlot(slot);
                        }

                        AzeriteEssences.Add(essence);
                    }
                }
            }
        }
Пример #7
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;
            }
        }
Пример #8
0
        public EnchantInfo GetEnchant(string name)
        {
            EnchantInfo info;

            if (Enchants.TryGetValue(name, out info))
            {
                return(info);
            }
            return(null);
        }
Пример #9
0
 public void Stamp(IZone zone)
 {
     zone.GetAll.ForEach(p =>
     {
         IPlayable copy = Entity.FromCard(Controller, p.Card, null, null, p.Id);
         copy.Stamp(p as Entity);
         MoveTo(copy, ((Entity)copy).GetNativeGameTag(GameTag.ZONE_POSITION) - 1);
     });
     zone.Enchants.ForEach(p => Enchants.Add(p.Copy(p.SourceId, Game, p.Turn, Enchants, p.Owner, p.RemoveTriggers)));
     zone.Triggers.ForEach(p => Triggers.Add(p.Copy(p.SourceId, Game, p.Turn, Triggers, p.Owner)));
 }
Пример #10
0
 public void Stamp(IZone zone)
 {
     zone.GetAll.ToList().ForEach(p =>
     {
         IPlayable copy = Entity.FromCard(Controller, p.Card, null, null, p.Id);
         copy.Stamp(p as Entity);
         MoveTo(copy, copy.ZonePosition);
     });
     zone.Enchants.ForEach(p => Enchants.Add(p.Copy(p.SourceId, Game, p.Turn, Enchants, p.Owner, p.RemoveTriggers)));
     zone.Triggers.ForEach(p => Triggers.Add(p.Copy(p.SourceId, Game, p.Turn, Triggers, p.Owner)));
 }
Пример #11
0
        public override void Stamp(Zone <IPlayable> zone)
        {
            foreach (IPlayable p in zone)
            {
                IPlayable copy = p.Clone(Controller);
                Entities.Add(copy);
                copy.Zone = this;
            }

            zone.Enchants.ForEach(p => Enchants.Add(p.Copy(p.SourceId, Game, p.Turn, Enchants, p.Owner, p.RemoveTriggers)));
            zone.Triggers.ForEach(p => Triggers.Add(p.Copy(p.SourceId, Game, p.Turn, Triggers, p.Owner)));
        }
Пример #12
0
        public override void Stamp(Zone <T> zone)
        {
            foreach (T entity in zone)
            {
                var copy = (T)entity.Clone(Controller);
                copy.Zone        = this;
                Entities[_count] = copy;
                _count++;
            }

            zone.Enchants.ForEach(p => Enchants.Add(p.Copy(p.SourceId, Game, p.Turn, Enchants, p.Owner, p.RemoveTriggers)));
            zone.Triggers.ForEach(p => Triggers.Add(p.Copy(p.SourceId, Game, p.Turn, Triggers, p.Owner)));
        }
Пример #13
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());
        }
Пример #14
0
        private string getDataString()
        {
            List <string> dataParts = new List <string>();

            if (Enchants != null)
            {
                dataParts.AddRange(Enchants.Select(e => e.ToString()));
            }
            if (Colors != null)
            {
                dataParts.Add(Colors.ToString());
            }
            return(string.Join(";", dataParts));
        }
Пример #15
0
 private void ReadEnchants(SQLiteHelper db, HeroesTextHelper HeroesText)
 {
     using (DbDataReader reader2 = db.GetReader("SELECT * FROM EnchantInfo ORDER BY EnchantLevel;"))
     {
         while (reader2 != null && reader2.Read())
         {
             EnchantInfo info = new EnchantInfo(reader2, HeroesText);
             if (info.Class.EndsWith("_100"))
             {
                 continue;
             }
             if (!Enchants.ContainsKey(info.Class))
             {
                 Enchants.Add(info.Class, info);
             }
         }
     }
 }
Пример #16
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));
            }
        }
Пример #17
0
        public string getGiveCommand(string MinecraftUser, int Durability = 0)
        {
            var minecraftItem = new MojangItem();

            minecraftItem.Display = new Display()
            {
                Lore = this.Lore?.ToArray(), Name = Name
            };
            minecraftItem.Enchants = Enchants?.AsMojang();
            //var mineString = JObject.FromObject(minecrafItem).ToString();
            //mineString = mineString.Replace("\r\n", "");
            //mineString = mineString.Replace("  ", "");
            var jsonSerializer = new JsonSerializer();
            var writer         = new StringWriter();

            using (JsonTextWriter jsonWriter = new JsonTextWriter(writer))
            {
                jsonWriter.QuoteName = false;
                jsonSerializer.Serialize(jsonWriter, minecraftItem);
            }

            return($"give {MinecraftUser} {Item} {Amount} {Durability} {writer.ToString()}");
        }
Пример #18
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());
        }
Пример #19
0
        /// <summary>
        /// A copy constructor. This constructor is only used to the inherited copy constructors.
        /// </summary>
        /// <param name="game"><see cref="Model.Game"/> instance of a copied entity.</param>
        /// <param name="entity">A source <see cref="Entity"/>.</param>
        protected Entity(Game game, Entity entity)
        {
            Game        = game;
            _data       = new EntityData(entity._data);
            Id          = entity.Id;
            OrderOfPlay = entity.OrderOfPlay;


            if (game == null)
            {
                return;
            }

            for (int i = 0; i < entity.Enchants.Count; i++)
            {
                Enchant p = entity.Enchants[i];
                Enchants.Add(p.Copy(p.SourceId, Game, p.Turn, Enchants, p.Owner, p.RemoveTriggers));
            }
            for (int i = 0; i < entity.Triggers.Count; i++)
            {
                Trigger p = entity.Triggers[i];
                Triggers.Add(p.Copy(p.SourceId, Game, p.Turn, Triggers, p.Owner));
            }
        }
Пример #20
0
 /// <summary>
 /// All gametag values that where changed after creation are wiped.
 /// Any enchants and trigger is removed.
 /// </summary>
 public virtual void Reset()
 {
     _data.Reset();
     Enchants.Clear();
     Triggers.Clear();
 }