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

Method endQuest

code/main/Quest.ts:526–554  ·  view source on GitHub ↗
(win: boolean)

Source from the content-addressed store, hash-verified

524 }
525
526 public endQuest(win: boolean): void{
527 // If the player won the quest
528 if(win){
529 // Handle candies drops
530 // We add a message to the log to tell about the candies we found
531 this.getGame().getQuestLog().addMessage(new QuestLogMessage(this.getCandiesDropMessage()));
532 // We give him/her the candies found during the quest
533 this.candiesFound.transferTo(this.getGame().getCandies());
534 // Handle chocolate bars drops
535 if(this.chocolateBarsFound.getCurrent() > 0){
536 // We add a message to the log to tell about the chocolate bars we found
537 this.getGame().getQuestLog().addMessage(new QuestLogMessage(this.getChocolateBarsDropMessage(), null, true));
538 // We give him/her the chocolate bars found during the quest
539 this.chocolateBarsFound.transferTo(this.getGame().getChocolateBars());
540 }
541 // Handle items drops
542 for(var i = 0; i < this.itemsFound.length; i++){
543 // We show the drop message
544 this.itemsFound[i].get();
545 // We give him/her the item
546 this.getGame().gainItem(this.itemsFound[i].getSavingName());
547 }
548 // We won
549 this.questEndedAndWeWon = true;
550 }
551
552 // The quest ended !
553 this.questEnded = true;
554 }
555
556 public foundCandies(howMany: number): number{
557 // We check all eqItems in case they want to change how many candies were found

Callers

nothing calls this directly

Calls 12

getCandiesDropMessageMethod · 0.95
addMessageMethod · 0.80
getQuestLogMethod · 0.80
transferToMethod · 0.80
getCurrentMethod · 0.80
getChocolateBarsMethod · 0.80
gainItemMethod · 0.80
getMethod · 0.65
getGameMethod · 0.45
getCandiesMethod · 0.45
getSavingNameMethod · 0.45

Tested by

no test coverage detected