mirror of
https://github.com/lov3b/Schack.git
synced 2025-01-18 04:40:11 +01:00
Ta bort onödig klass
This commit is contained in:
parent
0d80b0e37c
commit
06f6b4510c
@ -4,14 +4,11 @@ import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.HeadlessException;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
@ -158,6 +155,10 @@ public class Board extends JPanel implements MouseListener {
|
||||
getParent().repaint();
|
||||
}
|
||||
|
||||
/**
|
||||
* Få status över brädet
|
||||
* @return SCHACK, SCHACKMATT, PATT, NORMAL
|
||||
*/
|
||||
private SchackState getSchackState() {
|
||||
final ArrayList<Point> allValidMoves = getMoves(whitesTurn);
|
||||
final ArrayList<Point> opposingAttacks = getAttacks(!whitesTurn);
|
||||
|
@ -4,7 +4,7 @@ import java.awt.Point;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public final class King extends PieceKnownIfMoved {
|
||||
public final class King extends Piece {
|
||||
|
||||
public King(boolean isWhite, Point startingPosition) throws IOException {
|
||||
super(isWhite, startingPosition);
|
||||
|
@ -4,7 +4,7 @@ import java.awt.Point;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class LongWalkers extends PieceKnownIfMoved {
|
||||
public abstract class LongWalkers extends Piece {
|
||||
|
||||
public LongWalkers(boolean isWhite, Point startingPosition) throws IOException {
|
||||
super(isWhite, startingPosition);
|
||||
|
@ -4,7 +4,7 @@ import java.awt.Point;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Pawn extends PieceKnownIfMoved {
|
||||
public class Pawn extends Piece {
|
||||
|
||||
public Pawn(boolean isWhite, Point startingPosition) throws IOException {
|
||||
super(isWhite, startingPosition);
|
||||
|
@ -28,6 +28,11 @@ public abstract class Piece {
|
||||
*/
|
||||
protected BufferedImage icon;
|
||||
|
||||
/**
|
||||
* Nödvändigt för rockad
|
||||
*/
|
||||
protected boolean moved = false;
|
||||
|
||||
public Piece(boolean white, Point startingPosition) throws IOException {
|
||||
this.isWhite = white;
|
||||
this.position = startingPosition;
|
||||
@ -102,6 +107,7 @@ public abstract class Piece {
|
||||
pieces[toMove.x][toMove.y] = this;
|
||||
pieces[position.x][position.y] = null;
|
||||
this.position = new Point(toMove);
|
||||
this.moved = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -221,7 +227,7 @@ public abstract class Piece {
|
||||
* @return false
|
||||
*/
|
||||
public boolean isMoved() {
|
||||
return false;
|
||||
return moved;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,25 +0,0 @@
|
||||
package schack;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.io.IOException;
|
||||
|
||||
public abstract class PieceKnownIfMoved extends Piece {
|
||||
|
||||
protected boolean moved = false;
|
||||
|
||||
public PieceKnownIfMoved(boolean isWhite, Point startingPosition) throws IOException {
|
||||
super(isWhite, startingPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void move(Piece[][] pieces, Point toMove) {
|
||||
super.move(pieces, toMove);
|
||||
moved = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMoved() {
|
||||
return moved;
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +1,9 @@
|
||||
package schack;
|
||||
|
||||
import com.formdev.flatlaf.FlatLightLaf;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
|
Loading…
x
Reference in New Issue
Block a user