Skip to content
Snippets Groups Projects
Commit 3f9f5e9f authored by Magnus Strømseng's avatar Magnus Strømseng
Browse files

move loadout class, make square use position

parent 82d11f49
No related branches found
No related tags found
No related merge requests found
Pipeline #275486 passed
package com.mygdx.game.model; package com.mygdx.game.model;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Sound;
import com.mygdx.game.controller.SoundManager; import com.mygdx.game.controller.SoundManager;
import com.mygdx.game.model.board.Board; import com.mygdx.game.model.board.Board;
import com.mygdx.game.model.board.Loadout; import com.mygdx.game.model.player.Loadout;
import com.mygdx.game.model.board.Move; import com.mygdx.game.model.board.Move;
import com.mygdx.game.model.board.Square; import com.mygdx.game.model.board.Square;
import com.mygdx.game.model.pieces.King; import com.mygdx.game.model.pieces.King;
...@@ -12,7 +10,6 @@ import com.mygdx.game.model.player.Player; ...@@ -12,7 +10,6 @@ import com.mygdx.game.model.player.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
......
...@@ -18,8 +18,8 @@ public class Position { ...@@ -18,8 +18,8 @@ public class Position {
return y; return y;
} }
public boolean equals(Position position) { public boolean equals(Position that) {
return this.x == position.x && this.y == position.y; return this.x == that.x && this.y == that.y;
} }
@Override @Override
......
...@@ -3,6 +3,7 @@ package com.mygdx.game.model.board; ...@@ -3,6 +3,7 @@ package com.mygdx.game.model.board;
import com.mygdx.game.model.Game; import com.mygdx.game.model.Game;
import com.mygdx.game.model.Piece; import com.mygdx.game.model.Piece;
import com.mygdx.game.model.Position; import com.mygdx.game.model.Position;
import com.mygdx.game.model.player.Loadout;
public class Board { public class Board {
private int width; private int width;
......
...@@ -6,28 +6,24 @@ import com.mygdx.game.model.Position; ...@@ -6,28 +6,24 @@ import com.mygdx.game.model.Position;
import com.sun.org.apache.xpath.internal.operations.Bool; import com.sun.org.apache.xpath.internal.operations.Bool;
public class Square { public class Square {
private int x; private Position position;
private int y;
private Piece piece; private Piece piece;
private boolean isOccupied; private boolean isOccupied;
private Boolean isHighlighted = false; private Boolean isHighlighted = false;
public Square(int x, int y) { public Square(int x, int y) {
this.x = x;
this.y = y;
this.piece = null; this.piece = null;
this.position = new Position(x, y);
} }
public Square(Position position) { public Square(Position position) {
this.x = position.getX();
this.y = position.getY();
this.piece = null; this.piece = null;
this.position = position;
} }
public Square(Square that) { public Square(Square that) {
this.x = that.x; this.position = new Position(that.getPosition().getX(), that.getPosition().getY());
this.y = that.y;
if (that.piece == null) { if (that.piece == null) {
this.piece = null; this.piece = null;
} else { } else {
...@@ -69,15 +65,15 @@ public class Square { ...@@ -69,15 +65,15 @@ public class Square {
} }
public int getX() { public int getX() {
return x; return position.getX();
} }
public int getY() { public int getY() {
return y; return position.getY();
} }
public Position getPosition() { public Position getPosition() {
return new Position(x, y); return position;
} }
public void setIsHighlighted(Boolean isHighlighted) { public void setIsHighlighted(Boolean isHighlighted) {
...@@ -94,8 +90,8 @@ public class Square { ...@@ -94,8 +90,8 @@ public class Square {
@Override @Override
public String toString() { public String toString() {
return "Square{" + return "Square{" +
"x=" + x + "x=" + position.getX() +
", y=" + y + ", y=" + position.getY() +
", piece=" + getPieceNameIfNotNull() + ", piece=" + getPieceNameIfNotNull() +
", isOccupied=" + isOccupied + ", isOccupied=" + isOccupied +
", canMoveTo=" + isHighlighted + ", canMoveTo=" + isHighlighted +
...@@ -103,6 +99,6 @@ public class Square { ...@@ -103,6 +99,6 @@ public class Square {
} }
public Boolean equals(Square that) { public Boolean equals(Square that) {
return this.x == that.x && this.y == that.y; return this.position.equals(that.position);
} }
} }
package com.mygdx.game.model.board; package com.mygdx.game.model.player;
import com.badlogic.gdx.Files; import com.badlogic.gdx.Files;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
...@@ -8,6 +8,7 @@ import com.badlogic.gdx.utils.JsonReader; ...@@ -8,6 +8,7 @@ import com.badlogic.gdx.utils.JsonReader;
import com.badlogic.gdx.utils.JsonValue; import com.badlogic.gdx.utils.JsonValue;
import com.mygdx.game.model.ChessPieceFactory; import com.mygdx.game.model.ChessPieceFactory;
import com.mygdx.game.model.Piece; import com.mygdx.game.model.Piece;
import com.mygdx.game.model.board.Board;
import org.json.JSONObject; import org.json.JSONObject;
......
package com.mygdx.game.model.player; package com.mygdx.game.model.player;
import com.mygdx.game.model.Piece; import com.mygdx.game.model.Piece;
import com.mygdx.game.model.board.Loadout;
import com.mygdx.game.model.board.Move;
public class Player { public class Player {
private String name; private String name;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment