- Group avatar;
- Text stoneCounter;
- Sprite castle;
- Text stone;
-
-
- private int castlePosition;
- public int getCastlePosition() {
- return castlePosition;
- }
- public void setCastlePosition(int pos) {
- castlePosition = pos;
- }
-
- private int stones;
- public int getStones()
- {
- return stones;
- }
- public void consumeStones(int n) throws InvalidAction {
- if (n > stones) {
- throw new InvalidAction("attempted to throw more stones than they had.");
- }
- setStones(stones - n);
- }
- public void setStones(int n) {
- stones = n;
- if (stones <= 0) {
- stoneCounter.setText("No stones!");
- stoneCounter.setFillColor(0xff7777);
- }
- else if (stones == 1) {
- stoneCounter.setText("1 stone");
- stoneCounter.setFillColor(0xffbb77);
- }
- else {
- stoneCounter.setText(stones + " stones");
- }
- }