Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New from GitHub #2

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
36 changes: 36 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 5 additions & 3 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -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
136 changes: 113 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,116 @@
<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">
<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>Monopoly</groupId>
<artifactId>Monopoly</artifactId>
<groupId>upv-ehu-iso2</groupId>
<artifactId> MonopolyCI </artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Monopoly</name>
<url>http://maven.apache.org</url>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.6</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>objectdb</id>
<name>ObjectDB Repository</name>
<url>https://m2.objectdb.com</url>
</repository>
</repositories>

<properties>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<sonar.organization> maiteurreta </sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.projectKey>MonopolyCI </sonar.projectKey>
<sonar.login>6e245c0c0c5097aef76947d68c622a8410a1d90f</sonar.login>
</properties>

<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.toedter</groupId>
<artifactId>jcalendar</artifactId>
<version>1.4</version>
</dependency>

<!-- API JAXB -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.2</version>
</dependency>

<!-- Runtime -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
</dependency>


<!-- API JAX-WS -->
<dependency>
<groupId>jakarta.xml.ws</groupId>
<artifactId>jakarta.xml.ws-api</artifactId>
<version>2.3.2</version>
</dependency>

<!-- Runtime -->
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.2</version>
</dependency>

<dependency>
<groupId>com.objectdb</groupId>
<artifactId>objectdb</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>

2 changes: 1 addition & 1 deletion src/main/java/edu/ncsu/monopoly/Card.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/edu/ncsu/monopoly/GameMaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class GameMaster {
private GameBoard gameBoard;
private MonopolyGUI gui;
private int initAmountOfMoney;
private ArrayList players = new ArrayList();
private ArrayList<Player> players = new ArrayList<>();
private int turn = 0;
private int utilDiceRoll;
private boolean testMode;
Expand Down Expand Up @@ -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<Player> getSellerList() {
ArrayList<Player> sellers = new ArrayList<>();
for (Iterator<Player> iter = players.iterator(); iter.hasNext();) {
Player player = iter.next(); //(Player)
if(player != getCurrentPlayer()) sellers.add(player);
}
return sellers;
Expand All @@ -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);
}

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/ncsu/monopoly/RailRoadCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/edu/ncsu/monopoly/gui/BuyHouseDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@


public class BuyHouseDialog extends JDialog {
private JComboBox cboMonopoly;
private JComboBox cboNumber;
private JComboBox<String> cboMonopoly;
private JComboBox<String> cboNumber;

private Player player;

Expand Down Expand Up @@ -44,12 +44,12 @@ public void actionPerformed(ActionEvent e) {
return btn;
}

private JComboBox buildMonopolyComboBox() {
cboMonopoly = new JComboBox(player.getMonopolies());
private JComboBox<String> buildMonopolyComboBox() {
cboMonopoly = new JComboBox<>(player.getMonopolies());
return cboMonopoly;
}

private JComboBox buildNumberComboBox() {
private JComboBox<String> buildNumberComboBox() {
cboNumber = new JComboBox(new Integer[]{
new Integer(1),
new Integer(2),
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/edu/ncsu/monopoly/gui/GUITradeDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Player> cboSellers;
private JComboBox<Cell> cboProperties;

private TradeDeal deal;
private JTextField txtAmount;
Expand All @@ -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");
Expand Down Expand Up @@ -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<Player> sellers = GameMaster.instance().getSellerList();
for (Iterator<Player> iter = sellers.iterator(); iter.hasNext();) {
Player player = iter.next(); //(Player)
cboSellers.addItem(player);
}
if(sellers.size() > 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/edu/ncsu/monopoly/gui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down