merge dev into test #33
@@ -143,8 +143,6 @@ private void initializeSerializables() {
|
|||||||
Serializer.registerClass(StartNode.class);
|
Serializer.registerClass(StartNode.class);
|
||||||
Serializer.registerClass(PlayerData.class);
|
Serializer.registerClass(PlayerData.class);
|
||||||
Serializer.registerClass(HomeNode.class);
|
Serializer.registerClass(HomeNode.class);
|
||||||
Serializer.registerClass(PieceState.class, new EnumSerializer());
|
|
||||||
Serializer.registerClass(ShieldState.class, new EnumSerializer());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerListeners() {
|
private void registerListeners() {
|
||||||
|
|||||||
@@ -12,17 +12,17 @@ public class Piece {
|
|||||||
/**
|
/**
|
||||||
* The shield state of the piece.
|
* The shield state of the piece.
|
||||||
*/
|
*/
|
||||||
private ShieldState shield;
|
private int shield;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current state of the piece.
|
* The current state of the piece.
|
||||||
*/
|
*/
|
||||||
private PieceState state;
|
private int state;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The color of the piece.
|
* The color of the piece.
|
||||||
*/
|
*/
|
||||||
private final Color color;
|
private final int color;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The unique identifier of the piece.
|
* The unique identifier of the piece.
|
||||||
@@ -36,15 +36,15 @@ public class Piece {
|
|||||||
* @param state the state of the piece
|
* @param state the state of the piece
|
||||||
*/
|
*/
|
||||||
public Piece(Color color, PieceState state, int id) {
|
public Piece(Color color, PieceState state, int id) {
|
||||||
this.color = color;
|
this.color = color.ordinal();
|
||||||
this.state = state;
|
this.state = state.ordinal();
|
||||||
shield = ShieldState.NONE;
|
shield = ShieldState.NONE.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Piece() {
|
private Piece() {
|
||||||
color = null;
|
color = Color.NONE.ordinal();
|
||||||
state = PieceState.WAITING;
|
state = PieceState.WAITING.ordinal();
|
||||||
shield = ShieldState.NONE;
|
shield = ShieldState.NONE.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,7 +53,7 @@ private Piece() {
|
|||||||
* @return the color of the piece
|
* @return the color of the piece
|
||||||
*/
|
*/
|
||||||
public void setShield(ShieldState shield) {
|
public void setShield(ShieldState shield) {
|
||||||
this.shield = shield;
|
this.shield = shield.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,7 +62,7 @@ public void setShield(ShieldState shield) {
|
|||||||
* @return the color of the piece
|
* @return the color of the piece
|
||||||
*/
|
*/
|
||||||
public ShieldState getShield() {
|
public ShieldState getShield() {
|
||||||
return shield;
|
return ShieldState.values()[shield];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,7 +71,7 @@ public ShieldState getShield() {
|
|||||||
* @param state the state of the piece
|
* @param state the state of the piece
|
||||||
*/
|
*/
|
||||||
public void setState(PieceState state) {
|
public void setState(PieceState state) {
|
||||||
this.state = state;
|
this.state = state.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,7 +80,7 @@ public void setState(PieceState state) {
|
|||||||
* @return the color of the piece
|
* @return the color of the piece
|
||||||
*/
|
*/
|
||||||
public PieceState getState() {
|
public PieceState getState() {
|
||||||
return state;
|
return PieceState.values()[state];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,7 +89,7 @@ public PieceState getState() {
|
|||||||
* @return the color of the piece
|
* @return the color of the piece
|
||||||
*/
|
*/
|
||||||
public boolean isShielded() {
|
public boolean isShielded() {
|
||||||
return shield == ShieldState.ACTIVE;
|
return shield == ShieldState.ACTIVE.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,7 +98,7 @@ public boolean isShielded() {
|
|||||||
* @return the color of the piece
|
* @return the color of the piece
|
||||||
*/
|
*/
|
||||||
public boolean isSuppressed() {
|
public boolean isSuppressed() {
|
||||||
return shield == ShieldState.SUPPRESSED;
|
return shield == ShieldState.SUPPRESSED.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,7 +107,7 @@ public boolean isSuppressed() {
|
|||||||
* @return the color of the piece
|
* @return the color of the piece
|
||||||
*/
|
*/
|
||||||
public Color getColor() {
|
public Color getColor() {
|
||||||
return color;
|
return Color.values()[color];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package pp.mdga.game;
|
package pp.mdga.game;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the state of a piece.
|
* Represents the state of a piece.
|
||||||
*/
|
*/
|
||||||
@@ -21,6 +23,10 @@ public enum PieceState {
|
|||||||
*/
|
*/
|
||||||
HOMEFINISHED;
|
HOMEFINISHED;
|
||||||
|
|
||||||
|
PieceState(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static PieceState getPieceStateByIndex(int index){
|
public static PieceState getPieceStateByIndex(int index){
|
||||||
if (index < 0 || index >= values().length) {
|
if (index < 0 || index >= values().length) {
|
||||||
throw new IllegalArgumentException("");
|
throw new IllegalArgumentException("");
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package pp.mdga.game;
|
package pp.mdga.game;
|
||||||
|
|
||||||
|
import com.jme3.network.serializing.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the state of a piece's shield.
|
* Represents the state of a piece's shield.
|
||||||
*/
|
*/
|
||||||
|
@Serializable
|
||||||
public enum ShieldState {
|
public enum ShieldState {
|
||||||
/**
|
/**
|
||||||
* The shield is not active.
|
* The shield is not active.
|
||||||
@@ -17,6 +20,10 @@ public enum ShieldState {
|
|||||||
*/
|
*/
|
||||||
SUPPRESSED;
|
SUPPRESSED;
|
||||||
|
|
||||||
|
ShieldState(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static ShieldState getShieldStateByIndex(int index){
|
public static ShieldState getShieldStateByIndex(int index){
|
||||||
if (index < 0 || index >= values().length) {
|
if (index < 0 || index >= values().length) {
|
||||||
throw new IllegalArgumentException("");
|
throw new IllegalArgumentException("");
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public class StartNode extends Node {
|
|||||||
/**
|
/**
|
||||||
* The color of the node.
|
* The color of the node.
|
||||||
*/
|
*/
|
||||||
private Color color;
|
private int color;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new start node with the given color.
|
* Creates a new start node with the given color.
|
||||||
@@ -18,11 +18,11 @@ public class StartNode extends Node {
|
|||||||
* @param color the color of the node
|
* @param color the color of the node
|
||||||
*/
|
*/
|
||||||
public StartNode(Color color) {
|
public StartNode(Color color) {
|
||||||
this.color = color;
|
this.color = color.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
private StartNode() {
|
private StartNode() {
|
||||||
color = null;
|
color = Color.NONE.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,7 +31,7 @@ private StartNode() {
|
|||||||
* @return the color of the node
|
* @return the color of the node
|
||||||
*/
|
*/
|
||||||
public Color getColor() {
|
public Color getColor() {
|
||||||
return color;
|
return Color.values()[color];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,6 +40,6 @@ public Color getColor() {
|
|||||||
* @param color the new color of the node
|
* @param color the new color of the node
|
||||||
*/
|
*/
|
||||||
public void setColor(Color color) {
|
public void setColor(Color color) {
|
||||||
this.color = color;
|
this.color = color.ordinal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user