2026-06-25 14:51:58 +09:00
|
|
|
"use strict";
|
|
|
|
|
|
2026-06-25 22:30:35 +09:00
|
|
|
const GROUND_TYPE_ORDER = Object.freeze(["soil", "concrete", "blanket", "foot_massage", "ice"]);
|
2026-06-25 14:51:58 +09:00
|
|
|
const GROUND_TYPES = Object.freeze({
|
|
|
|
|
soil: Object.freeze({ id: "soil", label: "土", description: "いつものじめん", stressMultiplier: 1.0, grassMultiplier: 1.0 }),
|
|
|
|
|
concrete: Object.freeze({ id: "concrete", label: "コンクリート", description: "草が生えない", stressMultiplier: 1.0, grassMultiplier: 0.0, grassLimit: 0 }),
|
|
|
|
|
blanket: Object.freeze({ id: "blanket", label: "ふわふわ毛布", description: "ストレスが増えにくい", stressMultiplier: 0.5, grassMultiplier: 1.0 }),
|
2026-06-25 17:43:24 +09:00
|
|
|
foot_massage: Object.freeze({ id: "foot_massage", label: "足つぼ", description: "青いまだら地面。ストレスが増えやすい", stressMultiplier: 1.5, grassMultiplier: 1.0 }),
|
2026-06-25 22:30:35 +09:00
|
|
|
ice: Object.freeze({ id: "ice", label: "氷", description: "つるつる滑る。草は生えにくい", stressMultiplier: 1.1, grassMultiplier: 0.15 }),
|
2026-06-25 14:51:58 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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 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,
|
|
|
|
|
grassLimit: groundGrassLimit,
|
|
|
|
|
nextId: nextGroundTypeId,
|
|
|
|
|
tooltipText: groundTooltipText,
|
|
|
|
|
});
|