/// <summary> /// Sets a specific team's party. <see cref="BattleState"/> will change to <see cref="PBEBattleState.ReadyToBegin"/> if all teams have parties. /// </summary> /// <param name="team">The team which will have its party set.</param> /// <param name="party">The Pokémon party <paramref name="team"/> will use.</param> /// <exception cref="InvalidOperationException">Thrown when <see cref="BattleState"/> is not <see cref="PBEBattleState.WaitingForPlayers"/>.</exception> /// <exception cref="ArgumentNullException">Thrown when <paramref name="party"/> is null.</exception> /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="party"/>'s size is invalid.</exception> public static void CreateTeamParty(PBETeam team, IEnumerable <PBEPokemonShell> party) { if (team.Battle.BattleState != PBEBattleState.WaitingForPlayers) { throw new InvalidOperationException($"{nameof(BattleState)} must be {PBEBattleState.WaitingForPlayers} to set a team's party."); } if (party == null) { throw new ArgumentNullException(nameof(party)); } if (party.Count() == 0 || party.Count() > team.Battle.Settings.MaxPartySize) { throw new ArgumentOutOfRangeException(nameof(party)); } team.CreateParty(party, ref team.Battle.pkmnIdCounter); team.Battle.CheckForReadiness(); }
/// <summary>Sets a specific team's party. <see cref="BattleState"/> will change to <see cref="PBEBattleState.ReadyToBegin"/> if all teams have parties.</summary> /// <param name="team">The team which will have its party set.</param> /// <param name="teamShell">The information <paramref name="team"/> will use to create its party.</param> /// <param name="teamTrainerName">The name of the trainer(s) on <paramref name="team"/>.</param> /// <exception cref="InvalidOperationException">Thrown when <see cref="BattleState"/> is not <see cref="PBEBattleState.WaitingForPlayers"/> or <paramref name="team"/> already has its party set.</exception> /// <exception cref="ArgumentNullException">Thrown when <paramref name="team"/> or <paramref name="teamShell"/> is null.</exception> /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="teamShell"/>'s settings are unequal to <paramref name="team"/>'s battle's settings or when <paramref name="teamTrainerName"/> is invalid.</exception> public static void CreateTeamParty(PBETeam team, PBETeamShell teamShell, string teamTrainerName) { if (team == null) { throw new ArgumentNullException(nameof(team)); } if (teamShell == null) { throw new ArgumentNullException(nameof(teamShell)); } if (string.IsNullOrEmpty(teamTrainerName)) { throw new ArgumentOutOfRangeException(nameof(teamTrainerName)); } if (team.IsDisposed) { throw new ObjectDisposedException(nameof(team)); } if (teamShell.IsDisposed) { throw new ObjectDisposedException(nameof(teamShell)); } if (!teamShell.Settings.Equals(team.Battle.Settings)) { throw new ArgumentOutOfRangeException(nameof(teamShell), $"\"{nameof(teamShell)}\"'s settings must be equal to the battle's settings."); } if (team.Battle.BattleState != PBEBattleState.WaitingForPlayers) { throw new InvalidOperationException($"{nameof(BattleState)} must be {PBEBattleState.WaitingForPlayers} to set a team's party."); } if (team.Party.Count > 0) { throw new InvalidOperationException("This team already has its party set."); } team.CreateParty(teamShell, teamTrainerName); team.Battle.CheckForReadiness(); }