private async Task MainAsync(string[] args) { PBEUtils.CreateDatabaseConnection(string.Empty); _client = new DiscordSocketClient(new DiscordSocketConfig { WebSocketProvider = Discord.Net.Providers.WS4Net.WS4NetProvider.Instance }); _commands = new CommandService(new CommandServiceConfig { DefaultRunMode = RunMode.Async }); _services = new ServiceCollection() .AddSingleton(_client) .AddSingleton(_commands) .BuildServiceProvider(); await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), _services); _client.Log += LogMessage; _client.MessageReceived += CommandMessageReceived; _client.ReactionAdded += ReactionListener.Client_ReactionAdded; await _client.LoginAsync(TokenType.Bot, args[0]); // Token is passed in as args[0] await _client.StartAsync(); await Task.Delay(-1); }
public static void Main() { SqliteConnection GetConnection() { SQLitePCL.Batteries_V2.Init(); const string databasePath = @"../../../../\PokemonBattleEngine\PokemonBattleEngine.db"; var con = new SqliteConnection($"Filename={databasePath};"); con.Open(); return(con); } Extra e = Extra.AIBattle; switch (e) { case Extra.AIBattle: { PBEUtils.CreateDatabaseConnection(string.Empty); AIBattle.Test(); break; } case Extra.FontDumper: FontDumper.Dump(); break; case Extra.LocalizationDumper: { using (SqliteConnection con = GetConnection()) { LocalizationDumper.Dump(con); con.Close(); } break; } case Extra.NARCTextDumper: NARCTextDumper.Dump(); break; case Extra.PokemonDataDumper: { using (SqliteConnection con = GetConnection()) { PokemonDataDumper.Dump(con); con.Close(); } break; } default: throw new ArgumentOutOfRangeException(nameof(e)); } }
protected override void Initialize() { PBEUtils.CreateDatabaseConnection(string.Empty); Console.WriteLine("Server online."); Reset(); }
public static void Main(string[] args) { PBEUtils.CreateDatabaseConnection(string.Empty); new BattleServer(args); }
public static void SetWorkingDirectory(string workingDirectory) { PBEUtils.CreateDatabaseConnection(workingDirectory); WorkingDirectory = workingDirectory; }
public void Basic_Actions_Checks() { PBEUtils.CreateDatabaseConnection(string.Empty); PBESettings settings = PBESettings.DefaultSettings; var team1Shell = new PBETeamShell(settings, 2, true); PBEPokemonShell p = team1Shell[0]; p.Species = PBESpecies.Koffing; p.Item = PBEItem.None; p.Moveset[0].Move = PBEMove.Selfdestruct; var team2Shell = new PBETeamShell(settings, 1, true); p = team2Shell[0]; p.Species = PBESpecies.Darkrai; p.Item = PBEItem.None; p.Moveset[0].Move = PBEMove.Protect; var battle = new PBEBattle(PBEBattleFormat.Single, team1Shell, "Team 1", team2Shell, "Team 2"); team1Shell.Dispose(); team2Shell.Dispose(); battle.Begin(); PBETeam t = battle.Teams[0]; var a = new PBETurnAction(t.Party[0].Id, PBEMove.Selfdestruct, PBETurnTarget.FoeCenter); var a1 = new PBETurnAction[] { a }; Assert.Throws <ArgumentNullException>(() => PBEBattle.SelectActionsIfValid(null, a1)); // Throw for null team Assert.Throws <ArgumentNullException>(() => PBEBattle.SelectActionsIfValid(t, null)); // Throw for null collection Assert.Throws <ArgumentNullException>(() => PBEBattle.SelectActionsIfValid(t, new PBETurnAction[] { null })); // Throw for null elements Assert.False(PBEBattle.SelectActionsIfValid(t, new PBETurnAction[] { a, a })); // False for too many actions Assert.True(PBEBattle.SelectActionsIfValid(t, a1)); // True for good actions // TODO: bad move, bad targets, bad targets with templockedmove, battle status, bad pkmn id, wrong team pkmn id, duplicate pkmn id, can't switch out but tried, invalid switch mon (null hp pos), duplicate switch mon Assert.False(PBEBattle.SelectActionsIfValid(t, a1)); // False because actions were already submitted Assert.False(PBEBattle.SelectActionsIfValid(t, Array.Empty <PBETurnAction>())); // False for 0 despite us now needing 0 additional actions t = battle.Teams[1]; Assert.True(PBEBattle.SelectActionsIfValid(t, new PBETurnAction[] { new PBETurnAction(t.Party[0].Id, PBEMove.Protect, PBETurnTarget.AllyCenter) })); // True for good actions battle.RunTurn(); // Darkrai uses Protect, Koffing uses Selfdestruct, Koffing faints t = battle.Teams[0]; var s = new PBESwitchIn(t.Party[1].Id, PBEFieldPosition.Center); var s1 = new PBESwitchIn[] { s }; Assert.Throws <ArgumentNullException>(() => PBEBattle.SelectSwitchesIfValid(null, s1)); // Throw for null team Assert.Throws <ArgumentNullException>(() => PBEBattle.SelectSwitchesIfValid(t, null)); // Throw for null collection Assert.Throws <ArgumentNullException>(() => PBEBattle.SelectSwitchesIfValid(t, new PBESwitchIn[] { null })); // Throw for null elements Assert.False(PBEBattle.SelectSwitchesIfValid(t, new PBESwitchIn[] { s, s })); // False for too many Assert.True(PBEBattle.SelectSwitchesIfValid(t, s1)); // True for good switches // Below two wouldn't work because of battle status lol //Assert.False(PBEBattle.SelectSwitchesIfValid(t, s1)); // False because switches were already submitted //Assert.False(PBEBattle.SelectSwitchesIfValid(t, Array.Empty<PBESwitchIn>())); // False for 0 despite us now needing 0 additional actions battle.Dispose(); Assert.Throws <ObjectDisposedException>(() => PBEBattle.SelectActionsIfValid(t, a1)); // Throw for disposed battle Assert.Throws <ObjectDisposedException>(() => PBEBattle.SelectSwitchesIfValid(t, s1)); // Throw for disposed battle }