private void frmTests_Load(object sender, EventArgs e) { _deck = new Deck(2, false); _hand = new CardSet(); RefreshPanel(pnlCards, _deck); RefreshPanel(pnlHand, _hand); }
public ReplaceResult(IEnumerable<Card> replaced, IEnumerable<Card> notFound) { replaced.ThrowIfNullOrContainsNulls(nameof(replaced)); notFound.ThrowIfNullOrContainsNulls(nameof(notFound)); Replaced = new CardSet(replaced); NotFound = new CardSet(notFound); }
/// <summary> /// Main method counts the total score /// </summary> /// <param name="hand">The set of cards for which the score is calculated</param> /// <returns>Total score in the cardset</returns> public byte CountScore(CardSet hand) { byte score = 0; byte aces = 0; for (int i = 0; i < hand.GetCardsNumber(); i++) { byte rank = hand[i].Rank; if (rank > 10) { if (rank == 14) { rank = 11; aces++; } else { rank = 10; } } score += rank; } while (score > 21 && aces > 0) { score -= 10; aces--; } return score; }
public static List<int> CalculatePoints(CardSet hand) { List<int> results = new List<int>(); for (int i = 0; i <= CountAces(hand); i++) results.Add(CalculateAcesValues(i, hand)); return results; }
private void frmGame_Load(object sender, EventArgs e) { _deck = new Deck(1, false); _player1 = new CardSet(); _player2 = new CardSet(); Start(); }
/// <summary> /// Check card values to determine if they are right (i.e. are into allowed range for each property) /// </summary> /// <param name="_type">Card type as enum</param> /// <param name="_class">Card class as enum</param> /// <param name="_set">Card set as enum</param> /// <param name="_race">Card race as enum</param> /// <param name="_quality">Card quality as enum</param> /// <returns></returns> public static CardError checkCard(CardType _type, CardClass _class, CardSet _set, CardRace _race, CardQuality _quality, string _name) { if ((_type < CardType.Minion) || (_type > CardType.Weapon)) { return CardError.BadType; } // Wrong card class? if ((_class < CardClass.Neutral) || (_class > CardClass.Druid)) { return CardError.BadClass; } // Wrong card set? if ((_set < CardSet.Basic) || (_set > CardSet.WhispersOfTheOldGods)) { return CardError.BadSet; } // Wrong minion race? if ((_type == CardType.Minion) && ((_race < CardRace.None) || (_race > CardRace.Pirate))) { return CardError.BadRace; } // Wrong card quality? if ((_quality < CardQuality.Free) || (_quality > CardQuality.Legendary)) { return CardError.BadQuality; } // Wrong (empty) name? if (_name.Length == 0) { return CardError.BadName; } return CardError.None; }
public DiscardResult(IEnumerable<Card> cards, IEnumerable<Card> notFound) { cards.ThrowIfNullOrContainsNulls(nameof(cards)); notFound.ThrowIfNullOrContainsNulls(nameof(notFound)); Discarded = new CardSet(cards); NotFound = new CardSet(notFound); }
public Card( int id, CardSet cardSet, string name, int cost, int potionCost, CardType cardType, int additionalActions = 0, int additionalBuys = 0, int additionalCards = 0, int additionalCoin = 0, string actionText = null) { this.Id = id; this.Set = cardSet; this.Name = name; this.Cost = cost; this.PotionCost = potionCost; this.Type = cardType; this.ActionText = actionText; AdditionalActions = additionalActions; AdditionalBuys = additionalBuys; AdditinalCards = additionalCards; AdditionalCoin = additionalCoin; }
public bool CreateCardSet(CardSet cardSet) { if (cardSet.IsValid()) { } }
public SplitResult(CardSet top, CardSet bottom) { top.ThrowIfNull(nameof(top)); bottom.ThrowIfNull(nameof(bottom)); Top = top; Bottom = bottom; }
protected CharacterCardBase(CardType printedCardType, string title, CardSet cardSet, uint cardNumber, Sphere printedSphere, byte printedWillpower, byte printedAttack, byte printedDefense, byte printedHitPoints) : base(printedCardType, title, cardSet, cardNumber, printedSphere) { this.PrintedWillpower = printedWillpower; this.PrintedAttack = printedAttack; this.PrintedDefense = printedDefense; this.PrintedHitPoints = printedHitPoints; }
protected AllyObjectiveCardBase(string title, CardSet cardSet, uint cardNumber, EncounterSet encounterSet, byte quantity, byte victoryPoints, byte printedWillpower, byte printedAttack, byte printedDefense, byte printedHitPoints) : base(title, cardSet, cardNumber, encounterSet, quantity, victoryPoints) { this.PrintedWillpower = printedWillpower; this.PrintedAttack = printedAttack; this.PrintedDefense = printedDefense; this.PrintedHitPoints = printedHitPoints; }
public static bool ValidHand(CardSet hand) { if (CalculateBestPoints(hand) > 21) { return false; } return true; }
public void SaveDeckFileForNewSet(CardSet cardSet) { AutoItX.MouseClick(Tab); AutoItX.Sleep(2000); AutoItX.MouseClick(NewButton); AutoItX.Sleep(1000); AutoItX.MouseClick(NoSaveButton); while (AutoItX.PixelGetColor(alternateCardPosition) == waitingColor) { AutoItX.Sleep(500); } AutoItX.Sleep(2000); Selector.PickFilterOption(this._currentSet, (int) cardSet, SetSelector); AutoItX.Sleep(1000); AutoItX.MouseClick(BlankPosition); AutoItX.Sleep(1000); AutoItX.MouseClick("right", CardPool_ContextMenu.X, CardPool_ContextMenu.Y); AutoItX.Sleep(1000); AutoItX.MouseClick(CardPool_SelectAll); AutoItX.Sleep(1000); AutoItX.MouseClick("right", CardPool_ContextMenu.X, CardPool_ContextMenu.Y); AutoItX.Sleep(1000); AutoItX.MouseClick(CardPool_AddOneCard); while (AutoItX.PixelGetColor(blankCardPosition) == blankColor) { AutoItX.Sleep(500); } AutoItX.MouseClick("right", Deck_ContextMenu.X, Deck_ContextMenu.Y); AutoItX.Sleep(1000); AutoItX.MouseClick(Deck_SortByName); while (AutoItX.PixelGetColor(blankCardPosition) != blankColor) { AutoItX.Sleep(500); } AutoItX.Sleep(1000); AutoItX.MouseClick(SaveAsButton); AutoItX.Sleep(1000); AutoItX.MouseClick(WishListDeck); AutoItX.Sleep(1000); AutoItX.MouseClick(SaveButton); AutoItX.Sleep(1000); AutoItX.MouseClick(SaveOverwrite); while (AutoItX.PixelGetColor(alternateCardPosition) == waitingColor) { AutoItX.Sleep(500); } }
public static int CountAces(CardSet hand) { int countAces = 0; foreach (Card c in hand) if (Rules.ValueOf(c) == 11 && !c.IsClosed) countAces++; return countAces; }
protected CardBase(string title, CardType type, CardSet set) { if (title == null) throw new ArgumentNullException("title"); this.title = title; this.type = type; this.set = set; }
protected EnemyCardBase(string title, CardSet cardSet, uint cardNumber, EncounterSet encounterSet, byte quantity, byte printedThreat, byte engagementCost, byte printedAttack, byte printedDefense, byte printedHitPoints, byte victoryPoints) : base(CardType.Enemy, title, cardSet, cardNumber, encounterSet, quantity, printedThreat) { this.EngagementCost = engagementCost; this.PrintedAttack = printedAttack; this.PrintedDefense = printedDefense; this.PrintedHitPoints = printedHitPoints; this.VictoryPoints = victoryPoints; }
public void RpcPreSetCard(int id, CardTypes type, float cardreachseconds) { OwnerSet = Player.Players[id].PlayerSet; SetCard(type, cardreachseconds); if (isServer) { RpcServeCard(); } OwnerSet.PushCard(this, false, true); }
double CalculateAverageHVO(int[] board) { CardSet boardCs = StdDeck.Descriptor.GetCardSet(board); CalculateAverageHsParam param = new CalculateAverageHsParam(); int toDealCount = 7 - board.Length; CardEnum.Combin(StdDeck.Descriptor, toDealCount, boardCs, CardSet.Empty, OnPocket, param); Assert.AreEqual(EnumAlgos.CountCombin(52 - board.Length, toDealCount), param.Count); return(param.Sum / param.Count); }
private RandomCardTask(EntityType type, CardType cardType, CardClass cardClass, CardSet cardSet, Race race, List <GameTag> gameTagFilter, bool opposite) { Type = type; CardType = cardType; CardClass = cardClass; CardSet = cardSet; Race = race; GameTagFilter = gameTagFilter; Opposite = opposite; }
public static List <int> CalculatePoints(CardSet hand) { List <int> results = new List <int>(); for (int i = 0; i <= CountAces(hand); i++) { results.Add(CalculateAcesValues(i, hand)); } return(results); }
public Card(CardDesc desc) { this.setName(desc.name); this.setID(desc.id); this.setDescription(desc.description); this.type = desc.type; this.rarity = desc.rarity; this.collectible = desc.collectible; this.cardSet = desc.set; }
/// <summary> /// Returns an array containing enumerated combinations. /// </summary> public static CardSet[] Combin(DeckDescriptor deckDescr, int count, CardSet sharedCards, CardSet deadCards) { CardSet unused = deadCards | sharedCards; int combCount = (int)EnumAlgos.CountCombin(deckDescr.Size - unused.CountCards(), count); CombinArrayParams p = new CombinArrayParams(); p.arr = new CardSet[combCount]; Combin(deckDescr, count, sharedCards, deadCards, OnCombinArray, p); return(p.arr); }
public double GetProbability(CardSet hand) { int counter = 0; if (HandCounters.TryGetValue(hand, out counter)) { return(((double)counter) / TotalCounter); } return(0); }
private RandomCardTask(EntityType type, CardType cardType, CardClass cardClass, CardSet cardSet, Race race, GameTag[] gameTagFilter, bool opposite) { _type = type; _cardType = cardType; _cardClass = cardClass; _cardSet = cardSet; _race = race; _gameTagFilter = gameTagFilter; _opposite = opposite; }
/// <summary> /// Choose a random card that fits the criterias. /// </summary> /// <param name="cardType">CardType filter</param> /// <param name="cardClass">Cardclass filter</param> /// <param name="gameTagFilter">GameTags that must be contained in the card</param> /// <param name="opposite">If the card is for the opponent</param> public RandomCardTask(CardType cardType, CardClass cardClass, Race race = Race.INVALID, GameTag[] gameTagFilter = null, bool opposite = false) { _type = EntityType.INVALID; _cardType = cardType; _cardClass = cardClass; _cardSet = CardSet.INVALID; _race = race; _gameTagFilter = gameTagFilter; _opposite = opposite; }
public void Init(CardSet deck) { _deckOrigin = deck; _deck = deck.Clone(); _hand.Clear(); _grave.Clear(); _grave.Capacity = 1000; _deck.Random(); }
public void Insert(CardSet cardSet) { using (var connection = new SqlConnection(ConfigurationSettings.GetConnectionString())) { DynamicParameters p = new DynamicParameters(); p.Add("@CardSetName", cardSet.CardSetName); connection.Execute("CardSetInsert", p, commandType: CommandType.StoredProcedure); } }
public bool IsStraight(CardSet cards) { int r = 0; foreach (var card in cards.Cards) { r = cards.Cards.Count(c => c.Figure == c.Figure + 1); } return(r == 5); }
public ActionPhase(ITurnScope turnScope, CardSet availableActions) : base(turnScope) { Description = String.Format("{0}, select an action to play", turnScope.Player.Name); AvailableActions = new CardSet(availableActions.OrderByDescending(a => a.BaseCost).ToList()); AvailableActions.ToList().ForEach(actionCard => _availableResponses.Add(new PlayActionResponse(turnScope, actionCard))); if (_availableResponses.Any()) { _availableResponses.Add(new SkipActionPhaseResponse(turnScope)); } }
public static Deck GetDefaultDeck(CardClass cardClass, CardSet set) { var decks = GetClassDecks(set); if (decks == null || !decks.TryGetValue(cardClass, out var cards)) { return(null); } return(new Deck(DeckType.DungeonRun, "Dungeon Run", cardClass, cards)); }
void UpdateCards(List <CardState> cards, CardSet set) { set.Clear(); for (var i = 0; i < cards.Count; i++) { var card = cards[i]; var cardView = CreateCardView(card); set.Add(cardView); } }
public void updateSet(CardSet set) { using (var db = new Db()) { if (set.CardSetId != 0) { db.Entry(set).State = EntityState.Modified; db.SaveChanges(); } } }
/// <summary> /// Choose a random card that fits the criterias. /// </summary> /// <param name="type">EntityType to choose the random card from.</param> /// <param name="opposite">If the card is for the opponent</param> public RandomCardTask(EntityType type, bool opposite = false) { _type = type; _cardType = CardType.INVALID; _cardSet = CardSet.INVALID; _cardClass = CardClass.INVALID; _race = Race.INVALID; _gameTagFilter = null; _opposite = opposite; }
public static Deck GetDefaultDeck(string playerClass, CardSet set, string shrineCardId = null) { var cards = GetCards(playerClass, set, shrineCardId); if (cards == null) { return(null); } return(GetDeck(playerClass, set, cards.Select(Database.GetCardFromId))); }
public void Test_Showdown() { int seed = (int)DateTime.Now.Ticks; Console.WriteLine("RNG seed {0}", seed); SequenceRng dealer = new SequenceRng(seed, StdDeck.Descriptor.FullDeckIndexes); HoldemGameRules gr = new HoldemGameRules(); int[][] hands = new int[2][]; UInt32[] ranks = new UInt32[2]; for (int p = 0; p < 2; ++p) { hands[p] = new int[7]; } int repCount = 1000000; for (int r = 0; r < repCount; ++r) { dealer.Shuffle(2 + 2 + 5); hands[0][0] = dealer.Sequence[0]; hands[0][1] = dealer.Sequence[1]; hands[1][0] = dealer.Sequence[2]; hands[1][1] = dealer.Sequence[3]; for (int i = 0; i < 5; ++i) { hands[0][2 + i] = hands[1][2 + i] = dealer.Sequence[4 + i]; } gr.Showdown(_gd, hands, ranks); int actResult = -1; if (ranks[0] > ranks[1]) { actResult = 1; } else if (ranks[0] == ranks[1]) { actResult = 0; } CardSet h0 = _gd.DeckDescr.GetCardSet(hands[0]); CardSet h1 = _gd.DeckDescr.GetCardSet(hands[1]); UInt32 v0 = CardSetEvaluator.Evaluate(ref h0); UInt32 v1 = CardSetEvaluator.Evaluate(ref h1); int expResult = -1; if (v0 > v1) { expResult = 1; } else if (v0 == v1) { expResult = 0; } Assert.AreEqual(expResult, actResult); } }
public CardSetScore Score(CardSet set) { int maxCardValue = set.Cards .Select(card => (int)card.Value) .DefaultIfEmpty(-1) .Max(); return(maxCardValue == -1 ? new CardSetScore(Name) : new CardSetScore(Name, 0)); }
public KeyT(int handSize, int maxHandSize, CardSet cards) { HandSize = (byte)handSize; RankCards = NormRank.Convert(cards); FlushCards = ExtractFlush(cards, maxHandSize); if (handSize < 5) { return; } HandValue = CardSetEvaluator.Evaluate(ref cards); }
public OpeningPackStatsWindowViewModel(TrackerFactory trackerFactory) : base(trackerFactory) { cardImageService = trackerFactory.GetService <ICardImageService>(); winDialogs = trackerFactory.GetService <IWinDialogs>(); cardsDatabase = trackerFactory.GetService <ICardsDatabase>(); CommandExportToCsv = new RealyAsyncCommand <object>(CommandExportToCsvExecute); CommandOpenCsv = new RealyAsyncCommand <object>(CommandOpenCsvExcute); packSetFilter = AllFilter; }
protected CardBase(string title, CardType type, CardSet set) { if (title == null) { throw new ArgumentNullException("title"); } this.title = title; this.type = type; this.set = set; }
protected IEnumerable <Card> FlattenCardSet(CardSet cs) { foreach (FactionSet fs in cs.factionSets) { foreach (Card c in fs.cards) { c.faction = fs.name; yield return(c); } } }
public CardSetScore Score(CardSet set) { var groups = GroupCardSet(set); bool fourOfAKind = groups.Select(kv => kv.Value).Any(a => a.Count > 4); if (fourOfAKind) { return(new CardSetScore(Name, 4)); } return(new CardSetScore(Name)); }
public CardSetScore Score(CardSet set) { var groups = GroupCardSet(set); bool pair = groups.Select(kv => kv.Value).Any(a => a.Count > 2); if (pair) { return(new CardSetScore(Name, 4)); } return(new CardSetScore(Name)); }
public void Test_Simple() { string handS = "As Ks Kd Kc 2c 2d 5c"; int[] handA = StdDeck.Descriptor.GetIndexes(handS); CardSet handC = StdDeck.Descriptor.GetCardSet(handS); UInt32 val1 = LutEvaluator7.Evaluate(handA); UInt32 val2 = RefEvaluator.Evaluate(handC.bits, 7); Assert.AreEqual(val2, val1); }
public void Test_Simple() { CardSet hand = new CardSet { bits = 0x7F }; UInt32 handVal1 = CardSetEvaluator.Evaluate(ref hand); UInt32 handVal2 = RefEvaluator.Evaluate(hand.bits, 7); Assert.AreEqual(handVal1, handVal2); }
private void Refresh(PictureBox picture, CardSet player, Label placar) { picture.Image = null; if (player.Count > 0) { picture.Image = player[0].Image; picture.Refresh(); } placar.Text = player.Count.ToString(); }
private void SuitIsomorphismPreflopOmaha(ref CardSet pocket) { _pocketCount++; _normPocket = _sn.Convert(pocket); if (_maxNormPreflopPocket.bits < _normPocket.bits) { _normPreflopCount++; _maxNormPreflopPocket = _normPocket; } _sn.Reset(); }
protected QuestCardBase(string title, CardSet cardSet, uint cardNumber, ScenarioCode scenarioCode, IEnumerable<EncounterSet> encounterSets, byte sequence, byte questPoints, byte victoryPoints) : base(CardType.Quest, title, cardSet, cardNumber) { if (encounterSets == null) throw new ArgumentNullException("encounterSets"); this.ScenarioCode = scenarioCode; this.EncounterSets = encounterSets; this.Sequence = sequence; this.QuestPoints = questPoints; this.VictoryPoints = victoryPoints; }
private void RefreshPanel(Panel panel, CardSet cardset) { panel.Controls.Clear(); foreach (Card card in cardset) { PictureBox cardImage = new PictureBox(); cardImage.Height = card.Image.Height; cardImage.Width = card.Image.Width; cardImage.Image = card.Image; cardImage.Tag = card; cardImage.Click += new EventHandler(cardImage_Click); panel.Controls.Add(cardImage); } }
public bool AddSet(Guid authToken, CardSet set) { using(WebClient client = new WebClient()) { System.Collections.Specialized.NameValueCollection reqparm = new System.Collections.Specialized.NameValueCollection(); if(set.Id != null){reqparm.Add("Id", set.Id);} if(set.Name != null){reqparm.Add("Name", set.Name);} if(set.Type != null){reqparm.Add("Type", set.Type);} if(set.Block != null){reqparm.Add("Block", set.Type);} if(set.Description != null){reqparm.Add("Description", set.Description);} reqparm.Add("BasicLand", set.BasicLand.ToString()); reqparm.Add("Common", set.Common.ToString()); reqparm.Add("Uncommon", set.Uncommon.ToString()); reqparm.Add("Rare", set.Rare.ToString()); reqparm.Add("MythicRare", set.MythicRare.ToString()); reqparm.Add("ReleasedAt", set.ReleasedAt); reqparm.Add("AuthToken", authToken.ToString()); string responsebody = ""; try { ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; byte[] responsebytes = client.UploadValues(string.Format("{0}/sets",_apiUrl), "Post", reqparm); responsebody = Encoding.UTF8.GetString(responsebytes); } catch(WebException e) { throw e; return false; } } return true; }
public void PickCardSet(CardSet cardSet) { // for (int i = 0; i < 5; i++) // { _logger.TraceFormat(LogMessageFormat, this._currentSelectedSet, cardSet); this._currentSelectedSet = (CardSet)PickFilterOption((int)this._currentSelectedSet, (int)cardSet, _pbv.FilterSetSelectorPosition); //var set = _pbv.TradeFilterSetText.GetOCRValue().Enumerize(); //try //{ // AutoItX.Sleep(i > 2 ? 5000 : 3000); // var cardSets = Enum.GetNames(typeof (CardSet)); // var diffSet = (from s in cardSets // let diff = Levenshtein.Compute(set, s) // where diff < 4 // select s).FirstOrDefault(); // if (diffSet != null) // { // this._currentSelectedSet = (CardSet) Enum.Parse(typeof (CardSet), diffSet); // if (this._currentSelectedSet != cardSet) // { // _logger.Info("Incorrect filter set for set trying again."); // } // else // { // break; // } // } //} //catch (Exception ex) //{ // if (set.StartsWith(CardSet.AllCards.ToString())) // { // this._currentSelectedSet = CardSet.AllCards; // break; // } // _logger.Error(ex, "Exception parsing enum value from screen"); //} // } }
public void Export(CardSet cardSet) { AutoItX.MouseClick(CollectionTab); AutoItX.Sleep(2000); this._currentSet = Selector.PickFilterOption(this._currentSet, (int)cardSet, SetSelector); AutoItX.Sleep(2000); AutoItX.MouseClick("right", ContextMenu.X, ContextMenu.Y); AutoItX.Sleep(1000); AutoItX.MouseClick(SelectAllOption); AutoItX.Sleep(1000); AutoItX.MouseClick("right", ContextMenu.X, ContextMenu.Y); AutoItX.Sleep(1000); AutoItX.MouseClick(ExportCsv); AutoItX.Sleep(1000); AutoItX.Send(cardSet.ToString()); AutoItX.Sleep(1000); AutoItX.Send("{ENTER}"); }
public static bool IsBlackJack(CardSet hand) { bool hasAce = false; bool hasTen = false; int countCards = 0; foreach (Card c in hand) { if (!c.IsClosed) { if (Rules.ValueOf(c) == 11) hasAce = true; if (Rules.ValueOf(c) == 10) hasTen = true; countCards++; } } if (hasAce && hasTen && countCards == 2) return true; else return false; }
public static int CalculateAcesValues(int acesToChange, CardSet hand) { int total = 0; foreach (Card c in hand) { if (!c.IsClosed) { int cardValue = ValueOf(c); int changedValue = 0; if (Rules.ValueOf(c) == 11 && acesToChange > 0) { changedValue = 1; acesToChange--; } else { changedValue = cardValue; } total += changedValue; } } return total; }
internal static string GetSetName(CardSet set) { switch(set) { case CardSet.CORE: return "Basic"; case CardSet.EXPERT1: return "Classic"; case CardSet.PROMO: return "Promotion"; case CardSet.FP1: return "CurseOfNaxxramas"; case CardSet.PE1: return "GoblinsVsGnomes"; case CardSet.BRM: return "BlackrockMountain"; case CardSet.TGT: return "TheGrandTournament"; case CardSet.LOE: return "LeagueOfExplorers"; default: return CultureInfo.InvariantCulture.TextInfo.ToTitleCase(set.ToString().ToLower()); } }
protected void GetPartOfTheirCollection(CardSet cardSet, RaritySet rarity ) { DoTradeChecks(); if (!InTrade || !CollectionCheck()) { return; } this.MagicOnlineInterface.PickCardSet(cardSet); AutoItX.Sleep(250); this.MagicOnlineInterface.PickRarity(rarity); if (CollectionCheck() && InTrade) { var collection = this.MagicOnlineInterface.ExamineCollection(FindXCardsFromTheirCollection, this.TheirCollection.Values.Sum(p => p.CopiesOfCard)); AddToTheirCollection(collection); } }
protected EventCardBase(string title, CardSet cardSet, uint cardNumber, Sphere printedSphere, byte resourceCost) : base(CardType.Event, title, cardSet, cardNumber, printedSphere, resourceCost) { }
protected EventBase(string title, CardSet set) : base(title, CardType.Event, set) { }
protected ScenarioBase(string title, ScenarioCode scenarioCode, CardSet cardSet) { this.Title = title; this.ScenarioCode = scenarioCode; }