CardPair Draw() { CardPair cd = drawPile[0]; drawPile.RemoveAt(0); return(cd); }
IEnumerator FaceDown(CardPair B) { yield return(new WaitForSeconds(1)); A.Flip(true); B.Flip(false); SetCardA(null); }
void DeckEditView_Loaded(object sender, RoutedEventArgs e) { if (lstCard.Items.Count > 0) { lstCard.SelectedIndex = 0; CardPair pair = lstCard.SelectedValue as CardPair; pair.IsSelected = true; } this.SizeChanged += new SizeChangedEventHandler(DecksView_SizeChanged); }
public void pickForDefenseTest() { var defenderCards = ImmutableList.Create <Card>() .Add(new Card(Suit.Clubs, Rank.Ace)) .Add(new Card(Suit.Hearts, Rank.Four)); var defender = new Player(defenderCards, new PlayerNumber(1)); var toDefeatPair = new CardPair(new Card(Suit.Spades, Rank.King), Option <Card> .None); var expected = new Option <Card>(new Card(Suit.Hearts, Rank.Four)); var actual = Program.pickForDefense(defender, toDefeatPair, Suit.Hearts, Card.comparerForTrumpSuit(Suit.Hearts)); Assert.AreEqual(expected, actual); }
private void RightCardActivate() { CardPair pair = ((CardPair)this.DataContext); if (pair.ActiveCard != pair.Card2) { Storyboard sb = this.Resources["RightCardActivation"] as Storyboard; sb.Begin(this); pair.ActiveCard = pair.Card2; } Keyboard.Focus(rightCardEditView); }
internal Visual GetActiveCardVisual() { CardPair pair = ((CardPair)this.DataContext); if (rightCardEditView.DataContext == pair.ActiveCard) { return((Visual)rightCardEditView.ScatterView); } else { return((Visual)leftCardEditView.ScatterView); } }
public bool Check(CardPair B) { if (A == null || B == null) { return(false); } if (A.rank == B.rank && A.color == B.color) { SetCardA(null); photonView.RPC("PlayPairSound", RpcTarget.All); return(true); } StartCoroutine(FaceDown(B)); return(false); }
static void Main(string[] args) { CardPair.LoadPairs(CardPair.saveFile, CardPair.CardPairs); CardPair.LoadPairs(CardPair.fullSaveFile, CardPair.FullCardPairs); Cards.Load(); foreach (HeroClass hero in Enum.GetValues(typeof(HeroClass))) { if (hero == HeroClass.NONE) { continue; } List <CardPair> classPairs = CardPair.CardPairs.FindAll(x => x.Hero == hero); SaveHero(hero, classPairs, false); classPairs.Clear(); classPairs = CardPair.FullCardPairs.FindAll(x => x.Hero == hero); SaveHero(hero, classPairs, true); } }
private static double Calculate(string card, List <CardPair> classPairs, List <string> deck) { List <CardPair> interestingPairs = classPairs.FindAll(x => x.Card1 == card || x.Card2 == card); double ret = 0.0; int i = 0; foreach (string deckCard in deck) { CardPair pair = interestingPairs.Find(x => x.Card1 == deckCard || x.Card2 == deckCard); if (pair != null) { ret += pair.DeckWinPercentage() - .5; } if (++i == 31) { break; } } return(ret); }
void sb_Completed(object sender, EventArgs e) { CardPair pair = ((CardPair)this.DataContext); if (pair == null) { return; } if (pair.ActiveCard == pair.Card2) { Storyboard sb = this.Resources["RightCardActivation"] as Storyboard; sb.Begin(this); } if (pair.ActiveCard == pair.Card1) { Storyboard sb = this.Resources["LeftCardActivation"] as Storyboard; sb.Begin(this); } }
public void MakeCards() { cardNames = new List <string>(); string[] letters = new string[] { "C", "D", "H", "S" }; foreach (string s in letters) { for (int i = 0; i < 13; i++) { cardNames.Add(s + (i + 1)); } } cards = new List <Card>(); for (int i = 0; i < cardNames.Count; i++) { GameObject cgo = PhotonTool.instance.Instantiate("_Prefabs/PrefabCard"); CardPair card = cgo.GetComponent <CardPair>(); card.name = cardNames[i]; card.suit = cardNames[i][0].ToString(); card.rank = int.Parse(card.name.Substring(1)); if (card.suit == "D" || card.suit == "H") { card.color = Color.red; } else { card.color = Color.black; } card.photonView.RPC("RPC_SetupCard", RpcTarget.All, card.name, card.suit, card.rank, new Vector3(card.color.r, card.color.g, card.color.b), deckAnchor.name, new Vector3((i % 13) * 3, i / 13 * 4, 0)); cards.Add(card); } }//MakeCard()
private void OnMouseUp() { if (isFlipping || PairManager.S.blockFlip) // 카드를 뒤집을 수 없는 경우 { return; } if (faceup) // 이미 펼쳐진 카드는 다시 펼칠 수 없다. { return; } if (PairManager.S.GetCurrnetTurnPlayer().GetPlayerIndex() != PhotonManager.instance.playerIndex) { return; } CardPair A = PairManager.S.GetA(); if (A == null) { PairManager.S.SetCardA(this); Flip(true); return; } Flip(true); if (PairManager.S.Check(this)) { PairManager.S.IncreaseChain(rank); } else { PairManager.S.photonView.RPC("NextTurn", RpcTarget.All); } }
private static IGameHistory LoadHistoryHHFromText(string text) { var lines = text.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); if (lines.Any(l => l.Trim() == "")) { return(null); } var haspos = lines[0].IndexOf('#'); var colonpos = lines[0].IndexOf(':'); var num = lines[0].Substring(haspos + 1, colonpos - haspos - 1); haspos = lines[1].IndexOf('#'); var dealerSeat = Int32.Parse(lines[1].Substring(haspos + 1, 1)); int dealerPos = 0; int bracketpos = lines[0].IndexOf('('); int slashpos = lines[0].IndexOf('/'); uint smallBlind = (uint)(100 * Decimal.Parse(lines[0].Substring(bracketpos + 2, slashpos - bracketpos - 2))); uint bigBlind = (uint)(100 * Decimal.Parse(lines[0].Substring(slashpos + 2, lines[0].IndexOf(' ', slashpos) - 2 - slashpos))); // players int i = 2, pc = 0; List <PlayerHistorical> players = new List <PlayerHistorical>(); Dictionary <int, PlayerHistorical> seatIndex = new Dictionary <int, PlayerHistorical>(); List <int> seats = new List <int>(); while (lines[i].Contains("Seat")) { colonpos = lines[i].IndexOf(':'); var n = Int32.Parse(lines[i].Substring(5, colonpos - 5)); if (n == dealerSeat) { dealerPos = pc; } seats.Add(n); var id = lines[i].Substring(colonpos + 2, lines[i].LastIndexOf('(') - colonpos - 3); var dollarpos = lines[i].LastIndexOf('$'); var chips = (uint)(100 * Decimal.Parse(lines[i].Substring(dollarpos + 1, lines[i].IndexOf(' ', dollarpos) - dollarpos - 1))); PlayerHistorical p; players.Add(p = new PlayerHistorical() { Id = id, Balance = chips }); seatIndex.Add(n, p); pc++; i++; } bool[] folded = new bool[players.Count]; bool[] allin = new bool[players.Count]; while (!lines[i++].Contains("*** HOLE")) { ; } uint currentBet = bigBlind; uint pot = smallBlind + bigBlind; int playerPos = (dealerPos + 3) % players.Count; if (players.Count == 2) { playerPos = dealerPos; } int canbetcount = players.Count; // preflop int lastPos = 0; bool noRaise = true; Action <List <PlayerAction> > addActions = list => { while (!(lines[i].StartsWith("*** ") || lines[i].StartsWith("Uncalled bet (") || lines[i].Contains(" collected "))) { if (lines[i].Contains(" folds ")) { list.Add(new PlayerAction(playerPos, new Action(ActionType.Fold, 0))); folded[playerPos] = true; canbetcount--; } else if (lines[i].Contains(" calls ") || lines[i].Contains(" checks ")) { list.Add(new PlayerAction(playerPos, new Action(ActionType.Call, 0))); pot += currentBet; if (lines[i].Contains(" all-in")) { allin[playerPos] = true; canbetcount--; } } else if (lines[i].Contains(" raises ") || lines[i].Contains(" bets ")) { var dpos = lines[i].LastIndexOf("$"); var spos = lines[i].IndexOf(' ', dpos); uint raise = (uint)(100 * Decimal.Parse(lines[i].Substring(dpos + 1, (spos > -1 ? spos : lines[i].Length) - dpos - 1))); list.Add(new PlayerAction(playerPos, new Action(ActionType.Raise, (ushort)(raise - currentBet)))); currentBet = raise; pot += currentBet; if (lines[i].Contains(" all-in")) { allin[playerPos] = true; canbetcount--; } lastPos = playerPos; noRaise = false; } else { i++; continue; } if (!lines[i].Contains(players[playerPos].Id)) //&& players.Count != 2) { } if (canbetcount != 0) { do { playerPos = (playerPos + 1) % players.Count; }while (folded[playerPos] || allin[playerPos]); } i++; } }; var history = new GameHistory(); history.Players = players.ToArray(); history.SmallBlind = smallBlind; history.BigBlind = bigBlind; history.DealerPosition = dealerPos; history.Dealer = players[dealerPos]; history.TableId = num; history.SiteName = "Poker Stars"; noRaise = true; addActions(history.PreFlopActions); if (!(lines[i].Contains("Uncalled bet (") || lines[i].Contains(" collected "))) { // flop var flop = lines[i].Substring(lines[i++].IndexOf('[') + 1, 8).Split(' ').Select(c => ParseCard(c)).ToArray(); history.Flop = flop; playerPos = dealerPos; if (canbetcount != 0) { do { playerPos = (playerPos + 1) % players.Count; } while (folded[playerPos] || allin[playerPos]); } currentBet = 0; noRaise = true; addActions(history.FlopActions); if (!(lines[i].Contains("Uncalled bet (") || lines[i].Contains(" collected "))) { var turn = ParseCard(lines[i].Substring(lines[i++].LastIndexOf('[') + 1, 2)); history.Turn = turn; playerPos = dealerPos; if (canbetcount != 0) { do { playerPos = (playerPos + 1) % players.Count; } while (folded[playerPos] || allin[playerPos]); } currentBet = 0; noRaise = true; addActions(history.TurnActions); if (!(lines[i].Contains("Uncalled bet (") || lines[i].Contains(" collected "))) { var river = ParseCard(lines[i].Substring(lines[i++].LastIndexOf('[') + 1, 2)); history.River = river; playerPos = dealerPos; if (canbetcount != 0) { do { playerPos = (playerPos + 1) % players.Count; } while (folded[playerPos] || allin[playerPos]); } currentBet = 0; noRaise = true; addActions(history.RiverActions); } } } if (lines[i].Contains("Uncalled bet (") || lines[i].Contains(" collected ")) { history.Winner = players[folded.Select((f, id) => new { f = f, i = id }).Where(f => !f.f).First().i]; history.Winnings = pot; } else { int p = 0; foreach (var s in seats) { if (folded[p++]) { continue; } while (i < lines.Length && !lines[i].StartsWith("Seat " + s + ":")) { i++; } if (i < lines.Length && lines[i].Contains("showed [")) { var hcstr = lines[i].Substring(lines[i].LastIndexOf("showed [") + 8, 5); var cp = new CardPair(ParseCard(hcstr.Substring(0, 2)), ParseCard(hcstr.Substring(3, 2))); seatIndex[s].HoleCards = cp; } } } return(history); }
public void SetCardA(CardPair _A) { A = _A; }