90 lines
4.5 KiB
JavaScript
90 lines
4.5 KiB
JavaScript
"use strict";
|
|
|
|
const GROUND_TYPE_ORDER = Object.freeze(["soil", "dirt", "concrete", "blanket", "foot_massage", "ice", "laboratory"]);
|
|
const GROUND_TYPES = Object.freeze({
|
|
// デフォルト地面ID。表示名は「砂」。
|
|
soil: Object.freeze({ id: "soil", label: "砂", description: "普通の地面。", stressMultiplier: 1.0, grassMultiplier: 1.0, grassGrowthMultiplier: 1.0 }),
|
|
dirt: Object.freeze({ id: "dirt", label: "土", description: "草がよく育つ地面。", stressMultiplier: 1.0, grassMultiplier: 1.75, grassGrowthMultiplier: 2.45 }),
|
|
concrete: Object.freeze({ id: "concrete", label: "コンクリート", description: "草が生えない", stressMultiplier: 1.0, grassMultiplier: 0.0, grassGrowthMultiplier: 0.0, grassLimit: 0 }),
|
|
blanket: Object.freeze({ id: "blanket", label: "ふわふわ毛布", description: "ストレスが増えにくい", stressMultiplier: 0.5, grassMultiplier: 1.0, grassGrowthMultiplier: 1.0 }),
|
|
foot_massage: Object.freeze({ id: "foot_massage", label: "足つぼ", description: "青いまだら地面。ストレスが増えやすい", stressMultiplier: 1.5, grassMultiplier: 1.0, grassGrowthMultiplier: 1.0 }),
|
|
ice: Object.freeze({ id: "ice", label: "氷", description: "つるつる滑る。草は生えにくい", stressMultiplier: 1.1, grassMultiplier: 0.15, grassGrowthMultiplier: 0.35 }),
|
|
laboratory: Object.freeze({ id: "laboratory", label: "実験室", description: "常に晴れ。草は生えず、ずんちはすぐ消える。", stressMultiplier: 1.0, grassMultiplier: 0.0, grassGrowthMultiplier: 0.0, grassLimit: 0, fixedWeather: "sunny", zunchiStageMultiplier: 8.0, zunchiDecayMultiplier: 520.0 }),
|
|
});
|
|
|
|
function groundDefinition(id = "soil") {
|
|
return GROUND_TYPES[id] || GROUND_TYPES.soil;
|
|
}
|
|
|
|
function groundExists(id = "soil") {
|
|
return Boolean(GROUND_TYPES[id]);
|
|
}
|
|
|
|
function groundLabel(id = "soil") {
|
|
return groundDefinition(id).label || "砂";
|
|
}
|
|
|
|
function groundDescription(id = "soil") {
|
|
return groundDefinition(id).description || "";
|
|
}
|
|
|
|
function normalizedGroundStressMultiplier(id = "soil") {
|
|
const mult = Number(groundDefinition(id).stressMultiplier);
|
|
return Number.isFinite(mult) && mult > 0 ? mult : 1;
|
|
}
|
|
|
|
function normalizedGroundGrassMultiplier(id = "soil") {
|
|
const mult = Number(groundDefinition(id).grassMultiplier);
|
|
return Number.isFinite(mult) && mult >= 0 ? mult : 1;
|
|
}
|
|
|
|
function normalizedGroundGrassGrowthMultiplier(id = "soil") {
|
|
const def = groundDefinition(id);
|
|
const mult = Number(def.grassGrowthMultiplier ?? def.grassMultiplier);
|
|
return Number.isFinite(mult) && mult >= 0 ? mult : 1;
|
|
}
|
|
|
|
function groundLimitForField(fieldType = "garden") {
|
|
const config = typeof CONFIG !== "undefined" ? CONFIG : null;
|
|
const byField = config?.grassLimitsByField || { cage: 19, garden: 99, park: 299 };
|
|
const fieldLimit = byField[fieldType || "garden"];
|
|
return Number(Number.isFinite(fieldLimit) ? fieldLimit : (config?.grassLimit ?? 99));
|
|
}
|
|
|
|
function groundGrassLimit(id = "soil", fieldType = "garden") {
|
|
const def = groundDefinition(id);
|
|
if (Number.isFinite(def.grassLimit)) return Math.max(0, Math.floor(Number(def.grassLimit)));
|
|
const mult = normalizedGroundGrassMultiplier(def.id);
|
|
if (mult <= 0) return 0;
|
|
const limit = groundLimitForField(fieldType) * mult;
|
|
return Number.isFinite(limit) && limit >= 0 ? Math.floor(limit) : Infinity;
|
|
}
|
|
|
|
function nextGroundTypeId(current = "soil") {
|
|
const index = GROUND_TYPE_ORDER.indexOf(current || "soil");
|
|
return GROUND_TYPE_ORDER[(index + 1 + GROUND_TYPE_ORDER.length) % GROUND_TYPE_ORDER.length] || "soil";
|
|
}
|
|
|
|
function groundTooltipText(id = "soil") {
|
|
const def = groundDefinition(id);
|
|
const desc = def.description || "クリックで切り替え";
|
|
return `${def.label || "じめん"}\n${desc}`;
|
|
}
|
|
|
|
window.TarinaiGround = Object.freeze({
|
|
definitions: GROUND_TYPES,
|
|
order: GROUND_TYPE_ORDER,
|
|
definition: groundDefinition,
|
|
exists: groundExists,
|
|
label: groundLabel,
|
|
description: groundDescription,
|
|
stressMultiplier: normalizedGroundStressMultiplier,
|
|
grassMultiplier: normalizedGroundGrassMultiplier,
|
|
grassGrowthMultiplier: normalizedGroundGrassGrowthMultiplier,
|
|
grassLimit: groundGrassLimit,
|
|
nextId: nextGroundTypeId,
|
|
tooltipText: groundTooltipText,
|
|
fixedWeather(id = "soil") { return groundDefinition(id).fixedWeather || ""; },
|
|
zunchiStageMultiplier(id = "soil") { const v = Number(groundDefinition(id).zunchiStageMultiplier); return Number.isFinite(v) && v > 0 ? v : 1; },
|
|
zunchiDecayMultiplier(id = "soil") { const v = Number(groundDefinition(id).zunchiDecayMultiplier); return Number.isFinite(v) && v > 0 ? v : 1; },
|
|
});
|