private void GiveAwards(ArrayList players, TrophyRank rank, int cash) { if (players.Count == 0) return; if (players.Count > 1) cash /= (players.Count - 1); cash += 500; cash /= 1000; cash *= 1000; StringBuilder sb = new StringBuilder(); if (this.m_TournyType == TournyType.FreeForAll) { sb.Append(this.m_Participants.Count * this.m_PlayersPerParticipant); sb.Append("-man FFA"); } else if (this.m_TournyType == TournyType.RandomTeam) { sb.Append(this.m_ParticipantsPerMatch); sb.Append("-team"); } else if (this.m_TournyType == TournyType.RedVsBlue) { sb.Append("Red v Blue"); } else { for (int i = 0; i < this.m_ParticipantsPerMatch; ++i) { if (sb.Length > 0) sb.Append('v'); sb.Append(this.m_PlayersPerParticipant); } } if (this.m_EventController != null) sb.Append(' ').Append(this.m_EventController.Title); sb.Append(" Champion"); string title = sb.ToString(); for (int i = 0; i < players.Count; ++i) { Mobile mob = (Mobile)players[i]; if (mob == null || mob.Deleted) continue; Item item = new Trophy(title, rank); if (!mob.PlaceInBackpack(item)) mob.BankBox.DropItem(item); 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 tournament.", rank.ToString().ToLower(), cash); } else { mob.SendMessage("You have been awarded a {0} trophy for your participation in this tournament.", rank.ToString().ToLower()); } } }
private void Finish_Callback() { ArrayList teams = new ArrayList(); for ( int i = 0; i < m_Context.Participants.Count; ++i ) { BRTeamInfo 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(); BRTeamInfo winner = (BRTeamInfo)( 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; BRPlayerInfo leader = ((BRTeamInfo)teams[i]).Leader; foreach ( BRPlayerInfo pl in ((BRTeamInfo)teams[i]).Players.Values ) { Mobile mob = pl.Player; if ( mob == null ) continue; if ( pl != leader && rank != TrophyRank.Gold ) 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( 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 ? " point" : " points" ); } } Item item = new Trophy( sb.ToString(), rank ); if ( pl == leader ) item.ItemID = 4810; item.Name = String.Format( "{0}, {1} team", item.Name, ((BRTeamInfo)teams[i]).Name.ToLower() ); if ( !mob.PlaceInBackpack( item ) ) mob.BankBox.DropItem( item ); int cash = 0; if (rank != TrophyRank.Gold) cash = pl == leader ? 2500 : 0; else cash = pl == leader ? 7500 : 500; 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( BRBoardGump ) ); dp.Mobile.SendGump( new BRBoardGump( 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 ); }
private void GiveAwards(List<Mobile> players, TrophyRank rank, int cash) { if (players.Count == 0) { return; } if (players.Count > 1) { cash /= (players.Count - 1); } cash += 500; cash /= 1000; cash *= 1000; var sb = new StringBuilder(); if (m_TournyType == TournyType.FreeForAll) { sb.Append(m_Participants.Count * m_PlayersPerParticipant); sb.Append("-man FFA"); } else if (m_TournyType == TournyType.RandomTeam) { sb.Append(m_ParticipantsPerMatch); sb.Append("-team"); } else if (m_TournyType == TournyType.RedVsBlue) { sb.Append("Red v Blue"); } else { for (int i = 0; i < m_ParticipantsPerMatch; ++i) { if (sb.Length > 0) { sb.Append('v'); } sb.Append(m_PlayersPerParticipant); } } if (m_EventController != null) { sb.Append(' ').Append(m_EventController.Title); } sb.Append(" Champion"); string title = sb.ToString(); for (int i = 0; i < players.Count; ++i) { Mobile mob = players[i]; if (mob == null || mob.Deleted) { continue; } Item item = new Trophy(title, rank); if (!mob.PlaceInBackpack(item)) { BankBox bank = m_EventController != null ? mob.FindBank(m_EventController.Expansion) : mob.BankBox; if (bank != null) { bank.DropItem(item); } else { item.Delete(); } } if (cash > 0) { item = new Platinum(cash); if (!mob.PlaceInBackpack(item)) { mob.BankBox.DropItem(item); } mob.SendMessage( "You have been awarded a {0} trophy and {1:N0}platinum for your participation in this tournament.", rank.ToString().ToLower(), cash); } else { mob.SendMessage("You have been awarded a {0} trophy for your participation in this tournament.", rank.ToString().ToLower()); } } }