예제 #1
0
파일: Items.cs 프로젝트: hybrasyl/server
    public void ItemSlotRequirement()
    {
        Fixture.ResetUserStats();
        Fixture.TestUser.Class  = Class.Monk;
        Fixture.TestUser.Gender = Gender.Male;
        string error = string.Empty;

        Assert.True(Game.World.WorldData.TryGetValueByIndex("Test Armor Require Boots", out Item armorItem));
        Assert.NotNull(armorItem);
        Fixture.TestUser.Teleport("XUnit Test Realm", 10, 10);
        var armor = Fixture.TestUser.World.CreateItem(armorItem);

        // Check requirement: equip armor with slot restriction (requires boots), should fail
        Assert.False(armor.CheckRequirements(Fixture.TestUser, out error));
        var item2 = Game.World.WorldData.TryGetValueByIndex("Test Boots", out Item bootItem);

        Assert.NotNull(item2);
        // Now equip boots
        var boots = Fixture.TestUser.World.CreateItem(bootItem);

        Assert.True(boots.CheckRequirements(Fixture.TestUser, out error));
        Assert.True(Fixture.TestUser.AddEquipment(boots, boots.EquipmentSlot));
        // Now we should be able to equip the armor
        Assert.True(armor.CheckRequirements(Fixture.TestUser, out error));
        Assert.True(Fixture.TestUser.AddEquipment(armor, armor.EquipmentSlot));
        // Both boots and armor are equipped
        Assert.NotNull(Fixture.TestUser.Equipment.Armor);
        Assert.NotNull(Fixture.TestUser.Equipment.Boots);
        // Removing the boots should not be possible (we should get a system message)
        Assert.False(Fixture.TestUser.RemoveEquipment((byte)ItemSlots.Foot));
        Assert.Equal("Other equipment must be removed first.", Fixture.TestUser.LastSystemMessage);
        Assert.NotNull(Fixture.TestUser.Equipment.Armor);
        Assert.NotNull(Fixture.TestUser.Equipment.Boots);
    }
예제 #2
0
    public void ClearEquipment()
    {
        Fixture.TestUser.Equipment.Clear();
        Fixture.ResetUserStats();

        Assert.True(Fixture.TestUser.Equipment.Count == 0, "Equipment cleared but count is non-zero");
        Assert.True(Fixture.TestUser.Equipment.ToList().Count == 0,
                    "Equipment cleared but enumerated count is non-zero");
        Assert.True(Fixture.TestUser.Equipment.Weight == 0, "Equipment cleared but weight is non-zero");
        Fixture.TestUser.Equipment.RecalculateWeight();
        Assert.True(Fixture.TestUser.Equipment.Weight == 0,
                    "Equipment cleared but weight is non-zero after recalculation");
    }
예제 #3
0
파일: Variants.cs 프로젝트: hybrasyl/server
    public void EquipVariant()
    {
        Fixture.ResetUserStats();
        Fixture.TestUser.Equipment.Clear();
        Assert.True(Game.World.WorldData.TryGetValueByIndex <Item>("Variant Test Boots 2", out var variant));
        var itemObj = Game.World.CreateItem(variant);

        Assert.True(Fixture.TestUser.AddEquipment(itemObj, (byte)ItemSlots.Foot), "Equipping variant failed");
        Assert.True(Game.World.WorldData.TryGetValue <VariantGroup>("testgroup", out var variantGroup));

        Assert.True(Fixture.TestUser.Stats.MaximumHp == Fixture.TestUser.Stats.BaseHp + long.Parse(variant.Properties.StatModifiers.BonusHp));
        Assert.True(Fixture.TestUser.Stats.MaximumMp == Fixture.TestUser.Stats.BaseMp + long.Parse(variant.Properties.StatModifiers.BonusMp));
        Assert.True(Fixture.TestUser.Stats.Str == Fixture.TestUser.Stats.BaseStr + long.Parse(variant.Properties.StatModifiers.BonusStr));
        Assert.True(Fixture.TestUser.Stats.Con == Fixture.TestUser.Stats.BaseCon + long.Parse(variant.Properties.StatModifiers.BonusCon));
        Assert.True(Fixture.TestUser.Stats.Dex == Fixture.TestUser.Stats.BaseDex + long.Parse(variant.Properties.StatModifiers.BonusDex));
        Assert.True(Fixture.TestUser.Stats.Int == Fixture.TestUser.Stats.BaseInt + long.Parse(variant.Properties.StatModifiers.BonusInt));
        Assert.True(Fixture.TestUser.Stats.Wis == Fixture.TestUser.Stats.BaseWis + long.Parse(variant.Properties.StatModifiers.BonusWis));
        Assert.True(Fixture.TestUser.Stats.Crit == Fixture.TestUser.Stats.BaseCrit + long.Parse(variant.Properties.StatModifiers.BonusCrit));
        Assert.True(Fixture.TestUser.Stats.MagicCrit == Fixture.TestUser.Stats.BaseMagicCrit + long.Parse(variant.Properties.StatModifiers.BonusMagicCrit));
        Assert.True(Fixture.TestUser.Stats.Dmg == Fixture.TestUser.Stats.BaseDmg + long.Parse(variant.Properties.StatModifiers.BonusDmg));
        Assert.True(Fixture.TestUser.Stats.Hit == Fixture.TestUser.Stats.BaseHit + long.Parse(variant.Properties.StatModifiers.BonusHit));
        //Assert.True(Fixture.TestUser.Stats.Ac == Fixture.TestUser.Stats.BaseAc + long.Parse(variant.Properties.StatModifiers.BonusAc));
        Assert.True(Fixture.TestUser.Stats.Mr == Fixture.TestUser.Stats.BaseMr + long.Parse(variant.Properties.StatModifiers.BonusMr));
        Assert.True(Fixture.TestUser.Stats.Regen == Fixture.TestUser.Stats.BaseRegen + long.Parse(variant.Properties.StatModifiers.BonusRegen));
        Assert.True(Fixture.TestUser.Stats.InboundDamageModifier == Fixture.TestUser.Stats.BaseInboundDamageModifier + long.Parse(variant.Properties.StatModifiers.BonusInboundDamageModifier));
        Assert.True(Fixture.TestUser.Stats.InboundHealModifier == Fixture.TestUser.Stats.BaseInboundHealModifier + long.Parse(variant.Properties.StatModifiers.BonusInboundHealModifier));
        Assert.True(Fixture.TestUser.Stats.OutboundDamageModifier == Fixture.TestUser.Stats.BaseOutboundDamageModifier + long.Parse(variant.Properties.StatModifiers.BonusOutboundDamageModifier));
        Assert.True(Fixture.TestUser.Stats.OutboundHealModifier == Fixture.TestUser.Stats.BaseOutboundHealModifier + long.Parse(variant.Properties.StatModifiers.BonusOutboundHealModifier));
        Assert.True(Fixture.TestUser.Stats.ReflectMagical == Fixture.TestUser.Stats.BaseReflectMagical + long.Parse(variant.Properties.StatModifiers.BonusReflectMagical));
        Assert.True(Fixture.TestUser.Stats.ReflectPhysical == Fixture.TestUser.Stats.BaseReflectPhysical + long.Parse(variant.Properties.StatModifiers.BonusReflectPhysical));
        Assert.True(Fixture.TestUser.Stats.ExtraGold == Fixture.TestUser.Stats.BaseExtraGold + long.Parse(variant.Properties.StatModifiers.BonusExtraGold));
        Assert.True(Fixture.TestUser.Stats.Dodge == Fixture.TestUser.Stats.BaseDodge + long.Parse(variant.Properties.StatModifiers.BonusDodge));
        Assert.True(Fixture.TestUser.Stats.MagicDodge == Fixture.TestUser.Stats.BaseMagicDodge + long.Parse(variant.Properties.StatModifiers.BonusMagicDodge));
        Assert.True(Fixture.TestUser.Stats.ExtraXp == Fixture.TestUser.Stats.BaseExtraXp + long.Parse(variant.Properties.StatModifiers.BonusExtraXp));
        Assert.True(Fixture.TestUser.Stats.ExtraItemFind == Fixture.TestUser.Stats.BaseExtraItemFind + long.Parse(variant.Properties.StatModifiers.BonusExtraItemFind));
        Assert.True(Fixture.TestUser.Stats.LifeSteal == Fixture.TestUser.Stats.BaseLifeSteal + long.Parse(variant.Properties.StatModifiers.BonusLifeSteal));
        Assert.True(Fixture.TestUser.Stats.ManaSteal == Fixture.TestUser.Stats.BaseManaSteal + long.Parse(variant.Properties.StatModifiers.BonusManaSteal));
        Assert.True(Fixture.TestUser.Stats.InboundDamageToMp == Fixture.TestUser.Stats.BaseInboundDamageToMp + long.Parse(variant.Properties.StatModifiers.BonusInboundDamageToMp));
    }
예제 #4
0
파일: Stats.cs 프로젝트: hybrasyl/server
 public void CreateAndSerialize()
 {
     Fixture.ResetUserStats();
     Fixture.TestUser.Save();
     Assert.True(Game.World.WorldData.TryGetUser(Fixture.TestUser.Name, out var deserializedUser));
     Assert.True(Fixture.TestUser.Stats.BonusHp == deserializedUser.Stats.BonusHp,
                 $"BonusHp should be {Fixture.TestUser.Stats.BonusHp}, is {deserializedUser.Stats.BonusHp}");
     Assert.True(Fixture.TestUser.Stats.BaseHp == deserializedUser.Stats.BaseHp,
                 $"BaseHp should be {Fixture.TestUser.Stats.BaseHp}, is {deserializedUser.Stats.BaseHp}");
     Assert.True(Fixture.TestUser.Stats.BonusMp == deserializedUser.Stats.BonusMp,
                 $"BonusMp should be {Fixture.TestUser.Stats.BonusMp}, is {deserializedUser.Stats.BonusMp}");
     Assert.True(Fixture.TestUser.Stats.BaseMp == deserializedUser.Stats.BaseMp,
                 $"BaseMp should be {Fixture.TestUser.Stats.BaseMp}, is {deserializedUser.Stats.BaseMp}");
     Assert.True(Fixture.TestUser.Stats.BonusStr == deserializedUser.Stats.BonusStr,
                 $"BonusStr should be {Fixture.TestUser.Stats.BonusStr}, is {deserializedUser.Stats.BonusStr}");
     Assert.True(Fixture.TestUser.Stats.BaseStr == deserializedUser.Stats.BaseStr,
                 $"BaseStr should be {Fixture.TestUser.Stats.BaseStr}, is {deserializedUser.Stats.BaseStr}");
     Assert.True(Fixture.TestUser.Stats.BonusCon == deserializedUser.Stats.BonusCon,
                 $"BonusCon should be {Fixture.TestUser.Stats.BonusCon}, is {deserializedUser.Stats.BonusCon}");
     Assert.True(Fixture.TestUser.Stats.BaseCon == deserializedUser.Stats.BaseCon,
                 $"BaseCon should be {Fixture.TestUser.Stats.BaseCon}, is {deserializedUser.Stats.BaseCon}");
     Assert.True(Fixture.TestUser.Stats.BonusDex == deserializedUser.Stats.BonusDex,
                 $"BonusDex should be {Fixture.TestUser.Stats.BonusDex}, is {deserializedUser.Stats.BonusDex}");
     Assert.True(Fixture.TestUser.Stats.BaseDex == deserializedUser.Stats.BaseDex,
                 $"BaseDex should be {Fixture.TestUser.Stats.BaseDex}, is {deserializedUser.Stats.BaseDex}");
     Assert.True(Fixture.TestUser.Stats.BonusInt == deserializedUser.Stats.BonusInt,
                 $"BonusInt should be {Fixture.TestUser.Stats.BonusInt}, is {deserializedUser.Stats.BonusInt}");
     Assert.True(Fixture.TestUser.Stats.BaseInt == deserializedUser.Stats.BaseInt,
                 $"BaseInt should be {Fixture.TestUser.Stats.BaseInt}, is {deserializedUser.Stats.BaseInt}");
     Assert.True(Fixture.TestUser.Stats.BonusWis == deserializedUser.Stats.BonusWis,
                 $"BonusWis should be {Fixture.TestUser.Stats.BonusWis}, is {deserializedUser.Stats.BonusWis}");
     Assert.True(Fixture.TestUser.Stats.BaseWis == deserializedUser.Stats.BaseWis,
                 $"BaseWis should be {Fixture.TestUser.Stats.BaseWis}, is {deserializedUser.Stats.BaseWis}");
     Assert.True(Fixture.TestUser.Stats.BonusCrit == deserializedUser.Stats.BonusCrit,
                 $"BonusCrit should be {Fixture.TestUser.Stats.BonusCrit}, is {deserializedUser.Stats.BonusCrit}");
     Assert.True(Fixture.TestUser.Stats.BaseCrit == deserializedUser.Stats.BaseCrit,
                 $"BaseCrit should be {Fixture.TestUser.Stats.BaseCrit}, is {deserializedUser.Stats.BaseCrit}");
     Assert.True(Fixture.TestUser.Stats.BonusMagicCrit == deserializedUser.Stats.BonusMagicCrit,
                 $"BonusMagicCrit should be {Fixture.TestUser.Stats.BonusMagicCrit}, is {deserializedUser.Stats.BonusMagicCrit}");
     Assert.True(Fixture.TestUser.Stats.BaseMagicCrit == deserializedUser.Stats.BaseMagicCrit,
                 $"BaseMagicCrit should be {Fixture.TestUser.Stats.BaseMagicCrit}, is {deserializedUser.Stats.BaseMagicCrit}");
     Assert.True(Fixture.TestUser.Stats.BonusDmg == deserializedUser.Stats.BonusDmg,
                 $"BonusDmg should be {Fixture.TestUser.Stats.BonusDmg}, is {deserializedUser.Stats.BonusDmg}");
     Assert.True(Fixture.TestUser.Stats.BaseDmg == deserializedUser.Stats.BaseDmg,
                 $"BaseDmg should be {Fixture.TestUser.Stats.BaseDmg}, is {deserializedUser.Stats.BaseDmg}");
     Assert.True(Fixture.TestUser.Stats.BonusHit == deserializedUser.Stats.BonusHit,
                 $"BonusHit should be {Fixture.TestUser.Stats.BonusHit}, is {deserializedUser.Stats.BonusHit}");
     Assert.True(Fixture.TestUser.Stats.BaseHit == deserializedUser.Stats.BaseHit,
                 $"BaseHit should be {Fixture.TestUser.Stats.BaseHit}, is {deserializedUser.Stats.BaseHit}");
     Assert.True(Fixture.TestUser.Stats.BonusAc == deserializedUser.Stats.BonusAc,
                 $"BonusAc should be {Fixture.TestUser.Stats.BonusAc}, is {deserializedUser.Stats.BonusAc}");
     Assert.True(Fixture.TestUser.Stats.BaseAc == deserializedUser.Stats.BaseAc,
                 $"BaseAc should be {Fixture.TestUser.Stats.BaseAc}, is {deserializedUser.Stats.BaseAc}");
     Assert.True(Fixture.TestUser.Stats.BonusMr == deserializedUser.Stats.BonusMr,
                 $"BonusMr should be {Fixture.TestUser.Stats.BonusMr}, is {deserializedUser.Stats.BonusMr}");
     Assert.True(Fixture.TestUser.Stats.BaseMr == deserializedUser.Stats.BaseMr,
                 $"BaseMr should be {Fixture.TestUser.Stats.BaseMr}, is {deserializedUser.Stats.BaseMr}");
     Assert.True(Fixture.TestUser.Stats.BonusRegen == deserializedUser.Stats.BonusRegen,
                 $"BonusRegen should be {Fixture.TestUser.Stats.BonusRegen}, is {deserializedUser.Stats.BonusRegen}");
     Assert.True(Fixture.TestUser.Stats.BaseRegen == deserializedUser.Stats.BaseRegen,
                 $"BaseRegen should be {Fixture.TestUser.Stats.BaseRegen}, is {deserializedUser.Stats.BaseRegen}");
     Assert.True(
         Fixture.TestUser.Stats.BonusInboundDamageModifier == deserializedUser.Stats.BonusInboundDamageModifier,
         $"BonusInboundDamageModifier should be {Fixture.TestUser.Stats.BonusInboundDamageModifier}, is {deserializedUser.Stats.BonusInboundDamageModifier}");
     Assert.True(
         Fixture.TestUser.Stats.BaseInboundDamageModifier == deserializedUser.Stats.BaseInboundDamageModifier,
         $"BaseInboundDamageModifier should be {Fixture.TestUser.Stats.BaseInboundDamageModifier}, is {deserializedUser.Stats.BaseInboundDamageModifier}");
     Assert.True(Fixture.TestUser.Stats.BonusInboundHealModifier == deserializedUser.Stats.BonusInboundHealModifier,
                 $"BonusInboundHealModifier should be {Fixture.TestUser.Stats.BonusInboundHealModifier}, is {deserializedUser.Stats.BonusInboundHealModifier}");
     Assert.True(Fixture.TestUser.Stats.BaseInboundHealModifier == deserializedUser.Stats.BaseInboundHealModifier,
                 $"BaseInboundHealModifier should be {Fixture.TestUser.Stats.BaseInboundHealModifier}, is {deserializedUser.Stats.BaseInboundHealModifier}");
     Assert.True(
         Fixture.TestUser.Stats.BonusOutboundDamageModifier == deserializedUser.Stats.BonusOutboundDamageModifier,
         $"BonusOutboundDamageModifier should be {Fixture.TestUser.Stats.BonusOutboundDamageModifier}, is {deserializedUser.Stats.BonusOutboundDamageModifier}");
     Assert.True(
         Fixture.TestUser.Stats.BaseOutboundDamageModifier == deserializedUser.Stats.BaseOutboundDamageModifier,
         $"BaseOutboundDamageModifier should be {Fixture.TestUser.Stats.BaseOutboundDamageModifier}, is {deserializedUser.Stats.BaseOutboundDamageModifier}");
     Assert.True(
         Fixture.TestUser.Stats.BonusOutboundHealModifier == deserializedUser.Stats.BonusOutboundHealModifier,
         $"BonusOutboundHealModifier should be {Fixture.TestUser.Stats.BonusOutboundHealModifier}, is {deserializedUser.Stats.BonusOutboundHealModifier}");
     Assert.True(Fixture.TestUser.Stats.BaseOutboundHealModifier == deserializedUser.Stats.BaseOutboundHealModifier,
                 $"BaseOutboundHealModifier should be {Fixture.TestUser.Stats.BaseOutboundHealModifier}, is {deserializedUser.Stats.BaseOutboundHealModifier}");
     Assert.True(Fixture.TestUser.Stats.BonusReflectMagical == deserializedUser.Stats.BonusReflectMagical,
                 $"BonusReflectMagical should be {Fixture.TestUser.Stats.BonusReflectMagical}, is {deserializedUser.Stats.BonusReflectMagical}");
     Assert.True(Fixture.TestUser.Stats.BaseReflectMagical == deserializedUser.Stats.BaseReflectMagical,
                 $"BaseReflectMagical should be {Fixture.TestUser.Stats.BaseReflectMagical}, is {deserializedUser.Stats.BaseReflectMagical}");
     Assert.True(Fixture.TestUser.Stats.BonusReflectPhysical == deserializedUser.Stats.BonusReflectPhysical,
                 $"BonusReflectPhysical should be {Fixture.TestUser.Stats.BonusReflectPhysical}, is {deserializedUser.Stats.BonusReflectPhysical}");
     Assert.True(Fixture.TestUser.Stats.BaseReflectPhysical == deserializedUser.Stats.BaseReflectPhysical,
                 $"BaseReflectPhysical should be {Fixture.TestUser.Stats.BaseReflectPhysical}, is {deserializedUser.Stats.BaseReflectPhysical}");
     Assert.True(Fixture.TestUser.Stats.BonusExtraGold == deserializedUser.Stats.BonusExtraGold,
                 $"BonusExtraGold should be {Fixture.TestUser.Stats.BonusExtraGold}, is {deserializedUser.Stats.BonusExtraGold}");
     Assert.True(Fixture.TestUser.Stats.BaseExtraGold == deserializedUser.Stats.BaseExtraGold,
                 $"BaseExtraGold should be {Fixture.TestUser.Stats.BaseExtraGold}, is {deserializedUser.Stats.BaseExtraGold}");
     Assert.True(Fixture.TestUser.Stats.BonusDodge == deserializedUser.Stats.BonusDodge,
                 $"BonusDodge should be {Fixture.TestUser.Stats.BonusDodge}, is {deserializedUser.Stats.BonusDodge}");
     Assert.True(Fixture.TestUser.Stats.BaseDodge == deserializedUser.Stats.BaseDodge,
                 $"BaseDodge should be {Fixture.TestUser.Stats.BaseDodge}, is {deserializedUser.Stats.BaseDodge}");
     Assert.True(Fixture.TestUser.Stats.BonusMagicDodge == deserializedUser.Stats.BonusMagicDodge,
                 $"BonusMagicDodge should be {Fixture.TestUser.Stats.BonusMagicDodge}, is {deserializedUser.Stats.BonusMagicDodge}");
     Assert.True(Fixture.TestUser.Stats.BaseMagicDodge == deserializedUser.Stats.BaseMagicDodge,
                 $"BaseMagicDodge should be {Fixture.TestUser.Stats.BaseMagicDodge}, is {deserializedUser.Stats.BaseMagicDodge}");
     Assert.True(Fixture.TestUser.Stats.BonusExtraXp == deserializedUser.Stats.BonusExtraXp,
                 $"BonusExtraXp should be {Fixture.TestUser.Stats.BonusExtraXp}, is {deserializedUser.Stats.BonusExtraXp}");
     Assert.True(Fixture.TestUser.Stats.BaseExtraXp == deserializedUser.Stats.BaseExtraXp,
                 $"BaseExtraXp should be {Fixture.TestUser.Stats.BaseExtraXp}, is {deserializedUser.Stats.BaseExtraXp}");
     Assert.True(Fixture.TestUser.Stats.BonusExtraItemFind == deserializedUser.Stats.BonusExtraItemFind,
                 $"BonusExtraItemFind should be {Fixture.TestUser.Stats.BonusExtraItemFind}, is {deserializedUser.Stats.BonusExtraItemFind}");
     Assert.True(Fixture.TestUser.Stats.BaseExtraItemFind == deserializedUser.Stats.BaseExtraItemFind,
                 $"BaseExtraItemFind should be {Fixture.TestUser.Stats.BaseExtraItemFind}, is {deserializedUser.Stats.BaseExtraItemFind}");
     Assert.True(Fixture.TestUser.Stats.BonusLifeSteal == deserializedUser.Stats.BonusLifeSteal,
                 $"BonusLifeSteal should be {Fixture.TestUser.Stats.BonusLifeSteal}, is {deserializedUser.Stats.BonusLifeSteal}");
     Assert.True(Fixture.TestUser.Stats.BaseLifeSteal == deserializedUser.Stats.BaseLifeSteal,
                 $"BaseLifeSteal should be {Fixture.TestUser.Stats.BaseLifeSteal}, is {deserializedUser.Stats.BaseLifeSteal}");
     Assert.True(Fixture.TestUser.Stats.BonusManaSteal == deserializedUser.Stats.BonusManaSteal,
                 $"BonusManaSteal should be {Fixture.TestUser.Stats.BonusManaSteal}, is {deserializedUser.Stats.BonusManaSteal}");
     Assert.True(Fixture.TestUser.Stats.BaseManaSteal == deserializedUser.Stats.BaseManaSteal,
                 $"BaseManaSteal should be {Fixture.TestUser.Stats.BaseManaSteal}, is {deserializedUser.Stats.BaseManaSteal}");
     Assert.True(Fixture.TestUser.Stats.BonusInboundDamageToMp == deserializedUser.Stats.BonusInboundDamageToMp,
                 $"BonusInboundDamageToMp should be {Fixture.TestUser.Stats.BonusInboundDamageToMp}, is {deserializedUser.Stats.BonusInboundDamageToMp}");
     Assert.True(Fixture.TestUser.Stats.BaseInboundDamageToMp == deserializedUser.Stats.BaseInboundDamageToMp,
                 $"BaseInboundDamageToMp should be {Fixture.TestUser.Stats.BaseInboundDamageToMp}, is {deserializedUser.Stats.BaseInboundDamageToMp}");
 }