Skip to content
Merged
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
20 changes: 1 addition & 19 deletions src/main/java/org/example/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ public static void main(String[] args) throws IOException {
Traveler p3;
Traveler p4;




try {
tx.begin();
List<Transport> transportMethods = em.createQuery("select t from Transport t", Transport.class).getResultList();
Expand All @@ -33,15 +30,6 @@ public static void main(String[] args) throws IOException {
}

switch (pAmount){
// Test case for debuging and testing
// case 1 ->{
// while(true){
// Location current = randomLocation(em);
// Location dest = randomLocation(em);
//
// System.out.println(current.getName());
// System.out.println(dest.getName());}
// }
case 2 ->{
String p1Name = IO.readln("Input name for player 1: ");
Location newDestP1 = randomLocation(em);
Expand Down Expand Up @@ -207,14 +195,8 @@ public static void main(String[] args) throws IOException {
em.close();
}
}
// random locations
// public static Location randLoc(EntityManager em){
// Long locSize = em.createQuery("select count(l) from Location l", Long.class).getSingleResult();
// Location randLoc = em.createQuery("select l from Location l", Location.class).setFirstResult(randomIndex(locSize)).setMaxResults(1).getSingleResult();
// return randLoc;
// }

//Randomise through all points for continent, country and locations.
//Randomize through all points for continent, country and locations to get a random location. If the country has no locations, loop again until it finds a location.
static public Location randomLocation(EntityManager em){

Long contCount = em.createQuery("Select count(c) from Continent c", Long.class).getSingleResult();
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/example/TravelGameController.java
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,6 @@ private void doContinueJourney(Long travelerId) {
if (!managed.isTravelling() && !wonGame) {
currentPlayerIndex = (currentPlayerIndex + 1) % players.size();
}

syncHudAndMap();
} catch (RuntimeException e) {
if (tx.isActive()) tx.rollback();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/example/player.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ abstract class Player {
private int playerScore = 0;
int credits = 10000;

//Returns the name of the player.
public String getPlayerName() {
return playerName;
}

//Use to get the players current credits.
public int getCredits() {
return credits;
}
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/org/example/playerMovement.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import org.example.GameConfig;
import org.example.GameMode;


public class playerMovement extends Player{
private int dice = 6;
private int walkingDice = 4;
private final int dice = 6;
private final int walkingDice = 4;
private int selectedTransportDice;
private int availableMovement;
private int playerPosX;
Expand Down Expand Up @@ -190,6 +187,7 @@ public void playerTurnGui(int diceAmount) {
System.out.println("End of " + playerName + " GUI turn");
checkIfPlayerHasPenalties();
}

public void playerTurnByMode(List<Transport> transports, int guiDiceAmount) throws IOException {
if (GameConfig.MODE == GameMode.CLI) {
playerTurn(transports);
Expand All @@ -203,7 +201,7 @@ public void chooseTransportation(List<Transport> transport) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

while (true){
System.out.println("Player has " + getCredits() + " credits");
System.out.println("Player: "+playerName+" has " + getCredits() + " credits");
for (int i = 0; i < transport.size(); i++){
System.out.println("Nr " + (i+1) + ": " + transport.get(i).getType() + ". Dice amount: "+ transport.get(i).getDiceCount() + ". Costs: " + transport.get(i).getCostPerMove());
}
Expand Down