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

Method handlePond

code/main/LollipopFarm.ts:361–403  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

359 }
360
361 private handlePond(): void{
362 // Used later
363 var lineIndex: number;
364
365 // If the pond is dug
366 if(Saving.loadBool("lollipopFarmPondDug") == true){
367 // Move all the lolligators
368 for(var i = 0; i < this.pondLolligators.length; i++){
369 this.pondLolligators[i].move();
370 }
371
372 // Delete lolligators which need to be deleted
373 for(var i = 0; i < this.pondLolligators.length; i++){
374 // If this lolligator should be deleted, then we delete it
375 if(this.pondLolligators[i].shouldBeDeleted()){
376 // Warn that it will be deleted
377 this.pondLolligators[i].willBeDeleted();
378
379 // Delete it
380 this.pondLolligators.splice(i, 1);
381
382 // Reduce i
383 i--;
384 }
385 }
386
387 // Possibly add a lolligator if there wouldn't be more lolligators than we actually have (the more lollipops we have the more chance there is that one will be added)
388 if(Random.oneChanceOutOf(Math.ceil(20*(1/Saving.loadNumber("lollipopFarmPondHowManyLolligators")))) && this.pondLolligators.length < Saving.loadNumber("lollipopFarmPondHowManyLolligators")){
389 // Choose a line
390 lineIndex = Random.between(0, this.pondLines.length-1);
391
392 // If the line isn't used and the line above (if there is one) isn't used either
393 if(this.pondLines[lineIndex].getIsUsed() == false && (lineIndex == 0 || this.pondLines[lineIndex-1].getIsUsed() == false)){
394 // Add a lolligator here
395 this.addPondLolligator(new PondLolligator(this.pondLines, lineIndex));
396 }
397 }
398
399 // We update
400 this.update();
401 this.getGame().updatePlace();
402 }
403 }
404
405 private plantLollipops(howMany: number): void{
406 // If we have enough lollipops

Callers

nothing calls this directly

Calls 8

addPondLolligatorMethod · 0.95
updateMethod · 0.95
shouldBeDeletedMethod · 0.80
willBeDeletedMethod · 0.80
getIsUsedMethod · 0.80
updatePlaceMethod · 0.80
moveMethod · 0.45
getGameMethod · 0.45

Tested by

no test coverage detected