public ArenaParticipant(PlayerMobile player, ArenaMatch arenaMatch, int teamIndex) : base(0x0) { m_Player = player; m_ArenaMatch = arenaMatch; if (m_ArenaMatch == null) { Delete(); } ArenaTeam team1 = m_ArenaMatch.GetTeam(0); ArenaTeam team2 = m_ArenaMatch.GetTeam(1); if (team1 != null && teamIndex == 0) { team1.m_Participants.Add(this); } if (team2 != null && teamIndex == 1) { team2.m_Participants.Add(this); } Visible = false; Movable = false; }
public ArenaTeam GetPlayerTeam() { if (m_Player == null) { return(null); } ArenaTeam arenaTeam = null; if (!ArenaMatch.IsValidArenaMatch(m_ArenaMatch, null, false)) { return(null); } foreach (ArenaTeam team in m_ArenaMatch.m_Teams) { if (team == null) { continue; } if (team.Deleted) { continue; } if (team.GetPlayerParticipant(m_Player) != null) { return(team); } } return(arenaTeam); }
public static bool IsValidArenaMatch(ArenaMatch arenaMatch, PlayerMobile player, bool checkIfPlayerCanJoin) { if (arenaMatch == null) { return(false); } if (arenaMatch.Deleted) { return(false); } if (arenaMatch.m_ArenaGroupController == null) { return(false); } if (arenaMatch.m_ArenaGroupController.Deleted) { return(false); } if (arenaMatch.m_Ruleset == null) { return(false); } if (arenaMatch.m_Ruleset.Deleted) { return(false); } if (checkIfPlayerCanJoin) { if (!arenaMatch.CanPlayerJoinMatch(player)) { return(false); } } ArenaTeam arenaTeam1 = arenaMatch.GetTeam(0); ArenaTeam arenaTeam2 = arenaMatch.GetTeam(1); if (arenaTeam1 == null) { return(false); } if (arenaTeam1.Deleted) { return(false); } if (arenaTeam2 == null) { return(false); } if (arenaTeam2.Deleted) { return(false); } return(true); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); //Version 0 if (version >= 0) { m_ArenaMatch = reader.ReadItem() as ArenaMatch; m_MatchStatus = (ArenaMatchResultStatusType)reader.ReadInt(); m_CompletionDate = reader.ReadDateTime(); m_MatchType = (ArenaRuleset.MatchTypeType)reader.ReadInt(); m_MatchDuration = reader.ReadTimeSpan(); m_WinningTeam = reader.ReadString(); int teamResultEntriesCount = reader.ReadInt(); for (int a = 0; a < teamResultEntriesCount; a++) { bool winner = reader.ReadBool(); string teamName = reader.ReadString(); List <ArenaMatchPlayerResultEntry> m_playerResultEntries = new List <ArenaMatchPlayerResultEntry>(); int playerResultEntriesCount = reader.ReadInt(); for (int b = 0; b < playerResultEntriesCount; b++) { PlayerMobile player = reader.ReadMobile() as PlayerMobile; string playerName = reader.ReadString(); bool alive = reader.ReadBool(); int lowestHP = reader.ReadInt(); TimeSpan timeAlive = reader.ReadTimeSpan(); int damageDealt = reader.ReadInt(); int damageReceived = reader.ReadInt(); ArenaMatchPlayerResultEntry playerResultEntry = new ArenaMatchPlayerResultEntry(player, playerName, alive, lowestHP, timeAlive, damageDealt, damageReceived); m_playerResultEntries.Add(playerResultEntry); } ArenaMatchTeamResultEntry teamResultEntry = new ArenaMatchTeamResultEntry(winner, teamName, m_playerResultEntries); m_TeamResultEntries.Add(teamResultEntry); } } //----- ArenaPersistance.m_ArenaMatchResultEntries.Add(this); if (m_ArenaMatch != null) { m_ArenaMatch.m_ArenaMatchResultEntry = this; } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); //Version 0 if (version >= 0) { m_Player = (PlayerMobile)reader.ReadMobile(); m_SavedRulesetPreset = (ArenaRuleset)reader.ReadItem(); m_ArenaMatch = (ArenaMatch)reader.ReadItem(); Ranked1vs1Wins = reader.ReadInt(); Ranked1vs1Losses = reader.ReadInt(); Ranked2vs2Wins = reader.ReadInt(); Ranked2vs2Losses = reader.ReadInt(); Ranked3vs3Wins = reader.ReadInt(); Ranked3vs3Losses = reader.ReadInt(); Ranked4vs4Wins = reader.ReadInt(); Ranked4vs4Losses = reader.ReadInt(); Tournament1vs1EventsWon = reader.ReadInt(); Tournament1vs1RoundsWon = reader.ReadInt(); Tournament1vs1RoundsLost = reader.ReadInt(); Tournament2vs2EventsWon = reader.ReadInt(); Tournament2vs2RoundsWon = reader.ReadInt(); Tournament2vs2RoundsLost = reader.ReadInt(); Tournament3vs3EventsWon = reader.ReadInt(); Tournament3vs3RoundsWon = reader.ReadInt(); Tournament3vs3RoundsLost = reader.ReadInt(); Tournament4vs4EventsWon = reader.ReadInt(); Tournament4vs4RoundsWon = reader.ReadInt(); Tournament4vs4RoundsLost = reader.ReadInt(); } //----- if (m_Player == null) { Delete(); } else if (m_Player.Deleted) { Delete(); } }
protected override void OnTick() { if (m_ArenaGroupController == null) { Stop(); return; } if (m_ArenaGroupController.Deleted) { Stop(); return; } if (!m_ArenaGroupController.Enabled) { Stop(); return; } if (DateTime.UtcNow >= m_ArenaGroupController.m_NextListingAudit) { m_ArenaGroupController.AuditListings(); } ArenaController emptyArena = m_ArenaGroupController.GetAvailableArena(); if (emptyArena != null) { foreach (ArenaMatch arenaMatch in m_ArenaGroupController.m_MatchListings) { if (!ArenaMatch.IsValidArenaMatch(arenaMatch, null, false)) { continue; } if (DateTime.UtcNow < arenaMatch.m_NextReadyCheck) { continue; } if (!arenaMatch.IsReadyToStart()) { continue; } List <KeyValuePair <PlayerMobile, ArenaRuleset.ArenaRulesetFailureType> > m_RulesetViolations = new List <KeyValuePair <PlayerMobile, ArenaRuleset.ArenaRulesetFailureType> >(); bool rulesetViolationExists = false; foreach (ArenaTeam arenaTeam in arenaMatch.m_Teams) { if (arenaTeam == null) { continue; } if (arenaTeam.Deleted) { continue; } foreach (ArenaParticipant arenaParticipant in arenaTeam.m_Participants) { if (arenaParticipant == null) { continue; } if (arenaParticipant.Deleted) { continue; } if (arenaParticipant.m_Player == null) { continue; } if (arenaParticipant.Deleted == null) { continue; } if (arenaMatch.m_Ruleset == null) { continue; } ArenaRuleset.ArenaRulesetFailureType rulesetFailure = arenaMatch.m_Ruleset.CheckForRulesetViolations(arenaMatch, arenaParticipant.m_Player); m_RulesetViolations.Add(new KeyValuePair <PlayerMobile, ArenaRuleset.ArenaRulesetFailureType>(arenaParticipant.m_Player, rulesetFailure)); if (rulesetFailure != ArenaRuleset.ArenaRulesetFailureType.None) { rulesetViolationExists = true; } } } if (rulesetViolationExists) { arenaMatch.BroadcastMessage("Unable to start match due to the following ruleset violations:", 0); bool arenaError = false; foreach (KeyValuePair <PlayerMobile, ArenaRuleset.ArenaRulesetFailureType> rulesetViolation in m_RulesetViolations) { string message = ""; PlayerMobile player = rulesetViolation.Key; ArenaRuleset.ArenaRulesetFailureType rule = rulesetViolation.Value; if (player == null) { continue; } switch (rulesetViolation.Value) { case ArenaRuleset.ArenaRulesetFailureType.ArenaInvalid: arenaError = true; break; case ArenaRuleset.ArenaRulesetFailureType.Dead: message = player.RawName + ": Not Alive"; break; case ArenaRuleset.ArenaRulesetFailureType.EquipmentAllowed: message = player.RawName + ": Has Restricted Equipment (worn or in backpack)"; break; case ArenaRuleset.ArenaRulesetFailureType.Follower: message = player.RawName + ": Exceeds Follower Control Slots Allowed"; break; case ArenaRuleset.ArenaRulesetFailureType.PackAnimal: message = player.RawName + ": Pack Animals Not Allowed"; break; case ArenaRuleset.ArenaRulesetFailureType.Mount: message = player.RawName + ": Mounts Not Allowed"; break; case ArenaRuleset.ArenaRulesetFailureType.NotInArenaRegion: message = player.RawName + ": Outside of Arena Region"; break; case ArenaRuleset.ArenaRulesetFailureType.NotOnline: message = player.RawName + ": Not Online"; break; case ArenaRuleset.ArenaRulesetFailureType.PoisonedWeapon: message = player.RawName + ": Exceeds Allowed Number of Poisoned Weapons"; break; case ArenaRuleset.ArenaRulesetFailureType.Transformed: message = player.RawName + ": Transformed or Disguised"; break; case ArenaRuleset.ArenaRulesetFailureType.Young: message = player.RawName + ": Young Status"; break; case ArenaRuleset.ArenaRulesetFailureType.NotEnoughArenaCredits: message = player.RawName + ": Insufficient Arena Credits"; break; } if (message != "") { arenaMatch.BroadcastMessage(message, 1256); } } if (arenaError) { arenaMatch.BroadcastMessage("Arena Configuration Error", 1256); } arenaMatch.m_NextReadyCheck = DateTime.UtcNow + ArenaMatch.ReadyCheckInterval; string timeRemaining = Utility.CreateTimeRemainingString(DateTime.UtcNow, arenaMatch.m_NextReadyCheck, false, true, true, true, true); arenaMatch.BroadcastMessage("Match will re-attempt to start in " + timeRemaining + ".", 0); } else { arenaMatch.m_MatchStatus = ArenaMatch.MatchStatusType.Fighting; ArenaFight arenaFight = new ArenaFight(); arenaFight.m_ArenaController = emptyArena; arenaFight.m_ArenaMatch = arenaMatch; arenaMatch.m_ArenaFight = arenaFight; emptyArena.m_ArenaFight = arenaFight; arenaFight.Initialize(); } } } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); //Version 0 if (version >= 0) { m_LastEventTime = reader.ReadDateTime(); m_Player = reader.ReadMobile() as PlayerMobile; m_ArenaMatch = (ArenaMatch)reader.ReadItem(); m_ReadyToggled = reader.ReadBool(); m_FightStatus = (FightStatusType)reader.ReadInt(); m_LowestHealth = reader.ReadInt(); m_TimeAlive = reader.ReadTimeSpan(); m_DamageDealt = reader.ReadInt(); m_DamageReceived = reader.ReadInt(); int spellUsages = reader.ReadInt(); for (int a = 0; a < spellUsages; a++) { string typeText = reader.ReadString(); Type spellType = null; if (typeText != "null") { spellType = Type.GetType(typeText); } int usages = reader.ReadInt(); if (spellType != null) { m_SpellUsages.Add(new ArenaSpellUsage(spellType, usages)); } } int itemUsages = reader.ReadInt(); for (int a = 0; a < itemUsages; a++) { string typeText = reader.ReadString(); Type itemType = null; if (typeText != "null") { itemType = Type.GetType(typeText); } int usages = reader.ReadInt(); if (itemType != null) { m_ItemUsages.Add(new ArenaItemUsage(itemType, usages)); } } } //---- //Force On System Start m_ReadyToggled = false; if (m_ArenaMatch == null) { Delete(); } }