Skip to content

Commit

Permalink
Restricted enchanting targets - again
Browse files Browse the repository at this point in the history
  • Loading branch information
Zomis committed Sep 18, 2014
1 parent ce2a37e commit f74f5ff
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import net.zomis.cardshifter.ecs.actions.TargetableCheckEvent;
import net.zomis.cardshifter.ecs.actions.attack.SpecificActionTargetSystem;
import net.zomis.cardshifter.ecs.base.ComponentRetriever;
import net.zomis.cardshifter.ecs.cards.BattlefieldComponent;
import net.zomis.cardshifter.ecs.cards.CardComponent;
import net.zomis.cardshifter.ecs.cards.Cards;
import net.zomis.cardshifter.ecs.components.CreatureTypeComponent;

public class EnchantTargetCreatureTypes extends SpecificActionTargetSystem {
Expand All @@ -19,6 +22,17 @@ public EnchantTargetCreatureTypes(String[] allowedCreatureTypes) {

@Override
protected void checkTargetable(TargetableCheckEvent event) {
if (!event.getTarget().hasComponent(CardComponent.class)) {
event.setAllowed(false);
return;
}
if (!Cards.isOnZone(event.getTarget(), BattlefieldComponent.class)) {
event.setAllowed(false);
}
if (!Cards.isOwnedByCurrentPlayer(event.getTarget())) {
event.setAllowed(false);
}

if (!type.has(event.getTarget())) {
event.setAllowed(false);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ public void integration() {
useActionWithFailedTarget(enchantment, PhrancisGame.ENCHANT_ACTION, attackerPlayer);
assertResource(attacker, PhrancisResources.ATTACK, 4);
assertResource(attacker, PhrancisResources.HEALTH, 4);
List<Entity> targets = enchantment.get(actions).getAction(PhrancisGame.ENCHANT_ACTION).getTargetSets().get(0).findPossibleTargets();
assertEquals(1, targets.size());
useActionWithTarget(enchantment, PhrancisGame.ENCHANT_ACTION, attacker);
assertResource(attacker, PhrancisResources.ATTACK, 4);
assertResource(attacker, PhrancisResources.HEALTH, 5);
Expand Down

0 comments on commit f74f5ff

Please sign in to comment.