Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into ci-cd
Browse files Browse the repository at this point in the history
# Conflicts:
#	Sivatagi vizhalozatok uzemeltetese a gyakorlatban 2/pom.xml
  • Loading branch information
voroscsoki committed May 21, 2024
2 parents adc8b73 + 7e6fedd commit d42e673
Show file tree
Hide file tree
Showing 150 changed files with 4,264 additions and 295 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
- Manuális-és-statikus-ellenőrzés
pull_request:
types: [opened, synchronize, reopened]
jobs:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
*.out
*.OUT
/bin/
.idea/
out/production/iet-hf-2024-tizenhat_tonna/palya.txt
/target

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
77 changes: 41 additions & 36 deletions Sivatagi vizhalozatok uzemeltetese a gyakorlatban 2/pom.xml
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" 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>hu.bme.mit.iet.hf.2024.tizenhat_tonna</groupId>
<artifactId>hu.bme.mit.iet.hf.2024.tizenhat_tonna</artifactId>
<version>0.5.0-SNAPSHOT</version>
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>hu.bme.mit.iet.hf.2024.tizenhat_tonna</groupId>
<artifactId>hu.bme.mit.iet.hf.2024.tizenhat_tonna</artifactId>
<version>0.5.0-SNAPSHOT</version>

<properties>
<sonar.organization>bme-mit-iet-org</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>
<properties>
<sonar.organization>bme-mit-iet-org</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.2</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.17.0</version>
</dependency>

</dependencies>

<build>
<sourceDirectory>src</sourceDirectory>
Expand All @@ -56,11 +61,11 @@
</configuration>
</plugin>

<!-- JUnit 5 requires Surefire version 2.22.1 or higher -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>
<!-- JUnit 5 requires Surefire version 2.22.1 or higher -->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>
</project>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Color;
import javax.swing.WindowConstants;

import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JTextField;
Expand All @@ -13,7 +16,7 @@


public class Menu extends JFrame implements ActionListener {
private String currentTheme;
public String currentTheme;
private JButton newGame;
private JButton exitGame;
private JButton theme;
Expand All @@ -22,6 +25,8 @@ public class Menu extends JFrame implements ActionListener {
private JTextField mechanic;
private JTextField saboteur;

public static ViewGame vg;

/**
* konstruktor
* @param name az ablak neve
Expand All @@ -30,7 +35,7 @@ public class Menu extends JFrame implements ActionListener {
public Menu(String name, String t) {
currentTheme = t;
setTitle(name);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
setLayout(null);
setBounds(700, 250, 500, 500);
Expand All @@ -52,11 +57,11 @@ public Menu(String name, String t) {
add(theme);

Integer[] numOfMechanics = {2, 3, 4, 5, 6, 7, 8, 9};
mechanics = new JComboBox<Integer>(numOfMechanics);
mechanics = new JComboBox<>(numOfMechanics);
mechanics.setBounds(300, 165, 40, 20);

Integer[] numOfSaboteurs = {2, 3, 4, 5, 6, 7, 8, 9};
saboteurs = new JComboBox<Integer>(numOfSaboteurs);
saboteurs = new JComboBox<>(numOfSaboteurs);
saboteurs.setBounds(300, 195, 40, 20);

add(mechanics);
Expand Down Expand Up @@ -112,6 +117,27 @@ public void changeTheme(String s) {
}
}

public JButton getThemeButton() {
return theme;
}

public JButton getPlayButton() {
return newGame;
}

public ArrayList<JButton> getActionButtons() {
ArrayList<JButton> actionButtons = new ArrayList<JButton>();
if (vg == null) return actionButtons;

actionButtons.add(vg.repairButton);
actionButtons.add(vg.breakButton);
actionButtons.add(vg.makeSlipperyButton);
actionButtons.add(vg.makeStickyButton);
actionButtons.add(vg.putDownButton);

return actionButtons;
}

@Override
public void actionPerformed(ActionEvent e) {

Expand All @@ -133,15 +159,12 @@ public void actionPerformed(ActionEvent e) {
Controller.commandList.add("addplayer D Sab" + i);
}
}
try {
Controller.Run(); // egyszer fut le, felépíti a pályát, utána a függvényeit kell majd hívni
} catch (FileNotFoundException ex) {
throw new RuntimeException(ex);
}
Controller.Run(); // egyszer fut le, felépíti a pályát, utána a függvényeit kell majd hívni

Controller.create();
Controller.SetActivePlayer(Controller.getAllPlayers().get(0));
Controller.setActivePlayer(Controller.getAllPlayers().get(0));
this.dispose();
ViewGame vg = new ViewGame();
vg = new ViewGame();
vg.setBackgroundColor(currentTheme);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,24 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import javax.swing.WindowConstants;

public class ViewGame extends JFrame implements ActionListener {

private Controller controller;
private static boolean isChosen = false;
private JPanel gameBackground;

/**
* HashMap for the Drawables
*/
public static HashMap<Drawable, Object> objectDrawNames = new HashMap<>();
public static final Map<Drawable, Object> objectDrawNames = new HashMap<>();
/**
* HashMap for the Drawables
*/
public static HashMap<Object, Drawable> objectDrawReverseNames = new HashMap<>();
public static final Map<Object, Drawable> objectDrawReverseNames = new HashMap<>();


public static ViewGame vg;
Expand All @@ -42,14 +44,14 @@ public class ViewGame extends JFrame implements ActionListener {
/**
* Controll buttons
*/
JButton moveButton;
JButton repairButton;
JButton breakButton;
JButton makeSlipperyButton;
JButton makeStickyButton;
JButton pickUpButton;
JButton putDownButton;
JButton setPumpButton;
static JButton moveButton;
static JButton repairButton;
static JButton breakButton;
static JButton makeSlipperyButton;
static JButton makeStickyButton;
static JButton pickUpButton;
static JButton putDownButton;
static JButton setPumpButton;

/**
* Last action
Expand All @@ -58,11 +60,11 @@ public class ViewGame extends JFrame implements ActionListener {
/**
* ArrayList for the selected elements
*/
static ArrayList<Object> selectSequence = new ArrayList<Object>(); //kiválasztott elemek, kiválasztásuk sorrendjében
static final List<Object> selectSequence = new ArrayList<>(); //kiválasztott elemek, kiválasztásuk sorrendjében
/**
* HashMap for the buttons
*/
public static HashMap<JButton, Drawable> buttonToElement = new HashMap<JButton, Drawable>(); //kiválasztó gomb -> kiválasztott rajz
public static final Map<JButton, Drawable> buttonToElement = new HashMap<>(); //kiválasztó gomb -> kiválasztott rajz

/**
* Max number of rounds
Expand Down Expand Up @@ -119,13 +121,27 @@ public void actionPerformed(ActionEvent e) {
}
};

public static Menu menu;

/**
* Main method
* @param args
*/
public static void main(String[] args){
Menu menu = new Menu("Menu", "White");
// measure startup time
long startTime = System.currentTimeMillis();

menu = new Menu("Menu", "White");
menu.showMenu();

// measure startup time
long endTime = System.currentTimeMillis();
long duration = endTime - startTime;
System.out.println("Startup time: " + duration + "ms");
}

public static Menu getMenuInstance() {
return menu;
}

/**
Expand Down Expand Up @@ -153,16 +169,16 @@ public static boolean getChosen(){
*/
public ViewGame() {
setTitle("Sivatagi vízhálózatok üzemeltetése a gyakorlatban 2");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setResizable(true);
setBounds(400, 150, 1000, 700);
setLayout(new BorderLayout());
gameBackground = new JPanel() {
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
g2d.setColor(Color.black);
super.paintComponent(g2d);
int i = 0;
for (Drawable draw : objectDrawReverseNames.values()){
if (draw instanceof PipeDraw) {
Pipe p = (Pipe)ViewGame.objectDrawNames.get(draw);
Expand Down Expand Up @@ -233,18 +249,11 @@ protected void paintComponent(Graphics g) {
vg = this;
}

/**
* Sets the controller
* @param c
*/
public void setController(Controller c){
controller = c;
}

/**
* Paints the objects
* @param g
*/
@Override
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public abstract class ActiveFields extends Field {
*/
private ArrayList<Pipe> pipes = new ArrayList<>();
@Override
public ArrayList<Field> getNeighborFields(){ return new ArrayList<Field>(pipes);}
public ArrayList<Field> getNeighborFields(){ return new ArrayList<>(pipes);}
/**
* Getter for pipes. Only for child classes.
* @return The pipes connected to the active field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Class for Cistern
* */
public class Cistern extends ActiveFields{

private Random random = new Random();
/**
* Last created Pipe. Null if the last pump was just taken.
*/
Expand All @@ -36,11 +36,10 @@ public void step() {
}
}
if(createdPipe == null){
Random r = new Random();
if(Controller.isTest()){
createdPipe = new Pipe(65);
}
else createdPipe = new Pipe(30+r.nextInt(41));
else createdPipe = new Pipe(30+random.nextInt(41));
}
}

Expand All @@ -51,12 +50,11 @@ public void step() {
* */
@Override
public Pump createNewPump(boolean b) {
Random r = new Random();
if(b){
if(Controller.isTest()){
return new Pump(100);
}
else return new Pump(80+r.nextInt(41));
else return new Pump(80+random.nextInt(41));
}
else return null;
}
Expand Down
Loading

0 comments on commit d42e673

Please sign in to comment.