Example #1
0
 internal Equipment(EquipmentId id,
                    EquipmentClass eClass,
                    BonusType bonusType,
                    EquipmentRarity rarity,
                    double attributeBase,
                    double attributeBaseInc,
                    double attributeExp1,
                    double attributeExp2,
                    double attributeExpBase,
                    EquipmentSource source,
                    double[] _1163,
                    double[] _2095,
                    double[] _4450,
                    string fileVersion,
                    Func <string, ValueTask <Bitmap> > imageGetter = null)
 {
     Id               = id;
     Class            = eClass;
     BonusType        = bonusType;
     Rarity           = rarity;
     AttributeBase    = attributeBase;
     AttributeBaseInc = attributeBaseInc;
     AttributeExp1    = attributeExp1;
     AttributeExp2    = attributeExp2;
     AttributeExpBase = attributeExpBase;
     Source           = source;
     this._1163       = _1163;
     this._2095       = _2095;
     this._4450       = _4450;
     FileVersion      = fileVersion;
     ImageGetter      = imageGetter;
 }
Example #2
0
 public ChestMarker(int id, string name, int movementCost, EquipmentRarity rarity, Texture2D texture)
     : base(id, name, texture, movementCost)
 {
     Contract.Requires(name != null);
     Contract.Requires(name.Length > 0);
     Contract.Requires(movementCost >= 0);
     this.rarity = rarity;
 }
Example #3
0
 public Chest(int id, string name, EquipmentRarity rarity, Equipment equipment, Potion potion, int coin)
 {
     this.id = id;
     this.rarity = rarity;
     this.equipment = equipment;
     this.potion = potion;
     this.coin = coin;
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Treasure"/> class.
 /// </summary>
 /// <param name="id">
 /// The id of the treasure
 /// </param>
 /// <param name="name">
 /// The name of the treasure
 /// </param>
 /// <param name="rarity">
 /// The rarity of the treasure
 /// </param>
 /// <param name="equipment">
 /// The equipment equipment in the treasure
 /// </param>
 /// <param name="coins">
 /// The amount of coins in the treasure
 /// </param>
 public Treasure(int id, string name, EquipmentRarity rarity, Equipment equipment, int coins)
 {
     this.id = id;
     this.name = name;
     this.rarity = rarity;
     this.equipment = equipment;
     this.coins = coins;
 }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Chest"/> class.
 /// </summary>
 /// <param name="id">
 /// The id of the chest
 /// </param>
 /// <param name="rarity">
 /// The rarity of the chest (copper, silver and gold)
 /// </param>
 /// <param name="conquestTokens">
 /// The conquest tokens in the chest
 /// </param>
 /// <param name="coin">
 /// The coins in the chest
 /// </param>
 /// <param name="curses">
 /// The curses in the chest
 /// </param>
 /// <param name="treasures">
 /// The treasures in the chest
 /// </param>
 public Chest(int id, EquipmentRarity rarity, int conquestTokens, int coin, int curses, int treasures)
 {
     this.id = id;
     this.rarity = rarity;
     this.tokens = conquestTokens;
     this.coin = coin;
     this.curses = curses;
     this.treasures = treasures;
 }
Example #6
0
 public ChestMarker Constructor(
     int id,
     string name,
     int movementCost,
     EquipmentRarity rarity,
     Texture2D texture
 )
 {
     ChestMarker target = new ChestMarker(id, name, movementCost, rarity, texture);
     return target;
     // TODO: add assertions to method ChestMarkerTest.Constructor(Int32, String, Int32, EquipmentRarity, Texture2D)
 }
Example #7
0
 internal Equipment(EquipmentStatic staticData, EquipmentClass eClass, BonusType bonusType, EquipmentRarity rarity, double bonusBase, double bonusIncrease, EquipmentSource source, Bitmap image, string fileVersion)
 {
     _staticData   = staticData;
     Class         = eClass;
     BonusType     = bonusType;
     Rarity        = rarity;
     BonusBase     = bonusBase;
     BonusIncrease = bonusIncrease;
     Source        = source;
     Image         = image;
     FileVersion   = fileVersion;
 }
Example #8
0
 public Chest Constructor(
     int id,
     EquipmentRarity rarity,
     int conquestTokens,
     int coin,
     int curses,
     int treasures
 )
 {
     Chest target = new Chest(id, rarity, conquestTokens, coin, curses, treasures);
     return target;
     // TODO: add assertions to method ChestTest.Constructor(Int32, EquipmentRarity, Int32, Int32, Int32, Int32)
 }
Example #9
0
        public Affix GetAffix(EquipmentModifiers equipmentModifiers, CurrencyModifiers currencyModifiers, List <Affix> affixes, EquipmentRarity rarity, IRandom random)
        {
            PoolKey key = new PoolKey(equipmentModifiers, currencyModifiers);

            if (!_poolDic.ContainsKey(key))
            {
                _poolDic.Add(key, GenerateAffixPool(equipmentModifiers, currencyModifiers));
            }

            AffixPool pool           = _poolDic[key];
            var       existingGroups = new HashSet <string>(affixes.Select(x => x.Group));

            int affixesCount = rarity == EquipmentRarity.Normal ? 0 :
                               rarity == EquipmentRarity.Magic ? 1 :
                               rarity == EquipmentRarity.Rare ? 3 : 0;

            double prefixSkipAmount = CalculateSkipAmount("prefix", pool.PrefixWeight, pool.PrefixGroupWeights, affixes, affixesCount);
            double suffixSkipAmount = CalculateSkipAmount("suffix", pool.SuffixWeight, pool.SuffixGroupWeights, affixes, affixesCount);

            var targetWeight = random.NextDouble() * (pool.TotalWeight - prefixSkipAmount - suffixSkipAmount);

            return(GetRandomAffixFromPool(pool, targetWeight, existingGroups, prefixSkipAmount, suffixSkipAmount));
        }
Example #10
0
 public int GetAffixCap(EquipmentRarity rarity)
 {
     return(MightBeRarity(EquipmentRarity.Rare) ? 3 :
            MightBeRarity(EquipmentRarity.Magic) ? 1 : 0);
 }
Example #11
0
 public bool MightBeRarity(EquipmentRarity rarity)
 {
     return((Rarity & rarity) != rarity);
 }
Example #12
0
 public bool IsRarity(EquipmentRarity rarity)
 {
     return(this.Rarity == rarity);
 }
Example #13
0
 public Treasure[] getTreasures(int numberOfTreasures, EquipmentRarity rarity)
 {
     return treasures.Where(treasure => treasure.Rarity == rarity).OrderBy(t => random.Next()).Take(numberOfTreasures).ToArray();
 }
Example #14
0
        public Affix GetAffix(List <Affix> affixes, EquipmentRarity rarity, IRandom random, List <Fossil> fossils = null)
        {
            if (fossils == null)
            {
                fossils = new List <Fossil>();
            }

            var addedTags   = affixes.SelectMany(x => x.AddsTags).Distinct().ToList();
            var fossilNames = fossils.Select(x => x.FullName).Distinct().ToList();

            var masterMods = affixes.Where(x => x.Group.Contains(NoAttackMods) || x.Group.Contains(NoCasterMods)).Select(x => x.Group).ToList();

            PoolKey key = new PoolKey(addedTags, fossilNames, masterMods);

            if (!_poolDic.ContainsKey(key))
            {
                _poolDic.Add(key, GenerateAffixPool(addedTags, fossils, masterMods));
            }

            AffixPool pool           = _poolDic[key];
            var       existingGroups = new HashSet <string>(affixes.Select(x => x.Group));

            int affixesCount = rarity == EquipmentRarity.Normal ? 0 :
                               rarity == EquipmentRarity.Magic ? 1 :
                               rarity == EquipmentRarity.Rare ? 3 : 0;

            double prefixSkipAmount = 0;
            double suffixSkipAmount = 0;

            if (affixes.Count(x => x.GenerationType == "prefix") >= affixesCount)
            {
                prefixSkipAmount = pool.PrefixWeight;
            }
            else
            {
                prefixSkipAmount = affixes
                                   .Select(x => x.Group)
                                   .Where(x => pool.PrefixGroupWeights.ContainsKey(x))
                                   .Sum(x => pool.PrefixGroupWeights[x]);
            }

            if (affixes.Count(x => x.GenerationType == "suffix") >= affixesCount)
            {
                suffixSkipAmount = pool.SuffixWeight;
            }
            else
            {
                suffixSkipAmount = affixes
                                   .Select(x => x.Group)
                                   .Where(x => pool.SuffixGroupWeights.ContainsKey(x))
                                   .Sum(x => pool.SuffixGroupWeights[x]);
            }

            var totalWeight = pool.TotalWeight;

            totalWeight -= prefixSkipAmount;
            totalWeight -= suffixSkipAmount;

            var targetWeight = random.NextDouble() * totalWeight;

            return(GetRandomAffixFromPool(pool, targetWeight, existingGroups, prefixSkipAmount, suffixSkipAmount));
        }
Example #15
0
 public static LocalisedString Localisable(EquipmentRarity rarity)
 => new LocalisedString(BASE_PATH + rarity.ToString().ToUpper());
Example #16
0
 public Equipment Build(EquipmentClass eClass, BonusType bonusType, EquipmentRarity rarity, double bonusBase, double bonusIncrease, EquipmentSource source, Bitmap image, string fileVersion)
 {
     return(new Equipment(this, eClass, bonusType, rarity, bonusBase, bonusIncrease, source, image, fileVersion));
 }
Example #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Equipment"/> class.
 /// </summary>
 /// <param name="id">
 /// The unique id of the equipment
 /// </param>
 /// <param name="name">
 /// The name of the equipment
 /// </param>
 /// <param name="type">
 /// The equipments type
 /// </param>
 /// <param name="attackType">
 /// The attack type of the equipment
 /// </param>
 /// <param name="rarity">
 /// The rarity of the equipment
 /// </param>
 /// <param name="buyPrice">
 /// The buy price of the equipment
 /// This is 0 if the equipments rarity is not common
 /// </param>
 /// <param name="surgeAbilities">
 /// The surge abilities, if the equipment is a weapon
 /// </param>
 /// <param name="hands">
 /// The number of hands it takes to wield, if the equipment is a weapon
 /// </param>
 /// <param name="abilities">
 /// The abilities that the equipment have
 /// </param>
 /// <param name="dice">
 /// The dice that the equipment has
 /// </param>
 public Equipment(int id, string name, EquipmentType type, EAttackType attackType, EquipmentRarity rarity, int buyPrice, List<SurgeAbility> surgeAbilities, int hands, List<Ability> abilities, List<Dice> dice)
 {
     Contract.Requires(surgeAbilities != null);
     Contract.Requires(abilities != null);
     this.id = id;
     this.name = name;
     this.type = type;
     this.attackType = attackType;
     this.rarity = rarity;
     this.buyPrice = rarity == EquipmentRarity.Common ? buyPrice : 0;
     this.surgeAbilities = surgeAbilities;
     this.hands = hands;
     this.abilities = abilities;
     this.dice = dice ?? new List<Dice>();
     tapped = false;
 }
Example #18
0
        private void EvaluateRarity(List <ICraftingStep> craftingSteps, EquipmentRarity rarity)
        {
            StatusMetadata metadata = _statusManager.Evaluate(craftingSteps);

            Assert.IsTrue(metadata.CurrentStatus.Rarity == rarity);
        }
Example #19
0
        public Affix GetInfluenceAffix(Influence influence, EquipmentModifiers equipmentModifiers, List <Affix> affixes, EquipmentRarity rarity, IRandom random)
        {
            var existingGroups = new HashSet <string>(affixes.Select(x => x.Group));

            int affixesCount = rarity == EquipmentRarity.Normal ? 0 :
                               rarity == EquipmentRarity.Magic ? 1 :
                               rarity == EquipmentRarity.Rare ? 3 : 0;

            HashSet <string> fullGenTypes = new HashSet <string>();

            if (affixes.Count(x => x.GenerationType == "suffix") >= affixesCount)
            {
                fullGenTypes.Add("suffix");
            }
            if (affixes.Count(x => x.GenerationType == "prefix") >= affixesCount)
            {
                fullGenTypes.Add("prefix");
            }

            var pool = _influenceAffixes[influence]
                       .Where(x => x.RequiredLevel <= equipmentModifiers.ItemLevel)
                       .Where(x => !existingGroups.Contains(x.Group))
                       .Where(x => !fullGenTypes.Contains(x.GenerationType))
                       .ToList();

            var tag = _influenceTags[influence];

            var currentWeight = pool.Sum(x => x.SpawnWeights[tag]);
            var randomValue   = random.Next(currentWeight);

            foreach (var affix in pool)
            {
                currentWeight -= affix.Weight;
                if (randomValue < currentWeight)
                {
                    return(affix);
                }
            }
            throw new InvalidOperationException("An affix should have been selected");
        }
Example #20
0
 public int GetRandomChestID(EquipmentRarity rarity)
 {
     Random r = new Random(DateTime.Now.Millisecond);
     int n = chestsLeft.Count(c => c.Rarity == rarity);
     Chest chest = chestsLeft.Where(c1 => c1.Rarity == rarity).ToArray()[r.Next(n)];
     return chest.Id;
 }
Example #21
0
 public static ILocalisable <string> ToLocalisable(this EquipmentRarity rarity)
 => EquipmentRarityText.Localisable(rarity);