()
| 85 | |
| 86 | // Private methods |
| 87 | private cast(): void{ |
| 88 | var canWeCast: boolean = true; |
| 89 | |
| 90 | // Ceck if the quest is ended to possibly set canWeCast to false |
| 91 | if(this.quest.getQuestEnded()) |
| 92 | canWeCast = false; |
| 93 | |
| 94 | // Check the countdown to possibly set canWeCast to false |
| 95 | if(canWeCast == true){ |
| 96 | switch(this.countdownType){ |
| 97 | case QuestPlayerSpellCountdownType.SPELLS: |
| 98 | if(this.quest.getPlayerSpellsCountdown() > 0) |
| 99 | canWeCast = false; |
| 100 | break; |
| 101 | case QuestPlayerSpellCountdownType.POTIONS: |
| 102 | if(this.quest.getPlayerPotionsCountdown() > 0) |
| 103 | canWeCast = false; |
| 104 | break; |
| 105 | case QuestPlayerSpellCountdownType.BLACKHOLE: |
| 106 | if(this.countdownTime <= 0) |
| 107 | canWeCast = false; |
| 108 | break; |
| 109 | default: break; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | // Check the numberIdWichLimitsQuantity to possibly set canWeCast to false |
| 114 | if(this.numberIdWichLimitsQuantity != null){ |
| 115 | if(Saving.loadNumber(this.numberIdWichLimitsQuantity) <= 0){ |
| 116 | canWeCast = false; |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | // If we can cast |
| 121 | if(canWeCast == true){ |
| 122 | // Handle the countdown |
| 123 | switch(this.countdownType){ |
| 124 | case QuestPlayerSpellCountdownType.SPELLS: |
| 125 | this.quest.increasePlayerSpellsCountdown(this.countdownTime); |
| 126 | break; |
| 127 | case QuestPlayerSpellCountdownType.POTIONS: |
| 128 | this.quest.increasePlayerPotionsCountdown(this.countdownTime); |
| 129 | break; |
| 130 | case QuestPlayerSpellCountdownType.BLACKHOLE: |
| 131 | this.countdownTime -= 1; |
| 132 | break; |
| 133 | default: break; |
| 134 | } |
| 135 | |
| 136 | // Handle numberIdWichLimitsQuantity |
| 137 | if(this.numberIdWichLimitsQuantity != null){ |
| 138 | Saving.saveNumber(this.numberIdWichLimitsQuantity, Saving.loadNumber(this.numberIdWichLimitsQuantity) - 1); |
| 139 | } |
| 140 | |
| 141 | // Fire the callback collection which was given to us |
| 142 | this.callbackCollection.fire(); |
| 143 | } |
| 144 | } |
nothing calls this directly
no test coverage detected