public void InstantiateAndLoadRealFile()
        {
            Ultima4Data data = new Ultima4Data();

            data.Load("data\\u4data.dat");

            Assert.AreEqual("Ike", data.Characters[0].Name);
        }
        public void SaveAndLoadCurrentTransportation()
        {
            SaveFile.Load("u4Data.dat");

            SaveFile.CurrentTransportation = U4Transportation.HorseEast;

            SaveFile.Save("Transportation.d64");

            Ultima4Data newSave = new Ultima4Data(File);

            newSave.Load("Transportation.d64");

            Assert.AreEqual(U4Transportation.HorseEast, newSave.CurrentTransportation);
        }
        public void SaveAndLoadMoves()
        {
            SaveFile.Load("u4Data.dat");

            SaveFile.Moves = 87654321;

            SaveFile.Save("Moves.d64");

            Ultima4Data newSave = new Ultima4Data(File);

            newSave.Load("Moves.d64");

            Assert.AreEqual(87654321, newSave.Moves);
        }
        public void SaveLoadMultipleCharacters()
        {
            File.Files["u4Data.dat"][0x1130F] = 2;

            SaveFile.Load("u4Data.dat");

            SaveFile.Characters[1].Sex          = U4Sex.Female;
            SaveFile.Characters[1].Health       = U4Health.Asleep;
            SaveFile.Characters[1].Class        = U4Class.Bard;
            SaveFile.Characters[1].MaxHitPoints = 301;
            SaveFile.Characters[1].HitPoints    = 250;
            SaveFile.Characters[1].Strength     = 17;
            SaveFile.Characters[1].Dexterity    = 12;
            SaveFile.Characters[1].Intelligence = 25;
            SaveFile.Characters[1].Weapon       = U4Weapons.Crossbow;
            SaveFile.Characters[1].Armor        = U4Armor.MagicPlate;

            SaveFile.Save("MultipleCharacters.d64");

            Ultima4Data newSave = new Ultima4Data(File);

            newSave.Load("MultipleCharacters.d64");

            Assert.AreEqual(2, newSave.NumberOfCharactersInParty);

            Assert.AreEqual("Ike", newSave.Characters[0].Name);
            Assert.AreEqual(U4Sex.Male, newSave.Characters[0].Sex);
            Assert.AreEqual(U4Health.Good, newSave.Characters[0].Health);
            Assert.AreEqual(U4Class.Shepherd, newSave.Characters[0].Class);
            Assert.AreEqual(100, newSave.Characters[0].HitPoints);
            Assert.AreEqual(100, newSave.Characters[0].MaxHitPoints);
            Assert.AreEqual(16, newSave.Characters[0].Strength);
            Assert.AreEqual(22, newSave.Characters[0].Dexterity);
            Assert.AreEqual(19, newSave.Characters[0].Intelligence);
            Assert.AreEqual(U4Weapons.Staff, newSave.Characters[0].Weapon);
            Assert.AreEqual(U4Armor.Cloth, newSave.Characters[0].Armor);

            Assert.AreEqual("Iolo", newSave.Characters[1].Name);
            Assert.AreEqual(U4Sex.Female, newSave.Characters[1].Sex);
            Assert.AreEqual(U4Health.Asleep, newSave.Characters[1].Health);
            Assert.AreEqual(U4Class.Bard, newSave.Characters[1].Class);
            Assert.AreEqual(250, newSave.Characters[1].HitPoints);
            Assert.AreEqual(301, newSave.Characters[1].MaxHitPoints);
            Assert.AreEqual(17, newSave.Characters[1].Strength);
            Assert.AreEqual(12, newSave.Characters[1].Dexterity);
            Assert.AreEqual(25, newSave.Characters[1].Intelligence);
            Assert.AreEqual(U4Weapons.Crossbow, newSave.Characters[1].Weapon);
            Assert.AreEqual(U4Armor.MagicPlate, newSave.Characters[1].Armor);
        }
        public void SaveAndLoadThreePartKey()
        {
            SaveFile.Load("u4Data.dat");

            SaveFile.KeyOfTruth   = true;
            SaveFile.KeyOfLove    = true;
            SaveFile.KeyOfCourage = true;

            SaveFile.Save("ThreePartKey.d64");

            Ultima4Data newSave = new Ultima4Data(File);

            newSave.Load("ThreePartKey.d64");

            Assert.AreEqual(true, newSave.KeyOfTruth);
            Assert.AreEqual(true, newSave.KeyOfLove);
            Assert.AreEqual(true, newSave.KeyOfCourage);
        }
        public void SaveAndLoadVirtues()
        {
            SaveFile.Load("u4Data.dat");

            for (int i = 0; i < 8; ++i)
            {
                SaveFile.Virtues[i] = i * 4;
            }

            SaveFile.Save("Virtues.d64");

            Ultima4Data newSave = new Ultima4Data(File);

            newSave.Load("Virtues.d64");

            for (int i = 0; i < 8; ++i)
            {
                Assert.AreEqual(i * 4, newSave.Virtues[i]);
            }
        }
        public void SaveAndLoadStones()
        {
            SaveFile.Load("u4Data.dat");

            for (int i = 0; i < 8; ++i)
            {
                SaveFile.Stones[i] = i % 2 != 0;
            }

            SaveFile.Save("Stones.d64");

            Ultima4Data newSave = new Ultima4Data(File);

            newSave.Load("Stones.d64");

            for (int i = 0; i < 8; ++i)
            {
                Assert.AreEqual(i % 2 != 0, newSave.Stones[i]);
            }
        }
        public void SaveAndLoadLocation()
        {
            SaveFile.Load("u4Data.dat");

            SaveFile.Location.Lat1  = 'B';
            SaveFile.Location.Lat2  = 'G';
            SaveFile.Location.Long1 = 'D';
            SaveFile.Location.Long2 = 'H';

            SaveFile.Save("Location.d64");

            Ultima4Data newSave = new Ultima4Data(File);

            newSave.Load("Location.d64");

            Assert.AreEqual('B', newSave.Location.Lat1);
            Assert.AreEqual('G', newSave.Location.Lat2);
            Assert.AreEqual('D', newSave.Location.Long1);
            Assert.AreEqual('H', newSave.Location.Long2);
        }
        public void SaveAndLoadWeapons()
        {
            SaveFile.Load("u4Data.dat");

            for (int i = 0; i < 16; ++i)
            {
                SaveFile.Weapons[i] = i * 4;
            }

            SaveFile.Save("Weapons.d64");

            Ultima4Data newSave = new Ultima4Data(File);

            newSave.Load("Weapons.d64");

            for (int i = 0; i < 16; ++i)
            {
                Assert.AreEqual(i * 4, newSave.Weapons[i]);
            }
        }
        public void SaveAndLoadSpells()
        {
            SaveFile.Load("u4Data.dat");

            for (int i = 0; i < 26; ++i)
            {
                SaveFile.Spells[i] = i * 2;
            }

            SaveFile.Save("Spells.d64");

            Ultima4Data newSave = new Ultima4Data(File);

            newSave.Load("Spells.d64");

            for (int i = 0; i < 26; ++i)
            {
                Assert.AreEqual(i * 2, newSave.Spells[i]);
            }
        }
        public void SaveAndLoadBookBellCandleSkullWheelHorn()
        {
            SaveFile.Load("u4Data.dat");

            SaveFile.Skull  = true;
            SaveFile.Bell   = true;
            SaveFile.Book   = true;
            SaveFile.Candle = true;
            SaveFile.Wheel  = true;
            SaveFile.Horn   = true;

            SaveFile.Save("Items.d64");

            Ultima4Data newSave = new Ultima4Data(File);

            newSave.Load("Items.d64");

            Assert.AreEqual(true, newSave.Skull);
            Assert.AreEqual(true, newSave.Bell);
            Assert.AreEqual(true, newSave.Book);
            Assert.AreEqual(true, newSave.Candle);
            Assert.AreEqual(true, newSave.Wheel);
            Assert.AreEqual(true, newSave.Horn);
        }
        public void SaveAndLoadPartyInventory()
        {
            SaveFile.Load("u4Data.dat");

            SaveFile.Food     = 8192;
            SaveFile.Gold     = 6709;
            SaveFile.Torches  = 65;
            SaveFile.Gems     = 56;
            SaveFile.Keys     = 78;
            SaveFile.Sextants = 3;

            SaveFile.Save("Inventory.d64");

            Ultima4Data newSave = new Ultima4Data(File);

            newSave.Load("Inventory.d64");

            Assert.AreEqual(8192, newSave.Food);
            Assert.AreEqual(6709, newSave.Gold);
            Assert.AreEqual(65, newSave.Torches);
            Assert.AreEqual(56, newSave.Gems);
            Assert.AreEqual(78, newSave.Keys);
            Assert.AreEqual(3, newSave.Sextants);
        }
        public void SimpleSaveAndReload()
        {
            SaveFile.Load("u4Data.dat");

            SaveFile.Save("SimpleSave.d64");

            Ultima4Data newSave = new Ultima4Data(File);

            newSave.Load("SimpleSave.d64");

            Assert.AreEqual(1, newSave.NumberOfCharactersInParty);
            Assert.AreEqual(8, newSave.Characters.Length);

            Assert.AreEqual("Ike", newSave.Characters[0].Name);
            Assert.AreEqual(U4Sex.Male, newSave.Characters[0].Sex);
            Assert.AreEqual(U4Health.Good, newSave.Characters[0].Health);
            Assert.AreEqual(U4Class.Shepherd, newSave.Characters[0].Class);
            Assert.AreEqual(100, newSave.Characters[0].HitPoints);
            Assert.AreEqual(100, newSave.Characters[0].MaxHitPoints);
            Assert.AreEqual(16, newSave.Characters[0].Strength);
            Assert.AreEqual(22, newSave.Characters[0].Dexterity);
            Assert.AreEqual(19, newSave.Characters[0].Intelligence);
            Assert.AreEqual(U4Weapons.Staff, newSave.Characters[0].Weapon);
            Assert.AreEqual(U4Armor.Cloth, newSave.Characters[0].Armor);

            Assert.AreEqual(26, newSave.Spells.Length);
            foreach (var spell in newSave.Spells)
            {
                Assert.AreEqual(0, spell);
            }

            Assert.AreEqual(8, newSave.Reagents.Length);
            Assert.AreEqual(0, newSave.Reagents[0]);
            Assert.AreEqual(3, newSave.Reagents[1]);
            Assert.AreEqual(4, newSave.Reagents[2]);
            for (int i = 3; i < 8; ++i)
            {
                Assert.AreEqual(0, newSave.Reagents[i]);
            }

            Assert.AreEqual(8, newSave.Armor.Length);
            foreach (var armor in newSave.Armor)
            {
                Assert.AreEqual(0, armor);
            }

            Assert.AreEqual(16, newSave.Weapons.Length);
            foreach (var weapon in newSave.Weapons)
            {
                Assert.AreEqual(0, weapon);
            }

            Assert.AreEqual(299, newSave.Food);
            Assert.AreEqual(200, newSave.Gold);
            Assert.AreEqual(2, newSave.Torches);
            Assert.AreEqual(0, newSave.Gems);
            Assert.AreEqual(0, newSave.Keys);
            Assert.AreEqual(0, newSave.Sextants);
            Assert.AreEqual(false, newSave.Skull);
            Assert.AreEqual(false, newSave.Horn);
            Assert.AreEqual(false, newSave.Wheel);
            Assert.AreEqual(false, newSave.Candle);
            Assert.AreEqual(false, newSave.Book);
            Assert.AreEqual(false, newSave.Bell);
            Assert.AreEqual(false, newSave.KeyOfTruth);
            Assert.AreEqual(false, newSave.KeyOfLove);
            Assert.AreEqual(false, newSave.KeyOfCourage);
            Assert.AreEqual(6, newSave.Moves);

            Assert.AreEqual('K', newSave.Location.Lat1);
            Assert.AreEqual('K', newSave.Location.Lat2);
            Assert.AreEqual('L', newSave.Location.Long1);
            Assert.AreEqual('K', newSave.Location.Long2);

            Assert.AreEqual(8, newSave.Stones.Length);
            foreach (var stone in newSave.Stones)
            {
                Assert.AreEqual(false, stone);
            }

            Assert.AreEqual(8, newSave.Runes.Length);
            foreach (var rune in newSave.Runes)
            {
                Assert.AreEqual(false, rune);
            }

            Assert.AreEqual(8, newSave.Virtues.Length);
            Assert.AreEqual(55, newSave.Virtues[0]);
            Assert.AreEqual(60, newSave.Virtues[1]);
            Assert.AreEqual(50, newSave.Virtues[2]);
            Assert.AreEqual(50, newSave.Virtues[3]);
            Assert.AreEqual(50, newSave.Virtues[4]);
            Assert.AreEqual(50, newSave.Virtues[5]);
            Assert.AreEqual(55, newSave.Virtues[6]);
            Assert.AreEqual(65, newSave.Virtues[7]);

            Assert.AreEqual(U4Transportation.Foot, newSave.CurrentTransportation);
        }