MCPcopy Create free account
hub / github.com/candybox2/candybox2.github.io / changeAction

Method changeAction

code/main/Cauldron.ts:87–111  ·  view source on GitHub ↗
(newAction: CauldronAction)

Source from the content-addressed store, hash-verified

85 }
86
87 private changeAction(newAction: CauldronAction): void{
88 // If we're not already doing that
89 if(this.currentAction != newAction){
90 // If the action which just stopped wasn't nothing
91 if(this.currentAction != CauldronAction.NOTHING){
92 // Shift actions in the log
93 for(var i = this.actionLog.length-1; i > 0; i--){
94 this.actionLog[i] = this.actionLog[i-1];
95 }
96 // Set actionLog[0] to the action which just stopped
97 this.actionLog[0] = new CauldronActionLogEntry(this.currentAction, this.timerTime, this.getGame().getCandiesInCauldron().getCurrent(), this.getGame().getLollipopsInCauldron().getCurrent());
98 }
99 // Now we're doing that
100 this.currentAction = newAction;
101 // Reset the timer and restart the interval
102 this.timerTime = 0;
103 clearInterval(this.timerIntervalID);
104 this.timerIntervalID = setInterval(this.actionInterval.bind(this), 1000);
105 // We reset the flames array
106 this.resetFlamesArray();
107 // Update
108 this.update();
109 this.getGame().updatePlace();
110 }
111 }
112
113 private changeCandiesInput(): void{
114 if($(".cauldronCandiesInput").length) // If the element exists

Callers 1

putIntoBottlesMethod · 0.95

Calls 8

resetFlamesArrayMethod · 0.95
updateMethod · 0.95
getCurrentMethod · 0.80
getCandiesInCauldronMethod · 0.80
bindMethod · 0.80
updatePlaceMethod · 0.80
getGameMethod · 0.45

Tested by

no test coverage detected