public StakesContainer( DuelContext context, Participant participant ) : base( 0x9A8 ) { Movable = false; m_Initiator = context.Initiator; m_Participant = participant; m_Owners = new Hashtable(); }
public DuelPlayer(Mobile mob, Participant p) { this.m_Mobile = mob; this.m_Participant = p; if (mob is PlayerMobile) ((PlayerMobile)mob).DuelPlayer = this; }
public ParticipantGump(Mobile from, DuelContext context, Participant p) : base(50, 50) { this.m_From = from; this.m_Context = context; this.m_Participant = p; from.CloseGump(typeof(RulesetGump)); from.CloseGump(typeof(DuelContextGump)); from.CloseGump(typeof(ParticipantGump)); int count = p.Players.Length; if (count < 4) count = 4; this.AddPage(0); int height = 35 + 10 + 22 + 22 + 30 + 22 + 2 + (count * 22) + 2 + 30; this.AddBackground(0, 0, 300, height, 9250); this.AddBackground(10, 10, 280, height - 20, 0xDAC); this.AddButton(240, 25, 0xFB1, 0xFB3, 3, GumpButtonType.Reply, 0); //AddButton( 223, 54, 0x265A, 0x265A, 4, GumpButtonType.Reply, 0 ); this.AddHtml(35, 25, 230, 20, this.Center("Participant Setup"), false, false); int x = 35; int y = 47; this.AddHtml(x, y, 200, 20, String.Format("Team Size: {0}", p.Players.Length), false, false); y += 22; this.AddGoldenButtonLabeled(x + 20, y, 1, "Increase"); y += 22; this.AddGoldenButtonLabeled(x + 20, y, 2, "Decrease"); y += 30; this.AddHtml(35, y, 230, 20, this.Center("Players"), false, false); y += 22; for (int i = 0; i < p.Players.Length; ++i) { DuelPlayer pl = p.Players[i]; this.AddGoldenButtonLabeled(x, y, 5 + i, String.Format("{0}: {1}", 1 + i, pl == null ? "Empty" : pl.Mobile.Name)); y += 22; } }
private void ApplyHues( Participant p, int hueOverride ) { for ( int i = 0; i < p.Players.Length; ++i ) { if ( p.Players[i] != null ) p.Players[i].Mobile.SolidHueOverride = hueOverride; } }
public void Start(Arena arena, Tournament tourny) { TournyParticipant first = (TournyParticipant)this.m_Participants[0]; DuelContext dc = new DuelContext((Mobile)first.Players[0], tourny.Ruleset.Layout, false); dc.Ruleset.Options.SetAll(false); dc.Ruleset.Options.Or(tourny.Ruleset.Options); for (int i = 0; i < this.m_Participants.Count; ++i) { TournyParticipant tournyPart = (TournyParticipant)this.m_Participants[i]; Participant duelPart = new Participant(dc, tournyPart.Players.Count); duelPart.TournyPart = tournyPart; for (int j = 0; j < tournyPart.Players.Count; ++j) duelPart.Add((Mobile)tournyPart.Players[j]); for (int j = 0; j < duelPart.Players.Length; ++j) { if (duelPart.Players[j] != null) duelPart.Players[j].Ready = true; } dc.Participants.Add(duelPart); } if (tourny.EventController != null) dc.m_EventGame = tourny.EventController.Construct(dc); dc.m_Tournament = tourny; dc.m_Match = this; dc.m_OverrideArena = arena; if (tourny.SuddenDeath > TimeSpan.Zero && (tourny.SuddenDeathRounds == 0 || tourny.Pyramid.Levels.Count <= tourny.SuddenDeathRounds)) dc.StartSuddenDeath(tourny.SuddenDeath); dc.SendReadyGump(0); if (dc.StartedBeginCountdown) { this.m_Context = dc; for (int i = 0; i < this.m_Participants.Count; ++i) { TournyParticipant p = (TournyParticipant)this.m_Participants[i]; for (int j = 0; j < p.Players.Count; ++j) { Mobile mob = (Mobile)p.Players[j]; foreach (Mobile view in mob.GetMobilesInRange(18)) { if (!mob.CanSee(view)) mob.Send(view.RemovePacket); } mob.LocalOverheadMessage(MessageType.Emote, 0x3B2, false, "* Your mind focuses intently on the fight and all other distractions fade away *"); } } } else { dc.Unregister(); dc.StopCountdown(); } }
public void QueryRematch() { DuelContext dc = new DuelContext( m_Initiator, m_Ruleset.Layout, false ); dc.m_Ruleset = m_Ruleset; dc.m_Rematch = true; dc.m_Participants.Clear(); for ( int i = 0; i < m_Participants.Count; ++i ) { Participant oldPart = (Participant)m_Participants[i]; Participant newPart = new Participant( dc, oldPart.Players.Length ); for ( int j = 0; j < oldPart.Players.Length; ++j ) { DuelPlayer oldPlayer = oldPart.Players[j]; if ( oldPlayer != null ) newPart.Players[j] = new DuelPlayer( oldPlayer.Mobile, newPart ); } dc.m_Participants.Add( newPart ); } dc.CloseAllGumps(); dc.SendReadyUpGump(); }
public void Finish( Participant winner ) { if ( m_Finished ) return; EndAutoTie(); StopSDTimers(); m_Finished = true; for ( int i = 0; i < winner.Players.Length; ++i ) { DuelPlayer pl = winner.Players[i]; if ( pl != null && !pl.Eliminated ) DelayBounce( TimeSpan.FromSeconds( 8.0 ), pl.Mobile, null ); } winner.Broadcast( 0x59, null, winner.Players.Length == 1 ? "{0} has won the duel." : "{0} and {1} team have won the duel.", winner.Players.Length == 1 ? "You have won the duel." : "Your team has won the duel." ); if ( m_Tournament != null && winner.TournyPart != null ) { m_Match.Winner = winner.TournyPart; winner.TournyPart.WonMatch( m_Match ); m_Tournament.HandleWon( m_Arena, m_Match, winner.TournyPart ); } for ( int i = 0; i < m_Participants.Count; ++i ) { Participant loser = (Participant)m_Participants[i]; if ( loser != winner ) { loser.Broadcast( 0x22, null, loser.Players.Length == 1 ? "{0} has lost the duel." : "{0} and {1} team have lost the duel.", loser.Players.Length == 1 ? "You have lost the duel." : "Your team has lost the duel." ); if ( m_Tournament != null && loser.TournyPart != null ) loser.TournyPart.LostMatch( m_Match ); } for ( int j = 0; j < loser.Players.Length; ++j ) { if ( loser.Players[j] != null ) { RemoveAggressions( loser.Players[j].Mobile ); loser.Players[j].Mobile.Delta( MobileDelta.Noto ); loser.Players[j].Mobile.CloseGump( typeof( BeginGump ) ); if ( m_Tournament != null ) loser.Players[j].Mobile.SendEverything(); } } } if ( IsOneVsOne ) { DuelPlayer dp1 = ((Participant)m_Participants[0]).Players[0]; DuelPlayer dp2 = ((Participant)m_Participants[1]).Players[0]; if ( dp1 != null && dp2 != null ) { Award( dp1.Mobile, dp2.Mobile, dp1.Participant == winner ); Award( dp2.Mobile, dp1.Mobile, dp2.Participant == winner ); } } if ( m_EventGame != null ) m_EventGame.OnStop(); Timer.DelayCall( TimeSpan.FromSeconds( 9.0 ), new TimerCallback( UnregisterRematch ) ); }
public AcceptDuelGump( Mobile challenger, Mobile challenged, DuelContext context, Participant p, int slot ) : base( 50, 50 ) { m_Challenger = challenger; m_Challenged = challenged; m_Context = context; m_Participant = p; m_Slot = slot; challenged.CloseGump( typeof( AcceptDuelGump ) ); Closable = false; AddPage( 0 ); //AddBackground( 0, 0, 400, 220, 9150 ); AddBackground( 1, 1, 398, 218, 3600 ); //AddBackground( 16, 15, 369, 189, 9100 ); AddImageTiled( 16, 15, 369, 189, 3604 ); AddAlphaRegion( 16, 15, 369, 189 ); AddImage( 215, -43, 0xEE40 ); //AddImage( 330, 141, 0x8BA ); AddHtml( 22-1, 22, 294, 20, Color( Center( "Duel Challenge" ), BlackColor32 ), false, false ); AddHtml( 22+1, 22, 294, 20, Color( Center( "Duel Challenge" ), BlackColor32 ), false, false ); AddHtml( 22, 22-1, 294, 20, Color( Center( "Duel Challenge" ), BlackColor32 ), false, false ); AddHtml( 22, 22+1, 294, 20, Color( Center( "Duel Challenge" ), BlackColor32 ), false, false ); AddHtml( 22, 22, 294, 20, Color( Center( "Duel Challenge" ), LabelColor32 ), false, false ); string fmt; if ( p.Contains( challenger ) ) fmt = "You have been asked to join sides with {0} in a duel. Do you accept?"; else fmt = "You have been challenged to a duel from {0}. Do you accept?"; AddHtml( 22-1, 50, 294, 40, Color( String.Format( fmt, challenger.Name ), BlackColor32 ), false, false ); AddHtml( 22+1, 50, 294, 40, Color( String.Format( fmt, challenger.Name ), BlackColor32 ), false, false ); AddHtml( 22, 50-1, 294, 40, Color( String.Format( fmt, challenger.Name ), BlackColor32 ), false, false ); AddHtml( 22, 50+1, 294, 40, Color( String.Format( fmt, challenger.Name ), BlackColor32 ), false, false ); AddHtml( 22, 50, 294, 40, Color( String.Format( fmt, challenger.Name ), 0xB0C868 ), false, false ); AddImageTiled( 32, 88, 264, 1, 9107 ); AddImageTiled( 42, 90, 264, 1, 9157 ); AddRadio( 24, 100, 9727, 9730, true, 1 ); AddHtml( 60-1, 105, 250, 20, Color( "Yes, I will fight this duel.", BlackColor32 ), false, false ); AddHtml( 60+1, 105, 250, 20, Color( "Yes, I will fight this duel.", BlackColor32 ), false, false ); AddHtml( 60, 105-1, 250, 20, Color( "Yes, I will fight this duel.", BlackColor32 ), false, false ); AddHtml( 60, 105+1, 250, 20, Color( "Yes, I will fight this duel.", BlackColor32 ), false, false ); AddHtml( 60, 105, 250, 20, Color( "Yes, I will fight this duel.", LabelColor32 ), false, false ); AddRadio( 24, 135, 9727, 9730, false, 2 ); AddHtml( 60-1, 140, 250, 20, Color( "No, I do not wish to fight.", BlackColor32 ), false, false ); AddHtml( 60+1, 140, 250, 20, Color( "No, I do not wish to fight.", BlackColor32 ), false, false ); AddHtml( 60, 140-1, 250, 20, Color( "No, I do not wish to fight.", BlackColor32 ), false, false ); AddHtml( 60, 140+1, 250, 20, Color( "No, I do not wish to fight.", BlackColor32 ), false, false ); AddHtml( 60, 140, 250, 20, Color( "No, I do not wish to fight.", LabelColor32 ), false, false ); AddRadio( 24, 170, 9727, 9730, false, 3 ); AddHtml( 60-1, 175, 250, 20, Color( "No, knave. Do not ask again.", BlackColor32 ), false, false ); AddHtml( 60+1, 175, 250, 20, Color( "No, knave. Do not ask again.", BlackColor32 ), false, false ); AddHtml( 60, 175-1, 250, 20, Color( "No, knave. Do not ask again.", BlackColor32 ), false, false ); AddHtml( 60, 175+1, 250, 20, Color( "No, knave. Do not ask again.", BlackColor32 ), false, false ); AddHtml( 60, 175, 250, 20, Color( "No, knave. Do not ask again.", LabelColor32 ), false, false ); AddButton( 314, 173, 247, 248, 1, GumpButtonType.Reply, 0 ); Timer.DelayCall( TimeSpan.FromSeconds( 15.0 ), new TimerCallback( AutoReject ) ); }
public ParticipantTarget( DuelContext context, Participant p, int index ) : base( 12, false, TargetFlags.None ) { m_Context = context; m_Participant = p; m_Index = index; }
private void Finish_Callback() { List <CTFTeamInfo> teams = new List <CTFTeamInfo>(); for (int i = 0; i < m_Context.Participants.Count; ++i) { CTFTeamInfo teamInfo = m_Controller.TeamInfo[i % 8]; if (teamInfo == null || teamInfo.Flag == null) { continue; } teams.Add(teamInfo); } teams.Sort(delegate(CTFTeamInfo a, CTFTeamInfo b) { return(b.Score - a.Score); }); 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 && tourny.TournyType == TournyType.Faction) { sb.Append(tourny.ParticipantsPerMatch); sb.Append("-team Faction"); } 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(); CTFTeamInfo winner = (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; } CTFPlayerInfo leader = teams[i].Leader; foreach (CTFPlayerInfo pl in teams[i].Players.Values) { Mobile mob = pl.Player; if (mob == null) { continue; } //"Red v Blue CTF Champion" 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"); if (pl.Kills > 0) { 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} team", item.Name, 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 tournament.", rank.ToString().ToLower(), cash); } else { mob.SendMessage("You have been awarded a {0} trophy for your participation in this tournament.", rank.ToString().ToLower()); } } } for (int i = 0; i < m_Context.Participants.Count; ++i) { Participant p = m_Context.Participants[i] as Participant; for (int j = 0; j < p.Players.Length; ++j) { DuelPlayer dp = p.Players[j]; if (dp != null && dp.Mobile != null) { dp.Mobile.CloseGump(typeof(CTFBoardGump)); dp.Mobile.SendGump(new CTFBoardGump(dp.Mobile, this)); } } if (i == winner.TeamID) { continue; } 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 ReadyUpGump(Mobile from, DuelContext context) : base(50, 50) { m_From = from; m_Context = context; Closable = false; AddPage(0); if (context.Rematch) { int height = 25 + 20 + 10 + 22 + 25; AddBackground(0, 0, 210, height, 9250); AddBackground(10, 10, 190, height - 20, 0xDAC); AddHtml(35, 25, 140, 20, Center("Rematch?"), false, false); AddButton(35, 55, 247, 248, 1, GumpButtonType.Reply, 0); AddButton(115, 55, 242, 241, 2, GumpButtonType.Reply, 0); } else { #region Participants AddPage(1); List <Participant> parts = context.Participants; int height = 25 + 20; for (int i = 0; i < parts.Count; ++i) { Participant p = (Participant)parts[i]; height += 4; if (p.Players.Length > 1) { height += 22; } height += (p.Players.Length * 22); } height += 10 + 22 + 25; AddBackground(0, 0, 260, height, 9250); AddBackground(10, 10, 240, height - 20, 0xDAC); AddHtml(35, 25, 190, 20, Center("Participants"), false, false); int y = 20 + 25; for (int i = 0; i < parts.Count; ++i) { Participant p = (Participant)parts[i]; y += 4; int offset = 0; if (p.Players.Length > 1) { AddHtml(35, y, 176, 20, String.Format("Team #{0}", i + 1), false, false); y += 22; offset = 10; } for (int j = 0; j < p.Players.Length; ++j) { DuelPlayer pl = p.Players[j]; string name = (pl == null ? "(Empty)" : pl.Mobile.Name); AddHtml(35 + offset, y, 166, 20, name, false, false); y += 22; } } y += 8; AddHtml(35, y, 176, 20, "Continue?", false, false); y -= 2; AddButton(102, y, 247, 248, 0, GumpButtonType.Page, 2); AddButton(169, y, 242, 241, 2, GumpButtonType.Reply, 0); #endregion #region Rules AddPage(2); Ruleset ruleset = context.Ruleset; Ruleset basedef = ruleset.Base; height = 25 + 20 + 5 + 20 + 20 + 4 + 25; int changes = 0; BitArray defs; if (ruleset.Flavors.Count > 0) { defs = new BitArray(basedef.Options); for (int i = 0; i < ruleset.Flavors.Count; ++i) { defs.Or(((Ruleset)ruleset.Flavors[i]).Options); } height += ruleset.Flavors.Count * 18; } else { defs = basedef.Options; } BitArray opts = ruleset.Options; for (int i = 0; i < opts.Length; ++i) { if (defs[i] != opts[i]) { ++changes; } } height += (changes * 22); height += 10 + 22 + 25; AddBackground(0, 0, 260, height, 9250); AddBackground(10, 10, 240, height - 20, 0xDAC); AddHtml(35, 25, 190, 20, Center("Rules"), false, false); AddHtml(35, 50, 190, 20, String.Format("Era: {0}", ruleset.Era), false, false); AddHtml(35, 75, 190, 20, String.Format("Set: {0}", basedef.Title), false, false); y = 95; for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18) { AddHtml(35, y, 190, 20, String.Format(" + {0}", ((Ruleset)ruleset.Flavors[i]).Title), false, false); } y += 4; if (changes > 0) { AddHtml(35, y, 190, 20, "Modifications:", false, false); y += 20; for (int i = 0; i < opts.Length; ++i) { if (defs[i] != opts[i]) { string name = ruleset.Layout.FindByIndex(i); if (name != null) // sanity { AddImage(35, y, opts[i] ? 0xD3 : 0xD2); AddHtml(60, y, 165, 22, name, false, false); } y += 22; } } } else { AddHtml(35, y, 190, 20, "Modifications: None", false, false); y += 20; } y += 8; AddHtml(35, y, 176, 20, "Continue?", false, false); y -= 2; AddButton(102, y, 247, 248, 1, GumpButtonType.Reply, 0); AddButton(169, y, 242, 241, 3, GumpButtonType.Reply, 0); #endregion } }
public AcceptDuelGump(Mobile challenger, Mobile challenged, DuelContext context, Participant p, int slot) : base(50, 50) { this.m_Challenger = challenger; this.m_Challenged = challenged; this.m_Context = context; this.m_Participant = p; this.m_Slot = slot; challenged.CloseGump(typeof(AcceptDuelGump)); this.Closable = false; this.AddPage(0); //AddBackground( 0, 0, 400, 220, 9150 ); this.AddBackground(1, 1, 398, 218, 3600); //AddBackground( 16, 15, 369, 189, 9100 ); this.AddImageTiled(16, 15, 369, 189, 3604); this.AddAlphaRegion(16, 15, 369, 189); this.AddImage(215, -43, 0xEE40); //AddImage( 330, 141, 0x8BA ); this.AddHtml(22 - 1, 22, 294, 20, this.Color(this.Center("Duel Challenge"), BlackColor32), false, false); this.AddHtml(22 + 1, 22, 294, 20, this.Color(this.Center("Duel Challenge"), BlackColor32), false, false); this.AddHtml(22, 22 - 1, 294, 20, this.Color(this.Center("Duel Challenge"), BlackColor32), false, false); this.AddHtml(22, 22 + 1, 294, 20, this.Color(this.Center("Duel Challenge"), BlackColor32), false, false); this.AddHtml(22, 22, 294, 20, this.Color(this.Center("Duel Challenge"), LabelColor32), false, false); string fmt; if (p.Contains(challenger)) { fmt = "You have been asked to join sides with {0} in a duel. Do you accept?"; } else { fmt = "You have been challenged to a duel from {0}. Do you accept?"; } this.AddHtml(22 - 1, 50, 294, 40, this.Color(String.Format(fmt, challenger.Name), BlackColor32), false, false); this.AddHtml(22 + 1, 50, 294, 40, this.Color(String.Format(fmt, challenger.Name), BlackColor32), false, false); this.AddHtml(22, 50 - 1, 294, 40, this.Color(String.Format(fmt, challenger.Name), BlackColor32), false, false); this.AddHtml(22, 50 + 1, 294, 40, this.Color(String.Format(fmt, challenger.Name), BlackColor32), false, false); this.AddHtml(22, 50, 294, 40, this.Color(String.Format(fmt, challenger.Name), 0xB0C868), false, false); this.AddImageTiled(32, 88, 264, 1, 9107); this.AddImageTiled(42, 90, 264, 1, 9157); this.AddRadio(24, 100, 9727, 9730, true, 1); this.AddHtml(60 - 1, 105, 250, 20, this.Color("Yes, I will fight this duel.", BlackColor32), false, false); this.AddHtml(60 + 1, 105, 250, 20, this.Color("Yes, I will fight this duel.", BlackColor32), false, false); this.AddHtml(60, 105 - 1, 250, 20, this.Color("Yes, I will fight this duel.", BlackColor32), false, false); this.AddHtml(60, 105 + 1, 250, 20, this.Color("Yes, I will fight this duel.", BlackColor32), false, false); this.AddHtml(60, 105, 250, 20, this.Color("Yes, I will fight this duel.", LabelColor32), false, false); this.AddRadio(24, 135, 9727, 9730, false, 2); this.AddHtml(60 - 1, 140, 250, 20, this.Color("No, I do not wish to fight.", BlackColor32), false, false); this.AddHtml(60 + 1, 140, 250, 20, this.Color("No, I do not wish to fight.", BlackColor32), false, false); this.AddHtml(60, 140 - 1, 250, 20, this.Color("No, I do not wish to fight.", BlackColor32), false, false); this.AddHtml(60, 140 + 1, 250, 20, this.Color("No, I do not wish to fight.", BlackColor32), false, false); this.AddHtml(60, 140, 250, 20, this.Color("No, I do not wish to fight.", LabelColor32), false, false); this.AddRadio(24, 170, 9727, 9730, false, 3); this.AddHtml(60 - 1, 175, 250, 20, this.Color("No, knave. Do not ask again.", BlackColor32), false, false); this.AddHtml(60 + 1, 175, 250, 20, this.Color("No, knave. Do not ask again.", BlackColor32), false, false); this.AddHtml(60, 175 - 1, 250, 20, this.Color("No, knave. Do not ask again.", BlackColor32), false, false); this.AddHtml(60, 175 + 1, 250, 20, this.Color("No, knave. Do not ask again.", BlackColor32), false, false); this.AddHtml(60, 175, 250, 20, this.Color("No, knave. Do not ask again.", LabelColor32), false, false); this.AddButton(314, 173, 247, 248, 1, GumpButtonType.Reply, 0); Timer.DelayCall(TimeSpan.FromSeconds(15.0), new TimerCallback(AutoReject)); }
public ParticipantTarget(DuelContext context, Participant p, int index) : base(12, false, TargetFlags.None) { m_Context = context; m_Participant = p; m_Index = index; }
public ReadyGump(Mobile from, DuelContext context, int count) : base(50, 50) { m_From = from; m_Context = context; m_Count = count; ArrayList parts = context.Participants; int height = 25 + 20; for (int i = 0; i < parts.Count; ++i) { Participant p = (Participant)parts[i]; height += 4; if (p.Players.Length > 1) { height += 22; } height += (p.Players.Length * 22); } height += 25; Closable = true; Dragable = false; AddPage(0); AddBackground(0, 0, 260, height, 9250); AddBackground(10, 10, 240, height - 20, 0xDAC); if (count == -1) { AddHtml(35, 25, 190, 20, Center("Ready"), false, false); } else { AddHtml(35, 25, 190, 20, Center("Starting"), false, false); AddHtml(35, 25, 190, 20, "<DIV ALIGN=RIGHT>" + count.ToString(), false, false); } int y = 25 + 20; for (int i = 0; i < parts.Count; ++i) { Participant p = (Participant)parts[i]; y += 4; bool isAllReady = true; int yStore = y; int offset = 0; if (p.Players.Length > 1) { AddHtml(35 + 14, y, 176, 20, String.Format("Participant #{0}", i + 1), false, false); y += 22; offset = 10; } for (int j = 0; j < p.Players.Length; ++j) { DuelPlayer pl = p.Players[j]; if (pl != null && pl.Ready) { AddImage(35 + offset, y + 4, 0x939); } else { AddImage(35 + offset, y + 4, 0x938); isAllReady = false; } string name = (pl == null ? "(Empty)" : pl.Mobile.Name); AddHtml(35 + offset + 14, y, 166, 20, name, false, false); y += 22; } if (p.Players.Length > 1) { AddImage(35, yStore + 4, isAllReady ? 0x939 : 0x938); } } }
public void Start(Arena arena, Tournament tourney) { TourneyParticipant first = Participants[0]; DuelContext dc = new DuelContext(first.Players[0], tourney.Ruleset.Layout, false); dc.Ruleset.Options.SetAll(false); dc.Ruleset.Options.Or(tourney.Ruleset.Options); for (int i = 0; i < Participants.Count; ++i) { TourneyParticipant tourneyPart = Participants[i]; Participant duelPart = new Participant(dc, tourneyPart.Players.Count) { TourneyPart = tourneyPart }; for (int j = 0; j < tourneyPart.Players.Count; ++j) { duelPart.Add(tourneyPart.Players[j]); } for (int j = 0; j < duelPart.Players.Length; ++j) { if (duelPart.Players[j] != null) { duelPart.Players[j].Ready = true; } } dc.Participants.Add(duelPart); } if (tourney.EventController != null) { dc.m_EventGame = tourney.EventController.Construct(dc); } dc.m_Tournament = tourney; dc.m_Match = this; dc.m_OverrideArena = arena; if (tourney.SuddenDeath > TimeSpan.Zero && (tourney.SuddenDeathRounds == 0 || tourney.Pyramid.Levels.Count <= tourney.SuddenDeathRounds)) { dc.StartSuddenDeath(tourney.SuddenDeath); } dc.SendReadyGump(0); if (dc.StartedBeginCountdown) { Context = dc; for (int i = 0; i < Participants.Count; ++i) { TourneyParticipant p = Participants[i]; for (int j = 0; j < p.Players.Count; ++j) { Mobile mob = p.Players[j]; foreach (Mobile view in mob.GetMobilesInRange(18)) { if (!mob.CanSee(view)) { mob.Send(view.RemovePacket); } } mob.LocalOverheadMessage(MessageType.Emote, 0x3B2, false, "* Your mind focuses intently on the fight and all other distractions fade away *"); } } } else { dc.Unregister(); dc.StopCountdown(); } }