Sell value for wine

This commit is contained in:
2026-10-31 19:55:15 -03:00
parent b08de6bf81
commit facbbb07da
2 changed files with 32 additions and 10 deletions
+17 -9
View File
@@ -157,10 +157,13 @@ export const JUICER_PRESSES = 4;
// what juice sells for, as a multiple of what the items pressed to make it sell for
export const JUICE_VALUE = 1.2;
// what wine sells for, as a multiple of what the juice it's fermented from sells for, mB for mB
export const WINE_VALUE = 2;
// juice is one fluid for every fruit, like create's potion fluid: which fruit sits in its data, { item }. it's named
// after that item, "Strawberry Juice", in the color its bworld:juiceable says, and sells for JUICE_VALUE times the
// items it took. wine is too, fermented from the juice (see fermenting.ts), keeping its fruit: "Strawberry Wine"
// items it took. wine is too, fermented from the juice (see fermenting.ts), keeping its fruit: "Strawberry Wine", and
// sells for WINE_VALUE times that juice
function register_juice_and_wine(ctx: SharedContext) {
const item_of = (data: unknown) => {
const item = (data as { item?: unknown } | undefined)?.item;
@@ -177,15 +180,20 @@ function register_juice_and_wine(ctx: SharedContext) {
return item && juiceable(item)?.color;
},
});
ctx.fluids.register("bworld:wine", from_fruit("Wine"));
ctx.fluids.register("bworld:juice", {
...from_fruit("Juice"),
// what 1000 mB of the fruit's juice sells for
const juice_value = (data: unknown) => {
const item = item_of(data);
if (!item) return undefined;
const juice = juiceable(item)?.juice;
const value = ctx.items.sell_value(item);
return juice && value !== undefined ? JUICE_VALUE * value * 1000 / juice : undefined;
};
ctx.fluids.register("bworld:juice", { ...from_fruit("Juice"), sell_value: juice_value });
ctx.fluids.register("bworld:wine", {
...from_fruit("Wine"),
sell_value(data) {
const item = item_of(data);
if (!item) return undefined;
const juice = juiceable(item)?.juice;
const value = ctx.items.sell_value(item);
return juice && value !== undefined ? JUICE_VALUE * value * 1000 / juice : undefined;
const value = juice_value(data);
return value === undefined ? undefined : WINE_VALUE * value;
},
});
}