5NOOFT552GDEBDUACQZXG4TOLQSILGZEPGEJRS5BQD34TIJQ6T2QC
TWWXXFP7B7ESYFOB5BOLLUSYTVPBDW33SISI4HZINYZ7ODRKPMPQC
Z5I5KK7NX6RS23QAB7ISLQCM5Z6TMVZK532NPSE7CO4MNXNKVKMAC
WBAN6KIPMKEXHGGQGE3TB6G7YXHGOPT3HRCEUYZKLNJCJBMR7JHAC
Z3E7XJOW6NSBDYRDKSGTOAEJSPATAUX4JUFCL4DIL3372GL4K52QC
6EXHALB3E5HP3IQVC47M4RVZE2JERJHX37GOOHPYIVAFBWSWUX7QC
HUH4SI4HXIP72KQSJP2I4ELHX5KUQZM7FFGKZZGJ33DF7E3JHMYQC
DDJJXZKSQLXUXIMLKMKHY75JKC2IRA2A7SEVSUNL5FSCFH77T4IAC
3UFL673QX2JG7KHTAM7DFH4BBYVHDNMXBS2RW45G3JBNFZFLSRRQC
Y7TNTUXM44MRLGA6FEG7J6BR77I7N3AIPZYVPXULOQZQ6PNOWJ7QC
GJGKS2YPL6XOT4CLQ2NVHUU2W7MDHYE2XC77WWRGPBCPSTWZ5GIAC
3J7QNHQ4F2VBYCK6SWKPO3AW3YYAJZNWOW6XNSURSRDZOE2ZIGQAC
SJGRJWVRMIYRCSQUR4LMS2APZNSJ64JAW7647NYTB52REONXVD2QC
J6PGLNNQWZU7S7QKFZ7QXLMSVIISQM6BHALJ6EU3JPMDXLAEB7OQC
import { GameState, Quest } from "../data/GameState";
import { UpdaterGeneratorType2 } from "../lib/util/updaterGenerator";
export function createQuest(updaters: UpdaterGeneratorType2<GameState>) {
updaters.playerSave.activeQuest.enqueueUpdate((prev) => {
return new QuestFactory({}).create();
});
updaters.playerSave.batchesSinceQuestStart.enqueueUpdate((prev) => {
return 1;
});
updaters.playerSave.availableSp.enqueueUpdate((prev) => {
return 5;
});
}
type QuestFactoryConfig = { }
export class QuestFactory {
public config: QuestFactoryConfig
constructor(config: QuestFactoryConfig) {
this.config = config;
}
public create(): Quest {
return {
description: "placeholder"
};
}
}
// Things that should happen after allocation history is appended to , in order to maintain the game state in a good state
export function afterAppendAllocationHistory(updaters: UpdaterGeneratorType2<GameState>) {
updaters.playerSave.allocatedPointNodeSet.enqueueUpdate((prev: HashSet<PointNodeRef>, prevGameState) => {
let history = prevGameState.playerSave.allocatedPointNodeHistory
let mostRecent = history[history.length - 1]
console.log({ history, actualHistory: [...history] });
// if we were already selected, try to allocate us
if (!prev.contains(mostRecent)) {
const next = prev.clone();
next.put(mostRecent);
console.log({ prev, next, prevSize: prev.size(), nextSize: next.size(), isEqual: prev === next })
return next;
}
return prev;
});
updaters.playerSave.allocatedPointNodeHistory.update((prev, prevGameState) => {
updaters.playerSave.allocatedPointNodeHistory.enqueueUpdate((prev, prevGameState) => {
if (prevGameState.playerUI.selectedPointNode?.pointNodeId === args.selfPointNodeRef.pointNodeId &&
canAllocate(
if (prevGameState.playerUI.selectedPointNode?.pointNodeId === args.selfPointNodeRef.pointNodeId) {
if (canAllocate(
) === 'yes'
) {
prev.push(args.selfPointNodeRef);
console.log({ prev, actualPrev : [...prev]});
return [...prev];
) === 'yes') {
prev.push(args.selfPointNodeRef);
console.log({ prev, actualPrev: [...prev] });
return [...prev];
} else {
// happens +1 tick afterwards due to nested enqueue, but NBD
updaters.playerUI.activeTab.enqueueUpdate((prev) => {
return 1;
})
}
updaters.playerSave.allocatedPointNodeSet.update((prev: HashSet<PointNodeRef>, prevGameState) => {
let history = prevGameState.playerSave.allocatedPointNodeHistory
let mostRecent = history[history.length - 1]
console.log({ history, actualHistory: [...history] });
// if we were already selected, try to allocate us
if (!prev.contains(mostRecent)) {
const next = prev.clone();
next.put(mostRecent);
console.log({ prev, next, prevSize: prev.size(), nextSize: next.size(), isEqual: prev === next })
return next;
}
return prev;
})
afterAppendAllocationHistory(updaters);