public void AddAttribute(KeywordAttribute attribute) { if (!attributes.Contains(attribute)) { attributes.Add(attribute); } }
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); }
public bool HasKeyword(KeywordAttribute keyword) { if (card) { return(card.cardData.HasKeywordAttribute(keyword)); } return(false); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public KeywordModifier() { keywordAttribute = KeywordAttribute.NONE; }
public KeywordModifier(KeywordAttribute keyword, Creature source) : base(source) { keywordAttribute = keyword; }
public KeywordModifier(KeywordAttribute keyword, DurationType duration) : base(duration) { keywordAttribute = keyword; }
public override bool HasKeywordAttribute(KeywordAttribute keyword) { return(attributes.Exists(x => x == keyword)); }
public virtual bool HasKeywordAttribute(KeywordAttribute keyword) { return(false); }