Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f5375af7e5 | |||
| d8c276d979 | |||
| aa51b22202 | |||
| 2f0d8e6545 |
@@ -3,13 +3,15 @@ package fr.iut_fbleau.info.but3.automation.rock_paper_scissors.play.domain;
|
|||||||
public enum Move {
|
public enum Move {
|
||||||
ROCK,
|
ROCK,
|
||||||
PAPER,
|
PAPER,
|
||||||
SCISSORS;
|
SCISSORS,
|
||||||
|
PUIT;
|
||||||
|
|
||||||
public boolean beats(Move other) {
|
public boolean beats(Move other) {
|
||||||
return switch (this) {
|
return switch (this) {
|
||||||
case ROCK -> other == SCISSORS;
|
case ROCK -> other == SCISSORS;
|
||||||
case PAPER -> other == ROCK;
|
case PAPER -> other == ROCK || other == PUIT;
|
||||||
case SCISSORS -> other == PAPER;
|
case SCISSORS -> other == PAPER;
|
||||||
|
case PUIT -> other == SCISSORS || other == ROCK;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/play")
|
@RequestMapping("/play")
|
||||||
@Tag(name = "Play", description = "Rock Paper Scissors game endpoints")
|
@Tag(name = "Play", description = "Rock Paper Scissors Puit game endpoints")
|
||||||
public class PlayController {
|
public class PlayController {
|
||||||
|
|
||||||
private final RockPaperScissorsPlay rockPaperScissorsPlay;
|
private final RockPaperScissorsPlay rockPaperScissorsPlay;
|
||||||
@@ -26,7 +26,7 @@ public class PlayController {
|
|||||||
|
|
||||||
@Operation(
|
@Operation(
|
||||||
summary = "Play a round",
|
summary = "Play a round",
|
||||||
description = "Play a round of Rock Paper Scissors against the CPU",
|
description = "Play a round of Rock Paper Scissors PUIT against the CPU",
|
||||||
responses = {
|
responses = {
|
||||||
@ApiResponse(
|
@ApiResponse(
|
||||||
responseCode = "200",
|
responseCode = "200",
|
||||||
|
|||||||
@@ -46,7 +46,9 @@ public class PlayControllerTest {
|
|||||||
public static Stream<Arguments> scenario() {
|
public static Stream<Arguments> scenario() {
|
||||||
return Stream.of(
|
return Stream.of(
|
||||||
Arguments.of(Move.ROCK, Move.SCISSORS, WIN),
|
Arguments.of(Move.ROCK, Move.SCISSORS, WIN),
|
||||||
Arguments.of(Move.ROCK, Move.PAPER, LOOSE)
|
Arguments.of(Move.ROCK, Move.PAPER, LOOSE),
|
||||||
|
Arguments.of(Move.ROCK, Move.PUIT, LOOSE)
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class MoveTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_check_move_size(){
|
void should_check_move_size(){
|
||||||
Assertions.assertEquals(3, Move.values().length);
|
Assertions.assertEquals(4, Move.values().length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest(name = "{0} should beat {1}")
|
@ParameterizedTest(name = "{0} should beat {1}")
|
||||||
@@ -33,7 +33,12 @@ class MoveTest {
|
|||||||
return Stream.of(
|
return Stream.of(
|
||||||
Arguments.of(Move.ROCK,Move.SCISSORS),
|
Arguments.of(Move.ROCK,Move.SCISSORS),
|
||||||
Arguments.of(Move.PAPER,Move.ROCK),
|
Arguments.of(Move.PAPER,Move.ROCK),
|
||||||
Arguments.of(Move.SCISSORS,Move.PAPER)
|
Arguments.of(Move.PAPER,Move.PUIT),
|
||||||
|
Arguments.of(Move.SCISSORS,Move.PAPER),
|
||||||
|
Arguments.of(Move.PUIT,Move.ROCK),
|
||||||
|
Arguments.of(Move.PUIT,Move.SCISSORS)
|
||||||
|
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,11 @@ class RandomCpuPickerTest {
|
|||||||
obtainedMoves.add(picker.pick());
|
obtainedMoves.add(picker.pick());
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(3, obtainedMoves.size());
|
assertEquals(4, obtainedMoves.size());
|
||||||
assertTrue(obtainedMoves.contains(Move.ROCK));
|
assertTrue(obtainedMoves.contains(Move.ROCK));
|
||||||
assertTrue(obtainedMoves.contains(Move.PAPER));
|
assertTrue(obtainedMoves.contains(Move.PAPER));
|
||||||
assertTrue(obtainedMoves.contains(Move.SCISSORS));
|
assertTrue(obtainedMoves.contains(Move.SCISSORS));
|
||||||
|
assertTrue(obtainedMoves.contains(Move.PUIT));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user