mirror of
https://github.com/db9979/tidefront.git
synced 2026-12-05 12:24:13 +01:00
Version 0.59.0: Balance v1.40 – Verpflegung je Mission (Proviant beim Auslaufen nach Unterhalt × Fahrtstunden; KI hält Reserve; Saisonsimulation in ENTSCHEIDUNGEN-9)
This commit is contained in:
1 parent
70c2b5a8ad
commit
497c496491
31 files changed
+142
-32
No files matched your search
@@ -2,6 +2,10 @@
|
||||
|
||||
Änderungen an TIDEFRONT, neueste zuerst. Die Version steht im Handbuch unten und auf dem Anmeldebildschirm.
|
||||
|
||||
## 0.59.0 – 01.12.2026
|
||||
|
||||
- Balance v1.40: **Verpflegung.** Verbände nehmen beim Auslaufen Proviant mit: Unterhalt der Einheiten je Stunde mal der Stunden unterwegs, bei Patrouille und Feldzug für die ganze Fahrt. Die Planung zeigt die Menge neben dem Treibstoff. Reicht der Proviant nicht, läuft der Verband nicht aus. Wer viel und weit fährt, braucht damit Proviant; wer daheim bleibt, merkt nichts. Die KI-Spieler halten Proviant für ihre Fahrten zurück.
|
||||
|
||||
## 0.58.0 – 30.11.2026
|
||||
|
||||
- Balance v1.39: Die Chipfabrik liefert 60 statt 45 Elektronik je Stufe und Stunde. Elektronik war der Engpass beim Ausbau, während Proviant sich staute. In der Saisonsimulation kommen die Häfen damit rund 10 % schneller voran. Gilt sofort, auch in der laufenden Saison.
|
||||
|
||||
@@ -31,7 +31,7 @@ test("Überfall auf ein Nest planen, starten und auswerten", async ({ page, play
|
||||
await unitRow("Korvette").getByRole("button", { name: "alle" }).click();
|
||||
await unitRow("Landungsschiff").getByRole("button", { name: "alle" }).click();
|
||||
await unitRow("Schützen").getByRole("button", { name: "alle" }).click();
|
||||
await expect(page.getByText(/^Fahrt .* Treibstoff$/)).toBeVisible();
|
||||
await expect(page.getByText(/^Fahrt .* Treibstoff( · .* Proviant)?$/)).toBeVisible();
|
||||
await expectNoHorizontalOverflow(page, "Missionsplanung");
|
||||
await page.getByRole("button", { name: "Auslaufen" }).click();
|
||||
await expect(page.getByRole("heading", { name: "Mission gestartet" })).toBeVisible();
|
||||
|
||||
@@ -22,7 +22,7 @@ test("Rohstofffeld besetzen", async ({ page, player, seed }) => {
|
||||
for (const name of ["Korvette", "Zerstörer"]) {
|
||||
await page.getByRole("listitem").filter({ hasText: new RegExp(`^${name}\\d`) }).getByRole("button", { name: "alle" }).click();
|
||||
}
|
||||
await expect(page.getByText(/^Fahrt .* Treibstoff$/)).toBeVisible();
|
||||
await expect(page.getByText(/^Fahrt .* Treibstoff( · .* Proviant)?$/)).toBeVisible();
|
||||
await expectNoHorizontalOverflow(page, "Besetzen planen");
|
||||
await page.getByRole("button", { name: "Auslaufen" }).click();
|
||||
await expect(page.getByRole("heading", { name: "Mission gestartet" })).toBeVisible();
|
||||
|
||||
@@ -43,7 +43,7 @@ test("Fremdes Nest: ohne Sicht keine Stufe, in Radarreichweite schon", async ({
|
||||
await expect(page.getByRole("heading", { name: "Mission planen" })).toBeVisible();
|
||||
await expect(page.getByText(/Lage unbekannt/).first()).toBeVisible();
|
||||
await page.getByRole("listitem").filter({ hasText: /^Korvette\d/ }).getByRole("button", { name: "alle" }).click();
|
||||
await expect(page.getByText(/^(Fahrt|Flug) .* Treibstoff$/)).toBeVisible({ timeout: 40_000 }); // Flug bei reinem Luftverband; Vorschau unter Last langsam (bis ~30 s)
|
||||
await expect(page.getByText(/^(Fahrt|Flug) .* Treibstoff( · .* Proviant)?$/)).toBeVisible({ timeout: 40_000 }); // Flug bei reinem Luftverband; Vorschau unter Last langsam (bis ~30 s)
|
||||
await expect(page.getByRole("button", { name: "Probekampf" })).toHaveCount(0);
|
||||
|
||||
await page.getByRole("navigation").getByRole("button", { name: "Karte" }).click();
|
||||
|
||||
@@ -113,7 +113,7 @@ export function IntelOpsPlan({ op, base, map, initial, onSent }: {
|
||||
: p.ok ? (
|
||||
<div className="text-sm space-y-0.5" data-testid="intel-preview">
|
||||
<div>Entfernung {fmtNum(p.distanceKm)} km · Hinfahrt {fmtSeconds(p.travelSeconds)}</div>
|
||||
<div>Treibstoff {fmtNum(p.fuelCost)} (ganze Fahrt)</div>
|
||||
<div>Treibstoff {fmtNum(p.fuelCost)} (ganze Fahrt){p.rationCost ? ` · Verpflegung ${fmtNum(p.rationCost)} Proviant` : ""}</div>
|
||||
<div>Ankunft {fmtTime(p.arriveAtMs)} · zurück etwa {fmtTime(p.returnAtMs)}</div>
|
||||
{p.sightKm !== null && <div>Sicht {fmtNum(p.sightKm)} km{p.sonarKm ? ` · Sonar ${fmtNum(p.sonarKm)} km` : ""}</div>}
|
||||
{p.turnPoints && p.turnPoints.some((t) => t.km > 0) && <div data-testid="campaign-turns">Aufklärung auf Sicht: Umkehr je {fmtNum(Math.round(Math.max(...p.turnPoints.map((t) => t.km))))} km vor dem Ziel, Lagebild dort</div>}
|
||||
@@ -129,7 +129,7 @@ export function IntelOpsPlan({ op, base, map, initial, onSent }: {
|
||||
<div className="min-w-0 flex-1 text-sm leading-tight">
|
||||
<div className="font-semibold truncate"><Icon id={op === "postenangriff" ? "ueberfall" : op === "kampagne" ? "aufklaerung" : op} size={16} /> {label(op === "postenangriff" ? "ueberfall" : op)}</div>
|
||||
{p && !p.ok ? <ReasonInline code={p.code} open={barOpen} onToggle={() => setBarOpen(!barOpen)} />
|
||||
: <div className="text-xs text-ink2 truncate">{!ready ? "Punkte und Einheiten wählen" : !p ? "Berechne …" : p.ok ? `Fahrt ${fmtSeconds(p.travelSeconds)} · ${fmtNum(p.fuelCost)} Treibstoff` : ""}</div>}
|
||||
: <div className="text-xs text-ink2 truncate">{!ready ? "Punkte und Einheiten wählen" : !p ? "Berechne …" : p.ok ? `Fahrt ${fmtSeconds(p.travelSeconds)} · ${fmtNum(p.fuelCost)} Treibstoff${p.rationCost ? ` · ${fmtNum(p.rationCost)} Proviant` : ""}` : ""}</div>}
|
||||
</div>
|
||||
<Button className="shrink-0" disabled={!p?.ok || launch.busy} onBlocked={p && !p.ok && hasRemedy(p.code) ? () => setBarOpen(!barOpen) : undefined}
|
||||
onClick={async () => {
|
||||
|
||||
@@ -151,6 +151,7 @@ const ERRORS: Record<string, string> = {
|
||||
troop_capacity: "Zu wenig Platz auf den Landungsschiffen.",
|
||||
command_points: "Der Verband kostet zu viele Kommandopunkte.",
|
||||
fuel: "Nicht genug Treibstoff.",
|
||||
rations: "Nicht genug Proviant für die Verpflegung unterwegs.",
|
||||
storm: "Sturm am Hafen – reine Luftmissionen starten nicht. Mit Schiffen auslaufen oder das Wetter abwarten.",
|
||||
out_of_range: "Ein Flugzeugtyp erreicht das Ziel nicht.",
|
||||
no_mission_slot: "Alle Missionsplätze sind belegt.",
|
||||
|
||||
@@ -19,10 +19,15 @@ export function pairBrakeText(pairFights: number, pairFactor: number, name: stri
|
||||
: `Paarbremse: schon ${pairFights} Kämpfe mit ${name} in ${windowHours} h – dieser zählt nicht für die Wertung.`;
|
||||
}
|
||||
|
||||
/** Zeilen der Vorschau je Missionsart: Reisezeit, Treibstoff, Ankunft/Rückkehr wie planMission sie rechnet. */
|
||||
export function previewLines(type: string, p: { travelSeconds: number; fuelCost: number; arriveAtMs: number; returnAtMs: number }, fmt: (ms: number) => string): { travel: string; fuel: string; times: string } {
|
||||
/** Zeilen der Vorschau je Missionsart: Reisezeit, Treibstoff (samt Verpflegung), Ankunft/Rückkehr wie planMission sie rechnet. */
|
||||
export function previewLines(type: string, p: { travelSeconds: number; fuelCost: number; rationCost?: number; arriveAtMs: number; returnAtMs: number }, fmt: (ms: number) => string): { travel: string; fuel: string; times: string } {
|
||||
const travel = fmtSeconds(p.travelSeconds);
|
||||
const fuel = fmtNum(p.fuelCost);
|
||||
const lines = previewFuelLines(type, p, travel, fuel, fmt);
|
||||
return p.rationCost ? { ...lines, fuel: `${lines.fuel} · Verpflegung ${fmtNum(p.rationCost)} Proviant` } : lines;
|
||||
}
|
||||
|
||||
function previewFuelLines(type: string, p: { arriveAtMs: number; returnAtMs: number }, travel: string, fuel: string, fmt: (ms: number) => string): { travel: string; fuel: string; times: string } {
|
||||
switch (type) {
|
||||
case "verlegung": // nur Hinfahrt (returnAtMs = arriveAtMs), Treibstoff einfach
|
||||
return { travel: `Reisezeit ${travel} (nur hin)`, fuel: `Treibstoff ${fuel} (nur hin)`, times: `Ankunft ${fmt(p.arriveAtMs)} – der Verband bleibt dort` };
|
||||
|
||||
@@ -72,6 +72,15 @@ export const MISSIONS: RemedyTable = {
|
||||
};
|
||||
},
|
||||
|
||||
rations: ({ base, balance }) => {
|
||||
const prod = producer(balance, "proviant");
|
||||
return {
|
||||
hint: "Unterwegs essen die Besatzungen aus dem Lager: Proviant je Stunde Unterhalt mal Fahrtstunden. Kleineren Verband oder näheres Ziel wählen, Proviant an der Börse kaufen oder den Versorgungshof ausbauen.",
|
||||
summary: base ? `Im Lager: ${fmtNum(Math.floor(base.resources.proviant ?? 0))} Proviant` : undefined,
|
||||
actions: [market("proviant"), ...(prod ? [build(prod)] : [])],
|
||||
};
|
||||
},
|
||||
|
||||
storm: () => ({ hint: "Bei Sturm am eigenen Hafen starten keine reinen Luftverbände. Nimm mindestens ein Schiff mit oder warte, bis der Sturm abzieht (Wetter auf der Karte)." , actions: [mapAction] }),
|
||||
|
||||
out_of_range: ({ balance, detail }) => {
|
||||
|
||||
@@ -173,9 +173,9 @@ export function Handbook({ onClose, onSettings }: { onClose: () => void; onSetti
|
||||
<P><strong>Was du siehst:</strong> Wer ein Nest nur <em>erkennt</em> (Ausguck, Radar, Bordsicht, Satellit), sieht die Stufe, die Besatzung als Spanne, „Anlagen unbekannt“ und Beute {Math.round(100)}–{Math.round(b.pirates.living.lootMax * 100)} %; erst ein <em>Lagebild</em> (Aufklärung oder Kampfbericht) zeigt das Nest genau – {b.intel?.staleHours ?? 24} Stunden lang und nur bis zur nächsten Wiederbesetzung. Ohne Lagebild rechnet der Probekampf über die Spanne („Siegchance 22–100 %, im Mittel 90 %“).</P>
|
||||
<P><strong>Beute und Erholung:</strong> Die Beute wächst ab der Besetzung um {Math.round(b.pirates.living.lootPerHour * 100)} % je Stunde bis {Math.round(b.pirates.living.lootMax * 100)} %. Wehrt ein Nest einen Überfall ab, ist es geschwächt: sofort wieder mindestens {Math.round(b.pirates.living.recoverMin * 100)} %, dann {Math.round(b.pirates.living.recoverPerHour * 100)} % je Stunde; zerstörte Anlagen sind nach {b.pirates.living.defenseReturnHours} Stunden zurück.</P></>}
|
||||
<P><strong>Transport:</strong> Ladung an einen anderen Spielerhafen.</P>
|
||||
<P>Treibstoff für Hin- und Rückweg wird beim Auslaufen bezahlt. Die Reisezeit richtet sich nach dem langsamsten Schiff. Schiffe fahren über Wasser: Die Route führt um Land herum, durch die Meerengen (Gibraltar, Ärmelkanal, Bosporus, Suezkanal …) und ist oft länger als die Luftlinie; Reisezeit und Treibstoff richten sich nach ihr. Die Planung zeigt Seeweg und Route auf der Karte. Reine Flugzeug- und Drohnenverbände fliegen Luftlinie. Wie viele Missionen gleichzeitig laufen, bestimmt die Hafenkommandantur; wie groß ein Verband sein darf, die Kommandopunkte.</P>
|
||||
<P>Treibstoff für Hin- und Rückweg wird beim Auslaufen bezahlt, ebenso die <strong>Verpflegung</strong>: Proviant in Höhe des Unterhalts der Einheiten je Stunde mal der Stunden unterwegs{b?.rations && b.rations.perUpkeepHour !== 1 ? ` mal ${fmtNum(b.rations.perUpkeepHour, 1)}` : ""} (bei Patrouille und Feldzug für die ganze Fahrt). Der Unterhalt läuft daneben weiter. Die Reisezeit richtet sich nach dem langsamsten Schiff. Schiffe fahren über Wasser: Die Route führt um Land herum, durch die Meerengen (Gibraltar, Ärmelkanal, Bosporus, Suezkanal …) und ist oft länger als die Luftlinie; Reisezeit und Treibstoff richten sich nach ihr. Die Planung zeigt Seeweg und Route auf der Karte. Reine Flugzeug- und Drohnenverbände fliegen Luftlinie. Wie viele Missionen gleichzeitig laufen, bestimmt die Hafenkommandantur; wie groß ein Verband sein darf, die Kommandopunkte.</P>
|
||||
<P>Bodentruppen fahren nur auf Landungsschiffen ({fmtNum(lander?.troopSpace ?? 100)} Plätze je Schiff, Panzer brauchen {b?.units.kampfpanzer?.size ?? 10}). Flugzeuge fliegen nur innerhalb ihrer Reichweite mit.</P>
|
||||
<P><strong>Rückruf:</strong> Auf der Hinfahrt kannst du einen Verband unter Truppen zurückrufen. Er kehrt sofort um und ist nach der schon gefahrenen Zeit wieder daheim; am Ziel geschieht nichts. Treibstoff wird nicht erstattet, Transportgut kommt zurück.</P>
|
||||
<P><strong>Rückruf:</strong> Auf der Hinfahrt kannst du einen Verband unter Truppen zurückrufen. Er kehrt sofort um und ist nach der schon gefahrenen Zeit wieder daheim; am Ziel geschieht nichts. Treibstoff und Verpflegung werden nicht erstattet, Transportgut kommt zurück.</P>
|
||||
<P>Auf Kampffeldern bleiben <strong>Wracks</strong>. Jede deiner Missionen, die dort ankommt, birgt so viel Stahl und Elektronik, wie in den freien Laderaum passt. Wracks zerfallen in {b?.combat.wreckHours ?? 48} Stunden.</P>
|
||||
</>
|
||||
),
|
||||
|
||||
@@ -349,7 +349,7 @@ export function MissionPlan({ base, initialTarget, onClose, preset }: { base: Ba
|
||||
<div className="font-semibold truncate">{unitCount(Object.values(chosen).reduce((a, b) => a + b, 0))}{ownTarget ? ` → ${ownTarget.name}` : target ? ` · ${type === "gruendung" ? "Außenposten " : "Feld "}${target.col}/${target.row}` : ""}</div>
|
||||
{p && !p.ok && target && Object.keys(chosen).length > 0
|
||||
? <ReasonInline code={p.code} open={barOpen} onToggle={() => setBarOpen(!barOpen)} />
|
||||
: <div className="text-xs text-ink2 truncate">{!target ? "Ziel wählen" : Object.keys(chosen).length === 0 ? "Einheiten wählen" : !p ? "Berechne …" : p.ok ? `${dep.trip} ${fmtSeconds(p.travelSeconds)} · ${fmtNum(p.fuelCost)} Treibstoff` : errorText(p.code)}</div>}
|
||||
: <div className="text-xs text-ink2 truncate">{!target ? "Ziel wählen" : Object.keys(chosen).length === 0 ? "Einheiten wählen" : !p ? "Berechne …" : p.ok ? `${dep.trip} ${fmtSeconds(p.travelSeconds)} · ${fmtNum(p.fuelCost)} Treibstoff${p.rationCost ? ` · ${fmtNum(p.rationCost)} Proviant` : ""}` : errorText(p.code)}</div>}
|
||||
</div>
|
||||
<Button
|
||||
className="shrink-0"
|
||||
|
||||
@@ -23,6 +23,11 @@ Vier Ressourcen: `stahl`, `treibstoff`, `elektronik`, `proviant`. Strom ist eine
|
||||
- Dazu kommt immer die Grundrate `baseTricklePerHour`.
|
||||
- Strom (v1.6, „Wetter und Strom“): Erhält die Produktion nur den Anteil `f` ihres Bedarfs, wird die Gebäudeproduktion (nicht die Grundrate) mal `f` gerechnet.
|
||||
- Proviant-Unterhalt: Summe `upkeepPerHour * Anzahl` aller Einheiten des Stützpunkts wird von der Proviant-Rate abgezogen.
|
||||
- Verpflegung je Mission (Balance v1.40, `rations.perUpkeepHour` = 1): Beim Auslaufen kostet ein Verband zusätzlich
|
||||
Proviant = Summe `upkeepPerHour * Anzahl` × Stunden unterwegs (Hin- und Rückfahrt; Verlegung nur hin) × Faktor,
|
||||
aufgerundet. Patrouille und Feldzug zahlen die Zeit auf Station bzw. die weiteren Abschnitte dazu. Fehlt Proviant,
|
||||
läuft der Verband nicht aus (`rations`). Kein Erstatten beim Rückruf. KI-Spieler behalten Proviant für einen Tag
|
||||
Fahrt aller Einheiten und kaufen fehlenden an der Börse zu.
|
||||
Die Netto-Rate kann negativ sein; der Bestand fällt nie unter 0. Bei Bestand 0 und negativer Rate gilt `versorgungsmangel = true`
|
||||
(Ausbildungsstopp, Angriffswert aller eigenen Einheiten mal 0,8).
|
||||
- Lagerkapazität je Ressource: `capacityBase * capacityGrowth^L` (L = Stufe Lagerkomplex, ab 0).
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "tidefront",
|
||||
"private": true,
|
||||
"version": "0.58.0",
|
||||
"version": "0.59.0",
|
||||
"type": "module",
|
||||
"engines": {
|
||||
"node": ">=22.18"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "v1.39",
|
||||
"version": "v1.40",
|
||||
"resources": ["stahl", "treibstoff", "elektronik", "proviant"],
|
||||
"start": { "stahl": 2000, "treibstoff": 1000, "elektronik": 500, "proviant": 1000 },
|
||||
"baseTricklePerHour": { "stahl": 20, "treibstoff": 10, "elektronik": 5, "proviant": 15 },
|
||||
@@ -299,6 +299,7 @@
|
||||
}
|
||||
},
|
||||
"blockade": { "minHours": 2, "maxHours": 12, "minCommandPoints": 12, "productionFactor": 0.75, "deliveryHoldMinutes": 60 },
|
||||
"rations": { "perUpkeepHour": 1 },
|
||||
"convoys": {
|
||||
"cartelBaseChance": 0.02, "cartelChancePer100Km": 0.01, "cartelChancePer1000Value": 0.004, "cartelMaxChance": 0.12, "cartelMinDistanceKm": 150,
|
||||
"cartelBoatsPer1000Value": 0.8, "cartelMinBoats": 2, "cartelMaxBoats": 12,
|
||||
|
||||
@@ -105,7 +105,7 @@ export async function stationPreview(db: DbOrTx, playerId: number, own: BaseRow,
|
||||
const r = await planStation(db, { ...own, state: settle(own.state, nowMs, balance, mods) }, input.units, input, nowMs);
|
||||
if (!r.ok) return { ok: false as const, code: r.code, distanceKm, weather };
|
||||
return {
|
||||
ok: true as const, distanceKm, travelSeconds: r.mission.travelSeconds, route: r.mission.route ?? null, fuelCost: r.mission.fuelCost, arriveAtMs: r.mission.arriveAtMs,
|
||||
ok: true as const, distanceKm, travelSeconds: r.mission.travelSeconds, route: r.mission.route ?? null, fuelCost: r.mission.fuelCost, rationCost: r.mission.rationCost ?? 0, arriveAtMs: r.mission.arriveAtMs,
|
||||
returnAtMs: r.mission.returnAtMs, target: { kind: "base", own: ownHost }, intercept: null, weather: withArrival(weather, input.col, input.row, r.mission.arriveAtMs, nowMs, own.state), weatherFactor: r.mission.weather?.shipFactor ?? 1,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// (trade, createOffer/acceptOffer, launchMission zur Gründung, train). Rohstofffelder: bots-fields.ts.
|
||||
import { and, eq, inArray } from "drizzle-orm";
|
||||
import {
|
||||
rationCost,
|
||||
allowedBases,
|
||||
commandPoints,
|
||||
harborMarketUnlocked,
|
||||
@@ -51,16 +52,29 @@ export async function marketTurn(c: TurnCtx, base: Base, mods: Modifiers): Promi
|
||||
const fuelNeed = c.nest6Hold === base.id ? nest6FuelNeed(base, mods) : 0;
|
||||
const need = nextBuildNeed(base.state);
|
||||
if (fuelNeed > 0) need.treibstoff = Math.max(need.treibstoff ?? 0, fuelNeed);
|
||||
// Verpflegung je Mission: Proviant für einen Tag auf Fahrt aller Einheiten behalten, fehlenden zukaufen.
|
||||
const rationNeed = rationReserve(base.state);
|
||||
if (rationNeed > 0) need.proviant = Math.max(need.proviant ?? 0, rationNeed);
|
||||
const plan = botMarketPlan({
|
||||
stock: base.state.resources, perHour: productionRates(base.state, balance, mods, c.nowMs).perHour, need,
|
||||
room, price, maxLot: maxLots(), credits: view.credits - (c.creditReserve ?? 0), trader: c.cfg.trade,
|
||||
});
|
||||
for (const x of plan.sell) await doTrade(c, base, "sell", x.resource, x.qty);
|
||||
const short = Math.floor(fuelNeed - (base.state.resources.treibstoff ?? 0));
|
||||
const hungry = Math.floor(rationNeed - (base.state.resources.proviant ?? 0));
|
||||
if (short > 0 && (room.treibstoff ?? 0) > 0) await doTrade(c, base, "buy", "treibstoff", Math.min(short, Math.floor(room.treibstoff), maxLots().treibstoff ?? short), mods);
|
||||
else if (hungry > 0 && (room.proviant ?? 0) > 0) await doTrade(c, base, "buy", "proviant", Math.min(hungry, Math.floor(room.proviant), maxLots().proviant ?? hungry), mods);
|
||||
else if (plan.buy) await doTrade(c, base, "buy", plan.buy.resource, plan.buy.qty, mods);
|
||||
}
|
||||
|
||||
/** Proviant-Reserve für die Verpflegung (Balance `rations`): alle Einheiten einen Tag auf Fahrt; 0 ohne Verpflegung. */
|
||||
export const RATION_RESERVE_HOURS = 24;
|
||||
export function rationReserve(state: BaseState): number {
|
||||
const all: Record<string, number> = { ...state.units };
|
||||
for (const [id, n] of Object.entries(state.unitsAway)) all[id] = (all[id] ?? 0) + n;
|
||||
return rationCost(all, RATION_RESERVE_HOURS, balance);
|
||||
}
|
||||
|
||||
/** Ab diesem Warenwert (Richtpreis) nehmen KI-Spieler bei Börsenkäufen das empfohlene Geleit, wenn Schiffe daheim sind. */
|
||||
export const BOT_ESCORT_MIN_VALUE = 10000;
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ export async function launchExpansion(
|
||||
export type ExpansionPreview =
|
||||
| { ok: false; code: string; distanceKm: number; weather?: ReturnType<typeof missionWeather> }
|
||||
| {
|
||||
ok: true; distanceKm: number; travelSeconds: number; fuelCost: number; arriveAtMs: number; returnAtMs: number;
|
||||
ok: true; distanceKm: number; travelSeconds: number; fuelCost: number; rationCost: number; arriveAtMs: number; returnAtMs: number;
|
||||
target: { kind: string; own: boolean }; intercept: null; weather: ReturnType<typeof missionWeather>; weatherFactor: number;
|
||||
route: MissionRoute | null; // Seewege
|
||||
/** Häfen: eigene, laufende Gründungen, erlaubt (Kommandozentrale des Heimathafens), Höchstzahl; v1.35 Gründungsgebühr. */
|
||||
@@ -172,7 +172,7 @@ export async function previewExpansion(db: DbOrTx, playerId: number, own: BaseRo
|
||||
const bases = await db.select({ id: tables.base.id }).from(tables.base).where(eq(tables.base.playerId, playerId));
|
||||
const m = r.mission;
|
||||
return {
|
||||
ok: true as const, distanceKm: m.distanceKm, travelSeconds: m.travelSeconds, route: m.route ?? null, fuelCost: m.fuelCost, arriveAtMs: m.arriveAtMs,
|
||||
ok: true as const, distanceKm: m.distanceKm, travelSeconds: m.travelSeconds, route: m.route ?? null, fuelCost: m.fuelCost, rationCost: m.rationCost ?? 0, arriveAtMs: m.arriveAtMs,
|
||||
returnAtMs: m.returnAtMs, target: { kind: input.type === FOUNDING_TYPE ? SITE_TARGET : "base", own: input.type === TRANSFER_TYPE },
|
||||
intercept: null, weather: withArrival(weather, input.col, input.row, m.arriveAtMs, nowMs, own.state), weatherFactor: m.weather?.shipFactor ?? 1,
|
||||
expansion: { bases: bases.length, pending: await pendingFoundings(db, playerId), allowed: home ? allowedBases(home.state, balance) : 1, max: e.maxBases, fee },
|
||||
|
||||
@@ -98,7 +98,7 @@ export async function previewField(db: DbOrTx, playerId: number, own: BaseRow, i
|
||||
if (!r.ok) return { ok: false as const, code: r.code, distanceKm };
|
||||
const m = r.mission;
|
||||
return {
|
||||
ok: true as const, distanceKm: m.distanceKm, travelSeconds: m.travelSeconds, route: m.route ?? null, fuelCost: m.fuelCost, arriveAtMs: m.arriveAtMs,
|
||||
ok: true as const, distanceKm: m.distanceKm, travelSeconds: m.travelSeconds, route: m.route ?? null, fuelCost: m.fuelCost, rationCost: m.rationCost ?? 0, arriveAtMs: m.arriveAtMs,
|
||||
returnAtMs: m.returnAtMs, target: { kind: "field", own: reinforce }, intercept: null,
|
||||
weather: field ? missionWeather(own.col, own.row, field.col, field.row, nowMs) : null, weatherFactor: m.weather?.shipFactor ?? 1,
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// Meldung „Aufklärer gesichtet“ (scoutSighted).
|
||||
import { and, eq, sql } from "drizzle-orm";
|
||||
import {
|
||||
activeUnits, campaignCheck, liveLevelAt, campaignOf, fuelCost, hasShipUnits, reconRangeKm, sightTurn, travelSeconds, validateFleet,
|
||||
activeUnits, campaignCheck, liveLevelAt, campaignOf, fuelCost, rationCost, hasShipUnits, reconRangeKm, sightTurn, travelSeconds, validateFleet,
|
||||
type BaseState, type Counts, type Mission, type MissionRoute, type SightTurn,
|
||||
} from "@tidefront/game-core";
|
||||
import { hexCenterXY, hexDistanceKm, seaRoute, seaRouteCopy, type Hex } from "@tidefront/world";
|
||||
@@ -97,7 +97,13 @@ export async function planCampaign(db: DbOrTx, playerId: number, own: BaseRow, i
|
||||
if ((r.base.resources.treibstoff ?? 0) < extra) return { ok: false as const, code: "fuel" };
|
||||
r.base.resources = { ...r.base.resources, treibstoff: (r.base.resources.treibstoff ?? 0) - extra };
|
||||
const campaign: CampaignPlan = { targets, index: 0, legFrom: { col: own.col, row: own.row }, legDepartMs: nowMs };
|
||||
const mission = { ...r.mission, fuelCost: r.mission.fuelCost + extra, returnAtMs: at + Math.ceil(legSec(homeKm) * 1000), campaign };
|
||||
const returnAtMs = at + Math.ceil(legSec(homeKm) * 1000);
|
||||
// Verpflegung für die zusätzlichen Abschnitte (die erste Fahrt hin und zurück hat planMission schon verpflegt).
|
||||
const rations = rationCost(input.units, Math.max(0, returnAtMs - r.mission.returnAtMs) / 3_600_000, balance);
|
||||
if ((r.base.resources.proviant ?? 0) < rations) return { ok: false as const, code: "rations" };
|
||||
if (rations > 0) r.base.resources = { ...r.base.resources, proviant: (r.base.resources.proviant ?? 0) - rations };
|
||||
const rationTotal = (r.mission.rationCost ?? 0) + rations;
|
||||
const mission = { ...r.mission, fuelCost: r.mission.fuelCost + extra, ...(rationTotal > 0 ? { rationCost: rationTotal } : {}), returnAtMs, campaign };
|
||||
// Planung und Karte: Wendepunkte der Abschnitte (Projektions-km), null = bis ans Ziel.
|
||||
const turnPoints = turns.map((t, i) => t ? { x: t.x, y: t.y, km: t.rangeKm } : { ...hexCenterXY(targets[i].col, targets[i].row), km: 0 });
|
||||
return { ok: true as const, base: r.base, mission, targets, lastArriveAtMs: at, turnPoints };
|
||||
|
||||
@@ -56,7 +56,7 @@ export async function previewIntelOp(engine: Engine, playerId: number, i: IntelO
|
||||
const m = r.mission as Mission & { patrol?: PatrolPlan };
|
||||
const far = i.op === "patrouille" ? Math.max(0, ...(i.waypoints ?? []).map((w) => hexDistanceKm(own, w))) : m.distanceKm;
|
||||
return {
|
||||
ok: true as const, distanceKm: Math.round(far), travelSeconds: m.travelSeconds, route: m.route ?? null, fuelCost: m.fuelCost,
|
||||
ok: true as const, distanceKm: Math.round(far), travelSeconds: m.travelSeconds, route: m.route ?? null, fuelCost: m.fuelCost, rationCost: m.rationCost ?? 0,
|
||||
arriveAtMs: m.arriveAtMs, returnAtMs: m.returnAtMs, sightKm: m.patrol?.sightKm ?? null, sonarKm: m.patrol?.sonarKm ?? null,
|
||||
cost: "cost" in r ? r.cost : null,
|
||||
turnPoints: ("turnPoints" in r ? r.turnPoints : null) as { x: number; y: number; km: number }[] | null, // Aufklärung auf Sicht: Wendepunkte der Kampagne
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// Meldung „Fremde Patrouille gesichtet“.
|
||||
import { eq, ne } from "drizzle-orm";
|
||||
import {
|
||||
activeUnits, dronesShot, fuelCost, hasShipUnits, interceptChance, patrolCheck, patrolOf, patrolSightKm, slowestSpeedKmh, sonarKm,
|
||||
activeUnits, dronesShot, fuelCost, rationCost, hasShipUnits, interceptChance, patrolCheck, patrolOf, patrolSightKm, slowestSpeedKmh, sonarKm,
|
||||
techLevel, type BaseState, type Counts, type Mission,
|
||||
} from "@tidefront/game-core";
|
||||
import { hexAtXY, hexCenterXY, hexDistanceKm, inGrid, loopRouteHexes, routePointsXY, seaRoute, terrainAt } from "@tidefront/world";
|
||||
@@ -55,7 +55,13 @@ export async function planPatrol(db: DbOrTx, playerId: number, own: BaseRow, inp
|
||||
...(hasShipUnits(input.units, balance) ? { loop: loopRouteHexes(input.waypoints) } : {}),
|
||||
};
|
||||
const travel = r.mission.arriveAtMs - r.mission.departAtMs;
|
||||
const mission = { ...r.mission, fuelCost: r.mission.fuelCost + extra, returnAtMs: r.mission.arriveAtMs + input.hours * HOUR_MS + travel, patrol };
|
||||
const returnAtMs = r.mission.arriveAtMs + input.hours * HOUR_MS + travel;
|
||||
// Verpflegung für die Zeit auf Station (die Fahrt hin und zurück hat planMission schon verpflegt).
|
||||
const rations = rationCost(input.units, Math.max(0, returnAtMs - r.mission.returnAtMs) / HOUR_MS, balance);
|
||||
if ((r.base.resources.proviant ?? 0) < rations) return { ok: false as const, code: "rations" };
|
||||
if (rations > 0) r.base.resources = { ...r.base.resources, proviant: (r.base.resources.proviant ?? 0) - rations };
|
||||
const rationTotal = (r.mission.rationCost ?? 0) + rations;
|
||||
const mission = { ...r.mission, fuelCost: r.mission.fuelCost + extra, ...(rationTotal > 0 ? { rationCost: rationTotal } : {}), returnAtMs, patrol };
|
||||
return { ok: true as const, base: r.base, mission, extraFuel: extra };
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ export async function previewNaval(db: DbOrTx, playerId: number, own: BaseRow, i
|
||||
distanceKm: m.distanceKm,
|
||||
travelSeconds: m.travelSeconds,
|
||||
route: m.route ?? null, // Seewege
|
||||
fuelCost: m.fuelCost,
|
||||
fuelCost: m.fuelCost, rationCost: m.rationCost ?? 0,
|
||||
arriveAtMs: m.arriveAtMs,
|
||||
returnAtMs: m.returnAtMs,
|
||||
target: { kind: "naval", own: false },
|
||||
|
||||
@@ -53,7 +53,7 @@ export function travelMs(a: { col: number; row: number }, b: { col: number; row:
|
||||
|
||||
/** Gründe, aus denen das Geleit des Anbieters bei Annahme nicht ausläuft (Systemnachricht). */
|
||||
const ESCORT_FAIL: Record<string, string> = {
|
||||
units_unavailable: "Schiffe fehlen im Hafen", fuel: "zu wenig Treibstoff", no_mission_slot: "alle Missionsplätze belegt",
|
||||
units_unavailable: "Schiffe fehlen im Hafen", fuel: "zu wenig Treibstoff", rations: "zu wenig Proviant für die Verpflegung", no_mission_slot: "alle Missionsplätze belegt",
|
||||
command_points: "zu wenig Kommandopunkte",
|
||||
escort_ships_only: "nur Schiffe", empty_fleet: "keine Schiffe",
|
||||
};
|
||||
|
||||
@@ -329,7 +329,7 @@ export async function missionPreview(
|
||||
travelSeconds: r.mission.travelSeconds,
|
||||
route: r.mission.route ?? null, // Seewege: Wegpunkte und Länge (Planungskarte, Weglänge)
|
||||
sightTurn: r.mission.sightTurn ?? null, // Aufklärung auf Sicht: Wendepunkt (Planungskarte)
|
||||
fuelCost: r.mission.fuelCost,
|
||||
fuelCost: r.mission.fuelCost, rationCost: r.mission.rationCost ?? 0,
|
||||
arriveAtMs: r.mission.arriveAtMs,
|
||||
returnAtMs: r.mission.returnAtMs,
|
||||
target: { kind: target.kind, own: target.playerId === playerId },
|
||||
|
||||
@@ -150,7 +150,7 @@ export async function previewAgainstEvent(db: DbOrTx, playerId: number, own: Bas
|
||||
distanceKm,
|
||||
travelSeconds: r.mission.travelSeconds,
|
||||
route: r.mission.route ?? null, // Seewege
|
||||
fuelCost: r.mission.fuelCost,
|
||||
fuelCost: r.mission.fuelCost, rationCost: r.mission.rationCost ?? 0,
|
||||
arriveAtMs: r.mission.arriveAtMs,
|
||||
returnAtMs: r.mission.returnAtMs,
|
||||
target: { kind: "event", own: false },
|
||||
|
||||
@@ -51,6 +51,7 @@ async function newPlayer(name: string, field: number, bot = false) {
|
||||
s.protection.createdAtMs = Date.now() - 30 * DAY;
|
||||
s.units = { ...FLEET };
|
||||
s.resources.treibstoff = 1_000_000;
|
||||
s.resources.proviant = 1_000_000; // v1.40: Verpflegung je Mission
|
||||
s.buildings.kommandozentrale = 15;
|
||||
s.buildings.hafenkommandantur = 10;
|
||||
s.buildings.lagerkomplex = 15; // Platz für die Beute (das Lager begrenzt wie immer)
|
||||
|
||||
@@ -154,7 +154,7 @@ test("Angriff auf Spielerhafen plant attack_warning nach Radar-Vorwarnzeit; Push
|
||||
});
|
||||
await pushSubscribe(db, other.playerId, { endpoint: "https://push.example/ok", keys: { p256dh: "p".repeat(20), auth: "a".repeat(16) } });
|
||||
await pushSubscribe(db, other.playerId, { endpoint: "https://push.example/gone", keys: { p256dh: "p".repeat(20), auth: "a".repeat(16) } });
|
||||
await patchBase(admin.baseId, (s) => { s.units = { korvette: 2, landungsschiff: 1, schuetzen: 50 }; s.resources.treibstoff = 50000; s.buildings.hafenkommandantur = 4; });
|
||||
await patchBase(admin.baseId, (s) => { s.units = { korvette: 2, landungsschiff: 1, schuetzen: 50 }; s.resources.treibstoff = 50000; s.resources.proviant = 50000; s.buildings.hafenkommandantur = 4; });
|
||||
// v1.6: Das Radar braucht Strom (Kraftwerk); Nebel am Hafen kürzt die Vorwarnzeit.
|
||||
await patchBase(other.baseId, (s) => { s.protection.createdAtMs = 0; s.buildings.radarstation = 2; s.buildings.kraftwerk = 1; });
|
||||
const m = await launchMission(engine, admin.playerId, key(), { type: "ueberfall", units: { korvette: 1, landungsschiff: 1, schuetzen: 50 }, col: other.col, row: other.row });
|
||||
|
||||
@@ -86,6 +86,7 @@ async function arm(baseId: number, units: Record<string, number>) {
|
||||
await patchBase(baseId, (s) => {
|
||||
s.units = { ...units };
|
||||
s.resources.treibstoff = 1_000_000;
|
||||
s.resources.proviant = 1_000_000; // v1.40: Verpflegung je Mission
|
||||
s.buildings.kommandozentrale = 15;
|
||||
s.buildings.hafenkommandantur = 10;
|
||||
});
|
||||
|
||||
@@ -285,3 +285,22 @@ Basis 74.174 (KZ 10/10/10, 2 Warnungen) · P1 Verschiebung nur auf Proviant (Bau
|
||||
Saisonlauf ist trotz gleichem Seed nicht deterministisch (Basis v1.39 mit Seed 4242 einmal 82.843, einmal 74.174
|
||||
Punkte), Unterschiede unter ~10 % sind Rauschen; die Richtung war in beiden Varianten aber einheitlich schlechter.
|
||||
Offene Idee: Proviant an Aktivität statt an den Ausbau binden (Verpflegung je Mission nach Truppenzahl und Dauer).
|
||||
|
||||
## Verpflegung je Mission (Balance v1.40, 01.12.2026)
|
||||
|
||||
Proviant an Aktivität statt an den Ausbau gebunden: Beim Auslaufen kostet ein Verband Proviant = Unterhalt je Stunde ×
|
||||
Stunden unterwegs × `rations.perUpkeepHour` (Patrouille/Feldzug: ganze Fahrt). Saisonlauf, Punkte der KI an Tag 35:
|
||||
|
||||
| Variante | Seed 4242 | Seed 777 |
|
||||
|---|---|---|
|
||||
| Basis v1.39 | 81.569 | 78.223 |
|
||||
| Faktor 1, KI ohne Reserve | 66.952 (−19 %) | 68.048 (−22 %) |
|
||||
| Faktor 2, KI ohne Reserve | 66.021 (−20 %) | 62.855 (−28 %) |
|
||||
| Faktor 0,5, KI mit Reserve | 87.061 (+7 %) | 84.194 (+8 %) |
|
||||
| Faktor 1, KI mit Reserve | 83.452 (+2 %) | 87.472 (+12 %) |
|
||||
|
||||
(Basis der Läufe ohne Reserve: 83.023 / 86.939.) Ohne Reserve verkaufte die KI ihren Proviant und konnte danach nicht
|
||||
auslaufen (Nestsiege halbiert). Mit Reserve (Proviant für 24 h Fahrt aller Einheiten, `bots-econ.ts rationReserve`)
|
||||
kein Punkteverlust, keine neuen Warnungen. **Entscheidung: Faktor 1.** Proviant bekommt einen Zweck, der Spieler
|
||||
trifft, die viel und weit fahren; wer daheim bleibt, merkt nichts. Der Überschuss wird nicht abgebaut, sondern als
|
||||
Reserve gebunden (KI-Lager eher höher). Beobachten: Proviant-Füllgrad und Börsenpreis in der nächsten Saison.
|
||||
@@ -141,11 +141,23 @@ export function fuelCost(units: Counts, distance: number, balance: Balance, mods
|
||||
return Math.ceil(Math.round(sum * trips * modValue(mods, "fuel") * 1e9) / 1e9);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verpflegung für eine Fahrt (Balance `rations`): Proviant-Unterhalt der Einheiten × Stunden unterwegs × Faktor,
|
||||
* aufgerundet; 0 ohne den Block.
|
||||
*/
|
||||
export function rationCost(units: Counts, awayHours: number, balance: Balance): number {
|
||||
const f = balance.rations?.perUpkeepHour ?? 0;
|
||||
if (!(f > 0) || !(awayHours > 0)) return 0;
|
||||
let sum = 0;
|
||||
for (const [id, n] of entries(units)) sum += (balance.units[id]?.upkeepPerHour ?? 0) * n;
|
||||
return Math.ceil(Math.round(sum * awayHours * f * 1e9) / 1e9);
|
||||
}
|
||||
|
||||
/**
|
||||
* Plant eine Mission: prüft Verband, Missionsplatz, Treibstoff und Ladung, zieht Treibstoff
|
||||
* (und Transportgut) ab und verschiebt die Einheiten nach unitsAway.
|
||||
* Zusätzliche Codes: bad_type, no_mission_slot, target_protected, cargo_not_allowed, bad_cargo,
|
||||
* cargo_capacity, fuel, insufficient_resources, storm (reine Luftmission bei Sturm am Start).
|
||||
* cargo_capacity, fuel, rations (Proviant für die Verpflegung), insufficient_resources, storm (reine Luftmission bei Sturm am Start).
|
||||
* Mehrere Häfen: „gruendung“ braucht genau ein Kolonieschiff (colony_ship, ohne Balance-Block expansion_off); Treibstoff
|
||||
* für das Kolonieschiff nur hin, für das Geleit hin und zurück. „verlegung“ fährt nur hin (Treibstoff einfach,
|
||||
* returnAtMs = arriveAtMs). Beide dürfen Ladung bis zur Kapazität mitführen.
|
||||
@@ -213,6 +225,14 @@ export function planMission(
|
||||
if (!hasResources(next.resources, cargo)) return { ok: false, code: "insufficient_resources" };
|
||||
next.resources = subtractResources(next.resources, cargo);
|
||||
|
||||
const shipFactor = hasShips && input.weather ? input.weather.shipFactor : 1;
|
||||
const rawSeconds = (travelSeconds(input.units, tripKm, balance, mods) ?? 0) * shipFactor;
|
||||
const seconds = sr && turn ? sightTravelSeconds(rawSeconds, sr) : rawSeconds;
|
||||
const travelMs = Math.ceil(seconds * 1000);
|
||||
const rations = rationCost(input.units, ((type === "verlegung" ? 1 : 2) * travelMs) / 3_600_000, balance);
|
||||
if ((next.resources.proviant ?? 0) < rations) return { ok: false, code: "rations" };
|
||||
if (rations > 0) next.resources = subtractResources(next.resources, { proviant: rations });
|
||||
|
||||
const units: Counts = {};
|
||||
for (const [id, n] of entries(input.units)) {
|
||||
units[id] = n;
|
||||
@@ -225,10 +245,6 @@ export function planMission(
|
||||
if (input.playerHarbor && balance.pvp?.beginnerEndsOnPlayerRaid) next.protection = endBeginnerProtection(next.protection, nowMs, balance);
|
||||
}
|
||||
|
||||
const shipFactor = hasShips && input.weather ? input.weather.shipFactor : 1;
|
||||
const rawSeconds = (travelSeconds(input.units, tripKm, balance, mods) ?? 0) * shipFactor;
|
||||
const seconds = sr && turn ? sightTravelSeconds(rawSeconds, sr) : rawSeconds;
|
||||
const travelMs = Math.ceil(seconds * 1000);
|
||||
const mission: Mission = {
|
||||
type,
|
||||
units,
|
||||
@@ -237,6 +253,7 @@ export function planMission(
|
||||
distanceKm: distance,
|
||||
travelSeconds: seconds,
|
||||
fuelCost: fuel,
|
||||
...(rations > 0 ? { rationCost: rations } : {}),
|
||||
cargo,
|
||||
departAtMs: nowMs,
|
||||
arriveAtMs: nowMs + travelMs,
|
||||
|
||||
@@ -239,6 +239,8 @@ export interface Balance {
|
||||
mines?: MinesBalance;
|
||||
blockade?: BlockadeBalance;
|
||||
convoys?: ConvoysBalance;
|
||||
/** Verpflegung je Mission (mission.ts rationCost): Proviant beim Auslaufen, Unterhalt × Fahrtstunden × Faktor; fehlt = aus. */
|
||||
rations?: { perUpkeepHour: number };
|
||||
/** Mehrere Häfen: Gründung und Verlegung (expansion.ts); fehlt es, gibt es keine Außenposten. */
|
||||
expansion?: ExpansionDef;
|
||||
/** Lagebild (seit v1.17, intel.ts); fehlt es, sieht jeder alles (kein Kartennebel). */
|
||||
@@ -430,6 +432,7 @@ export interface Mission {
|
||||
distanceKm: number;
|
||||
travelSeconds: number;
|
||||
fuelCost: number;
|
||||
rationCost?: number; // Verpflegung beim Auslaufen (Proviant); fehlt = keine
|
||||
cargo: ResourceMap;
|
||||
departAtMs: number;
|
||||
arriveAtMs: number;
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
EARTH_RADIUS_KM,
|
||||
createProtection,
|
||||
fuelCost,
|
||||
rationCost,
|
||||
isNightShieldActive,
|
||||
planMission,
|
||||
recallMission,
|
||||
@@ -159,7 +160,7 @@ test("planMission: Transport nimmt Ladung bis zur Ladekapazität mit", () => {
|
||||
);
|
||||
assert.ok(ok.ok);
|
||||
assert.equal(ok.base.resources.stahl, 500);
|
||||
assert.equal(ok.base.resources.proviant, 500);
|
||||
assert.equal(ok.base.resources.proviant, 485); // 500 Ladung, 15 Verpflegung (3 je Stunde × 5 h)
|
||||
assert.deepEqual(ok.mission.cargo, { stahl: 1500, proviant: 500 });
|
||||
const cases: [Partial<MissionInput>, Counts, string][] = [
|
||||
[{ type: "transport", cargo: { stahl: 4001 } }, { landungsschiff: 1 }, "cargo_capacity"],
|
||||
@@ -232,3 +233,20 @@ test("Rückruf direkt nach der Abfahrt: sofort wieder daheim", () => {
|
||||
assert.ok(r.ok);
|
||||
assert.equal(r.returnAtMs, T0);
|
||||
});
|
||||
|
||||
test("Verpflegung je Mission: Unterhalt × Fahrtstunden × Faktor, beim Auslaufen abgezogen", () => {
|
||||
const units = { korvette: 2, landungsschiff: 1, schuetzen: 50 }; // Unterhalt 4 + 3 + 5 = 12 je Stunde
|
||||
assert.equal(rationCost(units, 12.5, { ...balance, rations: undefined }), 0); // ohne Balance-Block aus
|
||||
const b = { ...balance, rations: { perUpkeepHour: 1 } };
|
||||
assert.equal(rationCost(units, 12.5, balance), rationCost(units, 12.5, b)); // v1.40: Faktor 1
|
||||
assert.equal(rationCost(units, 12.5, b), 150);
|
||||
assert.equal(rationCost({ schuetzen: 3 }, 1, b), 1); // 0,3 → aufgerundet
|
||||
const base = makeBase(b, { units: { korvette: 4, landungsschiff: 1, schuetzen: 80 } });
|
||||
const res = planMission(base, input(units, 250), T0, b);
|
||||
assert.ok(res.ok);
|
||||
assert.equal(res.mission.rationCost, 150);
|
||||
assert.equal(res.base.resources.proviant, (base.resources.proviant ?? 0) - 150);
|
||||
const poor = makeBase(b, { units: { korvette: 4, landungsschiff: 1, schuetzen: 80 }, resources: { ...base.resources, proviant: 149 } });
|
||||
const no = planMission(poor, input(units, 250), T0, b);
|
||||
assert.ok(!no.ok && no.code === "rations");
|
||||
});
|
||||
Reference in new issue
Block a user