* Test the requirement for this ability. Negative values mean maximum value of the stat. * For instance : energy = -5 means energy must be lower than 5. * If one requirement fails it returns false. * @return Return true if ability requirements are met.
()
| 842 | * @return Return true if ability requirements are met. |
| 843 | */ |
| 844 | testRequirements(): boolean { |
| 845 | const game = this.game; |
| 846 | const def = { |
| 847 | plasma: 0, |
| 848 | energy: 0, |
| 849 | endurance: 0, |
| 850 | remainingMovement: 0, |
| 851 | stats: { |
| 852 | health: 0, |
| 853 | regrowth: 0, |
| 854 | endurance: 0, |
| 855 | energy: 0, |
| 856 | meditation: 0, |
| 857 | initiative: 0, |
| 858 | offense: 0, |
| 859 | defense: 0, |
| 860 | movement: 0, |
| 861 | pierce: 0, |
| 862 | slash: 0, |
| 863 | crush: 0, |
| 864 | shock: 0, |
| 865 | burn: 0, |
| 866 | frost: 0, |
| 867 | poison: 0, |
| 868 | sonic: 0, |
| 869 | mental: 0, |
| 870 | }, |
| 871 | }, |
| 872 | req = $j.extend(def, this.requirements), |
| 873 | abilityMsgs = game.msg.abilities; |
| 874 | |
| 875 | // Plasma |
| 876 | if (req.plasma > 0) { |
| 877 | if (this.creature.player.plasma < req.plasma) { |
| 878 | this.message = abilityMsgs.notEnough.replace('%stat%', 'plasma'); |
| 879 | return false; |
| 880 | } |
| 881 | } else if (req.plasma < 0) { |
| 882 | if (this.creature.player.plasma > -req.plasma) { |
| 883 | this.message = abilityMsgs.tooMuch.replace('%stat%', 'plasma'); |
| 884 | return false; |
| 885 | } |
| 886 | } |
| 887 | |
| 888 | // Energy |
| 889 | const reqEnergy = req.energy + this.creature.stats.reqEnergy; |
| 890 | if (reqEnergy > 0) { |
| 891 | if (this.creature.energy < reqEnergy) { |
| 892 | this.message = abilityMsgs.notEnough.replace('%stat%', 'energy'); |
| 893 | return false; |
| 894 | } |
| 895 | } else if (reqEnergy < 0) { |
| 896 | if (this.creature.energy > -reqEnergy) { |
| 897 | this.message = abilityMsgs.tooMuch.replace('%stat%', 'energy'); |
| 898 | return false; |
| 899 | } |
| 900 | } |
| 901 |