Skip to content

Commit

Permalink
Add also the mana check to the validator
Browse files Browse the repository at this point in the history
  • Loading branch information
tonihele committed Jul 18, 2024
1 parent cfdc92e commit d319981
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -917,11 +917,6 @@ public void castKeeperSpell(short keeperSpellId, EntityId target, Point tile, Ve
}

// Validate
// Mana...
if (keeperSpell.getManaCost() > player.getMana()) {
return;
}

if (!KeeperSpellCastValidator.isValidCast(keeperSpell, kwdFile, mapController, mapTile, player, entityData, target)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,15 @@ public static boolean isValidCast(
Keeper player,
EntityData entityData,
EntityId target) {
return checkCastRule(mapInformation, mapTile, keeperSpell, player)
return checkPlayerMana(keeperSpell, player)
&& checkCastRule(mapInformation, mapTile, keeperSpell, player)
&& checkTargetRule(target, entityData, kwdFile, keeperSpell, player);
}

private static boolean checkPlayerMana(KeeperSpell keeperSpell, Keeper player) {
return keeperSpell.getManaCost() <= player.getMana();
}

private static boolean checkTargetRule(EntityId target, EntityData entityData, KwdFile kwdFile, KeeperSpell keeperSpell, Keeper player) {
short playerId = player.getId();
Creature creature = null;
Expand Down

0 comments on commit d319981

Please sign in to comment.