Skip to content

Commit

Permalink
targeting is working except for enchants
Browse files Browse the repository at this point in the history
  • Loading branch information
bazola committed Sep 4, 2014
1 parent 030ab99 commit 4c3fd9b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
18 changes: 8 additions & 10 deletions cardshifter-fx/src/main/java/com/cardshifter/fx/CardNode.java
Expand Up @@ -136,20 +136,18 @@ private void buttonClick(ActionEvent event) {
return;
}

//int targetIndex = Integer.parseInt(input.nextLine());
int targetIndex = 0;
if (targetIndex < 0 || targetIndex >= cardActions.size()) {
return;
List<Card>targetCards = new ArrayList<>();
for(Targetable target : targets) {
if (target instanceof Card) {
targetCards.add((Card)target);
}
}

//TODO: add a check to make sure the target is valid//
Targetable target = targets.get(targetIndex);
targetAction.setTarget(target);
targetAction.perform();
this.controller.markTargets(targetCards);
this.controller.nextAction = targetAction;
}
else action.perform();
this.controller.createData();
}
this.controller.createData();
this.controller.render();
}
}
Expand Down
Expand Up @@ -151,10 +151,12 @@ private void buttonClick(ActionEvent event) {
Targetable target = targets.get(targetIndex);
targetAction.setTarget(target);
targetAction.perform();
} else {
action.perform();
this.controller.createData();
this.controller.render();
}
else action.perform();
}
this.controller.render();
}
}
}
Expand All @@ -178,6 +180,6 @@ private void createCardTargetButton() {
this.getChildren().add(button);
}
private void targetButtonClick(ActionEvent event) {

this.controller.performNextAction(this.card);
}
}
Expand Up @@ -90,19 +90,18 @@ private void buttonClick(ActionEvent event) {
for(Targetable target : targets) {
if (target instanceof Card) {
targetCards.add((Card)target);
} else {
//attacking the other player here
targetAction.setTarget(target);
targetAction.perform();
}
}
this.controller.markTargets(targetCards);

//int targetIndex = Integer.parseInt(input.nextLine());
//int targetIndex = 0;

//TODO: add a check to make sure the target is valid//
//Targetable target = targets.get(targetIndex);
//targetAction.setTarget(target);
//targetAction.perform();
this.controller.nextAction = targetAction;
} else {
this.action.perform();
this.controller.createData();
}
else this.action.perform();
}
this.controller.render();
}
Expand Down
Expand Up @@ -24,6 +24,8 @@
import com.cardshifter.core.Card;
import com.cardshifter.core.Game;
import com.cardshifter.core.Player;
import com.cardshifter.core.TargetAction;
import com.cardshifter.core.Targetable;
import com.cardshifter.core.UsableAction;
import com.cardshifter.core.Zone;
import com.cardshifter.core.console.CommandLineOptions;
Expand Down Expand Up @@ -293,6 +295,13 @@ public void buildChoiceBoxPane(Card card, List<UsableAction> actionList) {
}

//TARGETING
public TargetAction nextAction;
public void performNextAction(Targetable target) {
nextAction.setTarget(target);
nextAction.perform();
this.createData();
this.render();
}
public void markTargets(List<Card> targets) {
List<Node> cardsInPlayerBattlefield = playerBattlefieldPane.getChildren();
List<Node> cardsInOpponentBattlefield = opponentBattlefieldPane.getChildren();
Expand Down

0 comments on commit 4c3fd9b

Please sign in to comment.