diff --git a/.classpath b/.classpath index 23eec2b1..3e536e17 100644 --- a/.classpath +++ b/.classpath @@ -1,28 +1,28 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..d07fac1f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,36 @@ +name: Build +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Cache Maven packages + uses: actions/cache@v1 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Build and analyze + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: mvn -B clean org.jacoco:jacoco-maven-plugin:prepare-agent install org.jacoco:jacoco-maven-plugin:report install sonar:sonar \ No newline at end of file diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index b8947ec6..2af1e7b9 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,6 +1,8 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.source=11 diff --git a/pom.xml b/pom.xml index 9939ae1e..bb30850d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,26 +1,116 @@ - + 4.0.0 - - Monopoly - Monopoly + upv-ehu-iso2 + MonopolyCI 0.0.1-SNAPSHOT - jar - - Monopoly - http://maven.apache.org - - - 1.8 - 1.8 - - - - - junit - junit - 3.8.1 - test - - + + + + + org.jacoco + jacoco-maven-plugin + 0.8.6 + + + prepare-agent + + prepare-agent + + + + report + + report + + + + + + + + + objectdb + ObjectDB Repository + https://m2.objectdb.com + + + + + 11 + 11 + maiteurreta + https://sonarcloud.io + MonopolyCI + 6e245c0c0c5097aef76947d68c622a8410a1d90f + + + + + + junit + junit + 4.5 + test + + + com.toedter + jcalendar + 1.4 + + + + + jakarta.xml.bind + jakarta.xml.bind-api + 2.3.2 + + + + + org.glassfish.jaxb + jaxb-runtime + 2.3.2 + + + + + + jakarta.xml.ws + jakarta.xml.ws-api + 2.3.2 + + + + + com.sun.xml.ws + jaxws-rt + 2.3.2 + + + + com.objectdb + objectdb + 2.8.1 + + + org.eclipse.persistence + javax.persistence + 2.1.0 + + + javax.transaction + jta + 1.1 + + + + + org.mockito + mockito-all + 1.9.5 + test + + + + diff --git a/src/main/java/edu/ncsu/monopoly/Card.java b/src/main/java/edu/ncsu/monopoly/Card.java index bf40ccf7..cac400d1 100644 --- a/src/main/java/edu/ncsu/monopoly/Card.java +++ b/src/main/java/edu/ncsu/monopoly/Card.java @@ -1,5 +1,5 @@ package edu.ncsu.monopoly; -//updated 2021 +//PNueva acción maven public abstract class Card { public static final int TYPE_CHANCE = 1; diff --git a/src/main/java/edu/ncsu/monopoly/GameMaster.java b/src/main/java/edu/ncsu/monopoly/GameMaster.java index f7eb8244..1186fe5d 100644 --- a/src/main/java/edu/ncsu/monopoly/GameMaster.java +++ b/src/main/java/edu/ncsu/monopoly/GameMaster.java @@ -12,7 +12,7 @@ public class GameMaster { private GameBoard gameBoard; private MonopolyGUI gui; private int initAmountOfMoney; - private ArrayList players = new ArrayList(); + private ArrayList players = new ArrayList<>(); private int turn = 0; private int utilDiceRoll; private boolean testMode; @@ -166,17 +166,17 @@ public int getNumberOfSellers() { } public Player getPlayer(int index) { - return (Player)players.get(index); + return players.get(index); //(Player) } public int getPlayerIndex(Player player) { return players.indexOf(player); } - public ArrayList getSellerList() { - ArrayList sellers = new ArrayList(); - for (Iterator iter = players.iterator(); iter.hasNext();) { - Player player = (Player) iter.next(); + public ArrayList getSellerList() { + ArrayList sellers = new ArrayList<>(); + for (Iterator iter = players.iterator(); iter.hasNext();) { + Player player = iter.next(); //(Player) if(player != getCurrentPlayer()) sellers.add(player); } return sellers; @@ -191,7 +191,7 @@ public int getUtilDiceRoll() { } public void movePlayer(int playerIndex, int diceValue) { - Player player = (Player)players.get(playerIndex); + Player player = players.get(playerIndex); //(Player) movePlayer(player, diceValue); } @@ -227,7 +227,7 @@ public void playerMoved(Player player) { public void reset() { for(int i = 0; i < getNumberOfPlayers(); i++){ - Player player = (Player)players.get(i); + Player player = players.get(i); //(Player) player.setPosition(gameBoard.getCell(0)); } if(gameBoard != null) gameBoard.removeCards(); diff --git a/src/main/java/edu/ncsu/monopoly/RailRoadCell.java b/src/main/java/edu/ncsu/monopoly/RailRoadCell.java index fe5d9ec2..3ecea578 100644 --- a/src/main/java/edu/ncsu/monopoly/RailRoadCell.java +++ b/src/main/java/edu/ncsu/monopoly/RailRoadCell.java @@ -18,7 +18,7 @@ public int getPrice() { } public int getRent() { - return RailRoadCell.baseRent * (int)Math.pow(2, owner.numberOfRR() - 1); + return RailRoadCell.baseRent * (int)Math.pow(2, owner.numberOfRR() - 1.0); } public void playAction() { diff --git a/src/main/java/edu/ncsu/monopoly/gui/BuyHouseDialog.java b/src/main/java/edu/ncsu/monopoly/gui/BuyHouseDialog.java index 899c44b8..20dba769 100644 --- a/src/main/java/edu/ncsu/monopoly/gui/BuyHouseDialog.java +++ b/src/main/java/edu/ncsu/monopoly/gui/BuyHouseDialog.java @@ -15,8 +15,8 @@ public class BuyHouseDialog extends JDialog { - private JComboBox cboMonopoly; - private JComboBox cboNumber; + private JComboBox cboMonopoly; + private JComboBox cboNumber; private Player player; @@ -44,12 +44,12 @@ public void actionPerformed(ActionEvent e) { return btn; } - private JComboBox buildMonopolyComboBox() { - cboMonopoly = new JComboBox(player.getMonopolies()); + private JComboBox buildMonopolyComboBox() { + cboMonopoly = new JComboBox<>(player.getMonopolies()); return cboMonopoly; } - private JComboBox buildNumberComboBox() { + private JComboBox buildNumberComboBox() { cboNumber = new JComboBox(new Integer[]{ new Integer(1), new Integer(2), diff --git a/src/main/java/edu/ncsu/monopoly/gui/GUITradeDialog.java b/src/main/java/edu/ncsu/monopoly/gui/GUITradeDialog.java index aae46d01..4b94bb3c 100644 --- a/src/main/java/edu/ncsu/monopoly/gui/GUITradeDialog.java +++ b/src/main/java/edu/ncsu/monopoly/gui/GUITradeDialog.java @@ -14,12 +14,11 @@ import javax.swing.JLabel; import edu.ncsu.monopoly.*; -import edu.ncsu.monopoly.TradeDeal; -import edu.ncsu.monopoly.TradeDialog; public class GUITradeDialog extends JDialog implements TradeDialog { private JButton btnOK, btnCancel; - private JComboBox cboSellers, cboProperties; + private JComboBox cboSellers; + private JComboBox cboProperties; private TradeDeal deal; private JTextField txtAmount; @@ -28,8 +27,8 @@ public GUITradeDialog(Frame parent) { super(parent); setTitle("Trade Property"); - cboSellers = new JComboBox(); - cboProperties = new JComboBox(); + cboSellers = new JComboBox<>(); + cboProperties = new JComboBox<>(); txtAmount = new JTextField(); btnOK = new JButton("OK"); btnCancel = new JButton("Cancel"); @@ -91,9 +90,9 @@ public void actionPerformed(ActionEvent e) { } private void buildSellersCombo() { - List sellers = GameMaster.instance().getSellerList(); - for (Iterator iter = sellers.iterator(); iter.hasNext();) { - Player player = (Player) iter.next(); + List sellers = GameMaster.instance().getSellerList(); + for (Iterator iter = sellers.iterator(); iter.hasNext();) { + Player player = iter.next(); //(Player) cboSellers.addItem(player); } if(sellers.size() > 0) { diff --git a/src/main/java/edu/ncsu/monopoly/gui/MainWindow.java b/src/main/java/edu/ncsu/monopoly/gui/MainWindow.java index 86f87277..d5301a4d 100644 --- a/src/main/java/edu/ncsu/monopoly/gui/MainWindow.java +++ b/src/main/java/edu/ncsu/monopoly/gui/MainWindow.java @@ -118,8 +118,8 @@ public boolean isTradeButtonEnabled(int i) { public void movePlayer(int index, int from, int to) { GUICell fromCell = queryCell(from); GUICell toCell = queryCell(to); - fromCell.removePlayer(index); - toCell.addPlayer(index); + if (fromCell!=null) fromCell.removePlayer(index); + if (toCell!=null) toCell.addPlayer(index); } public RespondDialog openRespondDialog(TradeDeal deal) {