예제 #1
0
 public void AddAttribute(KeywordAttribute attribute)
 {
     if (!attributes.Contains(attribute))
     {
         attributes.Add(attribute);
     }
 }
예제 #2
0
    public static double GetKeywordCost(KeywordAttribute keyword, int atk, int def)
    {
        switch (keyword)
        {
        case KeywordAttribute.NONE:
            return(0);

        case KeywordAttribute.EVASION:
            return((atk / 2.0 + 0.5) * UNIT_COST);

        case KeywordAttribute.FAST_STRIKE:
            return(atk / 3.0 * UNIT_COST);

        case KeywordAttribute.PIERCING:
            return(0.5 * (atk / 2.0 + def / 3.0) * UNIT_COST);

        case KeywordAttribute.UNTOUCHABLE:
            return(UNIT_COST);

        case KeywordAttribute.EAGER:
            return(UNIT_COST * 0.75);
        }

        // If we have not defined a cost function return a really high cost so we don't generate this effect
        Debug.Log("Cost not defined for " + keyword.ToString());
        return(ManaFunction(20) * UNIT_COST);
    }
예제 #3
0
 public bool HasKeyword(KeywordAttribute keyword)
 {
     if (card)
     {
         return(card.cardData.HasKeywordAttribute(keyword));
     }
     return(false);
 }
예제 #4
0
        public void TestConstructor()
        {
            var maxLength   = 10;
            var maxKeywords = 5;
            var attribute   = new KeywordAttribute(maxKeywords, maxLength);

            Assert.AreEqual(maxKeywords, attribute.MaxNumberOfKeywords);
            Assert.AreEqual(maxLength, attribute.MaxKeywordLength);
        }
예제 #5
0
    public bool HasKeywordAttribute(KeywordAttribute keyword)
    {
        bool hasKeyword = baseCard.HasKeywordAttribute(keyword);

        foreach (IModifier mod in modifiers)
        {
            if (mod is KeywordModifier keywordMod)
            {
                if (keyword == keywordMod.keywordAttribute)
                {
                    hasKeyword = true;
                }
            }
        }

        return(hasKeyword);
    }
예제 #6
0
        public void TestIsValid_KeywordExceedsLength()
        {
            var maxLength   = 5;
            var maxKeywords = 5;
            var attribute   = new KeywordAttribute(maxKeywords, maxLength);

            var searchTerm = new String('s', maxLength);
            var isValid    = attribute.IsValid(new List <string> {
                searchTerm
            });

            Assert.IsTrue(isValid);

            isValid = attribute.IsValid(new List <string> {
                searchTerm + "s"
            });
            Assert.IsFalse(isValid);
        }
예제 #7
0
    public static CardTags GetCardTagsFromKeywordAttributes(KeywordAttribute keyword)
    {
        switch (keyword)
        {
        case KeywordAttribute.EVASION:
            return(CardTags.EVASION);

        case KeywordAttribute.FAST_STRIKE:
            return(CardTags.FAST_STRIKE);

        case KeywordAttribute.UNTOUCHABLE:
            return(CardTags.UNTOUCHABLE);

        case KeywordAttribute.PIERCING:
            return(CardTags.PIERCING);

        case KeywordAttribute.EAGER:
            return(CardTags.EAGER);
        }
        return(CardTags.NONE);
    }
예제 #8
0
        public void TestIsValid_ToManyKeywords()
        {
            var maxLength   = 5;
            var maxKeywords = 5;
            var attribute   = new KeywordAttribute(maxKeywords, maxLength);

            var searchTerm  = new String('s', maxLength);
            var searchTerms = new List <string>();

            for (var i = 0; i < maxKeywords; i++)
            {
                searchTerms.Add(searchTerm);
            }

            var isValid = attribute.IsValid(searchTerms);

            Assert.IsTrue(isValid);

            searchTerms.Add(searchTerm);
            isValid = attribute.IsValid(searchTerms);
            Assert.IsFalse(isValid);
        }
예제 #9
0
    static public string Parse(KeywordAttribute a)
    {
        switch (a)
        {
        case KeywordAttribute.NONE:
            return("<NONE>");

        case KeywordAttribute.EVASION:
            return("Evasive");

        case KeywordAttribute.FAST_STRIKE:
            return("Deft");

        case KeywordAttribute.PIERCING:
            return("Excessive");

        case KeywordAttribute.UNTOUCHABLE:
            return("Untouchable");

        case KeywordAttribute.EAGER:
            return("Eager");
        }
        return(PARSE_ERROR);
    }
예제 #10
0
    static private CardDescription GenerateCreatureCard(System.Random random, IHistogram model, ImageGlossary images, CreatureModelIndex creatureModels, NameModel nameModel, CardGenerationFlags flags)
    {
        CreatureCardDescription card = ScriptableObject.CreateInstance(typeof(CreatureCardDescription)) as CreatureCardDescription;

        card.creatureType = ProceduralUtils.GetRandomValue <CreatureType>(random, model);

        if ((flags & CardGenerationFlags.HUMAN) == CardGenerationFlags.HUMAN)
        {
            card.creatureType = CreatureType.HUMAN;
        }
        else if ((flags & CardGenerationFlags.GOBLIN) == CardGenerationFlags.GOBLIN)
        {
            card.creatureType = CreatureType.GOBLIN;
        }
        else if ((flags & CardGenerationFlags.FAERIE) == CardGenerationFlags.FAERIE)
        {
            card.creatureType = CreatureType.FAERIE;
        }

        MultiCardHistogram combinedModel = ScriptableObject.CreateInstance(typeof(MultiCardHistogram)) as MultiCardHistogram;

        combinedModel.Init(new IHistogram[] { model, creatureModels.GetModel(card.creatureType) });

        card.manaCost = (int)ProceduralUtils.GetRandomValue <ManaCost>(random, model);

        // Potentially generate a stronger body, but with a drawback
        double bodyManaCost = GetCreatureBodyBudget(creatureModels.GetBodyLambda(card.creatureType), random.Next(), card.manaCost + 1);
        int    maxStats     = PowerBudget.StatBudget(bodyManaCost);

        // Decide on stats
        card.health = GetHealth(random, creatureModels.GetStatProbability(card.creatureType, (int)Math.Round(bodyManaCost, MidpointRounding.AwayFromZero)), maxStats);
        card.attack = maxStats - card.health;

        // Decide on power budget
        double powerBudget = PowerBudget.ManaPowerBudgets[card.manaCost];
        double powerMargin = PowerBudget.ManaPowerMargin[card.manaCost];
        double powerLimit  = PowerBudget.ManaPowerLimit[card.manaCost];

        card.cardName = "A creature card";
        //card.name += "(" + powerBudget.ToString() + ")";

        // Decide on keyword attributes
        int maxKeywords = 3;

        for (int i = 0; i < maxKeywords; i++)
        {
            double keywordPowerLimit = powerLimit - card.PowerLevel();
            if (keywordPowerLimit < 0)
            {
                keywordPowerLimit = 0;
            }
            KeywordAttribute keyword = ProceduralUtils.GetRandomValue(random, combinedModel, ProceduralUtils.GetKeywordsWithinBudget(keywordPowerLimit, card.attack, card.health));
            if (keyword == KeywordAttribute.NONE)
            {
                break;
            }
            card.AddAttribute(keyword);
        }

        // Decide on effects
        GenerateCardEffects(random, combinedModel, creatureModels, card, powerBudget, powerMargin, powerLimit);

        // Revise the mana cost based on what effects we actually did generate
        int revisedMana = PowerBudget.PowerLevelToMana(card.PowerLevel());

        if (revisedMana != card.manaCost)
        {
            Debug.Log("Had to revise the mana cost from " + card.manaCost.ToString() + " to " + revisedMana.ToString());
            card.manaCost = revisedMana;
        }
        card.image = ProceduralUtils.GetRandomTexture(random, images.GetCreatureImages(card.creatureType));

        CardTags tags = CardTagging.GetCardTags(card);

        card.cardName = nameModel.GenerateName(random, tags);

        return(card);
    }
예제 #11
0
 public KeywordModifier()
 {
     keywordAttribute = KeywordAttribute.NONE;
 }
예제 #12
0
 public KeywordModifier(KeywordAttribute keyword, Creature source) : base(source)
 {
     keywordAttribute = keyword;
 }
예제 #13
0
 public KeywordModifier(KeywordAttribute keyword, DurationType duration) : base(duration)
 {
     keywordAttribute = keyword;
 }
예제 #14
0
 public override bool HasKeywordAttribute(KeywordAttribute keyword)
 {
     return(attributes.Exists(x => x == keyword));
 }
예제 #15
0
 public virtual bool HasKeywordAttribute(KeywordAttribute keyword)
 {
     return(false);
 }