public static void On_Logout(LogoutEventArgs args) { PlayerMobile pm = (PlayerMobile)args.Mobile; for (int i = 0; i < Registry.Count; ++i) { Duel d = (Duel)Registry[i]; if (d.Caller == pm) { Registry.Remove(d); d.EndSelf(); } else if (d.InDuel(pm)) { if (!d.InProgress) { d.RefundBuyIn(pm); d.SendControllerSetup(); } else { d.EchoMessage("A player disconnected, duel must end."); d.EndSelf(); } } } }
public static void On_ShutDown(ShutdownEventArgs args) { for (int i = 0; i < Registry.Count; ++i) { Duel d = (Duel)Registry[i]; d.EndSelf(); } }
protected override void OnTick() { if (Handeling.InProgress && !Handeling.Ended) { Handeling.EndSelf(); } this.Stop(); }
public static void DuelCleanUp_DelayLoop() { for (int i = 0; i < Registry.Count; ++i) { Duel d = (Duel)Registry[i]; if (d.Caller.NetState == null || d.Ended) { Registry.Remove(d); d.EndSelf(); } } Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerCallback(DuelCleanUp_DelayLoop)); }
public override void OnResponse(NetState sender, RelayInfo info) { Mobile from = sender.Mobile; switch (info.ButtonID) { case 0: // Close { Handling.EndSelf(); return; } case 1: // Start { if (FilledTeams(Handling) < 2) { Handling.EchoMessage("You must have at least two participating teams to start a duel."); from.SendGump(new DuelSetup_Main(Handling)); return; } else if (!CheckLoggedIn()) { Handling.EchoMessage("One or more players participating in this duel have logged out, duel start delayed."); from.SendGump(new DuelSetup_Main(Handling)); return; } else if (!AllAlive()) { Handling.EchoMessage("Not all players participating in the duel are alive, duel start delayed."); from.SendGump(new DuelSetup_Main(Handling)); return; } else // Start Duel { Handling.UpdateAllPending(); return; } } case 2: // Rules { from.SendGump(new DuelSetup_Rules(Handling)); from.SendMessage("If the box next to something is checked, it is allowed."); return; } case 3: // Add A Team { if (Handling.Teams.Count >= 4) { from.SendMessage("There is a maximum of 4 teams"); from.SendGump(new DuelSetup_Main(Handling)); return; } Duel_Team toadd = new Duel_Team((Handling.Teams.Count + 1)); toadd.Players.Add("@null"); Handling.Teams.Add((Handling.Teams.Count + 1), toadd); from.SendGump(new DuelSetup_Main(Handling)); return; } case 4: // Remove A Team { if (Handling.Teams.Count <= 2) { from.SendMessage("Cannot have less then 2 teams."); from.SendGump(new DuelSetup_Main(Handling)); return; } Duel_Team toremove = (Duel_Team)Handling.Teams[Handling.Teams.Count]; if (toremove.Players.Count <= 1 && toremove.Players[0] == "@null") { Handling.Teams.Remove(Handling.Teams.Count); } else { from.SendMessage("You can not remove a team that contains players, move the players to a higher team."); } from.SendGump(new DuelSetup_Main(Handling)); return; } case 5: // Set Buy In { if (FilledTeams(Handling) != 1) { from.SendMessage("You cannot set the duel buy in after you have already added players."); from.SendGump(new DuelSetup_Main(Handling)); return; } from.SendGump(new DuelSetup_SetBuyIn(Handling)); return; } } if (info.ButtonID >= 6) { int id = (info.ButtonID - 5); from.SendGump(new DuelSetup_ParticipantSetup(Handling, id)); } }
public void StartDuel(Duel d) { Handeling = d; if (Handeling.Caller.NetState == null) { Handeling.EndSelf(); return; } HasStarted = true; InUse = true; Handeling.InProgress = true; Handeling.Controller = this; if (PlayerLocations == null) { PlayerLocations = new Dictionary <Serial, Point3D>(); } if (PlayerMaps == null) { PlayerMaps = new Dictionary <Serial, Map>(); } if (PlayerItems == null) { PlayerItems = new Dictionary <Serial, ArrayList>(); } if (ItemLocations == null) { ItemLocations = new Dictionary <Serial, Point3D>(); } if (InsuredItems == null) { InsuredItems = new ArrayList(); } if (FrozenItems == null) { FrozenItems = new ArrayList(); } IEnumerator key = Handeling.Teams.Keys.GetEnumerator(); for (int i = 0; i < Handeling.Teams.Count; ++i) { key.MoveNext(); Duel_Team d_team = (Duel_Team)Handeling.Teams[(int)key.Current]; for (int i2 = 0; i2 < d_team.Players.Count; ++i2) { object o = (object)d_team.Players[i2]; if (o is PlayerMobile) { PlayerMobile pm = (PlayerMobile)o; StorePlayer(pm); SpawnPlayer(pm, (int)key.Current); PlayerNoto(pm); pm.Blessed = true; pm.Frozen = true; pm.Spell = null; ResurrectPlayer(pm); } } } Timer.DelayCall(TimeSpan.FromSeconds(3.0), new TimerCallback(UnInvul)); EndTimer = new Duel_EndTimer(Handeling); }