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

Behavior控場模式的解析(下)

        /// <summary>
        /// 計算敵方隨從價值
        /// </summary>
        /// <param name="m">正在計算的隨從</param>
        /// <param name="p">場面</param>
        /// <returns>價值,是一個整數</returns>
        public override int getEnemyMinionValue(Minion m, Playfield p)
        {
            
int retval = 5;//初始值5 retval += m.Hp * 2;//血量2 if (!m.frozen && !(m.cantAttack && m.name != CardDB.cardName.argentwatchman))//未被凍結,可以攻擊 { retval += m.Angr * 2;//攻擊2 if (m.windfury) retval += m.Angr * 2;//風怒,+2倍攻擊 if
(m.Angr >= 4) retval += 10;//攻擊大於等於4,+10 if (m.Angr >= 7) retval += 50;//攻擊大於等於7,+50 } if (!m.handcard.card.isSpecialMinion)//不是特殊隨從(penman裡的字典) { if (m.Angr == 0) retval -= 7;//攻擊為0,-7 else if (m.Angr <= 2 && m.Hp <= 2
&& !m.divineshild) retval -= 5;//攻擊血量小於2,無聖盾,-5 } else retval += m.handcard.card.rarity;//加隨從稀有度 if (m.taunt) retval += 5;//嘲諷,+5 if (m.divineshild) retval += m.Angr;//聖盾,+攻擊 if (m.divineshild && m.taunt) retval += 5;//聖盾嘲諷,+5 if (m.stealth) retval += 1;//潛行,+1 if (m.poisonous)//劇毒 { retval += 4; if (p.ownMinions.Count < p.enemyMinions.Count) retval += 10; } if (m.lifesteal) retval += m.Angr;//吸血,+攻擊 if (m.handcard.card.targetPriority >= 1 && !m.silenced) { retval += m.handcard.card.targetPriority;//目標優先順序,也在penman字典裡面 } if (m.name == CardDB.cardName.nerubianegg && m.Angr <= 3 && !m.taunt) retval = 0;//燭魔之卵 retval += m.synergy;//+職業契合度 return retval; } /// <summary> /// 芬利爵士優先順序 /// </summary> /// <param name="discoverCards"></param> /// <returns>選擇</returns> public override int getSirFinleyPriority(List<Handmanager.Handcard> discoverCards) { //return -1; //comment out or remove this to set manual priority int sirFinleyChoice = -1; int tmp = int.MinValue; for (int i = 0; i < discoverCards.Count; i++) { CardDB.cardName name = discoverCards[i].card.name; if (SirFinleyPriorityList.ContainsKey(name) && SirFinleyPriorityList[name] > tmp) { tmp = SirFinleyPriorityList[name]; sirFinleyChoice = i; } } return sirFinleyChoice; } private Dictionary<CardDB.cardName, int> SirFinleyPriorityList = new Dictionary<CardDB.cardName, int> { //{HeroPowerName, Priority}, where 0-9 = manual priority { CardDB.cardName.lesserheal, 2 }, { CardDB.cardName.shapeshift, 5 }, { CardDB.cardName.fireblast, 4 }, { CardDB.cardName.totemiccall, 7 }, { CardDB.cardName.lifetap, 9 }, { CardDB.cardName.daggermastery, 6 }, { CardDB.cardName.reinforce, 3 }, { CardDB.cardName.armorup, 1 }, { CardDB.cardName.steadyshot, 8 } };