Skip to content

Commit

Permalink
More test to PumpTest and little renames
Browse files Browse the repository at this point in the history
  • Loading branch information
Takibalu committed May 20, 2024
1 parent b3266fd commit 877e6b4
Show file tree
Hide file tree
Showing 19 changed files with 298 additions and 239 deletions.
102 changes: 51 additions & 51 deletions src/main/java/Controller/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,35 @@ static public Controller getInstance() {

return controller;
}
final String WrongAttr = "wrong attribute name";
final String WrongPipe = "wrong pipe name";
final String WrongPlayer = "wrong player name";
final String WrongMech = "wrong mechanic name";
final String fellDownStr = "fellDown";
final String stuckStr = "stuck";
final String standingOnStr = "standingOn";
final String stateStr = "state";
final String heldItemsStr = "heldItems";
final String pipesStr = "pipes";
final String createdPickupablesStr = "createdPickupables";
final String playersStr = "players";
final String saboteurPointsStr = "saboteurPoints";
final String mechanicPointsStr = "mechanicPoints";
final String pointsToWinStr = "pointsToWin";
final String moveActionStr = "moveAction";
final String specialActionStr = "specialAction";
final String turnOverStr = "turnOver";
final String brokenStr = "broken";
final String waterCapacityStr = "waterCapacity";
final String heldWaterStr = "heldWater";
final String maximumPipesStr = "maximumPipes";
final String activeInStr = "activeIn";
final String activeOutStr = "activeOut";
final String readyToPierceStr = "readyToPierce";
final String lubricatedStr = "lubricated";
final String gluedStr = "glued";
final String beingHeldStr = "beingHeld";
final String nodesStr = "nodes";
final static String WrongAttr = "wrong attribute name";
final static String WrongPipe = "wrong pipe name";
final static String WrongPlayer = "wrong player name";
final static String WrongMech = "wrong mechanic name";
final static String fellDownStr = "fellDown";
final static String stuckStr = "stuck";
final static String standingOnStr = "standingOn";
final static String stateStr = "state";
final static String heldItemsStr = "heldItems";
final static String pipesStr = "pipes";
final static String createdPickupablesStr = "createdPickupables";
final static String playersStr = "players";
final static String saboteurPointsStr = "saboteurPoints";
final static String mechanicPointsStr = "mechanicPoints";
final static String pointsToWinStr = "pointsToWin";
final static String moveActionStr = "moveAction";
final static String specialActionStr = "specialAction";
final static String turnOverStr = "turnOver";
final static String brokenStr = "broken";
final static String waterCapacityStr = "waterCapacity";
final static String heldWaterStr = "heldWater";
final static String maximumPipesStr = "maximumPipes";
final static String activeInStr = "activeIn";
final static String activeOutStr = "activeOut";
final static String readyToPierceStr = "readyToPierce";
final static String lubricatedStr = "lubricated";
final static String gluedStr = "glued";
final static String beingHeldStr = "beingHeld";
final static String nodesStr = "nodes";
/**
* Játék elkezdését mutató boolean
*/
Expand Down Expand Up @@ -293,7 +293,7 @@ public void connect(String pipeName, String wNodeName) {
}
WaterNode w = (WaterNode) objectCatalog.get(wNodeName);

if (w.AddPipe(p) && p.AddWaterNode(w)) {
if (w.addPipe(p) && p.addWaterNode(w)) {
IO_Manager.write(pipeName + ".nodes = " + listWrite(p.getNodes()), Controller.filetoWrite != null);
IO_Manager.write(wNodeName + ".pipes = " + listWrite(w.getPipes()), Controller.filetoWrite != null);
}
Expand All @@ -320,7 +320,7 @@ public void move(String playerName, String steppableName) {
Steppable s = (Steppable) objectCatalog.get(steppableName);
Steppable prev = p.getStandingOn();

if (p.Move(s)) {
if (p.move(s)) {
IO_Manager.write(steppableName + ".players = " + listWrite(s.getPlayers()), Controller.filetoWrite != null);
IO_Manager.write(playerName + ".standingOn = " + steppableName, Controller.filetoWrite != null);
if (prev != null)
Expand All @@ -344,7 +344,7 @@ public void pierce(String playerName) {
}
Player p = (Player) objectCatalog.get(playerName);

if (p.Pierce())
if (p.pierce())

IO_Manager.write(playerName + ".standingOn.broken = " + "true", Controller.filetoWrite != null);

Expand All @@ -361,7 +361,7 @@ public void glue(String playerName) {
}
Player p = (Player) objectCatalog.get(playerName);

if (p.Glue())
if (p.glue())

IO_Manager.write(playerName + ".standingOn.glued = " + "true", Controller.filetoWrite != null);

Expand All @@ -380,7 +380,7 @@ public void lubricate(String saboteurName) {
}
Saboteur s = (Saboteur) objectCatalog.get(saboteurName);

if (s.Lubricate())
if (s.lubricate())
IO_Manager.write(saboteurName + ".standingOn.lubricated = " + "true", Controller.filetoWrite != null);
}

Expand All @@ -396,7 +396,7 @@ public void repair(String mechanicName) {
}
Mechanic m = (Mechanic) objectCatalog.get(mechanicName);

if (m.Repair()) {
if (m.repair()) {
IO_Manager.write(mechanicName + ".standingOn.broken = false", Controller.filetoWrite != null);
if (pipes.contains((Pipe) m.getStandingOn())) {
IO_Manager.write(mechanicName + ".standingOn.readyToPierce = false", Controller.filetoWrite != null);
Expand Down Expand Up @@ -431,7 +431,7 @@ public void redirect(String playerName, String inPipeName, String outPipeName) {
}
Pipe out = (Pipe) objectCatalog.get(outPipeName);

if (p.Redirect(in, out)) {
if (p.redirect(in, out)) {
IO_Manager.write(playerName + ".standingOn.activeIn = " + inPipeName, Controller.filetoWrite != null);
IO_Manager.write(playerName + ".standingOn.activeOut = " + outPipeName, Controller.filetoWrite != null);
}
Expand All @@ -457,7 +457,7 @@ public void pickup(String mechanicName, String pickupName) {
}
PickupAble p = (PickupAble) objectCatalog.get(pickupName);

if (m.PickUp(p)) {
if (m.pickUp(p)) {
IO_Manager.write(mechanicName + ".heldItems = " + pickupName, Controller.filetoWrite != null);

}
Expand All @@ -475,7 +475,7 @@ public void placedown(String mechanicName) {
}
Mechanic m = (Mechanic) objectCatalog.get(mechanicName);

if (m.PlaceDown())
if (m.placeDown())
IO_Manager.write(mechanicName + ".heldItems = null", Controller.filetoWrite != null);

}
Expand Down Expand Up @@ -544,9 +544,9 @@ public void stateGet(String objectName, String attribName) {
}
} else if (objectName.equals("counter")) {
switch (attribName) {
case saboteurPointsStr -> output += Integer.toString(PointCounter.getInstance().GetSaboteurPoints());
case mechanicPointsStr -> output += Integer.toString(PointCounter.getInstance().GetMechanicPoints());
case pointsToWinStr -> output += Integer.toString(PointCounter.getInstance().GetPointsToWin());
case saboteurPointsStr -> output += Integer.toString(PointCounter.getInstance().getSaboteurPoints());
case mechanicPointsStr -> output += Integer.toString(PointCounter.getInstance().getMechanicPoints());
case pointsToWinStr -> output += Integer.toString(PointCounter.getInstance().getPointsToWin());
default -> IO_Manager.writeError(WrongAttr, Controller.filetoWrite != null);
}
} else {
Expand Down Expand Up @@ -651,7 +651,7 @@ public void turnOver() {
int chance = random.nextInt(0, nodes.size());
boolean ignoreStates = Player.isIgnoreStates();
Player.setIgnoreStates(true);
turnOrder.getFirst().Move(nodes.get(chance));
turnOrder.getFirst().move(nodes.get(chance));
Player.setIgnoreStates(false);
turnOrder.getFirst().setState(PlayerActionState.TURN_OVER);
turnOver();
Expand Down Expand Up @@ -684,10 +684,10 @@ public void turnOver() {
*/
public void nextTurn() {
for (WaterNode node : nodes) {
node.WaterFlow();
node.waterFlow();
}
for (Cistern cistern : cisterns) {
cistern.GeneratePickupables();
cistern.generatePickupables();
}
if (!deterministic) {
for (Pump pump : pumps) {
Expand All @@ -701,7 +701,7 @@ public void nextTurn() {
}
//end of game?
if (started) {
if (counter.GetMechanicPoints() >= counter.GetPointsToWin() || counter.GetSaboteurPoints() >= counter.GetPointsToWin())
if (counter.getMechanicPoints() >= counter.getPointsToWin() || counter.getSaboteurPoints() >= counter.getPointsToWin())
endGame();
}
}
Expand All @@ -719,7 +719,7 @@ public void generate(String cisternName, String pipeName, String pumpName) {
}
Cistern c = (Cistern) objectCatalog.get(cisternName);

c.GeneratePickupables();
c.generatePickupables();

IO_Manager.write("This is pipe:" + pipeName);
IO_Manager.write("This is pump:" + pumpName);
Expand All @@ -738,7 +738,7 @@ public void waterFlow(String wNodeName) {
}
WaterNode w = (WaterNode) objectCatalog.get(wNodeName);

w.WaterFlow();
w.waterFlow();


}
Expand Down Expand Up @@ -807,8 +807,8 @@ public void endGame() {
started = false;
gameView.end();
IO_Manager.write("game over", Controller.filetoWrite != null);
IO_Manager.write("saboteurPoints = " + counter.GetSaboteurPoints(), Controller.filetoWrite != null);
IO_Manager.write("mechanicPoints = " + counter.GetMechanicPoints(), Controller.filetoWrite != null);
IO_Manager.write("saboteurPoints = " + counter.getSaboteurPoints(), Controller.filetoWrite != null);
IO_Manager.write("mechanicPoints = " + counter.getMechanicPoints(), Controller.filetoWrite != null);

}
/**
Expand Down Expand Up @@ -845,10 +845,10 @@ public void startGame() {
return;
}
for (Player p : players) {
p.RemovePlayer();
p.removePlayer();
SecureRandom random = new SecureRandom();
int chance = random.nextInt(0, nodes.size());
p.Move(nodes.get(chance));
p.move(nodes.get(chance));
}
for (Pipe p : pipes) {
if (p.getNodes().getFirst() == null || p.getNodes().getLast() == null) {
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/Model/Cistern.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public Cistern() {
* @return a felvétel eredménye
*/
@Override
public boolean PickedUpFrom(PickupAble pickup) {
public boolean pickedUpFrom(PickupAble pickup) {
generatedPumps.remove(pickup);
generatedPipes.remove(pickup);
boolean result = createdPickupables.remove(pickup);
Expand All @@ -60,10 +60,10 @@ public boolean PickedUpFrom(PickupAble pickup) {
* @return a felvétel eredménye(mivel ciszternára lehet csövet kötni ezért ez mindig kivitelezhető)
*/
@Override
public boolean PlacedDownTo(Pipe pickup) {
public boolean placedDownTo(Pipe pickup) {

AddPipe(pickup);
pickup.AddWaterNode(this);
addPipe(pickup);
pickup.addWaterNode(this);
return true;

}
Expand All @@ -74,7 +74,7 @@ public boolean PlacedDownTo(Pipe pickup) {
* @return a felvétel eredménye(mivel ciszternára nem lehet pumpát kötni ezért ez sose kivitelezhető)
*/
@Override
public boolean PlacedDownTo(Pump pickup) {
public boolean placedDownTo(Pump pickup) {
IO_Manager.writeInfo("Can't place it here", Controller.filetoWrite != null);
return false;
}
Expand All @@ -87,18 +87,18 @@ public boolean PlacedDownTo(Pump pickup) {
* szerelők pontszáma.
*/
@Override
public void WaterFlow() {
public void waterFlow() {
for (Pipe p : pipes) {
int lost = p.LoseWater(1);
counter.AddMechanicPoints(lost);
int lost = p.loseWater(1);
counter.addMechanicPoints(lost);
IO_Manager.write(Controller.getInstance().getObjectName(p) + " lost " + lost, Controller.filetoWrite != null);
}
}

/**
* A generálás függvénye, ami random generál egy pumpát vagy csövet. Ha már van 3 generált akkor nem készít többet
*/
public void GeneratePickupables() {
public void generatePickupables() {
if (createdPickupables.size() > 3)
return;
SecureRandom rand = new SecureRandom();
Expand All @@ -115,8 +115,8 @@ public void GeneratePickupables() {
Pipe pi = (Pipe) Controller.getInstance().getObjectCatalog().get(pipeName);
createdPickupables.add(pi);
generatedPipes.add(pi);
pi.AddWaterNode(this);
AddPipe(pi);
pi.addWaterNode(this);
addPipe(pi);

GameView gameView = Controller.getInstance().getGameView();
PipeView pipeView = new PipeView(
Expand Down
Loading

0 comments on commit 877e6b4

Please sign in to comment.