Skip to content

Commit

Permalink
yellow border for active cards
Browse files Browse the repository at this point in the history
  • Loading branch information
bazola committed Sep 3, 2014
1 parent e40ed28 commit 4a6f475
Showing 1 changed file with 32 additions and 2 deletions.
Expand Up @@ -3,6 +3,7 @@
import com.cardshifter.core.CommandLineOptions;
import com.cardshifter.core.Game;
import com.cardshifter.core.Card;
import com.cardshifter.core.CardAction;
import com.cardshifter.core.LuaTools;
import com.cardshifter.core.Player;
import com.cardshifter.core.TargetAction;
Expand All @@ -25,11 +26,11 @@
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Group;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;

import javafx.scene.text.Text;
import javafx.scene.shape.QuadCurve;
import javafx.scene.shape.Rectangle;

Expand Down Expand Up @@ -109,22 +110,51 @@ private int getOpponentCardCount() {
return cardsInHand.size();
}

/*BIG TO DO: Make all dimensions relative to the Pane size or Screen size*/
@FXML
private Pane player01Pane;
private void renderPlayerHand() {
//First get the list of Card objects
List<Card> cardsInHand = this.getCurrentPlayerHand();

List<Card> cardsWithActions = new ArrayList<>();
List<UsableAction> actions = game.getAllActions().stream().filter(action ->
action.isAllowed()).collect(Collectors.toList());
for (UsableAction action : actions) {
if (action instanceof CardAction) {
Card card = ((CardAction)action).getCard();
cardsWithActions.add(card);
}
}

//Create a group for each card for positioning
//Another group is needed for each element in the LuaTable
int cardIndex = 0;
for (Card card : cardsInHand) {
System.out.println("found a card");

//check if the card is active
boolean isCardActive = false;
for (Card cardWithAction : cardsWithActions) {
if (card == cardWithAction) {
isCardActive = true;
//do a test to see if another break is needed
break;
}
}

Group cardGroup = new Group();
cardGroup.setId(String.format("player01card%d", cardIndex));
cardGroup.setTranslateX(cardIndex * 165);
player01Pane.getChildren().add(cardGroup);

Rectangle activeBackground = new Rectangle(-10,-10,170,240);
activeBackground.setFill(Color.BLACK);
if(isCardActive == true) {
activeBackground.setFill(Color.YELLOW);
}
cardGroup.getChildren().add(activeBackground);

Rectangle cardBack = new Rectangle(0,0,150,220);
cardBack.setFill(Color.FIREBRICK);
cardGroup.getChildren().add(cardBack);
Expand All @@ -149,7 +179,7 @@ private void renderPlayerHand() {
cardTextStrings.getChildren().add(cardStringLabel);
stringIndex++;
}

cardIndex++;
}
}
Expand Down

0 comments on commit 4a6f475

Please sign in to comment.