Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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
        }