Simplify custom world result editing controls
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { InventoryItem, WorldType } from '../types';
|
||||
import { resolveCustomWorldRuleProfile } from '../services/customWorldOwnedSettingLayers';
|
||||
import { CustomWorldProfile, InventoryItem, WorldType } from '../types';
|
||||
import { getRuntimeCustomWorldProfile } from './customWorldRuntime';
|
||||
|
||||
const RARITY_BASE_VALUES: Record<InventoryItem['rarity'], number> = {
|
||||
common: 12,
|
||||
@@ -8,13 +10,40 @@ const RARITY_BASE_VALUES: Record<InventoryItem['rarity'], number> = {
|
||||
legendary: 168,
|
||||
};
|
||||
|
||||
export function getCurrencyName(worldType: WorldType | null) {
|
||||
function resolveEconomyProfile(
|
||||
worldType: WorldType | null,
|
||||
customWorldProfile?: CustomWorldProfile | null,
|
||||
) {
|
||||
const profile =
|
||||
customWorldProfile ??
|
||||
(worldType === WorldType.CUSTOM ? getRuntimeCustomWorldProfile() : null);
|
||||
|
||||
return resolveCustomWorldRuleProfile(profile);
|
||||
}
|
||||
|
||||
export function getCurrencyName(
|
||||
worldType: WorldType | null,
|
||||
customWorldProfile?: CustomWorldProfile | null,
|
||||
) {
|
||||
const ruleProfile = resolveEconomyProfile(worldType, customWorldProfile);
|
||||
if (ruleProfile) {
|
||||
return ruleProfile.resourceLabels.currency;
|
||||
}
|
||||
|
||||
if (worldType === WorldType.XIANXIA) return '灵石';
|
||||
if (worldType === WorldType.WUXIA) return '铜钱';
|
||||
return '钱币';
|
||||
}
|
||||
|
||||
export function getInitialPlayerCurrency(worldType: WorldType | null) {
|
||||
export function getInitialPlayerCurrency(
|
||||
worldType: WorldType | null,
|
||||
customWorldProfile?: CustomWorldProfile | null,
|
||||
) {
|
||||
const ruleProfile = resolveEconomyProfile(worldType, customWorldProfile);
|
||||
if (ruleProfile) {
|
||||
return ruleProfile.economyProfile.initialCurrency;
|
||||
}
|
||||
|
||||
return worldType === WorldType.XIANXIA ? 140 : 160;
|
||||
}
|
||||
|
||||
@@ -55,6 +84,10 @@ export function getNpcBuybackPrice(item: InventoryItem, affinity: number) {
|
||||
return Math.max(4, Math.round(getInventoryItemValue(item) * buybackMultiplier));
|
||||
}
|
||||
|
||||
export function formatCurrency(value: number, worldType: WorldType | null) {
|
||||
return `${value} ${getCurrencyName(worldType)}`;
|
||||
export function formatCurrency(
|
||||
value: number,
|
||||
worldType: WorldType | null,
|
||||
customWorldProfile?: CustomWorldProfile | null,
|
||||
) {
|
||||
return `${value} ${getCurrencyName(worldType, customWorldProfile)}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user