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

Method update

code/main/CandyBox.ts:37–129  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35
36 // Public methods
37 public update(): void{
38 // Y gap for everything below the throwing candies stuff (because the throwing candies stuff can be extended a lot)
39 var yGapForEverythingBelowTheThrowingCandiesStuff: number = 0;
40
41 // Erase everything
42 this.renderArea.resetAllButSize();
43
44 // Draw the box
45 if(Saving.loadBool("lonelyHouseTakeTheBoxDone")){
46 if(Saving.loadBool("candyBoxBoxOpened") == true)
47 this.renderArea.drawArray(Database.getAscii("general/openBox"), 68, 4);
48 else
49 this.renderArea.drawArray(Database.getAscii("general/box"), 68, 4);
50 }
51
52 // If we possess the talking candy
53 if(Saving.loadBool("gridItemPossessedTalkingCandy") == true){
54 // Draw the ascii art
55 this.renderArea.drawArray(Database.getAscii("gridItems/talkingCandy"), 68, 37);
56
57 // If we don't have the box yet
58 if(Saving.loadBool("lonelyHouseTakeTheBoxDone") == false){
59 // Draw the speech
60 this.renderArea.drawSpeech(Database.getText("talkingCandySpeechNoBox"), 30, 72, 98, "candyBoxTalkingCandySpeech", Database.getTranslatedText("talkingCandySpeechNoBox"));
61 }
62 // Else, we have the box
63 else{
64 // If the talking candy already opened the box
65 if(Saving.loadBool("candyBoxBoxOpened")){
66 // Draw the speech
67 this.renderArea.drawSpeech(Database.getText("talkingCandySpeech2"), 34, 72, 98, "candyBoxTalkingCandySpeech", Database.getTranslatedText("talkingCandySpeech2"));
68 }
69 // Else, the box is still closed
70 else{
71 // Draw the speech
72 this.renderArea.drawSpeech(Database.getText("talkingCandySpeech1"), 30, 72, 98, "candyBoxTalkingCandySpeech", Database.getTranslatedText("talkingCandySpeech1"));
73 // Add the button
74 this.renderArea.addAsciiRealButton(Database.getText("talkingCandyButton"), 80, 37, "candyBoxTalkingCandyButton", Database.getTranslatedText("talkingCandyButton"));
75 this.renderArea.addLinkCall(".candyBoxTalkingCandyButton", new CallbackCollection(this.openBox.bind(this)));
76 }
77 }
78 }
79
80 // Eat all the candies
81 if(this.eatButtonShown){
82 this.renderArea.addAsciiRealButton(Database.getText("candyBoxEatCandiesButton"), 0, 1, "candyBoxEatCandiesButton", Database.getTranslatedText("candyBoxEatCandiesButton"), false, 0);
83 this.renderArea.addLinkCall(".candyBoxEatCandiesButton", new CallbackCollection(this.clickedEatCandiesButton.bind(this)));
84 if(this.getGame().getCandiesEaten().getCurrent() != 0) this.renderArea.drawString(this.getGame().getCandiesEaten().getCurrentAsString(), 0, 3);
85 }
86
87 // Throw 10 candies
88 if(this.throwButtonShown){
89 this.renderArea.addAsciiRealButton(Database.getText("candyBoxThrowCandiesButton"), 0, 6, "candyBoxThrowCandiesButton", Database.getTranslatedText("candyBoxThrowCandiesButton"), false, 0);
90 this.renderArea.addLinkCall(".candyBoxThrowCandiesButton", new CallbackCollection(this.clickedThrowCandiesButton.bind(this)));
91 if(this.getGame().getCandiesThrown().getCurrent() != 0){
92 yGapForEverythingBelowTheThrowingCandiesStuff = this.getGame().getCandiesThrown().draw(this.renderArea, 0, 8); // Set the yGap..
93 }
94 }

Callers 10

constructorMethod · 0.95
checkCandiesMethod · 0.95
openBoxMethod · 0.95

Calls 15

resetAllButSizeMethod · 0.80
drawArrayMethod · 0.80
getAsciiMethod · 0.80
addAsciiRealButtonMethod · 0.80
addLinkCallMethod · 0.80
bindMethod · 0.80
getCurrentMethod · 0.80
getCandiesEatenMethod · 0.80
drawStringMethod · 0.80
getCandiesThrownMethod · 0.80
drawSpeechMethod · 0.45
getTextMethod · 0.45

Tested by

no test coverage detected