public LeaveAllianceOkMessage(Client client, Alliance alliance)
            : base(client)
        {
            SetMessageType(24111);

            m_vServerCommandType = 0x02;
            m_vAlliance = alliance;
        }
 public static Alliance CreateAlliance(long seed)
 {
     Alliance alliance;
     lock (m_vDatabaseLock)
     {
         if (seed == 0)
             seed = m_vAllianceSeed;
         alliance = new Alliance(seed);
         m_vAllianceSeed++;
     }
     m_vDatabase.CreateAlliance(alliance);
     m_vAlliances.Add(alliance.GetAllianceId(), alliance);
     return alliance;
 }
 public void CreateAlliance(Alliance a)
 {
     try
     {
         Debugger.WriteLine("Saving new Alliance to database (alliance id: " + a.GetAllianceId() + ")");
         using (var db = new Database.ucsdbEntities(m_vConnectionString))
         {
             db.clan.Add(
                 new Database.clan
                 {
                     ClanId = a.GetAllianceId(),
                     LastUpdateTime = DateTime.Now,
                     Data = a.SaveToJSON()
                 }
             );
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         Debugger.WriteLine("An exception occured during CreateAlliance processing:", ex);
     }
 }
Exemple #4
0
        public byte[] Encode()
        {
            List <byte> list = new List <byte>();

            list.AddInt64(this.GetId());
            list.AddRange(new byte[]
            {
                1,
                1,
                132,
                165,
                29,
                145,
                159,
                42,
                155,
                158,
                235,
                241,
                10,
                0,
                3,
                8,
                128,
                234,
                229,
                24,
                129,
                234,
                229,
                24,
                141,
                234,
                229,
                24,
                129,
                252,
                217,
                26,
                128,
                252,
                217,
                26,
                131,
                234,
                229,
                24,
                142,
                234,
                229,
                24,
                140,
                234,
                229,
                24,
                8,
                128,
                234,
                229,
                24,
                129,
                234,
                229,
                24,
                141,
                234,
                229,
                24,
                129,
                252,
                217,
                26,
                128,
                252,
                217,
                26,
                131,
                234,
                229,
                24,
                0,
                0,
                8,
                128,
                234,
                229,
                24,
                129,
                234,
                229,
                24,
                141,
                234,
                229,
                24,
                129,
                252,
                217,
                26,
                128,
                252,
                217,
                26,
                131,
                234,
                229,
                24,
                0,
                0,
                255
            });
            list.AddRange(new byte[]
            {
                26,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                26,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                26,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                26,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                26,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                26,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                26,
                0,
                0,
                134,
                173,
                155,
                0,
                0,
                0,
                0,
                0,
                26,
                0,
                0,
                183,
                173,
                155,
                0,
                1,
                0,
                0,
                0,
                1,
                26,
                0,
                12,
                156,
                174,
                155,
                23,
                1
            });
            list.AddRange(new byte[]
            {
                0,
                0,
                2,
                0,
                0,
                4,
                7,
                19,
                6,
                0,
                1,
                6,
                0,
                0,
                152,
                137,
                35,
                128,
                148,
                35,
                156,
                195,
                235,
                240,
                10,
                0,
                0,
                127,
                0,
                0,
                0,
                0,
                0,
                127,
                0,
                0,
                0,
                127,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                2,
                2,
                54,
                1,
                251,
                241,
                245
            });
            list.AddRange(new byte[]
            {
                193,
                3,
                3,
                3,
                148,
                186,
                34,
                148,
                186,
                34,
                249,
                191,
                236,
                240,
                10,
                3
            });
            list.AddRange(new byte[]
            {
                28,
                2,
                0,
                28,
                0,
                0,
                26,
                27,
                0
            });
            list.AddRange(new byte[]
            {
                0,
                0,
                127,
                0,
                0,
                127,
                1,
                0,
                0,
                2,
                163,
                23,
                12,
                1,
                170,
                2,
                0,
                0,
                0,
                0,
                0,
                38,
                128,
                215,
                176,
                1,
                38,
                128,
                215,
                176,
                1,
                38,
                128,
                215,
                177,
                1
            });
            list.AddString(this.GetAvatarName());
            list.Add(this.GetNameSet());
            list.AddRange(new byte[]
            {
                0,
                54,
                2
            });
            list.AddRange(Message.AddVInt(this.GetScore()));
            list.Add(1);
            list.Add(0);
            list.Add(0);
            list.Add(0);
            list.Add(0);
            list.AddRange(Message.AddVInt(this.GetAvatarLevel()));
            list.AddRange(Message.AddVInt(this.GetScore()));
            list.AddRange(Message.AddVInt(this.GetScore()));
            list.Add(4);
            list.Add(6);
            list.Add(5);
            list.Add(5);
            list.Add(1);
            list.AddRange(Message.AddVInt(500000));
            list.Add(5);
            list.Add(2);
            list.Add(7);
            list.Add(5);
            list.Add(3);
            list.Add(10);
            List <ClientAvatar.CrownChests> chests = this.GetChests();

            if (chests.Count > 0)
            {
                using (List <ClientAvatar.CrownChests> .Enumerator enumerator = chests.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ClientAvatar.CrownChests current = enumerator.Current;
                        list.Add(current.ressources);
                        list.Add(current.stars);
                        list.Add(current.crown);
                    }
                    goto IL_207;
                }
            }
            list.Add(5);
            list.Add(4);
            list.Add(0);
IL_207:
            list.Add(5);
            list.Add(5);
            list.AddRange(Message.AddVInt(500000));
            list.AddRange(new byte[]
            {
                0,
                7,
                60,
                7,
                9,
                60,
                8,
                9,
                60,
                9,
                9,
                60,
                4,
                1,
                60,
                5,
                1,
                60,
                6,
                1,
                60,
                10,
                1,
                1,
                60,
                10,
                1,
                1,
                5,
                8,
                9,
                7
            });
            list.AddRange(new byte[]
            {
                26,
                0,
                11,
                26,
                1,
                8,
                26,
                3,
                9,
                26,
                13,
                13,
                26,
                14,
                6,
                28,
                0,
                2,
                26,
                12,
                4
            });
            list.AddRange(Message.AddVInt(this.GetDiamonds()));
            list.Add(10);
            list.AddRange(Message.AddVInt(this.GetExperience()));
            list.Add((byte)this.GetAvatarLevel());
            list.Add(1);
            if (this.GetAllianceId() != 0L)
            {
                Alliance alliance = ObjectManager.GetAlliance(this.GetAllianceId());
                list.Add(1);
                list.AddRange(Message.AddVInt(1));
                list.AddRange(Message.AddVInt(1));
                list.AddString(alliance.GetAllianceName());
                list.Add(0);
                list.Add(1);
            }
            else
            {
                list.Add(0);
            }
            return(list.ToArray());
        }
 public AllianceDataMessage(Client client, Alliance alliance)
     : base(client)
 {
     SetMessageType(24301);
     m_vAlliance = alliance;
 }
Exemple #6
0
        public byte[] Encode()
        {
            List <Byte> data = new List <Byte>();

            data.AddInt32(0);
            data.AddInt64(m_vId);
            data.AddInt64(m_vCurrentHomeId);
            if (m_vAllianceId != 0)
            {
                data.Add(1);
                data.AddInt64(m_vAllianceId);
                Alliance alliance = ObjectManager.GetAlliance(m_vAllianceId);
                data.AddString(alliance.GetAllianceName());
                data.AddInt32(alliance.GetAllianceBadgeData());
                data.AddInt32(alliance.GetAllianceMember(m_vId).GetRole());
                data.AddInt32(alliance.GetAllianceLevel());
                data.Add(0);
                data.AddInt32(0);
            }
            else
            {
                data.Add(0);
                data.AddInt32(0);
            }

            //7.156
            data.AddInt32(0);
            data.AddInt32(0);
            data.AddInt32(0);
            data.AddInt32(0);
            data.AddInt32(0);
            data.AddInt32(0);
            data.AddInt32(0);
            data.AddInt32(0);
            data.AddInt32(0);
            data.AddInt32(0);
            data.AddInt32(m_vLeagueId);//league

            data.AddInt32(GetAllianceCastleLevel());
            data.AddInt32(GetAllianceCastleTotalCapacity());
            data.AddInt32(GetAllianceCastleUsedCapacity());
            data.AddInt32(GetTownHallLevel());
            data.AddString(m_vAvatarName);
            data.AddInt32(-1);
            data.AddInt32(m_vAvatarLevel);
            data.AddInt32(m_vExperience);
            data.AddInt32(m_vCurrentGems);
            data.AddInt32(m_vCurrentGems); //FreeDiamonds
            data.AddInt32(0x04B0);
            data.AddInt32(0x003C);
            data.AddInt32(m_vScore);

            data.AddRange(new byte[] {
                0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00,
                0x01,
                0x00, 0x00, 0x00, 0xDC, 0x6C, 0xF5, 0xEB, 0x48
            });

            data.Add(m_vIsAvatarNameSet);
            data.AddInt32(0); //Cumulative Purchased Diamonds
            data.AddInt32(0);

            //7.65
            data.AddInt32(0);

            //7.1
            data.AddInt32(1);

            data.AddDataSlots(GetResourceCaps());
            data.AddDataSlots(GetResources());
            data.AddDataSlots(GetUnits());
            data.AddDataSlots(GetSpells());
            data.AddDataSlots(m_vUnitUpgradeLevel);
            data.AddDataSlots(m_vSpellUpgradeLevel);
            data.AddDataSlots(m_vHeroUpgradeLevel);
            data.AddDataSlots(m_vHeroHealth);
            data.AddDataSlots(m_vHeroState);

            data.AddRange(BitConverter.GetBytes(AllianceUnits.Count).Reverse());
            foreach (DataSlot u in AllianceUnits)
            {
                data.AddRange(BitConverter.GetBytes(u.Data.GetGlobalID()).Reverse());
                data.AddRange(BitConverter.GetBytes(u.Value).Reverse());
                data.AddRange(BitConverter.GetBytes(0).Reverse());//A CHANGER
            }

            data.AddRange(BitConverter.GetBytes(TutorialStepsCount).Reverse());
            for (uint i = 0; i < TutorialStepsCount; i++)
            {
                data.AddRange(BitConverter.GetBytes(0x01406F40 + i).Reverse());
            }

            //Unlocked Achievements
            data.AddRange(BitConverter.GetBytes(Achievements.Count).Reverse());
            foreach (DataSlot a in Achievements)
            {
                data.AddRange(BitConverter.GetBytes(a.Data.GetGlobalID()).Reverse());
            }

            //Achievement Progress
            data.AddRange(BitConverter.GetBytes(Achievements.Count).Reverse());
            foreach (DataSlot a in Achievements)
            {
                data.AddRange(BitConverter.GetBytes(a.Data.GetGlobalID()).Reverse());
                data.AddRange(BitConverter.GetBytes(0).Reverse());//A CHANGER
            }

            data.AddDataSlots(NpcStars);
            data.AddDataSlots(NpcLootedGold);
            data.AddDataSlots(NpcLootedElixir);

            //7.65
            data.AddInt32(0);

            return(data.ToArray());
        }
        public Alliance GetAlliance(long allianceId)
        {
            Alliance alliance = null;
            try
            {
                using (var db = new Database.ucsdbEntities(m_vConnectionString))
                {
                    var p = db.clan.Find(allianceId);

                    //Check if player exists
                    if (p != null)
                    {
                        alliance = new Alliance();
                        alliance.LoadFromJSON(p.Data);
                    }
                }
            }
            catch (Exception ex)
            {
                Debugger.WriteLine("An exception occured during GetAlliance processing:", ex);
            }
            return alliance;
        }
 public AllianceStreamMessage(Client client, Alliance alliance)
     : base(client)
 {
     SetMessageType(24311);
     m_vAlliance = alliance;
 }
 public void SetAlliance(Alliance alliance)
 {
     m_vAlliance = alliance;
 }
Exemple #10
0
        public async Task <byte[]> Encode()
        {
            try
            {
                Random      rnd  = new Random();
                List <byte> data = new List <byte>();
                data.AddLong(this.UserId);
                data.AddLong(this.CurrentHomeId);
                if (this.AllianceId != 0)
                {
                    data.Add(1);
                    data.AddLong(this.AllianceId);
                    Alliance alliance = ObjectManager.GetAlliance(this.AllianceId);
                    data.AddString(alliance.m_vAllianceName);
                    data.AddInt(alliance.m_vAllianceBadgeData);
                    data.AddInt(alliance.m_vAllianceMembers[this.UserId].Role);
                    data.AddInt(alliance.m_vAllianceLevel);
                }
                data.Add(0);

                if (m_vLeagueId == 22)
                {
                    data.AddInt(m_vScore / 12);
                    data.AddInt(1);
                    int month = DateTime.Now.Month;
                    data.AddInt(month);
                    data.AddInt(DateTime.Now.Year);
                    data.AddInt(rnd.Next(1, 10));
                    data.AddInt(this.m_vScore);
                    data.AddInt(1);
                    if (month == 1)
                    {
                        data.AddInt(12);
                        data.AddInt(DateTime.Now.Year - 1);
                    }
                    else
                    {
                        data.AddInt(month - 1);
                        data.AddInt(DateTime.Now.Year);
                    }
                    data.AddInt(rnd.Next(1, 10));
                    data.AddInt(this.m_vScore / 2);
                }
                else
                {
                    data.AddInt(0); //1
                    data.AddInt(0); //2
                    data.AddInt(0); //3
                    data.AddInt(0); //4
                    data.AddInt(0); //5
                    data.AddInt(0); //6
                    data.AddInt(0); //7
                    data.AddInt(0); //8
                    data.AddInt(0); //9
                    data.AddInt(0); //10
                    data.AddInt(0); //11
                }

                data.AddInt(this.m_vLeagueId);
                data.AddInt(GetAllianceCastleLevel());
                data.AddInt(GetAllianceCastleTotalCapacity());
                data.AddInt(GetAllianceCastleUsedCapacity());
                data.AddInt(0);
                data.AddInt(-1);
                data.AddInt(m_vTownHallLevel);
                data.AddString(this.AvatarName);
                data.AddString(this.FacebookId);
                data.AddInt(this.m_vAvatarLevel);
                data.AddInt(this.m_vExperience);
                data.AddInt(this.m_vCurrentGems);
                data.AddInt(this.m_vCurrentGems);
                data.AddInt(1200);
                data.AddInt(60);
                data.AddInt(m_vScore);
                data.AddInt(200); // Attack Wins
                data.AddInt(m_vDonated);
                data.AddInt(100); // Attack Loses
                data.AddInt(m_vReceived);

                data.AddInt(this.m_vAlliance_Gold);
                data.AddInt(this.m_vAlliance_Elixir);
                data.AddInt(this.m_vAlliance_DarkElixir);
                data.AddInt(0);
                data.Add(1);
                data.AddLong(946720861000);

                data.Add(this.m_vnameChosenByUser);

                data.AddInt(0);
                data.AddInt(0);
                data.AddInt(0);
                data.AddInt(1);

                data.AddInt(0);
                data.AddInt(0);
                data.Add(0);
                data.AddDataSlots(GetResourceCaps());
                data.AddDataSlots(GetResources());
                data.AddDataSlots(GetUnits());
                data.AddDataSlots(GetSpells());
                data.AddDataSlots(m_vUnitUpgradeLevel);
                data.AddDataSlots(m_vSpellUpgradeLevel);
                data.AddDataSlots(m_vHeroUpgradeLevel);
                data.AddDataSlots(m_vHeroHealth);
                data.AddDataSlots(m_vHeroState);

                data.AddRange(BitConverter.GetBytes(AllianceUnits.Count).Reverse());
                foreach (DonationSlot u in AllianceUnits)
                {
                    data.AddInt(u.ID);
                    data.AddInt(u.Count);
                    data.AddInt(u.UnitLevel);
                }

                data.AddRange(BitConverter.GetBytes(TutorialStepsCount).Reverse());
                for (uint i = 0; i < TutorialStepsCount; i++)
                {
                    data.AddRange(BitConverter.GetBytes(0x01406F40 + i).Reverse());
                }

                data.AddRange(BitConverter.GetBytes(Achievements.Count).Reverse());
                foreach (var a in Achievements)
                {
                    data.AddRange(BitConverter.GetBytes(a.Data.GetGlobalID()).Reverse());
                }

                data.AddRange(BitConverter.GetBytes(Achievements.Count).Reverse());
                foreach (var a in Achievements)
                {
                    data.AddRange(BitConverter.GetBytes(a.Data.GetGlobalID()).Reverse());
                    data.AddRange(BitConverter.GetBytes(0).Reverse());
                }

                data.AddRange(BitConverter.GetBytes(ObjectManager.NpcLevels.Count).Reverse());
                {
                    for (var i = 17000000; i < 17000050; i++)
                    {
                        data.AddRange(BitConverter.GetBytes(i).Reverse());
                        data.AddRange(BitConverter.GetBytes(rnd.Next(3, 3)).Reverse());
                    }
                }

                data.AddDataSlots(NpcLootedGold);
                data.AddDataSlots(NpcLootedElixir);
                data.AddDataSlots(new List <DataSlot>());
                data.AddDataSlots(new List <DataSlot>());
                data.AddDataSlots(new List <DataSlot>());
                data.AddDataSlots(new List <DataSlot>());

                data.AddInt(QuickTrain1.Count);
                foreach (var i in QuickTrain1)
                {
                    data.AddInt(i.Data.GetGlobalID());
                    data.AddInt(i.Value);
                }

                data.AddInt(QuickTrain2.Count);
                foreach (var i in QuickTrain2)
                {
                    data.AddInt(i.Data.GetGlobalID());
                    data.AddInt(i.Value);
                }
                data.AddInt(QuickTrain3.Count);
                foreach (var i in QuickTrain3)
                {
                    data.AddInt(i.Data.GetGlobalID());
                    data.AddInt(i.Value);
                }
                data.AddInt(QuickTrain1.Count);
                foreach (var i in QuickTrain1)
                {
                    data.AddInt(i.Data.GetGlobalID());
                    data.AddInt(i.Value);
                }
                data.AddDataSlots(new List <DataSlot>());
                return(data.ToArray());
            } catch (Exception) { return(null); }
        }