예제 #1
0
        /// <summary>
        /// Creates the initial data for a server.
        /// </summary>
        public void CreateInitialData()
        {
            BaseMapInitializer.ClearDefaultDropItemGroups();
            using (var temporaryContext = this.persistenceContextProvider.CreateNewContext())
            {
                this.gameConfiguration = temporaryContext.CreateNew <GameConfiguration>();
                temporaryContext.SaveChanges();
            }

            using var contextWithConfiguration = this.persistenceContextProvider.CreateNewContext(this.gameConfiguration);
            this.context = contextWithConfiguration;
            this.CreateGameClientDefinitions();
            this.CreateChatServerDefinition();
            new GameConfigurationInitializer(this.context, this.gameConfiguration).Initialize();

            var gameServerConfiguration = this.CreateGameServerConfiguration(this.gameConfiguration.Maps);

            this.CreateGameServerDefinitions(gameServerConfiguration, 3);
            this.CreateConnectServerDefinitions();
            this.context.SaveChanges();

            new MapsInitializer(this.context, this.gameConfiguration).SetSafezoneMaps();

            new TestAccountsInitialization(this.context, this.gameConfiguration).Initialize();

            if (!AppDomain.CurrentDomain.GetAssemblies().Contains(typeof(GameServer).Assembly))
            {
                // should never happen, but the access to the GameServer type is a trick to load the assembly into the current domain.
            }

            var plugInManager = new PlugInManager(null, this.loggerFactory, null);

            plugInManager.DiscoverAndRegisterPlugIns();
            plugInManager.KnownPlugInTypes.ForEach(plugInType =>
            {
                var plugInConfiguration      = this.context.CreateNew <PlugInConfiguration>();
                plugInConfiguration.TypeId   = plugInType.GUID;
                plugInConfiguration.IsActive = true;
                this.gameConfiguration.PlugInConfigurations.Add(plugInConfiguration);

                // Resets are disabled by default.
                if (plugInType == typeof(ResetFeaturePlugIn))
                {
                    plugInConfiguration.IsActive = false;
                    plugInConfiguration.SetConfiguration(new ResetConfiguration());
                }
            });

            this.context.SaveChanges();
        }
예제 #2
0
        private void InitializeGameConfiguration()
        {
            this.gameConfiguration.ExperienceRate              = 1.0f;
            this.gameConfiguration.MaximumLevel                = 400;
            this.gameConfiguration.InfoRange                   = 12;
            this.gameConfiguration.AreaSkillHitsPlayer         = false;
            this.gameConfiguration.MaximumInventoryMoney       = int.MaxValue;
            this.gameConfiguration.MaximumVaultMoney           = int.MaxValue;
            this.gameConfiguration.RecoveryInterval            = 3000;
            this.gameConfiguration.MaximumLetters              = 50;
            this.gameConfiguration.LetterSendPrice             = 1000;
            this.gameConfiguration.MaximumCharactersPerAccount = 5;
            this.gameConfiguration.CharacterNameRegex          = "^[a-zA-Z0-9]{3,10}$";
            this.gameConfiguration.MaximumPasswordLength       = 20;
            this.gameConfiguration.MaximumPartySize            = 5;
            this.gameConfiguration.ShouldDropMoney             = true;
            this.gameConfiguration.ExperienceTable             =
                Enumerable.Range(0, this.gameConfiguration.MaximumLevel + 2)
                .Select(level => CalculateNeededExperience(level))
                .ToArray();
            this.gameConfiguration.MasterExperienceTable =
                Enumerable.Range(0, 201).Select(level => this.CalcNeededMasterExp(level)).ToArray();
            var moneyDropItemGroup = this.context.CreateNew <DropItemGroup>();

            moneyDropItemGroup.Chance      = 0.5;
            moneyDropItemGroup.ItemType    = SpecialItemType.Money;
            moneyDropItemGroup.Description = "The common money drop item group (50 % drop chance)";
            this.gameConfiguration.DropItemGroups.Add(moneyDropItemGroup);
            BaseMapInitializer.RegisterDefaultDropItemGroup(moneyDropItemGroup);

            var randomItemDropItemGroup = this.context.CreateNew <DropItemGroup>();

            randomItemDropItemGroup.Chance      = 0.3;
            randomItemDropItemGroup.ItemType    = SpecialItemType.RandomItem;
            randomItemDropItemGroup.Description = "The common drop item group for random items (30 % drop chance)";
            this.gameConfiguration.DropItemGroups.Add(randomItemDropItemGroup);
            BaseMapInitializer.RegisterDefaultDropItemGroup(randomItemDropItemGroup);

            var excellentItemDropItemGroup = this.context.CreateNew <DropItemGroup>();

            excellentItemDropItemGroup.Chance      = 0.0001;
            excellentItemDropItemGroup.ItemType    = SpecialItemType.Excellent;
            excellentItemDropItemGroup.Description = "The common drop item group for random excellent items (0.01 % drop chance)";
            this.gameConfiguration.DropItemGroups.Add(excellentItemDropItemGroup);
            BaseMapInitializer.RegisterDefaultDropItemGroup(excellentItemDropItemGroup);

            this.CreateStatAttributes();

            this.CreateItemSlotTypes();
            this.CreateItemOptionTypes();
            this.gameConfiguration.ItemOptions.Add(this.CreateLuckOptionDefinition());
            this.gameConfiguration.ItemOptions.Add(this.CreateOptionDefinition(Stats.DefenseBase));
            this.gameConfiguration.ItemOptions.Add(this.CreateOptionDefinition(Stats.MaximumPhysBaseDmg));
            this.gameConfiguration.ItemOptions.Add(this.CreateOptionDefinition(Stats.MaximumWizBaseDmg));
            this.gameConfiguration.ItemOptions.Add(this.CreateOptionDefinition(Stats.MaximumCurseBaseDmg));

            new CharacterClassInitialization(this.context, this.gameConfiguration).Initialize();
            new SkillsInitializer(this.context, this.gameConfiguration).Initialize();
            new Orbs(this.context, this.gameConfiguration).Initialize();
            new Scrolls(this.context, this.gameConfiguration).Initialize();
            new EventTicketItems(this.context, this.gameConfiguration).Initialize();
            new Wings(this.context, this.gameConfiguration).Initialize();
            new Pets(this.context, this.gameConfiguration).Initialize();
            new ExcellentOptions(this.context, this.gameConfiguration).Initialize();
            new HarmonyOptions(this.context, this.gameConfiguration).Initialize();
            new GuardianOptions(this.context, this.gameConfiguration).Initialize();
            new Armors(this.context, this.gameConfiguration).Initialize();
            new Weapons(this.context, this.gameConfiguration).Initialize();
            new Potions(this.context, this.gameConfiguration).Initialize();
            new Jewels(this.context, this.gameConfiguration).Initialize();
            new Misc(this.context, this.gameConfiguration).Initialize();
            new PackedJewels(this.context, this.gameConfiguration).Initialize();
            new Jewellery(this.context, this.gameConfiguration).Initialize();
            new AncientSets(this.context, this.gameConfiguration).Initialize();
            this.CreateJewelMixes();
            this.CreateNpcs();
            this.CreateGameMapDefinitions();
            this.AssignCharacterClassHomeMaps();
            new SocketSystem(this.context, this.gameConfiguration).Initialize();
            new ChaosMixes(this.context, this.gameConfiguration).Initialize();
            new Gates().Initialize(this.context, this.gameConfiguration);
            new Items.Quest(this.context, this.gameConfiguration).Initialize();
            new Quests(this.context, this.gameConfiguration).Initialize();
            //// TODO: ItemSetGroups
        }