Beispiel #1
0
        public void RunGame(ServerGame game)
        {
            this.gameId = game.Id; //todo тут надо красиво вынести, раз уж используем клиента

            new Thread(new ThreadStart(() => {
                string error = null;//todo server GameCore<State, Turn, Round, Player>.RunOnServerOrGetError(new Game(), game.StartSettings, RoundPlayed);

                if (error == "Ok")
                {
                    this.GamePlayed();
                }
                else
                {
                    //todo что-то делать, если игра на сервере не сыграла (вылетела с ошибкой)
                }
            })).Start();
        }
Beispiel #2
0
        public void AddGame(List <int> playerIdList, DateTime date, FormMainSettings settings)
        {
            var client = Manager.ClientList[Context.ConnectionId];

            if (client == null && client.IsAdmin == false)
            {
                return;
            }

            using (var db = new MainContext())
            {
                var serverGame = new ServerGame {
                    DateStart     = date,
                    Name          = "игра",
                    RoomId        = -1,
                    StartSettings = settings,
                    state         = EServerGameState.waitForStart
                };
                serverGame.StartSettings.SaveToFile = false;
                settings.JavaPath = null; //todo server java path
                //  db.ServerGame.Add(serverGame);
                int num = 0;
                foreach (var id in playerIdList)
                {
                    var player = db.ServerPlayer.Find(id);
                    if (player != null)
                    {
                        db.ServerGameServerPlayer.Add(new ServerGameServerPlayer
                        {
                            Number       = num,
                            ServerGame   = serverGame,
                            ServerPlayer = player
                        });
                        num++;
                    }
                }
                db.SaveChanges();
            }
            Clients.Caller.message("Игра добавлена");
        }