fixed crash get bonus
This commit is contained in:
@@ -294,17 +294,14 @@ public void received(ChoosePieceStateMessage msg){
|
||||
|
||||
@Override
|
||||
public void received(DrawCardMessage msg){
|
||||
if(msg.getCard() instanceof HiddenCard){
|
||||
logic.getGame().getActivePlayer().addHandCard(msg.getCard());
|
||||
if (msg.getCard() instanceof HiddenCard) {
|
||||
logic.addNotification(new DrawCardNotification(logic.getGame().getActiveColor(), BonusCard.HIDDEN));
|
||||
} else if(msg.getCard() instanceof TurboCard) {
|
||||
logic.addNotification(new AcquireCardNotification(BonusCard.TURBO));
|
||||
} else if(msg.getCard() instanceof ShieldCard) {
|
||||
logic.addNotification(new AcquireCardNotification(BonusCard.SHIELD));
|
||||
} else if(msg.getCard() instanceof SwapCard) {
|
||||
logic.addNotification(new AcquireCardNotification(BonusCard.SWAP));
|
||||
} else {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
else{
|
||||
logic.addNotification(new AcquireCardNotification(msg.getCard().getCard()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
import pp.mdga.client.ClientGameLogic;
|
||||
import pp.mdga.client.ClientState;
|
||||
import pp.mdga.client.GameState;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.PieceState;
|
||||
import pp.mdga.game.card.HiddenCard;
|
||||
import pp.mdga.message.server.*;
|
||||
import pp.mdga.notification.*;
|
||||
|
||||
@@ -33,7 +35,12 @@ public void received(CeremonyMessage msg) {
|
||||
|
||||
@Override
|
||||
public void received(DrawCardMessage msg){
|
||||
logic.addNotification(new DrawCardNotification(logic.getGame().getActiveColor(), msg.getCard().getCard()));
|
||||
logic.getGame().getActivePlayer().addHandCard(msg.getCard());
|
||||
if (msg.getCard() instanceof HiddenCard) {
|
||||
logic.addNotification(new DrawCardNotification(logic.getGame().getActiveColor(), BonusCard.HIDDEN));
|
||||
}
|
||||
|
||||
//stats
|
||||
logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPlayerStatistic().increaseActivatedBonusNodes();
|
||||
logic.getGame().getGameStatistics().increaseActivatedBonusNodes();
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public TurnState(ClientState parent, ClientGameLogic logic) {
|
||||
|
||||
@Override
|
||||
public void enter() {
|
||||
logic = logic;
|
||||
for (Piece piece : logic.getGame().getPlayerByColor(logic.getGame().getActiveColor()).getPieces()) {
|
||||
if (piece.isShielded() || piece.isSuppressed()){
|
||||
piece.setShield(ShieldState.NONE);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import pp.mdga.client.gamestate.turnstate.PowerCardState;
|
||||
import pp.mdga.game.BonusCard;
|
||||
import pp.mdga.game.Piece;
|
||||
import pp.mdga.game.Player;
|
||||
import pp.mdga.game.card.*;
|
||||
import pp.mdga.message.client.NoPowerCardMessage;
|
||||
import pp.mdga.message.client.SelectCardMessage;
|
||||
@@ -73,8 +74,14 @@ public void received(PossibleCardsMessage msg){
|
||||
*/
|
||||
@Override
|
||||
public void selectCard(BonusCard card){
|
||||
Player player = logic.getGame().getPlayers().get(logic.getOwnPlayerId());
|
||||
ArrayList<PowerCard> handCards = player.getHandCards();
|
||||
if(card != null){
|
||||
logic.send(new SelectCardMessage(logic.getGame().getPlayers().get(logic.getOwnPlayerId()).getPowerCardByType(card)));
|
||||
PowerCard select = player.getPowerCardByType(card);
|
||||
if(select == null){
|
||||
select = select;
|
||||
}
|
||||
logic.send(new SelectCardMessage(select));
|
||||
} else {
|
||||
logic.send(new NoPowerCardMessage());
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public Game() {
|
||||
gameStatistics = new Statistic();
|
||||
initializeDrawPile();
|
||||
board = new Board();
|
||||
die = new Die(1,2,3,4,5);
|
||||
die = new Die(1,4);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,9 +43,6 @@ public Piece getOccupant() {
|
||||
* @param occupant the new occupant of the node
|
||||
*/
|
||||
public void setOccupant(Piece occupant) {
|
||||
if (occupant.isSuppressed()) {
|
||||
occupant.setShield(ShieldState.NONE);
|
||||
}
|
||||
this.occupant = occupant;
|
||||
}
|
||||
|
||||
|
||||
@@ -152,6 +152,7 @@ public PowerCard getPowerCardByType(BonusCard bonusCard) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
// throw new RuntimeException("bonusCard is not in handCards");
|
||||
}
|
||||
|
||||
public Piece getWaitingPiece(){
|
||||
|
||||
@@ -61,6 +61,30 @@ public void initializeGame() {
|
||||
player.addHandCard(new ShieldCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
player.addHandCard(new TurboCard());
|
||||
|
||||
player.addHandCard(new SwapCard());
|
||||
player.addHandCard(new SwapCard());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user