Skip to content

Commit

Permalink
Merge pull request #7 from BME-MIT-IET/Csongor
Browse files Browse the repository at this point in the history
Csongor
  • Loading branch information
pupcs authored May 20, 2024
2 parents 7c40dbd + f9e1f8c commit 2323006
Show file tree
Hide file tree
Showing 37 changed files with 39 additions and 96 deletions.
Binary file modified manual_testing.docx
Binary file not shown.
83 changes: 32 additions & 51 deletions src/main/java/program/main/Controller.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package program.main;


import java.util.Random;
import static program.main.Main.game;
import static program.main.State.Working;
Expand All @@ -11,7 +10,7 @@ public class Controller {
* attributumok
*/

private static int CoolDown;
private static int coolDown;

private static int roundsLeft = 10;
private static int plumberCoolDown;
Expand All @@ -22,12 +21,12 @@ public class Controller {

private static Random rand;
private static int index;
static Nomad CurrentNomad;
static Plumber CurrentPlumber;
static Nomad currentNomad;
static Plumber currentPlumber;

static boolean CurrentTurnIsNomad = false;
static boolean currentTurnIsNomad = false;

static boolean GameOver = false;
static boolean gameOver = false;


/**functions
Expand All @@ -37,7 +36,7 @@ public class Controller {
* setRounds
* Változtatja a roundLeft adattag értékét -1 el
*/
public static void setRounds_min1() {
public static void decrementRounds() {
roundsLeft--;
}

Expand All @@ -46,15 +45,20 @@ public static void setRounds_min1() {
*
* @param i Az új hátralévő körök száma.
*/
public static void setRounds(int i){roundsLeft=i;}
public static void setRounds(int i){
if (i < 0){
throw new IllegalArgumentException("Round count cannot be negative");
}
roundsLeft = i;
}

/**
* Visszaadja a jelenlegi vízszerelő játékost.
*
* @return A jelenlegi vízszerelő játékos.
*/
public static Plumber getCurrentPlumber() {
return CurrentPlumber;
return currentPlumber;
}

/**
Expand All @@ -63,7 +67,7 @@ public static Plumber getCurrentPlumber() {
* @return A jelenlegi nomád játékos.
*/
public static Nomad getCurrentNomad() {
return CurrentNomad;
return currentNomad;
}

/**
Expand All @@ -86,7 +90,7 @@ public static int getRounds() {
*/
public static int getCoolDown() {
// System.out.println("SUCCESS - Controller.getPlumberCoolDown()");
return CoolDown;
return coolDown;
}

/**
Expand All @@ -97,7 +101,7 @@ public static int getCoolDown() {
*/
public static void setCoolDown(int value) {
//System.out.println("SUCCESS - Controller.setNomadCoolDown()");
CoolDown = value;
coolDown = value;
}

/**
Expand All @@ -108,25 +112,25 @@ public static void setCoolDown(int value) {
*/
public static int getNomadCoolDown() {
// System.out.println("SUCCESS - Controller.getNomadCoolDown()");
return CoolDown;
return coolDown;
}

/**
* Visszaadja a jelenlegi nomád játékost.
*
* @return A jelenlegi nomád játékos.
*/
public Nomad CurrentNomadTurn() {
return CurrentNomad;
public Nomad currentNomadTurn() {
return currentNomad;
}

/**
* Visszaadja a jelenlegi vízszerelő játékost.
*
* @return A jelenlegi vízszerelő játékos.
*/
public Plumber CurrentPlumberTurn() {
return CurrentPlumber;
public Plumber currentPlumberTurn() {
return currentPlumber;
}

/**
Expand All @@ -135,82 +139,59 @@ public Plumber CurrentPlumberTurn() {
*/
public void turn() {
if (getRounds() == 0){
GameOver = true;
gameOver = true;
return;
}
//System.out.println("lefut a turn");
//System.out.println(game.plumberButtonPanel.getendturn());
Main.game.getGameWindow().getPlumberButtonPanel().setVisible(true);
for (int i = 0; i < game.Plumbers().size(); i++) {
//System.out.println("plumber size: " + game.Plumbers().size());
game.Nomads().get(i).setMoved(false);
//System.out.println("plumber");
CurrentPlumber = game.Plumbers().get(i);
currentPlumber = game.Plumbers().get(i);
while (!game.plumberButtonPanel.getendturn()) {
CurrentPlumber = game.Plumbers().get(i);
CurrentPlumber.turn();
currentPlumber = game.Plumbers().get(i);
currentPlumber.turn();
}
Main.game.gamePanel.repaint();
game.Plumbers().get(i).setMoved(false);

//System.out.println("plumber ended");
Main.game.gamePanel.repaint();
for (int j = 0; j < game.Pipes().size(); j++) {
game.Pipes().get(j).turn();
}
//System.out.println("minden pipe turn");
for (int k = 0; k < game.Fields().size(); k++) {
game.Fields().get(k).turn();
}
//System.out.println("minden fiels turn");

game.plumberButtonPanel.resetTurn(false);
//System.out.println("plumber turn reset");
//System.out.println(game.plumberButtonPanel.getendturn());
//System.out.println("szerelo : " + plumberPoints);
//System.out.println("nomad : " + nomadPoints);

}
CurrentTurnIsNomad = true;
currentTurnIsNomad = true;
Main.game.getGameWindow().getPlumberButtonPanel().setVisible(false);
Main.game.getGameWindow().getNomadButtonPanel().setVisible(true);


for (int i = 0; i < game.Nomads().size(); i++) {
game.Nomads().get(i).setMoved(false);
CurrentNomad = game.Nomads().get(i);
currentNomad = game.Nomads().get(i);
while (!game.nomadButtonPanel.getendturn()) {
CurrentNomad = game.Nomads().get(i);
CurrentPlumber.turn();
currentNomad = game.Nomads().get(i);
currentPlumber.turn();
}
Main.game.gamePanel.repaint();
game.Nomads().get(i).setMoved(false);

//System.out.println("plumber ended");
Main.game.gamePanel.repaint();
for (int k = 0; k < game.Pipes().size(); k++) {
game.Pipes().get(k).turn();
}
//System.out.println("minden pipe turn");
for (int j = 0; j < game.Fields().size(); j++) {
game.Fields().get(j).turn();
}
//System.out.println("minden fiels turn");

game.nomadButtonPanel.resetTurn(false);
//System.out.println("nomad turn reset");
//System.out.println(game.nomadButtonPanel.getendturn());
//.out.println("szerelo : " + plumberPoints);
//System.out.println("nomad : " + nomadPoints);
}
CurrentTurnIsNomad = false;
currentTurnIsNomad = false;
Main.game.getGameWindow().getNomadButtonPanel().setVisible(false);
Main.game.getGameWindow().getPlumberButtonPanel().setVisible(true);
setRounds_min1();




decrementRounds();
}

/**
Expand Down Expand Up @@ -276,7 +257,7 @@ public static void destroyPump() {
}

public static boolean getCurrentTurnIsNomad() {
return CurrentTurnIsNomad;
return currentTurnIsNomad;
}

public static void setPlumberPoints(int plumberPoints) {
Expand Down
17 changes: 3 additions & 14 deletions src/main/java/program/main/Field.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package program.main;


import java.awt.image.BufferedImage;
import java.io.Serializable;
import java.util.ArrayList;



/**
* A pálya ezekből az elemekből áll. Ez egy absztrakt osztály.
*/
Expand All @@ -21,17 +17,14 @@ public abstract class Field implements Round, Serializable {

public void SetName(String s) {
ID = s;
//System.out.println("SUCCESS - Field.SetName()");
}

public String GetName() {
//System.out.println("SUCCESS - Field.GetName()");
return ID;
}

@Override
public String toString() {
//System.out.println("SUCCESS - Field.toString()");
return (ID + " Field");
}

Expand Down Expand Up @@ -127,9 +120,7 @@ public String toString() {
/**
* A víz áramlását valósítja meg.
*/
public void waterFlowing() {
//System.out.println("SUCCESS - Field.waterFlowing");
}
public abstract void waterFlowing();

/**
* Beállítja, hogy a ciszternában van-e pumpa a newPump adattag értékének változtatásával.
Expand All @@ -145,17 +136,16 @@ public void waterFlowing() {
*/
public abstract boolean getNewPump();

public abstract ArrayList getConnectedPipes();
public abstract ArrayList<Pipe> getConnectedPipes();

public abstract ArrayList getConnectedPumps();
public abstract ArrayList<Pump> getConnectedPumps();

/**
* A field állapotának lekérésére szolgál
*
* @param state
*/
public void setState(State state) {
//System.out.println("SUCCESS - Field.setState()");
this.state = state;
}

Expand All @@ -165,7 +155,6 @@ public void setState(State state) {
* @return
*/
public State getState() {
//System.out.println("SUCCESS - Field.getState()");
return state;
}

Expand Down
Loading

0 comments on commit 2323006

Please sign in to comment.