Newer
Older
hanabi-networking / src / server / Move.java
package server;

public class Move {
	public static final byte[] MAGIC = { 1, 3, 3, 7 };

	public static final byte DRY = 1 << 5;
	public static final byte PLACE_CARD = 3;
	public static final byte TRASH_CARD = 4;
	public static final byte HINT = 5;

	public static final byte HINT_COLOR = 0;
	public static final byte HINT_VALUE = 1;

	private int moveType;
	
	private int hintType;
	private int hintRecipient;
	private int value;
	private int color;

	public Move(byte mT) {
		setMoveType(mT);
	}

	public int getMoveType() { return moveType; }

	public int getHintType() {
		if(moveType != HINT) {
			throw new RuntimeException("Internal Error: Hint type of non-hint move requested.");
		}
		return hintType;
	}
	public int getValue() {
		if(moveType == HINT && hintType == HINT_COLOR) {
			throw new RuntimeException("Internal Error: Value of color hint requested.");
		}
		return value;
	}

	public int getColor() {
		if(moveType == HINT && hintType == HINT_VALUE) {
			throw new RuntimeException("Internal Error: Color of value hint requested.");
		}
		return color;
	}

	public int getHintRecipient() {
		if(moveType != HINT) {
			throw new RuntimeException("Internal Error: Target player ID of non-hint move requested.");
		}
		return hintRecipient;
	}

	public void setMoveType(byte moveType) {
		this.moveType = moveType;
	}

	public void setHintType(int type) {
		if(moveType != HINT) throw new InternalHanabiError("Attempt to set hint type of non-hint.");
		hintType = type;
	}

	public void setColor(int color) {
		this.color = color;
	}

	public void setValue(int value) {
		this.value = value;
	}
}