Beispiel #1
0
        public void RecordRankings(ArenaDuel duel, ArenaTeam winners)
        {
            List <ArenaStats> rankings;

            rankings = duel.BattleMode == BattleMode.Team ? TeamRankings : SurvivalRankings;

            foreach (KeyValuePair <PlayerMobile, PlayerStatsEntry> part in duel.GetParticipants())
            {
                PlayerMobile pm    = part.Key;
                ArenaStats   stats = rankings.FirstOrDefault(r => r.Owner == pm);

                if (stats == null)
                {
                    stats = new ArenaStats(pm);
                    rankings.Add(stats);
                }

                ArenaTeam team = duel.GetTeam(pm);

                if (team != winners)
                {
                    stats.Ranking -= 33;
                }
                else
                {
                    stats.Ranking += 33;
                }
            }

            rankings.Sort();
        }
Beispiel #2
0
        public void Serialize(GenericWriter writer)
        {
            writer.Write(1);

            writer.Write(SurvivalRankings.Count);
            for (var index = 0; index < SurvivalRankings.Count; index++)
            {
                ArenaStats ranking = SurvivalRankings[index];
                ranking.Serialize(writer);
            }

            writer.Write(TeamRankings.Count);
            for (var index = 0; index < TeamRankings.Count; index++)
            {
                ArenaStats ranking = TeamRankings[index];
                ranking.Serialize(writer);
            }

            writer.Write(Blockers.Count);
            for (var index = 0; index < Blockers.Count; index++)
            {
                Item blocker = Blockers[index];
                writer.Write(blocker);
            }

            writer.Write(Stone);
            writer.Write(Manager);
            writer.Write(Banner1);
            writer.Write(Banner2);

            writer.Write(PendingDuels.Count);
            foreach (KeyValuePair <ArenaDuel, DateTime> kvp in PendingDuels)
            {
                kvp.Key.Serialize(writer);
                writer.WriteDeltaTime(kvp.Value);
            }

            writer.Write(BookedDuels.Count);
            for (var index = 0; index < BookedDuels.Count; index++)
            {
                ArenaDuel duel = BookedDuels[index];
                duel.Serialize(writer);
            }

            if (CurrentDuel != null)
            {
                writer.Write(1);
                CurrentDuel.Serialize(writer);
            }
            else
            {
                writer.Write(0);
            }
        }
Beispiel #3
0
        public void RecordRankings(ArenaDuel duel, ArenaTeam winners)
        {
            List <ArenaStats> rankings;

            rankings = duel.BattleMode == BattleMode.Team ? TeamRankings : SurvivalRankings;

            foreach (KeyValuePair <PlayerMobile, PlayerStatsEntry> part in duel.GetParticipants())
            {
                PlayerMobile pm    = part.Key;
                ArenaStats   stats = null;

                for (var index = 0; index < rankings.Count; index++)
                {
                    var r = rankings[index];

                    if (r.Owner == pm)
                    {
                        stats = r;
                        break;
                    }
                }

                if (stats == null)
                {
                    stats = new ArenaStats(pm);
                    rankings.Add(stats);
                }

                ArenaTeam team = duel.GetTeam(pm);

                if (team != winners)
                {
                    stats.Ranking -= 33;
                }
                else
                {
                    stats.Ranking += 33;
                }
            }

            rankings.Sort();
        }
Beispiel #4
0
        public void RecordRankings(ArenaDuel duel, ArenaTeam winners)
        {
            List <ArenaStats> rankings;

            if (duel.BattleMode == BattleMode.Team)
            {
                rankings = TeamRankings;
            }
            else
            {
                rankings = SurvivalRankings;
            }

            foreach (var part in duel.GetParticipants())
            {
                var        pm    = part.Key;
                ArenaStats stats = rankings.FirstOrDefault(r => r.Owner == pm);

                if (stats == null)
                {
                    stats = new ArenaStats(pm);
                    rankings.Add(stats);
                }

                var team = duel.GetTeam(pm);

                if (team != winners)
                {
                    stats.Ranking -= 33;
                }
                else
                {
                    stats.Ranking += 33;
                }
            }

            rankings.Sort();
        }
Beispiel #5
0
        public void Deserialize(GenericReader reader)
        {
            int version = reader.ReadInt();

            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                ArenaStats stats = new ArenaStats(reader);

                if (stats.Owner != null)
                {
                    SurvivalRankings.Add(stats);
                }
            }

            count = reader.ReadInt();
            for (int i = 0; i < count; i++)
            {
                ArenaStats stats = new ArenaStats(reader);

                if (stats.Owner != null)
                {
                    TeamRankings.Add(stats);
                }
            }

            count = reader.ReadInt();
            for (int i = 0; i < count; i++)
            {
                Item blocker = reader.ReadItem();

                if (blocker != null)
                {
                    Blockers.Add(blocker);
                }
            }

            Stone   = reader.ReadItem() as ArenaStone;
            Manager = reader.ReadMobile() as ArenaManager;
            Banner1 = reader.ReadItem() as ArenaExitBanner;
            Banner2 = reader.ReadItem() as ArenaExitBanner;

            count = reader.ReadInt();
            for (int i = 0; i < count; i++)
            {
                ArenaDuel duel = new ArenaDuel(reader, this);
                DateTime  dt   = reader.ReadDeltaTime();

                PendingDuels[duel] = dt;
            }

            count = reader.ReadInt();
            for (int i = 0; i < count; i++)
            {
                BookedDuels.Add(new ArenaDuel(reader, this));
            }

            if (reader.ReadInt() == 1)
            {
                CurrentDuel = new ArenaDuel(reader, this);
            }

            if (Stone != null)
            {
                Stone.Arena = this;
            }

            if (Manager != null)
            {
                Manager.Arena = this;
            }

            if (Banner1 != null)
            {
                Banner1.Arena = this;
            }

            if (Banner2 != null)
            {
                Banner2.Arena = this;
            }

            if (version == 0)
            {
                foreach (var blocker in Blockers)
                {
                    if (blocker != null)
                    {
                        blocker.Delete();
                    }
                }

                ColUtility.Free(Blockers);
            }
        }