Merge remote-tracking branch 'origin/main'
This commit is contained in:
		
						commit
						1bbb05ebfd
					
				| 
						 | 
				
			
			@ -1,11 +1,10 @@
 | 
			
		|||
package ch.zhaw.catan;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
public class Bank {
 | 
			
		||||
    private HashMap<Config.Resource, Integer> resources = new HashMap<>();
 | 
			
		||||
    private final HashMap<Config.Resource, Integer> resources = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
    public Bank(){
 | 
			
		||||
        resources.putAll(Config.INITIAL_RESOURCE_CARDS_BANK);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
package ch.zhaw.catan;
 | 
			
		||||
 | 
			
		||||
import java.awt.*;
 | 
			
		||||
import java.awt.Point;
 | 
			
		||||
 | 
			
		||||
public class City extends Settlement {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,12 +1,11 @@
 | 
			
		|||
package ch.zhaw.catan;
 | 
			
		||||
 | 
			
		||||
import org.beryx.textio.TextIO;
 | 
			
		||||
 | 
			
		||||
//TODO:JavaDoc
 | 
			
		||||
public enum Command {
 | 
			
		||||
    NEXTPLAYER ("next player"), BUILDSETTLEMENT ("build settlement"), BUILDCITY("build city"),
 | 
			
		||||
    BUILDROAD("build road"), TRADEWITHBANK("trade with bank"),QUIT("quit");
 | 
			
		||||
 | 
			
		||||
    private String commandWord;
 | 
			
		||||
    private final String commandWord;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,58 +0,0 @@
 | 
			
		|||
package ch.zhaw.catan;
 | 
			
		||||
 | 
			
		||||
import ch.zhaw.catan.Config.Land;
 | 
			
		||||
import ch.zhaw.hexboard.Label;
 | 
			
		||||
import java.awt.Point;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import org.beryx.textio.TextIO;
 | 
			
		||||
import org.beryx.textio.TextIoFactory;
 | 
			
		||||
import org.beryx.textio.TextTerminal;
 | 
			
		||||
 | 
			
		||||
public class Dummy {
 | 
			
		||||
 | 
			
		||||
  public enum Actions {
 | 
			
		||||
    SHOW, QUIT
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private void run() {
 | 
			
		||||
    TextIO textIO = TextIoFactory.getTextIO();
 | 
			
		||||
    TextTerminal<?> textTerminal = textIO.getTextTerminal();
 | 
			
		||||
    SiedlerBoard board = new SiedlerBoard();
 | 
			
		||||
    board.addField(new Point(2, 2), Land.FOREST);
 | 
			
		||||
    board.setCorner(new Point(3, 3), new Settlement(Config.Faction.RED,new Point(3, 3)));
 | 
			
		||||
    board.setEdge(new Point(2, 0), new Point(3, 1), new Road(Config.Faction.BLUE,new Point(2, 0),new Point(2, 0)));
 | 
			
		||||
    board.addFieldAnnotation(new Point(2, 2), new Point(3, 1), "AA");
 | 
			
		||||
 | 
			
		||||
    Map<Point, Label> lowerFieldLabel = new HashMap<>();
 | 
			
		||||
    lowerFieldLabel.put(new Point(2, 2), new Label('0', '9'));
 | 
			
		||||
    SiedlerBoardTextView view = new SiedlerBoardTextView(board);
 | 
			
		||||
 | 
			
		||||
    for (Map.Entry<Point, Label> e : lowerFieldLabel.entrySet()) {
 | 
			
		||||
      view.setLowerFieldLabel(e.getKey(), e.getValue());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    boolean running = true;
 | 
			
		||||
    while (running) {
 | 
			
		||||
      switch (getEnumValue(textIO, Actions.class)) {
 | 
			
		||||
        case SHOW:
 | 
			
		||||
          textTerminal.println(view.toString());
 | 
			
		||||
          break;
 | 
			
		||||
        case QUIT:
 | 
			
		||||
          running = false;
 | 
			
		||||
          break;
 | 
			
		||||
        default:
 | 
			
		||||
          throw new IllegalStateException("Internal error found - Command not implemented.");
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    textIO.dispose();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public static <T extends Enum<T>> T getEnumValue(TextIO textIO, Class<T> commands) {
 | 
			
		||||
    return textIO.newEnumInputReader(commands).read("What would you like to do?");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public static void main(String[] args) {
 | 
			
		||||
    new Dummy().run();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -76,7 +76,7 @@ public class Parser {
 | 
			
		|||
     */
 | 
			
		||||
    public HashMap<String, Integer> gameStart() {
 | 
			
		||||
        HashMap<String, Integer> gameStartValues = new HashMap<>();
 | 
			
		||||
        gameStartValues.put("NumberOfPlayers", textIO.newIntInputReader().withMinVal(2).withMaxVal(4).read("Number of players:"));
 | 
			
		||||
        gameStartValues.put("NumberOfPlayers", textIO.newIntInputReader().withMinVal(Config.MIN_NUMBER_OF_PLAYERS).withMaxVal(4).read("Number of players:"));
 | 
			
		||||
        gameStartValues.put("NumberOfWinPoints", textIO.newIntInputReader().withMinVal(5).withMaxVal(15).read("Winpoints needed for Victory:"));
 | 
			
		||||
        return gameStartValues;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
package ch.zhaw.catan;
 | 
			
		||||
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * New Class PLayer
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,10 @@
 | 
			
		|||
package ch.zhaw.catan;
 | 
			
		||||
 | 
			
		||||
import java.awt.*;
 | 
			
		||||
import java.awt.Point;
 | 
			
		||||
 | 
			
		||||
public class Road extends Structure {
 | 
			
		||||
 | 
			
		||||
    private Point start,end;
 | 
			
		||||
    private final Point start,end;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public Road(Config.Faction faction,Point start,Point end) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -35,7 +35,7 @@ public class SiedlerGame {
 | 
			
		|||
     *                                  three or players is not between two and four
 | 
			
		||||
     */
 | 
			
		||||
    public SiedlerGame(int winPoints, int numberOfPlayers) {
 | 
			
		||||
        if(winPoints < 3 || numberOfPlayers < 2 || numberOfPlayers > 4) {
 | 
			
		||||
        if(winPoints < 3 || numberOfPlayers < Config.MIN_NUMBER_OF_PLAYERS || numberOfPlayers > 4) {
 | 
			
		||||
            throw new IllegalArgumentException();
 | 
			
		||||
        }
 | 
			
		||||
        bank = new Bank();
 | 
			
		||||
| 
						 | 
				
			
			@ -246,7 +246,7 @@ public class SiedlerGame {
 | 
			
		|||
                resourceArrayList.add(resource);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        if(resourceArrayList.size() > 7){
 | 
			
		||||
        if(resourceArrayList.size() > Config.MAX_CARDS_IN_HAND_NO_DROP){
 | 
			
		||||
            int resourcesToRemove =resourceArrayList.size() - (resourceArrayList.size() / 2);
 | 
			
		||||
            Random random = new Random();
 | 
			
		||||
            for(int i = 0; i < resourcesToRemove; i++){
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue