예제 #1
0
파일: Coach.cs 프로젝트: Arukim/aladdin
        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);
            }
        }
예제 #2
0
 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();
     }
 }
예제 #3
0
파일: Player.cs 프로젝트: Arukim/aladdin
 public Player(string name, ServerStuff serverStuff)
 {
     _name            = name;
     this.ServerStuff = serverStuff;
 }