Esempio n. 1
0
 public LaserWeapon(CompleteStructure structure, RealLiveBlock block, WeaponConstants constants)
     : base(structure, block, constants)
 {
     _particles = Turret.GetComponent <ParticleSystem>();
     ParticleSystem.ShapeModule shape = _particles.shape;
     shape.position = Constants.TurretOffset;
 }
Esempio n. 2
0
        public void SelectWithQuantityOf0_Thrown(string weapon)
        {
            var thrown = WeaponConstants.GetAllThrown(false, false);
            var simple = WeaponConstants.GetAllSimple(false, false);
            var melee  = WeaponConstants.GetAllMelee(false, false);

            var thrownRanged = thrown.Except(melee).Intersect(simple);

            Assert.That(thrownRanged, Contains.Item(weapon)
                        .And.EquivalentTo(new[]
            {
                WeaponConstants.Javelin,
                WeaponConstants.Dart,
            }));

            var item = itemSelector.SelectFrom($"{weapon}[{ItemTypeConstants.Weapon}]");

            Assert.That(item.Name, Is.EqualTo(weapon), weapon);
            Assert.That(item.ItemType, Is.EqualTo(ItemTypeConstants.Weapon), weapon);
            Assert.That(item.Traits, Is.Empty, weapon);
            Assert.That(item.Magic.SpecialAbilities, Is.Empty, weapon);
            Assert.That(item.Magic.Bonus, Is.Zero, weapon);
            Assert.That(item.IsMagical, Is.False, weapon);
            Assert.That(item.Quantity, Is.Zero, weapon);
        }
Esempio n. 3
0
        public void WeaponPowerGroupsMatch(string itemName)
        {
            var possiblePowers = new List <string>();
            var powers         = table[ItemTypeConstants.Weapon];

            possiblePowers.AddRange(powers);

            var generalWeapons = WeaponConstants.GetAllWeapons(false, true);
            var cursed         = percentileSelector.SelectAllFrom(TableNameConstants.Percentiles.Set.SpecificCursedItems);

            if (!generalWeapons.Contains(itemName))
            {
                possiblePowers.Remove(PowerConstants.Mundane);

                if (!cursed.Contains(itemName))
                {
                    foreach (var power in powers.Except(new[] { PowerConstants.Mundane }))
                    {
                        var tableName = string.Format(TableNameConstants.Percentiles.Formattable.POWERSpecificITEMTYPEs, power, ItemTypeConstants.Weapon);
                        var results   = typeAndAmountPercentileSelector.SelectAllFrom(tableName);

                        if (!results.Any(r => NameMatchesWithReplacements(r.Type, itemName)))
                        {
                            possiblePowers.Remove(power);
                        }
                    }
                }
            }

            base.Collections(itemName, possiblePowers.ToArray());
        }
Esempio n. 4
0
        public void AllWeaponsAreInTable()
        {
            var weapons = WeaponConstants.GetAllWeapons(false, false);
            var keys    = GetKeys();

            AssertCollection(keys, weapons);
        }
Esempio n. 5
0
        public void MartialWeaponProficiencyFoci()
        {
            var foci       = WeaponConstants.GetAllMartial(false, false);
            var ammunition = WeaponConstants.GetAllAmmunition(false, false);

            foci = foci.Except(ammunition);
            base.AssertDistinctCollection(FeatConstants.WeaponProficiency_Martial, foci.ToArray());
        }
Esempio n. 6
0
        public void SlashingWeaponsMatchConstants(string weapon)
        {
            var slashing    = WeaponConstants.GetAllSlashing(false, false);
            var isSlashing  = slashing.Contains(weapon);
            var hasSlashing = table[weapon].All(d => d.Contains(AttributeConstants.DamageTypes.Slashing));

            Assert.That(hasSlashing, Is.EqualTo(isSlashing), weapon);
        }
Esempio n. 7
0
        public void BludgeoningWeaponsMatchConstants(string weapon)
        {
            var bludgeoning    = WeaponConstants.GetAllBludgeoning(false, false);
            var isBludgeoning  = bludgeoning.Contains(weapon);
            var hasBludgeoning = table[weapon].All(d => d.Contains(AttributeConstants.DamageTypes.Bludgeoning));

            Assert.That(hasBludgeoning, Is.EqualTo(isBludgeoning), weapon);
        }
Esempio n. 8
0
        public Item SelectFrom(string source)
        {
            var template = new Item();

            template.Name = source;
            template.Name = itemTypeRegex.Replace(template.Name, string.Empty);
            template.Name = itemBonusRegex.Replace(template.Name, string.Empty);
            template.Name = specialAbilityRegex.Replace(template.Name, string.Empty);
            template.Name = traitRegex.Replace(template.Name, string.Empty);
            template.Name = isMagicRegex.Replace(template.Name, string.Empty);

            template.ItemType = GetMatchValue(itemTypeRegex, source, "[", "]");

            if (isMagicRegex.IsMatch(source))
            {
                var rawIsMagic = GetMatchValue(isMagicRegex, source, "@", "@");
                template.IsMagical = Convert.ToBoolean(rawIsMagic);
            }

            if (itemBonusRegex.IsMatch(source))
            {
                var rawBonus = GetMatchValue(itemBonusRegex, source, "(", ")");
                template.Magic.Bonus = Convert.ToInt32(rawBonus);
            }

            if (specialAbilityRegex.IsMatch(source))
            {
                var rawSpecialAbilities = GetMatchValue(specialAbilityRegex, source, "{", "}");
                var specialAbilities    = rawSpecialAbilities.Split(',');
                template.Magic.SpecialAbilities = GetSpecialAbilities(specialAbilities);
            }

            if (traitRegex.IsMatch(source))
            {
                var rawTraits = GetMatchValue(traitRegex, source, "#");
                var traits    = rawTraits.Split(',');

                foreach (var trait in traits)
                {
                    template.Traits.Add(trait);
                }
            }

            var ammunition         = WeaponConstants.GetAllAmmunition(false, false);
            var thrown             = WeaponConstants.GetAllThrown(false, false);
            var simple             = WeaponConstants.GetAllSimple(false, false);
            var melee              = WeaponConstants.GetAllMelee(false, false);
            var thrownRanged       = thrown.Except(melee).Intersect(simple);
            var needRandomQuantity = ammunition.Union(thrownRanged);

            if (needRandomQuantity.Contains(template.Name))
            {
                template.Quantity = 0;
            }

            return(template);
        }
Esempio n. 9
0
        public void AllKeysArePresent()
        {
            var weapons          = WeaponConstants.GetAllWeapons(false, false);
            var specialAbilities = SpecialAbilityConstants.GetAllAbilities(true);

            var expectedKeys = weapons.Union(specialAbilities);
            var actualKeys   = GetKeys();

            AssertCollection(actualKeys, expectedKeys);
        }
Esempio n. 10
0
        protected WeaponSystem(CompleteStructure structure, RealLiveBlock block, WeaponConstants constants)
            : base(structure, block)
        {
            Constants = constants;
            Turret    = block.transform.Find("Turret");

            if (!NetworkUtils.IsServer && !NetworkUtils.IsLocal(Structure.Id))
            {
                _turretRotationMultiplier *= 1.25f;
            }
        }
Esempio n. 11
0
        public void BUG_OversizedWeaponHasCorrectAttackDamage(string creatureName)
        {
            var creature = creatureGenerator.Generate(creatureName, CreatureConstants.Templates.None);

            creatureAsserter.AssertCreature(creature);
            Assert.That(creature.Equipment, Is.Not.Null);
            Assert.That(creature.Equipment.Weapons, Is.Not.Empty.And.All.Not.Null);

            var oversizedFeat = creature.SpecialQualities.FirstOrDefault(sq => sq.Name == FeatConstants.SpecialQualities.OversizedWeapon);

            Assert.That(oversizedFeat, Is.Not.Null);
            Assert.That(oversizedFeat.Foci, Is.Not.Empty);
            Assert.That(oversizedFeat.Foci.Count(), Is.EqualTo(1));

            var oversizedSize = oversizedFeat.Foci.First();

            var weaponNames      = WeaponConstants.GetAllWeapons(true, false);
            var unnaturalAttacks = creature.Attacks.Where(a => !a.IsNatural && weaponNames.Contains(a.Name));

            foreach (var attack in unnaturalAttacks)
            {
                var weapon = creature.Equipment.Weapons.FirstOrDefault(w => w.Name == attack.Name);
                Assert.That(weapon, Is.Not.Null, $"{creature.Summary}: {attack.Name}");
                Assert.That(weapon.DamageDescription, Is.Not.Empty, $"{creature.Summary}: {weapon.Description}");
                Assert.That(weaponNames, Contains.Item(weapon.Name), $"{creature.Summary}: {weapon.Description}");

                Assert.That(attack.Damages, Is.Not.Empty.And.Count.EqualTo(weapon.Damages.Count), $"{creature.Summary}; Weapon: {weapon.Description}");

                for (var i = 0; i < weapon.Damages.Count; i++)
                {
                    if (i == 0)
                    {
                        Assert.That(attack.DamageDescription, Contains.Substring(weapon.Damages[i].Roll), $"{creature.Summary}; Weapon: {weapon.Description}");
                        Assert.That(attack.DamageDescription, Contains.Substring(weapon.Damages[i].Type), $"{creature.Summary}; Weapon: {weapon.Description}");
                        Assert.That(attack.DamageDescription, Contains.Substring(weapon.Damages[i].Condition), $"{creature.Summary}; Weapon: {weapon.Description}");
                    }
                    else
                    {
                        Assert.That(attack.DamageDescription, Contains.Substring(weapon.Damages[i].Description), $"{creature.Summary}; Weapon: {weapon.Description}");
                    }
                }

                if (weapon.Attributes.Contains(AttributeConstants.Melee))
                {
                    Assert.That(attack.AttackType, Contains.Substring("melee"), $"{creature.Summary} ({creature.Size}): {weapon.Description} ({weapon.Size}) [Oversized: {oversizedSize}]");
                }
                else if (weapon.Attributes.Contains(AttributeConstants.Ranged))
                {
                    Assert.That(attack.AttackType, Contains.Substring("ranged"), $"{creature.Summary} ({creature.Size}): {weapon.Description} ({weapon.Size}) [Oversized: {oversizedSize}]");
                }
            }
        }
Esempio n. 12
0
        private void VerifyAttribute(IEnumerable <string> weaponsWith, string attribute)
        {
            var keys = GetKeys();

            var entriesWith    = table.Where(kvp => kvp.Value.Contains(attribute));
            var entriesWithout = table.Except(entriesWith);

            var weapons        = WeaponConstants.GetAllWeapons(false, false);
            var weaponsWithout = weapons.Except(weaponsWith);

            AssertCollection(entriesWith.Select(kvp => kvp.Key), weaponsWith);
            AssertCollection(entriesWithout.Select(kvp => kvp.Key), weaponsWithout);
        }
Esempio n. 13
0
        private IEnumerable <string> GetGear(string gearType)
        {
            switch (gearType)
            {
            case ItemTypeConstants.Weapon: return(WeaponConstants.GetAllSpecific());

            case ItemTypeConstants.Armor: return(ArmorConstants.GetAllSpecificArmors());

            case AttributeConstants.Shield: return(ArmorConstants.GetAllSpecificShields());

            default: throw new ArgumentException($"{gearType} is not a valid specific gear type");
            }
        }
Esempio n. 14
0
        public void DoubleWeaponsHaveMultipleDamages(string weapon)
        {
            var doubleWeapons = WeaponConstants.GetAllDouble(false, false);
            var isDouble      = doubleWeapons.Contains(weapon);
            var damageData    = table[weapon].Select(d => damageHelper.ParseEntries(d));

            if (isDouble)
            {
                Assert.That(damageData, Is.All.Length.EqualTo(2), weapon);
            }
            else
            {
                Assert.That(damageData, Is.All.Length.EqualTo(1), weapon);
            }
        }
Esempio n. 15
0
        private List <string> GetRangedWithBowTemplates()
        {
            var ranged = WeaponConstants.GetAllRanged(false, true, false).ToList();
            var ammo   = WeaponConstants.GetAllAmmunition(false, false);

            ranged.Remove(WeaponConstants.CompositeShortbow);
            ranged.Remove(WeaponConstants.CompositeLongbow);
            ranged = ranged.Except(ammo).ToList();

            if (!ranged.Contains(WeaponConstants.Shuriken))
            {
                ranged.Add(WeaponConstants.Shuriken);
            }

            return(ranged);
        }
Esempio n. 16
0
        private string GetRandomItemName(string itemType)
        {
            var itemNames = Enumerable.Empty <string>();

            switch (itemType)
            {
            case ItemTypeConstants.AlchemicalItem:
                itemNames = AlchemicalItemConstants.GetAllAlchemicalItems(); break;

            case ItemTypeConstants.Armor:
                itemNames = ArmorConstants.GetAllArmorsAndShields(true); break;

            case ItemTypeConstants.Potion:
                itemNames = PotionConstants.GetAllPotions(true); break;

            case ItemTypeConstants.Ring:
                itemNames = RingConstants.GetAllRings(); break;

            case ItemTypeConstants.Rod:
                itemNames = RodConstants.GetAllRods(); break;

            case ItemTypeConstants.Scroll:
                itemNames = new[] { $"Scroll {Guid.NewGuid()}" }; break;

            case ItemTypeConstants.Staff:
                itemNames = StaffConstants.GetAllStaffs(); break;

            case ItemTypeConstants.Tool:
                itemNames = ToolConstants.GetAllTools(); break;

            case ItemTypeConstants.Wand:
                itemNames = new[] { $"Wand {Guid.NewGuid()}" }; break;

            case ItemTypeConstants.Weapon:
                itemNames = WeaponConstants.GetAllWeapons(true, true); break;

            case ItemTypeConstants.WondrousItem:
                itemNames = WondrousItemConstants.GetAllWondrousItems(); break;
            }

            var itemName = collectionSelector.SelectRandomFrom(itemNames);

            return(itemName);
        }
Esempio n. 17
0
        private void VerifyFeats(Creature creature)
        {
            Assert.That(creature.Feats, Is.Not.Null, creature.Summary);
            Assert.That(creature.SpecialQualities, Is.Not.Null, creature.Summary);

            var weapons  = WeaponConstants.GetAllWeapons(false, false);
            var allFeats = creature.Feats.Union(creature.SpecialQualities);

            foreach (var feat in allFeats)
            {
                var message = $"Creature: {creature.Summary}\nFeat: {feat.Name}";

                Assert.That(feat.Name, Is.Not.Empty, message);
                Assert.That(feat.Foci, Is.Not.Null, message);
                Assert.That(feat.Foci, Is.All.Not.Null, message);
                Assert.That(feat.Foci, Is.All.Not.EqualTo(FeatConstants.Foci.NoValidFociAvailable), message);
                Assert.That(feat.Power, Is.Not.Negative, message);
                Assert.That(feat.Frequency.Quantity, Is.Not.Negative, message);
                Assert.That(feat.Frequency.TimePeriod, Is.EqualTo(FeatConstants.Frequencies.Constant)
                            .Or.EqualTo(FeatConstants.Frequencies.AtWill)
                            .Or.EqualTo(FeatConstants.Frequencies.Hit)
                            .Or.EqualTo(FeatConstants.Frequencies.Round)
                            .Or.EqualTo(FeatConstants.Frequencies.Minute)
                            .Or.EqualTo(FeatConstants.Frequencies.Hour)
                            .Or.EqualTo(FeatConstants.Frequencies.Day)
                            .Or.EndsWith(FeatConstants.Frequencies.Day)
                            .Or.EqualTo(FeatConstants.Frequencies.Week)
                            .Or.EqualTo(FeatConstants.Frequencies.Month)
                            .Or.EqualTo(FeatConstants.Frequencies.Year)
                            .Or.EqualTo(FeatConstants.Frequencies.Life)
                            .Or.Empty, message);

                if (!creature.CanUseEquipment)
                {
                    var weaponFoci = feat.Foci.Intersect(weapons);
                    Assert.That(weaponFoci, Is.Empty, message);

                    //TODO: Also should assert that equipment is empty, but equipment does not exist on creatures yet
                    //add it once we have added that
                }
            }
        }
Esempio n. 18
0
        public void SelectWithQuantityOf0_Ammunition(string ammo)
        {
            var ammos = WeaponConstants.GetAllAmmunition(false, false);

            Assert.That(ammos, Contains.Item(ammo)
                        .And.EquivalentTo(new[]
            {
                WeaponConstants.Arrow,
                WeaponConstants.CrossbowBolt,
                WeaponConstants.Shuriken,
                WeaponConstants.SlingBullet,
            }));

            var item = itemSelector.SelectFrom($"{ammo}[{ItemTypeConstants.Weapon}]");

            Assert.That(item.Name, Is.EqualTo(ammo), ammo);
            Assert.That(item.ItemType, Is.EqualTo(ItemTypeConstants.Weapon), ammo);
            Assert.That(item.Traits, Is.Empty, ammo);
            Assert.That(item.Magic.SpecialAbilities, Is.Empty, ammo);
            Assert.That(item.Magic.Bonus, Is.Zero, ammo);
            Assert.That(item.IsMagical, Is.False, ammo);
            Assert.That(item.Quantity, Is.Zero, ammo);
        }
Esempio n. 19
0
        public void SelectWithQuantityOf1_AllOtherWeapons()
        {
            var allWeapons   = WeaponConstants.GetAllWeapons(false, false);
            var ammos        = WeaponConstants.GetAllAmmunition(false, false);
            var thrown       = WeaponConstants.GetAllThrown(false, false);
            var simple       = WeaponConstants.GetAllSimple(false, false);
            var melee        = WeaponConstants.GetAllMelee(false, false);
            var thrownRanged = thrown.Except(melee).Intersect(simple);

            var weapons = allWeapons.Except(ammos).Except(thrownRanged);

            foreach (var weapon in weapons)
            {
                var item = itemSelector.SelectFrom($"{weapon}[{ItemTypeConstants.Weapon}]");
                Assert.That(item.Name, Is.EqualTo(weapon), weapon);
                Assert.That(item.ItemType, Is.EqualTo(ItemTypeConstants.Weapon), weapon);
                Assert.That(item.Traits, Is.Empty, weapon);
                Assert.That(item.Magic.SpecialAbilities, Is.Empty, weapon);
                Assert.That(item.Magic.Bonus, Is.Zero, weapon);
                Assert.That(item.IsMagical, Is.False, weapon);
                Assert.That(item.Quantity, Is.EqualTo(1), weapon);
            }
        }
Esempio n. 20
0
        public void WeaponData(string weapon, int threatRange, string criticalMultiplier, string ammunition, string secondaryCriticalMultiplier)
        {
            var collection = new string[4];

            collection[DataIndexConstants.Weapon.CriticalMultiplier]          = criticalMultiplier;
            collection[DataIndexConstants.Weapon.SecondaryCriticalMultiplier] = secondaryCriticalMultiplier;
            collection[DataIndexConstants.Weapon.ThreatRange] = threatRange.ToString();
            collection[DataIndexConstants.Weapon.Ammunition]  = ammunition;

            Assert.That(criticalMultiplier, Is.EqualTo("x2").Or.EqualTo("x3").Or.EqualTo("x4"));

            var doubleWeapons = WeaponConstants.GetAllDouble(false, false);

            if (doubleWeapons.Contains(weapon))
            {
                Assert.That(secondaryCriticalMultiplier, Is.EqualTo("x2").Or.EqualTo("x3").Or.EqualTo("x4"));
            }
            else
            {
                Assert.That(secondaryCriticalMultiplier, Is.Empty);
            }

            base.OrderedCollections(weapon, collection);
        }
Esempio n. 21
0
        public void AmmunitionWeaponsMatchConstants()
        {
            var ammunitions = WeaponConstants.GetAllAmmunition(false, false);

            VerifyAttribute(ammunitions, AttributeConstants.Ammunition);
        }
Esempio n. 22
0
        public void ThrownWeaponsMatchConstants()
        {
            var thrown = WeaponConstants.GetAllThrown(false, false);

            VerifyAttribute(thrown, AttributeConstants.Thrown);
        }
Esempio n. 23
0
        public void ProjectileWeaponsMatchConstants()
        {
            var projectiles = WeaponConstants.GetAllProjectile(false, false);

            VerifyAttribute(projectiles, AttributeConstants.Projectile);
        }
Esempio n. 24
0
        public void DoubleWeaponsMatchConstants()
        {
            var doubleWeapons = WeaponConstants.GetAllDouble(false, false);

            VerifyAttribute(doubleWeapons, AttributeConstants.DoubleWeapon);
        }
Esempio n. 25
0
        public void ReachWeaponsMatchConstants()
        {
            var reach = WeaponConstants.GetAllReach(false, false);

            VerifyAttribute(reach, AttributeConstants.Reach);
        }
Esempio n. 26
0
        public void TwoHandedWeaponsMatchConstants()
        {
            var twoHanded = WeaponConstants.GetAllTwoHandedMelee(false, false);

            VerifyAttribute(twoHanded, AttributeConstants.TwoHanded);
        }
Esempio n. 27
0
        public void OneHandedWeaponsMatchConstants()
        {
            var oneHanded = WeaponConstants.GetAllOneHandedMelee(false, false);

            VerifyAttribute(oneHanded, AttributeConstants.OneHanded);
        }
Esempio n. 28
0
        public void LightWeaponsMatchConstants()
        {
            var light = WeaponConstants.GetAllLightMelee(false, false);

            VerifyAttribute(light, AttributeConstants.Light);
        }
Esempio n. 29
0
        public void ExoticWeaponsMatchConstants()
        {
            var exotic = WeaponConstants.GetAllExotic(false, false);

            VerifyAttribute(exotic, AttributeConstants.Exotic);
        }
Esempio n. 30
0
        public void MartialWeaponsMatchConstants()
        {
            var martial = WeaponConstants.GetAllMartial(false, false);

            VerifyAttribute(martial, AttributeConstants.Martial);
        }