private void UpdateCostAndGold()
        {
            bool modeActionEnabled = false;

            cost = 0;

            if (windowMode == WindowModes.Buy && basketItems != null)
            {
                for (int i = 0; i < basketItems.Count; i++)
                {
                    DaggerfallUnityItem item = basketItems.GetItem(i);
                    modeActionEnabled = true;
                    cost += FormulaHelper.CalculateCost(item.value, buildingDiscoveryData.quality) * item.stackCount;
                }
            }
            else if (remoteItems != null)
            {
                for (int i = 0; i < remoteItems.Count; i++)
                {
                    DaggerfallUnityItem item = remoteItems.GetItem(i);
                    switch (windowMode)
                    {
                    case WindowModes.Sell:
                        modeActionEnabled = true;
                        cost += FormulaHelper.CalculateCost(item.value, buildingDiscoveryData.quality) * item.stackCount;
                        break;

                    case WindowModes.SellMagic:     // TODO: Fencing base price higher and guild rep affects it. Implement new formula or can this be used?
                        modeActionEnabled = true;
                        cost += FormulaHelper.CalculateCost(item.value, buildingDiscoveryData.quality);
                        break;

                    case WindowModes.Repair:
                        if (!item.RepairData.IsBeingRepaired())
                        {
                            modeActionEnabled = true;
                            cost += FormulaHelper.CalculateItemRepairCost(item.value, buildingDiscoveryData.quality, item.currentCondition, item.maxCondition, guild) * item.stackCount;
                        }
                        break;

                    case WindowModes.Identify:
                        if (!item.IsIdentified)
                        {
                            modeActionEnabled = true;
                            // Identify spell remains free
                            if (!usingIdentifySpell)
                            {
                                cost += FormulaHelper.CalculateItemIdentifyCost(item.value, guild);
                            }
                        }
                        break;
                    }
                }
            }
            costLabel.Text           = cost.ToString();
            goldLabel.Text           = PlayerEntity.GetGoldAmount().ToString();
            modeActionButton.Enabled = modeActionEnabled;
        }
        private void UpdateCostAndGold()
        {
            cost = 0;

            // Identify spell remains free
            if (usingIdentifySpell)
            {
                costLabel.Text = cost.ToString();
                goldLabel.Text = PlayerEntity.GetGoldAmount().ToString();
                return;
            }

            if (windowMode == WindowModes.Buy && basketItems != null)
            {
                for (int i = 0; i < basketItems.Count; i++)
                {
                    DaggerfallUnityItem item = basketItems.GetItem(i);
                    cost += FormulaHelper.CalculateCost(item.value, buildingDiscoveryData.quality) * item.stackCount;
                }
            }
            else if (remoteItems != null)
            {
                for (int i = 0; i < remoteItems.Count; i++)
                {
                    DaggerfallUnityItem item = remoteItems.GetItem(i);
                    switch (windowMode)
                    {
                    case WindowModes.Sell:
                        cost += FormulaHelper.CalculateCost(item.value, buildingDiscoveryData.quality) * item.stackCount;
                        break;

                    case WindowModes.Repair:
                        cost += FormulaHelper.CalculateItemRepairCost(item.value, buildingDiscoveryData.quality, item.currentCondition, item.maxCondition, guild) * item.stackCount;
                        break;

                    case WindowModes.Identify:
                        if (!item.IsIdentified)
                        {
                            cost += FormulaHelper.CalculateItemIdentifyCost(item.value, guild);
                        }
                        break;
                    }
                }
            }
            costLabel.Text = cost.ToString();
            goldLabel.Text = PlayerEntity.GetGoldAmount().ToString();
        }
Esempio n. 3
0
        private void UpdateCostAndGold()
        {
            bool modeActionEnabled = false;

            cost = 0;

            if (windowMode == WindowModes.Buy && basketItems != null)
            {
                // Check holidays for half price sales:
                // - Merchants Festival, suns height 10th for normal shops
                // - Tales and Tallows hearth fire 3rd for mages guild
                // - Weapons on Warriors Festival suns dusk 20th
                uint minutes   = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime();
                int  holidayId = FormulaHelper.GetHolidayId(minutes, GameManager.Instance.PlayerGPS.CurrentRegionIndex);

                for (int i = 0; i < basketItems.Count; i++)
                {
                    DaggerfallUnityItem item = basketItems.GetItem(i);
                    modeActionEnabled = true;
                    int itemPrice = FormulaHelper.CalculateCost(item.value, buildingDiscoveryData.quality) * item.stackCount;
                    if ((holidayId == (int)DFLocation.Holidays.Merchants_Festival && guild == null) ||
                        (holidayId == (int)DFLocation.Holidays.Tales_and_Tallow && guild != null && guild.GetFactionId() == (int)FactionFile.FactionIDs.The_Mages_Guild) ||
                        (holidayId == (int)DFLocation.Holidays.Warriors_Festival && guild == null && item.ItemGroup == ItemGroups.Weapons))
                    {
                        itemPrice /= 2;
                    }
                    cost += itemPrice;
                }
            }
            else if (remoteItems != null)
            {
                for (int i = 0; i < remoteItems.Count; i++)
                {
                    DaggerfallUnityItem item = remoteItems.GetItem(i);
                    switch (windowMode)
                    {
                    case WindowModes.Sell:
                        modeActionEnabled = true;
                        cost += FormulaHelper.CalculateCost(item.value, buildingDiscoveryData.quality) * item.stackCount;
                        break;

                    case WindowModes.SellMagic:     // TODO: Fencing base price higher and guild rep affects it. Implement new formula or can this be used?
                        modeActionEnabled = true;
                        cost += FormulaHelper.CalculateCost(item.value, buildingDiscoveryData.quality);
                        break;

                    case WindowModes.Repair:
                        if (!item.RepairData.IsBeingRepaired())
                        {
                            modeActionEnabled = true;
                            cost += FormulaHelper.CalculateItemRepairCost(item.value, buildingDiscoveryData.quality, item.currentCondition, item.maxCondition, guild) * item.stackCount;
                        }
                        break;

                    case WindowModes.Identify:
                        if (!item.IsIdentified)
                        {
                            modeActionEnabled = true;
                            // Identify spell remains free
                            if (!usingIdentifySpell)
                            {
                                cost += FormulaHelper.CalculateItemIdentifyCost(item.value, guild);
                            }
                        }
                        break;
                    }
                }
            }
            costLabel.Text           = cost.ToString();
            goldLabel.Text           = PlayerEntity.GetGoldAmount().ToString();
            modeActionButton.Enabled = modeActionEnabled;
        }