Skip to content

Commit

Permalink
Update to version 4.0.7 with currency consumption fix
Browse files Browse the repository at this point in the history
This release addresses an issue where currency was consumed incorrectly in certain failed test scenarios. Additionally, code has been refactored to enhance clarity and maintainability, including a few variable naming improvements and swapped configuration paths.
  • Loading branch information
AngryBeaver committed Nov 13, 2024
1 parent 569c6b8 commit cef38b7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Changelog
## 4.0.7
- fix consume money on failed check
## 4.0.6
- fix ToolTest migration
## 4.0.5
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Beaver's Crafting Module",
"description": "A Module for crafting, brewing, harvesting, mining, fabricating, gathering, character advancement, tech tree, skill tree, ability tree, downtime activities, factions / organisation reputation, quest logs, skill training",
"id": "beavers-crafting",
"version": "4.0.6",
"version": "4.0.7",
"authors": [
{
"name": "angryBeaver",
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "beavers-crafting",
"title": "Beaver's Crafting",
"version": "4.0.6",
"version": "4.0.7",
"description": "Crafting",
"devDir": "c:\\vtts\\v12.331\\Data\\modules",
"#devDir": "c:\\vtts\\v11.315\\Data\\modules",
"#devDir": "c:\\vtts\\v12.331\\Data\\modules",
"devDir": "c:\\vtts\\v11.315\\Data\\modules",
"main": "src/main.js",
"scripts": {
"build": "npx gulp",
Expand Down
4 changes: 2 additions & 2 deletions src/Crafting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ export class Crafting implements CraftingData {
componentList.push(...this._processComponentResult(this.result._components.consumed));
componentList.push(...this._processComponentResult(this.result._components.produced));
if (this.result._currencyResult !== undefined) {
if (!this.recipe.tests?.consume && this.result.hasError()) {
this.result.revertPayedCurrency();
if (!this.recipe.beaversTests?.consume && this.result.hasError()) {
await this.result.revertPayedCurrency();
}
}
try{
Expand Down
7 changes: 4 additions & 3 deletions src/Result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,14 @@ export class Result implements ResultApi, ResultData {
return;
}
if(this._currencyResult.isConsumed) {
const name = this._currencyResult.name;
const configCurrency = beaversSystemInterface.configCurrencies.find(c=>c.id===name);
const id = this._currencyResult.name;
const configCurrency = beaversSystemInterface.configCurrencies.find(c=>c.id===id);
let name = configCurrency?.label || "";
void await this._currencyResult.pay(this._actor, true);
const component = configCurrency?.component?configCurrency.component:beaversSystemInterface.componentCreate(
{
type:"Currency",
name:configCurrency?.label,
name:name.replaceAll(".","-"),
img:'icons/commodities/currency/coins-assorted-mix-copper-silver-gold.webp'
});
component.quantity = this._currencyResult.value * -1
Expand Down

0 comments on commit cef38b7

Please sign in to comment.