mirror of
https://github.com/motajs/template.git
synced 2026-11-11 21:44:31 +08:00
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:
1 parent
76a62918d7
commit
e7f341095d
2 files changed
+13
-11
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -333,22 +333,22 @@ describe('EquipmentState save and load round trips', () => {
|
||||
);
|
||||
});
|
||||
|
||||
// 疑似 bug�E�Low 压缩档读档未回退到裁E��E��始定义,未修改皁E��刁E��加成丢失�E�详见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�E�High 压缩档读档未回退到裁E��E��始定义,未修改皁E��刁E��加成丢失�E�详见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�E�loadNoCompression 误从存档百刁E��表读取数值表�E�详见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�E�loadDiff 渁E��后未回退到裁E��E��始定义,未修改皁E��成丢失�E�详见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);
|
||||
|
||||
Reference in new issue
Block a user