Add bonus node logic
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
package pp.mdga.server.automaton.game.turn.choosepiece;
|
package pp.mdga.server.automaton.game.turn.choosepiece;
|
||||||
|
|
||||||
import pp.mdga.game.Node;
|
import pp.mdga.game.*;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.card.HiddenCard;
|
||||||
import pp.mdga.game.PieceState;
|
|
||||||
import pp.mdga.game.ShieldState;
|
|
||||||
import pp.mdga.message.client.RequestMoveMessage;
|
import pp.mdga.message.client.RequestMoveMessage;
|
||||||
|
import pp.mdga.message.server.DrawCardMessage;
|
||||||
import pp.mdga.message.server.MoveMessage;
|
import pp.mdga.message.server.MoveMessage;
|
||||||
import pp.mdga.message.server.SelectPieceMessage;
|
import pp.mdga.message.server.SelectPieceMessage;
|
||||||
import pp.mdga.server.ServerGameLogic;
|
import pp.mdga.server.ServerGameLogic;
|
||||||
@@ -82,6 +81,17 @@ public void received(RequestMoveMessage msg, int from){
|
|||||||
movePiece.setShield(ShieldState.NONE);
|
movePiece.setShield(ShieldState.NONE);
|
||||||
} else {
|
} else {
|
||||||
Node targetNode = logic.getGame().getBoard().getInfield()[targIdx];
|
Node targetNode = logic.getGame().getBoard().getInfield()[targIdx];
|
||||||
|
|
||||||
|
if(targetNode.isBonus()) {
|
||||||
|
for (Player p : logic.getGame().getPlayersAsList()) {
|
||||||
|
if(p.isActive()) {
|
||||||
|
logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(logic.getGame().draw()));
|
||||||
|
} else {
|
||||||
|
logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(new HiddenCard()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Piece occ = targetNode.getOccupant();
|
Piece occ = targetNode.getOccupant();
|
||||||
if (occ != null) {
|
if (occ != null) {
|
||||||
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
|
logic.getGame().getPlayerByColor(occ.getColor()).addWaitingPiece(occ);
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
|
|
||||||
import pp.mdga.game.Node;
|
import pp.mdga.game.Node;
|
||||||
import pp.mdga.game.Piece;
|
import pp.mdga.game.Piece;
|
||||||
|
import pp.mdga.game.Player;
|
||||||
|
import pp.mdga.game.card.HiddenCard;
|
||||||
import pp.mdga.message.client.RequestMoveMessage;
|
import pp.mdga.message.client.RequestMoveMessage;
|
||||||
|
import pp.mdga.message.server.DrawCardMessage;
|
||||||
import pp.mdga.message.server.MoveMessage;
|
import pp.mdga.message.server.MoveMessage;
|
||||||
import pp.mdga.message.server.StartPieceMessage;
|
import pp.mdga.message.server.StartPieceMessage;
|
||||||
import pp.mdga.server.ServerGameLogic;
|
import pp.mdga.server.ServerGameLogic;
|
||||||
@@ -42,6 +45,17 @@ public void received(RequestMoveMessage msg, int from){
|
|||||||
if (piece.equals(msg.getPiece())) {
|
if (piece.equals(msg.getPiece())) {
|
||||||
int targetIndex = calculateTargetIndex(piece);
|
int targetIndex = calculateTargetIndex(piece);
|
||||||
Node targetNode = logic.getGame().getBoard().getInfield()[targetIndex];
|
Node targetNode = logic.getGame().getBoard().getInfield()[targetIndex];
|
||||||
|
|
||||||
|
if(targetNode.isBonus()) {
|
||||||
|
for (Player p : logic.getGame().getPlayersAsList()) {
|
||||||
|
if(p.isActive()) {
|
||||||
|
logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(logic.getGame().draw()));
|
||||||
|
} else {
|
||||||
|
logic.getServerSender().send(logic.getGame().getPlayerIdByColor(p.getColor()), new DrawCardMessage(new HiddenCard()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//send MoveMessage
|
//send MoveMessage
|
||||||
logic.getServerSender().broadcast(new MoveMessage(piece, false, targetIndex));
|
logic.getServerSender().broadcast(new MoveMessage(piece, false, targetIndex));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user