private void SetUpInactiveGame() { Game.GameStatus = 1; //Creating turns for User1 Flop f1 = new Flop(); Flop f2 = new Flop(); Flop f3 = new Flop(); // User1 Hand LinkedList <Card> handPair = new LinkedList <Card>(); handPair.AddLast(new Card(Value.Eight, Suit.Club)); handPair.AddLast(new Card(Value.Ace, Suit.Spade)); // User2 Hand LinkedList <Card> handPairTwo = new LinkedList <Card>(); handPair.AddLast(new Card(Value.Two, Suit.Club)); handPair.AddLast(new Card(Value.Seven, Suit.Spade)); initFlop(f1, f2, f3); InitUser(f1, f2, f3, handPair, 1212, "User1"); InitUser(f1, f2, f3, handPairTwo, 2323, "User2"); }
private bool UpdateFlop(IDatavObj obj) { Flop flop = obj as Flop; var existFlops = Flops.Where(p => p.Name() == flop.Name()); if (existFlops.Any()) { Flop existFlop = existFlops.First(); if (existFlop.Same(flop)) { return(false); } else { Logger.Log($"[Datav][{Name}]更新翻牌器:"); Logger.Log(flop.ToString()); Logger.Log($"[Datav][{Name}]--------------"); Flops.Remove(existFlop); Flops.Add(flop); return(true); } } else { Flops.Add(flop); return(true); } }
public void PerformFlop(Deck deck) { deck.Discard(); Flop.Add(deck.Draw()); Flop.Add(deck.Draw()); Flop.Add(deck.Draw()); }
public ActionResult <List <FlopReturnValue> > UpdateFlop(string datavName, string flopName, int startNumber, int variation, int changeInterval) { Flop flop = new Flop(flopName, datavName, startNumber, startNumber, variation, changeInterval); Flop existFlop = Backend.Instance.Controller().GetFlop(datavName, flopName); FlopReturnValue ret = new FlopReturnValue("", 0); if (existFlop == null) { bool succ = Backend.Instance.Controller().NewObj(datavName, flop); if (succ) { ret.value = flop.CurrentNumber; } } else { if (flop.Same(existFlop)) { ret.value = existFlop.CurrentNumber; } else { Backend.Instance.Controller().UpdateObj(datavName, flop); ret.value = startNumber; } } List <FlopReturnValue> retlist = new List <FlopReturnValue>(); retlist.Add(ret); return(retlist); }
protected override void EnregistrerFlop(Flop evt) { _flop[0] = evt.Carte1; _flop[1] = evt.Carte2; _flop[2] = evt.Carte3; EcrireDetailPartie(evt.DateEvenement, _numDonne, "Flop", evt.Carte1.LibelleCarte() + "," + evt.Carte2.LibelleCarte() + "," + evt.Carte3.LibelleCarte(), evt.Pot.ToString(), PAS_D_INFOS); }
private void TraiterEvtFlop(Flop evt) { _board[0] = evt.Carte1; _board[1] = evt.Carte2; _board[2] = evt.Carte3; _pot = evt.Pot; LancerEvtMessageInfo(new MessageInfo(EtapeDonne.Flop, _board)); }
private void FlopUpdated(Flop obj) { Prepare(cards[0], obj.First); Prepare(cards[1], obj.Second); Prepare(cards[2], obj.Third); Prepare(cards[3], obj.Fourth); Prepare(cards[4], obj.Fiveth); }
public void NewRound() { Pocket.Clear(); PlayerHand.HandCards.Clear(); PlayerHand.HandValue = 0; Flop.Clear(); Active = true; RoundBid = 0; HandValue = 0; }
private void EvaluateHands() { IEnumerable <Card> cards = Flop.Append(Turn).Append(River); foreach (var player in Players) { var combinedCards = player.Cards.Concat(cards); IEnumerable <Hand> hands = combinedCards.DifferentCombinations(5).Select(x => new Hand(x)); player.HandValue = hands.Max(x => x.Value); } }
private void InitUser(Flop f1, Flop f2, Flop f3, LinkedList <Card> handPair, int userMoney, String userName) { // Pack the Hand Hand h1 = new Hand(handPair); Turn turnOne = new Turn(h1, f1, 425, userMoney); Turn turnTwo = new Turn(h1, f2, 425, userMoney); Turn turnThree = new Turn(h1, f3, 425, userMoney); LinkedList <Turn> userTurns = new LinkedList <Turn>(); userTurns.AddLast(turnOne); userTurns.AddLast(turnTwo); userTurns.AddLast(turnThree); //add to user his turns Game.GameHistory.Add(userName, userTurns); }
private bool AddFlop(IDatavObj obj) { Flop flop = obj as Flop; var existFlops = Flops.Where(p => p.Name() == flop.Name()); if (existFlops.Any()) { return(false); } else { Logger.Log($"[Datav][{Name}]创建翻牌器:"); Logger.Log(flop.ToString()); Logger.Log($"[Datav][{Name}]--------------"); Flops.Add(flop); return(true); } }
/// <summary> /// Enregistrement du flop /// </summary> /// <param name="carte1"></param> /// <param name="carte2"></param> /// <param name="carte3"></param> /// <param name="pot"></param> internal void EnregistrerFlop(CartePoker carte1, CartePoker carte2, CartePoker carte3, int pot) { try { Flop enregFlop = new Flop(); enregFlop.Carte1 = carte1; enregFlop.Carte2 = carte2; enregFlop.Carte3 = carte3; enregFlop.Pot = pot; foreach (IStatistiques stat in _statistiques) { stat.Enregistrer(enregFlop); } } catch (Exception ex) { logServeur.Debug("Erreur lors d'EnregistrerFlop : " + ex.Message); } }
private GameState GetCurrentGameState() { try { var state = new GameState() { Players = GetAllPlayers()?.ToArray(), Flop = Flop?.ToArray(), Pot = Pot, PendingPot = PendingPot, Round = Round }; return(state); } catch (Exception ex) { return(null); } }
private void initFlop(Flop f1, Flop f2, Flop f3) { f1.Cards[0] = new Card(Value.Ace, Suit.Club); f1.Cards[1] = new Card(Value.Ace, Suit.Diamond); f1.Cards[2] = new Card(Value.Ace, Suit.Heart); f1.Cards[3] = null; f1.Cards[4] = null; f2.Cards[0] = new Card(Value.Ace, Suit.Club); f2.Cards[1] = new Card(Value.Ace, Suit.Diamond); f2.Cards[2] = new Card(Value.Ace, Suit.Heart); f2.Cards[3] = new Card(Value.King, Suit.Heart); f2.Cards[4] = null; f3.Cards[0] = new Card(Value.Ace, Suit.Club); f3.Cards[1] = new Card(Value.Ace, Suit.Diamond); f3.Cards[2] = new Card(Value.Ace, Suit.Heart); f3.Cards[3] = new Card(Value.King, Suit.Heart); f3.Cards[4] = new Card(Value.Two, Suit.Heart); }
public static void OnFlop(object sender, FlopEventArgs e) { Flop?.Invoke(null, e); }
protected virtual void EnregistrerFlop(Flop evt) { }
public FlopTest() { this.Flop = new Flop(); }
public void EndRound() { int PotTotal = 0; int NewPot = 0; List <DSeat> PeopleWhoCanWinMoney = new List <DSeat>(); List <DSeat> NewPotPeople = new List <DSeat>(); List <DSeat> MatchingHandValues = new List <DSeat>(); GetTurnOrder(); foreach (DSeat seat in SeatsInTurnOrder) { if (seat.Occupied && seat.Active && seat.RoundBid > 0) { PeopleWhoCanWinMoney.Add(seat); } } foreach (DSeat seat in SeatsInTurnOrder) { if (seat.Occupied) { PotTotal += seat.RoundBid; } } if (PeopleWhoCanWinMoney.Count == 1) { PeopleWhoCanWinMoney[0].ChipTotal += PotTotal; MoveBlinds(); Flop.Clear(); return; } foreach (DSeat seat in PeopleWhoCanWinMoney) { seat.FindBestHand(); } do { PeopleWhoCanWinMoney = PeopleWhoCanWinMoney.OrderByDescending(h => h.HandValue).ToList(); if (PeopleWhoCanWinMoney[0].HandValue > PeopleWhoCanWinMoney[1].HandValue) { NewPotPeople.Clear(); for (int i = 1; i < PeopleWhoCanWinMoney.Count; i++) { if (PeopleWhoCanWinMoney[i].RoundBid > PeopleWhoCanWinMoney[0].RoundBid) { NewPotPeople.Add(PeopleWhoCanWinMoney[i]); } } if (NewPotPeople.Count == 0) { PeopleWhoCanWinMoney[0].ChipTotal += PotTotal; MoveBlinds(); Flop.Clear(); return; } else { foreach (DSeat seat in NewPotPeople) { NewPot += seat.RoundBid - PeopleWhoCanWinMoney[0].RoundBid; seat.RoundBid -= PeopleWhoCanWinMoney[0].RoundBid; } PotTotal -= NewPot; PeopleWhoCanWinMoney[0].ChipTotal += PotTotal; PeopleWhoCanWinMoney = new List <DSeat>(NewPotPeople); PotTotal = NewPot; NewPot = 0; } } else { //get list of people who have matching hand values MatchingHandValues.Clear(); MatchingHandValues.Add(PeopleWhoCanWinMoney[0]); for (int i = 1; i < PeopleWhoCanWinMoney.Count; i++) { if (PeopleWhoCanWinMoney[i].HandValue == PeopleWhoCanWinMoney[0].HandValue) { MatchingHandValues.Add(PeopleWhoCanWinMoney[i]); } } //run through the cards one by one to see if someone has a high value for (int i = 0; i < 5; i++) { foreach (DSeat seat in MatchingHandValues) { seat.HandValue += seat.PlayerHand.HandCards[i].Value; } MatchingHandValues = MatchingHandValues.OrderByDescending(h => h.HandValue).ToList(); if (MatchingHandValues[0].HandValue > MatchingHandValues[1].HandValue) { break; } } //if someone has the highest value if (MatchingHandValues[0].HandValue > MatchingHandValues[1].HandValue) { PeopleWhoCanWinMoney = PeopleWhoCanWinMoney.OrderByDescending(h => h.HandValue).ToList(); NewPotPeople.Clear(); for (int i = 1; i < PeopleWhoCanWinMoney.Count; i++) { if (PeopleWhoCanWinMoney[i].RoundBid > PeopleWhoCanWinMoney[0].RoundBid) { NewPotPeople.Add(PeopleWhoCanWinMoney[i]); } } if (NewPotPeople.Count == 0) { PeopleWhoCanWinMoney[0].ChipTotal += PotTotal; } else { foreach (DSeat seat in NewPotPeople) { NewPot += seat.RoundBid - PeopleWhoCanWinMoney[0].RoundBid; seat.RoundBid -= PeopleWhoCanWinMoney[0].RoundBid; } PotTotal -= NewPot; PeopleWhoCanWinMoney[0].ChipTotal += PotTotal; PeopleWhoCanWinMoney = new List <DSeat>(NewPotPeople); PotTotal = NewPot; NewPot = 0; foreach (DSeat seat in PeopleWhoCanWinMoney) { seat.FindBestHand(); } } } else { // may have matching hand levels but different pot levels\ MatchingHandValues = MatchingHandValues.OrderByDescending(h => h.HandValue).ToList(); List <DSeat> StillMatching = new List <DSeat>(); StillMatching.Add(MatchingHandValues[0]); for (int i = 1; i < MatchingHandValues.Count; i++) { if (MatchingHandValues[i].HandValue == StillMatching[0].HandValue) { StillMatching.Add(MatchingHandValues[0]); } } StillMatching = StillMatching.OrderBy(h => h.RoundBid).ToList(); NewPotPeople.Clear(); for (int i = 1; i < PeopleWhoCanWinMoney.Count; i++) { if (PeopleWhoCanWinMoney[i].RoundBid > StillMatching[0].RoundBid) { NewPotPeople.Add(PeopleWhoCanWinMoney[i]); } } if (NewPotPeople.Count == 0) { // divide pot among still matching if (PotTotal % StillMatching.Count != 0) { StillMatching[0].ChipTotal += 1; } foreach (DSeat seat in StillMatching) { seat.ChipTotal += PotTotal / StillMatching.Count; } } else { foreach (DSeat seat in NewPotPeople) { NewPot += seat.RoundBid - StillMatching[0].RoundBid; seat.RoundBid -= StillMatching[0].RoundBid; } PotTotal -= NewPot; foreach (DSeat seat in StillMatching) { seat.ChipTotal += PotTotal / StillMatching.Count; } PeopleWhoCanWinMoney = new List <DSeat>(NewPotPeople); PotTotal = NewPot; NewPot = 0; } } } } while (NewPotPeople.Count > 0); // NEED TO ADD MOVING THE SMALL BLIND BIG BLIND MoveBlinds(); Flop.Clear(); }
public static int BetRequest(GameState gameState) { try { LogicResult result = null; if (gameState.CommunityCards.Count == 0) { result = Preflop.Result(gameState); } if (gameState.CommunityCards.Count == 3) { result = Flop.Result(gameState); } if (gameState.CommunityCards.Count == 4) { result = Turn.Result(gameState); } if (gameState.CommunityCards.Count == 5) { result = River.Result(gameState); } if (result == null) { Console.WriteLine("RESULT IS NULL"); return(0); } if (gameState.IsAllin()) { if (result.CanRespondToAllIn) { return(int.MaxValue); } else { return(0); } } if (result.RaiseOdds > 0) { var raiseBase = Math.Max(gameState.Pot - gameState.Me().Bet, gameState.MinimumRaise); return(gameState.Me().Bet + (int)Math.Round(raiseBase * result.RaiseOdds)); } if (result.CallOdds > 0) { var toCall = gameState.CurrentBuyIn - gameState.Me().Bet; var odds = toCall / (gameState.Pot + 1); if (result.CallOdds > odds) { return(toCall); } } return(0); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); return(0); } }
public static LogicResult Result(GameState state) { return(Flop.Result(state)); }
IEnumerator Start() { var cards = new Card[52]; for (var cardIndex = 0; cardIndex < cards.Length; cardIndex++) { cards[cardIndex] = new Card { State = Card.States.None, Suit = cardIndex / 13, Value = cardIndex % 13 }; } Deck = new Stack <Card>(cards.OrderBy(x => Random.value)); Entity flop = Manager.CreateEntity(typeof(Flop), typeof(Bid)); Entity local = Entity.Null; Entity oponent1 = Entity.Null; Entity oponent2 = Entity.Null; for (int i = 0; i < 9; i++) { var sit = Manager.CreateEntity(); AddOrSet(sit, new Sit { Id = i }); if (i == 0) { local = sit; } if (i == 4) { oponent1 = sit; } if (i == 5) { oponent2 = sit; } } yield return(new WaitForSeconds(2f)); yield return(new WaitForEndOfFrame()); AddOrSet(local, new Player { Id = 50 }); AddOrSet(local, new Bank { Value = 10000 }); yield return(new WaitForSeconds(2f)); yield return(new WaitForEndOfFrame()); AddOrSet(oponent1, new Player { Id = 60 }); AddOrSet(oponent1, new Bank { Value = 10000 }); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); AddOrSet(oponent2, new Player { Id = 70 }); AddOrSet(oponent2, new Bank { Value = 10000 }); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); AddOrSet(oponent1, new Bid() { Value = 5 }); AddOrSet(oponent2, new Bid() { Value = 10 }); AddOrSet(oponent1, new Bank() { Value = 10000 - 5 }); AddOrSet(oponent2, new Bank() { Value = 10000 - 10 }); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); var localCards = default(Cards); var opponent1Cards = default(Cards); var opponent2Cards = default(Cards); localCards.Right = RandomCard(); AddOrSet(local, localCards); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); opponent1Cards.Right = RandomCard(Card.States.Close); AddOrSet(oponent1, opponent1Cards); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); opponent2Cards.Right = RandomCard(Card.States.Close); AddOrSet(oponent2, opponent2Cards); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); localCards.Left = RandomCard(); AddOrSet(local, localCards); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); opponent1Cards.Left = RandomCard(Card.States.Close); AddOrSet(oponent1, opponent1Cards); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); opponent2Cards.Left = RandomCard(Card.States.Close); AddOrSet(oponent2, opponent2Cards); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); AddOrSet(local, new Bid() { Value = 100 }); AddOrSet(local, new Bank() { Value = 10000 - 100 }); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); AddOrSet(oponent1, new Bid() { Value = 250 }); AddOrSet(local, new Bank() { Value = 10000 - 250 }); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); Manager.RemoveComponent <Cards>(oponent2); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); AddOrSet(local, new Bid() { Value = 250 }); AddOrSet(local, new Bank() { Value = 10000 - 250 }); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); var flop1 = new Flop { First = RandomCard(), Second = RandomCard(), Third = RandomCard() }; AddOrSet(flop, flop1); AddOrSet(local, default(Bid)); AddOrSet(oponent1, default(Bid)); AddOrSet(oponent2, default(Bid)); AddOrSet(flop, new Bid() { Value = 510 }); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); flop1.Fourth = RandomCard(); AddOrSet(flop, flop1); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); AddOrSet(oponent1, new Bid() { Value = 1500 }); AddOrSet(oponent1, new Bank() { Value = 10000 - 250 - 1500 }); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); AddOrSet(local, new Bid() { Value = 1500 }); AddOrSet(local, new Bank() { Value = 10000 - 250 - 1500 }); yield return(new WaitForSeconds(2.1f)); yield return(new WaitForEndOfFrame()); AddOrSet(local, default(Bid)); AddOrSet(oponent1, default(Bid)); AddOrSet(flop, new Bid() { Value = 510 + 3000 }); flop1.Fiveth = RandomCard(); AddOrSet(flop, flop1); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); AddOrSet(oponent1, new Bid() { Value = 5000 }); AddOrSet(oponent1, new Bank() { Value = 10000 - 250 - 1500 - 5000 }); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); AddOrSet(local, new Bid() { Value = 5000 }); AddOrSet(local, new Bank() { Value = 10000 - 250 - 1500 - 5000 }); yield return(new WaitForSeconds(2.5f)); yield return(new WaitForEndOfFrame()); AddOrSet(local, default(Bid)); AddOrSet(oponent1, default(Bid)); AddOrSet(flop, new Bid() { Value = 510 + 3000 + 10000 }); AddOrSet(oponent1, new Cards { Left = RandomCard(), Right = RandomCard() }); yield return(new WaitForSeconds(2f)); yield return(new WaitForEndOfFrame()); AddOrSet(flop, default(Bid)); AddOrSet(oponent1, default(Bid)); AddOrSet(oponent2, default(Bid)); AddOrSet(local, default(Bid)); Manager.RemoveComponent <Cards>(local); Manager.RemoveComponent <Cards>(oponent1); Manager.RemoveComponent <Flop>(flop); AddOrSet(local, new Bank { Value = 10000 - 250 - 1500 - 5000 + 510 + 3000 + 10000 }); }