public void Reset() { m_Kills = 0; m_Captures = 0; m_Score = 0; m_Leader = null; m_Players.Clear(); }
public override bool OnDeath(Mobile mob, Container corpse) { Mobile killer = mob.FindMostRecentDamager(false); KHTeamInfo teamInfo = null; KHTeamInfo victInfo = GetTeamInfo(mob); int bonus = 0; if (killer != null && killer.Player) { teamInfo = GetTeamInfo(killer); } for (int i = 0; i < m_Controller.Hills.Length; i++) { if (m_Controller.Hills[i] == null) { continue; } if (m_Controller.Hills[i].King == mob) { bonus += m_Controller.Hills[i].CapturesSoFar; m_Controller.Hills[i].OnKingDied(mob, victInfo, killer, teamInfo); } if (m_Controller.Hills[i].King == killer) { bonus += 2; } } if (teamInfo != null && teamInfo != victInfo) { KHPlayerInfo playerInfo = teamInfo[killer]; if (playerInfo != null) { playerInfo.Kills += 1; playerInfo.Score += 1 + bonus; } } mob.CloseGump(typeof(KHBoardGump)); mob.SendGump(new KHBoardGump(mob, this)); m_Context.Requip(mob, corpse); DelayBounce(TimeSpan.FromSeconds(30.0), mob, corpse); return(false); }
public int CompareTo(object obj) { KHPlayerInfo pi = (KHPlayerInfo)obj; int res = pi.Score.CompareTo(this.Score); if (res == 0) { res = pi.Captures.CompareTo(this.Captures); if (res == 0) { res = pi.Kills.CompareTo(this.Kills); } } return(res); }
public KHPlayerInfo this[Mobile mob] { get { if (mob == null) { return(null); } KHPlayerInfo val = m_Players[mob] as KHPlayerInfo; if (val == null) { m_Players[mob] = val = new KHPlayerInfo(this, mob); } return(val); } }
protected override void OnTick() { KHTeamInfo ti = null; KHPlayerInfo pi = null; if (m_Hill == null || m_Hill.Deleted || m_Hill.Game == null) { Stop(); return; } if (m_Hill.King == null || m_Hill.King.Deleted || !m_Hill.King.Alive) { m_Hill.DeKingify(); Stop(); return; } ti = m_Hill.Game.GetTeamInfo(m_Hill.King); if (ti != null) { pi = ti[m_Hill.King]; } if (ti == null || pi == null) { // error, bail m_Hill.DeKingify(); Stop(); return; } m_Counter++; m_Hill.King.RevealingAction(); if (m_Counter >= m_Hill.ScoreInterval) { string hill = m_Hill.Name; string king = m_Hill.King.Name; if (king == null) { king = ""; } if (hill == null || hill == "") { hill = "the hill"; } m_Hill.Game.Alert("{0} ({1}) is king of {2}!", king, ti.Name, hill); m_Hill.PublicOverheadMessage(MessageType.Regular, 0x0481, false, "Capture!"); pi.Captures++; m_Total++; pi.Score += m_Counter; m_Counter = 0; } else { m_Hill.PublicOverheadMessage(MessageType.Regular, 0x0481, false, (m_Hill.ScoreInterval - m_Counter).ToString()); } }
private void Finish_Callback() { ArrayList teams = new ArrayList(); for (int i = 0; i < m_Context.Participants.Count; ++i) { KHTeamInfo teamInfo = m_Controller.TeamInfo[i % m_Controller.TeamInfo.Length]; if (teamInfo == null) { continue; } teams.Add(teamInfo); } teams.Sort(); Tournament tourny = m_Context.m_Tournament; StringBuilder sb = new StringBuilder(); if (tourny != null && tourny.TournyType == TournyType.FreeForAll) { sb.Append(m_Context.Participants.Count * tourny.PlayersPerParticipant); sb.Append("-man FFA"); } else if (tourny != null && tourny.TournyType == TournyType.RandomTeam) { sb.Append(tourny.ParticipantsPerMatch); sb.Append("-team"); } else if (tourny != null && tourny.TournyType == TournyType.RedVsBlue) { sb.Append("Red v Blue"); } else if (tourny != null) { for (int i = 0; i < tourny.ParticipantsPerMatch; ++i) { if (sb.Length > 0) { sb.Append('v'); } sb.Append(tourny.PlayersPerParticipant); } } if (m_Controller != null) { sb.Append(' ').Append(m_Controller.Title); } string title = sb.ToString(); KHTeamInfo winner = (KHTeamInfo)(teams.Count > 0 ? teams[0] : null); for (int i = 0; i < teams.Count; ++i) { TrophyRank rank = TrophyRank.Bronze; if (i == 0) { rank = TrophyRank.Gold; } else if (i == 1) { rank = TrophyRank.Silver; } KHPlayerInfo leader = ((KHTeamInfo)teams[i]).Leader; foreach (KHPlayerInfo pl in ((KHTeamInfo)teams[i]).Players.Values) { Mobile mob = pl.Player; if (mob == null) { continue; } sb = new StringBuilder(); sb.Append(title); if (pl == leader) { sb.Append(" Leader"); } if (pl.Score > 0) { sb.Append(": "); sb.Append(pl.Score.ToString("N0")); sb.Append(pl.Score == 1 ? " point" : " points"); sb.Append(", "); sb.Append(pl.Kills.ToString("N0")); sb.Append(pl.Kills == 1 ? " kill" : " kills"); if (pl.Captures > 0) { sb.Append(", "); sb.Append(pl.Captures.ToString("N0")); sb.Append(pl.Captures == 1 ? " capture" : " captures"); } } Item item = new Trophy(sb.ToString(), rank); if (pl == leader) { item.ItemID = 4810; } item.Name = String.Format("{0}, {1}", item.Name, ((KHTeamInfo)teams[i]).Name.ToLower()); if (!mob.PlaceInBackpack(item)) { mob.BankBox.DropItem(item); } int cash = pl.Score * 250; if (cash > 0) { item = new BankCheck(cash); if (!mob.PlaceInBackpack(item)) { mob.BankBox.DropItem(item); } mob.SendMessage("You have been awarded a {0} trophy and {1:N0}gp for your participation in this game.", rank.ToString().ToLower(), cash); } else { mob.SendMessage("You have been awarded a {0} trophy for your participation in this game.", rank.ToString().ToLower()); } } } for (int i = 0; i < m_Context.Participants.Count; ++i) { Participant p = m_Context.Participants[i] as Participant; if (p == null || p.Players == null) { continue; } for (int j = 0; j < p.Players.Length; ++j) { DuelPlayer dp = p.Players[j]; if (dp != null && dp.Mobile != null) { dp.Mobile.CloseGump(typeof(KHBoardGump)); dp.Mobile.SendGump(new KHBoardGump(dp.Mobile, this)); } } if (i == winner.TeamID) { continue; } if (p != null && p.Players != null) { for (int j = 0; j < p.Players.Length; ++j) { if (p.Players[j] != null) { p.Players[j].Eliminated = true; } } } } m_Context.Finish(m_Context.Participants[winner.TeamID] as Participant); }
public KHPlayerInfo this[Mobile mob] { get { if (mob == null) return null; KHPlayerInfo val = m_Players[mob] as KHPlayerInfo; if (val == null) m_Players[mob] = val = new KHPlayerInfo(this, mob); return val; } }