public virtual IEnumerable <PlayerMobile> GetLocalBroadcastList() { if (BattleRegion != null) { foreach (var pm in BattleRegion.GetMobiles().OfType <PlayerMobile>().Where(IsOnline)) { yield return(pm); } } if (SpectateRegion != null) { foreach (var pm in SpectateRegion.GetMobiles().OfType <PlayerMobile>().Where(IsOnline)) { yield return(pm); } } }
public void MicroSync() { if (!Validate()) { State = PvPBattleState.Internal; return; } if (BattleRegion != null) { BattleRegion.MicroSync(); } if (SpectateRegion != null) { SpectateRegion.MicroSync(); } ForEachTeam(t => t.MicroSync()); OnMicroSync(); }
public void MicroSync() { if (!Validate()) { State = PvPBattleState.Internal; return; } if (BattleRegion != null) { BattleRegion.MicroSync(); } if (SpectateRegion != null) { SpectateRegion.MicroSync(); } Teams.Where(team => team != null && !team.Deleted).ForEach(team => team.MicroSync()); OnMicroSync(); }
public virtual bool Validate(Mobile viewer, List <string> errors, bool pop = true) { if (Deleted) { errors.Add("This battle has been deleted."); return(false); } if (String.IsNullOrWhiteSpace(Name)) { errors.Add("Select a valid Name."); errors.Add("[Options] -> [Edit Options]"); if (pop) { return(false); } } if (String.IsNullOrWhiteSpace(Description)) { errors.Add("Select a valid Description."); errors.Add("[Options] -> [Edit Options]"); if (pop) { return(false); } } if (SpectateAllowed) { if (SpectateRegion == null) { errors.Add("Select a valid Spectate Region."); errors.Add("[Options] -> [Edit Spectage Region]"); if (pop) { return(false); } } else if (Options.Locations.SpectateBounds.Count == 0) { errors.Add("The Spectate Region has no zones."); errors.Add("[Options] -> [Edit Spectage Region]"); if (pop) { return(false); } } } if (BattleRegion == null) { errors.Add("Select a valid Battle Region."); errors.Add("[Options] -> [Edit Battle Region]"); if (pop) { return(false); } } else if (Options.Locations.BattleBounds.Count == 0) { errors.Add("The Battle Region has no zones."); errors.Add("[Options] -> [Edit Battle Region]"); if (pop) { return(false); } } if (Options.Locations.Map == Map.Internal) { errors.Add("The Battle Map must not be Internal."); errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]"); if (pop) { return(false); } } if (Options.Locations.Eject.Internal) { errors.Add("The Eject Map must not be Internal."); errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]"); if (pop) { return(false); } } if (Options.Locations.Eject == Point3D.Zero) { errors.Add("Select a valid Eject Location."); errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]"); if (pop) { return(false); } } else if (BattleRegion != null && BattleRegion.Contains(Options.Locations.Eject.Location, Options.Locations.Eject.Map)) { errors.Add("Eject Location must be outside the Battle Region."); errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]"); if (pop) { return(false); } } if (SpectateAllowed) { if (Options.Locations.SpectateJoin == Point3D.Zero) { errors.Add("Select a valid Spectator Join location."); errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]"); if (pop) { return(false); } } else if (SpectateRegion != null && !SpectateRegion.Contains(Options.Locations.SpectateJoin)) { errors.Add("Spectate Join Location must be within the Spectate Region."); errors.Add("[Options] -> [Edit Advanced Options] -> [Locations]"); if (pop) { return(false); } } } if (Schedule == null) { errors.Add("No Schedule has been set for this battle."); errors.Add("[Options] -> [View Schedule]"); if (pop) { return(false); } } else if (Schedule.Enabled && Schedule.NextGlobalTick == null) { errors.Add("The Schedule has no more future dates."); errors.Add("[Options] -> [View Schedule]"); if (pop) { return(false); } } if (IdleKick && IdleThreshold.TotalSeconds < 10.0) { errors.Add("The Idle Threshold must be greater than, or equal to 10 seconds."); errors.Add("[Options] -> [Edit Options]"); if (pop) { return(false); } } if (Teams.Count == 0) { errors.Add("There are no teams available for this Battle."); errors.Add("[Options] -> [View Teams]"); if (pop) { return(false); } } else if (Teams.Any(team => !team.Validate(viewer))) { errors.Add("One or more teams did not pass validation."); errors.Add("[Options] -> [View Teams]"); if (pop) { return(false); } } return(errors.Count == 0); }
public virtual void Serialize(GenericWriter writer) { var version = writer.SetVersion(7); if (version > 5) { writer.WriteBlock( w => { if (version > 6) { Serial.Serialize(w); } else { w.WriteType(Serial, t => Serial.Serialize(w)); } }); } switch (version) { case 7: case 6: case 5: writer.Write(Hidden); goto case 4; case 4: writer.Write(_FloorItemDelete); goto case 3; case 3: case 2: writer.Write(Gate); goto case 1; case 1: { writer.Write(Category); writer.Write(Ranked); writer.Write(InviteWhileRunning); } goto case 0; case 0: { if (version < 6) { writer.WriteBlock(w => w.WriteType(Serial, t => Serial.Serialize(w))); } writer.Write(DebugMode); writer.WriteFlag(_State); writer.Write(_Name); writer.Write(Description); writer.Write(AutoAssign); writer.Write(UseTeamColors); writer.Write(IgnoreCapacity); writer.Write(_SubCommandPrefix); writer.Write(QueueAllowed); writer.Write(SpectateAllowed); writer.Write(KillPoints); writer.Write(PointsBase); writer.Write(PointsRankFactor); writer.Write(IdleKick); writer.Write(IdleThreshold); writer.WriteFlag(LastState); writer.Write(LastStateChange); writer.Write(_LightLevel); writer.Write(LogoutDelay); writer.WriteItemList(Doors, true); writer.WriteBlock(w => w.WriteType(Options, t => Options.Serialize(w))); writer.WriteBlock(w => w.WriteType(Schedule, t => Schedule.Serialize(w))); writer.WriteBlock(w => w.WriteType(BattleRegion, t => BattleRegion.Serialize(w))); writer.WriteBlock(w => w.WriteType(SpectateRegion, t => SpectateRegion.Serialize(w))); writer.WriteBlockList(Teams, (w, team) => w.WriteType(team, t => team.Serialize(w))); } break; } }