added Intro state and its logic
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.GameState;
|
import pp.mdga.client.GameState;
|
||||||
import pp.mdga.client.gamestate.determinestartplayerstate.DetermineStartPlayerStates;
|
import pp.mdga.client.gamestate.determinestartplayerstate.DetermineStartPlayerStates;
|
||||||
|
import pp.mdga.client.gamestate.determinestartplayerstate.Intro;
|
||||||
import pp.mdga.client.gamestate.determinestartplayerstate.RollRankingDiceState;
|
import pp.mdga.client.gamestate.determinestartplayerstate.RollRankingDiceState;
|
||||||
import pp.mdga.client.gamestate.determinestartplayerstate.WaitRankingState;
|
import pp.mdga.client.gamestate.determinestartplayerstate.WaitRankingState;
|
||||||
import pp.mdga.message.server.DieMessage;
|
import pp.mdga.message.server.DieMessage;
|
||||||
@@ -17,12 +18,33 @@ public class DetermineStartPlayerState extends GameStates {
|
|||||||
|
|
||||||
private final RollRankingDiceState rollRankingDiceState = new RollRankingDiceState(this, logic);
|
private final RollRankingDiceState rollRankingDiceState = new RollRankingDiceState(this, logic);
|
||||||
private final WaitRankingState waitRankingState = new WaitRankingState(this, logic);
|
private final WaitRankingState waitRankingState = new WaitRankingState(this, logic);
|
||||||
|
private final Intro intro = new Intro(this, logic);
|
||||||
|
|
||||||
public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) {
|
public DetermineStartPlayerState(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (GameState) parent;
|
this.parent = (GameState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RollRankingDiceState getRollRankingDice() {
|
||||||
|
return rollRankingDiceState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WaitRankingState getWaitRanking() {
|
||||||
|
return waitRankingState;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DetermineStartPlayerStates getState(){
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Intro getIntro(){
|
||||||
|
return intro;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameState getParent() {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enter() {
|
public void enter() {
|
||||||
this.setState(this.rollRankingDiceState);
|
this.setState(this.rollRankingDiceState);
|
||||||
@@ -60,20 +82,4 @@ public void received(RankingRollAgainMessage msg){
|
|||||||
public void received(RankingResponseMessage msg){
|
public void received(RankingResponseMessage msg){
|
||||||
state.received(msg);
|
state.received(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RollRankingDiceState getRollRankingDice() {
|
|
||||||
return rollRankingDiceState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WaitRankingState getWaitRanking() {
|
|
||||||
return waitRankingState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DetermineStartPlayerStates getState(){
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameState getParent() {
|
|
||||||
return parent;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,27 +3,78 @@
|
|||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.DetermineStartPlayerState;
|
import pp.mdga.client.gamestate.DetermineStartPlayerState;
|
||||||
|
import pp.mdga.game.Player;
|
||||||
|
import pp.mdga.message.client.AnimationEndMessage;
|
||||||
|
import pp.mdga.notification.AcquireCardNotification;
|
||||||
|
import pp.mdga.notification.DrawCardNotification;
|
||||||
|
import pp.mdga.notification.WaitMoveNotification;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class Intro extends DetermineStartPlayerStates{
|
public class Intro extends DetermineStartPlayerStates{
|
||||||
|
|
||||||
private final DetermineStartPlayerState parent;
|
private final DetermineStartPlayerState parent;
|
||||||
|
|
||||||
|
private int animationCounter = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for Intro
|
||||||
|
*
|
||||||
|
* @param parent the parent state
|
||||||
|
* @param logic the client game logic
|
||||||
|
*/
|
||||||
public Intro(ClientState parent, ClientGameLogic logic) {
|
public Intro(ClientState parent, ClientGameLogic logic) {
|
||||||
super(parent, logic);
|
super(parent, logic);
|
||||||
this.parent = (DetermineStartPlayerState) parent;
|
this.parent = (DetermineStartPlayerState) parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public void enter() {
|
* This method is used to get the parent state;
|
||||||
|
*
|
||||||
}
|
* @return the parent state
|
||||||
|
*/
|
||||||
@Override
|
|
||||||
public void exit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public DetermineStartPlayerState getParent(){
|
public DetermineStartPlayerState getParent(){
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used to enter this state and play all necessary intro animations.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void enter() {
|
||||||
|
for(Map.Entry<Integer, Player> entry : logic.getGame().getPlayers().entrySet()){
|
||||||
|
logic.addNotification(new WaitMoveNotification(entry.getValue().getPieces()[0].getUuid()));
|
||||||
|
animationCounter++;
|
||||||
|
if(entry.getKey() == logic.getOwnPlayerId()){
|
||||||
|
logic.addNotification(new AcquireCardNotification(entry.getValue().getHandCards().get(0)));
|
||||||
|
} else {
|
||||||
|
logic.addNotification(new DrawCardNotification(entry.getValue().getColor(), entry.getValue().getHandCards().get(0)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method i s used to exit this state.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void exit() {
|
||||||
|
animationCounter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used when the view has completed the animation.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void selectAnimationEnd(){
|
||||||
|
animationCounter--;
|
||||||
|
if(animationCounter != 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
logic.send(new AnimationEndMessage());
|
||||||
|
if (logic.getGame().getActivePlayerId() == logic.getOwnPlayerId()){
|
||||||
|
parent.getParent().setState(parent.getParent().getTurn());
|
||||||
|
} else {
|
||||||
|
parent.getParent().setState(parent.getParent().getWaiting());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import pp.mdga.client.ClientGameLogic;
|
import pp.mdga.client.ClientGameLogic;
|
||||||
import pp.mdga.client.ClientState;
|
import pp.mdga.client.ClientState;
|
||||||
import pp.mdga.client.gamestate.DetermineStartPlayerState;
|
import pp.mdga.client.gamestate.DetermineStartPlayerState;
|
||||||
|
import pp.mdga.message.server.ActivePlayerMessage;
|
||||||
import pp.mdga.message.server.RankingResponseMessage;
|
import pp.mdga.message.server.RankingResponseMessage;
|
||||||
import pp.mdga.message.server.RankingRollAgainMessage;
|
import pp.mdga.message.server.RankingRollAgainMessage;
|
||||||
import pp.mdga.notification.ActivePlayerNotification;
|
import pp.mdga.notification.ActivePlayerNotification;
|
||||||
@@ -33,8 +34,12 @@ public void received(RankingRollAgainMessage msg){
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void received(RankingResponseMessage msg){
|
public void received(RankingResponseMessage msg){
|
||||||
logic.addNotification(new ActivePlayerNotification(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor()));
|
}
|
||||||
logic.getGame().setActiveColor(logic.getGame().getPlayers().get(msg.getStartingPlayerId()).getColor());
|
|
||||||
parent.getParent().setState(parent.getParent().getWaiting());
|
@Override
|
||||||
|
public void received(ActivePlayerMessage msg){
|
||||||
|
logic.addNotification(new ActivePlayerNotification(msg.getColor()));
|
||||||
|
logic.getGame().setActiveColor(msg.getColor());
|
||||||
|
parent.setState(parent.getIntro());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user