fix(07-04): #06-09-1 restore equipment modifiers from split save tables

- loadNoCompression reads value entries from state.value instead of state.percentage
- loadDiff seeds this.value/this.percentage from the item.equip base definition before applying save diffs
- un-skip the four correct-expectation EquipmentState round-trip cases (Low/High percentage, NoCompression value, compressed unchanged value)
This commit is contained in:
unanmed 2026-09-15 20:26:45 +08:00
parent 76a62918d7
commit e7f341095d
2 changed files with 13 additions and 11 deletions

View File

@ -116,7 +116,7 @@ export class EquipmentState<THero> implements IEquipmentState<THero> {
private loadNoCompression(state: IEquipmentStateSave<THero>): void {
this.value.clear();
this.percentage.clear();
for (const [name, value] of state.percentage) {
for (const [name, value] of state.value) {
this.value.set(name, value);
}
for (const [name, value] of state.percentage) {
@ -132,10 +132,12 @@ export class EquipmentState<THero> implements IEquipmentState<THero> {
private loadDiff(state: IEquipmentStateSave<THero>): void {
this.value.clear();
this.percentage.clear();
for (const [name, value] of state.percentage) {
// 基准为装备原始定义,再叠加存档中的差异条目
for (const [name, value] of this.item.equip.value) {
this.value.set(name, value);
}
for (const [name, value] of state.percentage) {
for (const [name, value] of this.item.equip.percentage) {
this.percentage.set(name, value);
}

View File

@ -333,22 +333,22 @@ describe('EquipmentState save and load round trips', () => {
);
});
// 疑似 bug<75>E<EFBFBD>Low 压缩档读档未回退到裁E<E8A381><45>E<EFBFBD><45>始定义,未修改皁E<E79A81><45>刁E<E58881><45>加成丢失<E4B8A2>E<EFBFBD>详见E06-TEST-FINDINGS.md #06-09-1
it.skip('restores a percentage modifier on the same instance in LowCompression', () => {
// 验证 Low 压缩档读档以装备原始定义为回退基准,未修改的百分比加成不丢失(#06-09-1)
it('restores a percentage modifier on the same instance in LowCompression', () => {
expect(
roundTripPercentageModifier(SaveCompression.LowCompression)
).toBe(0.5);
});
// 疑似 bug<75>E<EFBFBD>High 压缩档读档未回退到裁E<E8A381><45>E<EFBFBD><45>始定义,未修改皁E<E79A81><45>刁E<E58881><45>加成丢失<E4B8A2>E<EFBFBD>详见E06-TEST-FINDINGS.md #06-09-1
it.skip('restores a percentage modifier on the same instance in HighCompression', () => {
// 验证 High 压缩档读档以装备原始定义为回退基准,未修改的百分比加成不丢失(#06-09-1)
it('restores a percentage modifier on the same instance in HighCompression', () => {
expect(
roundTripPercentageModifier(SaveCompression.HighCompression)
).toBe(0.5);
});
// 疑似 bug<75>E<EFBFBD>loadNoCompression 误从存档百刁E<E58881><45>表读取数值表<E580BC>E<EFBFBD>详见E06-TEST-FINDINGS.md #06-09-1
it.skip('restores a value modifier on the same instance', () => {
// 验证 NoCompression 读档按 value/percentage 分表恢复数值修饰器(#06-09-1)
it('restores a value modifier on the same instance', () => {
const env = createEquipEnv();
const item = createEquipItem(10, 'sword', [0], [['atk', 5]]);
registerItem(env, item);
@ -365,8 +365,8 @@ describe('EquipmentState save and load round trips', () => {
expect(restored?.[1].getValue()).toBe(5);
});
// 疑似 bug<75>E<EFBFBD>loadDiff 渁E<E6B881><45>后未回退到裁E<E8A381><45>E<EFBFBD><45>始定义,未修改皁E<E79A81><45>成丢失<E4B8A2>E<EFBFBD>详见E06-TEST-FINDINGS.md #06-09-1
it.skip('keeps unchanged value modifiers for compressed snapshots', () => {
// 验证压缩档读档回退原始定义后未修改的数值修饰器仍保留(#06-09-1)
it('keeps unchanged value modifiers for compressed snapshots', () => {
const env = createEquipEnv();
const item = createEquipItem(10, 'sword', [0], [['atk', 5]]);
registerItem(env, item);