Пример #1
0
        /// <summary>
        /// Compute score for using a Card.
        /// </summary>
        /// <param name="sceneContext">The RockSceneContext</param>
        /// <param name="cardRockId">The RockId of Card</param>
        /// <returns>The score in double</returns>
        private static double ScoreForUseCard(RockSceneContext sceneContext, int cardRockId)
        {
            RockCard card = sceneContext.GetRockCard(cardRockId);

            if (card.CardId == "GAME_005")
            {
                // the coin
                foreach (RockCard handCard in sceneContext.Scene.Self.Cards)
                {
                    if (handCard.Cost == sceneContext.Scene.Self.Resources + 1)
                    {
                        return(4.5);
                    }
                }

                return(-4);
            }

            double score = 4;

            // adjust score by wasted cost
            int wastedCost = sceneContext.GetMininWastedCost(cardRockId);

            score -= wastedCost * 0.4d;

            if (sceneContext.Scene.Self.Cards.Count >= 5)
            {
                score += 0.5;
            }

            return(score);
        }
Пример #2
0
        /// <summary>
        /// Compute score for using a HeroPower.
        /// </summary>
        /// <param name="sceneContext">The RockSceneContext</param>
        /// <param name="cardRockId">The RockId of HeroPower</param>
        /// <param name="targetRockId">The RockId of Target</param>
        /// <returns>The score in double</returns>
        private static double ScoreForUsePriestHeroPower(RockSceneContext sceneContext, int cardRockId, int targetRockId)
        {
            double   score = 4; // initial score
            RockCard card  = sceneContext.GetRockCard(cardRockId);

            // adjust score by wasted cost
            int wastedCost = sceneContext.GetMininWastedCost(cardRockId);

            score -= wastedCost * 0.4d;

            var target = sceneContext.GetRockObject(targetRockId);

            switch (target.ObjectType)
            {
            case RockObjectType.EnemyHero:
                score -= 5d;
                break;

            case RockObjectType.EnemyMinion:
                // but in some special case, we will want to heal them
                score -= 5d;
                break;

            case RockObjectType.FriendlyHero:
                RockHero hero = (RockHero)target.Object;
                if (hero.Health < 30)
                {
                    score += 0.5d;
                }
                else
                {
                    return(0);
                }

                score += (30 - hero.Health) * 0.05;

                break;

            case RockObjectType.FriendlyMinion:
                RockMinion minion = (RockMinion)target.Object;
                if (minion.Health < minion.BaseHealth)
                {
                    score += minion.Damage * 0.4d;
                }

                break;

            default:
                break;
            }

            return(score);
        }
Пример #3
0
        /// <summary>
        /// Compute score for using a HeroPower.
        /// </summary>
        /// <param name="sceneContext">The RockSceneContext</param>
        /// <param name="cardRockId">The RockId of HeroPower</param>
        /// <returns>The score in double</returns>
        private static double ScoreForUseHeroPower(RockSceneContext sceneContext, int cardRockId)
        {
            double   score = 4; // initial score
            RockCard card  = sceneContext.GetRockCard(cardRockId);

            // adjust score by wasted cost
            int wastedCost = sceneContext.GetMininWastedCost(cardRockId);

            score -= wastedCost * 0.4d;

            return(score);
        }
Пример #4
0
        /// <summary>
        /// Generate a sample RockPlayer.
        /// </summary>
        /// <returns>A RockPlayer.</returns>
        private static RockPlayer GenerateRockPlayer()
        {
            var rockPlayer = new RockPlayer();

            rockPlayer.Cards = new List <RockCard>();

            var rockCard = new RockCard();

            rockCard.CardId = "GAME_005";

            rockPlayer.Cards.Add(rockCard);

            rockPlayer.Hero = GenerateRockHero();
            return(rockPlayer);
        }
Пример #5
0
        /// <summary>
        /// Compute score for using a Card on target.
        /// </summary>
        /// <param name="sceneContext">The RockSceneContext</param>
        /// <param name="cardRockId">The RockId of Card</param>
        /// <param name="targetRockId">The RockId of Target</param>
        /// <returns>The score in double</returns>
        private static double ScoreForUseCardOnTarget(RockSceneContext sceneContext, int cardRockId, int targetRockId)
        {
            double   score = 1; // initial score
            RockCard card  = sceneContext.GetRockCard(cardRockId);

            // adjust score by wasted cost
            int wastedCost = sceneContext.GetMininWastedCost(cardRockId);

            score -= wastedCost * 0.1d;

            switch (card.CardType)
            {
            case RockCardType.Enchantment:
                if (sceneContext.IsEnemy(targetRockId))
                {
                    score -= 1;
                }

                break;

            case RockCardType.Spell:
                if (sceneContext.IsFriendly(targetRockId))
                {
                    score -= 1;
                }

                break;

            case RockCardType.Weapon:
                if (sceneContext.GetFriendlyRockPlayer().HasWeapon)
                {
                    score -= 1;
                }
                else
                {
                    score += 4;
                }

                break;

            default:
                break;
            }

            return(score);
        }
        /// <summary>
        /// Snapshot a card.
        /// </summary>
        /// <param name="card">The Entity.</param>
        /// <returns>The RockCard.</returns>
        private static RockCard SnapshotCard(Entity card)
        {
            var rockCard = new RockCard();

            rockCard.RockId = card.GetEntityId();
            rockCard.Name   = card.GetName();
            rockCard.CardId = card.GetCardId();
            rockCard.Cost   = card.GetCost();
            if (card.IsMinion())
            {
                rockCard.CardType = RockCardType.Minion;
            }
            else if (card.IsSpell())
            {
                rockCard.CardType = RockCardType.Spell;
            }
            else if (card.IsEnchantment())
            {
                rockCard.CardType = RockCardType.Enchantment;
            }
            else if (card.IsWeapon())
            {
                rockCard.CardType = RockCardType.Weapon;
            }
            else
            {
                rockCard.CardType = RockCardType.None;
            }

            rockCard.Damage    = card.GetATK();
            rockCard.Health    = card.IsWeapon() ? card.GetCurrentDurability() : card.GetHealth();
            rockCard.HasTaunt  = card.HasTaunt();
            rockCard.HasCharge = card.HasCharge();
            rockCard.Options   = new List <RockCard>();

            if (card.HasSubCards())
            {
                foreach (var subCardID in card.GetSubCardIDs())
                {
                    rockCard.Options.Add(SnapshotCard(GameState.Get().GetEntity(subCardID)));
                }
            }

            return(rockCard);
        }
Пример #7
0
        /// <summary>
        /// Compute score for using a HeroPower.
        /// </summary>
        /// <param name="sceneContext">The RockSceneContext</param>
        /// <param name="cardRockId">The RockId of HeroPower</param>
        /// <param name="targetRockId">The RockId of Target</param>
        /// <returns>The score in double</returns>
        private static double ScoreForUseMageHeroPower(RockSceneContext sceneContext, int cardRockId, int targetRockId)
        {
            double   score = 4; // initial score
            RockCard card  = sceneContext.GetRockCard(cardRockId);

            // adjust score by wasted cost
            int wastedCost = sceneContext.GetMininWastedCost(cardRockId);

            score -= wastedCost * 0.4d;

            var target = sceneContext.GetRockObject(targetRockId);

            switch (target.ObjectType)
            {
            case RockObjectType.FriendlyHero:
                score -= 5d;
                break;

            case RockObjectType.FriendlyMinion:
                score -= 5d;
                break;

            case RockObjectType.EnemyHero:
                score += 0.1d;
                break;

            case RockObjectType.EnemyMinion:
                score += 0.1d;
                if (((RockMinion)target.Object).Health < 2)
                {
                    score += ((RockMinion)target.Object).Damage;
                }

                break;

            default:
                break;
            }

            return(score);
        }