Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Corentin GUILLEVIC
Not Alone
Commits
36e2a509
Commit
36e2a509
authored
Dec 16, 2020
by
Killian LUCAS
Browse files
GameTest.java ajout de test
parent
b024c552
Changes
1
Hide whitespace changes
Inline
Side-by-side
not-alone-server/src/test/java/fr/univnantes/alma/server/game/GameTest.java
View file @
36e2a509
...
...
@@ -4,7 +4,9 @@ import fr.univnantes.alma.common.NotAloneDatabase;
import
fr.univnantes.alma.data.DatabaseFactory
;
import
fr.univnantes.alma.server.game.item.Phase
;
import
fr.univnantes.alma.server.game.item.Reserve
;
import
fr.univnantes.alma.server.game.item.action.Action
;
import
fr.univnantes.alma.server.game.item.action.ActionChoosePower
;
import
fr.univnantes.alma.server.game.item.action.ActionTargetPlayer
;
import
fr.univnantes.alma.server.game.item.board.Board
;
import
fr.univnantes.alma.server.game.item.board.BoardColor
;
import
fr.univnantes.alma.server.game.item.board.BoardDistribution
;
...
...
@@ -69,10 +71,10 @@ class GameTest {
final
TrackingCard
angoisse
=
database
.
findTrackingCard
(
ANGOISSE
.
toString
());
final
TrackingCard
mutation
=
database
.
findTrackingCard
(
MUTATION
.
toString
());
final
TrackingCard
flashBack
=
database
.
findTrackingCard
(
FLASHBACK
.
toString
());
final
TrackingCard
anticipation
=
database
.
findTrackingCard
(
ANTICIPATION
.
toString
());
final
TrackingCard
virus
=
database
.
findTrackingCard
(
VIRUS
.
toString
());
final
SurvivalCard
adrenaline
=
database
.
findSurvivalCard
(
ADRENALINE
.
toString
());
final
SurvivalCard
alerte
=
database
.
findSurvivalCard
(
ALERTE
.
toString
());
final
SurvivalCard
sacrifice
=
database
.
findSurvivalCard
(
SACRIFICE
.
toString
());
final
SurvivalCard
vaccin
=
database
.
findSurvivalCard
(
VACCIN
.
toString
());
final
SurvivalCard
sixieme_sens
=
database
.
findSurvivalCard
(
SIXIEME_SENS
.
toString
());
final
SurvivalCard
riposte
=
database
.
findSurvivalCard
(
RIPOSTE
.
toString
());
...
...
@@ -578,6 +580,35 @@ class GameTest {
assertEquals
(
response
.
getCards
(),
game
.
getSurvivalCardPioche
().
getCards
());
}
@Test
void
testGetNumberWillingnessDecrementByJetonCreature_false
()
throws
TException
{
Room
room
=
mock
(
Room
.
class
);
List
<
Pair
<
Integer
,
String
>>
list
=
new
ArrayList
<>(
Arrays
.
asList
(
new
Pair
<>(
1
,
"Nathan"
),
new
Pair
<>(
2
,
"Odile"
)));
Game
game
=
new
Game
(
list
,
1
,
planet
,
board
,
room
);
game
.
getCreature
().
getTrackingCardHand
().
clear
();
game
.
getCreature
().
getTrackingCardHand
().
addAll
(
Arrays
.
asList
(
acharnement
,
mutation
,
virus
));
PowerModifier
powerModifier
=
new
PowerModifier
(
1
,
playableTrackingCard
,
2
);
assertEquals
(
Phase
.
PREPHASE_1
,
game
.
getState
());
game
.
addPowerForNextRound
(
powerModifier
);
//Start phase 1
game
.
startNextPhase
();
//Start postphase 1
game
.
startNextPhase
();
//Start prephase 2
game
.
startNextPhase
();
assertTrue
(
game
.
creatureCanPlayThisTrackingCards
(
game
.
getCreature
(),
acharnement
));
assertTrue
(
game
.
creatureCanPlayThisTrackingCards
(
game
.
getCreature
(),
mutation
));
game
.
creaturePlayTrackingCard
(
game
.
getCreature
(),
acharnement
);
assertEquals
(
2
,
game
.
getNumberWillingnessDecrementByJetonCreature
());
game
.
setNumberWillingnessDecrementByJetonCreature
(
3
);
assertEquals
(
3
,
game
.
getNumberWillingnessDecrementByJetonCreature
());
game
.
setNumberWillingnessDecrementByJetonCreature
(
2
);
assertEquals
(
2
,
game
.
getNumberWillingnessDecrementByJetonCreature
());
}
@Test
void
testPowerScenario_false
()
throws
TException
{
Room
room
=
mock
(
Room
.
class
);
List
<
Pair
<
Integer
,
String
>>
list
=
new
ArrayList
<>(
Arrays
.
asList
(
new
Pair
<>(
1
,
"Nathan"
),
new
Pair
<>(
2
,
"Odile"
)));
...
...
@@ -599,6 +630,8 @@ class GameTest {
assertTrue
(
game
.
creatureCanPlayThisTrackingCards
(
game
.
getCreature
(),
acharnement
));
assertTrue
(
game
.
creatureCanPlayThisTrackingCards
(
game
.
getCreature
(),
mutation
));
game
.
creaturePlayTrackingCard
(
game
.
getCreature
(),
acharnement
);
assertEquals
(
2
,
game
.
getNumberWillingnessDecrementByJetonCreature
());
assertFalse
(
game
.
creatureCanPlayThisTrackingCards
(
game
.
getCreature
(),
mutation
));
//Start Phase 2
game
.
startNextPhase
();
...
...
@@ -646,6 +679,35 @@ class GameTest {
}
@Test
void
testGetIdPlayerTargetByTrackingCardAnticipation
()
throws
TException
{
Room
room
=
mock
(
Room
.
class
);
Game
game
=
new
Game
(
Arrays
.
asList
(
1
,
2
),
1
,
planet
,
board
,
room
);
Board
board
=
game
.
getBoard
();
Action
targetPlayer
=
new
ActionTargetPlayer
(
2
);
game
.
getCreature
().
getTrackingCardHand
().
clear
();
game
.
getCreature
().
getTrackingCardHand
().
addAll
(
Arrays
.
asList
(
anticipation
));
when
(
room
.
askAction
(
any
(
Integer
.
class
),
any
(
TAskAction
.
class
)))
.
thenReturn
(
targetPlayer
);
assertEquals
(
Phase
.
PREPHASE_1
,
game
.
getState
());
assertTrue
(
game
.
playerHasFinished
(
1
,
Phase
.
PREPHASE_1
).
state
);
assertTrue
(
game
.
playerHasFinished
(
2
,
Phase
.
PREPHASE_1
).
state
);
assertTrue
(
game
.
playerHasFinished
(
1
,
Phase
.
PHASE_1
).
state
);
assertTrue
(
game
.
playerPlayCard
(
2
,
Collections
.
singletonList
(
plage
)).
state
);
assertTrue
(
game
.
playerHasFinished
(
2
,
Phase
.
PHASE_1
).
state
);
assertTrue
(
game
.
playerHasFinished
(
1
,
Phase
.
POSTPHASE_1
).
state
);
assertTrue
(
game
.
playerHasFinished
(
2
,
Phase
.
POSTPHASE_1
).
state
);
assertTrue
(
game
.
creatureCanPlayThisTrackingCards
(
game
.
getCreature
(),
anticipation
));
game
.
creaturePlayTrackingCard
(
game
.
getCreature
(),
anticipation
);
assertTrue
(
game
.
playerHasFinished
(
1
,
Phase
.
PREPHASE_2
).
state
);
assertTrue
(
game
.
playerHasFinished
(
2
,
Phase
.
PREPHASE_2
).
state
);
assertTrue
(
game
.
playerPlaceJeton
(
1
,
Collections
.
singletonList
(
new
PlacedJeton
(
JetonSymbol
.
CREATURE
,
Collections
.
singletonList
(
Place
.
PLACE_FOUR
)))).
state
);
assertEquals
(
2
,
game
.
getIdPlayerTargetByTrackingCardAnticipation
());
}
@Test
void
testGameScenario
()
throws
TException
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment