public override void onCardPlay(Playfield p, bool ownplay, Minion target, int choice) { foreach (GraveYardItem gyi in p.diedMinions.ToArray()) // toArray() because a knifejuggler could kill a minion due to the summon :D { if (gyi.own == ownplay) { CardDB.Card card = CardDB.Instance.getCardDataFromID(gyi.cardid); int pos = ownplay ? p.ownMinions.Count : p.enemyMinions.Count; p.CallKid(card, p.ownMinions.Count, gyi.own); } } }
public Weapon(Weapon w) { this.name = w.name; this.card = w.card; this.numAttacksThisTurn = w.numAttacksThisTurn; this.immuneWhileAttacking = w.immuneWhileAttacking; this.Angr = w.Angr; this.Durability = w.Durability; this.windfury = w.windfury; this.immune = w.immune; this.lifesteal = w.lifesteal; this.poisonous = w.poisonous; this.cantAttackHeroes = w.cantAttackHeroes; }
public void equip(CardDB.Card c) { this.name = c.name; this.card = c; this.numAttacksThisTurn = 0; this.immuneWhileAttacking = c.immuneWhileAttacking; this.Angr = c.Attack; this.Durability = c.Durability; this.windfury = c.windfury; this.immune = false; this.lifesteal = c.lifesteal; this.poisonous = c.poisonous; this.cantAttackHeroes = (c.name == CardName.foolsbane) ? true : false; }
public int anzCardsInDeck(CardIdEnum cardid) { int ret = 2; CardDB.Card c = CardDB.Instance.getCardDataFromID(cardid); if (c.rarity == 5) { ret = 1; //you can have only one rare; } if (this.enemyCardsOut.ContainsKey(cardid)) { if (this.enemyCardsOut[cardid] == 1) { return(1); } return(0); } return(ret); }
public int getPenalityForDestroyingCombo(CardDB.Card crd, Playfield p) { if (this.combos.Count == 0) { return(0); } int pen = int.MaxValue; bool found = false; int mana = Math.Max(p.ownMaxMana, p.mana); foreach (combo c in this.combos) { if ((c.oHero == HeroEnum.None || c.oHero == p.ownHeroName) && c.isCardInCombo(crd)) { int iia = c.isInCombo(p.owncards, p.ownMaxMana);//check if we have all cards for a combo, and if the choosen card is one int iib = c.isMultiTurnComboTurn1(p.owncards, mana, p.ownMinions, p.ownWeapon.name); int iic = Math.Max(iia, iib); if (iia == 2 && iib != 2 && c.isMultiTurn1Card(crd))// it is a card of the combo, is a turn 1 card, but turn 1 is not possible -> we have to play turn 0 cards first { iic = 1; } if (iic == 1) { found = true; } if (iic == 1 && pen > c.cardspen[crd.cardIDenum]) { pen = c.cardspen[crd.cardIDenum]; //iic==1 will destroy combo } if (iic == 2) { pen = 0; //card is ok to play } } } if (found) { return(pen); } return(0); }
public void updateSecretList(Playfield p, Playfield old) { if (p.enemySecretCount == 0 || p.optionsPlayedThisTurn == 0) { return; } Action doneMove = Ai.Instance.bestmove; if (doneMove == null) { return; } List <CardIdEnum> enemySecretsOpenedStep = new List <CardIdEnum>(); List <CardDB.Card> enemyMinionsDiedStep = new List <CardDB.Card>(); foreach (KeyValuePair <CardIdEnum, int> tmp in p.enemyCardsOut) { if (!old.enemyCardsOut.ContainsKey(tmp.Key) || old.enemyCardsOut[tmp.Key] != tmp.Value) { CardDB.Card c = CardDB.Instance.getCardDataFromID(tmp.Key); if (c.Secret) { enemySecretsOpenedStep.Add(tmp.Key); } else if (c.type == CardType.Minion) { enemyMinionsDiedStep.Add(c); } } } bool beartrap = false; bool explosive = false; bool snaketrap = false; bool missdirection = false; bool freezing = false; bool snipe = false; bool darttrap = false; bool cattrick = false; bool mirrorentity = false; bool counterspell = false; bool spellbender = false; bool iceblock = false; bool icebarrier = false; bool vaporize = false; bool duplicate = false; bool effigy = false; bool eyeforaneye = false; bool noblesacrifice = false; bool redemption = false; bool repentance = false; bool avenge = false; bool sacredtrial = false; if (enemyMinionsDiedStep.Count > 0) { duplicate = true; if (old.enemyMinions.Count > 1) { avenge = true; } if (old.enemyMinions.Count < 7) { effigy = true; redemption = true; } else if (!enemyMinionsDiedStep[0].deathrattle) { redemption = true; effigy = true; } else { switch (enemyMinionsDiedStep[0].cardIDenum) { case CardIdEnum.AT_019: redemption = false; effigy = false; break; case CardIdEnum.AT_036: redemption = false; effigy = false; break; case CardIdEnum.BRMC_87: redemption = false; effigy = false; break; case CardIdEnum.EX1_110: redemption = false; effigy = false; break; case CardIdEnum.EX1_534: redemption = false; effigy = false; break; case CardIdEnum.EX1_556: redemption = false; effigy = false; break; case CardIdEnum.FP1_002: redemption = false; effigy = false; break; case CardIdEnum.FP1_007: redemption = false; effigy = false; break; case CardIdEnum.FP1_012: redemption = false; effigy = false; break; case CardIdEnum.GVG_096: redemption = false; effigy = false; break; case CardIdEnum.GVG_105: redemption = false; effigy = false; break; case CardIdEnum.GVG_114: redemption = false; effigy = false; break; case CardIdEnum.LOE_050: redemption = false; effigy = false; break; case CardIdEnum.LOE_089: redemption = false; effigy = false; break; default: redemption = true; effigy = true; break; } } } bool targetWasHero = (doneMove.target != null && doneMove.target.entitiyID == p.enemyHero.entitiyID); if (doneMove.actionType == actionEnum.attackWithHero || doneMove.actionType == actionEnum.attackWithMinion) { bool attackerIsHero = doneMove.own.isHero; if (enemySecretsOpenedStep.Count == 0) { if (old.enemyMinions.Count < 7) { noblesacrifice = true; } if (doneMove.actionType == actionEnum.attackWithMinion) { freezing = true; } if (targetWasHero) { explosive = true; if (old.enemyMinions.Count < 7) { beartrap = true; } missdirection = true; if (attackerIsHero && old.ownMinions.Count == 0 && old.enemyMinions.Count == 0) { missdirection = false; } icebarrier = true; if (!attackerIsHero) { vaporize = true; } } else { snaketrap = true; } } else { if (targetWasHero) { explosive = true; icebarrier = true; if (!attackerIsHero) { vaporize = true; //? } } else { snaketrap = true; } if (!attackerIsHero) { freezing = true; } if (old.enemyMinions.Count < 7) { noblesacrifice = true; } foreach (CardIdEnum id in enemySecretsOpenedStep) { switch (id) { case CardIdEnum.AT_060: //beartrap beartrap = true; missdirection = true; continue; case CardIdEnum.EX1_610: //explosivetrap if (enemySecretsOpenedStep.Count == 1) { missdirection = true; if (!attackerIsHero && p.ownMinions.Find(x => x.entitiyID == doneMove.own.entitiyID) == null) { missdirection = false; freezing = false; } } continue; case CardIdEnum.EX1_533: //misdirection missdirection = true; vaporize = false; if (enemySecretsOpenedStep.Contains(CardIdEnum.EX1_554)) { continue; } int hpBalance = 0; //we need to know who has become the new target foreach (Minion m in p.enemyMinions) { hpBalance += m.HealthPoints; } foreach (Minion m in old.enemyMinions) { hpBalance -= m.HealthPoints; } if (hpBalance < 0) { snaketrap = true; } continue; case CardIdEnum.EX1_611: //freezingtrap freezing = true; vaporize = false; continue; case CardIdEnum.EX1_594: //vaporize vaporize = true; freezing = false; continue; case CardIdEnum.EX1_130: //noblesacrifice noblesacrifice = true; snaketrap = true; vaporize = false; icebarrier = false; continue; } } } } else if (doneMove.actionType == actionEnum.playcard) { if (doneMove.card.card.type == CardType.SPELL) { cattrick = true; counterspell = true; if (!targetWasHero) { spellbender = true; } } /* else if (doneMove.card.card.type == CardType.MOB) //we need the response from the core * { * mirrorentity = true; * snipe = true; * repentance = true; * if (p.ownMinions.Count > 3) sacredtrial = true; * }*/ } if (p.mobsplayedThisTurn > old.mobsplayedThisTurn) //if we have a response from the core - remove { mirrorentity = true; snipe = true; repentance = true; if (p.ownMinions.Count > 3) { sacredtrial = true; } } if (p.enemyHero.HealthPoints + p.enemyHero.armor < old.enemyHero.HealthPoints + old.enemyHero.armor) { eyeforaneye = true; } if (doneMove.actionType == actionEnum.useHeroPower) { darttrap = true; } foreach (CardIdEnum id in enemySecretsOpenedStep) { switch (id) { case CardIdEnum.AT_002: effigy = true; continue; case CardIdEnum.AT_060: beartrap = true; continue; case CardIdEnum.EX1_130: noblesacrifice = true; continue; case CardIdEnum.EX1_132: eyeforaneye = true; continue; case CardIdEnum.EX1_136: redemption = true; continue; case CardIdEnum.EX1_287: counterspell = true; continue; case CardIdEnum.EX1_289: icebarrier = true; continue; case CardIdEnum.EX1_294: mirrorentity = true; continue; case CardIdEnum.EX1_295: iceblock = true; continue; case CardIdEnum.EX1_379: repentance = true; continue; case CardIdEnum.EX1_533: missdirection = true; continue; case CardIdEnum.EX1_554: snaketrap = true; continue; case CardIdEnum.EX1_594: vaporize = true; continue; case CardIdEnum.EX1_609: snipe = true; continue; case CardIdEnum.EX1_610: explosive = true; continue; case CardIdEnum.EX1_611: freezing = true; continue; case CardIdEnum.FP1_018: duplicate = true; continue; case CardIdEnum.FP1_020: avenge = true; continue; case CardIdEnum.LOE_021: darttrap = true; continue; case CardIdEnum.LOE_027: sacredtrial = true; continue; case CardIdEnum.tt_010: spellbender = true; continue; case CardIdEnum.KAR_004: cattrick = true; continue; } } foreach (SecretItem si in this.enemySecrets) { if (beartrap) { si.canBe_beartrap = false; } if (explosive) { si.canBe_explosive = false; } if (snaketrap) { si.canBe_snaketrap = false; } if (missdirection) { si.canBe_missdirection = false; } if (freezing) { si.canBe_freezing = false; } if (snipe) { si.canBe_snipe = false; } if (darttrap) { si.canBe_darttrap = false; } if (cattrick) { si.canBe_cattrick = false; } if (counterspell) { si.canBe_counterspell = false; } if (icebarrier) { si.canBe_icebarrier = false; } if (iceblock) { si.canBe_iceblock = false; } if (mirrorentity) { si.canBe_mirrorentity = false; } if (spellbender) { si.canBe_spellbender = false; } if (vaporize) { si.canBe_vaporize = false; } if (duplicate) { si.canBe_duplicate = false; } if (effigy) { si.canBe_effigy = false; } if (eyeforaneye) { si.canBe_eyeforaneye = false; } if (noblesacrifice) { si.canBe_noblesacrifice = false; } if (redemption) { si.canBe_redemption = false; } if (repentance) { si.canBe_repentance = false; } if (avenge) { si.canBe_avenge = false; } if (sacredtrial) { si.canBe_sacredtrial = false; } } }
public virtual int getPlayCardPenality(CardDB.Card card, Minion target, Playfield p) { return(0); }
public bool getHoldList(MulliganData mulliganData, Behavior behave) { cards.Clear(); readRules(behave.BehaviorName()); if (!mulliganRulesLoaded) { return(false); } if (!(mulliganData.Cards.Count == 3 || mulliganData.Cards.Count == 4)) { Helpfunctions.Instance.ErrorLog("[Mulligan] Mulligan is not used, since it got number of cards: " + cards.Count.ToString()); return(false); } Log.InfoFormat("[Mulligan] Apply the {0} rules:", behave.BehaviorName()); for (var i = 0; i < mulliganData.Cards.Count; i++) { cards.Add(new CardIDEntity(mulliganData.Cards[i].Entity.Id, i)); } HeroEnum ownHeroClass = Hrtprozis.Instance.heroTAG_CLASSstringToEnum(mulliganData.UserClass.ToString()); HeroEnum enemyHeroClass = Hrtprozis.Instance.heroTAG_CLASSstringToEnum(mulliganData.OpponentClass.ToString()); int manaRule = 4; string MullRuleKey = getMullRuleKey(CardIdEnum.None, ownHeroClass, enemyHeroClass, 1); if (MulliganRules.ContainsKey(MullRuleKey)) { string[] temp = MulliganRules[MullRuleKey].Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); manaRule = Convert.ToInt32(temp[2]); } else { MullRuleKey = getMullRuleKey(CardIdEnum.None, ownHeroClass, HeroEnum.None, 1); if (MulliganRules.ContainsKey(MullRuleKey)) { string[] temp = MulliganRules[MullRuleKey].Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); manaRule = Convert.ToInt32(temp[2]); } } CardIDEntity Coin = new CardIDEntity("GAME_005", -888); if (cards.Count == 4) { cards.Add(Coin); //we have a coin } foreach (CardIDEntity CardIDEntityC in cards) { CardDB.Card c = CardDB.Instance.getCardDataFromID(CardIDEntityC.id); if (CardIDEntityC.hold == 0 && CardIDEntityC.holdByRule == 0) { if (c.cost < manaRule) { CardIDEntityC.holdByManarule = 2; CardIDEntityC.holdReason = joinSomeTxt("hold because the card cost:", c.cost.ToString(), " is less then Manarule cost:", manaRule.ToString()); } else { CardIDEntityC.holdByManarule = -2; CardIDEntityC.holdReason = joinSomeTxt("discard because the card cost:", c.cost.ToString(), " is not less then Manarule cost:", manaRule.ToString()); } } int allowedQuantitySimple = 0; int allowedQuantityExtra = 0; bool hasRuleClassSimple = false; bool hasRule = false; string MullRuleKeySimple = getMullRuleKey(c.cardIDenum, ownHeroClass, enemyHeroClass, 0); //Simple key for Class enemy if (MulliganRules.ContainsKey(MullRuleKeySimple)) { hasRule = true; hasRuleClassSimple = true; } else { MullRuleKeySimple = getMullRuleKey(c.cardIDenum, ownHeroClass, HeroEnum.None, 0); //Simple key for ALL enemy if (MulliganRules.ContainsKey(MullRuleKeySimple)) { hasRule = true; } } if (hasRule) { string[] val = MulliganRules[MullRuleKeySimple].Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); allowedQuantitySimple = ((val[1] == "2") ? 2 : 1) * ((val[0] == "Hold") ? 1 : -1); } hasRule = false; string MullRuleKeyExtra = getMullRuleKey(c.cardIDenum, ownHeroClass, enemyHeroClass, 1); //Extra key for Class enemy if (MulliganRules.ContainsKey(MullRuleKeyExtra)) { hasRule = true; } else if (!hasRuleClassSimple) { MullRuleKeyExtra = getMullRuleKey(c.cardIDenum, ownHeroClass, HeroEnum.None, 1); //Extra key for ALL enemy if (MulliganRules.ContainsKey(MullRuleKeyExtra)) { hasRule = true; } } if (hasRule) { string[] val = MulliganRules[MullRuleKeyExtra].Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); allowedQuantityExtra = ((val[1] == "2") ? 2 : 1) * ((val[0] == "Hold") ? 1 : -1); } //superimpose Class rules to All rules bool useHold = false; bool useDiscard = false; bool useHoldRule = false; bool useDiscardRule = false; if (allowedQuantitySimple != 0 && allowedQuantitySimple != allowedQuantityExtra) { if (allowedQuantitySimple > 0) { useHold = true; } else { useDiscard = true; } } if (allowedQuantityExtra != 0) { if (allowedQuantityExtra < 0) { useDiscardRule = true; } else { useHoldRule = true; } } //apply the rules string[] MullRuleValueExtra = new string[3]; if (allowedQuantityExtra != 0) { MullRuleValueExtra = MulliganRules[MullRuleKeyExtra].Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); } if (useDiscardRule) { if (MullRuleValueExtra[2] != "/") { string[] addedCards = MullRuleValueExtra[2].Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); MulliganRulesManual.Clear(); foreach (string s in addedCards) { MulliganRulesManual.Add(CardDB.Instance.cardIdstringToEnum(s), ""); } foreach (CardIDEntity tmp in cards) { if (CardIDEntityC.entitiy == tmp.entitiy) { continue; } if (MulliganRulesManual.ContainsKey(tmp.id)) { CardIDEntityC.holdByRule = -2; CardIDEntityC.holdReason = joinSomeTxt("discard by rule: ", getClearRule(MullRuleKeyExtra)); break; } } } } else if (useDiscard) { CardIDEntityC.hold = -2; CardIDEntityC.holdReason = joinSomeTxt("discard by rule: ", getClearRule(MullRuleKeySimple)); } if (useHoldRule) { if (CardIDEntityC.holdByRule == 0) { string[] addedCards = MullRuleValueExtra[2].Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); MulliganRulesManual.Clear(); foreach (string s in addedCards) { MulliganRulesManual.Add(CardDB.Instance.cardIdstringToEnum(s), ""); } bool foundFreeCard = false; for (int i = 0; i < cards.Count; i++) { if (CardIDEntityC.entitiy == cards[i].entitiy) { continue; } if (MulliganRulesManual.ContainsKey(cards[i].id)) { CardIDEntityC.holdByRule = 2; CardIDEntityC.holdReason = joinSomeTxt("hold by rule: ", getClearRule(MullRuleKeyExtra)); if (cards[i].holdByRule < 0) { for (int j = i; j < cards.Count; j++) { if (CardIDEntityC.entitiy == cards[j].entitiy) { continue; } if (MulliganRulesManual.ContainsKey(cards[j].id)) { if (cards[j].holdByRule < 0) { continue; } foundFreeCard = true; cards[j].holdByRule = 2; cards[j].holdReason = joinSomeTxt("hold by rule: ", getClearRule(MullRuleKeyExtra)); break; } } if (!foundFreeCard) { foundFreeCard = true; cards[i].holdByRule = 2; cards[i].holdReason = joinSomeTxt("hold by rule: ", getClearRule(MullRuleKeyExtra)); break; } } else { foundFreeCard = true; cards[i].holdByRule = 2; cards[i].holdReason = joinSomeTxt("hold by rule: ", getClearRule(MullRuleKeyExtra)); } if (allowedQuantityExtra == 1) { foreach (CardIDEntity tmp in cards) { if (tmp.entitiy == CardIDEntityC.entitiy) { continue; } if (tmp.id == CardIDEntityC.id) { tmp.holdByRule = -2; tmp.holdReason = joinSomeTxt("discard by rule: ", getClearRule(MullRuleKeyExtra)); } } } } } } } if (useHold && CardIDEntityC.holdByRule != -2) { if (CardIDEntityC.hold == 0) { CardIDEntityC.hold = 2; CardIDEntityC.holdReason = joinSomeTxt("hold by rule: ", getClearRule(MullRuleKeySimple)); if (allowedQuantitySimple == 1) { CardIDEntityC.hold = 1; foreach (CardIDEntity tmp in cards) { if (tmp.entitiy == CardIDEntityC.entitiy) { continue; } if (tmp.id == CardIDEntityC.id) { tmp.hold = -2; tmp.holdReason = joinSomeTxt("discard Second card by rule: ", getClearRule(MullRuleKeySimple)); } } } } } } if (cards.Count == 5) { cards.Remove(Coin); } foreach (CardIDEntity c in cards) { if (c.holdByRule == 0) { if (c.hold == 0) { c.holdByRule = c.holdByManarule; } else { c.holdByRule = c.hold; } } } for (var i = 0; i < mulliganData.Cards.Count; i++) { mulliganData.Mulligans[i] = (cards[i].holdByRule > 0) ? false : true; Log.InfoFormat("[Mulligan] {0} {1}.", mulliganData.Cards[i].Entity.Name, cards[i].holdReason); } return(true); }
public Weapon() { this.card = CardDB.Instance.unknownCard; }
public Handcard() { card = CardDB.Instance.unknownCard; }
CardDB.Card kid3 = CardDB.Instance.getCardDataFromID(CardIdEnum.NEW1_032); //misha public override void onCardPlay(Playfield p, bool ownplay, Minion target, int choice) { p.setNewHeroPower(CardIdEnum.TRL_065h, ownplay); // if (ownplay) { p.ownHero.armor += 5; } else { p.enemyHero.armor += 5; } int pos = (ownplay) ? p.ownMinions.Count : p.enemyMinions.Count; if (ownplay) { foreach (KeyValuePair <CardIdEnum, int> e in Probabilitymaker.Instance.ownCardsOut) { kid = cdb.getCardDataFromID(e.Key); if (kid.type == CardType.SPELL) { { if (kid.Secret) { if (p.ownSecretsIDList.Count < 5 && !p.ownSecretsIDList.Contains(kid.cardIDenum)) { p.ownSecretsIDList.Add(kid.cardIDenum); } } else if (kid.name == CardName.unleashthebeasts) { p.CallKid(kid2, pos, ownplay); p.drawACard(CardName.unknown, ownplay, true); if (e.Value > 1) { p.CallKid(kid2, pos, ownplay); } } else if (kid.name == CardName.animalcompanion) { if (e.Value > 1) { p.CallKid(kid3, pos, ownplay); } p.CallKid(kid3, pos, ownplay); } else if (kid.name == CardName.masterscall) { p.drawACard(CardName.unknown, ownplay, true); p.drawACard(CardName.unknown, ownplay, true); if (e.Value > 1) { p.drawACard(CardName.unknown, ownplay, true); p.drawACard(CardName.unknown, ownplay, true); } p.drawACard(CardName.unknown, ownplay, true); if (e.Value > 1) { p.drawACard(CardName.unknown, ownplay, true); } } } } } } }
public List <Action> GetMoveList(Playfield p, bool usePenalityManager, bool useCutingTargets, bool own) { //generates only own moves List <Action> ret = new List <Action>(); List <Minion> targetMinions; if (p.complete || p.ownHero.HealthPoints <= 0) { return(ret); } //play cards: if (own) { List <string> playedCards = new List <string>(); StringBuilder cardNcost = new StringBuilder(); foreach (Handmanager.Handcard hc in p.owncards) { int cardCost = hc.card.getManaCost(p, hc.manacost); if ((p.nextSpellThisTurnCostHealth && hc.card.type == CardType.SPELL) || (p.nextMurlocThisTurnCostHealth && (TAG_RACE)hc.card.race == TAG_RACE.MURLOC)) { if (p.ownHero.HealthPoints > cardCost || p.ownHero.immune) { } else { // if not enough Hp continue; } } else if (p.mana < cardCost) { // if not enough manna continue; } CardDB.Card c = hc.card; cardNcost.Clear(); cardNcost.Append(c.name).Append(hc.manacost); if (playedCards.Contains(cardNcost.ToString())) { // don't play the same card in one loop continue; } playedCards.Add(cardNcost.ToString()); int isChoice = (c.choice) ? 1 : 0; bool choiceDamageFound = false; for (int choice = 0 + 1 * isChoice; choice < 1 + 2 * isChoice; choice++) { if (isChoice == 1) { c = pen.getChooseCard(hc.card, choice); // do all choice if (p.ownFandralStaghelm > 0) { if (choiceDamageFound) { break; } for (int i = 1; i < 3; i++) { CardDB.Card cTmp = pen.getChooseCard(hc.card, i); // do all choice if (pen.DamageTargetDatabase.ContainsKey(cTmp.name) || (p.anzOwnAuchenaiSoulpriest > 0 && pen.HealTargetDatabase.ContainsKey(cTmp.name))) { choice = i; choiceDamageFound = true; c = cTmp; break; } //- Draw a card must be at end in the Sim_xxx - then it will selected! } } } if (p.ownMinions.Count > 6 && (c.type == CardType.Minion || hc.card.type == CardType.Minion)) { continue; } targetMinions = c.GetTargetsForCard(p, p.isLethalCheck, true); if (targetMinions.Count == 0) { continue; } int cardPlayPenalty = 0; CardDB.Card card; if (c.type == CardType.Minion) { card = c; } else { card = hc.card; } int bestPlace = p.getBestPlace(card, p.isLethalCheck); foreach (Minion targetMinion in targetMinions) { if (usePenalityManager) { cardPlayPenalty = pen.getPlayCardPenality(c, targetMinion, p); } if (cardPlayPenalty <= 499) { Action a = new Action(actionEnum.playcard, hc, null, bestPlace, targetMinion, cardPlayPenalty, choice); ret.Add(a); } } } } } //get targets for Hero weapon and Minions ################################################################################### targetMinions = p.getAttackTargets(own, p.isLethalCheck); if (!p.isLethalCheck) { targetMinions = this.cutAttackList(targetMinions); } // attack with minions List <Minion> attackingMinions = new List <Minion>(8); var minions = own ? p.ownMinions : p.enemyMinions; foreach (Minion minion in minions) { if (minion.Ready && minion.Attack >= 1 && !minion.frozen) { //add non-attacking minions attackingMinions.Add(minion); } } attackingMinions = cutAttackList(attackingMinions); foreach (Minion m in attackingMinions) { int attackPenalty = 0; foreach (Minion targetMinion in targetMinions) { //can not attack hero if (m.cantAttackHeroes && targetMinion.isHero) { continue; } if (usePenalityManager) { attackPenalty = pen.getAttackWithMininonPenality(m, p, targetMinion); } if (attackPenalty <= 499) { Action a = new Action(actionEnum.attackWithMinion, null, m, 0, targetMinion, attackPenalty, 0); ret.Add(a); } } } // attack with hero (weapon) if ((own && p.ownHero.Ready && p.ownHero.Attack >= 1) || (!own && p.enemyHero.Ready && p.enemyHero.Attack >= 1)) { int heroAttackPen = 0; foreach (Minion targetMinion in targetMinions) { if ((own ? p.ownWeapon.cantAttackHeroes : p.enemyWeapon.cantAttackHeroes) && targetMinion.isHero) { continue; } if (usePenalityManager) { heroAttackPen = pen.getAttackWithHeroPenality(targetMinion, p); } if (heroAttackPen <= 499) { Action a = new Action(actionEnum.attackWithHero, null, (own ? p.ownHero : p.enemyHero), 0, targetMinion, heroAttackPen, 0); ret.Add(a); } } } //############################################################################################################# // use own ability if (own) { if (p.ownAbilityReady && p.mana >= p.ownHeroAblility.card.getManaCost(p, p.ownHeroAblility.manacost)) // if ready and enough manna { CardDB.Card c = p.ownHeroAblility.card; int isChoice = (c.choice) ? 1 : 0; for (int choice = 0 + 1 * isChoice; choice < 1 + 2 * isChoice; choice++) { if (isChoice == 1) { c = pen.getChooseCard(p.ownHeroAblility.card, choice); // do all choice } int cardPlayPenalty = 0; int bestPlace = p.ownMinions.Count + 1; //we can not manage it targetMinions = p.ownHeroAblility.card.getTargetsForHeroPower(p, true); foreach (Minion targetMinion in targetMinions) { if (usePenalityManager) { cardPlayPenalty = pen.getPlayCardPenality(p.ownHeroAblility.card, targetMinion, p); } if (cardPlayPenalty <= 499) { Action a = new Action(actionEnum.useHeroPower, p.ownHeroAblility, null, bestPlace, targetMinion, cardPlayPenalty, choice); ret.Add(a); } } } } } return(ret); }
public combo(string s) { int i = 0; this.neededMana = 0; requiredWeapon = CardName.unknown; this.type = combotype.combo; this.twoTurnCombo = false; bool fixmana = false; if (s.Contains("nxttrn")) { this.twoTurnCombo = true; } if (s.Contains("mana:")) { fixmana = true; } /*foreach (string ding in s.Split(':')) * { * if (i == 0) * { * if (ding == "c") this.type = combotype.combo; * if (ding == "t") this.type = combotype.target; * if (ding == "w") this.type = combotype.weaponuse; * } * if (ding == "" || ding == string.Empty) continue; * * if (i == 1 && type == combotype.combo) * { * int m = Convert.ToInt32(ding); * neededMana = -1; * if (m >= 1) neededMana = m; * } */ if (type == combotype.combo) { this.combolength = 0; this.combot0len = 0; this.combot1len = 0; this.combot0lenAll = 0; int manat0 = 0; int manat1 = -1; bool t1 = false; foreach (string crdl in s.Split(';')) //ding.Split { if (crdl == "" || crdl == string.Empty) { continue; } if (crdl == "nxttrn") { t1 = true; continue; } if (crdl.StartsWith("mana:")) { this.neededMana = Convert.ToInt32(crdl.Replace("mana:", "")); continue; } if (crdl.StartsWith("hero:")) { this.oHero = Hrtprozis.Instance.heroNametoEnum(crdl.Replace("hero:", "")); continue; } if (crdl.StartsWith("bonus:")) { this.bonusForPlaying = Convert.ToInt32(crdl.Replace("bonus:", "")); continue; } if (crdl.StartsWith("bonusfirst:")) { this.bonusForPlayingT0 = Convert.ToInt32(crdl.Replace("bonusfirst:", "")); continue; } if (crdl.StartsWith("bonussecond:")) { this.bonusForPlayingT1 = Convert.ToInt32(crdl.Replace("bonussecond:", "")); continue; } string crd = crdl.Split(',')[0]; if (t1) { manat1 += cb.cdb.getCardDataFromID(cb.cdb.cardIdstringToEnum(crd)).cost; } else { manat0 += cb.cdb.getCardDataFromID(cb.cdb.cardIdstringToEnum(crd)).cost; } this.combolength++; if (combocards.ContainsKey(cb.cdb.cardIdstringToEnum(crd))) { combocards[cb.cdb.cardIdstringToEnum(crd)]++; } else { combocards.Add(cb.cdb.cardIdstringToEnum(crd), 1); cardspen.Add(cb.cdb.cardIdstringToEnum(crd), Convert.ToInt32(crdl.Split(',')[1])); } if (this.twoTurnCombo) { if (t1) { if (this.combocardsTurn1.ContainsKey(cb.cdb.cardIdstringToEnum(crd))) { combocardsTurn1[cb.cdb.cardIdstringToEnum(crd)]++; } else { combocardsTurn1.Add(cb.cdb.cardIdstringToEnum(crd), 1); } this.combot1len++; } else { CardDB.Card lolcrd = cb.cdb.getCardDataFromID(cb.cdb.cardIdstringToEnum(crd)); if (lolcrd.type == CardType.Minion) { if (this.combocardsTurn0Mobs.ContainsKey(cb.cdb.cardIdstringToEnum(crd))) { combocardsTurn0Mobs[cb.cdb.cardIdstringToEnum(crd)]++; } else { combocardsTurn0Mobs.Add(cb.cdb.cardIdstringToEnum(crd), 1); } this.combot0len++; } if (lolcrd.type == CardType.WEAPON) { this.requiredWeapon = lolcrd.name; } if (this.combocardsTurn0All.ContainsKey(cb.cdb.cardIdstringToEnum(crd))) { combocardsTurn0All[cb.cdb.cardIdstringToEnum(crd)]++; } else { combocardsTurn0All.Add(cb.cdb.cardIdstringToEnum(crd), 1); } this.combot0lenAll++; } } } if (!fixmana) { this.neededMana = Math.Max(manat1, manat0); } } /*if (i == 2 && type == combotype.combo) * { * int m = Convert.ToInt32(ding); * penality = 0; * if (m >= 1) penality = m; * } * * i++; * }*/ this.bonusForPlaying = Math.Max(bonusForPlaying, 1); this.bonusForPlayingT0 = Math.Max(bonusForPlayingT0, 1); this.bonusForPlayingT1 = Math.Max(bonusForPlayingT1, 1); }
public int checkIfComboWasPlayed(Playfield p) { if (this.combos.Count == 0) { return(0); } List <Action> alist = p.playactions; CardName weapon = p.ownWeapon.name; HeroEnum heroname = p.ownHeroName; //returns a penalty only if the combo could be played, but is not played completely List <Handmanager.Handcard> playedcards = new List <Handmanager.Handcard>(); List <combo> searchingCombo = new List <combo>(); // only check the cards, that are in a combo that can be played: int mana = Math.Max(p.ownMaxMana, p.mana); foreach (Action a in alist) { if (a.actionType != actionEnum.playcard) { continue; } CardDB.Card crd = a.card.card; foreach (combo c in this.combos) { if ((c.oHero == HeroEnum.None || c.oHero == p.ownHeroName) && c.isCardInCombo(crd)) { int iia = c.isInCombo(p.owncards, p.ownMaxMana); int iib = c.isMultiTurnComboTurn1(p.owncards, mana, p.ownMinions, weapon); int iic = Math.Max(iia, iib); if (iia == 2 && iib != 2 && c.isMultiTurn1Card(crd)) { iic = 1; } if (iic == 2) { playedcards.Add(a.card); // add only the cards, which dont get a penalty } } } } if (playedcards.Count == 0) { return(0); } bool wholeComboPlayed = false; int bonus = 0; foreach (combo c in this.combos) { int iia = c.hasPlayedCombo(playedcards); int iib = c.hasPlayedTurn0Combo(playedcards); int iic = c.hasPlayedTurn1Combo(playedcards); int iie = iia + iib + iic; if (iie >= 1) { wholeComboPlayed = true; bonus -= iie; } } if (wholeComboPlayed) { return(bonus); } return(250); }