1. 程式人生 > 實用技巧 >Behavior控場模式的解析(中)

Behavior控場模式的解析(中)

            bool useAbili = false;//是否使用過技能
            int usecoin = 0;//是否使用過硬幣,用一次+1
            //soulfire etc
            int deletecardsAtLast = 0;//是否需要棄牌
            int wasCombo = 0;//是否觸發連擊
            bool firstSpellToEnHero = false;//回合中第一個法術打對面臉
            int count = p.playactions.Count;//動作數量
            int
ownActCount = 0;//己方動作數量 for (int i = 0; i < count; i++) { Action a = p.playactions[i]; ownActCount++; switch (a.actionType) { case actionEnum.attackWithHero: if (p.enemyHero.Hp <= p.attackFaceHP) retval++;//
p.attackFaceHP就是15 if (p.ownHeroName == HeroEnum.warrior && useAbili) retval -= 1;//戰士先砍再用技能 continue; case actionEnum.useHeroPower: useAbili = true; continue;
case actionEnum.playcard: break; default: continue; } switch (a.card.card.name) { case CardDB.cardName.innervate: case CardDB.cardName.thecoin: usecoin++; if (i == count - 1) retval -= 10;//不要用完硬幣結束回合 goto default; case CardDB.cardName.darkshirelibrarian: goto case CardDB.cardName.soulfire; case CardDB.cardName.darkbargain: goto case CardDB.cardName.soulfire; case CardDB.cardName.doomguard: goto case CardDB.cardName.soulfire; case CardDB.cardName.queenofpain: goto case CardDB.cardName.soulfire; case CardDB.cardName.soulfire: deletecardsAtLast = 1; break; default: if (deletecardsAtLast == 1) retval -= 20;//不要隨便出棄牌隨從 break; } if (a.card.card.Combo && i > 0) wasCombo++; if (a.target == null) continue; //save spell for all classes if (a.card.card.type == CardDB.cardtype.SPELL && (a.target.isHero && !a.target.own)) { if (i == 0) firstSpellToEnHero = true; retval -= 11;//法術不要隨便打臉 } } if (wasCombo > 0 && firstSpellToEnHero) { if (wasCombo + 1 == ownActCount) retval += 10; } if (usecoin > 0) { if (useAbili && p.ownMaxMana <= 2) retval -= 40;//2費之前不要硬幣技能 retval -= 5 * p.manaTurnEnd;//不要浪費硬幣 if (p.manaTurnEnd + usecoin > 10) retval -= 5 * usecoin;//不要浪費硬幣 } if (p.manaTurnEnd >= 2 && !useAbili && p.ownAbilityReady)//費用充足,不要不用技能就結束回合 { switch (p.ownHeroAblility.card.name) { case CardDB.cardName.heal: goto case CardDB.cardName.lesserheal; case CardDB.cardName.lesserheal: bool wereTarget = false; if (p.ownHero.Hp < p.ownHero.maxHp) wereTarget = true; if (!wereTarget) { foreach (Minion m in p.ownMinions) { if (m.wounded) { wereTarget = true; break;} } } if (wereTarget && !(p.anzOwnAuchenaiSoulpriest > 0 || p.embracetheshadow > 0)) retval -= 10; break; case CardDB.cardName.poisoneddaggers: goto case CardDB.cardName.daggermastery; case CardDB.cardName.daggermastery: if (!(p.ownWeapon.Durability > 1 || p.ownWeapon.Angr > 1)) retval -= 10; break; case CardDB.cardName.totemicslam: goto case CardDB.cardName.totemiccall; case CardDB.cardName.totemiccall: if (p.ownMinions.Count < 7) retval -= 10; else retval -= 3; break; case CardDB.cardName.thetidalhand: goto case CardDB.cardName.reinforce; case CardDB.cardName.thesilverhand: goto case CardDB.cardName.reinforce; case CardDB.cardName.reinforce: if (p.ownMinions.Count < 7) retval -= 10; else retval -= 3; break; case CardDB.cardName.soultap: if (p.owncards.Count < 10 && p.ownDeckSize > 0) retval -= 10; break; case CardDB.cardName.lifetap: if (p.owncards.Count < 10 && p.ownDeckSize > 0) { retval -= 10; if (p.ownHero.immune) retval-= 5; } break; default: retval -= 10; break; } } int mobsInHand = 0;//手牌中隨從數量 int bigMobsInHand = 0;//手牌中攻擊力大於3的隨從數量 foreach (Handmanager.Handcard hc in p.owncards) { if (hc.card.type == CardDB.cardtype.MOB) { mobsInHand++; if (hc.card.Attack + hc.addattack >= 3) bigMobsInHand++; retval += hc.addattack + hc.addHp + hc.elemPoweredUp; } } if (ownMinionsCount - p.enemyMinions.Count >= 4 && bigMobsInHand >= 1) { retval += bigMobsInHand * 25;//己方場面優勢,留一個大隨從在手裡 } foreach (Minion m in p.enemyMinions) { retval -= this.getEnemyMinionValue(m, p);//減去所有敵方隨從的價值 } retval -= p.enemyMinions.Count * 2;//減去敵方隨從數量2倍的價值 retval -= p.enemySecretCount;//減去敵方奧祕數量價值 retval -= p.lostDamage;//減去超殺(浪費傷害)的價值 retval -= p.lostWeaponDamage;//亂切刀浪費的價值 if (p.enemyHero.Hp <= 0)//斬殺價值 { retval += 10000; if (retval < 10000) retval = 10000; } if (p.enemyHero.Hp >= 1 && p.guessingHeroHP <= 0)//被斬殺 { if (p.turnCounter < 2) retval += p.owncarddraw * 100; retval -= 1000; } if (p.ownHero.Hp <= 0) retval -= 10000; p.value = retval; return retval; }