revert commit
This commit is contained in:
@@ -29,7 +29,6 @@ public class CardLayerHandler {
|
||||
private DiceControl diceControl;
|
||||
|
||||
private final Map<BonusCard, CardControl> bonusCardControlMap = new HashMap<>();
|
||||
private final List<BonusCard> cardOrder = new ArrayList<>();
|
||||
private final Map<BonusCard, Integer> bonusCardIntegerMap = new HashMap<>();
|
||||
private final Set<CardControl> selectableCards = new HashSet<>();
|
||||
|
||||
@@ -81,13 +80,14 @@ public void addCard(BonusCard card) {
|
||||
if (card == BonusCard.HIDDEN) throw new RuntimeException("Can't add hidden card to GUI");
|
||||
|
||||
if (!bonusCardControlMap.containsKey(card)) {
|
||||
cardOrder.add(card);
|
||||
CardControl control = createCard(bonusToAsset(card), nextPos());
|
||||
bonusCardControlMap.put(card, control);
|
||||
cardLayer.addSpatial(control.getRoot());
|
||||
}
|
||||
|
||||
int newNum = bonusCardIntegerMap.getOrDefault(card, 0) + 1;
|
||||
bonusCardIntegerMap.put(card, newNum);
|
||||
|
||||
updateCard();
|
||||
bonusCardControlMap.get(card).setNumCard(newNum);
|
||||
}
|
||||
|
||||
public void removeCard(BonusCard card){
|
||||
@@ -95,11 +95,12 @@ public void removeCard(BonusCard card){
|
||||
bonusCardIntegerMap.put(card, bonusCardIntegerMap.get(card) - 1);
|
||||
|
||||
if(bonusCardIntegerMap.get(card) <= 0){
|
||||
cardLayer.deleteSpatial(bonusCardControlMap.get(card).getRoot());
|
||||
bonusCardIntegerMap.remove(card);
|
||||
cardOrder.remove(card);
|
||||
bonusCardControlMap.remove(card);
|
||||
}
|
||||
updateCard();
|
||||
} else throw new RuntimeException("card is not in bonusCardControlMap");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void clearSelectableCards() {
|
||||
@@ -113,22 +114,6 @@ public void clearSelectableCards() {
|
||||
cardSelect = null;
|
||||
}
|
||||
|
||||
private void updateCard(){
|
||||
for(BonusCard card : bonusCardControlMap.keySet()){
|
||||
CardControl control = bonusCardControlMap.get(card);
|
||||
cardLayer.deleteSpatial(control.getRoot());
|
||||
}
|
||||
bonusCardControlMap.clear();
|
||||
|
||||
for(int i = 0; i < cardOrder.size(); i++){
|
||||
BonusCard card = cardOrder.get(i);
|
||||
CardControl control = createCard(bonusToAsset(card), nextPos(i));
|
||||
control.setNumCard(bonusCardIntegerMap.get(card));
|
||||
cardLayer.addSpatial(control.getRoot());
|
||||
bonusCardControlMap.put(card, control);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectableCards(List<BonusCard> select) {
|
||||
for (BonusCard card : select) {
|
||||
selectableCards.add(bonusCardControlMap.get(card));
|
||||
@@ -186,8 +171,8 @@ private Asset bonusToAsset(BonusCard card) {
|
||||
};
|
||||
}
|
||||
|
||||
private Vector3f nextPos(int i) {
|
||||
return START.add(MARGIN.mult(i));
|
||||
private Vector3f nextPos() {
|
||||
return START.add(MARGIN.mult(bonusCardControlMap.size()));
|
||||
}
|
||||
|
||||
private Camera createOverlayCam() {
|
||||
|
||||
@@ -87,16 +87,16 @@ public Game() {
|
||||
gameStatistics = new Statistic();
|
||||
initializeDrawPile();
|
||||
board = new Board();
|
||||
die = new Die(2,4,5,5,1,3);
|
||||
die = new Die();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes the draw pile with the predefined number of bonus cards.
|
||||
*/
|
||||
private void initializeDrawPile() {
|
||||
this.addBonusCards(new ShieldCard(), AMOUNT_OF_SHIELD_CARDS);
|
||||
this.addBonusCards(new TurboCard(), AMOUNT_OF_TURBO_CARDS);
|
||||
this.addBonusCards(new SwapCard(), AMOUNT_OF_SWAP_CARDS);
|
||||
this.addBonusCards(new ShieldCard(), AMOUNT_OF_SHIELD_CARDS);
|
||||
Collections.shuffle(this.drawPile);
|
||||
}
|
||||
|
||||
@@ -210,6 +210,15 @@ public Player getPlayerByColor(Color color) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to the get the active player
|
||||
*
|
||||
* @return the active player
|
||||
*/
|
||||
public Player getActivePlayer(){
|
||||
return getPlayerByColor(activeColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be used to return all connected players as a list.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user