Exemplo n.º 1
0
Arquivo: Log.cs Projeto: B3J4y/Poker
 public static void action(Game gl, Player player, SurfacePoker.Action.playerAction action, int amount, List<Card> board)
 {
     log.Debug("action(Game gl, Player "+ player.name + ", SurfacePoker.Action.playerAction "+ action+ ", int " + amount + ", List<Card> board) - Begin");
     String str = "";
     foreach(Card c in board){
         str += c.ToString();
     }
     if (player.cards.Count != 0)
     {
         log.Info(player.name+ ";" + player.stack + ";" + action.ToString() + ";" + amount + ";" + player.getCardsToString() + ";" + str + ";" + gl.pot.value + ";" + player.winChance);
     }
     else
     {
         log.Info(player.name + ";" + player.stack + ";" + action.ToString() + ";" + amount + "; ;" + str + ";"+ gl.pot.value + ";0");
     }
     log.Debug("action() - End");
 }
Exemplo n.º 2
0
Arquivo: Log.cs Projeto: B3J4y/Poker
 public static void calculateWinChance(Game gl)
 {
     log.Debug("calculateWinChance(Game gl) - Begin");
     long totalHands = 10000000;
     int count = gl.players.FindAll(x => x.cards.Count == 2).Count;
     string[] pockets = new string[count];
     string board = "";
     long[] win = new long[count];
     long[] tie = new long[count];
     long[] los = new long[count];
     int j = 0;
     for(int i = 0; i < gl.players.Count; i++)
     {
         if (gl.players[i].cards.Count == 2)
         {
             pockets[i - j] = gl.players[i].getCardsToString();
         }
         else
         {
             j++;
         }
     }
     foreach (Card c in gl.board)
     {
         board += c.ToString() + " ";
     }
     Hand.HandOdds(pockets, board, "", win, tie, los, ref totalHands);
     j = 0;
     Console.WriteLine(totalHands);
     for (int i = 0; i < gl.players.Count; i++)
     {
         if (gl.players[i].cards.Count == 2)
         {
             gl.players[i].winChance = win[i - j] * 100 / totalHands;
             log.Debug("Player" + gl.players[i] + " win/tie/loose " +  (win[i - j] * 100 / totalHands)+ "/" + (tie[i - j] * 100 / totalHands) + "/" + (los[i - j] * 100 / totalHands));
         }
         else
         {
             j++;
         }
     }
     log.Debug("calculateWinChance() - End");
 }
Exemplo n.º 3
0
 /// <summary>
 /// Starts a new round or if game does not exist creates new game and start new round
 /// </summary>
 private async Task startGame()
 {
     log.Debug("startGame() - Begin");
     await Task.Delay(5);
     if (gl == null)
     {
         gl = new Game(players, bb, bb / 2, trainMode);
         EMIcancelRound.IsEnabled = true;
     }
     try
     {
         //set dealer button to pos
         Player p = gl.newGame();
         setDealerButtonPos(p.position);
         //get first player
         kvp = gl.nextPlayer();
         Mitte.Visibility = Visibility.Visible;
         showCards();
         showActionButton(kvp);
     }
     catch (EndGameException exp)
     {
         log.Debug("catch NoPlayerInGameException exp: " + exp.ToString());
         hideStacksPot();
         Point p = new Point(400,400);
         SVIWinner.Center = p;
         TBWinner.Text = gl.players.Find(x => x.stack != 0).name;
         switch (gl.players.Find(x => x.stack != 0).position)
         {
             case 1: SVIWinner.Orientation = 90; break;
             case 2:
                 case 3: SVIWinner.Orientation = 180; break;
             case 4: SVIWinner.Orientation = 270; break;
             default: SVIWinner.Orientation = 0; break;
         }
         SVIWinner.Visibility = Visibility.Visible;
     }
     log.Debug("startGame() - End");
     
 }
Exemplo n.º 4
0
Arquivo: Game.cs Projeto: B3J4y/Poker
 private void NewPlayRound()
 {
     players = new List<Player>();
     for (int i = 0; i < PLAYERCOUNT; i++)
     {
         Player player = new Player("Player" + i, 1000, i+1);
         players.Add(player);
     }
     gl = new Game(players, bb, sb, true);
 }