Esempio n. 1
0
        private static void TestImport()
        {
            MysteryImporter importer = new MysteryImporter();

            importer.Load(@"D:\GitHub\OldMud\area\midgaard.are");
            importer.Parse();

            //MysteryImporter importer = new MysteryImporter();
            //string path = @"D:\GitHub\OldMud\area";
            //string fileList = Path.Combine(path, "area.lst");
            //string[] areaFilenames = File.ReadAllLines(fileList);
            //foreach (string areaFilename in areaFilenames)
            //{
            //    if (areaFilename.Contains("$"))
            //        break;
            //    string areaFullName = Path.Combine(path, areaFilename);
            //    importer.Load(areaFullName);
            //    importer.Parse();
            //}
        }
Esempio n. 2
0
        private static void CreateMidgaard()
        {
            MysteryImporter importer = new MysteryImporter();

            importer.Load(@"D:\GitHub\OldMud\area\midgaard.are");
            importer.Parse();
            //MysteryImporter importer = new MysteryImporter();
            //string path = @"D:\GitHub\OldMud\area";
            //string fileList = Path.Combine(path, "area.lst");
            //string[] areaFilenames = File.ReadAllLines(fileList);
            //foreach (string areaFilename in areaFilenames)
            //{
            //    if (areaFilename.Contains("$"))
            //        break;
            //    string areaFullName = Path.Combine(path, areaFilename);
            //    importer.Load(areaFullName);
            //    importer.Parse();
            //}

            Dictionary <int, IArea> areasByVnums = new Dictionary <int, IArea>();
            Dictionary <int, IRoom> roomsByVNums = new Dictionary <int, IRoom>();

            // Create Areas
            foreach (AreaData importedArea in importer.Areas)
            {
                // TODO: levels
                IArea area = DependencyContainer.Instance.GetInstance <IWorld>().AddArea(Guid.NewGuid(), importedArea.Name, 1, 99, importedArea.Builders, importedArea.Credits);
                areasByVnums.Add(importedArea.VNum, area);
            }

            // Create Rooms
            foreach (RoomData importedRoom in importer.Rooms)
            {
                IArea         area          = areasByVnums[importedRoom.AreaVnum];
                RoomBlueprint roomBlueprint = new RoomBlueprint
                {
                    Id          = importedRoom.VNum,
                    Name        = importedRoom.Name,
                    Description = importedRoom.Description,
                };
                IRoom room = DependencyContainer.Instance.GetInstance <IWorld>().AddRoom(Guid.NewGuid(), roomBlueprint, area);
                roomsByVNums.Add(importedRoom.VNum, room);
            }
            // Create Exits
            foreach (RoomData room in importer.Rooms)
            {
                for (int i = 0; i < RoomData.MaxExits - 1; i++)
                {
                    ExitData exit = room.Exits[i];
                    if (exit != null)
                    {
                        IRoom from;
                        roomsByVNums.TryGetValue(room.VNum, out from);
                        IRoom to;
                        roomsByVNums.TryGetValue(exit.DestinationVNum, out to);
                        if (from == null)
                        {
                            Log.Default.WriteLine(LogLevels.Error, "Origin room not found for vnum {0}", room.VNum);
                        }
                        else if (to == null)
                        {
                            Log.Default.WriteLine(LogLevels.Error, "Destination room not found for vnum {0}", room.VNum);
                        }
                        else
                        {
                            DependencyContainer.Instance.GetInstance <IWorld>().AddExit(from, to, null, (ExitDirections)i);
                        }
                    }
                }
            }
            //// Handle resets
            //foreach (RoomData importedRoom in importer.Rooms.Where(x => x.Resets.Any()))
            //{
            //    IRoom room;
            //    roomsByVNums.TryGetValue(importedRoom.VNum, out room);
            //    foreach (ResetData reset in importedRoom.Resets)
            //    {
            //        switch (reset.Command)
            //        {
            //            case 'M':
            //                MobileData mob = importer.Mobiles.FirstOrDefault(x => x.VNum == reset.Arg1);
            //                if (mob != null)
            //                    DependencyContainer.Instance.GetInstance<IWorld>().AddCharacter(Guid.NewGuid(), mob.Name, room);
            //                break;
            //            case 'O':
            //                ObjectData obj = importer.Objects.FirstOrDefault(x => x.VNum == reset.Arg1);
            //                if (obj != null) // TODO: itemType
            //                    DependencyContainer.Instance.GetInstance<IWorld>().AddItemContainer(Guid.NewGuid(), obj.Name, room);
            //                break;
            //            // TODO: other command  P, E, G, D, R, Z
            //        }
            //    }
            //}

            CharacterBlueprint mob2Blueprint = new CharacterBlueprint
            {
                Id               = 2,
                Name             = "mob2",
                ShortDescription = "Second mob (female)",
                Description      = "Second mob (female) is here",
                Sex              = Sex.Female,
                Level            = 10
            };
            CharacterBlueprint mob3Blueprint = new CharacterBlueprint
            {
                Id               = 3,
                Name             = "mob3",
                ShortDescription = "Third mob (male)",
                Description      = "Third mob (male) is here",
                Sex              = Sex.Male,
                Level            = 10
            };
            CharacterBlueprint mob4Blueprint = new CharacterBlueprint
            {
                Id               = 4,
                Name             = "mob4",
                ShortDescription = "Fourth mob (neutral)",
                Description      = "Fourth mob (neutral) is here",
                Sex              = Sex.Neutral,
                Level            = 10
            };
            CharacterBlueprint mob5Blueprint = new CharacterBlueprint
            {
                Id               = 5,
                Name             = "mob5",
                ShortDescription = "Fifth mob (female)",
                Description      = "Fifth mob (female) is here",
                Sex              = Sex.Female,
                Level            = 10
            };
            ItemContainerBlueprint item1Blueprint = new ItemContainerBlueprint
            {
                Id               = 1,
                Name             = "item1",
                ShortDescription = "First item (container)",
                Description      = "The first item (container) has been left here.",
                ItemCount        = 10,
                WeightMultiplier = 100
            };
            ItemWeaponBlueprint item2Blueprint = new ItemWeaponBlueprint
            {
                Id               = 2,
                Name             = "item2",
                ShortDescription = "Second item (weapon)",
                Description      = "The second item (weapon) has been left here.",
                Type             = WeaponTypes.Axe1H,
                DiceCount        = 10,
                DiceValue        = 20,
                DamageType       = SchoolTypes.Fire,
                WearLocation     = WearLocations.Wield
            };
            ItemArmorBlueprint item3Blueprint = new ItemArmorBlueprint
            {
                Id               = 3,
                Name             = "item3",
                ShortDescription = "Third item (armor|feet)",
                Description      = "The third item (armor|feet) has been left here.",
                Armor            = 100,
                ArmorKind        = ArmorKinds.Mail,
                WearLocation     = WearLocations.Feet
            };
            ItemLightBlueprint item4Blueprint = new ItemLightBlueprint
            {
                Id               = 4,
                Name             = "item4",
                ShortDescription = "Fourth item (light)",
                Description      = "The fourth item (light) has been left here.",
                DurationHours    = -1,
                WearLocation     = WearLocations.Light
            };
            ItemWeaponBlueprint item5Blueprint = new ItemWeaponBlueprint
            {
                Id               = 5,
                Name             = "item5",
                ShortDescription = "Fifth item (weapon)",
                Description      = "The fifth item (weapon) has been left here.",
                Type             = WeaponTypes.Sword1H,
                DiceCount        = 5,
                DiceValue        = 40,
                DamageType       = SchoolTypes.Physical,
                WearLocation     = WearLocations.Wield
            };

            //
            ServerOptions.CorpseBlueprint = new ItemCorpseBlueprint();

            // Add dummy mobs and items to allow impersonate :)
            IRoom templeOfMota = DependencyContainer.Instance.GetInstance <IWorld>().Rooms.FirstOrDefault(x => x.Name.ToLower() == "the temple of mota");
            IRoom templeSquare = DependencyContainer.Instance.GetInstance <IWorld>().Rooms.FirstOrDefault(x => x.Name.ToLower() == "the temple square");

            //ICharacter mob1 = DependencyContainer.Instance.GetInstance<IWorld>().AddCharacter(Guid.NewGuid(), "mob1", Repository.ClassManager["Mage"], Repository.RaceManager["Troll"], Sex.Male, templeOfMota); // playable
            ICharacter mob2 = DependencyContainer.Instance.GetInstance <IWorld>().AddCharacter(Guid.NewGuid(), mob2Blueprint, templeOfMota);
            ICharacter mob3 = DependencyContainer.Instance.GetInstance <IWorld>().AddCharacter(Guid.NewGuid(), mob3Blueprint, templeSquare);
            ICharacter mob4 = DependencyContainer.Instance.GetInstance <IWorld>().AddCharacter(Guid.NewGuid(), mob4Blueprint, templeSquare);
            ICharacter mob5 = DependencyContainer.Instance.GetInstance <IWorld>().AddCharacter(Guid.NewGuid(), mob5Blueprint, templeSquare);

            IItemContainer item1     = DependencyContainer.Instance.GetInstance <IWorld>().AddItemContainer(Guid.NewGuid(), item1Blueprint, templeOfMota);
            IItemContainer item1Dup1 = DependencyContainer.Instance.GetInstance <IWorld>().AddItemContainer(Guid.NewGuid(), item1Blueprint, templeOfMota);
            IItemWeapon    item2     = DependencyContainer.Instance.GetInstance <IWorld>().AddItemWeapon(Guid.NewGuid(), item2Blueprint, mob2);
            IItemArmor     item3     = DependencyContainer.Instance.GetInstance <IWorld>().AddItemArmor(Guid.NewGuid(), item3Blueprint, item1Dup1);
            //IItemLight item4 = DependencyContainer.Instance.GetInstance<IWorld>().AddItemLight(Guid.NewGuid(), item4Blueprint, mob1);
            //IItemWeapon item5 = DependencyContainer.Instance.GetInstance<IWorld>().AddItemWeapon(Guid.NewGuid(), item5Blueprint, mob1);
            //IItemContainer item1Dup2 = DependencyContainer.Instance.GetInstance<IWorld>().AddItemContainer(Guid.NewGuid(), item1Blueprint, mob1);
            IItemArmor item3Dup1 = DependencyContainer.Instance.GetInstance <IWorld>().AddItemArmor(Guid.NewGuid(), item3Blueprint, mob3);
            IItemLight item4Dup1 = DependencyContainer.Instance.GetInstance <IWorld>().AddItemLight(Guid.NewGuid(), item4Blueprint, mob4);

            // Equip weapon on mob2
            mob2.Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Wield).Item = item2;
            item2.ChangeContainer(null);
            item2.ChangeEquipedBy(mob2);
        }