parent
eeaf1225de
commit
76623aa66f
|
|
@ -1,4 +1,16 @@
|
||||||
package domain;
|
package domain;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class Dice {
|
public class Dice {
|
||||||
|
private int amountSides;
|
||||||
|
|
||||||
|
public Dice(int amountSides){
|
||||||
|
this.amountSides = amountSides;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int roll(){
|
||||||
|
Random rand = new Random();
|
||||||
|
return (rand.nextInt(amountSides) + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,25 @@ package domain;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Game {
|
public class Game {
|
||||||
ArrayList<Player> currentPlayers;
|
private ArrayList<Player> currentPlayers;
|
||||||
|
private int turnPlayer;
|
||||||
|
private Dice dice;
|
||||||
|
|
||||||
public Game(){
|
public Game(){
|
||||||
currentPlayers = new ArrayList<Player>();
|
currentPlayers = new ArrayList<Player>();
|
||||||
|
turnPlayer = 0;
|
||||||
|
dice = new Dice(6);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int rollDice(){
|
||||||
|
return dice.roll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPlayer(Player playerToAdd){
|
public void addPlayer(Player playerToAdd){
|
||||||
currentPlayers.add(playerToAdd);
|
currentPlayers.add(playerToAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<Player> getPlayers(){
|
||||||
|
return currentPlayers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,6 @@ public class Player {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String ANSI_RESET = "\u001B[0m";
|
String ANSI_RESET = "\u001B[0m";
|
||||||
String coloredName = String.format(this.color + this.name + ANSI_RESET);
|
String coloredName = String.format(this.color + this.name + ANSI_RESET);
|
||||||
return String.format("Name: %s, Colored name: %s \n", this.name, coloredName);
|
return String.format("Player %d: %s", this.playerNumber, coloredName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
package domain;
|
||||||
|
|
||||||
|
public class Sheet {
|
||||||
|
String[] usedRows;
|
||||||
|
String[] canceledRows;
|
||||||
|
String[] emptyRows;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package fassade;
|
||||||
|
|
||||||
|
public class GameCycle {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -21,8 +21,8 @@ public class KniffelSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String scorebaordData(){
|
public String LeaderBaordData(){
|
||||||
return "Scoreboard - TODO";
|
return "Leaderboard - TODO \n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -51,4 +51,31 @@ public class KniffelSystem {
|
||||||
int randomIndex = rand.nextInt(playerColors.size()); //
|
int randomIndex = rand.nextInt(playerColors.size()); //
|
||||||
return playerColors.remove(randomIndex); // Quelle 1 Ende
|
return playerColors.remove(randomIndex); // Quelle 1 Ende
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void createTestPlayers(int amountPlayer){
|
||||||
|
String[] names = {"Vic", "Natja", "Lilli", "Emelie", "Esra", "Oli"};
|
||||||
|
for (int i = 0; i < amountPlayer; i++){
|
||||||
|
addPlayer(i+1, names[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void rollDice(int amountRolls){
|
||||||
|
for (int i = 0; i < amountRolls; i++){
|
||||||
|
System.out.println(game.rollDice());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TEST
|
||||||
|
public String[] getAllPlayerStrings(){
|
||||||
|
ArrayList<Player> players = game.getPlayers();
|
||||||
|
String[] returnStrings = new String[players.size()];
|
||||||
|
|
||||||
|
for (int i = 0; i < players.size(); i++){
|
||||||
|
returnStrings[i] = players.get(i).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnStrings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
36
tui/TUI.java
36
tui/TUI.java
|
|
@ -10,15 +10,21 @@ public class TUI {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println("Welcome to the PR2 Kniffel game!");
|
System.out.println("Welcome to the PR2 Kniffel game!");
|
||||||
while (true){
|
|
||||||
mainMenuOutput();
|
// while (true){
|
||||||
}
|
// mainMenuOutput();
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// DEV:
|
||||||
|
gameSystem = new KniffelSystem();
|
||||||
|
gameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int mainMenuOutput(){
|
private static int mainMenuOutput(){
|
||||||
System.out.println("What do you want to do?");
|
System.out.println("What do you want to do?");
|
||||||
System.out.println("1 - Play");
|
System.out.println("1 - Play");
|
||||||
System.out.println("2 - See scoreboard");
|
System.out.println("2 - See leaderboard");
|
||||||
System.out.println("3 - Exit");
|
System.out.println("3 - Exit");
|
||||||
System.out.print("> ");
|
System.out.print("> ");
|
||||||
String mainMenuUserInput = sc.nextLine().toLowerCase();
|
String mainMenuUserInput = sc.nextLine().toLowerCase();
|
||||||
|
|
@ -31,10 +37,11 @@ public class TUI {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if ((mainMenuUserInput.equals("2"))
|
else if ((mainMenuUserInput.equals("2"))
|
||||||
|| (mainMenuUserInput.equals("see scoreboard"))
|
|| (mainMenuUserInput.equals("see leaderboard"))
|
||||||
|| (mainMenuUserInput.equals("see"))
|
|| (mainMenuUserInput.equals("see"))
|
||||||
|| (mainMenuUserInput.equals("scoreboard"))){
|
|| (mainMenuUserInput.equals("leaderboard"))){
|
||||||
System.out.println("scoreboard"); // TEST
|
System.out.println("leaderboard"); // TEST
|
||||||
|
mainMenuLeaderBoard();
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -52,6 +59,7 @@ public class TUI {
|
||||||
String mainMenuPlayAmountPlayersInput = sc.nextLine().toLowerCase();
|
String mainMenuPlayAmountPlayersInput = sc.nextLine().toLowerCase();
|
||||||
|
|
||||||
int amountPlayers = Integer.parseInt(mainMenuPlayAmountPlayersInput);
|
int amountPlayers = Integer.parseInt(mainMenuPlayAmountPlayersInput);
|
||||||
|
|
||||||
for (int i = 0; i < amountPlayers; i++){
|
for (int i = 0; i < amountPlayers; i++){
|
||||||
System.out.printf("Player %d: ", i + 1);
|
System.out.printf("Player %d: ", i + 1);
|
||||||
System.out.println("Enter your name: ");
|
System.out.println("Enter your name: ");
|
||||||
|
|
@ -63,8 +71,20 @@ public class TUI {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void mainMenuScoreboard(){
|
private static void gameLoop(){
|
||||||
|
gameSystem.createTestPlayers(6);
|
||||||
|
String[] playerStrings = gameSystem.getAllPlayerStrings();
|
||||||
|
|
||||||
|
for (String player : playerStrings){
|
||||||
|
System.out.println(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
gameSystem.rollDice(40);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void mainMenuLeaderBoard(){
|
||||||
|
gameSystem = new KniffelSystem(); // Scorboard System
|
||||||
|
System.out.println(gameSystem.LeaderBaordData()); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void mainMenuExit(){
|
private static void mainMenuExit(){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue