Ändra från egotripp till egodipp

This commit is contained in:
Love 2022-12-10 00:02:23 +01:00
parent 3e5bd56780
commit 161e5700c3
30 changed files with 205 additions and 205 deletions

View File

@ -4,7 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.billenius</groupId>
<groupId>com.limone</groupId>
<artifactId>Schack</artifactId>
<version>1</version>
@ -39,7 +39,7 @@
<resource>
<directory>src/main/java/</directory>
<includes>
<include>com/billenius/img/</include>
<include>com/limone/img/</include>
</includes>
</resource>
</resources>
@ -97,7 +97,7 @@
<configuration>
<archive>
<manifest>
<mainClass>com.billenius.schack.Schack</mainClass>
<mainClass>com.limone.schack.Schack</mainClass>
</manifest>
</archive>
<descriptorRefs>
@ -114,7 +114,7 @@
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.billenius.schack.Schack</mainClass>
<mainClass>com.limone.schack.Schack</mainClass>
</manifest>
</archive>
</configuration>

View File

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 132 KiB

View File

@ -1,4 +1,4 @@
package com.billenius.schack;
package com.limone.schack;
import java.awt.Point;
import java.io.Serializable;

View File

@ -1,8 +1,8 @@
package com.billenius.schack;
package com.limone.schack;
import java.awt.Point;
import com.billenius.schack.pieces.Piece;
import com.limone.schack.pieces.Piece;
public class Move extends BasicMove {
public Piece movedPiece;

View File

@ -1,4 +1,4 @@
package com.billenius.schack;
package com.limone.schack;
import java.awt.Component;
import java.awt.image.BufferedImage;

View File

@ -1,167 +1,167 @@
package com.billenius.schack;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.Inet4Address;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.UIManager;
import com.billenius.schack.boards.Board;
import com.billenius.schack.boards.NetworkBoard;
import com.billenius.schack.boards.SameBoard;
import com.formdev.flatlaf.FlatLightLaf;
/**
*
* @author Love Billenius & Simon Hansson
*/
public class Schack {
final JFrame frame;
// Förlåt mig fader för jag kommer synda
public final static Map<String, BufferedImage> pieceIcons = new HashMap<>();
public Schack() throws IOException {
// Set theme
try {
if (UIManager.getSystemLookAndFeelClassName()
.equals("javax.swing.plaf.metal.MetalLookAndFeel"))
UIManager.setLookAndFeel(new FlatLightLaf());
else
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception cantGetSystemTheme) {
}
String[] options = { "On the same screen", "Over the internet" };
int choosenTransformations = JOptionPane.showOptionDialog(null,
"How do you want to connect with your opponent",
"Schack: Selection",
JOptionPane.DEFAULT_OPTION,
JOptionPane.INFORMATION_MESSAGE,
null,
options,
options[0]);
DefaultListModel<Move> listModel = new DefaultListModel<>();
final Board board;
if (choosenTransformations == 0)
board = new SameBoard(listModel);
else
board = new NetworkBoard(listModel);
frame = new JFrame();
frame.setTitle("Schack");
frame.setAlwaysOnTop(false);
frame.setResizable(true);
// Might throw an IOException if the icon of the Pieces isn't embedded correctly
// final Board board = new BlistModeloard(listModel);
// Logger
final JList<Move> jlist = new JList<>(listModel);
jlist.setVisible(true);
jlist.setCellRenderer(new PieceRenderer());
JScrollPane scrollPane = new JScrollPane(jlist);
// scrollPane.setPreferredSize(new Dimension(120, 700));
JPanel logPanel = new JPanel(new BorderLayout());
logPanel.setPreferredSize(new Dimension(120, 800));
JLabel infoText = new JLabel("Moves");
infoText.setFont(new Font("Cantarell", Font.PLAIN, 18));
infoText.setHorizontalAlignment(JLabel.CENTER);
logPanel.add(infoText, BorderLayout.NORTH);
logPanel.add(scrollPane, BorderLayout.CENTER);
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setDividerLocation(800);
splitPane.setLeftComponent(board);
splitPane.setRightComponent(logPanel);
frame.setContentPane(splitPane);
frame.getContentPane().addMouseListener(board);
// Create menu
final JMenuBar menuBar = new JMenuBar();
final JMenu gameMenu = new JMenu("Game");
final JMenu connectMenu = new JMenu("Connect");
final JMenuItem askForRemi = new JMenuItem("Ask for remi");
final JMenuItem surrender = new JMenuItem("Surrender");
final JMenuItem showIP = new JMenuItem("Show IP");
final JMenuItem connectToOpponent = new JMenuItem("Connect to opponent");
askForRemi.addActionListener((ActionEvent ae) -> {
String whosWantingRemi = board.isWhitesTurn() ? "Vit" : "Svart";
int choice = JOptionPane.showConfirmDialog(board, whosWantingRemi + " erbjuder remi\nAccepterar du?");
if (choice == JOptionPane.YES_OPTION) {
choice = JOptionPane.showConfirmDialog(board, "Lika\nStarta om?");
if (choice == JOptionPane.YES_OPTION) {
try {
board.restartGame();
} catch (IOException ex) {
}
}
}
});
surrender.addActionListener((ActionEvent ae) -> {
String whosGivingUp = board.isWhitesTurn() ? "Vit" : "Svart";
int choice = JOptionPane.showConfirmDialog(board, whosGivingUp + " har gett upp\nStarta om?");
if (choice == JOptionPane.YES_OPTION) {
try {
board.restartGame();
} catch (IOException ex) {
}
}
});
showIP.addActionListener((ActionEvent ae) -> {
try {
String ip = Inet4Address.getLocalHost().toString();
JOptionPane.showMessageDialog(null, "IP: " + ip);
} catch (HeadlessException | UnknownHostException e) {
}
});
connectToOpponent.addActionListener((ActionEvent ae) -> {
String opponentIP = JOptionPane.showInputDialog(null, "What's your opponents IP?");
System.out.println("opponents ip: " + opponentIP);
});
// Add the menu stuff
frame.setJMenuBar(menuBar);
menuBar.add(gameMenu);
menuBar.add(connectMenu);
gameMenu.add(askForRemi);
gameMenu.add(surrender);
connectMenu.add(showIP);
connectMenu.add(connectToOpponent);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public static void main(String[] args) throws IOException {
new Schack();
}
}
package com.limone.schack;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.Inet4Address;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.UIManager;
import com.formdev.flatlaf.FlatLightLaf;
import com.limone.schack.boards.Board;
import com.limone.schack.boards.NetworkBoard;
import com.limone.schack.boards.SameBoard;
/**
*
* @author Love Billenius & Simon Hansson
*/
public class Schack {
final JFrame frame;
// Förlåt mig fader för jag kommer synda
public final static Map<String, BufferedImage> pieceIcons = new HashMap<>();
public Schack() throws IOException {
// Set theme
try {
if (UIManager.getSystemLookAndFeelClassName()
.equals("javax.swing.plaf.metal.MetalLookAndFeel"))
UIManager.setLookAndFeel(new FlatLightLaf());
else
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception cantGetSystemTheme) {
}
String[] options = { "On the same screen", "Over the internet" };
int choosenTransformations = JOptionPane.showOptionDialog(null,
"How do you want to connect with your opponent",
"Schack: Selection",
JOptionPane.DEFAULT_OPTION,
JOptionPane.INFORMATION_MESSAGE,
null,
options,
options[0]);
DefaultListModel<Move> listModel = new DefaultListModel<>();
final Board board;
if (choosenTransformations == 0)
board = new SameBoard(listModel);
else
board = new NetworkBoard(listModel);
frame = new JFrame();
frame.setTitle("Schack");
frame.setAlwaysOnTop(false);
frame.setResizable(true);
// Might throw an IOException if the icon of the Pieces isn't embedded correctly
// final Board board = new BlistModeloard(listModel);
// Logger
final JList<Move> jlist = new JList<>(listModel);
jlist.setVisible(true);
jlist.setCellRenderer(new PieceRenderer());
JScrollPane scrollPane = new JScrollPane(jlist);
// scrollPane.setPreferredSize(new Dimension(120, 700));
JPanel logPanel = new JPanel(new BorderLayout());
logPanel.setPreferredSize(new Dimension(120, 800));
JLabel infoText = new JLabel("Moves");
infoText.setFont(new Font("Cantarell", Font.PLAIN, 18));
infoText.setHorizontalAlignment(JLabel.CENTER);
logPanel.add(infoText, BorderLayout.NORTH);
logPanel.add(scrollPane, BorderLayout.CENTER);
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
splitPane.setDividerLocation(800);
splitPane.setLeftComponent(board);
splitPane.setRightComponent(logPanel);
frame.setContentPane(splitPane);
frame.getContentPane().addMouseListener(board);
// Create menu
final JMenuBar menuBar = new JMenuBar();
final JMenu gameMenu = new JMenu("Game");
final JMenu connectMenu = new JMenu("Connect");
final JMenuItem askForRemi = new JMenuItem("Ask for remi");
final JMenuItem surrender = new JMenuItem("Surrender");
final JMenuItem showIP = new JMenuItem("Show IP");
final JMenuItem connectToOpponent = new JMenuItem("Connect to opponent");
askForRemi.addActionListener((ActionEvent ae) -> {
String whosWantingRemi = board.isWhitesTurn() ? "Vit" : "Svart";
int choice = JOptionPane.showConfirmDialog(board, whosWantingRemi + " erbjuder remi\nAccepterar du?");
if (choice == JOptionPane.YES_OPTION) {
choice = JOptionPane.showConfirmDialog(board, "Lika\nStarta om?");
if (choice == JOptionPane.YES_OPTION) {
try {
board.restartGame();
} catch (IOException ex) {
}
}
}
});
surrender.addActionListener((ActionEvent ae) -> {
String whosGivingUp = board.isWhitesTurn() ? "Vit" : "Svart";
int choice = JOptionPane.showConfirmDialog(board, whosGivingUp + " har gett upp\nStarta om?");
if (choice == JOptionPane.YES_OPTION) {
try {
board.restartGame();
} catch (IOException ex) {
}
}
});
showIP.addActionListener((ActionEvent ae) -> {
try {
String ip = Inet4Address.getLocalHost().toString();
JOptionPane.showMessageDialog(null, "IP: " + ip);
} catch (HeadlessException | UnknownHostException e) {
}
});
connectToOpponent.addActionListener((ActionEvent ae) -> {
String opponentIP = JOptionPane.showInputDialog(null, "What's your opponents IP?");
System.out.println("opponents ip: " + opponentIP);
});
// Add the menu stuff
frame.setJMenuBar(menuBar);
menuBar.add(gameMenu);
menuBar.add(connectMenu);
gameMenu.add(askForRemi);
gameMenu.add(surrender);
connectMenu.add(showIP);
connectMenu.add(connectToOpponent);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public static void main(String[] args) throws IOException {
new Schack();
}
}

View File

@ -1,4 +1,4 @@
package com.billenius.schack;
package com.limone.schack;
/**
*

View File

@ -1,4 +1,4 @@
package com.billenius.schack.boards;
package com.limone.schack.boards;
import java.awt.Color;
import java.awt.Dimension;
@ -14,15 +14,15 @@ import java.util.List;
import javax.swing.DefaultListModel;
import javax.swing.JPanel;
import com.billenius.schack.Move;
import com.billenius.schack.SchackState;
import com.billenius.schack.pieces.Bishop;
import com.billenius.schack.pieces.Horse;
import com.billenius.schack.pieces.King;
import com.billenius.schack.pieces.Pawn;
import com.billenius.schack.pieces.Piece;
import com.billenius.schack.pieces.Queen;
import com.billenius.schack.pieces.Rook;
import com.limone.schack.Move;
import com.limone.schack.SchackState;
import com.limone.schack.pieces.Bishop;
import com.limone.schack.pieces.Horse;
import com.limone.schack.pieces.King;
import com.limone.schack.pieces.Pawn;
import com.limone.schack.pieces.Piece;
import com.limone.schack.pieces.Queen;
import com.limone.schack.pieces.Rook;
public abstract class Board extends JPanel implements MouseListener {

View File

@ -1,4 +1,4 @@
package com.billenius.schack.boards;
package com.limone.schack.boards;
import java.awt.BorderLayout;
import java.awt.Dimension;
@ -18,10 +18,10 @@ import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import com.billenius.schack.BasicMove;
import com.billenius.schack.Move;
import com.billenius.schack.SchackState;
import com.billenius.schack.pieces.Piece;
import com.limone.schack.BasicMove;
import com.limone.schack.Move;
import com.limone.schack.SchackState;
import com.limone.schack.pieces.Piece;
public final class NetworkBoard extends Board implements Runnable {
public final static int PORT = 1339;

View File

@ -1,4 +1,4 @@
package com.billenius.schack.boards;
package com.limone.schack.boards;
import java.io.IOException;
import java.util.ArrayList;
@ -6,9 +6,9 @@ import java.util.ArrayList;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import com.billenius.schack.Move;
import com.billenius.schack.SchackState;
import com.billenius.schack.pieces.Piece;
import com.limone.schack.Move;
import com.limone.schack.SchackState;
import com.limone.schack.pieces.Piece;
public final class SameBoard extends Board {

View File

@ -1,4 +1,4 @@
package com.billenius.schack.pieces;
package com.limone.schack.pieces;
import java.awt.Point;
import java.io.IOException;

View File

@ -1,4 +1,4 @@
package com.billenius.schack.pieces;
package com.limone.schack.pieces;
import java.awt.Point;
import java.io.IOException;

View File

@ -1,4 +1,4 @@
package com.billenius.schack.pieces;
package com.limone.schack.pieces;
import java.awt.Point;
import java.io.IOException;

View File

@ -1,4 +1,4 @@
package com.billenius.schack.pieces;
package com.limone.schack.pieces;
import java.awt.Point;
import java.io.IOException;

View File

@ -1,4 +1,4 @@
package com.billenius.schack.pieces;
package com.limone.schack.pieces;
import java.awt.HeadlessException;
import java.awt.Point;

View File

@ -1,4 +1,4 @@
package com.billenius.schack.pieces;
package com.limone.schack.pieces;
import java.awt.Graphics2D;
import java.awt.Point;
@ -9,7 +9,7 @@ import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;
import com.billenius.schack.boards.Board;
import com.limone.schack.boards.Board;
public abstract class Piece {
@ -67,7 +67,7 @@ public abstract class Piece {
private BufferedImage getPieceIcon() throws IOException {
String colorName = isWhite() ? "White" : "Black";
String path = "/com/billenius/img/" + colorName + getClass().getSimpleName() + ".png";
String path = "/com/limone/img/" + colorName + getClass().getSimpleName() + ".png";
InputStream inputStream = getClass().getResourceAsStream(path);
return ImageIO.read(inputStream);
}

View File

@ -1,4 +1,4 @@
package com.billenius.schack.pieces;
package com.limone.schack.pieces;
import java.awt.Point;
import java.io.IOException;

View File

@ -1,4 +1,4 @@
package com.billenius.schack.pieces;
package com.limone.schack.pieces;
import java.awt.Point;
import java.io.IOException;