public void PartySubmitted(Player player, PBETeamShell teamShell) { if (_state != ServerState.WaitingForParties) { return; } lock (this) { if (_state != ServerState.WaitingForParties) { return; } foreach (PBEPokemonShell shell in teamShell) { try { // Not currently necessary, but it would be necessary eventually because PBEMovesetBuilder cannot check if a moveset "makes sense" for the method the Pokémon was obtained in // Eventually we would probably want to store that sort of information in PBEPokemonShell PBELegalityChecker.MoveLegalityCheck(shell.Moveset); } catch (Exception e) { Console.WriteLine($"Illegal moveset received from {player.TrainerName}"); Console.WriteLine(e.Message); CancelMatch(); return; } } PBEBattle.CreateTeamParty(_battle.Teams[player.BattleId], teamShell, player.TrainerName); } }
private void BattleStateHandler(PBEBattle battle) { Console.WriteLine("Battle state changed: {0}", battle.BattleState); switch (battle.BattleState) { case PBEBattleState.ReadyToBegin: { _resetEvent.Reset(); foreach (Player player in _battlers) { foreach (PBEPokemonShell shell in player.TeamShell) { try { // Not currently necessary, but it would be necessary eventually because PBEMovesetBuilder cannot check if a moveset "makes sense" for the method the Pokémon was obtained in // Eventually we would probably want to store that sort of information in PBEPokemonShell PBELegalityChecker.MoveLegalityCheck(shell.Moveset); } catch (Exception e) { Console.WriteLine($"Illegal moveset received from {player.TrainerName}"); Console.WriteLine(e.Message); CancelMatch(); return; } } } Console.WriteLine("Battle starting!"); new Thread(battle.Begin) { Name = "Battle Thread" }.Start(); break; } case PBEBattleState.Processing: { _resetEvent.Reset(); _state = ServerState.BattleProcessing; break; } case PBEBattleState.ReadyToRunTurn: { new Thread(battle.RunTurn) { Name = "Battle Thread" }.Start(); break; } case PBEBattleState.Ended: { _resetEvent.Set(); _state = ServerState.BattleEnded; break; } } }
public void RandomizeMoves() { var moves = new List <PBEMove>(PBELegalityChecker.GetLegalMoves(Species, Form, Level, PBESettings.DefaultSettings)); for (int i = 0; i < PBESettings.DefaultNumMoves; i++) { Moveset[i].Clear(); } for (int i = 0; i < PBESettings.DefaultNumMoves && moves.Count > 0; i++) { Moveset.MovesetSlot slot = Moveset[i]; PBEMove move = PBEUtils.GlobalRandom.RandomElement(moves); moves.Remove(move); slot.Move = move; slot.PPUps = 0; slot.SetMaxPP(); } }