/// <summary> /// 新建游戏 /// </summary> /// <param name="players"></param> /// <param name="gameSetting"></param> public void CreateGame(Player[] players, GameSetting gameSetting) { //收到请求后,1、如果Host或Realboard在玩家列表里,添加Client信息。 //2、添加游戏列表 //3、给所有client发送消息 string sessionID = OperationContext.Current.SessionId; ClientInfo client = Common.ClientListGet(sessionID); foreach (Player player in players) { //除了Internet,其他三个,AI、Realboard、Host的连接都是Host本身的连接 if (player.Type != PlayerType.Internet) { player.Client = client; } } Game game = new Game() { Name = gameSetting.Name, GameID = sessionID, Players = players, GameSetting = gameSetting }; game.Init(); Common.GameList.TryAdd(sessionID, game); foreach (ClientInfo c in Common.ClientList.Values) { //if (c.PlayingState == ClientState.Idel) //{ Task.Factory.StartNew(() => { ICallback callback = c.ClientCallback; callback.DistributeNewGame(game); }); //} } }