private decimal GetPrice(Blind blind, decimal railPrice, decimal materialPrice, List <Component> components) { var railCost = railPrice * (blind.Width / 1000); var materialCost = materialPrice * ((blind.Width * blind.Height) / 1000000); decimal componentCost = 0; decimal expence = 0; foreach (var component in components) { if (component.HeigthBased && component.WidthBased) { var wide = blind.Width < 1000 ? 1000 : blind.Width; expence = component.DefaultAmount * ((blind.Height * wide) / 1000000); } else if (component.HeigthBased) { expence = (component.DefaultAmount * blind.Height) / 1000; } else if (component.WidthBased) { expence = (component.DefaultAmount * blind.Width) / 1000; } else { expence = component.DefaultAmount; } componentCost += expence * component.Price; } var total = railCost + materialCost + componentCost; return(total); }
public void Crud_Blind() { Blind blind = new Blind() { ID = 0, BlindSetupID = 9999, BlindLevel = 100, Interval = 20 }; foreach (Blind b in repo.GetBlindsForBlindSetup(9999)) { repo.DeleteBlind(b); } Assert.AreEqual(0, repo.GetBlindsForBlindSetup(9999).Count()); repo.AddBlind(blind); Assert.AreEqual(1, repo.GetBlindsForBlindSetup(9999).Count()); blind.BlindLevel = 101; repo.UpdateBlind(blind); Assert.AreEqual(101, repo.GetBlindsForBlindSetup(9999).FirstOrDefault().BlindLevel); repo.DeleteBlind(blind); Assert.AreEqual(0, repo.GetBlindsForBlindSetup(9999).Count()); }
public BlindsHelper() { Blinds = new Blind[22]; Blinds[0] = new Blind(25, 50); Blinds[1] = new Blind(50, 100); Blinds[2] = new Blind(75, 150); Blinds[3] = new Blind(100, 200); Blinds[4] = new Blind(150, 300); Blinds[5] = new Blind(200, 400); Blinds[6] = new Blind(300, 600); Blinds[7] = new Blind(400, 800); Blinds[8] = new Blind(500, 1000); Blinds[9] = new Blind(600, 1200); Blinds[10] = new Blind(800, 1600); Blinds[11] = new Blind(1000, 2000); Blinds[12] = new Blind(1200, 2400); Blinds[13] = new Blind(1500, 3000); Blinds[14] = new Blind(2000, 4000); Blinds[15] = new Blind(2500, 5000); Blinds[16] = new Blind(3000, 6000); Blinds[17] = new Blind(4000, 8000); Blinds[18] = new Blind(5000, 10000); Blinds[19] = new Blind(6000, 12000); Blinds[20] = new Blind(8000, 16000); Blinds[21] = new Blind(10000, 20000); }
public DataSourceResult Save(BlindsModel viewModel, ModelStateDictionary modelState) { if (viewModel != null && modelState.IsValid) { var repo = this.RepoFactory.Get <BlindRepository>(); var entity = repo.GetById(viewModel.Id); if (entity == null) { entity = new Blind(); repo.Add(entity); } Mapper.Map(viewModel, entity); try { repo.SaveChanges(); viewModel.Id = entity.Id; } catch (DbEntityValidationException e) { return(new DataSourceResult { Errors = this.HandleDbEntityValidationException(e) }); } return(null); } else { return(this.HandleErrors(modelState)); } }
private void DealCards(List <IPlayer> players) { bool missingTrump = true; while (missingTrump) { IDeck Deck = new Piquet(); int timesAround = Deck.Cards.Count / players.Count; for (int i = 0; i < timesAround; ++i) { foreach (IPlayer player in players) { player.AddToHand(Deck.GetTopCard()); } } Blind.AddCard(Deck.GetTopCard()); Blind.AddCard(Deck.GetTopCard()); players.ForEach(player => { missingTrump &= !player.Hand.Cards.Aggregate(false, (agg, card) => agg || card.IsTrump()); }); // If nobody got trump, wipe the hands and blind and start again if (missingTrump) { players.ForEach(player => { player.Hand = new Hand.Hand(); }); Blind = new Blind.Blind(); } } }
/// <summary>Starts a new round.</summary> /// <param name="rnd"> /// The randomizer to shuffle the deck. /// </param> public bool StartNewRound(MT19937Generator rnd) { this.Round++; var deck = Cards.GetShuffledDeck(rnd); this.Player1.Hand = Cards.Create(deck.Take(4)); this.Player2.Hand = Cards.Create(deck.Skip(4).Take(4)); this.Table = Cards.Create(deck.Skip(8).Take(5)); this.OnButton = this.OnButton.Other(); if (this.Round > 1 && this.Round % HandsPerLevel == 1) { this.SmallBlind += 5; } if (Player1.Stack < BigBlind || Player2.Stack < BigBlind) { return(false); } Button.Post(this.SmallBlind); Blind.Post(this.BigBlind); return(true); }
private void ProcessShortcuts() { for (int nBlindIndex = 0; nBlindIndex < g_Configuration.m_arrBlinds.Count; nBlindIndex++) { Blind BlindItem = g_Configuration.m_arrBlinds[nBlindIndex]; List <string> arrShortcutUp = BlindItem.m_strShortcutUp.Split(new string[] { "," }, StringSplitOptions.None).ToList(); List <string> arrShortcutDown = BlindItem.m_strShortcutDown.Split(new string[] { "," }, StringSplitOptions.None).ToList(); bool bShortcutUp = arrShortcutUp.Count > 0; bool bShortcutDown = arrShortcutDown.Count > 0; foreach (string strKey in arrShortcutUp) { bool bFound = false; foreach (Pair <String, int> PairItem in g_arrKeyCodes) { if (PairItem.m_First == strKey.ToUpper()) { if (g_arrKeys.IndexOf(PairItem.m_Second) != -1) { bFound = true; break; } } } if (!bFound) { bShortcutUp = false; break; } } foreach (string strKey in arrShortcutDown) { bool bFound = false; foreach (Pair <String, int> PairItem in g_arrKeyCodes) { if (PairItem.m_First == strKey.ToUpper()) { if (g_arrKeys.IndexOf(PairItem.m_Second) != -1) { bFound = true; break; } } } if (!bFound) { bShortcutDown = false; break; } } if (bShortcutUp) { g_arrWindowBlinds[nBlindIndex].Increment(); } if (bShortcutDown) { g_arrWindowBlinds[nBlindIndex].Decrement(); } } }
public void BlindPointsTest() { Blind blind = new Blind(); blind.AddCard(card1); blind.AddCard(card2); Assert.AreEqual(2, blind.BlindPoints()); }
public void RunEffects() { map.selectedEnemy = this.name; GameObject effects = GameObject.Find("Effects"); if (Burned) { // map.selectedEnemy = this.name; // Burn burn = effects.GetComponent <Burn> (); burn.RunBurn(); } if (Slowed) { // map.selectedEnemy = this.name; // GameObject Slow = GameObject.Find ("_Scripts"); Slow slow = effects.GetComponent <Slow> (); slow.RunSlow(); } if (Poisoned) { // map.selectedEnemy = this.name; // GameObject Poison = GameObject.Find ("_Scripts"); Poison poison = effects.GetComponent <Poison> (); poison.RunPoison(); } if (Bleeding) { // map.selectedEnemy = this.name; // GameObject Bleed = GameObject.Find ("_Scripts"); Bleed bleed = effects.GetComponent <Bleed> (); bleed.RunBleed(); } if (Stunned) { // map.selectedEnemy = this.name; // GameObject Stun = GameObject.Find ("_Scripts"); Stun stun = effects.GetComponent <Stun> (); stun.RunStun(); } if (Chilled) { Chill chill = effects.GetComponent <Chill> (); chill.RunChill(); } if (Frozen) { Frozen frozen = effects.GetComponent <Frozen> (); frozen.RunFrozen(); } if (Blinded) { Blind blind = effects.GetComponent <Blind> (); blind.RunBlind(); } }
public Poker() { combo = new CardCombination(); players = new List <Player>(); blind = new Blind(); deck = new CardStack(); bigBlind = 1; smallBlind = 0; blind.upBlinds(50, 50); }
public void SwapCardTest() { Blind blind = new Blind(); blind.AddCard(card1); blind.AddCard(card2); blind.SwapCard(0, card3); Assert.AreEqual(card3, blind.BlindCards[0]); Assert.AreEqual(card2, blind.BlindCards[1]); blind.SwapCard(1, card1); Assert.AreEqual(card1, blind.BlindCards[1]); }
public void AddCardTest() { Blind blind = new Blind(); blind.AddCard(card1); blind.AddCard(card2); Assert.AreEqual(card1, blind.BlindCards[0]); Assert.AreEqual(card2, blind.BlindCards[1]); blind.AddCard(card3); Assert.AreEqual(2, blind.BlindCards.Count); Assert.AreEqual(card1, blind.BlindCards[0]); Assert.AreEqual(card2, blind.BlindCards[1]); }
public BlindExample() { var blind = new Blind(Connectors.GPIO17, Connectors.GPIO17); Console.WriteLine("Blind is closing.."); blind.Down(); Console.WriteLine("Blind is opening.."); blind.Up(); blind.Stop(); Console.WriteLine("Blind stop."); blind.OnDispose(); }
private void TraiterEvtAugmentationBlinds(AugmentationBlinds evt) { logClient.Debug("* Augmentation Blinds"); Blind infosBlind = new Blind(); infosBlind.DelaiAugmentationBlinds = TimeSpan.Zero; infosBlind.MontantPetiteBlind = evt.MontantPetiteBlind; _montantPetiteBlind = infosBlind.MontantPetiteBlind; infosBlind.MontantGrosseBlind = evt.MontantGrosseBlind; _montantGrosseBlind = infosBlind.MontantGrosseBlind; infosBlind.MontantProchainePetiteBlind = infosBlind.MontantProchainePetiteBlind; infosBlind.MontantProchaineGrosseBlind = infosBlind.MontantProchaineGrosseBlind; infosBlind.DelaiAugmentationBlinds = infosBlind.DelaiAugmentationBlinds; LancerEvtMessageInfo(new MessageInfo(infosBlind)); }
public static string ToFriendlyString(this Blind blind) { switch (blind) { case Blind.None: return(""); case Blind.Small: return("SB"); case Blind.Big: return("BB"); default: return(""); } }
public Table() { players = new PlayerList(); deck = new Deck(); rand = new Random(); mainPot = new Pot(); sidePots = new List<Pot>(); smallBlind = new Blind(); bigBlind = new Blind(); roundCounter = 0; turnCount = 0; dealerPosition = rand.Next(players.Count); //set blind amount and position smallBlind.Amount = 500; bigBlind.Amount = 1000; mainPot.SmallBlind = 500; mainPot.BigBlind = 1000; smallBlind.position = dealerPosition + 1; bigBlind.position = dealerPosition + 2; currentIndex = dealerPosition; }
/// <summary> /// Enregistrement de l'augmentation des blinds /// </summary> /// <param name="montantGrosseBlind"></param> /// <param name="montantPetiteBlind"></param> internal void EnregistrerAugmentationBlinds(Blind infosBlind) { try { AugmentationBlinds aug = new AugmentationBlinds(); aug.MontantPetiteBlind = infosBlind.MontantPetiteBlind; aug.MontantGrosseBlind = infosBlind.MontantGrosseBlind; aug.MontantProchainePetiteBlind = infosBlind.MontantProchainePetiteBlind; aug.MontantProchaineGrosseBlind = infosBlind.MontantProchaineGrosseBlind; aug.DelaiAugmentationBlinds = infosBlind.DelaiAugmentationBlinds; foreach (IStatistiques stat in _statistiques) { stat.Enregistrer(aug); } } catch (Exception ex) { logServeur.Debug("Erreur lors d'EnregistrerAugmentationBlinds : " + ex.Message); } }
public Table() { players = new PlayerList(); deck = new Deck(); rand = new Random(); mainPot = new Pot(); sidePots = new List <Pot>(); smallBlind = new Blind(); bigBlind = new Blind(); roundCounter = 0; turnCount = 0; dealerPosition = rand.Next(players.Count); //set blind amount and position smallBlind.Amount = 500; bigBlind.Amount = 1000; mainPot.SmallBlind = 500; mainPot.BigBlind = 1000; smallBlind.position = dealerPosition + 1; bigBlind.position = dealerPosition + 2; currentIndex = dealerPosition; }
public virtual async Task Apply(Block block, JsonElement op, JsonElement content) { #region init var activation = new ActivationOperation { Id = Cache.AppState.NextOperationId(), Block = block, Level = block.Level, Timestamp = block.Timestamp, OpHash = op.RequiredString("hash"), Account = (User)await Cache.Accounts.GetAsync(content.RequiredString("pkh")), Balance = content.Required("metadata").Required("balance_updates")[0].RequiredInt64("change") }; var btz = Blind.GetBlindedAddress(content.RequiredString("pkh"), content.RequiredString("secret")); var commitment = await Db.Commitments.FirstAsync(x => x.Address == btz); #endregion #region entities //var block = activation.Block; var sender = activation.Account; //Db.TryAttach(block); Db.TryAttach(sender); #endregion #region apply operation sender.Balance += activation.Balance; sender.Activated = true; block.Operations |= Operations.Activations; commitment.AccountId = sender.Id; commitment.Level = block.Level; #endregion Db.ActivationOps.Add(activation); Activation = activation; }
public int GetPickerScore() { int total = 0; int pickTricks = 0; Rounds.ForEach(round => { IPlayer winner = round.Trick.TheWinnerPlayer(); if (winner == Picker) { ++pickTricks; } if (winner == Picker || winner == Partner) { total += round.Trick.TrickValue(); } }); if (pickTricks > 0) { total += Blind.BlindPoints(); } return(total); }
private void TraiterEvtNouvelleDonne(NouvelleDonne evt) { logClient.Debug("* Nouvelle Donne"); Blind infosBlind = evt.InfosBlind; _pot = null; _board = new CartePoker[5]; LancerEvtMessageInfo(new MessageInfo(MessageJeu.NouvelleDonne) { InfosBlind = infosBlind }); // Dealer, PetiteBlind, Grosse Blind ReinitialiserBouton(evt.Dealer, evt.PetiteBlind, evt.GrosseBlind); // Liste des cartes foreach (JoueurStat j in evt.ListeJoueurs) { Joueur joueurEnCours = _listeJoueurs[j.Nom]; joueurEnCours.Carte1 = j.Carte1; joueurEnCours.Carte2 = j.Carte2; joueurEnCours.TapisJoueur = j.Tapis; joueurEnCours.TourDeJeu = false; joueurEnCours.Mise = 0; joueurEnCours.Elimine = (j.Tapis == 0); joueurEnCours.DerniereAction = TypeActionJoueur.Aucune; if (joueurEnCours.TapisJoueur == 0) { LancerEvtChangementInfosJoueur(joueurEnCours.Nom, EtatMain.PasDeCartes, j.Carte1, j.Carte2, 0); } else { LancerEvtChangementInfosJoueur(joueurEnCours.Nom, EtatMain.Montree, j.Carte1, j.Carte2, 0); } } }
public void Crud_Blind() { Blind blind = new Blind() { ID = 0, BlindSetupID = 9999, BlindLevel = 100, Interval = 20 }; foreach (Blind b in repo.GetBlindsForBlindSetup(9999)) repo.DeleteBlind(b); Assert.AreEqual(0, repo.GetBlindsForBlindSetup(9999).Count()); repo.AddBlind(blind); Assert.AreEqual(1, repo.GetBlindsForBlindSetup(9999).Count()); blind.BlindLevel = 101; repo.UpdateBlind(blind); Assert.AreEqual(101, repo.GetBlindsForBlindSetup(9999).FirstOrDefault().BlindLevel); repo.DeleteBlind(blind); Assert.AreEqual(0, repo.GetBlindsForBlindSetup(9999).Count()); }
/// <summary> /// Enregistrement d'une nouvelle donne /// </summary> /// <param name="listeJoueurs"></param> /// <param name="numeroDonne"></param> internal void EnregistrerNouvelleDonne(int numeroDonne, List <Joueur> listeJoueurs, Blind infosBlind) { try { NouvelleDonne donne = new NouvelleDonne(); donne.Dealer = RechercherDealer(listeJoueurs); donne.PetiteBlind = RechercherPetiteBlind(listeJoueurs); donne.GrosseBlind = RechercherGrosseBlind(listeJoueurs); donne.NumeroDonne = numeroDonne; donne.InfosBlind = infosBlind; donne.ListeJoueurs = CloneListeJoueursSansCartes(listeJoueurs); foreach (IStatistiques stat in _statistiques) { stat.Enregistrer(donne); } } catch (Exception ex) { logServeur.Debug("Erreur lors d'EnregistrerNouvelleDonne : " + ex.Message); } }
//Note that lines is only passed for efficiency, it could be obtained //by just splitting handText private PokerHand parseHand(List <string> lines, string handText) { PokerHand hand = new PokerHand(); #region setup variables int start; int curLine; List <Round> rounds = new List <Round>(); #endregion #region Make sure it's a Party Poker hand if (!handText.StartsWith(HAND_START_TEXT)) { throw new InvalidHandFormatException(handText); } #endregion hand.Context.Online = true; hand.Context.Site = Name; #if DEBUG Console.WriteLine("Hand Number"); #endif #region Get the hand number hand.Context.ID = gameNumExp.Match(handText).Groups[1].Value; //Console.WriteLine("ID: {0}", hand.Context.ID); if (printed < 200) { Console.WriteLine("Hand Text: {0}", handText); printed++; } #endregion #if DEBUG Console.WriteLine("Hand Number: {0}", hand.Context.ID); Console.WriteLine("Table Name"); #endif #region Get the table name hand.Context.Table = tableNameExp.Match(handText).Groups[1].Value; #endregion #if DEBUG Console.WriteLine(hand.Context.Table); Console.WriteLine("Blinds"); #endif #region Get the blinds and game format var stakesAndDate = stakesAndDateExp.Match(lines.First(line => line.StartsWith("$"))); hand.Context.SmallBlind = decimal.Parse(stakesAndDate.Groups[1].Value) / 2.0m; // All old pp stakesAndDate were sb = 0.5 * bb hand.Context.BigBlind = decimal.Parse(stakesAndDate.Groups[1].Value); // Assume no ante. #endregion #if DEBUG Console.WriteLine("Small Blind: {0}", hand.Context.SmallBlind); Console.WriteLine("Big Blind: {0}", hand.Context.BigBlind); Console.WriteLine("Game Format"); #endif #region Get the game format // TODO: Support more than cash games hand.Context.Format = GameFormat.CashGame; #endregion #if DEBUG Console.WriteLine("Poker Variant and Betting Type"); #endif #region Get the betting type and poker variant // Assume playing fixed limit Texas Hold'em hand.Context.CapAmountSpecified = false; hand.Context.Capped = false; hand.Context.BettingType = BettingType.FixedLimit; hand.Context.PokerVariant = PokerVariant.TexasHoldEm; #endregion #if DEBUG Console.WriteLine("Time Stamp"); #endif #region Get the date and time int year = int.Parse(stakesAndDate.Groups[14].Value); int month = monthToInt(stakesAndDate.Groups[8].Value); int day = int.Parse(stakesAndDate.Groups[9].Value); int hour = int.Parse(stakesAndDate.Groups[10].Value); int minute = int.Parse(stakesAndDate.Groups[11].Value); int second = int.Parse(stakesAndDate.Groups[12].Value); string timeZone = stakesAndDate.Groups[13].Value;// Note: Currently not considered. hand.Context.TimeStamp = new DateTime(year, month, day, hour, minute, second); #endregion #if DEBUG Console.WriteLine("DateTime: {0}", hand.Context.TimeStamp.ToString()); Console.WriteLine("Players"); #endif #region Create the players List <Player> players = new List <Player>(); curLine = 5; for (Match m = stacksExp.Match(lines[curLine]); m.Success; m = stacksExp.Match(lines[++curLine])) { if (m.Success) { GroupCollection gc = m.Groups; Player p = new Player(); p.Seat = Int32.Parse(gc[1].Value); p.Name = gc[2].Value; p.Stack = Decimal.Parse(gc[3].Value); players.Add(p); } } hand.Players = players.ToArray(); #endregion #if DEBUG foreach (var player in hand.Players) { Console.WriteLine("Seat: {0} Name: {1} Chips: {2}", player.Seat, player.Name, player.Stack); } Console.WriteLine("Blinds and Antes Posted"); #endif #region Get the blinds and antes posted List <Blind> blinds = new List <Blind>(); for (; lines[curLine] != "** Dealing down cards **"; curLine++) { Match m = actionExp.Match(lines[curLine]); if (!m.Success) { continue; } //throw new InvalidHandFormatException("Hand " + hand.Context.ID + ". Unknown blind or ante: " + lines[curLine]); GroupCollection gc = m.Groups; Blind blind = new Blind(); blind.Player = gc[1].Value; if (gc[2].Value == "posts the ante") { blind.Type = BlindType.Ante; } else if (gc[2].Value == "posts small blind") { blind.Type = BlindType.SmallBlind; } else if (gc[2].Value == "posts big blind") { blind.Type = BlindType.BigBlind; } else if (gc[2].Value.StartsWith("posts")) { blind.Type = BlindType.LateBlind; } else { throw new Exception("Unknown blind type: " + lines[curLine]); } //TODO: Handle dead and late blinds appropriately blind.Amount = Decimal.Parse(gc[4].Value); // TODO: Handle all-in blind posts //blind.AllIn = gc[9].Value.Length == 15; blind.AllIn = false; blinds.Add(blind); } hand.Blinds = blinds.ToArray(); #endregion #if DEBUG foreach (var blind in hand.Blinds) { Console.WriteLine("Player: {0} Amount: {1} Type: {2} All-in: {3}", blind.Player, blind.Amount, blind.Type, blind.AllIn); } Console.WriteLine("Button"); #endif #region Get the hole cards and the name of the hero Match hcMatch = holeCardsExp.Match(handText); if (hcMatch.Success) { List <Card> holecards = new List <Card>(); hand.Hero = hcMatch.Groups[1].Value; holecards.Add(new Card(hcMatch.Groups[2].Value)); holecards.Add(new Card(hcMatch.Groups[3].Value)); hand.HoleCards = holecards.ToArray(); //TODO: Handle Omaha. } #endregion #if DEBUG if (hcMatch.Success) { Console.WriteLine("Hero: {0} HoleCard1: {1} HoleCard2: {2}", hand.Hero, hand.HoleCards[0], hand.HoleCards[1]); } Console.WriteLine("Preflop Actions"); #endif #region Preflop Actions curLine = lines.IndexOf("** Dealing down cards **") + (hand.Hero == null ? 1 : 2); rounds.Add(new Round()); rounds[0].Actions = getRoundActions(hand, rounds, lines, ref curLine); #endregion #if DEBUG if (rounds[0].CommunityCards != null) { foreach (var card in rounds[0].CommunityCards) { Console.WriteLine("Preflop Card: {0}", card); } } foreach (var action in rounds[0].Actions) { Console.WriteLine("Preflop Player: {0} Action: {1} Amount: {2} All-In: {3}", action.Player, action.Type, action.Amount, action.AllIn); } Console.WriteLine("Flop Actions"); #endif #region Get the button // F**k the button statement. Hand histories are buggy with this number. // hand.Context.Button = Int32.Parse(buttonExp.Match(handText).Groups[1].Value); // curLine++; // Validate the button -- It is apparently buggy in some hand histories. var blindNames = hand.Blinds.Where(b => b.Type == BlindType.SmallBlind || b.Type == BlindType.BigBlind).Select(b => b.Player); var buttonName = rounds[0].Actions[0].Player; List <string> actedAlready = new List <string>(); actedAlready.AddRange(blindNames); actedAlready.Add(buttonName); for (int i = 1; i < rounds[0].Actions.Length; i++) { string actor = rounds[0].Actions[i].Player; if (!actedAlready.Contains(actor)) { buttonName = actor; actedAlready.Add(actor); } } hand.Context.Button = hand.Players.First(p => p.Name == buttonName).Seat; #endregion #if DEBUG Console.WriteLine("Button: {0}", hand.Context.Button); Console.WriteLine("Hole Cards and Hero"); #endif #region Flop Actions and Community Cards if (lines[curLine].StartsWith("** Dealing Flop **")) { rounds.Add(new Round()); start = lines[curLine].IndexOf('[') + 2; Card[] flop = new Card[3]; flop[0] = new Card(lines[curLine].Substring(start, 2)); flop[1] = new Card(lines[curLine].Substring(start + 4, 2)); flop[2] = new Card(lines[curLine].Substring(start + 8, 2)); rounds[1].CommunityCards = flop; curLine++; rounds[1].Actions = getRoundActions(hand, rounds, lines, ref curLine); } #endregion #if DEBUG if (rounds.Count > 1) { foreach (var card in rounds[1].CommunityCards) { Console.WriteLine("Flop Card: {0}", card); } foreach (var action in rounds[1].Actions) { Console.WriteLine("Flop Player: {0} Action: {1} Amount: {2} All-In: {3}", action.Player, action.Type, action.Amount, action.AllIn); } } Console.WriteLine("Turn Actions"); #endif #region Turn Actions and Community Card if (lines[curLine].StartsWith("** Dealing Turn **")) { rounds.Add(new Round()); start = lines[curLine].LastIndexOf('[') + 2; Card[] turn = new Card[1]; turn[0] = new Card(lines[curLine].Substring(start, 2)); rounds[2].CommunityCards = turn; curLine++; rounds[2].Actions = getRoundActions(hand, rounds, lines, ref curLine); } #endregion #if DEBUG if (rounds.Count > 2) { foreach (var card in rounds[2].CommunityCards) { Console.WriteLine("Turn Card: {0}", card); } foreach (var action in rounds[2].Actions) { Console.WriteLine("Turn Player: {0} Action: {1} Amount: {2} All-In: {3}", action.Player, action.Type, action.Amount, action.AllIn); } } Console.WriteLine("River Actions"); #endif #region River Actions and Community Card if (lines[curLine].StartsWith("** Dealing River **")) { rounds.Add(new Round()); start = lines[curLine].LastIndexOf('[') + 2; Card[] river = new Card[1]; river[0] = new Card(lines[curLine].Substring(start, 2)); rounds[3].CommunityCards = river; curLine++; rounds[3].Actions = getRoundActions(hand, rounds, lines, ref curLine); } #endregion #region Set rounds hand.Rounds = rounds.ToArray(); #endregion #if DEBUG if (rounds.Count > 3) { foreach (var card in rounds[3].CommunityCards) { Console.WriteLine("River Card: {0}", card); } foreach (var action in rounds[3].Actions) { Console.WriteLine("River Player: {0} Action: {1} Amount: {2} All-In: {3}", action.Player, action.Type, action.Amount, action.AllIn); } } Console.WriteLine("Shown Hands"); #endif List <HandResult> results = new List <HandResult>(); #region Get the shown down hands for (Match match = shownHandsExp.Match(handText); match.Success; match = match.NextMatch()) { GroupCollection gc = match.Groups; if (!hand.Players.Select(p => p.Name).Contains(gc[1].Value)) { continue; } HandResult hr = new HandResult(gc[1].Value); if (gc[2].Value != "does not show cards") { hr.HoleCards = new Card[] { new Card(gc[4].Value), new Card(gc[5].Value) } } ; results.Add(hr); } #endregion #if DEBUG foreach (var hr in results) { Console.WriteLine("Player: {0} Cards: {1}", hr.Player, hr.HoleCards == null ? "" : hr.HoleCards[0].ToString() + " " + hr.HoleCards[1].ToString()); } #endif #region Get pots won List <List <Pot> > pots = new List <List <Pot> >(); for (int i = 0; i < results.Count; i++) { pots.Add(new List <Pot>()); } for (; curLine < lines.Count; curLine++) { Match m = potsExp.Match(lines[curLine]); if (m.Success) { GroupCollection gc = m.Groups; if (!hand.Players.Select(player => player.Name).Contains(gc[1].Value)) { continue; } Pot p = new Pot(); p.Amount = Decimal.Parse(gc[2].Value); if (gc[6].Value == "" || gc[6].Value == "the main pot") { p.Number = 0; } else { p.Number = int.Parse(gc[7].Value); } HandResult result = null; List <Pot> potList = null; for (int i = 0; i < results.Count; i++) { if (results[i].Player == gc[1].Value) { result = results[i]; potList = pots[i]; break; } } //if (result == null) //{ // result = new HandResult(gc[1].Value); // potList = new List<Pot>(); // results.Add(result); // pots.Add(potList); //} potList.Add(p); } } //add the pots to the model for (int i = 0; i < results.Count; i++) { results[i].WonPots = pots[i].ToArray(); } // Set the results hand.Results = results.ToArray(); #if DEBUG foreach (var result in hand.Results) { foreach (var pot in result.WonPots) { Console.WriteLine("Pot: {0} Player: {1} Amount: {2}", pot.Number, result.Player, pot.Amount); } } Console.WriteLine("Calculating rake"); #endif //get the rake, if any if (hand.Context.Format == GameFormat.CashGame) { hand.Rake = hand.Rounds.Sum(r => r.Actions.Sum(act => act.Amount)) + hand.Blinds.Sum(b => b.Amount) - hand.Results.Sum(r => r.WonPots.Sum(w => w.Amount)); } #endregion #if DEBUG Console.WriteLine("Rake: {0}", hand.Rake); Console.WriteLine("Done"); #endif return(hand); }
public void UpdateBlind(Blind blind) { Connection.Update<Blind>(blind); }
//====================================================== #region Event Methods private void SpecialForm_Load(object sender, EventArgs e) { //Until I find a better way, this list is typed manually. //Rules attached to this ability should be added first, for editing. if (ability.SpecialRules != null) { foreach (SpecialRule rule in ability.SpecialRules) { clbSpecials.Items.Add(rule, true); } } //Add the rest of the rules, but don't add ones already added from the ability. SpecialRule nRule = new Acid(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new ArmorBuster(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Blast(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Blind(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new ChangeSpeed(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new ChangeStrength(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new ChangeMarksmanship(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new ChangeTech(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new CounterAttack(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Deafen(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new DrainTime(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Encase(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Explosion(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Fear(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new GreaterAcid(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new GreaterCounterAttack(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new GreaterIndirect(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new GreaterNoDeflect(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new GreaterNoDodge(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Heal(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new IdentifyFriendFoe(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Indirect(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Leap(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new NoArmorReduction(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new NoDeflect(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new NoDodge(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Paralyze(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new PoisonMalignant(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new PoisonResilient(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Pull(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Range(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new CharacterCreator.Classes.SpecialRules.Radius(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new RerollMisses(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new RerollHits(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Reach(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Roll(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Slam(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Stream(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Stun(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new SuperbAcid(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new SuperbCounterAttack(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new SuperbIndirect(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new SuperbNoDeflect(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new SuperbNoDodge(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new TechAttack(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new TechBlast(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new TechBlind(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new TechDeafen(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new TechExplosion(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new TechEncase(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new TechMelee(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new TechParalyze(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new TechRange(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Teleport(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Throw(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } nRule = new Trip(); if (!ability.SpecialRules.Contains(nRule)) { clbSpecials.Items.Add(nRule); } }
public void RunEffect() { GameObject effects = GameObject.Find("Effects"); switch (effect) { case Effects.ArmorUp: // less inc physical dmg break; case Effects.Burn: Burn burn = effects.GetComponent <Burn> (); damage = burn.Damage(damage, 3); //= damage / 3; burn.ApplyBurn(3, damage); break; case Effects.Bleed: // GameObject Bleed = GameObject.Find ("_Scripts"); Bleed bleed = effects.GetComponent <Bleed> (); bleed.ApplyBleed(); break; case Effects.Chill: // same as slow, but second proc will apply "frozen". Also apply frozen if speed = 0 Chill chill = effects.GetComponent <Chill> (); chill.ApplyChill(); break; case Effects.Slow: // GameObject Slow = GameObject.Find ("_Scripts"); Slow slow = effects.GetComponent <Slow> (); slow.ApplySlow(); break; case Effects.Freeze: // enemy will turns as long as frozen. Burn will neutralize effect. 50% less physical dmg Frozen frozen = effects.GetComponent <Frozen> (); frozen.ApplyFrozen(); break; case Effects.Poison: // GameObject Poison = GameObject.Find ("_Scripts"); Poison poison = effects.GetComponent <Poison> (); poison.damage = damage / 5; poison.ApplyPoison(); break; case Effects.ShieldUp: // block next melee or ranged attack break; case Effects.SpeedUp: // 20% more MS break; case Effects.Stun: // GameObject Stun = GameObject.Find ("_Scripts"); Stun stun = effects.GetComponent <Stun> (); stun.ApplyStun(); break; case Effects.Blind: // GameObject Stun = GameObject.Find ("_Scripts"); Blind blind = effects.GetComponent <Blind> (); blind.Applyblind(); break; case Effects.RemoveBleed: // Remove bleed stacks from target break; case Effects.MagicResUp: // less inc magic dmg break; case Effects.Restoration: // GameObject Restoration = GameObject.Find ("_Scripts"); Restoration restoration = effects.GetComponent <Restoration> (); restoration.heal = healDot; restoration.ApplyRestoration(); break; case Effects.Fly: // walk through objects break; case Effects.FullVision: // see full map break; case Effects.SharedVision: // all players see shared vision break; case Effects.VisionTotem: // tetem taht grands only vision break; case Effects.SpellTotem: // "playable" totem break; case Effects.Cure: // remove all negative effect break; case Effects.AiAlly: // summon AI ally break; case Effects.Empty: break; default: break; } }
/// <summary>指定されたBlindの支払い処理を計算する</summary> /// <param name="blind"></param> /// <param name="result"></param> /// <param name="hh"></param> /// <param name="line"></param> private void calcBlindPayment(Blind blind, ref TableData result, string[] hh, ref int line) { Regex regex = new Regex("(.+):" + Regex.Escape(" ") + "posts" + Regex.Escape(" ") + blind + Regex.Escape(" ") + "blind" + Regex.Escape(" ") + "([0-9]+)"); MatchCollection matchCol = regex.Matches(hh[++line]); if (matchCol.Count > 0) { for (int j = 0; j < maxSeatNum; ++j) { if (matchCol[0].Groups[1].Value.Equals(result.playerNames[j])) { result.posted[j] = System.Convert.ToInt32(matchCol[0].Groups[2].Value); result.chips[j] -= result.posted[j]; result.pot += result.posted[j]; } } } else { line -= 1; } }
//Note that lines is only passed for efficiency, it could be obtained by just splitting handText private PokerHand parseHand(List <string> lines, string handText) { PokerHand hand = new PokerHand(); #region setup variables int start; int end; int curLine; char currencySymbol; List <Round> rounds = new List <Round>(); #endregion // Edited #region Make sure it's a PokerStars hand if (!handText.StartsWith("PokerStars")) { throw new InvalidHandFormatException(handText); } #endregion #region Skip partial hands if (lines[0].EndsWith("(partial)")) { return(null); } #endregion // Edited hand.Context.Online = true; hand.Context.Site = "PokerStars"; #if DEBUG Console.WriteLine("Hand Number"); #endif // Edited #region Get the hand number start = handText.IndexOf('#') + 1; end = handText.IndexOf(':'); hand.Context.ID = handText.Substring(start, end - start); //Console.WriteLine("ID: {0}", hand.Context.ID); if (printed < 2) { Console.WriteLine("Hand Text: {0}", handText); printed++; } #endregion #if DEBUG Console.WriteLine("Table Name"); #endif // Edited #region Get the table name start = lines[1].IndexOf('\''); end = lines[1].IndexOf('\'', 7); hand.Context.Table = (lines[1].Substring(start + 1, end - start - 1)); #endregion #if DEBUG Console.WriteLine("Blinds"); #endif // Edited #region Get the blinds, antes and currency start = handText.IndexOf('('); end = handText.IndexOf('/'); string smallBlind = handText.Substring(start + 1, end - start - 1); start = end; end = handText.IndexOf(' ', start); string bigBlind = handText.Substring(start + 1, end - start - 1); if (smallBlind[0].Equals('$') || smallBlind[0].Equals('€')) { if (smallBlind[0].Equals('$')) { hand.Context.Currency = "USD"; currencySymbol = '$'; } else { hand.Context.Currency = "EUR"; currencySymbol = '€'; } hand.Context.SmallBlind = Decimal.Parse(smallBlind.Substring(1).Trim()); hand.Context.BigBlind = Decimal.Parse(bigBlind.Substring(1).Trim()); } else { currencySymbol = 'T'; hand.Context.SmallBlind = Decimal.Parse(smallBlind.Trim()); hand.Context.BigBlind = Decimal.Parse(bigBlind.Substring(0, bigBlind.Length - 1).Trim()); } // Antes are not written on the first line in PokerStars hand histories // Ante amount will have to be extracted from post blind lines. // Smallest possible post blind line index is 4 curLine = 4; while (!lines[curLine].Equals("*** HOLE CARDS ***")) { if (lines[curLine].Contains(" posts the ante ")) { start = lines[curLine].IndexOf("ante"); string anteText = lines[curLine].Substring(start + 5); if (anteText[0].Equals(currencySymbol)) { anteText = anteText.Substring(1); } hand.Context.Ante = Decimal.Parse(anteText.Trim()); break; } curLine++; } #endregion #if DEBUG Console.WriteLine("Game Format"); #endif #region Get the game format // Stars does not have different notations for Sit&Go's and MTTs. // All tournament hand histories are of the same format. if (currencySymbol.Equals('T')) { if (lines[0].Contains(": Tournament #")) { hand.Context.Format = GameFormat.Tournament; } else { hand.Context.Format = GameFormat.PlayMoney; } } else { hand.Context.Format = GameFormat.CashGame; } #endregion #if DEBUG Console.WriteLine("Poker Variant and Betting Type"); #endif #region Get the betting type and poker variant if (hand.Context.Format == GameFormat.CashGame && handText.Contains(" Cap - ")) { start = handText.IndexOf(" - ") + 3; end = handText.IndexOf(" Cap "); string capAmountText = handText.Substring(start, end - start); hand.Context.CapAmount = Decimal.Parse(capAmountText.Substring(1).Trim()); hand.Context.CapAmountSpecified = true; hand.Context.Capped = true; } else { hand.Context.CapAmountSpecified = false; hand.Context.Capped = false; } string typeAndVariant; if (hand.Context.Format == GameFormat.CashGame) { start = handText.IndexOf(": ") + 3; end = handText.IndexOf(" (", start); typeAndVariant = handText.Substring(start, end - start); } else { start = handText.IndexOf(hand.Context.Currency) + 4; end = handText.IndexOf(" - ", start); typeAndVariant = handText.Substring(start, end - start); } if (typeAndVariant.Contains("Pot Limit")) { hand.Context.BettingType = BettingType.PotLimit; } else if (typeAndVariant.Contains("No Limit")) { hand.Context.BettingType = BettingType.NoLimit; } else { hand.Context.BettingType = BettingType.FixedLimit; } if (typeAndVariant.Contains("Hold'em")) { hand.Context.PokerVariant = PokerVariant.TexasHoldEm; } else if (typeAndVariant.Contains("Omaha Hi")) { hand.Context.PokerVariant = PokerVariant.OmahaHi; } else { hand.Context.PokerVariant = PokerVariant.OmahaHiLo; } #endregion #if DEBUG Console.WriteLine("Time Stamp"); #endif #region Get the date and time start = lines[0].LastIndexOf(" - ") + 3; end = lines[0].IndexOf(' ', start); string dateText = lines[0].Substring(start, end - start); string[] dateTokens = dateText.Split('/'); int year = Int32.Parse(dateTokens[0]); int month = Int32.Parse(dateTokens[1]); int day = Int32.Parse(dateTokens[2]); start = end; end = lines[0].IndexOf(' ', start + 1); string timeText = lines[0].Substring(start, end - start); string[] timeTokens = timeText.Split(':'); int hour = Int32.Parse(timeTokens[0]); int minute = Int32.Parse(timeTokens[1]); int second = Int32.Parse(timeTokens[2]); hand.Context.TimeStamp = new DateTime(year, month, day, hour, minute, second); #endregion #if DEBUG Console.WriteLine("Players"); #endif #region Create the players List <Player> players = new List <Player>(); curLine = 2; for (Match m = stacksExp.Match(lines[curLine]); m.Success; m = stacksExp.Match(lines[curLine])) { if (m.Success) { GroupCollection gc = m.Groups; Player p = new Player(); p.Seat = Int32.Parse(gc[1].Value); p.Name = gc[2].Value; p.Stack = Decimal.Parse(gc[4].Value); players.Add(p); curLine++; } } hand.Players = players.ToArray(); #endregion #if DEBUG Console.WriteLine("Blinds and Antes Posted"); #endif #region Terminate parsing of unsupported poker type if ((!typeAndVariant.Contains("Hold'em") && (!typeAndVariant.Contains("Omaha")))) { return(hand); } #endregion #region Get the blinds and antes posted List <Blind> blinds = new List <Blind>(); for (; !lines[curLine].StartsWith("*** HOLE CARDS ***"); curLine++) { for (Match m = actionExp.Match(lines[curLine]); m.Success; m = m.NextMatch()) { GroupCollection gc = m.Groups; Blind blind = new Blind(); blind.Player = gc[1].Value; String a = gc[2].Value + "" + gc[3].Value + "" + gc[4].Value + "" + gc[5].Value + "" + gc[6].Value + "" + gc[7].Value + "" + gc[8].Value + "" + gc[9].Value + "" + gc[10].Value + "" + gc[11].Value + "" + gc[12].Value; if (gc[2].Value.Contains("ante")) { blind.Type = BlindType.Ante; } else if (gc[2].Value.Contains("small")) { blind.Type = BlindType.SmallBlind; } else if (gc[2].Value.Contains("big")) { blind.Type = BlindType.BigBlind; } else { throw new Exception("Unknown blind type: " + lines[curLine]); } if (lines[curLine].Contains("dead")) { for (int i = 0; i < gc.Count; i++) { Console.WriteLine("{0}: \"{1}\"", i, gc[i].Value); } Console.WriteLine("Found as {0}", blind.Type.ToString()); } blind.Amount = Decimal.Parse(gc[4].Value); blind.AllIn = !gc[12].Value.Equals(""); blinds.Add(blind); } } hand.Blinds = blinds.ToArray(); #endregion #if DEBUG Console.WriteLine("Button"); #endif #region Get the button string buttonText = lines[1].Substring(lines[1].IndexOf('#') + 1, 1); hand.Context.Button = Int32.Parse(buttonText); curLine++; #endregion #if DEBUG Console.WriteLine("Hole Cards and Hero"); #endif #region Get the hole cards and the name of the hero int tempIndex = curLine; bool heroType = true; while (!lines[curLine].StartsWith("Dealt to ")) { if (lines[curLine].Equals("*** FLOP ***") || lines[curLine].Equals("*** SUMMARY ***")) { curLine = tempIndex; heroType = false; break; } else { curLine++; } } if (heroType) { start = "Dealt to ".Length; end = lines[curLine].IndexOf(" [", start); hand.Hero = lines[curLine].Substring(start, end - start); start = end + 2; List <Card> holecards = new List <Card>(); holecards.Add(new Card(lines[curLine].Substring(start, 2))); holecards.Add(new Card(lines[curLine].Substring(start + 3, 2))); if (hand.Context.PokerVariant != PokerVariant.TexasHoldEm) { holecards.Add(new Card(lines[curLine].Substring(start + 6, 2))); holecards.Add(new Card(lines[curLine].Substring(start + 9, 2))); } hand.HoleCards = holecards.ToArray(); curLine++; } #endregion #if DEBUG Console.WriteLine("Preflop Actions"); #endif #region Preflop Actions rounds.Add(new Round()); rounds[0].Actions = getRoundActions(lines, ref curLine); #endregion #if DEBUG Console.WriteLine("Flop Actions"); #endif #region Flop Actions and Community Cards if (lines[curLine].StartsWith("*** FLOP ***")) { rounds.Add(new Round()); start = lines[curLine].IndexOf('[') + 1; Card[] flop = new Card[3]; flop[0] = new Card(lines[curLine].Substring(start, 2)); flop[1] = new Card(lines[curLine].Substring(start + 3, 2)); flop[2] = new Card(lines[curLine].Substring(start + 6, 2)); rounds[1].CommunityCards = flop; curLine++; rounds[1].Actions = getRoundActions(lines, ref curLine); } #endregion #if DEBUG Console.WriteLine("Turn Actions"); #endif #region Turn Actions and Community Card if (lines[curLine].StartsWith("*** TURN ***")) { rounds.Add(new Round()); start = lines[curLine].LastIndexOf('[') + 1; Card[] turn = new Card[1]; turn[0] = new Card(lines[curLine].Substring(start, 2)); rounds[2].CommunityCards = turn; curLine++; rounds[2].Actions = getRoundActions(lines, ref curLine); } #endregion #if DEBUG Console.WriteLine("River Actions"); #endif #region River Actions and Community Card if (lines[curLine].StartsWith("*** RIVER ***")) { rounds.Add(new Round()); start = lines[curLine].LastIndexOf('[') + 1; Card[] river = new Card[1]; river[0] = new Card(lines[curLine].Substring(start, 2)); rounds[3].CommunityCards = river; curLine++; rounds[3].Actions = getRoundActions(lines, ref curLine); } #endregion #region Set rounds hand.Rounds = rounds.ToArray(); #endregion #if DEBUG Console.WriteLine("Results"); #endif #region Get pots won List <HandResult> results = new List <HandResult>(); List <List <Pot> > pots = new List <List <Pot> >(); for (; !lines[curLine].StartsWith("*** SUMMARY"); curLine++) { Match m = potsExp.Match(lines[curLine]); if (m.Success) { GroupCollection gc = m.Groups; Pot p = new Pot(); p.Amount = Decimal.Parse(gc[3].Value); if (gc[7].Value.Length > 0) { p.Number = Int32.Parse(gc[7].Value.Substring(1)); } else if ((gc[5].Value.Length == 0 && gc[3].Value == "the pot") || gc[5].Value == "main ") { p.Number = 0; } else if (gc[5].Length > 0) { p.Number = 1; } HandResult result = null; List <Pot> potList = null; for (int i = 0; i < results.Count; i++) { if (results[i].Player == gc[1].Value) { result = results[i]; potList = pots[i]; break; } } if (result == null) { result = new HandResult(gc[1].Value); potList = new List <Pot>(); results.Add(result); pots.Add(potList); } potList.Add(p); } } //add the pots to the model for (int i = 0; i < results.Count; i++) { results[i].WonPots = pots[i].ToArray(); } //get the rake, if any if (hand.Context.Format == GameFormat.CashGame) { for (; !lines[curLine].StartsWith("Total pot") || lines[curLine].Contains(":") || !lines[curLine].Contains("| Rake "); curLine++) { } int rakeStart = lines[curLine].LastIndexOf("| Rake ") + "| Rake ".Length; string rakeText = lines[curLine].Substring(rakeStart).Replace(currencySymbol + "", ""); hand.Rake = Decimal.Parse(rakeText.Trim()); } #endregion #if DEBUG Console.WriteLine("Shown Hands"); #endif #region Get the shown down hands for (; curLine < lines.Count; curLine++) { Match m = shownHandsExp.Match(lines[curLine]); if (m.Success) { GroupCollection gc = m.Groups; List <Card> shownCards = new List <Card>(); shownCards.Add(new Card(gc[5].Value)); shownCards.Add(new Card(gc[6].Value)); if (hand.Context.PokerVariant != PokerVariant.TexasHoldEm) { shownCards.Add(new Card(gc[8].Value)); shownCards.Add(new Card(gc[9].Value)); } string player = gc[2].Value; HandResult hr = null; foreach (HandResult curResult in results) { if (curResult.Player == player) { hr = curResult; break; } } if (hr == null) { hr = new HandResult(player); results.Add(hr); } hr.HoleCards = shownCards.ToArray(); } } #endregion #region Set the results hand.Results = results.ToArray(); #endregion #if DEBUG Console.WriteLine("Done"); #endif return(hand); }
public Window(Blind blind) { this.blind = blind; }
private void expandContext(Context con) { viaCon = con; textBox.Text = ""; textBox.Text = Util.TypeContextToString(con.Type) + "\n"; textBox.Text += "Имя : " + con.Name + "\n"; textBox.Text += "Описание: " + con.Description + "\n"; if (con.Type == Util.TypeContext.Root) { textBox.Text += "Шаг сервера " + Server.stepserver.ToString() + " ms.\n"; textBox.Text += "Отладчик " + (Util.debug?"включен":"выключен") + "\n"; if (Server.mainloop == null) { textBox.Text += "Основной процесс не создан\n"; return; } if (Server.threadml == null) { textBox.Text += "Поток основного процесса не создан\n"; return; } textBox.Text += Server.threadml.IsAlive ? "Поток в работе " : "Поток остановлен"; return; } if (con.defContext == null) { return; } if (con.Type == Util.TypeContext.Blinds) { Blind conbl = (Blind)con.defContext; if (conbl.OnTimer) { textBox.Text += "Запуск по времени. Интервал запуска " + conbl.StepTime.ToString() + " (ms)\n"; } textBox.Text += "Вход:\n"; for (int i = 0; i < conbl.listParamIn.Count; i++) { Context convar = Server.getContext(conbl.listParamIn[i]); textBox.Text += "Номер " + i.ToString() + " " + convar.Name + " " + convar.Description + "\n"; expandVariable(convar); } textBox.Text += "\nВыход:\n"; for (int i = 0; i < conbl.listParamOut.Count; i++) { Context convar = Server.getContext(conbl.listParamOut[i]); textBox.Text += "Номер " + i.ToString() + " " + convar.Name + " " + convar.Description + "\n"; expandVariable(convar); } return; } if (con.Type == Util.TypeContext.Variables) { expandVariable(con); } if (con.Type == Util.TypeContext.Devices) { Device dev = (Device)con.defContext; textBox.Text += dev.StatusDevice(); } }
public void AddBlind(Blind blind) { Connection.Insert<Blind>(blind); }
//Note that lines is only passed for efficiency, it could be obtained //by just splitting handText private PokerHand parseHand(List <string> lines, string handText) { PokerHand hand = new PokerHand(); #region setup variables int start; int end; int curLine; List <Round> rounds = new List <Round>(); #endregion #region Make sure it's a Full Tilt hand if (!handText.StartsWith("Full Tilt Poker")) { throw new InvalidHandFormatException(handText); } #endregion #region Skip partial hands if (lines[0].EndsWith("(partial)")) { return(null); } #endregion hand.Context.Online = true; hand.Context.Site = "Full Tilt Poker"; #if DEBUG Console.WriteLine("Hand Number"); #endif #region Get the hand number start = handText.IndexOf('#') + 1; end = handText.IndexOf(':'); hand.Context.ID = handText.Substring(start, end - start); //Console.WriteLine("ID: {0}", hand.Context.ID); if (printed < 2) { Console.WriteLine("Hand Text: {0}", handText); printed++; } #endregion #if DEBUG Console.WriteLine("Table Name"); #endif #region Get the table name start = end + 2; end = handText.IndexOf('-', start); hand.Context.Table = handText.Substring(start, end - start - 1); #endregion #if DEBUG Console.WriteLine("Blinds"); #endif #region Get the blinds and game format start = end + 2; end = handText.IndexOf('-', start); string blindsAndAntes = handText.Substring(start, end - start); int blindSeparator = blindsAndAntes.IndexOf('/'); string smallBlindText = blindsAndAntes.Substring(0, blindSeparator); if (smallBlindText[0] == '$') { smallBlindText = smallBlindText.Substring(1); } hand.Context.SmallBlind = Decimal.Parse(smallBlindText.Trim()); int bigBlindStart = blindSeparator + 1; int bigBlindEnd = blindsAndAntes.IndexOf(' ', bigBlindStart); string bigBlindText = blindsAndAntes.Substring(bigBlindStart, bigBlindEnd - bigBlindStart); if (bigBlindText[0] == '$') { bigBlindText = bigBlindText.Substring(1); } hand.Context.BigBlind = Decimal.Parse(bigBlindText.Trim()); int anteIndex = blindsAndAntes.IndexOf("Ante"); if (anteIndex != -1) { int anteStart = anteIndex + 5; string anteText = blindsAndAntes.Substring(anteStart); if (anteText[0] == '$') { anteText = anteText.Substring(1); } hand.Context.Ante = Decimal.Parse(anteText.Trim()); } #endregion #if DEBUG Console.WriteLine("Game Format"); #endif #region Get the game format if (hand.Context.Table.Contains("Sit & Go")) { hand.Context.Format = GameFormat.SitNGo; } else if (blindsAndAntes.Contains("$")) { hand.Context.Format = GameFormat.CashGame; } else { hand.Context.Format = GameFormat.MultiTableTournament; } #endregion #if DEBUG Console.WriteLine("Poker Variant and Betting Type"); #endif #region Get the betting type and poker variant start = end + 2; end = handText.IndexOf('-', start); string typeAndVariant = handText.Substring(start, end - start); int capIndex = typeAndVariant.IndexOf(" Cap "); if (capIndex != -1) { string capAmountText = handText.Substring(start, capIndex - start); hand.Context.CapAmount = Decimal.Parse(capAmountText.Trim().Replace("$", "")); hand.Context.CapAmountSpecified = true; hand.Context.Capped = true; } else { hand.Context.CapAmountSpecified = false; hand.Context.Capped = false; } if (typeAndVariant.Contains("Pot Limit")) { hand.Context.BettingType = BettingType.PotLimit; } else if (typeAndVariant.Contains("No Limit")) { hand.Context.BettingType = BettingType.NoLimit; } else { hand.Context.BettingType = BettingType.FixedLimit; } if (typeAndVariant.Contains("Hold'em")) { hand.Context.PokerVariant = PokerVariant.TexasHoldEm; } else if (typeAndVariant.Contains("Omaha Hi")) { hand.Context.PokerVariant = PokerVariant.OmahaHi; } else { hand.Context.PokerVariant = PokerVariant.OmahaHiLo; } #endregion #if DEBUG Console.WriteLine("Time Stamp"); #endif #region Get the date and time start = end + 2; end = handText.IndexOf(' ', start); string timeText = handText.Substring(start, end - start); string[] timeTokens = timeText.Split(':'); int hour = Int32.Parse(timeTokens[0]); int minute = Int32.Parse(timeTokens[1]); int second = Int32.Parse(timeTokens[2]); start = handText.IndexOf('-', end) + 2; string dateText = lines[0].Substring(start); string[] dateTokens = dateText.Split('/'); int year = Int32.Parse(dateTokens[0]); int month = Int32.Parse(dateTokens[1]); int day = Int32.Parse(dateTokens[2]); hand.Context.TimeStamp = new DateTime(year, month, day, hour, minute, second); #endregion #if DEBUG Console.WriteLine("Players"); #endif #region Create the players List <Player> players = new List <Player>(); curLine = 1; for (Match m = stacksExp.Match(lines[curLine]); m.Success; m = stacksExp.Match(lines[curLine])) { if (m.Success) { GroupCollection gc = m.Groups; Player p = new Player(); p.Seat = Int32.Parse(gc[1].Value); p.Name = gc[2].Value; p.Stack = Decimal.Parse(gc[3].Value); players.Add(p); curLine++; } } hand.Players = players.ToArray(); #endregion #if DEBUG Console.WriteLine("Blinds and Antes Posted"); #endif #region Get the blinds and antes posted List <Blind> blinds = new List <Blind>(); for (; !lines[curLine].StartsWith("The button is in seat #"); curLine++) { for (Match m = actionExp.Match(lines[curLine]); m.Success; m = m.NextMatch()) { GroupCollection gc = m.Groups; Blind blind = new Blind(); blind.Player = gc[1].Value; if (gc[2].Value == "antes") { blind.Type = BlindType.Ante; } else if (gc[6].Value == "small") { blind.Type = gc[5].Value.Trim() == "dead" ? BlindType.DeadBlind : BlindType.SmallBlind; } else if (gc[6].Value == "big") { blind.Type = gc[5].Value.Trim() == "dead" ? BlindType.DeadBlind : BlindType.BigBlind; } else if (gc[2].Value == "posts") { blind.Type = BlindType.LateBlind; } else { throw new Exception("Unknown blind type: " + lines[curLine]); } if (lines[curLine].Contains("dead")) { for (int i = 0; i < gc.Count; i++) { Console.WriteLine("{0}: \"{1}\"", i, gc[i].Value); } Console.WriteLine("Found as {0}", blind.Type.ToString()); } blind.Amount = Decimal.Parse(gc[7].Value); blind.AllIn = gc[9].Value.Length == 15; blinds.Add(blind); } } hand.Blinds = blinds.ToArray(); #endregion #if DEBUG Console.WriteLine("Button"); #endif #region Get the button string buttonText = lines[curLine].Substring(lines[curLine].IndexOf('#') + 1); hand.Context.Button = Int32.Parse(buttonText); curLine++; #endregion #if DEBUG Console.WriteLine("Hole Cards and Hero"); #endif #region Get the hole cards and the name of the hero while (!lines[curLine].StartsWith("Dealt to ")) { curLine++; } start = "Dealt to ".Length; end = lines[curLine].IndexOf(" [", start); hand.Hero = lines[curLine].Substring(start, end - start); start = end + 2; List <Card> holecards = new List <Card>(); holecards.Add(new Card(lines[curLine].Substring(start, 2))); holecards.Add(new Card(lines[curLine].Substring(start + 3, 2))); if (hand.Context.PokerVariant != PokerVariant.TexasHoldEm) { holecards.Add(new Card(lines[curLine].Substring(start + 6, 2))); holecards.Add(new Card(lines[curLine].Substring(start + 9, 2))); } hand.HoleCards = holecards.ToArray(); curLine++; #endregion #if DEBUG Console.WriteLine("Preflop Actions"); #endif #region Preflop Actions rounds.Add(new Round()); rounds[0].Actions = getRoundActions(lines, ref curLine); #endregion #if DEBUG Console.WriteLine("Flop Actions"); #endif #region Flop Actions and Community Cards if (lines[curLine].StartsWith("*** FLOP ***")) { rounds.Add(new Round()); start = lines[curLine].IndexOf('[') + 1; Card[] flop = new Card[3]; flop[0] = new Card(lines[curLine].Substring(start, 2)); flop[1] = new Card(lines[curLine].Substring(start + 3, 2)); flop[2] = new Card(lines[curLine].Substring(start + 6, 2)); rounds[1].CommunityCards = flop; curLine++; rounds[1].Actions = getRoundActions(lines, ref curLine); } #endregion #if DEBUG Console.WriteLine("Turn Actions"); #endif #region Turn Actions and Community Card if (lines[curLine].StartsWith("*** TURN ***")) { rounds.Add(new Round()); start = lines[curLine].LastIndexOf('[') + 1; Card[] turn = new Card[1]; turn[0] = new Card(lines[curLine].Substring(start, 2)); rounds[2].CommunityCards = turn; curLine++; rounds[2].Actions = getRoundActions(lines, ref curLine); } #endregion #if DEBUG Console.WriteLine("River Actions"); #endif #region River Actions and Community Card if (lines[curLine].StartsWith("*** RIVER ***")) { rounds.Add(new Round()); start = lines[curLine].LastIndexOf('[') + 1; Card[] river = new Card[1]; river[0] = new Card(lines[curLine].Substring(start, 2)); rounds[3].CommunityCards = river; curLine++; rounds[3].Actions = getRoundActions(lines, ref curLine); } #endregion #region Set rounds hand.Rounds = rounds.ToArray(); #endregion #if DEBUG Console.WriteLine("Results"); #endif #region Get pots won List <HandResult> results = new List <HandResult>(); List <List <Pot> > pots = new List <List <Pot> >(); for (; !lines[curLine].StartsWith("*** SUMMARY"); curLine++) { Match m = potsExp.Match(lines[curLine]); if (m.Success) { GroupCollection gc = m.Groups; Pot p = new Pot(); p.Amount = Decimal.Parse(gc[8].Value); if (gc[7].Value.Length > 0) { p.Number = Int32.Parse(gc[7].Value); } else if ((gc[5].Value.Length == 0 && gc[3].Value == "the pot") || gc[5].Value == "main ") { p.Number = 0; } else if (gc[5].Length > 0) { p.Number = 1; } HandResult result = null; List <Pot> potList = null; for (int i = 0; i < results.Count; i++) { if (results[i].Player == gc[1].Value) { result = results[i]; potList = pots[i]; break; } } if (result == null) { result = new HandResult(gc[1].Value); potList = new List <Pot>(); results.Add(result); pots.Add(potList); } potList.Add(p); } } //add the pots to the model for (int i = 0; i < results.Count; i++) { results[i].WonPots = pots[i].ToArray(); } //get the rake, if any if (hand.Context.Format == GameFormat.CashGame) { for (; !lines[curLine].StartsWith("Total pot") || lines[curLine].Contains(":") || !lines[curLine].Contains("| Rake "); curLine++) { } int rakeStart = lines[curLine].LastIndexOf("| Rake ") + "| Rake ".Length; string rakeText = lines[curLine].Substring(rakeStart).Replace("$", ""); hand.Rake = Decimal.Parse(rakeText); } #endregion #if DEBUG Console.WriteLine("Shown Hands"); #endif #region Get the shown down hands for (; curLine < lines.Count; curLine++) { Match m = shownHandsExp.Match(lines[curLine]); if (m.Success) { GroupCollection gc = m.Groups; List <Card> shownCards = new List <Card>(); shownCards.Add(new Card(gc[5].Value)); shownCards.Add(new Card(gc[6].Value)); if (hand.Context.PokerVariant != PokerVariant.TexasHoldEm) { shownCards.Add(new Card(gc[8].Value)); shownCards.Add(new Card(gc[9].Value)); } string player = gc[2].Value; HandResult hr = null; foreach (HandResult curResult in results) { if (curResult.Player == player) { hr = curResult; break; } } if (hr == null) { hr = new HandResult(player); results.Add(hr); } hr.HoleCards = shownCards.ToArray(); } } #endregion #region Set the results hand.Results = results.ToArray(); #endregion #if DEBUG Console.WriteLine("Done"); #endif return(hand); }
private void HandleCurrentEvents() { foreach (BaseEvent baseEvent in currentTick.Events) { switch (baseEvent.Type) { case EventType.MatchStarted: MatchStarted?.Invoke(this, baseEvent); break; case EventType.RoundAnnounceMatchStarted: break; case EventType.RoundStart: RoundStart?.Invoke(this, (RoundStartEvent)baseEvent); break; case EventType.RoundEnd: RoundEnd?.Invoke(this, (RoundEndEvent)baseEvent); break; case EventType.WinPanelMatch: WinPanelMatch?.Invoke(this, baseEvent); break; case EventType.RoundFinal: break; case EventType.LastRoundHalf: break; case EventType.RoundOfficiallyEnd: RoundOfficiallyEnd?.Invoke(this, baseEvent); break; case EventType.RoundMVP: RoundMVP?.Invoke(this, (RoundMVPEvent)baseEvent); break; case EventType.FreezetimeEnded: FreezetimeEnded?.Invoke(this, baseEvent); break; case EventType.PlayerKilled: PlayerKilled?.Invoke(this, (PlayerKilledEvent)baseEvent); break; case EventType.PlayerTeam: PlayerTeam?.Invoke(this, (PlayerTeamEvent)baseEvent); break; case EventType.WeaponFired: WeaponFired?.Invoke(this, (WeaponFiredEvent)baseEvent); break; case EventType.SmokeNadeStarted: SmokeNadeStarted?.Invoke(this, (SmokeNadeStartedEvent)baseEvent); break; case EventType.SmokeNadeEnded: SmokeNadeEnded?.Invoke(this, (SmokeNadeEndedEvent)baseEvent); break; case EventType.DecoyNadeStarted: DecoyNadeStarted?.Invoke(this, (DecoyNadeStartedEvent)baseEvent); break; case EventType.DecoyNadeEnded: DecoyNadeEnded?.Invoke(this, (DecoyNadeEndedEvent)baseEvent); break; case EventType.FireNadeStarted: FireNadeStarted?.Invoke(this, (FireNadeStartedEvent)baseEvent); break; case EventType.FireNadeWithOwnerStarted: FireNadeWithOwnerStarted?.Invoke(this, (FireNadeWithOwnerStartedEvent)baseEvent); break; case EventType.FireNadeEnded: FireNadeEnded?.Invoke(this, (FireNadeEndedEvent)baseEvent); break; case EventType.FlashNadeExploded: FlashNadeExploded?.Invoke(this, (FlashNadeExplodedEvent)baseEvent); break; case EventType.ExplosiveNadeExploded: ExplosiveNadeExploded?.Invoke(this, (ExplosiveNadeExplodedEvent)baseEvent); break; case EventType.NadeReachedTarget: NadeReachedTarget?.Invoke(this, (NadeReachedTargetEvent)baseEvent); break; case EventType.BombBeginPlant: BombBeginPlant?.Invoke(this, (BombBeginPlantEvent)baseEvent); break; case EventType.BombAbortPlant: BombAbortPlant?.Invoke(this, (BombAbortPlantEvent)baseEvent); break; case EventType.BombPlanted: BombPlanted?.Invoke(this, (BombPlantedEvent)baseEvent); break; case EventType.BombDefused: BombDefused?.Invoke(this, (BombDefusedEvent)baseEvent); break; case EventType.BombExploded: BombExploded?.Invoke(this, (BombExplodedEvent)baseEvent); break; case EventType.BombBeginDefuse: BombBeginDefuse?.Invoke(this, (BombBeginDefuseEvent)baseEvent); break; case EventType.BombAbortDefuse: BombAbortDefuse?.Invoke(this, (BombAbortDefuseEvent)baseEvent); break; case EventType.PlayerHurt: PlayerHurt?.Invoke(this, (PlayerHurtEvent)baseEvent); break; case EventType.Blind: Blind?.Invoke(this, (BlindEvent)baseEvent); break; case EventType.PlayerBind: PlayerBind?.Invoke(this, (PlayerBindEvent)baseEvent); break; case EventType.PlayerDisconnect: PlayerDisconnect?.Invoke(this, (PlayerDisconnectEvent)baseEvent); break; case EventType.SayText: SayText?.Invoke(this, (SayTextEvent)baseEvent); break; case EventType.SayText2: SayText2?.Invoke(this, (SayText2Event)baseEvent); break; case EventType.PlayerJump: PlayerJump?.Invoke(this, (PlayerJumpEvent)baseEvent); break; case EventType.PlayerFootstep: PlayerFootstep?.Invoke(this, (PlayerFootstepEvent)baseEvent); break; case EventType.OtherDeath: OtherDeath?.Invoke(this, (OtherDeathEvent)baseEvent); break; case EventType.EntitySpawned: EntitySpawned?.Invoke(this, (EntitySpawnedEvent)baseEvent); break; case EventType.EntityRemoved: EntityRemoved?.Invoke(this, (EntityRemovedEvent)baseEvent); break; default: break; } } }
public void DeleteBlind(Blind blind) { Connection.Delete<Blind>(blind); }
public void TestMethod1() { var _blindOfficeGarage = new Blind("RolloArbeitszimmerGarage", 25); _blindOfficeGarage.MoveHalf(); }
private void calcBlindPayment(Blind blind, ref TableData result, string[] hh, ref int line, bool isSkip) { Regex regex = new Regex("(.+)" + Regex.Escape(" posts the ") + blind + Regex.Escape(" blind of ") + "([0-9,]+)"); MatchCollection matchCol = regex.Matches(hh[++line]); if (matchCol.Count > 0) { if (isSkip == false) { for (int j = 0; j < maxSeatNum; ++j) { if (matchCol[0].Groups[1].Value.Equals(result.playerNames[j])) { int value = System.Convert.ToInt32(matchCol[0].Groups[2].Value.Replace(",", string.Empty)); result.posted[j] = value; result.chips[j] -= value; result.pot += value; } } } } else { line -= 1; } }