Skip to content

Commit

Permalink
#1 All sonarlint issues are fixed now, also added extension recommend…
Browse files Browse the repository at this point in the history
…ations.
  • Loading branch information
ErikSkare committed May 16, 2024
1 parent fade8e7 commit f4b5640
Show file tree
Hide file tree
Showing 19 changed files with 168 additions and 193 deletions.
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"vscjava.vscode-java-pack",
"SonarSource.sonarlint-vscode"
]
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"sonarlint.connectedMode.project": {
"connectionId": "bme-mit-iet-org",
"projectKey": "BME-MIT-IET_iet-hf-2024-nomad-szabotorok"
}
},
"java.configuration.updateBuildConfiguration": "interactive"
}
6 changes: 2 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
<version>1.0-SNAPSHOT</version>

<name>pipe_game</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<sonar.organization>bme-mit-iet-org</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/hu/bme/mit/iet/pipe_game/Cistern.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public Cistern() {
public void createPipe() {
Pipe p = new Pipe();
Control.addPipe(p);
p.AddNeighbour(this);
p.AddNeighbour(this);
AddNeighbour(p);
AddNeighbour(p);
p.addNeighbour(this);
p.addNeighbour(this);
addNeighbour(p);
addNeighbour(p);
pipe = p;
hasPipe = true;
pCount++;
Expand All @@ -65,7 +65,7 @@ public void createPump() {
* @return visszadjuk a pumpát
*/
@Override
public Pump CarryPump() {
public Pump carryPump() {

Pump p = pump;
pump = null;
Expand All @@ -79,7 +79,7 @@ public Pump CarryPump() {
* @return visszadja hogy mennyi vizet gyűjtött össze
*/
@Override
public int PullWater() {
public int pullWater() {

int points = 0;
for (SystemPart _pipe: neighbours) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/hu/bme/mit/iet/pipe_game/CisternView.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public CisternView(View view, Cistern cistern) {
* frissíti a part JButtont a jelenlegi állapotoknak megfelelően
*/
@Override
public void Update() {
public void update() {
button.setBounds(x,y,50,50);
button.setBackground(Color.RED);

Expand Down
40 changes: 20 additions & 20 deletions src/main/java/hu/bme/mit/iet/pipe_game/Control.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public static void init(int r, int mechanicCounter, int saboteurCounter) {
connect(pump2, pipe3);
connect(pump2, pipe5);

pump1.AcceptNewFlow(pipe1,pipe4);
pump2.AcceptNewFlow(pipe2,pipe5);
pump1.acceptNewFlow(pipe1,pipe4);
pump2.acceptNewFlow(pipe2,pipe5);

connect(c1, pipe4);
connect(c2, pipe5);
Expand Down Expand Up @@ -107,27 +107,27 @@ public static void init(int r, int mechanicCounter, int saboteurCounter) {

public static void handlePumps() {
for (Pump p:pumps) {
saboteurPoints += p.PushWater();
saboteurPoints += p.pushWater();
}
for (Pump p:pumps) {
p.PullWater();
p.pullWater();
// pump random eltörése
pumpBreak--;
if (randEnabled) {
if(rnd.nextInt(10) > 7)
p.BreakPump();
p.breakPump();
}
else {
if (pumpBreak == 0)
p.BreakPump();
p.breakPump();
}
}
}
public static void roundOver() {
/** ciszternák
*/
for (Cistern c:cisterns) {
mechanicPoints += c.PullWater();
mechanicPoints += c.pullWater();
c.generate();
}
/** pumpák
Expand All @@ -137,7 +137,7 @@ public static void roundOver() {
/** Vízforrás
*/
for (WaterSource ws:waterSources) {
saboteurPoints += ws.PushWater();
saboteurPoints += ws.pushWater();
}
/** Csövek
*/
Expand Down Expand Up @@ -181,7 +181,7 @@ public void pumpChangeFlow(List<String> command) {
if (!p2found && id.equals(pipe2.id))
p2found = true;
if (p1found && p2found) {
currentPlayer.ChangePumpFlow(pipe1, pipe2);
currentPlayer.changePumpFlow(pipe1, pipe2);
break;
}
}
Expand All @@ -191,19 +191,19 @@ public int handlePlayerCommand(List<String> command) {
int pumpLayed = -1;
switch (command.get(0)){
case "breakpipe":
currentPlayer.BreakPipe();
currentPlayer.breakPipe();
break;
case "carrypipe":
currentPlayer.CarryPipeEnd(pipes.get(Integer.parseInt(command.get(2))));
currentPlayer.carryPipeEnd(pipes.get(Integer.parseInt(command.get(2))));
break;
case "carrypump":
currentPlayer.CarryPump();
currentPlayer.carryPump();
break;
case "laypipe":
currentPlayer.LayPipe();
currentPlayer.layPipe();
break;
case "laypump":
SystemPart pump = currentPlayer.LayPump();
SystemPart pump = currentPlayer.layPump();
if (pumps.contains(pump))
pumpLayed = pumps.indexOf(pump);
break;
Expand All @@ -218,20 +218,20 @@ public int handlePlayerCommand(List<String> command) {
if (moveTo == null) {//ha nem erheto el breakelunk
break;
}
currentPlayer.Move(moveTo);//jatekos probal mozogni
currentPlayer.move(moveTo);//jatekos probal mozogni
break;
}
case "pumpchangeflow":
pumpChangeFlow(command);
break;
case "repair":
currentPlayer.Repair();
currentPlayer.repair();
break;
case "makeslippery":
currentPlayer.MakePipeSlippery();
currentPlayer.makePipeSlippery();
break;
case "makegluey":
currentPlayer.GluePipe();
currentPlayer.gluePipe();
break;
case "pass":
// passed the turn
Expand Down Expand Up @@ -286,8 +286,8 @@ public static void addPipe(Pipe p) {
}

private static void connect(SystemPart s1, SystemPart s2) {
s1.AddNeighbour(s2);
s2.AddNeighbour(s1);
s1.addNeighbour(s2);
s2.addNeighbour(s1);
}

public static void setRand(boolean a) {
Expand Down
30 changes: 7 additions & 23 deletions src/main/java/hu/bme/mit/iet/pipe_game/GUIControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -54,20 +52,8 @@ public void run(){
* ActionListener-ek a gombokhoz
* kilepes es start
*/
exit.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
dispatchEvent(new WindowEvent(GUIControl.this, WindowEvent.WINDOW_CLOSING));
}
});

start.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
settings(menu);
}
});

exit.addActionListener(e -> dispatchEvent(new WindowEvent(GUIControl.this, WindowEvent.WINDOW_CLOSING)));
start.addActionListener(e -> settings(menu));
}

/**
Expand Down Expand Up @@ -126,16 +112,14 @@ public void settings(JPanel oldMenu) {
/**
* 3 comboboxhoz ActionListener
*/
start.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
start.addActionListener(e -> {
rounds = (int)roundNum.getSelectedItem();
sabCount = (int)saboteurCount.getSelectedItem();
mechCount = (int)mechanicCount.getSelectedItem();
remove(menu);
startGame();
}
});
);

this.add(menu);
this.revalidate();
Expand Down Expand Up @@ -189,7 +173,7 @@ public void startGame() {
things.get(10).setCoords(750, 0);

gameField.setFields(things);
gameField.UpdateAll();
gameField.updateAll();
}

public void handlePutDownPipe(int ertek) throws NullPointerException {
Expand Down Expand Up @@ -217,7 +201,7 @@ public void handlePutDownPipe(int ertek) throws NullPointerException {
String n1 = posp.getNeighbours().get(0).getId();
String n2 = newp.getNeighbours().get(1).getId();

ArrayList<ViewBase> fields = gameField.getFields();
List<ViewBase> fields = gameField.getFields();
for (ViewBase f : fields) {
String id = f.getID();
if (id.equals(n1)) {
Expand Down Expand Up @@ -259,7 +243,7 @@ public void commitCommand(List<String> commands) {
for (int i = 0; i < cisterns.size(); ++i){

if ( !cisterns.get(i).hasPump() && cisterns.get(i).hasP()) {
ArrayList<ViewBase> fields = gameField.getFields();
List<ViewBase> fields = gameField.getFields();
PipeView pw = new PipeView(gameField, cisterns.get(i).getPipe());
int x = 0;
int y = 0;
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/hu/bme/mit/iet/pipe_game/Mechanic.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ void setPump(SystemPart pump) {
* Megjavítja a csövet ahol áll.
*/
@Override
public void Repair() {
position.Repair();
public void repair() {
position.repair();
}

/**
* A szerelő felveszi a paraméterként megadott cső végét.
* @param pipe a cső, aminek az egyik végét felveszi a szerelő.
*/
@Override
public void CarryPipeEnd(SystemPart pipe) {
if(position.CarryPipeEnd(pipe)) {
public void carryPipeEnd(SystemPart pipe) {
if(position.carryPipeEnd(pipe)) {
carriedPart = pipe;
hasPipe = true;
}
Expand All @@ -67,9 +67,9 @@ public void CarryPipeEnd(SystemPart pipe) {
* @return Visszaadja, hogy sikerült-e letenni a csövet.
*/
@Override
public boolean LayPipe() {
public boolean layPipe() {
if (!hasPipe) return false;
if (position.LayPipe(carriedPart)) {
if (position.layPipe(carriedPart)) {
hasPipe = false;
carriedPart = null;
return true;
Expand All @@ -81,8 +81,8 @@ public boolean LayPipe() {
* A szerelő felveszi a generált pumpát, onnan, ahol éppen tartózkodik.
*/
@Override
public void CarryPump() {
carriedPart = position.CarryPump();
public void carryPump() {
carriedPart = position.carryPump();
hasPump = true;
}

Expand All @@ -91,9 +91,9 @@ public void CarryPump() {
* @return Visszaadja, hogy sikerült-e letenni a pumpát.
*/
@Override
public SystemPart LayPump() {
public SystemPart layPump() {
if (carriedPart == null || !hasPump) return null;
position.LayPump(carriedPart);
position.layPump(carriedPart);
hasPump = false;
SystemPart pump = carriedPart;
carriedPart = null;
Expand Down
Loading

0 comments on commit f4b5640

Please sign in to comment.