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

Method drawFieldStuff

code/main/LollipopFarm.ts:168–216  ·  view source on GitHub ↗
(x: number, y: number)

Source from the content-addressed store, hash-verified

166 }
167
168 private drawFieldStuff(x: number, y: number): void{
169 // A variable useful later
170 var plantingButtonsXPos: number;
171
172 // How many lollipops planted
173 this.renderArea.drawString("Lollipops planted : " + Algo.numberToStringButNicely(Saving.loadNumber("lollipopFarmLollipopsPlanted")), x, y);
174
175 // Button(s) to plant lollipops
176 // If the first button is unlocked but not the second
177 if(Saving.loadBool("lollipopFarmPlant1LollipopButtonUnlocked") == true && Saving.loadBool("lollipopFarmPlant10LollipopsButtonUnlocked") == false){
178 this.renderArea.addAsciiRealButton("Plant 1 lollipop", x, y+2, "lollipopFarmPlant1LollipopButton");
179 this.renderArea.addLinkCall(".lollipopFarmPlant1LollipopButton", new CallbackCollection(this.plantLollipops.bind(this, 1)));
180 }
181 // Else, if the second is unlocked
182 else if(Saving.loadBool("lollipopFarmPlant10LollipopsButtonUnlocked") == true){
183 // We set the x position to 0
184 plantingButtonsXPos = 0;
185 // We draw the first text
186 this.renderArea.drawString("Plant", x, y+2);
187 plantingButtonsXPos += 6;
188 // We add the button to plant 1
189 this.renderArea.addAsciiRealButton("1", x + plantingButtonsXPos, y+2, "lollipopFarmPlant1LollipopButton");
190 this.renderArea.addLinkCall(".lollipopFarmPlant1LollipopButton", new CallbackCollection(this.plantLollipops.bind(this, 1)));
191 plantingButtonsXPos += 2;
192 // We add the button to plant 10
193 this.renderArea.addAsciiRealButton("10", x + plantingButtonsXPos, y+2, "lollipopFarmPlant10LollipopsButton");
194 this.renderArea.addLinkCall(".lollipopFarmPlant10LollipopsButton", new CallbackCollection(this.plantLollipops.bind(this, 10)));
195 plantingButtonsXPos += 3;
196 // We possibly add the button to plant 100
197 if(Saving.loadBool("lollipopFarmPlant100LollipopsButtonUnlocked") == true){
198 this.renderArea.addAsciiRealButton("100", x + plantingButtonsXPos, y+2, "lollipopFarmPlant100LollipopsButton");
199 this.renderArea.addLinkCall(".lollipopFarmPlant100LollipopsButton", new CallbackCollection(this.plantLollipops.bind(this, 100)));
200 plantingButtonsXPos += 4;
201 }
202 // We possibly add the button to plant 100
203 if(Saving.loadBool("lollipopFarmPlant1000LollipopsButtonUnlocked") == true){
204 this.renderArea.addAsciiRealButton("1000", x + plantingButtonsXPos, y+2, "lollipopFarmPlant1000LollipopsButton");
205 this.renderArea.addLinkCall(".lollipopFarmPlant1000LollipopsButton", new CallbackCollection(this.plantLollipops.bind(this, 1000)));
206 plantingButtonsXPos += 5;
207 }
208 // We add the final text
209 this.renderArea.drawString("lollipops", x + plantingButtonsXPos, y+2);
210 }
211
212 // The production
213 if(Saving.loadNumber("lollipopFarmLollipopsPlanted") > 0){
214 this.renderArea.drawString("Production : " + this.getProductionAsString(), x, y+4);
215 }
216 }
217
218 private drawMillStuff(x: number, y: number): void{
219 // Button to construct the mill (show if the button is unlocked and the mill isn't constructed yet)

Callers 1

updateMethod · 0.95

Calls 5

getProductionAsStringMethod · 0.95
drawStringMethod · 0.80
addAsciiRealButtonMethod · 0.80
addLinkCallMethod · 0.80
bindMethod · 0.80

Tested by

no test coverage detected