modified 'ChoosePowerCardState' to work with PowerCards as well as adjusted 'SelectcardMessage' to use 'PowerCards'
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
|
import pp.mdga.client.gamestate.turnstate.PowerCardState;
|
||||||
import pp.mdga.game.BonusCard;
|
import pp.mdga.game.BonusCard;
|
||||||
|
import pp.mdga.game.card.*;
|
||||||
import pp.mdga.message.client.NoPowerCardMessage;
|
import pp.mdga.message.client.NoPowerCardMessage;
|
||||||
import pp.mdga.message.client.SelectCardMessage;
|
import pp.mdga.message.client.SelectCardMessage;
|
||||||
import pp.mdga.message.server.DiceNowMessage;
|
import pp.mdga.message.server.DiceNowMessage;
|
||||||
@@ -11,6 +12,7 @@
|
|||||||
import pp.mdga.message.server.PossibleCardMessage;
|
import pp.mdga.message.server.PossibleCardMessage;
|
||||||
import pp.mdga.message.server.PossiblePieceMessage;
|
import pp.mdga.message.server.PossiblePieceMessage;
|
||||||
import pp.mdga.notification.SelectableCardsNotification;
|
import pp.mdga.notification.SelectableCardsNotification;
|
||||||
|
import pp.mdga.visitor.Visitor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -21,7 +23,7 @@
|
|||||||
public class ChoosePowerCardState extends PowerCardStates {
|
public class ChoosePowerCardState extends PowerCardStates {
|
||||||
|
|
||||||
private final PowerCardState parent;
|
private final PowerCardState parent;
|
||||||
private ArrayList<BonusCard> possibleCards;
|
private ArrayList<PowerCard> possibleCards;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -39,7 +41,6 @@ public ChoosePowerCardState(ClientState parent, ClientGameLogic logic) {
|
|||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
possibleCards = new ArrayList<>();
|
possibleCards = new ArrayList<>();
|
||||||
System.out.println("ChoosePowerCardState");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,8 +57,14 @@ public void exit() {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(PossibleCardMessage msg){
|
public void received(PossibleCardMessage msg){
|
||||||
possibleCards = (ArrayList<BonusCard>) msg.getPossibleCards();
|
possibleCards = (ArrayList<PowerCard>)msg.getPossibleCards();
|
||||||
logic.addNotification(new SelectableCardsNotification(possibleCards));
|
ArrayList<BonusCard> possibleBonusCards = new ArrayList<>();
|
||||||
|
for (PowerCard card : possibleCards) {
|
||||||
|
if (!possibleBonusCards.contains(card.getCard())) {
|
||||||
|
possibleBonusCards.add(card.getCard());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logic.addNotification(new SelectableCardsNotification(possibleBonusCards));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,7 +74,7 @@ public void received(PossibleCardMessage msg){
|
|||||||
@Override
|
@Override
|
||||||
public void selectCard(BonusCard card){
|
public void selectCard(BonusCard card){
|
||||||
if(card != null){
|
if(card != null){
|
||||||
logic.send(new SelectCardMessage(card));
|
logic.send(new SelectCardMessage(logic.getGame().getPlayers().get(logic.getOwnPlayerId()).getPowerCardByType(card)));
|
||||||
} else {
|
} else {
|
||||||
logic.send(new NoPowerCardMessage());
|
logic.send(new NoPowerCardMessage());
|
||||||
}
|
}
|
||||||
@@ -79,11 +86,6 @@ public void selectCard(BonusCard card){
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void received(PlayCardMessage msg){
|
public void received(PlayCardMessage msg){
|
||||||
if(msg.getCard().equals(BonusCard.TURBO)){
|
|
||||||
logic.getGame().setDiceModifier(msg.getDiceModifier());
|
|
||||||
} else {
|
|
||||||
LOGGER.log(System.Logger.Level.ERROR, "Received card that is not turbo");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import com.jme3.network.serializing.Serializable;
|
import com.jme3.network.serializing.Serializable;
|
||||||
import pp.mdga.game.BonusCard;
|
import pp.mdga.game.BonusCard;
|
||||||
|
import pp.mdga.game.card.PowerCard;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A message sent from the client to the server to select a bonus card.
|
* A message sent from the client to the server to select a bonus card.
|
||||||
@@ -11,14 +12,14 @@ public class SelectCardMessage extends ClientMessage {
|
|||||||
/**
|
/**
|
||||||
* The bonus card to be selected.
|
* The bonus card to be selected.
|
||||||
*/
|
*/
|
||||||
private final BonusCard card;
|
private final PowerCard card;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new SelectCard instance.
|
* Constructs a new SelectCard instance.
|
||||||
*
|
*
|
||||||
* @param card the bonus card to be selected
|
* @param card the power card to be selected
|
||||||
*/
|
*/
|
||||||
public SelectCardMessage(BonusCard card) {
|
public SelectCardMessage(PowerCard card) {
|
||||||
this.card = card;
|
this.card = card;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,11 +31,11 @@ private SelectCardMessage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the bonus card associated with this selection.
|
* Gets the power card associated with this selection.
|
||||||
*
|
*
|
||||||
* @return the bonus card
|
* @return the power card
|
||||||
*/
|
*/
|
||||||
public BonusCard getCard() {
|
public PowerCard getCard() {
|
||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user