Ejemplo n.º 1
0
        private bool IsCategoryEnabled(ItemCategory category)
        {
            if (!configuration.Categories.ContainsKey(category.ToString()))
            {
                return(false);
            }

            return(configuration.Categories[category.ToString()].Enabled);
        }
Ejemplo n.º 2
0
        private int GetRandomAmount(ItemCategory category)
        {
            if (!configuration.Categories.ContainsKey(category.ToString()))
            {
                return(0);
            }

            Category settings = configuration.Categories[category.ToString()];

            return(UnityEngine.Random.Range(settings.MinimalAmount, settings.MaximalAmount + 1));
        }
        private ItemInfo GetIndexedItem(ItemCategory itemCategory, int itemId)
        {
            ItemInfo itemInfo = _data.ItemCategories[itemCategory.ToString()].First(item => item.ItemId == itemId) ??
                                AddItemToIndex(itemId);

            return(itemInfo);
        }
Ejemplo n.º 4
0
        private List <Item> GetItemsFromConfig(JsonManager jsonManager, ItemCategory itemCategory)
        {
            var configPath  = $"{configDirectory}\\Items{itemCategory.ToString()}.json";
            var configItems = jsonManager.GetItemsFromJsonFile(configPath);

            return(configItems);
        }
Ejemplo n.º 5
0
    SavedItemData CreateFakeItem(ItemCategory category, Item.ItemType type)
    {
        SavedItemData saveDataItem = new SavedItemData();

        saveDataItem.itemCategory = category.ToString();
        saveDataItem.itemType     = type.ToString();
        saveDataItem.prefabName   = type.ToString();
        return(saveDataItem);
    }
Ejemplo n.º 6
0
    public static bool GetIsItemBuyable(ItemCategory category, int num)
    {
        if (category == ItemCategory.ETC)
        {
            return(true);
        }
        else if (num == 0)
        {
            return(true);
        }

        int temp = PlayerPrefs.GetInt("Item_" + category.ToString() + "_" + num + "_Buyable", 0);


        return((temp == 0) ? (false) : (true));
    }
Ejemplo n.º 7
0
        private void SetStackCategoryCommand(IPlayer player, string command, string[] args)
        {
            if (args.Length != 2)
            {
                player.Reply(
                    string.Format(GetMessage("NotEnoughArguments", player.Id), 2));
            }

            ItemCategory itemCategory = (ItemCategory)Enum.Parse(typeof(ItemCategory), args[0], true);

            _config.CategoryStackMultipliers[itemCategory.ToString()] = Convert.ToInt32(args[1].TrimEnd('x'));

            SaveConfig();
            SetStackSizes();

            player.Reply(GetMessage("OperationSuccessful", player.Id));
        }
Ejemplo n.º 8
0
        public override string ToString()
        {
            string item = $"{Variable}: ";

            if (RewardType == RewardType.Gold || RewardType == RewardType.Unknown)
            {
                item += (Category == ItemCategory.Random) ? "Random gold" : $"{ItemId} - {Category} gold";
            }
            else
            {
                if (!ItemMapper.ItemMap.ContainsKey(Category))
                {
                    Console.Error.WriteLine("{0}: Failed to find item category {1} in item map", Program.Quest.Name, Category);
                    return("ERROR");
                }
                try
                {
                    var name = ItemId == 0xffff ? Category.ToString() : ItemMapper.ItemMap[Category][ItemId];
                    item += $"{RewardType} {Category} {name}";
                }
                catch (Exception)
                {
                    Console.Error.WriteLine($"{Program.Quest.Name}: no {ItemId} in {Category}");
                    throw;
                }
            }

            if (TextRecordId1 > 0)
            {
                item += $" [{TextRecordId1}]";
            }
            if (TextRecordId2 > 0)
            {
                item += $" [{TextRecordId2}]";
            }

            return(item);
        }
Ejemplo n.º 9
0
        public static bool EconomyTweak_h_MakeConsumption(Town town, Dictionary <ItemCategory, float> categoryDemand, Dictionary <ItemCategory, int> saleLog)
        {
            bool flag = EconomyTweak_h_globalConstants.EconomyTweak_h_DebugLevel > 0;

            if (flag)
            {
                using (StreamWriter streamWriter = File.AppendText(EconomyTweak_h_globalConstants.EconomyTweak_h_path + "EconomyTweak_h_log.txt"))
                {
                    streamWriter.WriteLine("EconomyTweak_h_MakeConsumption");
                }
                bool economyTweak_h_DebugDisplay = EconomyTweak_h_globalConstants.EconomyTweak_h_DebugDisplay;
                if (economyTweak_h_DebugDisplay)
                {
                    InformationManager.DisplayMessage(new InformationMessage("EconomyTweak_h_MakeConsumption"));
                }
            }
            EconomyTweak_h_Dictionaries.EconomyTweak_h_TownDemandFulfilledDictionary[town] = 0f;
            saleLog.Clear();
            TownMarketData marketData = town.MarketData;
            ItemRoster     itemRoster = town.Owner.ItemRoster;
            List <int>     list       = Enumerable.Range(0, itemRoster.Count - 1).ToList <int>();

            list.Shuffle <int>();
            foreach (int num in list)
            {
                ItemObject itemAtIndex = itemRoster.GetItemAtIndex(num);
                if (itemAtIndex is not null)
                {
                    int          elementNumber = itemRoster.GetElementNumber(num);
                    ItemCategory itemCategory  = itemAtIndex.GetItemCategory();
                    float        num2          = categoryDemand[itemCategory];
                    bool         flag2         = EconomyTweak_h_Dictionaries.EconomyTweak_h_TownCategoryWorkshopPriceFactorDictionary.ContainsKey(new ValueTuple <Town, ItemCategory>(town, itemCategory));
                    if (flag2)
                    {
                        num2 /= EconomyTweak_h_Dictionaries.EconomyTweak_h_TownCategoryWorkshopPriceFactorDictionary[new ValueTuple <Town, ItemCategory>(town, itemCategory)];
                    }
                    bool flag3 = EconomyTweak_h_Dictionaries.EconomyTweak_h_TownCategoryProsperityPriceFactorDictionary.ContainsKey(new ValueTuple <Town, ItemCategory>(town, itemCategory));
                    if (flag3)
                    {
                        num2 /= EconomyTweak_h_Dictionaries.EconomyTweak_h_TownCategoryProsperityPriceFactorDictionary[new ValueTuple <Town, ItemCategory>(town, itemCategory)];
                    }
                    float num3  = (float)EconomyTweak_h_globalConstants.EconomyTweak_h_OptimalStockPeriodOverconsumption * num2 / (float)itemAtIndex.Value;
                    float num4  = num2;
                    bool  flag4 = (float)elementNumber > num3;
                    if (flag4)
                    {
                        num4 = (float)MBRandom.RoundRandomized(num4 * (float)elementNumber / num3);
                    }
                    bool flag5 = num4 > 0.01f;
                    if (flag5)
                    {
                        int  price = marketData.GetPrice(itemAtIndex, null, false, null);
                        int  num5  = MBRandom.RoundRandomized(num4 / (float)itemAtIndex.Value);
                        int  num6  = num5;
                        bool flag6 = num5 > elementNumber;
                        if (flag6)
                        {
                            num6 = elementNumber;
                        }
                        bool flag7 = num6 > elementNumber;
                        if (flag7)
                        {
                            num6 = elementNumber;
                        }
                        //itemRoster.AddToCountsAtIndex(num, -num6);
                        itemRoster.AddToCounts(itemAtIndex, -num6);
                        town.ChangeGold(num6 * price);
                        int num7 = 0;
                        saleLog.TryGetValue(itemCategory, out num7);
                        saleLog[itemCategory] = num7 + num6;
                        bool isTradeGood = itemCategory.IsTradeGood;
                        if (isTradeGood)
                        {
                            EconomyTweak_h_Dictionaries.EconomyTweak_h_TownDemandFulfilledAdd(town, (float)(num6 * itemAtIndex.Value) / EconomyTweak_h_globalConstants.EconomyTweak_h_ValueOfProsperity);
                        }
                        categoryDemand[itemCategory] = (float)((num5 - num6) * itemAtIndex.Value);
                        bool flag8 = EconomyTweak_h_globalConstants.EconomyTweak_h_DebugLevel > 1;
                        if (flag8)
                        {
                            using (StreamWriter streamWriter2 = File.AppendText(EconomyTweak_h_globalConstants.EconomyTweak_h_path + "EconomyTweak_h_log.txt"))
                            {
                                streamWriter2.WriteLine(string.Concat(new string[]
                                {
                                    "EconomyTweak_h_MakeConsumption itemRoster.Count, i = ",
                                    num.ToString(),
                                    ": , town = ",
                                    town.ToString(),
                                    ", itemAtIndex.Name = ",
                                    itemAtIndex.Name.ToString(),
                                    ", itemAtIndex.Value = ",
                                    itemAtIndex.Value.ToString(),
                                    ", elementNumber = ",
                                    elementNumber.ToString(),
                                    ", itemCategory = ",
                                    itemCategory.ToString(),
                                    ", DemandValue(num) = ",
                                    num4.ToString(),
                                    ", DemandCount(num2) = ",
                                    num5.ToString(),
                                    ", DemandCountAvail(num3) = ",
                                    num6.ToString(),
                                    ", SoldBefore(num4) = ",
                                    num7.ToString(),
                                    ", categoryDemand[itemCategory] = ",
                                    categoryDemand[itemCategory].ToString()
                                }));
                            }
                        }
                    }
                }
            }
            foreach (ItemObject item in ItemObject.All)
            {
                ItemCategory itemCategory2 = item.GetItemCategory();
                bool         flag9         = categoryDemand[itemCategory2] > 0f;
                if (flag9)
                {
                    bool isTradeGood2 = itemCategory2.IsTradeGood;
                    if (isTradeGood2)
                    {
                        EconomyTweak_h_Dictionaries.EconomyTweak_h_TownDemandFulfilledAdd(town, -categoryDemand[itemCategory2] / EconomyTweak_h_globalConstants.EconomyTweak_h_ValueOfProsperity);
                        categoryDemand[itemCategory2] = 0f;
                    }
                }
            }
            //itemRoster.RemoveZeroCounts();
            typeof(ItemRoster).GetMethod("RemoveZeroCounts", BindingFlags.NonPublic | BindingFlags.Static).Invoke(null, null);
            List <Town.SellLog> list2 = new List <Town.SellLog>();

            foreach (KeyValuePair <ItemCategory, int> keyValuePair in saleLog)
            {
                bool flag10 = keyValuePair.Value > 0;
                if (flag10)
                {
                    list2.Add(new Town.SellLog(keyValuePair.Key, keyValuePair.Value));
                }
            }
            Town.SellLog[] value = new Town.SellLog[0];
            value = list2.ToArray <Town.SellLog>();
            FieldInfo field = typeof(Town).GetField("_soldItems", BindingFlags.Instance | BindingFlags.NonPublic);

            field.SetValue(town, value);
            bool flag11 = EconomyTweak_h_globalConstants.EconomyTweak_h_DebugLevel > 1;

            if (flag11)
            {
                foreach (Town.SellLog sellLog in town.SoldItems)
                {
                    using (StreamWriter streamWriter3 = File.AppendText(EconomyTweak_h_globalConstants.EconomyTweak_h_path + "EconomyTweak_h_log.txt"))
                    {
                        streamWriter3.WriteLine(string.Concat(new string[]
                        {
                            "EconomyTweak_h_MakeConsumption town.SoldItems: town = ",
                            town.ToString(),
                            ", sellLog.Category = ",
                            sellLog.Category.ToString(),
                            ", sellLog.Number = ",
                            sellLog.Number.ToString()
                        }));
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 10
0
 /*
 public static IGui.EditorType getEditorType(ItemCategory itemCategory)
 {
     switch (itemCategory)
     {
     }
 }
 */
 public static string CategoryLookup(ItemCategory itemCategory)
 {
     return itemCategory.ToString().Replace('_', ' ');
 }
Ejemplo n.º 11
0
 public void Setup(ItemCategory name, int unlocked, int total)
 {
     this.categoryName.set_text(name.ToString().ToUpper());
     this.unlockCount.set_text(string.Format("UNLOCKED {0}/{1}", (object)unlocked, (object)total));
 }
Ejemplo n.º 12
0
 public void Setup(ItemCategory name, int unlocked, int total)
 {
     this.categoryName.text = name.ToString().ToUpper();
     this.unlockCount.text  = string.Format("UNLOCKED {0}/{1}", unlocked, total);
 }
Ejemplo n.º 13
0
 public static void SetHaveItem(ItemCategory category, int num, bool haveAlready)
 {
     PlayerPrefs.SetInt("Item_" + category.ToString() + "_" + num, (haveAlready) ? (1) : (0));
     PlayerPrefs.Save();
 }
Ejemplo n.º 14
0
        public static bool EconomyTweak_h_GetSupplyDemandForCategory(Town town, ItemCategory category, float dailySupply, float dailyDemand, float oldSupply, float oldDemand, ref ValueTuple <float, float> __result)
        {
            float num  = dailySupply;
            float num2 = (float)EconomyTweak_h_globalConstants.EconomyTweak_h_OptimalStockPeriodPrice * dailyDemand;
            float item = oldDemand * MathF.Pow(dailyDemand / oldDemand, 0.2f);
            float num3 = MathF.Pow((num2 + dailyDemand + 1f) / (num + dailyDemand + 1f), EconomyTweak_h_globalConstants.EconomyTweak_h_LongtermPriceMultiplierExpValue);
            bool  flag = oldSupply > 10f;

            if (flag)
            {
                oldSupply = MathF.Clamp(oldDemand / oldSupply, 0.5f, 1.5f);
            }
            float num4 = oldSupply * MathF.Pow(num3 / oldSupply, 0.2f);

            num4     = MathF.Clamp(num4, 0.4f, 10f);
            __result = new ValueTuple <float, float>(num4, item);
            bool flag2 = EconomyTweak_h_globalConstants.EconomyTweak_h_DebugLevel > 0;

            if (flag2)
            {
                using (StreamWriter streamWriter = File.AppendText(EconomyTweak_h_globalConstants.EconomyTweak_h_path + "EconomyTweak_h_log.txt"))
                {
                    streamWriter.WriteLine("EconomyTweak_h_GetSupplyDemandForCategory");
                }
                bool economyTweak_h_DebugDisplay = EconomyTweak_h_globalConstants.EconomyTweak_h_DebugDisplay;
                if (economyTweak_h_DebugDisplay)
                {
                    InformationManager.DisplayMessage(new InformationMessage("EconomyTweak_h_GetSupplyDemandForCategory"));
                }
                bool flag3 = EconomyTweak_h_globalConstants.EconomyTweak_h_DebugLevel > 1;
                if (flag3)
                {
                    using (StreamWriter streamWriter2 = File.AppendText(EconomyTweak_h_globalConstants.EconomyTweak_h_path + "EconomyTweak_h_log.txt"))
                    {
                        streamWriter2.WriteLine(string.Concat(new string[]
                        {
                            "town = ",
                            town.ToString(),
                            ", category = ",
                            category.ToString(),
                            ", dailySupply = ",
                            dailySupply.ToString(),
                            ", dailyDemand = ",
                            dailyDemand.ToString(),
                            ", oldSupply = ",
                            oldSupply.ToString(),
                            ", oldDemand = ",
                            oldDemand.ToString(),
                            ", EconomyTweak_h_LongtermPriceMultiplier = ",
                            num3.ToString(),
                            ", newDemand(item) = ",
                            item.ToString(),
                            ", newSupply(num) = ",
                            num4.ToString(),
                            ", EconomyTweak_h_GetSupplyDemandForCategory(result) = ",
                            __result.ToString()
                        }));
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 15
0
 public void Setup(ItemCategory name, int unlocked, int total)
 {
     categoryName.text = name.ToString().ToUpper();
     unlockCount.text  = $"UNLOCKED {unlocked}/{total}";
 }
Ejemplo n.º 16
0
 public void Set(ItemCategory itemCategory)
 {
     category      = itemCategory;
     nameText.text = itemCategory.ToString();
 }
Ejemplo n.º 17
0
 public static void SetIsItemBuyable(ItemCategory category, int num, bool isBuyable)
 {
     PlayerPrefs.SetInt("Item_" + category.ToString() + "_" + num + "_Buyable", (isBuyable) ? (1) : (0));
     PlayerPrefs.Save();
 }
Ejemplo n.º 18
0
        private bool _validateDataGrid(DataGridView mapGrid, out ItemDetail itemDetail)
        {
            itemDetail = new ItemDetail();

            DataGridViewRow row = mapGrid.Rows[0];

            if (row == null)
            {
                throw new IndexOutOfRangeException("No rows found");
            }

            // Validate inline row details
            AllErrors.Clear();
            if (row.ValidateDependentProperties(_columntype) == false)
            {
                AllErrors.Add("JewelType", "JewelType is required.");
            }

            if (row.ValidateDependentProperties(_columnjewelnumber) == false)
            {
                AllErrors.Add("JewelNumber", "JewelNumber is required.");
            }

            if (row.ValidateDependentProperties(_columnntwt) == false)
            {
                AllErrors.Add("MetalWeight", "Total MetalWeight is required.");
            }

            if (JewelHasStone)
            {
                if (IsStoneMode)
                {
                    if (row.ValidateDependentProperties(_columndiawt) == false)
                    {
                        AllErrors.Add("DiamondWeight", "Total Diamond Weight is required.");
                    }

                    if (row.ValidateDependentProperties(_columndiapcs) == false)
                    {
                        AllErrors.Add("DiamondPcs", "Total Diamond Pcs required.");
                    }

                    if (row.ValidateDependentProperties(_columngrwt, _columndiawt))
                    {
                        if (row.GetParsedCellValue <decimal>(_columngrwt) - row.GetParsedCellValue <decimal>(_columndiawt) < 0)
                        {
                            AllErrors.Add("InvalidDiamondWeight", "Invalid diamond weight.");
                        }
                    }
                }
                else if (IsColorStoneMode)
                {
                    if (row.ValidateDependentProperties(_columncstonewt) == false)
                    {
                        AllErrors.Add("ColorStoneWeight", "Total ColorStone Weight is required.");
                    }

                    if (row.ValidateDependentProperties(_columncstonepcs) == false)
                    {
                        AllErrors.Add("ColorStonePcs", "Total ColorStone Pcs is required.");
                    }

                    if (row.ValidateDependentProperties(_columngrwt, _columncstonewt))
                    {
                        if (row.GetParsedCellValue <decimal>(_columngrwt) - row.GetParsedCellValue <decimal>(_columncstonewt) < 0)
                        {
                            AllErrors.Add("InvalidColorStoneWeight", "Invalid ColorStone weight.");
                        }
                    }
                }

                if (row.ValidateDependentProperties(_columngrwt, _columndiawt, _columncstonewt))
                {
                    if (row.GetParsedCellValue <decimal>(_columngrwt) - (row.GetParsedCellValue <decimal>(_columndiawt) + row.GetParsedCellValue <decimal>(_columncstonewt)) < 0)
                    {
                        AllErrors.Add("InvalidTotalWeight", "Invalid total stone weights.");
                    }
                }
            }

            if (row.ValidateDependentProperties(_columnamount) == false)
            {
                AllErrors.Add("TotalAmount", "TotalAmount is required.");
            }

            if (AllErrors.Count > 0)
            {
                MessageBox.Show(AllErrors.ErrorMessageString(), Constants.ALERTMESSAGEHEADER);
                return(false);
            }

            if (JewelHasStone)
            {
                if (IsStoneMode)
                {
                    // Validate DiamondPcs with the bifercation row details
                    Int32   returnValdiaPcs = default(Int32);
                    Decimal returnValdiaWt  = default(decimal);
                    var     diaPcs          = Convert.ToInt32(row.GetCellValue(_columndiapcs));
                    var     diaWt           = Convert.ToDecimal(row.GetCellValue(_columndiawt));

                    foreach (DataGridViewRow curRow in mapGrid.Rows)
                    {
                        if (curRow.ValidateDependentProperties(_columndiapcsdetails) && curRow.ValidateDependentProperties(_columndiawtdetails))
                        {
                            returnValdiaPcs += Convert.ToInt32(curRow.Cells[_columndiapcsdetails.ToLowerCaseColumnName()].Value);
                        }
                        if (curRow.ValidateDependentProperties(_columndiawtdetails) && curRow.ValidateDependentProperties(_columndiapcsdetails))
                        {
                            returnValdiaWt += Convert.ToDecimal(curRow.Cells[_columndiawtdetails.ToLowerCaseColumnName()].Value);
                        }
                    }

                    if (returnValdiaPcs != diaPcs)
                    {
                        AllErrors.Add("InvalidDiamondPcs", "Invalid diamond pcs count.");
                    }

                    if (returnValdiaWt != diaWt)
                    {
                        AllErrors.Add("TotalDiamondPcs", "Total diamond weight must match with sum of diamonds weight.");
                    }

                    if (mapGrid.Rows.Cast <DataGridViewRow>().Where(curRow => curRow.ValidateDependentProperties(_columnavrdia)).Any(curRow => row.ValidateDependentProperties(_columndiapr) == false))
                    {
                        AllErrors.Add("TotalDiamondPrices", "Invalid diamond prices, please define costing.");
                    }

                    if (ItemCategory == JewelItemCategory.Gold && false == CostingRate.CertificateRate.Items.Any(x => x.RangeMinValue <= diaWt && x.RangeMaxValue >= diaWt))
                    {
                        AllErrors.Add("CertificateCosting", "Certificate costing is not defined.");
                    }
                }
                else if (IsColorStoneMode)
                {
                    if (row.ValidateDependentProperties(_columncstonepcs) == false)
                    {
                        AllErrors.Add("ColorStonePices", "ColorStone pcs is required.");
                    }

                    if (row.ValidateDependentProperties(_columncstonewt) == false)
                    {
                        AllErrors.Add("ColorStoneWeight", "Total ColorStoneWeight is required.");
                    }
                    else
                    {
                        var grwt     = Convert.ToDecimal(row.Cells[_columngrwt.ToLowerCaseColumnName()].Value);
                        var cstonewt = Convert.ToDecimal(row.Cells[_columncstonewt.ToLowerCaseColumnName()].Value);
                        if ((grwt - cstonewt) <= 0)
                        {
                            AllErrors.Add("ColorStoneWeight", "Invalid Total ColorStone Weight.");
                        }
                    }
                }
            }

            if (AllErrors.Count > 0)
            {
                MessageBox.Show(AllErrors.ErrorMessageString(), Constants.ALERTMESSAGEHEADER);
                return(false);
            }

            itemDetail.ItemDescription   = row.GetCellValue(_columntype);
            itemDetail.CertificateNumber = row.GetCellValue(_columncerno);
            itemDetail.DesignCode        = row.GetCellValue(_columndesignno);
            itemDetail.ItemCategory      = ItemCategory.ToString();
            itemDetail.TotalWeight       = Convert.ToDecimal(row.GetCellValue(_columngrwt, true));
            itemDetail.StampingCharges   = Convert.ToDecimal(row.GetCellValue(_columnstamp, true));
            itemDetail.LabourCharges     = Convert.ToDecimal(row.GetCellValue(_columnlabr, true));

            row.GetCellValue(_columnmetaltype);

            itemDetail.MetalDetail = new MetalDetail
            {
                MetalKT        = row.GetCellValue(_columnmetaltype),
                MetalNetAmount = Convert.ToDecimal(row.GetCellValue(_columngamt)),
                MetalNetWt     = Convert.ToDecimal(row.GetCellValue(_columnntwt)),
                MetalType      = row.GetCellValue(_columnmetaltype)
            };

            if (JewelHasStone)
            {
                var stoneAmount = 0M;
                if (IsStoneMode)
                {
                    itemDetail.CertificateCharges = Convert.ToDecimal(row.GetCellValue(_columncert));
                    // I am unknown
                    Func <List <StoneMetaDetail> > getMetaData = () => (from DataGridViewRow gridRow in mapGrid.Rows
                                                                        where
                                                                        gridRow.ValidateDependentProperties(_columnavrdia) &&
                                                                        gridRow.ValidateDependentProperties(_columndiapr)
                                                                        select new StoneMetaDetail
                    {
                        StoneSieveSz = gridRow.GetCellValue(_columnsievsz),
                        StoneWt = Convert.ToDecimal(gridRow.GetCellValue(_columndiawtdetails)),
                        StonePcs = Convert.ToInt32(gridRow.GetCellValue(_columndiapcsdetails)),
                        StoneValue = Convert.ToDecimal(gridRow.GetCellValue(_columndiaval))
                    }).ToList();

                    var detail = new StoneDetail
                    {
                        StoneType     = row.GetCellValue(_columnstonetype),
                        StoneNetWt    = Convert.ToDecimal(row.GetCellValue(_columndiawt)),
                        TotalStonePcs = Convert.ToInt32(row.GetCellValue(_columndiapcs)),
                        StoneChart    = new StoneChart
                        {
                            StoneMetaDetailList = getMetaData.Invoke()
                        }
                    };

                    stoneAmount            = detail.StoneChart.StoneMetaDetailList.Sum(x => x.StoneValue);
                    detail.StoneNetAmount  = stoneAmount;
                    itemDetail.StoneDetail = detail;
                }
                if (IsColorStoneMode)
                {
                    itemDetail.ColorStoneDetail = new ColorStoneDetail
                    {
                        ColorStoneType      = row.GetCellValue(_columncsstonetype),
                        ColorStoneNetWt     = Convert.ToDecimal(row.GetCellValue(_columncstonewt)),
                        ColorStoneNetAmount = Convert.ToDecimal(row.GetCellValue(_columndiavalsum)) - stoneAmount,
                        ColorTotalStonePcs  = Convert.ToInt32(row.GetCellValue(_columncstonepcs))
                    };
                }
            }

            return(true);
        }
Ejemplo n.º 19
0
        public static bool EconomyTweak_h_GetBasePriceFactor(ItemCategory itemCategory, float inStoreValue, float supply, float demand, bool isSelling, int transferValue, ref float __result)
        {
            bool flag = isSelling;

            if (flag)
            {
                inStoreValue += (float)transferValue;
            }
            float num   = (float)EconomyTweak_h_globalConstants.EconomyTweak_h_OptimalStockPeriodPrice * demand;
            float num2  = MathF.Pow((num + demand + 1f) / (inStoreValue + demand + 1f), EconomyTweak_h_globalConstants.EconomyTweak_h_ShorttermPriceMultiplierExpValue);
            bool  flag2 = supply <= 10f;

            if (flag2)
            {
                num2 *= supply;
            }
            bool flag3 = itemCategory == DefaultItemCategories.Unassigned;

            if (flag3)
            {
                num2 = MathF.Clamp(num2, 0.2f, 10f);
            }
            num2     = MathF.Clamp(num2, 0.01f, 100f);
            __result = num2;
            bool flag4 = EconomyTweak_h_globalConstants.EconomyTweak_h_DebugLevel > 2;

            if (flag4)
            {
                using (StreamWriter streamWriter = File.AppendText(EconomyTweak_h_globalConstants.EconomyTweak_h_path + "EconomyTweak_h_log.txt"))
                {
                    streamWriter.WriteLine("EconomyTweak_h_GetBasePriceFactor");
                }
                bool economyTweak_h_DebugDisplay = EconomyTweak_h_globalConstants.EconomyTweak_h_DebugDisplay;
                if (economyTweak_h_DebugDisplay)
                {
                    InformationManager.DisplayMessage(new InformationMessage("EconomyTweak_h_GetBasePriceFactor"));
                }
                bool flag5 = EconomyTweak_h_globalConstants.EconomyTweak_h_DebugLevel > 3;
                if (flag5)
                {
                    using (StreamWriter streamWriter2 = File.AppendText(EconomyTweak_h_globalConstants.EconomyTweak_h_path + "EconomyTweak_h_log.txt"))
                    {
                        streamWriter2.WriteLine(string.Concat(new string[]
                        {
                            "itemCategory = ",
                            itemCategory.ToString(),
                            ", inStoreValue = ",
                            inStoreValue.ToString(),
                            ", supply = ",
                            supply.ToString(),
                            ", demand = ",
                            demand.ToString(),
                            ", isSelling = ",
                            isSelling.ToString(),
                            ", transferValue = ",
                            transferValue.ToString(),
                            ", EconomyTweak_h_OptimalStockValue = ",
                            num.ToString(),
                            ", EconomyTweak_h_GetBasePriceFactor(result) = ",
                            __result.ToString()
                        }));
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 20
0
/*
 *      public static IGui.EditorType getEditorType(ItemCategory itemCategory)
 *      {
 *          switch (itemCategory)
 *          {
 *          }
 *      }
 */

        public static string CategoryLookup(ItemCategory itemCategory)
        {
            return(itemCategory.ToString().Replace('_', ' '));
        }
Ejemplo n.º 21
0
 public new string GetType()
 {
     return(type.ToString());
 }
Ejemplo n.º 22
0
 public static Label CategoryToLabel(ItemCategory category, int floor)
 {
     return((Label)Enum.Parse(typeof(Label), category.ToString() + ((2 + floor) / 2).ToString()));
 }
Ejemplo n.º 23
0
        public static bool EconomyTweak_h_GetDailyDemandForCategory(Town town, ItemCategory category, int extraProsperity, ref float __result)
        {
            float num = 0f;

            for (int i = 0; i < town.Workshops.Length; i++)
            {
                for (int j = 0; j < town.Workshops[i].WorkshopType.Productions.Count; j++)
                {
                    IEnumerable <ValueTuple <ItemCategory, int> > inputs = town.Workshops[i].WorkshopType.Productions[j].Inputs;
                    foreach (ValueTuple <ItemCategory, int> valueTuple in inputs)
                    {
                        bool flag = category == valueTuple.Item1;
                        if (flag)
                        {
                            float averageValue = category.AverageValue;
                            num += town.Workshops[i].WorkshopType.Productions[j].ConversionSpeed / averageValue;
                        }
                    }
                }
            }
            float num2  = Math.Max(1f, town.Prosperity);
            float num3  = Math.Max(1f, num2 - 3000f);
            float num4  = category.BaseDemand * EconomyTweak_h_globalConstants.EconomyTweak_h_DemandMultiplier * num2;
            float num5  = category.LuxuryDemand * EconomyTweak_h_globalConstants.EconomyTweak_h_DemandMultiplier * num3;
            float num6  = num4 + num5;
            bool  flag2 = category.BaseDemand < 1E-08f;

            if (flag2)
            {
                num6 = num2 * 0.01f;
            }
            EconomyTweak_h_Dictionaries.EconomyTweak_h_TownCategoryWorkshopPriceFactorDictionary[new ValueTuple <Town, ItemCategory>(town, category)] = MathF.Clamp(1f + num / (category.BaseDemand / 2f + category.LuxuryDemand / 2f + num), 0.5f, 1.5f);
            num6 *= EconomyTweak_h_Dictionaries.EconomyTweak_h_TownCategoryWorkshopPriceFactorDictionary[new ValueTuple <Town, ItemCategory>(town, category)];
            EconomyTweak_h_Dictionaries.EconomyTweak_h_TownCategoryProsperityPriceFactorDictionary[new ValueTuple <Town, ItemCategory>(town, category)] = MathF.Clamp(MathF.Pow(3000f / (town.Prosperity + 1f), EconomyTweak_h_globalConstants.EconomyTweak_h_ProsperityPriceFactorExpValue), 0.5f, 1.5f);
            num6 *= EconomyTweak_h_Dictionaries.EconomyTweak_h_TownCategoryProsperityPriceFactorDictionary[new ValueTuple <Town, ItemCategory>(town, category)];
            float num7  = 0f;
            float num8  = town.FoodStocks + town.FoodChange * (float)EconomyTweak_h_globalConstants.EconomyTweak_h_OptimalStockPeriodFood - town.Prosperity / 50f;
            bool  flag3 = num8 < 0f;

            if (flag3)
            {
                bool flag4 = category.Properties == ItemCategory.Property.BonusToFoodStores;
                if (flag4)
                {
                    num7  = Math.Min(-num8, num6 * 0.1f);
                    num6 += num7;
                }
            }
            bool flag5 = !category.IsTradeGood;

            if (flag5)
            {
                num6 *= EconomyTweak_h_globalConstants.EconomyTweak_h_EquipmentDemandMultiplier;
            }
            __result = num6;
            bool flag6 = EconomyTweak_h_globalConstants.EconomyTweak_h_DebugLevel > 0;

            if (flag6)
            {
                using (StreamWriter streamWriter = File.AppendText(EconomyTweak_h_globalConstants.EconomyTweak_h_path + "EconomyTweak_h_log.txt"))
                {
                    streamWriter.WriteLine("EconomyTweak_h_GetDailyDemandForCategory");
                }
                bool economyTweak_h_DebugDisplay = EconomyTweak_h_globalConstants.EconomyTweak_h_DebugDisplay;
                if (economyTweak_h_DebugDisplay)
                {
                    InformationManager.DisplayMessage(new InformationMessage("EconomyTweak_h_GetDailyDemandForCategory"));
                }
                bool flag7 = EconomyTweak_h_globalConstants.EconomyTweak_h_DebugLevel > 1;
                if (flag7)
                {
                    using (StreamWriter streamWriter2 = File.AppendText(EconomyTweak_h_globalConstants.EconomyTweak_h_path + "EconomyTweak_h_log.txt"))
                    {
                        streamWriter2.WriteLine(string.Concat(new string[]
                        {
                            "town = ",
                            town.ToString(),
                            ", category = ",
                            category.ToString(),
                            ", EconomyTweak_h_workShopProduction = ",
                            num.ToString(),
                            ", BaseDemand(num3) = ",
                            num4.ToString(),
                            ", LuxuryDemand(num4) = ",
                            num5.ToString(),
                            ", EconomyTweak_h_TownCategoryWorkshopPriceFactorDictionary = ",
                            EconomyTweak_h_Dictionaries.EconomyTweak_h_TownCategoryWorkshopPriceFactorDictionary[new ValueTuple <Town, ItemCategory>(town, category)].ToString(),
                            ", EconomyTweak_h_TownCategoryProsperityPriceFactorDictionary = ",
                            EconomyTweak_h_Dictionaries.EconomyTweak_h_TownCategoryProsperityPriceFactorDictionary[new ValueTuple <Town, ItemCategory>(town, category)].ToString(),
                            ", EconomyTweak_h_foodShortageDemand = ",
                            num7.ToString(),
                            ", category.IsTradeGood = ",
                            category.IsTradeGood.ToString(),
                            ", EconomyTweak_h_GetDailyDemandForCategory(result) = ",
                            __result.ToString()
                        }));
                    }
                }
            }
            return(false);
        }