Beispiel #1
0
        public static SoldierClassMetadata toDriverMetadata(XElement xmlMetadata)
        {
            SoldierClassMetadata metadata = new SoldierClassMetadata();

            metadata.internalName = xmlMetadata.Element(Constants.XML_METADATA_INTERNAL_NAME).Value;
            metadata.displayName  = xmlMetadata.Element(Constants.XML_METADATA_DISPLAY_NAME).Value;
            metadata.description  = xmlMetadata.Element(Constants.XML_METADATA_DESCRIPTION).Value;
            metadata.iconString   = xmlMetadata.Element(Constants.XML_METADATA_ICON_STRING).Value;

            return(metadata);
        }
Beispiel #2
0
        public static XElement toXmlMetadata(SoldierClassMetadata metadata)
        {
            XElement xmlMetadata = new XElement(Constants.XML_METADATA);

            addBaseChild(xmlMetadata, Constants.XML_METADATA_INTERNAL_NAME, metadata.internalName);
            addBaseChild(xmlMetadata, Constants.XML_METADATA_DISPLAY_NAME, metadata.displayName);
            addBaseChild(xmlMetadata, Constants.XML_METADATA_DESCRIPTION, metadata.description);
            addBaseChild(xmlMetadata, Constants.XML_METADATA_ICON_STRING, metadata.iconString);

            return(xmlMetadata);
        }
Beispiel #3
0
        public void convertMetadata()
        {
            SoldierClassMetadata metadata = new SoldierClassMetadata();

            metadata.internalName = "InternalTest";
            metadata.displayName  = "Internal Test";
            metadata.description  = "This is a test";
            metadata.iconString   = "Here.jpg";

            XElement actual = XcomPerkManager.Conversion.Convert.toXmlMetadata(metadata);

            XElement expected = new XElement(Constants.XML_METADATA);

            expected.Add(new XElement(Constants.XML_METADATA_INTERNAL_NAME, "InternalTest"));
            expected.Add(new XElement(Constants.XML_METADATA_DISPLAY_NAME, "Internal Test"));
            expected.Add(new XElement(Constants.XML_METADATA_DESCRIPTION, "This is a test"));
            expected.Add(new XElement(Constants.XML_METADATA_ICON_STRING, "Here.jpg"));

            Assert.IsTrue(XNode.DeepEquals(expected, actual), "Expected: " + expected.ToString() + "\nActual: " + actual.ToString());
        }
Beispiel #4
0
        public void convertMetadata()
        {
            XElement xmlMetadata = new XElement(Constants.XML_METADATA);

            xmlMetadata.Add(new XElement(Constants.XML_METADATA_INTERNAL_NAME, "InternalTest"));
            xmlMetadata.Add(new XElement(Constants.XML_METADATA_DISPLAY_NAME, "Internal Test"));
            xmlMetadata.Add(new XElement(Constants.XML_METADATA_DESCRIPTION, "This is a test"));
            xmlMetadata.Add(new XElement(Constants.XML_METADATA_ICON_STRING, "Here.jpg"));

            SoldierClassMetadata actual = XcomPerkManager.Conversion.Convert.toDriverMetadata(xmlMetadata);

            SoldierClassMetadata expected = new SoldierClassMetadata();

            expected.internalName = "InternalTest";
            expected.displayName  = "Internal Test";
            expected.description  = "This is a test";
            expected.iconString   = "Here.jpg";

            Assert.AreEqual(expected, actual);
        }
Beispiel #5
0
        public void convertSoldierClass()
        {
            SoldierClassMetadata metadata = new SoldierClassMetadata();

            metadata.internalName = "InternalTest";
            metadata.displayName  = "Internal Test";
            metadata.description  = "This is a test";
            metadata.iconString   = "Here.jpg";

            SoldierClassExperience experience = new SoldierClassExperience();

            experience.numberInForcedDeck = 1;
            experience.numberInDeck       = 2;
            experience.killAssistsPerKill = 3;

            SoldierClassEquipment equipment = new SoldierClassEquipment();

            equipment.squaddieLoadout = "Squaddie_TestClass";
            equipment.allowedArmors   = "squaddie";

            List <Weapon> weapons = new List <Weapon>();

            Weapon weaponA = new Weapon();

            weaponA.weaponName = "shotgun";
            weaponA.weaponSlot = WeaponSlot.Primary;
            weapons.Add(weaponA);

            Weapon weaponB = new Weapon();

            weaponB.weaponName = "sword";
            weaponB.weaponSlot = WeaponSlot.Secondary;
            weapons.Add(weaponB);

            equipment.weapons = weapons;

            List <SoldierClassAbility> abilities = new List <SoldierClassAbility>();

            SoldierClassAbility abilityA = new SoldierClassAbility();

            abilityA.internalName = "TestAbility";
            abilityA.displayName  = "Test Ability";
            abilityA.description  = "Hello";
            abilityA.requiredMod  = "My Mod";
            abilityA.rank         = SoldierRank.Corporal;
            abilityA.slot         = 3;
            abilityA.weaponSlot   = WeaponSlot.Primary;
            abilities.Add(abilityA);

            SoldierClassAbility abilityB = new SoldierClassAbility();

            abilityB.internalName = "TestAbility2";
            abilityB.displayName  = "Test Ability2";
            abilityB.description  = "Hello2";
            abilityB.requiredMod  = "My Mod2";
            abilityB.rank         = SoldierRank.Lieutenant;
            abilityB.slot         = 1;
            abilityB.weaponSlot   = WeaponSlot.Secondary;
            abilities.Add(abilityB);

            List <SoldierClassStat> stats = new List <SoldierClassStat>();

            SoldierClassStat statA = new SoldierClassStat();

            statA.stat  = Stat.Strength;
            statA.value = 2;
            statA.rank  = SoldierRank.Sergeant;
            stats.Add(statA);

            SoldierClassStat statB = new SoldierClassStat();

            statB.stat  = Stat.Aim;
            statB.value = 0;
            statB.rank  = SoldierRank.Squaddie;
            stats.Add(statB);

            SoldierClass soldierClass = new SoldierClass();

            soldierClass.metadata         = metadata;
            soldierClass.experience       = experience;
            soldierClass.equipment        = equipment;
            soldierClass.soldierAbilities = abilities;
            soldierClass.stats            = stats;

            XElement actual = XcomPerkManager.Conversion.Convert.toXmlSoldierClass(soldierClass);

            XElement expected = new XElement(Constants.XML_CLASS);
        }