• 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;
            }
  • 相关阅读:
    Pascal 语言中的关键字及保留字
    单元文件结构
    在 case 语句中使用字符串-转
    程序流程的辅助控制-转
    XE版本 InputQuery 可以同时填多个输入值
    转:Delphi 6 实用函数
    转:Delphi 函数大全
    d 属性: 赋予字段执行动作的能力
    Json格式示意图
    转:虚拟方法跳过父类继承调用祖父类的代码 --值得试一试
  • 原文地址:https://www.cnblogs.com/dch0319/p/13564406.html
Copyright © 2020-2023  润新知