Added methods as setup and new datafields for test cases
This commit is contained in:
		
							parent
							
								
									666f324fb2
								
							
						
					
					
						commit
						51defac6f3
					
				| 
						 | 
				
			
			@ -32,6 +32,23 @@ public class SiedlerGameTest {
 | 
			
		|||
    private final static int DEFAULT_WINPOINTS = 10;
 | 
			
		||||
    private final static int DEFAULT_PLAYERAMOUNT = 4;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    private final static Map<Config.Faction, Point> START_SETTLEMENT_POSITIONS = new HashMap<>(
 | 
			
		||||
            Map.of(
 | 
			
		||||
                    Config.Faction.BLUE, new Point(5, 7),
 | 
			
		||||
                    Config.Faction.RED, new Point(1, 3),
 | 
			
		||||
                    Config.Faction.GREEN, new Point(11, 13),
 | 
			
		||||
                    Config.Faction.YELLOW, new Point(13, 5)
 | 
			
		||||
            ));
 | 
			
		||||
 | 
			
		||||
    private final static Map<Config.Faction, Tuple<Point, Point>> START_ROADS_POSITIONS = new HashMap<>(
 | 
			
		||||
            Map.of(
 | 
			
		||||
                    Config.Faction.BLUE, new Tuple<>(new Point(5, 6), new Point(5, 6)),
 | 
			
		||||
                    Config.Faction.RED, new Tuple<>(new Point(1, 2), new Point(1, 1)),
 | 
			
		||||
                    Config.Faction.GREEN, new Tuple<>(new Point(12, 12), new Point(13, 11)),
 | 
			
		||||
                    Config.Faction.YELLOW, new Tuple<>(new Point(13, 6), new Point(13, 7))
 | 
			
		||||
            ));
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * To Test getLongestRoad in SiedlerGame isolatet do:
 | 
			
		||||
     * 1. make SiedlerGame.getLongestRoadFaction, Siedlergame.countRoad && Siedlergame.getNextPoint static
 | 
			
		||||
| 
						 | 
				
			
			@ -103,7 +120,7 @@ public class SiedlerGameTest {
 | 
			
		|||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void TestGameInSetupPhase() {
 | 
			
		||||
        SiedlerGame game = new SiedlerGame(DEFAULT_WINPOINTS, DEFAULT_PLAYERAMOUNT);
 | 
			
		||||
        SiedlerGame game = startGame();
 | 
			
		||||
 | 
			
		||||
        for (Config.Faction faction: game.getPlayerFactions()) {
 | 
			
		||||
            HashMap<Config.Resource, Integer> resources = game.getCurrentPlayerResource();
 | 
			
		||||
| 
						 | 
				
			
			@ -120,14 +137,14 @@ public class SiedlerGameTest {
 | 
			
		|||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void TestGameAfterSetupPhase() {
 | 
			
		||||
        SiedlerGame game = new SiedlerGame(DEFAULT_WINPOINTS, DEFAULT_PLAYERAMOUNT);
 | 
			
		||||
        SiedlerGame game = gameAfterSetupPhase();
 | 
			
		||||
 | 
			
		||||
        throwDiceSeveralTimes(game, 5, 5);
 | 
			
		||||
 | 
			
		||||
        System.out.println("\n\nVerteilung \n\n");
 | 
			
		||||
        for (Config.Faction faction: game.getPlayerFactions()) {
 | 
			
		||||
            HashMap<Config.Resource, Integer> resources = game.getCurrentPlayerResource();
 | 
			
		||||
            System.out.printf(faction.toString() + "\n");
 | 
			
		||||
            System.out.println(faction.toString() + "\n");
 | 
			
		||||
            System.out.println(" BRICK " + resources.get(Config.Resource.BRICK).toString());
 | 
			
		||||
            System.out.println(" GRAIN " + resources.get(Config.Resource.GRAIN));
 | 
			
		||||
            System.out.println(" LUMBER " + resources.get(Config.Resource.LUMBER));
 | 
			
		||||
| 
						 | 
				
			
			@ -138,12 +155,15 @@ public class SiedlerGameTest {
 | 
			
		|||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void TestGameInMiddle() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private SiedlerGame startGame() {
 | 
			
		||||
        return new SiedlerGame(DEFAULT_WINPOINTS, DEFAULT_PLAYERAMOUNT);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void throwDiceSeveralTimes(SiedlerGame game, int dice, int amountDiceThrows) {
 | 
			
		||||
        for (int i = 0; i < amountDiceThrows; i++) {
 | 
			
		||||
            System.out.println(game.getCurrentPlayerFaction().toString());
 | 
			
		||||
| 
						 | 
				
			
			@ -152,10 +172,14 @@ public class SiedlerGameTest {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    private SiedlerGame gameAfterSetupPhase() {
 | 
			
		||||
        SiedlerGame game = new SiedlerGame(DEFAULT_WINPOINTS, DEFAULT_PLAYERAMOUNT);
 | 
			
		||||
        SiedlerGame game = startGame();
 | 
			
		||||
 | 
			
		||||
        for (Config.Faction faction: game.getPlayerFactions()) {
 | 
			
		||||
 | 
			
		||||
            game.buildSettlement(START_SETTLEMENT_POSITIONS.get(faction));
 | 
			
		||||
            game.buildRoad(START_ROADS_POSITIONS.get(faction).first, START_ROADS_POSITIONS.get(faction).second);
 | 
			
		||||
 | 
			
		||||
            game.switchToNextPlayer();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return game;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue