Skip to content

Commit

Permalink
Fixed some more issues
Browse files Browse the repository at this point in the history
  • Loading branch information
botondborocz committed May 22, 2024
1 parent c8cc681 commit 4f4f299
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/main/java/GraphicsDesigner.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import model.Game;

import javax.swing.*;
import javax.swing.plaf.FontUIResource;
import javax.swing.text.StyleContext;
Expand All @@ -7,7 +9,7 @@
import java.util.Locale;

public class GraphicsDesigner extends JFrame implements ActionListener {
//private Game game;
private Game game = new Game();
private CardLayout cardLayout;
private JPanel cardPanel;
private JButton bPlay;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
public class Main {
public static void main(String[] args) {
defaultMap(); // load initial map
//Test18();
Graphics graphics = new Graphics();
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/display/DisplayPipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class DisplayPipe extends DisplayField {
/**
* A kirajzolt cső szélessége.
*/
final float displayWidth = 10;
static final float DISPLAYWIDTH = 10;

/**
* Kiszámolja a kirajzolt sokszög helyét. A cső két vége a következő helyeken lesz, a következő kritériumok alapján:
Expand Down Expand Up @@ -92,7 +92,7 @@ private void calculatePolygon () {
// lineTo -> lineFrom
Vec2 directionVector = Vec2.normalize(Vec2.subtract(lineFrom, lineTo));
Vec2 normal = new Vec2(directionVector.getY() * -1, directionVector.getX()); // perpendicular to directionVector (still unit vector)
normal = Vec2.multiply(normal, displayWidth / 2);
normal = Vec2.multiply(normal, DISPLAYWIDTH / 2);

Vec2 topLeft = Vec2.add(lineTo, normal);
Vec2 bottomLeft = Vec2.subtract(lineTo, normal);
Expand Down Expand Up @@ -206,7 +206,7 @@ protected void setPlayerIcons() {

if(p.getPlayers().isEmpty()) return;
Point c = getCenter();
int dim = (int)displayWidth * 3;
int dim = (int)DISPLAYWIDTH * 3;
Rectangle r = new Rectangle(c.x - dim / 2, c.y - dim / 2, dim, dim);
playerIcons.add(new PlayerIcon(r, p.getPlayers().get(0)));
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/model/Cistern.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

import java.security.SecureRandom;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* Felelossege, hogy eltarolja folyt-e bele viz a korben (mert ha igen, akkor pontot kapnak a szerelok). Emellett
* tarolja, hogy van-e rajta meg fel nem vett pumpa, melyet a szerelok felvehetnek
*/
public class Cistern extends Field implements Periodic {
private static final Logger logger = Logger.getLogger("logger");
private final SecureRandom random = new SecureRandom();
/**
* A bemeneti csove
Expand Down Expand Up @@ -54,7 +57,7 @@ public void addNeighbor(Field p) {
if(input != null) input.setNewWaterState(false);
input = (Pipe) p;
} catch(Exception e) {
System.out.print("Error casting field to pipe.");
logger.log(Level.WARNING, "Error casting field to pipe.");
}
}

Expand Down Expand Up @@ -83,14 +86,14 @@ public void step() {
spawnedPump = new Pump();
}
} else {
System.out.println("Spawnoljon pumpa?");
logger.log(Level.INFO, "Spawnoljon pumpa?");
Scanner scanner = new Scanner(System.in);
String valasz = scanner.nextLine();
if (valasz.equals("Igen")) {
spawnedPump = new Pump();
}
if (!valasz.equals("Nem")) {
System.out.println("Helytelen valasz, ezert nem spawnolodik pumpa.");
logger.log(Level.WARNING, "Helytelen valasz, ezert nem spawnolodik pumpa.");
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/model/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* Tarolja a jatek mindenkori allapotat, iranyitja azt. Ebbe bele kell erteni a jatekosok listajanak jegyzeset,
* a mezok szamontartasat, az eppen soron levo jatekos es a csapatok pontjainak szamontartasat
*/
public class Game implements Serializable {
private static final Logger logger = Logger.getLogger("logger");
static final int ROUND_BEGIN_ACTION_NUMBER = 3;
/**
* Az osztaly egyetlen peldanya
Expand Down Expand Up @@ -214,13 +217,13 @@ public void movePipe(Pipe p, Field oldEnd, Field newEnd) {

//the field that needs to be changed is not neighbouring
if(!p.getNeighbours().contains(oldEnd)) {
System.out.println("Old end is not neighbour!!!!!!");
logger.log(Level.WARNING, "Old end is not neighbour!!!!!!");
return;
}

//the field that needs to be plugged is already a neighbour
if(p.getNeighbours().contains(newEnd)) {
System.out.println("New end is neighbour!!!!!!");
logger.log(Level.WARNING, "New end is neighbour!!!!!!");
return;
}

Expand All @@ -234,7 +237,7 @@ public void movePipe(Pipe p, Field oldEnd, Field newEnd) {
}
this.actionTaken();
}
else System.out.println("New end is same as old end!!!!!!");
else logger.log(Level.WARNING, "New end is same as old end!!!!!!");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/model/Graphics.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.logging.Logger;

public class Graphics extends JFrame {
private transient Logger logger;
private static final Logger logger = Logger.getLogger("logger");
/**
* all the GUI elements
*/
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/model/Source.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
import interfaces.Periodic;

import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* Vegtelen vizforrasnak szamit. A kimeneten mindig folyik a viz
*/
public class Source extends Field implements Periodic, Serializable {
private static final Logger logger = Logger.getLogger("logger");
/**
* A kimeneti csove
*/
Expand Down Expand Up @@ -37,7 +40,7 @@ public void addNeighbor(Field p) {
try {
output = (Pipe) p;
} catch(Exception e) {
System.out.print("Error casting field to pipe.");
logger.log(Level.WARNING, "Error casting field to pipe.");
}

}
Expand Down

0 comments on commit 4f4f299

Please sign in to comment.