Files
crystall-punk-14/Content.Client/_CP14/Trading/CP14SellingRequestControl.xaml.cs

50 lines
1.7 KiB
C#
Raw Normal View History

Trading request system (#1460) * mapping public stores update * base selling platform update * basic UI setup * Update coin icon textures Refreshed the c, g, p, and s coin images in the interface textures. This likely improves their appearance or corrects previous visual issues. * parse requests data into UI * selling platform UI state now include price Updated the selling platform UI to display the calculated price of placed items. Moved the UpdateSellingUIState logic from the shared system to the server system, and modified the CP14SellingPlatformUiState to include a price field. The client window now uses the state-provided price instead of a hardcoded value. * Update selling UI state on item placed or removed Added event subscriptions for ItemPlacedEvent and ItemRemovedEvent to update the selling UI state when items are placed or removed from the selling platform. Refactored UpdateSellingUIState to remove the user parameter, as it is no longer needed. * sell button works now Replaces the previous sell request mechanism with a new CP14TradingSellAttempt message for selling items on the platform. Updates client and server logic to use this new message, adds a CanSell helper for item validation, and refactors related UI and event handling code for improved clarity and maintainability. * auto pricing requirements * Refactor reputation reward to use cashback rate Reputation rewards for selling requests are now calculated as a percentage (cashback) of the sale price, rather than a fixed value. Updated the relevant UI, server logic, and prototype fields to reflect this change. Also cleaned up the brad_potions.yml prototype file by removing a duplicate entry and correcting an ID. * request rerolling
2025-06-23 01:21:25 +03:00
using Content.Client._CP14.UserInterface;
using Content.Client._CP14.Workbench;
using Content.Shared._CP14.Trading.Prototypes;
using Content.Shared._CP14.Trading.Systems;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
namespace Content.Client._CP14.Trading;
[GenerateTypedNameReferences]
public sealed partial class CP14SellingRequestControl : Control
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
public event Action? OnSellAttempt;
Public market + Solutions requests (#1503) * Add platform markup to trading platform prices Introduces a PlatformMarkupProcent field to CP14TradingPlatformComponent and applies it to price calculations in both client and server logic. Adds a new public trading platform entity with a higher markup and updates related sprites and metadata. * Add platform markup percent to selling platforms Introduces a PlatformMarkupProcent field to CP14SellingPlatformComponent, allowing selling platforms to apply a markup or markdown to item prices. Updates server logic to use this value when calculating payouts and UI state. Adds a new public selling platform entity with a lower markup in the trade_platform.yml prototype. * Add Brad Potions trading requests prototype Introduces a new YAML prototype defining multiple cp14TradingRequest entries for the BradPotions faction, each specifying requirements for various potion effects with minimum purity and amount. * Apply platform markup to selling prices and payouts Updated the selling request control and platform window to factor in the platform's markup percentage when displaying prices. Adjusted the server-side payout logic to multiply the payout by the platform markup percentage, ensuring consistency between client display and server rewards. * replace mapping to public platforms * bug + remove eepy potions request * Clarify purity requirement in workbench reagent text Updated the reagent requirement string in both English and Russian locale files to indicate that the required purity is '{$purity}%+' instead of just '{$purity}%'. This clarifies that the purity must be at least the specified percentage.
2025-07-06 00:09:03 +03:00
public CP14SellingRequestControl(ProtoId<CP14TradingRequestPrototype> request, float markupProcent, bool active)
Trading request system (#1460) * mapping public stores update * base selling platform update * basic UI setup * Update coin icon textures Refreshed the c, g, p, and s coin images in the interface textures. This likely improves their appearance or corrects previous visual issues. * parse requests data into UI * selling platform UI state now include price Updated the selling platform UI to display the calculated price of placed items. Moved the UpdateSellingUIState logic from the shared system to the server system, and modified the CP14SellingPlatformUiState to include a price field. The client window now uses the state-provided price instead of a hardcoded value. * Update selling UI state on item placed or removed Added event subscriptions for ItemPlacedEvent and ItemRemovedEvent to update the selling UI state when items are placed or removed from the selling platform. Refactored UpdateSellingUIState to remove the user parameter, as it is no longer needed. * sell button works now Replaces the previous sell request mechanism with a new CP14TradingSellAttempt message for selling items on the platform. Updates client and server logic to use this new message, adds a CanSell helper for item validation, and refactors related UI and event handling code for improved clarity and maintainability. * auto pricing requirements * Refactor reputation reward to use cashback rate Reputation rewards for selling requests are now calculated as a percentage (cashback) of the sale price, rather than a fixed value. Updated the relevant UI, server logic, and prototype fields to reflect this change. Also cleaned up the brad_potions.yml prototype file by removing a duplicate entry and correcting an ID. * request rerolling
2025-06-23 01:21:25 +03:00
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
if (!_proto.TryIndex(request, out var indexedRequest))
return;
//Requirements
ItemRequirements.RemoveAllChildren();
foreach (var requirement in indexedRequest.Requirements)
{
ItemRequirements.AddChild(new CP14WorkbenchRequirementControl(requirement));
}
//Coin reward
PriceHolder.RemoveAllChildren();
var economySystem = _entityManager.System<CP14SharedStationEconomySystem>();
Public market + Solutions requests (#1503) * Add platform markup to trading platform prices Introduces a PlatformMarkupProcent field to CP14TradingPlatformComponent and applies it to price calculations in both client and server logic. Adds a new public trading platform entity with a higher markup and updates related sprites and metadata. * Add platform markup percent to selling platforms Introduces a PlatformMarkupProcent field to CP14SellingPlatformComponent, allowing selling platforms to apply a markup or markdown to item prices. Updates server logic to use this value when calculating payouts and UI state. Adds a new public selling platform entity with a lower markup in the trade_platform.yml prototype. * Add Brad Potions trading requests prototype Introduces a new YAML prototype defining multiple cp14TradingRequest entries for the BradPotions faction, each specifying requirements for various potion effects with minimum purity and amount. * Apply platform markup to selling prices and payouts Updated the selling request control and platform window to factor in the platform's markup percentage when displaying prices. Adjusted the server-side payout logic to multiply the payout by the platform markup percentage, ensuring consistency between client display and server rewards. * replace mapping to public platforms * bug + remove eepy potions request * Clarify purity requirement in workbench reagent text Updated the reagent requirement string in both English and Russian locale files to indicate that the required purity is '{$purity}%+' instead of just '{$purity}%'. This clarifies that the purity must be at least the specified percentage.
2025-07-06 00:09:03 +03:00
var originalPrice = economySystem.GetPrice(indexedRequest);
var price = (int?)(originalPrice * markupProcent);
Trading request system (#1460) * mapping public stores update * base selling platform update * basic UI setup * Update coin icon textures Refreshed the c, g, p, and s coin images in the interface textures. This likely improves their appearance or corrects previous visual issues. * parse requests data into UI * selling platform UI state now include price Updated the selling platform UI to display the calculated price of placed items. Moved the UpdateSellingUIState logic from the shared system to the server system, and modified the CP14SellingPlatformUiState to include a price field. The client window now uses the state-provided price instead of a hardcoded value. * Update selling UI state on item placed or removed Added event subscriptions for ItemPlacedEvent and ItemRemovedEvent to update the selling UI state when items are placed or removed from the selling platform. Refactored UpdateSellingUIState to remove the user parameter, as it is no longer needed. * sell button works now Replaces the previous sell request mechanism with a new CP14TradingSellAttempt message for selling items on the platform. Updates client and server logic to use this new message, adds a CanSell helper for item validation, and refactors related UI and event handling code for improved clarity and maintainability. * auto pricing requirements * Refactor reputation reward to use cashback rate Reputation rewards for selling requests are now calculated as a percentage (cashback) of the sale price, rather than a fixed value. Updated the relevant UI, server logic, and prototype fields to reflect this change. Also cleaned up the brad_potions.yml prototype file by removing a duplicate entry and correcting an ID. * request rerolling
2025-06-23 01:21:25 +03:00
PriceHolder.AddChild(new CP14PriceControl(price ?? 10000));
//Rep reward
Reputation.Text = ((price ?? 0) * indexedRequest.ReputationCashback).ToString("0.00");
RequestButton.OnPressed += _ => OnSellAttempt?.Invoke();
RequestButton.Disabled = !active;
}
}