コード例 #1
0
        public void UpdateDefaults()
        {
            bool needSave = false;

            if (Admins.Count == 0)
            {
                logger.Info("Adding default admin");
                Admins.AddAdmin("76561198003534614", 100);
                needSave = true;
            }
            GlobalShop = (from s in Shops where s.ShopID == 0 select s).FirstOrDefault();
            if ((GlobalShop != null) && !EnableProtection)
            {
                logger.Info("Removing global shop (EnableProtection = false)");
                Shops.Remove(GlobalShop);
                GlobalShop = null;
                needSave   = true;
            }
            else
            if ((GlobalShop == null) && EnableProtection)
            {
                logger.Info("Adding global shop");
                GlobalShop = new Shop
                {
                    ShopName     = "Serverwide Shop",
                    ShopRestocks = false,
                    ShopID       = 0,
                };
                GlobalShop.RegisterItem(new ShopItem
                {
                    ItemName      = "One RL Day Protection",
                    SellPrice     = ProtectionPriceOneDay,
                    StockAmount   = 100,
                    RestockAmount = -1,
                    BuyPrice      = 1,
                    HandlerName   = "ProtectionShopHandler"
                });
                GlobalShop.RegisterItem(new ShopItem
                {
                    ItemName      = "One RL week Protection",
                    SellPrice     = ProtectionPriceOneWeek,
                    StockAmount   = 100,
                    RestockAmount = -1,
                    BuyPrice      = 7,
                    HandlerName   = "ProtectionShopHandler"
                });
                GlobalShop.RegisterItem(new ShopItem
                {
                    ItemName      = "One RL Month Protection",
                    SellPrice     = ProtectionPriceOneMonth,
                    StockAmount   = 100,
                    RestockAmount = -1,
                    BuyPrice      = 30,
                    HandlerName   = "ProtectionShopHandler"
                });
                Shops.Add(GlobalShop);
                needSave = true;
            }
            if (GlobalShop != null)
            {
                GlobalShop.GlobalShop = true;
            }
            if (needSave)
            {
                Save(true);
            }
        }