public void CheckOccupation()
        {
            if (!OnGoing)
            {
                return;
            }

            if (Participants.Count == 1)
            {
                Guild g = Participants[0];

                if (!GuildStats.ContainsKey(g))
                {
                    GuildStats[g] = new VvVGuildBattleStats(g);
                }

                GuildStats[g].Points += OccupyPoints;
                UpdateAllGumps();
                CheckScore();

                if (OnGoing && NextAnnouncement < DateTime.UtcNow)
                {
                    System.SendVvVMessage(1154957, g.Name); // ~1_NAME~ is occupying the city!
                    NextAnnouncement = DateTime.UtcNow + TimeSpan.FromMinutes(Announcement);
                }
            }
            else // Is this a bug?  Verified on EA this is how it behaves
            {
                if (NextAnnouncement < DateTime.UtcNow)
                {
                    System.SendVvVMessage(1154958); // The City is unoccupied! Slay opposing forces to claim the city for your guild!
                    NextAnnouncement = DateTime.UtcNow + TimeSpan.FromMinutes(Announcement);
                }
            }
        }
        public void OccupyAltar(Guild g)
        {
            VvVGuildBattleStats killerStats = GetGuildStats(g);

            foreach (KeyValuePair <Guild, VvVGuildBattleStats> kvp in GuildStats)
            {
                Guild guild = kvp.Key;

                if (guild == g || guild.IsAlly(g))
                {
                    VvVGuildBattleStats stats = GetGuildStats(guild);

                    if (stats != null)
                    {
                        stats.Points += AltarPoints;
                        stats.Silver += AltarSilver + (OppositionCount(g) * 50);
                    }
                }
            }

            SendStatusMessage(String.Format("{0} claimed the altar!", g.Abbreviation));

            foreach (PlayerMobile pm in Region.GetEnumeratedMobiles().OfType <PlayerMobile>())
            {
                if (pm.QuestArrow != null)
                {
                    pm.QuestArrow = null;
                }
            }

            CheckScore();
            NextAltarActivate = DateTime.UtcNow + TimeSpan.FromMinutes(2);
        }
        public VvVGuildBattleStats GetGuildStats(Guild g)
        {
            if (g == null)
            {
                return(null);
            }

            if (!GuildStats.ContainsKey(g))
            {
                GuildStats[g] = new VvVGuildBattleStats(g);
            }

            return(GuildStats[g]);
        }
        /// <summary>
        /// Gets real time leader of battle, out parameter of their score
        /// </summary>
        /// <param name="score"></param>
        /// <returns></returns>
        public Guild GetLeader(out int score)
        {
            Guild leader = null;

            score = 0;

            foreach (Guild g in Participants)
            {
                if (!GuildStats.ContainsKey(g))
                {
                    GuildStats[g] = new VvVGuildBattleStats(g);
                }

                if (leader == null || GuildStats[g].Points > score)
                {
                    leader = g;
                    score  = (int)GuildStats[g].Points;
                }
            }

            return(leader);
        }
        public void Update(VvVPlayerEntry victim, VvVPlayerEntry killer, UpdateType type)
        {
            VvVGuildBattleStats killerStats = GetGuildStats(killer.Guild);
            VvVGuildBattleStats victimStats = victim == null ? null : GetGuildStats(victim.Guild);

            switch (type)
            {
            case UpdateType.Kill:
                if (killer != null)
                {
                    killer.Kills++;
                }
                if (victim != null)
                {
                    victim.Deaths++;
                }
                if (killerStats != null)
                {
                    killerStats.Kills++;
                }
                if (victimStats != null)
                {
                    victimStats.Deaths++;
                }

                if (victim != null && victim.Player != null)
                {
                    if (!KillCooldown.ContainsKey(victim.Player) || KillCooldown[victim.Player] < DateTime.UtcNow)
                    {
                        if (killerStats != null)
                        {
                            killerStats.Points += KillPoints;
                        }

                        SendStatusMessage(String.Format("{0} has killed {1}!", killer.Player.Name, victim.Player.Name));
                        killerStats.Silver         += KillSilver + (OppositionCount(killer.Guild) * 50);
                        KillCooldown[victim.Player] = DateTime.UtcNow + TimeSpan.FromMinutes(KillCooldownDuration);
                    }
                }

                break;

            case UpdateType.Assist:
                if (killer != null)
                {
                    killer.Assists++;
                }

                if (killerStats != null)
                {
                    killerStats.Assists++;
                }
                break;

            case UpdateType.Steal:
                if (killerStats != null)
                {
                    killer.StolenSigils++;
                    killerStats.Stolen++;
                    SendStatusMessage(String.Format("{0} has stolen the sigil!", killer.Player.Name));
                }
                break;

            case UpdateType.TurnInVice:
                if (killerStats != null)
                {
                    killer.ReturnedSigils++;
                    killerStats.ViceReturned++;
                    killerStats.Points += TurnInPoints;
                    killerStats.Silver += TurnInSilver + (OppositionCount(killer.Guild) * 50);
                    SendStatusMessage(String.Format("{0} has returned the sigil!", killer.Player.Name));
                    NextSigilSpawn = DateTime.UtcNow + TimeSpan.FromMinutes(1);
                }
                RemovePriests();
                break;

            case UpdateType.TurnInVirtue:
                if (killerStats != null)
                {
                    killer.ReturnedSigils++;
                    killerStats.VirtueReturned++;
                    killerStats.Points += TurnInPoints;
                    killerStats.Silver += TurnInSilver + (OppositionCount(killer.Guild) * 50);
                    SendStatusMessage(String.Format("{0} has returned the sigil!", killer.Player.Name));
                    NextSigilSpawn = DateTime.UtcNow + TimeSpan.FromMinutes(1);
                }
                RemovePriests();
                break;

            case UpdateType.Disarm:
                if (killerStats != null)
                {
                    killerStats.Disarmed++;
                    killer.DisarmedTraps++;
                    killerStats.Silver += DisarmSilver + (OppositionCount(killer.Guild) * 50);
                    SendStatusMessage(String.Format("{0} has disarmed a trap!", killer.Player.Name));
                }
                break;
            }

            CheckScore();
        }
        public VvVBattle(GenericReader reader, ViceVsVirtueSystem system)
        {
            int version = reader.ReadInt();

            System = system;

            Altars       = new List <VvVAltar>();
            GuildStats   = new Dictionary <Guild, VvVGuildBattleStats>();
            KillCooldown = new Dictionary <Mobile, DateTime>();
            Participants = new List <Guild>();
            Messages     = new List <string>();
            Traps        = new List <VvVTrap>();
            Warned       = new List <Mobile>();
            Turrets      = new List <CannonTurret>();

            OnGoing = reader.ReadBool();

            if (reader.ReadInt() == 0)
            {
                StartTime           = reader.ReadDateTime();
                CooldownEnds        = reader.ReadDateTime();
                LastOccupationCheck = reader.ReadDateTime();
                NextSigilSpawn      = reader.ReadDateTime();
                NextAnnouncement    = reader.ReadDateTime();
                NextAltarActivate   = reader.ReadDateTime();
                City         = (VvVCity)reader.ReadInt();
                Sigil        = reader.ReadItem() as VvVSigil;
                VicePriest   = reader.ReadMobile() as VvVPriest;
                VirtuePriest = reader.ReadMobile() as VvVPriest;

                if (Sigil != null)
                {
                    Sigil.Battle = this;
                }

                if (VicePriest != null)
                {
                    VicePriest.Battle = this;
                }

                if (VirtuePriest != null)
                {
                    VirtuePriest.Battle = this;
                }

                int count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    VvVAltar altar = reader.ReadItem() as VvVAltar;
                    if (altar != null)
                    {
                        altar.Battle = this;
                        Altars.Add(altar);
                    }
                }

                count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    Guild g = reader.ReadGuild() as Guild;
                    VvVGuildBattleStats stats = new VvVGuildBattleStats(reader, g);

                    if (g != null)
                    {
                        GuildStats[g] = stats;
                    }
                }

                count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    VvVTrap t = reader.ReadItem() as VvVTrap;

                    if (t != null)
                    {
                        Traps.Add(t);
                    }
                }

                Timer.DelayCall(TimeSpan.FromSeconds(10), () =>
                {
                    if (Region is GuardedRegion)
                    {
                        GuardedRegion.Disable((GuardedRegion)Region);
                    }

                    BeginTimer();

                    ActivateArrows();
                });
            }
        }
        public BattleStatsGump(PlayerMobile pm, VvVBattle battle)
            : base(50, 50)
        {
            Battle = battle;
            AddBackground(0, 0, 500, 500, 9380);

            Guild leader  = battle.GetLeader();
            Guild myGuild = pm.Guild as Guild;

            if (leader == null || myGuild == null)
            {
                return;
            }

            AddHtmlLocalized(0, 40, 500, 20, 1154645, "#1154945", Color16, false, false); // The Battle between Vice and Virtue has ended!
            AddHtml(40, 65, 420, 20, String.Format("<basefont color=#B22222>{0} [{1}] has won the battle!", leader.Name, leader.Abbreviation), false, false);

            int y = 90;

            if (leader.Alliance != null && Battle.HasAlliance(leader))
            {
                AddHtml(40, y, 420, 20, String.Format("<basefont color=#B22222>The {0} Alliance has won the battle!", leader.Alliance.Name), false, false);
                y += 25;
            }

            // TODO: Does score reflect everyone, alliance, or just that player! For now, it will be entire alliance

            int          silver = 0, score = 0, kills = 0, assists = 0, deaths = 0, stolen = 0, returned = 0, vicereturned = 0, virtuereturned = 0, disarmed = 0;
            List <Guild> alliance = Battle.GetAlliance(myGuild);

            foreach (Guild g in alliance)
            {
                VvVGuildBattleStats stats = Battle.GetGuildStats(g);

                kills          += stats.Kills;
                assists        += stats.Assists;
                deaths         += stats.Deaths;
                stolen         += stats.Stolen;
                returned       += stats.ReturnedSigils;
                vicereturned   += stats.ViceReturned;
                virtuereturned += stats.VirtueReturned;
                disarmed       += stats.Disarmed;
            }

            silver += (int)ViceVsVirtueSystem.Instance.GetPoints(pm);

            VvVPlayerEntry entry = ViceVsVirtueSystem.Instance.GetPlayerEntry <VvVPlayerEntry>(pm);

            if (entry != null)
            {
                score = entry.Score;
            }

            AddHtmlLocalized(40, y, 420, 20, 1154947, silver.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false); // Total Silver Points: ~1_val~
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154948, score.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false); // Total Score: ~1_val~
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154949, kills.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false);
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154950, assists.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false);
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154951, deaths.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false);
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154952, stolen.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false);
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154953, returned.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false);
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154954, vicereturned.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false);
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154955, virtuereturned.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false);
            y += 25;

            AddHtmlLocalized(40, y, 420, 20, 1154956, disarmed.ToString("N0", CultureInfo.GetCultureInfo("en-US")), Color16, false, false);
            y += 25;
        }
Beispiel #8
0
        public void AddGumpLayout()
        {
            AddPage(0);
            AddImage(0, 0, 30566);

            if (DateTime.UtcNow >= Battle.NextSigilSpawn && Battle.Sigil != null && !Battle.Sigil.Deleted)
            {
                AddImage(200, 300, 30583);
            }

            List <VvVGuildBattleStats> guilds = new List <VvVGuildBattleStats>();

            foreach (Guild g in Battle.Participants)
            {
                VvVGuildBattleStats stats = Battle.GetGuildStats(g);

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

            guilds.Sort();
            double offset = 216 / (double)VvVBattle.ScoreToWin;

            for (int i = 0; i < guilds.Count; i++)
            {
                VvVGuildBattleStats stats = guilds[i];

                AddHtml(87, 115 + (31 * i), 50, 20, String.Format("<basefont color=#FFFFFF>{0}", stats.Guild.Abbreviation), false, false);
                AddBackground(145, 120 + (31 * i), (int)Math.Min(216, (stats.Points * offset)), 12, 30584);

                if (i == 2)  // stupid gump only allows 3 to be shown
                {
                    break;
                }
            }

            int count = Battle.Messages.Count - 1;
            int y     = 206;

            for (int i = count; i >= 0; i--)
            {
                if (i <= count - 3)
                {
                    break;
                }

                AddHtml(98, y, 250, 16, String.Format("<basefont color=#80BFFF>{0}", Battle.Messages[i]), false, false);

                y += 16;
            }

            Guild gu = User.Guild as Guild;

            if (gu != null)
            {
                VvVGuildBattleStats stats = Battle.GetGuildStats(gu);

                AddHtml(87, 268, 50, 20, String.Format("<basefont color=#FFFFFF>{0}", gu.Abbreviation), false, false);
                AddBackground(145, 271, (int)Math.Min(216, (stats.Points * offset)), 12, 30584);
            }

            AddCountdown();
        }
        public void AddGumpLayout()
        {
            AddImage(0, 0, 30566);

            if (DateTime.UtcNow >= Battle.NextSigilSpawn && Battle.Sigil != null && !Battle.Sigil.Deleted)
            {
                AddImage(200, 300, 30583);
            }

            List <VvVGuildBattleStats> guilds = new List <VvVGuildBattleStats>();

            foreach (Guild g in Battle.Participants)
            {
                VvVGuildBattleStats stats = Battle.GetGuildStats(g);

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

            guilds.Sort();
            double offset = 216 / (double)VvVBattle.ScoreToWin;

            for (int i = 0; i < guilds.Count; i++)
            {
                VvVGuildBattleStats stats = guilds[i];

                AddHtml(87, 118 + (30 * i), 50, 20, String.Format("<basefont color=#FFFFFF>{0}", stats.Guild.Abbreviation), false, false);
                AddImageTiled(145, 120 + (30 * i), (int)Math.Min(216, (stats.Points * offset)), 12, 30584);

                if (i == 2)  // stupid gump only allows 3 to be shown
                {
                    break;
                }
            }

            int count = Battle.Messages.Count - 1;
            int y     = 205;

            for (int i = count; i >= 0; i--)
            {
                if (i <= count - 3)
                {
                    break;
                }

                AddHtml(100, y, 250, 16, String.Format("<basefont color=#00CED1>{0}", Battle.Messages[i]), false, false);

                y += 16;
            }

            Guild gu = User.Guild as Guild;

            if (gu != null)
            {
                VvVGuildBattleStats stats = Battle.GetGuildStats(gu);

                AddHtml(87, 268, 50, 20, String.Format("<basefont color=#FFFFFF>{0}", gu.Abbreviation), false, false);
                AddImageTiled(145, 270, (int)Math.Min(216, (stats.Points * offset)), 12, 30584);
            }

            TimeSpan left = (Battle.StartTime + TimeSpan.FromMinutes(VvVBattle.Duration)) - DateTime.UtcNow;

            AddHtml(207, 21, 60, 20, "<basefont color=red>" + String.Format("{0:mm\\:ss}", left), false, false);
        }