public bool Match(string connectionId, string deckId, string password)//匹配 { //如果这个玩家在登陆状态,并且处于闲置中 if (_users.ContainsKey(connectionId) && _users[connectionId].UserState == UserState.Standby) { //获取这个玩家 var user = _users[connectionId]; //如果玩家不处于闲置状态,或玩家没有该Id的卡组,或者该卡组不符合标准,禁止匹配 if (user.UserState != UserState.Standby || !(user.Decks.Any(x => x.Id == deckId) && user.Decks.Single(x => x.Id == deckId).IsBasicDeck())) { return(false); } //建立一个新的玩家 var player = user.CurrentPlayer = new ClientPlayer(user, () => _hub);//Container.Resolve<IHubContext<GwentHub>>); //设置玩家的卡组 player.Deck = user.Decks.Single(x => x.Id == deckId); //将这个玩家加入到游戏匹配系统之中 _gwentMatchs.PlayerJoin(player, password); InovkeUserChanged(); //成功进入匹配队列了哟 return(true); } //玩家未在线,失败 return(false); }
public bool Match(string connectionId, string deckId)//匹配 { if (_users.ContainsKey(connectionId)) { var user = _users[connectionId]; //如果玩家不处于闲置状态,或玩家没有该卡组,或者该卡组不符合标准,禁止匹配 if (user.UserState != UserState.Standby || !(user.Decks.Any(x => x.Id == deckId) && user.Decks.Single(x => x.Id == deckId).IsBasicDeck())) { return(false); } var player = user.CurrentPlayer = new ClientPlayer(user, () => _hub);//Container.Resolve<IHubContext<GwentHub>>); player.Deck = user.Decks.Single(x => x.Id == deckId); _gwentMatchs.PlayerJoin(player); return(true); } return(false); }