internal override void Encode(List <byte> Packet)
        {
            base.Encode(Packet);

            Packet.AddInt(this.LowId);
            Packet.AddInt(this.MaxTroop);
            Packet.AddInt(this.MaxSpell);
            Packet.AddInt(this.UsedTroop);
            Packet.AddInt(this.UsedSpell);

            this.New = true;


            Packet.AddInt(0);

            /*var requestorDonatedUnit = this.Units.FindAll(T => T.DonatorId == this.RequesterId);
             *
             * if (requestorDonatedUnit.Count > 0)
             * {
             *  Packet.AddInt(1);
             *  Packet.AddLong(this.RequesterId);
             *
             *  Packet.AddInt(requestorDonatedUnit.Sum(unit => unit.Count));
             *
             *  foreach (UnitItem Unit in requestorDonatedUnit)
             *  {
             *      for (int i = 0; i < Unit.Count; i++)
             *      {
             *          Packet.AddInt(Unit.Data);
             *          Packet.AddInt(Unit.Level);
             *      }
             *  }
             * }
             * else
             * {
             *  Packet.AddInt(0);
             * }*/

            Packet.AddBool(this.HaveMessage);
            if (this.HaveMessage)
            {
                Packet.AddString(this.Message);
            }

            if (this.Units == null)
            {
                this.Units = new AllianceUnitSlots();
            }

            UnitItem[] donatedUnits = this.Units.ToArray();

            Packet.AddInt(donatedUnits.Length);

            foreach (UnitItem donatedUnit in donatedUnits)
            {
                Packet.AddInt(donatedUnit.Data);
                Packet.AddInt(donatedUnit.Count);
                Packet.AddInt(donatedUnit.Level);
            }
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlayerBase"/> class.
        /// </summary>
        public PlayerBase()
        {
            this.AchievementProgress = new DataSlots();
            this.ResourceCaps        = new DataSlots();
            this.Resources           = new ResourceSlots();
            this.Units         = new UnitSlots();
            this.Units2        = new UnitSlots();
            this.Spells        = new DataSlots();
            this.UnitUpgrades  = new DataSlots();
            this.SpellUpgrades = new DataSlots();
            this.HeroUpgrades  = new DataSlots();
            this.AllianceUnits = new AllianceUnitSlots();

            this.NpcMapProgress  = new NpcMapSlots();
            this.NpcLootedGold   = new DataSlots();
            this.NpcLootedElixir = new DataSlots();

            this.Variables = new DataSlots();
        }
        internal override void Load(JToken Json)
        {
            base.Load(Json);

            string Message;

            if (JsonHelper.GetJsonString(Json, "message", out Message))
            {
                this.Message     = Message;
                this.HaveMessage = true;
            }
            else
            {
                this.Message     = string.Empty;
                this.HaveMessage = false;
            }

            JsonHelper.GetJsonNumber(Json, "max_troop", out this.MaxTroop);
            JsonHelper.GetJsonNumber(Json, "max_spell", out this.MaxSpell);
            JsonHelper.GetJsonNumber(Json, "used_troop", out this.UsedTroop);
            JsonHelper.GetJsonNumber(Json, "used_spell", out this.UsedSpell);

            JArray units = (JArray)Json["units"];

            if (units != null)
            {
                if (this.Units != null)
                {
                    this.Units.Load(units);
                }
                else
                {
                    this.Units = new AllianceUnitSlots();
                    this.Units.Load(units);
                }
            }
        }
 public DonateStreamEntry(Member Member) : base(Member)
 {
     this.Units = new AllianceUnitSlots();
 }
        internal int UsedTroopSend; //Do not save this

        public DonateStreamEntry()
        {
            this.Units = new AllianceUnitSlots();
        }