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

Method update

code/main/Yourself.ts:59–89  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

57 }
58
59 public update(): void{
60 if(this.getQuestEnded() == false){
61 // Test if the player is dead, if so, end the quest and return
62 if(this.getGame().getPlayer().shouldDie()){
63 this.endQuest(false);
64 return;
65 }
66
67 // Test if the player won the quest, if so, end the quest and return
68 if(this.thePlayerWon()){
69 this.endQuest(true);
70 return;
71 }
72
73 // Handle sentences
74 this.handleSentences();
75
76 // Update entities
77 this.updateEntities();
78 }
79
80 // Draw
81 this.preDraw();
82 this.drawEntities();
83 this.drawSentences(); // Draw the sentences
84 this.drawAroundQuest();
85 if(this.getQuestEnded() == false) this.addExitQuestButton(new CallbackCollection(this.getGame().goToMainMap.bind(this.getGame())), "buttonExitQuestNoKeeping");
86 else if(this.getQuestEndedAndWeWon() == false) this.addExitQuestButton(new CallbackCollection(this.getGame().goToMainMap.bind(this.getGame())), "buttonExitQuestNoKeepingBecauseLose");
87 else this.addExitQuestButton(new CallbackCollection(this.getGame().goToMainMap.bind(this.getGame())), "buttonExitQuestKeeping");
88 this.postDraw();
89 }
90
91 // Private methods
92 private addYourself(): void{

Callers 1

handleSentencesMethod · 0.45

Calls 15

endQuestMethod · 0.95
thePlayerWonMethod · 0.95
handleSentencesMethod · 0.95
drawSentencesMethod · 0.95
getQuestEndedMethod · 0.80
getPlayerMethod · 0.80
updateEntitiesMethod · 0.80
preDrawMethod · 0.80
drawEntitiesMethod · 0.80
drawAroundQuestMethod · 0.80
addExitQuestButtonMethod · 0.80
bindMethod · 0.80

Tested by

no test coverage detected