public List <Action> getMoveList(Playfield p, bool usePenalityManager, bool useCutingTargets, bool own) { //generates only own moves List <Action> ret = new List <Action>(); List <Minion> trgts = new List <Minion>(); if (p.complete || p.ownHero.Hp <= 0) { return(ret); } //play cards: if (own) { List <string> playedcards = new List <string>(); System.Text.StringBuilder cardNcost = new System.Text.StringBuilder(); foreach (Handmanager.Handcard hc in p.owncards) { int cardCost = hc.card.getManaCost(p, hc.manacost); if ((p.nextSpellThisTurnCostHealth && hc.card.type == CardDB.cardtype.SPELL) || (p.nextMurlocThisTurnCostHealth && (TAG_RACE)hc.card.race == TAG_RACE.MURLOC)) { if (p.ownHero.Hp > cardCost || p.ownHero.immune) { } else { continue; // if not enough Hp } } else if (p.mana < cardCost) { continue; // if not enough manna } CardDB.Card c = hc.card; cardNcost.Clear(); cardNcost.Append(c.name).Append(hc.manacost); if (playedcards.Contains(cardNcost.ToString())) { continue; // dont play the same card in one loop } 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 == CardDB.cardtype.MOB || hc.card.type == CardDB.cardtype.MOB)) { continue; } trgts = c.getTargetsForCard(p, p.isLethalCheck, true); if (trgts.Count == 0) { continue; } int cardplayPenality = 0; int bestplace = p.getBestPlace(c.type == CardDB.cardtype.MOB ? c : hc.card, p.isLethalCheck); foreach (Minion trgt in trgts) { if (usePenalityManager) { cardplayPenality = pen.getPlayCardPenality(c, trgt, p); } if (cardplayPenality <= 499) { Action a = new Action(actionEnum.playcard, hc, null, bestplace, trgt, cardplayPenality, choice); ret.Add(a); } } } } } //get targets for Hero weapon and Minions ################################################################################### trgts = p.getAttackTargets(own, p.isLethalCheck); if (!p.isLethalCheck) { trgts = this.cutAttackList(trgts); } // attack with minions List <Minion> attackingMinions = new List <Minion>(8); foreach (Minion m in (own ? p.ownMinions : p.enemyMinions)) { if (m.Ready && m.Angr >= 1 && !m.frozen) { attackingMinions.Add(m); //* add non-attacing minions } } attackingMinions = this.cutAttackList(attackingMinions); foreach (Minion m in attackingMinions) { int attackPenality = 0; foreach (Minion trgt in trgts) { if (m.cantAttackHeroes && trgt.isHero) { continue; } if (usePenalityManager) { attackPenality = pen.getAttackWithMininonPenality(m, p, trgt); } if (attackPenality <= 499) { Action a = new Action(actionEnum.attackWithMinion, null, m, 0, trgt, attackPenality, 0); ret.Add(a); } } } // attack with hero (weapon) if ((own && p.ownHero.Ready && p.ownHero.Angr >= 1) || (!own && p.enemyHero.Ready && p.enemyHero.Angr >= 1)) { int heroAttackPen = 0; foreach (Minion trgt in trgts) { if ((own ? p.ownWeapon.cantAttackHeroes : p.enemyWeapon.cantAttackHeroes) && trgt.isHero) { continue; } if (usePenalityManager) { heroAttackPen = pen.getAttackWithHeroPenality(trgt, p); } if (heroAttackPen <= 499) { Action a = new Action(actionEnum.attackWithHero, null, (own ? p.ownHero : p.enemyHero), 0, trgt, 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 cardplayPenality = 0; int bestplace = p.ownMinions.Count + 1; //we can not manage it trgts = p.ownHeroAblility.card.getTargetsForHeroPower(p, true); foreach (Minion trgt in trgts) { if (usePenalityManager) { cardplayPenality = pen.getPlayCardPenality(p.ownHeroAblility.card, trgt, p); } if (cardplayPenality <= 499) { Action a = new Action(actionEnum.useHeroPower, p.ownHeroAblility, null, bestplace, trgt, cardplayPenality, choice); ret.Add(a); } } } } } return(ret); }
public List <Action> getMoveList(Playfield p, bool isLethalCheck, bool usePenalityManager, bool useCutingTargets) { //generates only own moves List <Action> ret = new List <Action>(); List <Minion> trgts = new List <Minion>(); if (p.complete || p.ownHero.Hp <= 0) { return(ret); } //play cards: List <CardDB.cardName> playedcards = new List <CardDB.cardName>(); foreach (Handmanager.Handcard hc in p.owncards) { CardDB.Card c = hc.card; if (playedcards.Contains(c.name) || !hc.canplayCard(p)) { continue; // dont play the same card in one loop } playedcards.Add(c.name); int isChoice = (c.choice) ? 1 : 0; for (int i = 0 + 1 * isChoice; i < 1 + 2 * isChoice; i++) { if (isChoice == 1) { c = pen.getChooseCard(hc.card, i); // do all choice } if (p.mana >= c.getManaCost(p, hc.manacost)) // if enough manna { int cardplayPenality = 0; int bestplace = p.getBestPlace(c, isLethalCheck); trgts = c.getTargetsForCard(p, isLethalCheck); foreach (Minion trgt in trgts) { if (usePenalityManager) { cardplayPenality = pen.getPlayCardPenality(hc.card, trgt, p, i, isLethalCheck); } if (cardplayPenality <= 499) { Action a = new Action(actionEnum.playcard, hc, null, bestplace, trgt, cardplayPenality, i); //i is the choice ret.Add(a); } } } } } foreach (Action a in ret) { if (a.actionType == actionEnum.playcard) { bool isCardValid = false; foreach (Handmanager.Handcard hh in p.owncards) { if (hh.entity == a.card.entity) { isCardValid = true; break; } } if (!isCardValid) { int debug1 = 1; } } } //get targets for Hero weapon and Minions ################################################################################### trgts = p.getAttackTargets(true, isLethalCheck); if (!isLethalCheck) { trgts = this.cutAttackList(trgts); } // attack with minions List <Minion> attackingMinions = new List <Minion>(8); foreach (Minion m in p.ownMinions) { if (m.Ready && m.Angr >= 1 && !m.frozen) { attackingMinions.Add(m); //* add non-attacing minions } } attackingMinions = this.cutAttackList(attackingMinions); foreach (Minion m in attackingMinions) { int attackPenality = 0; foreach (Minion trgt in trgts) { if (usePenalityManager) { attackPenality = pen.getAttackWithMininonPenality(m, p, trgt, isLethalCheck); } if (attackPenality <= 499) { Action a = new Action(actionEnum.attackWithMinion, null, m, 0, trgt, attackPenality, 0); ret.Add(a); } } } // attack with hero (weapon) if (p.ownHero.Ready && p.ownHero.Angr >= 1) { int heroAttackPen = 0; foreach (Minion trgt in trgts) { if (usePenalityManager) { heroAttackPen = pen.getAttackWithHeroPenality(trgt, p, isLethalCheck); } if (heroAttackPen <= 499) { Action a = new Action(actionEnum.attackWithHero, null, p.ownHero, 0, trgt, heroAttackPen, 0); ret.Add(a); } } } //############################################################################################################# // use ability if (p.ownAbilityReady && p.mana >= p.ownHeroAblility.card.getManaCost(p, 2)) // if ready and enough manna { int cardplayPenality = 0; int bestplace = p.ownMinions.Count + 1; //we can not manage it trgts = p.ownHeroAblility.card.getTargetsForCard(p, isLethalCheck); foreach (Minion trgt in trgts) { if (usePenalityManager) { cardplayPenality = pen.getPlayCardPenality(p.ownHeroAblility.card, trgt, p, 0, isLethalCheck); } if (cardplayPenality <= 499) { Action a = new Action(actionEnum.useHeroPower, p.ownHeroAblility, null, bestplace, trgt, cardplayPenality, 0); //if (trgt.own == true) //{ // sf.helpfunctions.logg("ping on own minion"); //} ret.Add(a); } } } return(ret); }