Fix mineral hold clamping on restore and re-assert Explore gate
- Raise the ship's mining capacity from build records before applying saved minerals, so holds above the base 250 cap survive load/jump-cut instead of being clamped away. - Re-assert the EXPLORE story gate after blanket slot re-arming in SurfaceScene to prevent it coming back live pre-'Special Delivery'. - Move ui_hover SFX from row/node hover to close-button hover in BuildWindow and ResearchWindow.
This commit is contained in:
parent
52650ff5b9
commit
ab7cd1857e
|
|
@ -9737,6 +9737,29 @@ export class GameScene extends Phaser.Scene {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The MAX effects.mining.capacity across a restore's build records
|
||||
* (r.builds.built — planet → build ids — the same source
|
||||
* _restoreMiningUpgrades reads once those records are back in
|
||||
* buildState). applyRestore calls this to raise the hold cap BEFORE
|
||||
* setMinerals, so a save holding more minerals than the base cap (250)
|
||||
* survives the load / jump-cut instead of being clamped to 250. Returns
|
||||
* the ship's current cap when no record expands it.
|
||||
*/
|
||||
_miningCapacityFromBuilds(builds) {
|
||||
let cap = Number(this.ship?.stats?.mineralStorage) || 0;
|
||||
const built = builds?.built;
|
||||
if (built && typeof built === 'object') {
|
||||
for (const ids of Object.values(built)) {
|
||||
for (const id of Array.isArray(ids) ? ids : []) {
|
||||
const c = Number(defById(id)?.effects?.mining?.capacity);
|
||||
if (Number.isFinite(c) && c > cap) cap = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
return cap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-derive the ship's mining upgrades from the build RECORDS (the
|
||||
* save carries the records, not the ship's derived stats): the MAX
|
||||
|
|
@ -10230,8 +10253,17 @@ export class GameScene extends Phaser.Scene {
|
|||
this.ship.setPosition(Number(r.ship.x) || 0, Number(r.ship.y) || 0);
|
||||
if (typeof r.ship.heading === 'number') this.ship.rotation = r.ship.heading;
|
||||
// The hold — saves that predate minerals have no field (stay at 0);
|
||||
// setMinerals clamps to the ship's capacity.
|
||||
if (typeof r.ship.minerals === 'number') this.ship.setMinerals(r.ship.minerals);
|
||||
// setMinerals clamps to the ship's capacity. The hold CAP's source
|
||||
// of truth is the save's build records (effects.mining.capacity —
|
||||
// restored into buildState below, re-asserted by
|
||||
// _restoreMiningUpgrades after create), so raise it BEFORE the
|
||||
// minerals land: a save with more minerals than the base cap (250)
|
||||
// must not be clamped away.
|
||||
if (typeof r.ship.minerals === 'number') {
|
||||
const cap = this._miningCapacityFromBuilds(r.builds);
|
||||
if (cap > (Number(this.ship.stats?.mineralStorage) || 0)) this.ship.stats.mineralStorage = cap;
|
||||
this.ship.setMinerals(r.ship.minerals);
|
||||
}
|
||||
// The credit ledger (data/economy.json) — a save predating credits
|
||||
// has no field; setCredits floors a missing/invalid value at 0.
|
||||
this.ship.setCredits(r.ship.credits ?? 0);
|
||||
|
|
|
|||
|
|
@ -387,6 +387,10 @@ export class SurfaceScene extends Phaser.Scene {
|
|||
if (!s.live || s.id === 'shop') continue; // SHOP is the way out
|
||||
bar.setSlotEnabled(s.id, !locked);
|
||||
}
|
||||
// Re-assert the EXPLORE story gate (idempotent): the blanket re-arm
|
||||
// above would lift its standby underneath the gate (open the shop,
|
||||
// leave it, and Explore would come back live pre-'Special Delivery').
|
||||
this._syncExploreLock();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -536,6 +540,9 @@ export class SurfaceScene extends Phaser.Scene {
|
|||
if (!s.live) continue;
|
||||
deck.setSlotEnabled(s.id, !locked);
|
||||
}
|
||||
// Re-assert the EXPLORE story gate (idempotent): the blanket
|
||||
// re-arm above must not lift its standby underneath the gate.
|
||||
this._syncExploreLock();
|
||||
}
|
||||
const drawer = this.exploreSubBar;
|
||||
if (drawer && Array.isArray(drawer.buttons)) {
|
||||
|
|
|
|||
|
|
@ -369,6 +369,7 @@ export class BuildWindow extends Phaser.GameObjects.Container {
|
|||
});
|
||||
this.closeG.on('pointerover', () => {
|
||||
this.closeBtn.hover = true;
|
||||
this.sfx('ui_hover');
|
||||
this._paintClose();
|
||||
});
|
||||
this.closeG.on('pointerout', () => {
|
||||
|
|
@ -781,7 +782,6 @@ export class BuildWindow extends Phaser.GameObjects.Container {
|
|||
});
|
||||
g.on('pointerover', () => {
|
||||
row.hover = true;
|
||||
this.sfx('ui_hover');
|
||||
this._paintRow(row);
|
||||
});
|
||||
g.on('pointerout', () => {
|
||||
|
|
|
|||
|
|
@ -351,6 +351,7 @@ export class ResearchWindow extends Phaser.GameObjects.Container {
|
|||
});
|
||||
this.closeG.on('pointerover', () => {
|
||||
this.closeBtn.hover = true;
|
||||
this.sfx('ui_hover');
|
||||
this._paintClose();
|
||||
});
|
||||
this.closeG.on('pointerout', () => {
|
||||
|
|
@ -887,7 +888,6 @@ export class ResearchWindow extends Phaser.GameObjects.Container {
|
|||
});
|
||||
g.on('pointerover', () => {
|
||||
node.hover = true;
|
||||
this.sfx('ui_hover');
|
||||
this._paintNode(node);
|
||||
});
|
||||
g.on('pointerout', () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue