-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed scaling stats carrying over between runs.
- Loading branch information
Showing
3 changed files
with
45 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,43 @@ | ||
import { flog } from "../../helpers/DebugHelper"; | ||
import { mod } from "../../Mod"; | ||
import {flog} from "../../helpers/DebugHelper"; | ||
import {mod} from "../../Mod"; | ||
import {BladeScalingUpgradeType} from "../../items/samuraiBlade/scaling/BladeScalingUpgradeType"; | ||
import {CachePosition} from "../../items/samuraiBlade/scaling/CachePosition"; | ||
|
||
|
||
const saveDataObject = { | ||
persistent: {}, | ||
run: { | ||
loaded: false, | ||
damageDealt: new Map<number, number>(), // Controller Index, damage dealt pairs. | ||
}, | ||
room: {}, | ||
level: {}, | ||
persistent: {}, | ||
run: { | ||
loaded: false, | ||
damageDealt: new Map<number, number>(), // Controller Index, damage dealt pairs. | ||
scalingStateCache: new Map<number, Map<BladeScalingUpgradeType, CachePosition>>() | ||
}, | ||
room: {}, | ||
level: {}, | ||
}; | ||
|
||
export function getScalingStateCache(): Map<number, Map<BladeScalingUpgradeType, CachePosition>> { | ||
return saveDataObject.run.scalingStateCache; | ||
} | ||
|
||
export function registerSaveData(): void { | ||
if (!saveDataObject.run.loaded) { | ||
saveDataObject.run.loaded = true; | ||
mod.saveDataManager("bladeProgressionData", saveDataObject); | ||
} | ||
flog(`Save data registered: ${saveDataObject.run.damageDealt}`); | ||
if (!saveDataObject.run.loaded) { | ||
saveDataObject.run.loaded = true; | ||
mod.saveDataManager("bladeProgressionData", saveDataObject); | ||
} | ||
flog(`Save data registered: ${saveDataObject.run.damageDealt}`); | ||
} | ||
|
||
export function getTotalDamageDealt(controllerIndex: number): number { | ||
const value = saveDataObject.run.damageDealt.get(controllerIndex); | ||
return value ? value : 0; | ||
const value = saveDataObject.run.damageDealt.get(controllerIndex); | ||
return value ? value : 0; | ||
} | ||
|
||
export function increaseDamageDealt(controllerIndex: number, amount: number): void { | ||
const value = saveDataObject.run.damageDealt.get(controllerIndex); | ||
if (value) { | ||
saveDataObject.run.damageDealt.set(controllerIndex, value + amount); | ||
} else { | ||
saveDataObject.run.damageDealt.set(controllerIndex, amount); | ||
} | ||
flog(`DAMAGE DEALT: ${saveDataObject.run.damageDealt.get(controllerIndex)}, LOADED: ${saveDataObject.run.loaded}`, `[PERSISTENT BLADE DATA]`); | ||
const value = saveDataObject.run.damageDealt.get(controllerIndex); | ||
if (value) { | ||
saveDataObject.run.damageDealt.set(controllerIndex, value + amount); | ||
} else { | ||
saveDataObject.run.damageDealt.set(controllerIndex, amount); | ||
} | ||
flog(`DAMAGE DEALT: ${saveDataObject.run.damageDealt.get(controllerIndex)}, LOADED: ${saveDataObject.run.loaded}`, `[PERSISTENT BLADE DATA]`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export class CachePosition { | ||
public index: number; | ||
public value: number; | ||
|
||
constructor(index: number, value: number) { | ||
this.index = index; | ||
this.value = value; | ||
} | ||
} |