MLD2UMGNFL5Q446O6EI5L5JS3RTEZ4IR4VENYHE7RIKBKVYKVUEAC HSGHFAWQDMFAO6XGAUTFBV2DC5TT6XH3K5Y6FWHPQJLTS2OH3FMQC WBAN6KIPMKEXHGGQGE3TB6G7YXHGOPT3HRCEUYZKLNJCJBMR7JHAC GIDOI5BK3WYIDEQL7SZTJPR3Q5TDQ34YHDPDCUFFH6PX4POEDSQQC HXHNGFB2VCXB6YXDND35HJI22GBJC3QTSUR2TK3M3LXGJHVNXVHAC TWWXXFP7B7ESYFOB5BOLLUSYTVPBDW33SISI4HZINYZ7ODRKPMPQC BGASX3JPOPME4PSC34CHD5VLBZAQMXIAPZQ4DKCWZGEASXCKGW3AC X7IQA5I46B6EHXPBIWTPCMZR4RZQ7PSJN5IMSEHA7H6F2NWQSNSQC BDMXIXECYJQDF66EF2TSVVHWIJ5CC22LUFOAOO2Y6YTZZPI3GOYQC 5NOOFT552GDEBDUACQZXG4TOLQSILGZEPGEJRS5BQD34TIJQ6T2QC P6J3K3PNCSP323JJJ4IBEMX3OMFUVLSHGMA66FUACCUC3Z72DQMQC 3UFL673QX2JG7KHTAM7DFH4BBYVHDNMXBS2RW45G3JBNFZFLSRRQC PZNEDCRDS5IBR7QDPHTW5HZRMQAZFIF7VB3IKWPZDC7IALHZKHWAC L4VMIGM6D5WUEBYOCXBIF6V66NRJAKOJO4FHALHIUIAGAUQUKDPAC OAY5NOOTDF5QELB64LYDGSKANR33WIH4QKNRBO437TMUMAQ5CWRQC 5BALZJFM2MNK7LFDM3YU2GBPB7CAMKWEZSHKXDWU7SAXXMPZ2OQQC import { GameState, PointNodeRef } from "../data/GameState";import { UpdaterGeneratorType2 } from "../lib/util/updaterGenerator";import { computePlayerResourceAmounts } from "./ComputeState";import { afterMaybeSpendingSp, doTryAllocate } from "./OnAllocation";export function selectOrReselectNode(updaters: UpdaterGeneratorType2<GameState>,selfPointNodeRef: PointNodeRef) {let justTriedToAllocate = false;let justSpentSp = false;let justFailedToAllocate = false;// update selected to ourselvesupdaters.playerUI.selectedPointNode.enqueueUpdate((prev, gameState) => {if (prev?.pointNodeId === selfPointNodeRef.pointNodeId) {// console.log('just selected: ', this);justTriedToAllocate = true;}return selfPointNodeRef;});// if we tried to allocate ourselves, see if we canupdaters.playerSave.enqueueUpdate((prev, prevGameState) => {if (justTriedToAllocate) {justTriedToAllocate = false;let [next, succeeded] = doTryAllocate(prev, prevGameState, selfPointNodeRef);if (succeeded) {justSpentSp = true;return next;} else {justFailedToAllocate = true;return prev;}}return prev;});// TODO(bowei): if we spent sp, remember to update quest status!!updaters.computed.enqueueUpdate((prev, prevGameState) => {if (justSpentSp) {// this.state.justSpentSp = false;// console.log("just spent SP!");return computePlayerResourceAmounts(prevGameState);}return prev;})updaters.playerSave.enqueueUpdate((prev, prevGameState) => {if (justSpentSp) {justSpentSp = false;// console.log("just spent SP!");return afterMaybeSpendingSp(prev, prevGameState);}return prev;})// if we failed to allocate, shift the active tab so the player can see whyupdaters.playerUI.activeTab.enqueueUpdate((prev, prevGameState) => {if (justFailedToAllocate) {justFailedToAllocate = false;return 1;}return prev;});}
// update selected to ourselvesupdaters.playerUI.selectedPointNode.enqueueUpdate((prev, gameState) => {if (prev?.pointNodeId === this._staleProps.selfPointNodeRef.pointNodeId) {console.log('just selected: ', this);this.state.justTriedToAllocate = true;}return this._staleProps.selfPointNodeRef;});// if we tried to allocate ourselves, see if we canupdaters.playerSave.enqueueUpdate((prev, prevGameState) => {if (this.state.justTriedToAllocate) {this.state.justTriedToAllocate = false;let [next, succeeded] = doTryAllocate(prev, prevGameState, this._staleProps.selfPointNodeRef);if (succeeded) {this.state.justSpentSp = true;return next;} else {this.state.justFailedToAllocate = true;return prev;}}return prev;});// TODO(bowei): if we spent sp, remember to update quest status!!updaters.computed.enqueueUpdate((prev, prevGameState) => {if (this.state.justSpentSp) {// this.state.justSpentSp = false;// console.log("just spent SP!");return computePlayerResourceAmounts(prevGameState);}return prev;})updaters.playerSave.enqueueUpdate((prev, prevGameState) => {if (this.state.justSpentSp) {this.state.justSpentSp = false;// console.log("just spent SP!");return afterMaybeSpendingSp(prev, prevGameState);}return prev;})// if we failed to allocate, shift the active tab so the player can see whyupdaters.playerUI.activeTab.enqueueUpdate((prev, prevGameState) => {if (this.state.justFailedToAllocate) {console.log('just failed to allocate: ', this);this.state.justFailedToAllocate = false;return 1;}return prev;});
// event.stopPropagation();