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; }
void CureDiseaseService() { CloseWindow(); int numberOfDiseases = 0; if (playerEntity.Disease.IsDiseased()) { numberOfDiseases++; // TODO: Support multiple diseases } if (playerEntity.TimeToBecomeVampireOrWerebeast != 0) { numberOfDiseases++; } if (numberOfDiseases > 0) { // Get base cost int baseCost = 250 * numberOfDiseases; // Apply rank-based discount if this is an Arkay temple baseCost = guild.ReducedCureCost(baseCost); // Apply temple quality and regional price modifiers int costBeforeBargaining = FormulaHelper.CalculateCost(baseCost, buildingDiscoveryData.quality); // Apply bargaining to get final price curingCost = FormulaHelper.CalculateTradePrice(costBeforeBargaining, buildingDiscoveryData.quality, false); // Index correct message const int tradeMessageBaseId = 260; int msgOffset = 0; if (costBeforeBargaining >> 1 <= curingCost) { if (costBeforeBargaining - (costBeforeBargaining >> 2) <= curingCost) { msgOffset = 2; } else { msgOffset = 1; } } // Offer curing at the calculated price. DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow); TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(tradeMessageBaseId + msgOffset); messageBox.SetTextTokens(tokens, this); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No); messageBox.OnButtonClick += ConfirmCuring_OnButtonClick; uiManager.PushWindow(messageBox); } else { // Not diseased DaggerfallUI.MessageBox(30); } }
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(); }
void CureDiseaseService() { CloseWindow(); int numberOfDiseases = GameManager.Instance.PlayerEffectManager.DiseaseCount; if (playerEntity.TimeToBecomeVampireOrWerebeast != 0) { numberOfDiseases++; } // Check holidays for free / cheaper curing uint minutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime(); int holidayId = FormulaHelper.GetHolidayId(minutes, GameManager.Instance.PlayerGPS.CurrentRegionIndex); if (numberOfDiseases > 0 && (holidayId == (int)DFLocation.Holidays.South_Winds_Prayer || holidayId == (int)DFLocation.Holidays.First_Harvest || holidayId == (int)DFLocation.Holidays.Second_Harvest)) { GameManager.Instance.PlayerEffectManager.CureAllDiseases(); playerEntity.TimeToBecomeVampireOrWerebeast = 0; DaggerfallUI.MessageBox(TextManager.Instance.GetText(textDatabase, "freeHolidayCuring")); } else if (numberOfDiseases > 0) { // Get base cost int baseCost = 250 * numberOfDiseases; // Apply rank-based discount if this is an Arkay temple baseCost = guild.ReducedCureCost(baseCost); // Apply temple quality and regional price modifiers int costBeforeBargaining = FormulaHelper.CalculateCost(baseCost, buildingDiscoveryData.quality); // Halve the price on North Winds Prayer holiday if (holidayId == (int)DFLocation.Holidays.North_Winds_Festival) { costBeforeBargaining /= 2; } // Apply bargaining to get final price curingCost = FormulaHelper.CalculateTradePrice(costBeforeBargaining, buildingDiscoveryData.quality, false); // Index correct message const int tradeMessageBaseId = 260; int msgOffset = 0; if (costBeforeBargaining >> 1 <= curingCost) { if (costBeforeBargaining - (costBeforeBargaining >> 2) <= curingCost) { msgOffset = 2; } else { msgOffset = 1; } } // Offer curing at the calculated price. DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow); TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(tradeMessageBaseId + msgOffset); messageBox.SetTextTokens(tokens, this); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No); messageBox.OnButtonClick += ConfirmCuring_OnButtonClick; messageBox.Show(); } else { // Not diseased DaggerfallUI.MessageBox(30); } }
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; }
protected virtual void CureDiseaseService() { int numberOfDiseases = GameManager.Instance.PlayerEffectManager.DiseaseCount; if (playerEntity.TimeToBecomeVampireOrWerebeast != 0) { numberOfDiseases++; } // Check holidays for free / cheaper curing uint minutes = DaggerfallUnity.Instance.WorldTime.DaggerfallDateTime.ToClassicDaggerfallTime(); int holidayId = FormulaHelper.GetHolidayId(minutes, GameManager.Instance.PlayerGPS.CurrentRegionIndex); if (numberOfDiseases > 0 && (holidayId == (int)DFLocation.Holidays.South_Winds_Prayer || holidayId == (int)DFLocation.Holidays.First_Harvest || holidayId == (int)DFLocation.Holidays.Second_Harvest)) { // Just cure and inform player GameManager.Instance.PlayerEffectManager.CureAllDiseases(); playerEntity.TimeToBecomeVampireOrWerebeast = 0; SetText(TextManager.Instance.GetLocalizedText("freeHolidayCuring"), this); ClickAnywhereToClose = true; } else if (numberOfDiseases > 0) { // Get base cost int baseCost = 250 * numberOfDiseases; // Apply rank-based discount if this is an Arkay temple and member baseCost = Guild.ReducedCureCost(baseCost); // Apply temple quality and regional price modifiers int costBeforeBargaining = FormulaHelper.CalculateCost(baseCost, buildingDiscoveryData.quality); // Halve the price on North Winds Prayer holiday if (holidayId == (int)DFLocation.Holidays.North_Winds_Festival) { costBeforeBargaining /= 2; } // Apply bargaining to get final price curingCost = FormulaHelper.CalculateTradePrice(costBeforeBargaining, buildingDiscoveryData.quality, false); // Index correct message int msgOffset = 0; if (costBeforeBargaining >> 1 <= curingCost) { if (costBeforeBargaining - (costBeforeBargaining >> 2) <= curingCost) { msgOffset = 2; } else { msgOffset = 1; } } // Offer curing at the calculated price SetTextTokens(GetCureOfferTokens(msgOffset), this); AddButton(MessageBoxButtons.Yes); AddButton(MessageBoxButtons.No); OnButtonClick += ConfirmCuring_OnButtonClick; } else { // Not diseased SetTextTokens(NoDisease, this); ClickAnywhereToClose = true; } }