protected async Task RunSession(AccountEntity acc, GenomeEntity genome) { try { // Connect to server var server = new ServerStuff(acc.Token, false, _turns, _serverUrl, null); // Play game var player = new Player(acc.Name, server); await player.Run(); if (server.finished) { var result = new GameEntity { AccoundId = acc.Id, AccountName = acc.Name, GameId = server.Id, GenomeId = genome?.Id, IsWinner = server.heroes.OrderBy(x => x.Gold).First().Name == acc.Name }; await _gameDataProvider.Add(result); } } catch (Exception ex) { Console.WriteLine("Unhandled exception " + ex); } }
private static void Server(string installpath, string username = "", string password = "", bool steamauth = false, string mounts = "") { if (installpath != null & username == "" & password == "") { new ServerFormStuffs().OpenServerForm(installpath); } else if (installpath == null) { Console.WriteLine(@"Please specify where to install the server"); string input = Console.ReadLine(); if (input != null && input.Contains(@" ")) { input = MiscFunctions.PutIntoQuotes(input); } Console.WriteLine(input); Console.ReadLine(); new ServerFormStuffs().OpenServerForm(input); } else if (username != null & password != null & !steamauth & mounts == "") { ServerStuff fun = new ServerStuff(installpath, username, password); fun.RunFun(); } else if (username != "" & password != "" & steamauth & mounts == "") { ServerStuff fun = new ServerStuff(installpath, username, password, true); fun.RunFun(); } else if (username != "" & password != "" & !steamauth & mounts != "") { ServerStuff fun = new ServerStuff(installpath, username, password, false, mounts); fun.RunFun(); } else if (username != "" & password != "" & steamauth & mounts != "") { ServerStuff fun = new ServerStuff(installpath, username, password, true, mounts); fun.RunFun(); } }
public Player(string name, ServerStuff serverStuff) { _name = name; this.ServerStuff = serverStuff; }