/// <summary> /// Get a list of the players for a specific Competition. /// </summary> /// <param name="competition"></param> /// <returns></returns> public static List <GamePlayerModel> GetPlayerRoster(CompetitionModel competition) { List <GamePlayerModel> returnList = null; if (competition.TeamsAreFixed) { // If teams are fixed, then look for a regular team first. returnList = CompetitionDataAccess.GetRegularTeams(competition.CompetitionID); } // If a regular team is not found, then get all the players. if ((competition.TeamsAreRandomised) || (returnList == null)) { List <PlayerModel> players = CompetitionDataAccess.GetRegisteredPlayers(competition.CompetitionID); returnList = new List <GamePlayerModel>(players.Count); foreach (PlayerModel p in players) { GamePlayerModel tfm = new GamePlayerModel { CompetitionID = competition.CompetitionID, PlayerID = p.PlayerID, PlayerName = p.PlayerName }; returnList.Add(tfm); } } return(returnList); }
public void OnUpateUI(GamePlayerModel model) { UIGamePlayer component = GetGamePlayersByChairIndex(model.chairIndex); if (component != null) { component.UpdateGamePlayer(model); } }
private void OnUpdatePlayerEvent(GamePlayerModel model) { this.model.Update(model); OnChangeBetRange(this.view.GetScrollRate()); editable = true; this.view.EnableScrollBar(editable); }
public GamePlayerModel GetGamePlayerByUserIndex(long userIndex) { GamePlayerModel gamePlayer = null; if (Room == null) { return(null); } for (int i = 0; i < Room.gamePlayers.Count; i++) { if (Room.gamePlayers[i].userIndex == userIndex) { gamePlayer = new GamePlayerModel(); gamePlayer.SetGamePlayer(Room.gamePlayers[i], Room); break; } } return(gamePlayer); }
public void ShowResult(GamePlayerModel model) { int[] madeCards = model.result.madeCards; for (int i = 0; i < cards.Length; i++) { cards[i].transform.localPosition = new Vector2(cards[i].transform.localPosition.x, cards[i].transform.localPosition.y - 20); cards[i].SetAlpha(0.3f); for (int j = 0; j < madeCards.Length; j++) { if (cards[i].index == madeCards[j]) { cards[i].transform.localPosition = new Vector2(cards[i].transform.localPosition.x, cards[i].transform.localPosition.y + 20); cards[i].SetAlpha(1); break; } } } }
private void OnPlayerTurnEvent(GamePlayerModel model) { currentGamePlayer = model; bool isBlind = currentGamePlayer.roomStage == (int)Stage.PreFlop && currentGamePlayer.betCount <= 1; if (isBlind == false && model.lastBetType != GamePlayerModel.BetType.Allin && model.lastBetType != GamePlayerModel.BetType.Fold) { view.SetCallButton(model.betCount != 0, manager.Room.stageBet - model.stageBet); view.EnableAllButtons(true); view.EnableCallButton(model.betCount != 0); view.EnableCheckButton(model.betCount == 0); isClickable = true; } else { view.EnableAllButtons(false); } }
public void InvokePlayerTurnEvent(GamePlayerModel model) { playerTurnEvent.Invoke(model); }
public void InvokeGamePlayerEvent(GamePlayerModel gameplayer) { gamePlayerEvent.Invoke(gameplayer); }
public void UpdateGamePlayer(GamePlayerModel model) { this.model.Update(model); }
public void InvokeGetTableCardEvent(GamePlayerModel model) { getTableCardEvent.Invoke(model); }
public PF CheckGameStatus(string desiredgame, string username)//1 if the min num required is reached // -1 if still waiting { int GID = 0; var prox = new DBFunctionsClient(); bool isInQueue = wrapper_TwoThree.Player_GameFrame_Queue.ContainsKey(username); if (!isInQueue)//if the player is not in the queue , this means that the game is already created { List <GamePlayerModel> games = prox.RetreiveAllGamePlayersByPlayer(username).ToList(); GamePlayerModel gp = games.ElementAt(games.Count - 1);//last gameplayer foreach (PF p in wrapper_TwoThree.playerInfo) { if (p.username == username) { return(p); } } return(null); } else { //get the min num required for the games , then check if the nop is sufficient List <string> opengames = findKeyforValue(wrapper_TwoThree.Player_GameFrame_Queue, desiredgame);//players in this game prox.Open(); int minplayers = prox.RetreiveMinPlayers(desiredgame); //get the min nop required in the desired game int maxplayers = prox.RetreiveMaxPlayers(desiredgame); //get the max nop of the game // prox.Close(); if (opengames.Count < minplayers)//if the required number of players is not reached { return(null); } if (opengames.Count > maxplayers) //if opengames has a number of players that exceeds the max of the game, remove the exceeding players { opengames.RemoveRange(maxplayers, opengames.Count - maxplayers); //remove players from index max until reaching (opengames.Count - maxplayers)-count } if (opengames.Count >= minplayers && opengames.Count <= maxplayers) //if the opengames count equals the number of players required for the game then add a new game and return the ID { GameModel newGame = new GameModel(); newGame.NPlayers = minplayers; newGame.Title = desiredgame; GID = prox.AddGame(newGame);//add the new game List <List <string> > strategies = new List <List <string> >(); List <string> tempstrategies = new List <string>(); int counterfororderofplayers = 0; for (int i = 0; i < opengames.Count; i++)// search the queue to add the players { GamePlayerModel player = new GamePlayerModel(); PF ppp = new PF(); player.UserName = opengames[i]; player.GID = GID; prox.AddGamePlayer(player); ppp.username = player.UserName; wrapper_TwoThree.Strategies.TryGetValue(ppp.username, out tempstrategies); strategies.Add(tempstrategies); wrapper_TwoThree.Strategies.Remove(player.UserName); ppp.GID = player.GID; ppp.orderInGame = counterfororderofplayers++; ppp.strategies.AddRange(tempstrategies); wrapper_TwoThree.playerInfo.Add(ppp); } List <List <string> > cp = new List <List <string> >(); // Cartisian_Product(strategies, wrapper_TwoThree.neprofiles); if (wrapper_TwoThree.playerInfo.Count > 3) //1: Start N_Player_Game { wrapper_TwoThree.N_Players_Game.Game_Initializr(wrapper_TwoThree.playerInfo.Count, strategies); //Strategies are ordered cp.AddRange(wrapper_TwoThree.N_Players_Game.get_SetOfCStategy); //Add cartesian product } else { cp = Cartisian_Product(strategies, wrapper_TwoThree.neprofiles); } foreach (PF p in wrapper_TwoThree.playerInfo) { p.CP = cp; } for (int i = 0; i < opengames.Count; i++)//remove the players from the queue { wrapper_TwoThree.Player_GameFrame_Queue.Remove(opengames[i]); } } foreach (PF p in wrapper_TwoThree.playerInfo)//return this player's PF { if (p.username == username) { return(p); } } return(new PF());//dummy } }//RETURNS PF containing CP AND FINISHES
private void OnUpdateGamePlayer(GamePlayerModel model) { this.view.OnUpateUI(model); }
/// <summary> /// Return Team and Player information about Competitions with regular teams. /// Records are sorted so that by default the players are not sitting next to Team mates. /// (The user may still need to adjust seating positions). /// (Note that GamePlayerModel.TeamNumber is a consecutive number and NOT a database ID). /// </summary> /// <param name="competitionID"></param> /// <returns></returns> public static List <GamePlayerModel> GetRegularTeams(long competitionID) { List <GamePlayerModel> rValue = null; _conn = new SQLiteConnection(CONNECTION_STRING); _conn.Open(); using (SQLiteCommand command = _conn.CreateCommand()) { command.CommandText = "SELECT CompetitionID," + " Team1ID, Team1_Member1ID, Team1_Member1_Name, Team1_Member2ID, Team1_Member2_Name, " + " Team2ID, Team2_Member1ID, Team2_Member1_Name, Team2_Member2ID, Team2_Member2_Name, " + " Team3ID, Team3_Member1ID, Team3_Member1_Name, Team3_Member2ID, Team3_Member2_Name " + " FROM vwRegularTeams" + " WHERE CompetitionID = @competitionID"; command.Parameters.AddWithValue("@competitionID", competitionID); SQLiteDataReader reader = command.ExecuteReader(); if (reader.HasRows) { rValue = new List <GamePlayerModel>(); while (reader.Read()) { // Team 1, Player 1 long gameTeamID = reader.GetInt64(1); GamePlayerModel gpm = new GamePlayerModel(competitionID, 1); gpm.TeamID = gameTeamID; gpm.PlayerID = reader.GetInt64(2); gpm.PlayerName = reader.GetString(3); rValue.Add(gpm); // Team 2, Player 1 gameTeamID = reader.GetInt64(6); gpm = new GamePlayerModel(competitionID, 2); gpm.TeamID = gameTeamID; gpm.PlayerID = reader.GetInt64(7); gpm.PlayerName = reader.GetString(8); rValue.Add(gpm); // Team 3, Player 1 if (reader.IsDBNull(11) == false) { // Team 3 gameTeamID = reader.GetInt64(11); gpm = new GamePlayerModel(competitionID, 3); gpm.TeamID = gameTeamID; gpm.PlayerID = reader.GetInt64(12); gpm.PlayerName = reader.GetString(13); rValue.Add(gpm); } // Team 1, Player 2 gpm = new GamePlayerModel(competitionID, 1); gpm.TeamID = gameTeamID; gpm.PlayerID = reader.GetInt64(4); gpm.PlayerName = reader.GetString(5); rValue.Add(gpm); // Team 2, Player 2 gpm = new GamePlayerModel(competitionID, 2); gpm.TeamID = gameTeamID; gpm.PlayerID = reader.GetInt64(9); gpm.PlayerName = reader.GetString(10); rValue.Add(gpm); // Team 3, Player 2 if (reader.IsDBNull(11) == false) { gpm = new GamePlayerModel(competitionID, 3); gpm.TeamID = gameTeamID; gpm.PlayerID = reader.GetInt64(15); gpm.PlayerName = reader.GetString(16); rValue.Add(gpm); } } } } _conn.Dispose(); return(rValue); }
/// <summary> /// /// </summary> /// <param name="player"></param> public static void AddPlayerPenalty(GamePlayerModel player, long roundID) { System.Diagnostics.Debug.WriteLine($"==> Penalty for {player.PlayerName}, Player ID # {player.PlayerID} in game ID {player.GameID}, gameTeamID {player.TeamID}, team # {player.TeamNumber}"); GameDataAccess.InsertScorePenalty(player.CompetitionID, player.GameID, roundID, player.TeamID, player.PlayerID); }