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

Method update

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

Source from the content-addressed store, hash-verified

87 }
88
89 public update(): void{
90 if(this.getQuestEnded() == false){
91 // Possibly add a bird
92 if(this.currentBirdTime >= this.nextBirdAt){
93 this.currentBirdTime = 0;
94 this.setNextBirdAt();
95 this.addBird();
96 }
97 else this.currentBirdTime += 1;
98
99 // Test if the player won the quest, if so, end the quest and return
100 if(this.thePlayerWon()){
101 this.endQuest(true);
102 return;
103 }
104
105 // Test if the player is dead, if so, end the quest and return
106 if(this.getGame().getPlayer().shouldDie()){
107 this.endQuest(false);
108 return;
109 }
110
111 // Update entities
112 this.updateEntities();
113 }
114
115 // Draw
116 this.preDraw();
117 this.getRenderArea().drawArray(Database.getAscii("places/quests/desert/background"), this.getRealQuestPosition().x, this.getRealQuestPosition().y + 21);
118 this.drawEntities();
119 this.drawAroundQuest();
120 if(this.getQuestEnded() == false) this.addExitQuestButton(new CallbackCollection(this.getGame().goToMainMap.bind(this.getGame())), "buttonExitQuestNoKeeping");
121 else if(this.getQuestEndedAndWeWon() == false) this.addExitQuestButton(new CallbackCollection(this.getGame().goToMainMap.bind(this.getGame())), "buttonExitQuestNoKeepingBecauseLose");
122 else this.addExitQuestButton(new CallbackCollection(this.getGame().goToMainMap.bind(this.getGame())), "buttonExitQuestKeeping");
123 this.postDraw();
124 }
125
126 // Private methods
127 private addBird(): void{

Callers

nothing calls this directly

Calls 15

setNextBirdAtMethod · 0.95
addBirdMethod · 0.95
thePlayerWonMethod · 0.95
endQuestMethod · 0.95
getQuestEndedMethod · 0.80
getPlayerMethod · 0.80
updateEntitiesMethod · 0.80
preDrawMethod · 0.80
drawArrayMethod · 0.80
getAsciiMethod · 0.80
getRealQuestPositionMethod · 0.80
drawEntitiesMethod · 0.80

Tested by

no test coverage detected