fix: material cancellation refund uses flat 50% per spec §6.3
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m20s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m20s
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
# Circular Dependencies
|
# Circular Dependencies
|
||||||
Generated: 2026-06-08T10:43:31.572Z
|
Generated: 2026-06-08T10:56:12.135Z
|
||||||
Found: 1 circular chain(s) — these MUST be fixed before modifying involved files.
|
Found: 1 circular chain(s) — these MUST be fixed before modifying involved files.
|
||||||
|
|
||||||
1. 1) stores/golem-combat-actions.ts > stores/golem-combat-helpers.ts
|
1. 1) stores/golem-combat-actions.ts > stores/golem-combat-helpers.ts
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"generated": "2026-06-08T10:43:29.519Z",
|
"generated": "2026-06-08T10:56:10.139Z",
|
||||||
"description": "Import dependency graph for src/lib/game. Keys are files, values are arrays of files they import.",
|
"description": "Import dependency graph for src/lib/game. Keys are files, values are arrays of files they import.",
|
||||||
"usage": "To find what a file affects, search for its path in the VALUES. To find what a file depends on, look at its KEY entry."
|
"usage": "To find what a file affects, search for its path in the VALUES. To find what a file depends on, look at its KEY entry."
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -74,13 +74,13 @@ export function cancelEquipmentCrafting(get: GetFn, set: SetFn): void {
|
|||||||
const refunded = refundFabricatorMana(recipe, manaRefund, rawMana, elements);
|
const refunded = refundFabricatorMana(recipe, manaRefund, rawMana, elements);
|
||||||
useManaStore.setState({ rawMana: refunded.rawMana, elements: refunded.elements });
|
useManaStore.setState({ rawMana: refunded.rawMana, elements: refunded.elements });
|
||||||
|
|
||||||
// Refund materials — use reduced amounts (what player actually paid)
|
// Refund materials — flat 50% per spec §6.3
|
||||||
const reduction = getCraftingCostReduction();
|
const reduction = getCraftingCostReduction();
|
||||||
const currentMaterials = get().lootInventory.materials;
|
const currentMaterials = get().lootInventory.materials;
|
||||||
const refundedMaterials = { ...currentMaterials };
|
const refundedMaterials = { ...currentMaterials };
|
||||||
for (const [matId, rawAmount] of Object.entries(recipe.materials)) {
|
for (const [matId, rawAmount] of Object.entries(recipe.materials)) {
|
||||||
const reducedAmount = applyCostReduction(rawAmount, reduction);
|
const reducedAmount = applyCostReduction(rawAmount, reduction);
|
||||||
const refundAmount = Math.floor(reducedAmount * remainingFraction);
|
const refundAmount = Math.floor(reducedAmount * 0.5);
|
||||||
if (refundAmount > 0) {
|
if (refundAmount > 0) {
|
||||||
refundedMaterials[matId] = (refundedMaterials[matId] || 0) + refundAmount;
|
refundedMaterials[matId] = (refundedMaterials[matId] || 0) + refundAmount;
|
||||||
}
|
}
|
||||||
@@ -98,16 +98,13 @@ export function cancelEquipmentCrafting(get: GetFn, set: SetFn): void {
|
|||||||
progress.progress,
|
progress.progress,
|
||||||
progress.required,
|
progress.required,
|
||||||
);
|
);
|
||||||
// Refund materials proportionally to remaining progress
|
// Refund materials — flat 50% per spec §6.3
|
||||||
const recipe = CraftingEquipment.getRecipe(progress.blueprintId);
|
const recipe = CraftingEquipment.getRecipe(progress.blueprintId);
|
||||||
if (recipe) {
|
if (recipe) {
|
||||||
const remainingFraction = progress.required > 0
|
|
||||||
? Math.max(0, (progress.required - progress.progress) / progress.required)
|
|
||||||
: 1;
|
|
||||||
const currentMaterials = get().lootInventory.materials;
|
const currentMaterials = get().lootInventory.materials;
|
||||||
const refundedMaterials = { ...currentMaterials };
|
const refundedMaterials = { ...currentMaterials };
|
||||||
for (const [matId, amount] of Object.entries(recipe.materials)) {
|
for (const [matId, amount] of Object.entries(recipe.materials)) {
|
||||||
const refundAmount = Math.floor(amount * remainingFraction);
|
const refundAmount = Math.floor(amount * 0.5);
|
||||||
if (refundAmount > 0) {
|
if (refundAmount > 0) {
|
||||||
refundedMaterials[matId] = (refundedMaterials[matId] || 0) + refundAmount;
|
refundedMaterials[matId] = (refundedMaterials[matId] || 0) + refundAmount;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user