// make a move on the game // we use a list instead of array becouse if in the second move // the cards are stil the same, we want to to make a third move and etc. // and for each move we need to add the cards to the array, and this is much easier // to this with a list. public string Move() { bool isMove = false; Card firstCard; Card SecondCard; List <Card> cards = new List <Card>(); string moveCards = ""; // iterate the move as long as the cards are the same do { if (FinishGame()) { return("no body has cards"); // if finish the game } firstCard = pl1.PopCard(); SecondCard = pl2.PopCard(); // add to the list moveCards += pl1.Name + ": " + firstCard.ToString() + " " + pl2.Name + ": " + SecondCard.ToString() + '\n'; // check whose ticket is bigger if (firstCard.Number > SecondCard.Number) { cards.Add(firstCard); cards.Add(SecondCard); pl1.AddCard(cards.ToArray()); isMove = true; } else if (firstCard.Number < SecondCard.Number) { cards.Add(SecondCard); cards.Add(firstCard); pl2.AddCard(cards.ToArray()); isMove = true; } else { cards.Add(firstCard); cards.Add(SecondCard); } // if the cerds the same make another move } while (!isMove); return(moveCards); }
public string GetUserInfo() { return(string.Format("{0}^{1}^{2}^{3}^{4}^{5}", Name, Wallet, Action, Active, FirstCard?.GetCardDescription() ?? "", SecondCard?.GetCardDescription() ?? "")); }
public void RefreshCombos() { var combos = Enum.GetValues(typeof(EquitySelectionMode)).Cast <EquitySelectionMode>().ToDictionary(x => x, x => 0); var deadCards = usedCards?.Select(x => x.ToString()).ToArray() ?? new string[0]; var selectedSuits = HandSuitsModelList.Where(x => x.IsSelected && x.IsVisible) .Select(x => new { x.SelectionMode, HandSuit = x.HandSuit.ToString() }) .ToArray(); var suits = new[] { RangeCardSuit.Clubs, RangeCardSuit.Diamonds, RangeCardSuit.Hearts, RangeCardSuit.Spades }; bool checkCombos(string cardCombo, string suitCombo, out EquitySelectionMode selectionMode) { selectionMode = DriveHUD.ViewModels.EquitySelectionMode.None; var result = deadCards.Length == 0 || deadCards.All(x => !cardCombo.Contains(x)); if (!result) { return(false); } var suit = selectedSuits.FirstOrDefault(x => suitCombo.Equals(x.HandSuit, StringComparison.OrdinalIgnoreCase)); if (suit == null) { return(false); } selectionMode = suit.SelectionMode; return(true); } if (ItemType == RangeSelectorItemType.Pair) { var rank = FisrtCard.ToRankString(); for (var i = 0; i < suits.Length; i++) { for (var j = i + 1; j < suits.Length; j++) { var suit1 = suits[i].ToSuitString(); var suit2 = suits[j].ToSuitString(); var cardCombo = $"{rank}{suit1}{rank}{suit2}"; var suitCombo = $"{suit1}{suit2}"; if (checkCombos(cardCombo, suitCombo, out EquitySelectionMode mode)) { combos[mode]++; } } } } else if (ItemType == RangeSelectorItemType.Suited) { var rank1 = FisrtCard.ToRankString(); var rank2 = SecondCard.ToRankString(); for (var i = 0; i < suits.Length; i++) { var suit = suits[i].ToSuitString(); var cardCombo = $"{rank1}{suit}{rank2}{suit}"; var suitCombo = $"{suit}{suit}"; if (checkCombos(cardCombo, suitCombo, out EquitySelectionMode mode)) { combos[mode]++; } } } else if (ItemType == RangeSelectorItemType.OffSuited) { var rank1 = FisrtCard.ToRankString(); var rank2 = SecondCard.ToRankString(); for (var i = 0; i < suits.Length; i++) { for (var j = 0; j < suits.Length; j++) { if (i == j) { continue; } var suit1 = suits[i].ToSuitString(); var suit2 = suits[j].ToSuitString(); var cardCombo = $"{rank1}{suit1}{rank2}{suit2}"; var suitCombo = $"{suit1}{suit2}"; if (checkCombos(cardCombo, suitCombo, out EquitySelectionMode mode)) { combos[mode]++; } } } } FoldCheckCombos = combos[DriveHUD.ViewModels.EquitySelectionMode.FoldCheck]; CallCombos = combos[DriveHUD.ViewModels.EquitySelectionMode.Call]; BluffCombos = combos[DriveHUD.ViewModels.EquitySelectionMode.Bluff]; ValueBetCombos = combos[DriveHUD.ViewModels.EquitySelectionMode.ValueBet]; Combos = combos.Values.Sum(); RaisePropertyChanged(nameof(Combos)); }