Example #1
0
        public async Task AvatarRankingEntry(MemoryStream stream)
        {
            await stream.WriteIntAsync(ExpLevel);                           // Exp Level

            await stream.WriteIntAsync(0);                                  // Attack Win Count

            await stream.WriteIntAsync(0);                                  // Attack Lose Count

            await stream.WriteIntAsync(0);                                  // Defense Win Count

            await stream.WriteIntAsync(0);                                  // Defense Lose Count

            await stream.WriteIntAsync(LogicUtils.GetLeagueByScore(Score)); // League Type

            await stream.WriteStringAsync(Language);                        // Country

            await stream.WriteLongAsync(AccountId);                         // Home Id

            if (AllianceId > 0)
            {
                var alliance = await Resources.AllianceCache.GetAlliance(AllianceId);

                if (alliance != null)
                {
                    stream.WriteByte(1);
                    await stream.WriteLongAsync(AllianceId);      // Clan Id

                    await stream.WriteStringAsync(alliance.Name); // Clan Name

                    await stream.WriteIntAsync(alliance.Badge);   // Badge
                }
                else
                {
                    AllianceId = 0;
                    stream.WriteByte(0);
                }
            }
            else
            {
                stream.WriteByte(0);
            }
        }
Example #2
0
        public ReplayProfile GetReplayProfile(bool attacker)
        {
            var profile = new ReplayProfile
            {
                Name          = Name,
                Score         = Score,
                League        = LogicUtils.GetLeagueByScore(Score),
                TownHallLevel = LogicGameObjectManager.GetTownHallLevel(),
                CastleLevel   = 1,
                CastleTotal   = 15,
                CastleUsed    = 0,
                BadgeId       = 13000000,
                AllianceName  = "RetroClash"
            };

            foreach (var troop in Units.Troops)
            {
                if (troop.Count > 0)
                {
                    profile.Units.Add(new ReplayUnitItem
                    {
                        Id  = troop.Id,
                        Cnt = troop.Count
                    });
                }
            }

            foreach (var spell in Units.Spells)
            {
                if (spell.Count > 0)
                {
                    profile.Spells.Add(new ReplayUnitItem
                    {
                        Id  = spell.Id,
                        Cnt = spell.Count
                    });
                }
            }

            foreach (var unit in Units.Troops)
            {
                profile.UnitUpgrades.Add(new ReplayUnitItem
                {
                    Id  = unit.Id,
                    Cnt = unit.Level
                });
            }

            foreach (var spell in Units.Spells)
            {
                profile.SpellUpgrades.Add(new ReplayUnitItem
                {
                    Id  = spell.Id,
                    Cnt = spell.Level
                });
            }

            if (attacker)
            {
                foreach (var resource in ResourcesManager)
                {
                    profile.Resources.Add(new ReplayUnitItem
                    {
                        Id  = resource.Id,
                        Cnt = resource.Value
                    });
                }
            }

            foreach (var hero in HeroManager)
            {
                profile.HeroStates.Add(new ReplayUnitItem
                {
                    Id  = hero.Id,
                    Cnt = hero.State
                });
            }

            foreach (var hero in HeroManager)
            {
                profile.HeroHealth.Add(new ReplayUnitItem
                {
                    Id  = hero.Id,
                    Cnt = hero.Health
                });
            }

            foreach (var hero in HeroManager)
            {
                profile.HeroUpgrade.Add(new ReplayUnitItem
                {
                    Id  = hero.Id,
                    Cnt = hero.Level
                });
            }

            return(profile);
        }
Example #3
0
        public async Task LogicClientAvatar(MemoryStream stream)
        {
            await stream.WriteIntAsync(0);

            await stream.WriteLongAsync(AccountId); // Account Id

            await stream.WriteLongAsync(AccountId); // Home Id

            if (AllianceId > 0)
            {
                var alliance = await Resources.AllianceCache.GetAlliance(AllianceId);

                if (alliance != null)
                {
                    stream.WriteByte(1);
                    await stream.WriteLongAsync(AllianceId);      // Alliance Id

                    await stream.WriteStringAsync(alliance.Name); // Alliance Name

                    await stream.WriteIntAsync(alliance.Badge);   // Alliance Badge

                    await stream.WriteIntAsync(alliance.Members.Find(x => x.AccountId == AccountId)
                                               .Role); // Alliance Role

                    stream.WriteByte(1);
                    await stream.WriteLongAsync(AllianceId); // Alliance Id

                    stream.WriteByte(1);
                    await stream.WriteLongAsync(AllianceId); // Alliance Id
                }
                else
                {
                    stream.WriteByte(0);
                }
            }
            else
            {
                stream.WriteByte(0);
            }

            await stream.WriteIntAsync(LogicUtils.GetLeagueByScore(Score)); // League Type

            await stream.WriteIntAsync(0);                                  // Alliance Castle Level

            await stream.WriteIntAsync(10);                                 // Alliance Total Capacity

            await stream.WriteIntAsync(0);                                  // Alliance Used Capacity

            await stream.WriteIntAsync(2);                                  // Townhall Level

            await stream.WriteStringAsync(Name);                            // Name

            await stream.WriteStringAsync(null);                            // Facebook Id

            await stream.WriteIntAsync(ExpLevel);                           // Exp Level

            await stream.WriteIntAsync(0);                                  // Exp Points

            await stream.WriteIntAsync(100000000);                          // Diamonts

            await stream.WriteIntAsync(0);                                  // Current Diamonts

            await stream.WriteIntAsync(0);                                  // Free Diamonts

            await stream.WriteIntAsync(0);                                  // Unknown

            await stream.WriteIntAsync(Score);                              // Score

            await stream.WriteIntAsync(0);                                  // Attack Win Count

            await stream.WriteIntAsync(0);                                  // Attack Lose Count

            await stream.WriteIntAsync(0);                                  // Defense Win Count

            await stream.WriteIntAsync(0);                                  // Defense Lose Count

            stream.WriteByte(0);                                            // Name Set By User (bool)
            await stream.WriteIntAsync(0);

            await stream.WriteIntAsync(0);          // Resource Caps Count

            await stream.WriteIntAsync(3);          // Resource DataSlot Count

            await stream.WriteIntAsync(3000001);    // Gold

            await stream.WriteIntAsync(1000000000); // Count

            await stream.WriteIntAsync(3000002);    // Elixir

            await stream.WriteIntAsync(1000000000); // Count

            await stream.WriteIntAsync(3000003);    // Dark Elixir

            await stream.WriteIntAsync(100000000);  // Count

            // Troops
            await stream.WriteIntAsync(Units.Troops.Count);

            foreach (var troop in Units.Troops)
            {
                await stream.WriteIntAsync(troop.Id);

                await stream.WriteIntAsync(troop.Count);
            }

            // Spells
            await stream.WriteIntAsync(Units.Spells.Count);

            foreach (var spell in Units.Spells)
            {
                await stream.WriteIntAsync(spell.Id);

                await stream.WriteIntAsync(spell.Count);
            }

            // Troop Levels
            await stream.WriteIntAsync(Units.Troops.Count);

            foreach (var troop in Units.Troops)
            {
                await stream.WriteIntAsync(troop.Id);

                await stream.WriteIntAsync(troop.Level);
            }

            // Spell Levels
            await stream.WriteIntAsync(Units.Spells.Count);

            foreach (var spell in Units.Spells)
            {
                await stream.WriteIntAsync(spell.Id);

                await stream.WriteIntAsync(spell.Level);
            }

            await stream.WriteIntAsync(HeroManager.Count); // Hero Upgrade DataSlot Count

            foreach (var hero in HeroManager)
            {
                await stream.WriteIntAsync(hero.Id);

                await stream.WriteIntAsync(hero.Level);
            }

            await stream.WriteIntAsync(HeroManager.Count); // Hero Health DataSlot Count

            foreach (var hero in HeroManager)
            {
                await stream.WriteIntAsync(hero.Id);

                await stream.WriteIntAsync(hero.Health);
            }

            await stream.WriteIntAsync(HeroManager.Count); // Hero State DataSlot Count

            foreach (var hero in HeroManager)
            {
                await stream.WriteIntAsync(hero.Id);

                await stream.WriteIntAsync(hero.State);
            }

            await stream.WriteIntAsync(0);             // Alliance Unit DataSlot Count

            await stream.WriteIntAsync(TutorialSteps); // TutorialSteps

            for (var index = 21000000; index < 21000000 + TutorialSteps; index++)
            {
                await stream.WriteIntAsync(index);
            }

            await stream.WriteIntAsync(Achievements.Count);

            foreach (var achievement in Achievements)
            {
                await stream.WriteIntAsync(achievement.Id);
            }

            await stream.WriteIntAsync(Achievements.Count); // Achievement Progress DataSlot Count

            foreach (var achievement in Achievements)
            {
                await stream.WriteIntAsync(achievement.Id);

                await stream.WriteIntAsync(achievement.Data);
            }

            await stream.WriteIntAsync(50); // Npc Map Progress DataSlot Count

            for (var index = 17000000; index < 17000050; index++)
            {
                await stream.WriteIntAsync(index);

                await stream.WriteIntAsync(3);
            }

            await stream.WriteIntAsync(0); // Npc Looted Gold DataSlot

            await stream.WriteIntAsync(0); // Npc Looted Elixir DataSlot
        }
Example #4
0
        public async Task LogicClientAvatar(MemoryStream stream)
        {
            await stream.WriteInt(0);

            await stream.WriteLong(AccountId); // Account Id

            await stream.WriteLong(AccountId); // Home Id

            if (AllianceId > 0)
            {
                var alliance = await Resources.AllianceCache.GetAlliance(AllianceId);

                if (alliance != null)
                {
                    stream.WriteBool(true);
                    await stream.WriteLong(AllianceId);      // Alliance Id

                    await stream.WriteString(alliance.Name); // Alliance Name

                    await stream.WriteInt(alliance.Badge);   // Alliance Badge

                    await stream.WriteInt(alliance.Members.Find(x => x.AccountId == AccountId)
                                          .Role); // Alliance Role

                    stream.WriteByte(1);
                    await stream.WriteLong(AllianceId); // Alliance Id

                    stream.WriteByte(1);
                    await stream.WriteLong(AllianceId); // Alliance Id
                }
                else
                {
                    stream.WriteBool(false);
                }
            }
            else
            {
                stream.WriteBool(false);
            }

            await stream.WriteInt(LogicUtils.GetLeagueByScore(Score));              // League Type

            await stream.WriteInt(0);                                               // Alliance Castle Level

            await stream.WriteInt(10);                                              // Alliance Total Capacity

            await stream.WriteInt(0);                                               // Alliance Used Capacity

            await stream.WriteInt(LogicGameObjectManager?.GetTownHallLevel() ?? 1); // Townhall Level

            await stream.WriteString(Name);                                         // Name

            await stream.WriteString(null);                                         // Facebook Id

            await stream.WriteInt(ExpLevel);                                        // Exp Level

            await stream.WriteInt(ExpPoints);                                       // Exp Points

            await stream.WriteInt(Diamonds);                                        // Diamonts

            await stream.WriteInt(0);                                               // Current Diamonts

            await stream.WriteInt(0);                                               // Free Diamonts

            await stream.WriteInt(0);                                               // Unknown

            await stream.WriteInt(Score);                                           // Score

            await stream.WriteInt(0);                                               // Attack Win Count

            await stream.WriteInt(0);                                               // Attack Lose Count

            await stream.WriteInt(0);                                               // Defense Win Count

            await stream.WriteInt(0);                                               // Defense Lose Count

            stream.WriteBool(false);                                                // Name Set By User
            await stream.WriteInt(0);

            // Resource Caps
            await stream.WriteInt(0);

            // Resources
            await stream.WriteInt(ResourcesManager.Count);

            foreach (var resource in ResourcesManager)
            {
                await stream.WriteInt(resource.Id);

                await stream.WriteInt(resource.Value);
            }

            // Troops
            await stream.WriteInt(Units.Troops.Count);

            foreach (var troop in Units.Troops)
            {
                await stream.WriteInt(troop.Id);

                await stream.WriteInt(troop.Count);
            }

            // Spells
            await stream.WriteInt(Units.Spells.Count);

            foreach (var spell in Units.Spells)
            {
                await stream.WriteInt(spell.Id);

                await stream.WriteInt(spell.Count);
            }

            // Troop Levels
            await stream.WriteInt(Units.Troops.Count);

            foreach (var troop in Units.Troops)
            {
                await stream.WriteInt(troop.Id);

                await stream.WriteInt(troop.Level);
            }

            // Spell Levels
            await stream.WriteInt(Units.Spells.Count);

            foreach (var spell in Units.Spells)
            {
                await stream.WriteInt(spell.Id);

                await stream.WriteInt(spell.Level);
            }

            // Hero Levels
            await stream.WriteInt(HeroManager.Count);

            foreach (var hero in HeroManager)
            {
                await stream.WriteInt(hero.Id);

                await stream.WriteInt(hero.Level);
            }

            // Hero Health
            await stream.WriteInt(HeroManager.Count);

            foreach (var hero in HeroManager)
            {
                await stream.WriteInt(hero.Id);

                await stream.WriteInt(hero.Health);
            }

            // Hero State
            await stream.WriteInt(HeroManager.Count);

            foreach (var hero in HeroManager)
            {
                await stream.WriteInt(hero.Id);

                await stream.WriteInt(hero.State);
            }

            // Alliance Units
            await stream.WriteInt(0);

            // Tutorials
            await stream.WriteInt(TutorialSteps);

            for (var index = 21000000; index < 21000000 + TutorialSteps; index++)
            {
                await stream.WriteInt(index);
            }

            // Achievements
            await stream.WriteInt(Achievements.Count);

            foreach (var achievement in Achievements)
            {
                await stream.WriteInt(achievement.Id);
            }

            // Achievement Progress
            await stream.WriteInt(Achievements.Count);

            foreach (var achievement in Achievements)
            {
                await stream.WriteInt(achievement.Id);

                await stream.WriteInt(achievement.Data);
            }

            // Npc Map Progress
            await stream.WriteInt(50);

            for (var index = 17000000; index < 17000050; index++)
            {
                await stream.WriteInt(index);

                await stream.WriteInt(3);
            }

            await stream.WriteInt(0); // Npc Looted Gold DataSlot

            await stream.WriteInt(0); // Npc Looted Elixir DataSlot
        }