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

Method update

code/main/Lighthouse.ts:42–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40
41 // Public methods
42 public update(): void{
43 // Erase everything
44 this.renderArea.resetAllButSize();
45
46 // Back to the map button
47 this.addBackToMainMapButton(this.renderArea, "lighthouseBackToTheMapButton");
48
49 // Draw the lighthouse
50 this.renderArea.drawArray(Database.getAscii("places/lighthouse/lighthouse"), 0, 3);
51
52 // Add the questions list
53 this.renderArea.addList(1, 55, 7, "lighthouseQuestionsList", new CallbackCollection(this.questionSelected.bind(this)), this.questionsArray);
54
55 // Add the ask button and the link
56 this.renderArea.addAsciiRealButton(Database.getText("lighthouseAskButton"), 5, 10, "lighthouseAskButton", Database.getTranslatedText("lighthouseAskButton"));
57 this.renderArea.addLinkCall(".lighthouseAskButton", new CallbackCollection(this.ask.bind(this)));
58
59 // Draw the speech if there's a speech id
60 if(this.speechId != null){
61 this.renderArea.drawSpeech(Database.getText(this.speechId), 17, 75, 99, "lighthouseSpeech", Database.getTranslatedText(this.speechId));
62 }
63
64 // If we should show the puzzle
65 if(this.showPuzzle){
66 // Create the puzzle if it's not done yet
67 if(this.puzzle == null)
68 this.puzzle = new LighthousePuzzle(this);
69 // Draw it
70 this.puzzle.draw(this.renderArea, new Pos(2, 12));
71 // Add the reset button
72 this.renderArea.addAsciiRealButton(Database.getText("lighthousePuzzleResetButton"), 2, 34, "lighthousePuzzleResetButton", Database.getTranslatedText("lighthousePuzzleResetButton"));
73 this.renderArea.addLinkCall(".lighthousePuzzleResetButton", new CallbackCollection(this.resetPuzzle.bind(this)));
74 }
75
76 // Add the link which will call the selectRightQuestion method after the html dom is created
77 this.renderArea.addLinkCallbackCollection(new CallbackCollection(this.selectRightQuestion.bind(this)));
78 }
79
80 // Public getters
81 public getPuzzle(): LighthousePuzzle{

Callers 4

constructorMethod · 0.95
askMethod · 0.95
questionSelectedMethod · 0.95
resetPuzzleMethod · 0.95

Calls 12

resetAllButSizeMethod · 0.80
drawArrayMethod · 0.80
getAsciiMethod · 0.80
addListMethod · 0.80
bindMethod · 0.80
addAsciiRealButtonMethod · 0.80
addLinkCallMethod · 0.80
getTextMethod · 0.45
drawSpeechMethod · 0.45
drawMethod · 0.45

Tested by

no test coverage detected