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

Method update

code/main/Dragon.ts:135–210  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

133 }
134
135 private update(): void{
136 // Erase everything
137 this.renderArea.resetAllButSize();
138
139 // Back to the map button
140 this.addBackToTheCastleButton(this.renderArea, "dragonBackToTheCastleButton");
141
142 // Draw the ascii
143 this.renderArea.drawArray(Database.getAscii("places/dragonFoot"), 0, 3);
144
145 // Draw something different depending on the step
146 switch(this.step){
147 case DragonStep.PLAYER_MOVING:
148 // Draw the player (eventually going down the stairs at the beginning)
149 this.drawPlayer(this.playerPos, 20 + (this.playerPos < 21? (Math.floor(this.playerPos/3)) : 6));
150 break;
151 case DragonStep.PLAYER_ATTACKING:
152 // Draw the player
153 this.drawPlayer(this.playerPos);
154 // Draw the dragon fake health bar
155 this.renderArea.drawString("| A dragon foot : so much hp/so much hp |", 45, 11);
156 this.renderArea.addBackgroundColor(46, 109, 11, new Color(ColorType.HEALTH_GREEN));
157 break;
158 case DragonStep.STOP_TICKLING:
159 // Draw the player
160 this.drawPlayer(this.playerPos);
161 // Draw the speech
162 this.renderArea.drawSpeech(Database.getText("dragonStopTickling"), 5, 50, 78, "dragonStopTicklingSpeech", Database.getTranslatedText("dragonStopTickling"));
163 // Add the button
164 this.renderArea.addAsciiRealButton(Database.getText("dragonStopTicklingButton"), 50, 9, "dragonStopTicklingButton", Database.getTranslatedText("dragonStopTicklingButton"), true);
165 this.renderArea.addLinkCall(".dragonStopTicklingButton", new CallbackCollection(this.okayStopTickling.bind(this)));
166 break;
167 case DragonStep.TALKING:
168 // Draw the player
169 this.drawPlayer(this.playerPos);
170 // Draw the speech
171 this.renderArea.drawSpeech(Database.getText("dragonTalking"), 5, 50, 78, "dragonTalkingSpeech", Database.getTranslatedText("dragonTalking"));
172 // Add the challenge button
173 this.renderArea.addAsciiRealButton(Database.getText("dragonTalkingChallengeButton"), 82, 5, "dragonTalkingChallengeButton", Database.getTranslatedText("dragonTalkingChallengeButton"));
174 this.renderArea.addLinkCall(".dragonTalkingChallengeButton", new CallbackCollection(this.chooseChallenge.bind(this)));
175 // Add the fame button
176 this.renderArea.addAsciiRealButton(Database.getText("dragonTalkingFameButton"), 82, 7, "dragonTalkingFameButton", Database.getTranslatedText("dragonTalkingFameButton"));
177 this.renderArea.addLinkCall(".dragonTalkingFameButton", new CallbackCollection(this.chooseFame.bind(this)));
178 // Add the candies button
179 this.renderArea.addAsciiRealButton(Database.getText("dragonTalkingCandiesButton"), 82, 9, "dragonTalkingCandiesButton", Database.getTranslatedText("dragonTalkingCandiesButton"));
180 this.renderArea.addLinkCall(".dragonTalkingCandiesButton", new CallbackCollection(this.chooseCandies.bind(this)));
181 break;
182 case DragonStep.TALKING_CHALLENGE:
183 // Draw the player
184 this.drawPlayer(this.playerPos);
185 // Draw the speech
186 this.renderArea.drawSpeech(Database.getText("dragonTalkingChallengeSpeech"), 5, 50, 78, "dragonTalkingChallengeSpeech", Database.getTranslatedText("dragonTalkingChallengeSpeech"));
187 // Add the button
188 this.renderArea.addAsciiRealButton(Database.getText("dragonTalkingChallengeAnswer"), 82, 5, "dragonTalkingChallengeAnswer", Database.getTranslatedText("dragonTalkingChallengeAnswer"));
189 this.renderArea.addLinkCall(".dragonTalkingChallengeAnswer", new CallbackCollection(this.goToHell.bind(this)));
190 break;
191 case DragonStep.TALKING_FAME:
192 // Draw the player

Callers 6

constructorMethod · 0.95
actionIntervalMethod · 0.95
chooseCandiesMethod · 0.95
chooseChallengeMethod · 0.95
chooseFameMethod · 0.95
okayStopTicklingMethod · 0.95

Calls 13

drawPlayerMethod · 0.95
resetAllButSizeMethod · 0.80
drawArrayMethod · 0.80
getAsciiMethod · 0.80
drawStringMethod · 0.80
addBackgroundColorMethod · 0.80
addAsciiRealButtonMethod · 0.80
addLinkCallMethod · 0.80
bindMethod · 0.80
drawSpeechMethod · 0.45
getTextMethod · 0.45

Tested by

no test coverage detected