public List<Action> getMoveList(Playfield p, bool isLethalCheck, bool usePenalityManager, bool useCutingTargets) { bool own = p.isOwnTurn; Player mPlayer, ePlayer; if (own) { mPlayer = p.playerFirst; ePlayer = p.playerSecond; } else { mPlayer = p.playerSecond; ePlayer = p.playerFirst; } //generates only own moves List<Action> ret = new List<Action>(); List<Minion> trgts = new List<Minion>(); if (p.complete || mPlayer.ownHero.Hp <= 0) { return ret; } //play cards: List<CardDB.cardName> playedcards = new List<CardDB.cardName>(); foreach (Handmanager.Handcard hc in mPlayer.owncards) { CardDB.Card c = hc.card; //implementation if (c.name == CardDB.cardName.armorplating) { p.moveTrigger.hasOwnTargetMove = true; } //end of implementation if (playedcards.Contains(c.name) || !hc.canplayCard(p, own)) 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 = getChooseCard(hc.card, i); // do all choice int manaCost = hc.getManaCost(p, own); if (mPlayer.mana >= manaCost) // if enough manna { int cardplayPenality = 0; int bestplace = p.getBestPlace(c, isLethalCheck, own); //if (c.cardIDenum == CardDB.cardIDEnum.NEW1_005) { // int toBreak = 1; //} trgts = c.getTargetsForCard(p, isLethalCheck, own); float bestReward = Single.MinValue; List<Tuple<Action, float>> tempRet = new List<Tuple<Action, float>>(); 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, manaCost); //i is the choice ret.Add(a); if (trgt != null && trgt.own == p.isOwnTurn) { p.moveTrigger.hasOwnTargetMove = true; } //if (trgt != null) //{ // if (trgt.isHero && trgt.Hp <= 12) // { // ret.Add(a); // continue; // } // float reward = pen.getOffenseReward(a, p); // tempRet.Add(new Tuple<Action, float>(a, reward)); //} //else //{ // ret.Add(a); //} } } //tempRet.Sort((x, y) => y.Item2.CompareTo(x.Item2)); //if (tempRet.Count > 0) //{ // ret.Add(tempRet[0].Item1); // if (tempRet[0].Item1.target.own == p.isOwnTurn) // { // p.moveTrigger.hasOwnTargetMove = true; // } //} //if (tempRet.Count > 1) //{ // ret.Add(tempRet[1].Item1); // if (tempRet[1].Item1.target.own == p.isOwnTurn) // { // p.moveTrigger.hasOwnTargetMove = true; // } //} } } } //get targets for Hero weapon and Minions ################################################################################### trgts = p.getAttackTargets(own, isLethalCheck); //if (!isLethalCheck) trgts = this.cutAttackList(trgts); // attack with minions List<Minion> attackingMinions = new List<Minion>(8); foreach (Minion m in mPlayer.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, 0); ret.Add(a); } } } // attack with hero (weapon) if (mPlayer.ownHero.Ready && mPlayer.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, mPlayer.ownHero, 0, trgt, heroAttackPen, 0, 0); ret.Add(a); } } } //############################################################################################################# // use ability if (mPlayer.ownAbilityReady && mPlayer.mana >= 2) // if ready and enough manna TODO: TGT mana cost change { int cardplayPenality = 0; int bestplace = mPlayer.ownMinions.Count + 1; //we can not manage it trgts = mPlayer.ownHeroAblility.card.getTargetsForCard(p, isLethalCheck, own); foreach (Minion trgt in trgts) { if (usePenalityManager) cardplayPenality = pen.getPlayCardPenality(mPlayer.ownHeroAblility.card, trgt, p, 0, isLethalCheck); if (cardplayPenality <= 499) { Action a = new Action(actionEnum.useHeroPower, mPlayer.ownHeroAblility, null, bestplace, trgt, cardplayPenality, 0, 2); if (trgt.own == p.isOwnTurn) { //Helpfunctions.Instance.logg("ping on own minion"); } if ((trgt.entitiyID == 0 && p.isOwnTurn) || (trgt.entitiyID == 1 && !p.isOwnTurn)) { Helpfunctions.Instance.logg("ping on own hero"); } ret.Add(a); } } } return ret; }