Finished test case throwDice with 7 and TestGameAfterSetupPhase

This commit is contained in:
MikeZyeman 2021-12-10 19:48:17 +01:00
parent 47b5a8b0bb
commit 3049650bc4
1 changed files with 24 additions and 54 deletions

View File

@ -11,15 +11,6 @@ import java.awt.*;
import java.util.*;
import java.util.List;
/***
* TODO Write your own tests in this class.
*
* Note: Have a look at {@link ch.zhaw.catan.games.ThreePlayerStandard}. It can be used
* to get several different game states.
*
*/
/**
* @class SiedlerGameTest
*
@ -101,13 +92,32 @@ public class SiedlerGameTest {
}
/**
* Tests if the method throwDice halves the resources of the player
* 7 will be passed to the throwDice Method when called
*
* Method does not halve a resource, when the amount is below 7.
* Player has gotten 8 wool resources and throws a 7 with the dice
*
* expected: throwDice with a 7 will halve wool resource, the amount should be 4
*/
@Test
@DisplayName("Test")
public void TestHandle7() {
SiedlerGame game = startGame();
//todo
@DisplayName("Test Throw Dice with value 7, expected half the resources")
public void TestThrowDiceWith7() {
SiedlerGame game = gameAfterSetupPhase();
throwDiceSeveralTimes(game, 8, 1);
throwDiceSeveralTimes(game, 7, 1);
Assertions.assertEquals(2, game.getCurrentPlayerResource().get(Config.Resource.WOOL));
throwDiceSeveralTimes(game, 8, 1);
throwDiceSeveralTimes(game, 8, 1);
throwDiceSeveralTimes(game, 8, 1);
Assertions.assertEquals(8, game.getCurrentPlayerResource().get(Config.Resource.WOOL));
throwDiceSeveralTimes(game, 7, 1);
Assertions.assertEquals(4, game.getCurrentPlayerResource().get(Config.Resource.WOOL));
}
}
@ -179,18 +189,6 @@ public class SiedlerGameTest {
Assertions.assertFalse(game.placeInitialSettlement(settlementPoint, false));
}
/**
* This testcase will test, if the methods buildRoad, buildCity buildSettlement are overwritting
* already occupied positions if the same faction or any other faction are calling the method with the same positions
*
* Expected: Method placeInitialRoad placeInitialSettlement should return false, independent of the current faction playing
*/
@Test
@DisplayName("Test buildRoad, buildCity and buildSettlement with already occupied positions")
public void testBuildStructuresOnOccupiedFields() {
}
}
/**
@ -229,24 +227,11 @@ public class SiedlerGameTest {
public void TestGameAfterSetupPhase() {
SiedlerGame game = gameAfterSetupPhase();
//throwDiceSeveralTimes(game, 5, 1);
throwDiceSeveralTimes(game, 8, 1);
getResourceTypeFromField(game.getBoard().getFieldsForDiceValue(8), game.getCurrentPlayerFaction());
//Assertions.assertEquals(game.getCurrentPlayerResource().get(), game.getBoard().getFieldsForDiceValue(8).size());
Assertions.assertEquals(2, game.getCurrentPlayerResourceStock(Config.Resource.WOOL));
}
private void getResourceTypeFromField(List<Point> points, Config.Faction faction) {
SiedlerBoard b = new SiedlerBoard();
for (Point point: points) {
System.out.println(point.toString());
b.getFields(point);
}
}
}
@ -297,24 +282,9 @@ public class SiedlerGameTest {
* @param amountDiceThrows Type int, The amount of dice throws
*/
private static void throwDiceSeveralTimes(SiedlerGame game, int dice, int amountDiceThrows) {
//System.out.println(game.getCurrentPlayerFaction().toString() + " got " + dice + " and throw " + amountDiceThrows + " times");
for (int i = 0; i < amountDiceThrows; i++) {
game.throwDice(dice);
}
}
/**
* This method will setup a game to a state before a player has the points
* for being able to win the game
*
* @return SiedlerGame which is near the
*/
private static SiedlerGame gameNearEnd() {
SiedlerGame game = gameAfterSetupPhase();
return game;
}
}