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
67b7d9ff
Commit
67b7d9ff
authored
Dec 11, 2020
by
Corentin Guillevic
Browse files
Merge branch 'master' of
https://gitlab.univ-nantes.fr/E175362L/projet-2020
parents
7453117d
9c2a0468
Changes
2
Hide whitespace changes
Inline
Side-by-side
not-alone-server/src/test/java/fr/univnantes/alma/server/game/GameTest.java
View file @
67b7d9ff
...
...
@@ -9,6 +9,7 @@ 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
;
import
fr.univnantes.alma.server.game.item.board.Score
;
import
fr.univnantes.alma.server.game.item.card.Card
;
import
fr.univnantes.alma.server.game.item.card.PlaceCard
;
import
fr.univnantes.alma.server.game.item.card.SurvivalCard
;
import
fr.univnantes.alma.server.game.item.card.TrackingCard
;
...
...
@@ -433,12 +434,147 @@ class GameTest {
Board
board
=
game
.
getBoard
();
assertEquals
(
new
Score
(
7
,
13
),
board
.
getScore
());
board
.
moveForwardTraque
(
11
);
board
.
moveForwardCreature
(
6
);
assertEquals
(
new
Score
(
1
,
2
),
board
.
getScore
());
when
(
room
.
askAction
(
any
(
Integer
.
class
),
any
(
TAskAction
.
class
)))
.
thenReturn
(
new
ActionChoosePower
(
0
));
}
@Test
void
testPlayerPlayCard_sendErrorMessage2
()
throws
TException
{
Room
room
=
mock
(
Room
.
class
);
List
<
Pair
<
Integer
,
String
>>
a
=
new
ArrayList
(
Arrays
.
asList
(
new
Pair
(
1
,
"Nathan"
),
new
Pair
(
2
,
"Odile"
)));
Game
game
=
new
Game
(
a
,
1
,
planet
,
board
,
room
);
game
.
getPlanet
().
forceMovePlanetPawn
();
Board
board
=
game
.
getBoard
();
assertEquals
(
new
Score
(
7
,
13
),
board
.
getScore
());
game
.
getTraques
().
get
(
0
).
getSurvivalCardsHand
().
clear
();
game
.
getTraques
().
get
(
0
).
getSurvivalCardsHand
().
add
(
vaccin
);
game
.
getTraques
().
get
(
0
).
getSurvivalCardsHand
().
add
(
sixieme_sens
);
when
(
room
.
askAction
(
any
(
Integer
.
class
),
any
(
TAskAction
.
class
)))
.
thenReturn
(
new
ActionChoosePower
(
0
));
assertTrue
(
game
.
playerHasFinished
(
1
,
Phase
.
PREPHASE_1
).
state
);
assertTrue
(
game
.
playerHasFinished
(
2
,
Phase
.
PREPHASE_1
).
state
);
assertTrue
(
game
.
playerHasFinished
(
1
,
Phase
.
PHASE_1
).
state
);
Response
response
=
new
Response
(
false
,
"Need a place card"
);
assertEquals
(
response
,
game
.
playerPlayCard
(
2
,
vaccin
));
}
@Test
void
testPlayerPlayCard_sendErrorMessage3
()
throws
TException
{
Room
room
=
mock
(
Room
.
class
);
List
<
Pair
<
Integer
,
String
>>
a
=
new
ArrayList
(
Arrays
.
asList
(
new
Pair
(
1
,
"Nathan"
),
new
Pair
(
2
,
"Odile"
)));
Game
game
=
new
Game
(
a
,
1
,
planet
,
board
,
room
);
game
.
getPlanet
().
forceMovePlanetPawn
();
Board
board
=
game
.
getBoard
();
assertEquals
(
new
Score
(
7
,
13
),
board
.
getScore
());
game
.
getCreature
().
getTrackingCardHand
().
clear
();
game
.
getCreature
().
getTrackingCardHand
().
add
(
acharnement
);
game
.
getCreature
().
getTrackingCardHand
().
add
(
mutation
);
when
(
room
.
askAction
(
any
(
Integer
.
class
),
any
(
TAskAction
.
class
)))
.
thenReturn
(
new
ActionChoosePower
(
0
));
assertTrue
(
game
.
playerHasFinished
(
1
,
Phase
.
PREPHASE_1
).
state
);
assertTrue
(
game
.
playerHasFinished
(
2
,
Phase
.
PREPHASE_1
).
state
);
assertTrue
(
game
.
playerHasFinished
(
1
,
Phase
.
PHASE_1
).
state
);
Response
response
=
new
Response
(
false
,
"No card authorize in this phase"
);
assertEquals
(
response
,
game
.
playerPlayCard
(
1
,
acharnement
));
}
@Test
void
testPlayerPlayCard_true
()
throws
TException
{
Room
room
=
mock
(
Room
.
class
);
List
<
Pair
<
Integer
,
String
>>
a
=
new
ArrayList
(
Arrays
.
asList
(
new
Pair
(
1
,
"Nathan"
),
new
Pair
(
2
,
"Odile"
)));
Game
game
=
new
Game
(
a
,
1
,
planet
,
board
,
room
);
game
.
getPlanet
().
forceMovePlanetPawn
();
Board
board
=
game
.
getBoard
();
assertEquals
(
new
Score
(
7
,
13
),
board
.
getScore
());
when
(
room
.
askAction
(
any
(
Integer
.
class
),
any
(
TAskAction
.
class
)))
.
thenReturn
(
new
ActionChoosePower
(
0
));
assertTrue
(
game
.
playerHasFinished
(
1
,
Phase
.
PREPHASE_1
).
state
);
assertTrue
(
game
.
playerHasFinished
(
2
,
Phase
.
PREPHASE_1
).
state
);
assertTrue
(
game
.
playerHasFinished
(
1
,
Phase
.
PHASE_1
).
state
);
Response
response
=
new
Response
(
true
,
""
);
assertEquals
(
response
,
game
.
playerPlayCard
(
2
,
plage
));
assertTrue
(
game
.
playerHasFinished
(
2
,
Phase
.
PHASE_1
).
state
);
}
@Test
void
testPlayerPlayCardList_sendErrorMessage
()
throws
TException
{
Room
room
=
mock
(
Room
.
class
);
List
<
Pair
<
Integer
,
String
>>
a
=
new
ArrayList
(
Arrays
.
asList
(
new
Pair
(
1
,
"Nathan"
),
new
Pair
(
2
,
"Odile"
)));
Game
game
=
new
Game
(
a
,
1
,
planet
,
board
,
room
);
assertEquals
(
new
Score
(
7
,
13
),
board
.
getScore
());
game
.
getTraques
().
get
(
0
).
getSurvivalCardsHand
().
clear
();
game
.
getTraques
().
get
(
0
).
getSurvivalCardsHand
().
add
(
vaccin
);
game
.
getTraques
().
get
(
0
).
getSurvivalCardsHand
().
add
(
sixieme_sens
);
when
(
room
.
askAction
(
any
(
Integer
.
class
),
any
(
TAskAction
.
class
)))
.
thenReturn
(
new
ActionChoosePower
(
0
));
assertTrue
(
game
.
playerHasFinished
(
1
,
Phase
.
PREPHASE_1
).
state
);
assertTrue
(
game
.
playerHasFinished
(
2
,
Phase
.
PREPHASE_1
).
state
);
assertTrue
(
game
.
playerHasFinished
(
1
,
Phase
.
PHASE_1
).
state
);
Response
response
=
new
Response
(
false
,
"Need only place card"
);
assertEquals
(
response
,
game
.
playerPlayCard
(
2
,
new
ArrayList
(
Arrays
.
asList
(
plage
,
vaccin
))));
}
@Test
void
testTraquePlayPlaceCard_sendErrorMessage
()
throws
TException
{
Room
room
=
mock
(
Room
.
class
);
List
<
Pair
<
Integer
,
String
>>
a
=
new
ArrayList
(
Arrays
.
asList
(
new
Pair
(
1
,
"Nathan"
),
new
Pair
(
2
,
"Odile"
)));
Game
game
=
new
Game
(
a
,
1
,
planet
,
board
,
room
);
assertEquals
(
new
Score
(
7
,
13
),
board
.
getScore
());
game
.
getTraques
().
get
(
0
).
getSurvivalCardsHand
().
clear
();
game
.
getTraques
().
get
(
0
).
getSurvivalCardsHand
().
add
(
vaccin
);
game
.
getTraques
().
get
(
0
).
getSurvivalCardsHand
().
add
(
sixieme_sens
);
when
(
room
.
askAction
(
any
(
Integer
.
class
),
any
(
TAskAction
.
class
)))
.
thenReturn
(
new
ActionChoosePower
(
0
));
assertTrue
(
game
.
playerHasFinished
(
1
,
Phase
.
PREPHASE_1
).
state
);
assertTrue
(
game
.
playerHasFinished
(
2
,
Phase
.
PREPHASE_1
).
state
);
assertTrue
(
game
.
playerHasFinished
(
1
,
Phase
.
PHASE_1
).
state
);
Response
response
=
new
Response
(
false
,
"Unable to play this card"
);
game
.
traquePlayPlaceCard
(
game
.
getTraques
().
get
(
0
),
plage
);
assertEquals
(
response
,
game
.
traquePlayPlaceCard
(
game
.
getTraques
().
get
(
0
),
riviere
));
}
}
...
...
@@ -462,7 +598,6 @@ class GameTest {
assertEquals(game.getState(), Phase.PREPHASE_1);
assertTrue(game.playerHasFinished(1, Phase.PREPHASE_1).state);
assertTrue(game.playerHasFinished(2, Phase.PREPHASE_1).state);
assertEquals(game.getState(), Phase.PHASE_1);
assertTrue(game.playerHasFinished(1, Phase.PHASE_1).state);
assertTrue(game.playerPlayCard(2, Collections.singletonList(plage)).state);
assertTrue(game.playerHasFinished(2, Phase.PHASE_1).state);
...
...
not-alone-server/src/test/java/fr/univnantes/alma/server/game/item/player/hand/HandCreatureTest.java
View file @
67b7d9ff
package
fr.univnantes.alma.server.game.item.player.hand
;
import
fr.univnantes.alma.server.game.item.Phase
;
import
fr.univnantes.alma.server.game.item.card.CardName
;
import
fr.univnantes.alma.server.game.item.card.TrackingCard
;
import
org.junit.jupiter.api.Test
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertFalse
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
fr.univnantes.alma.server.game.item.jeton.JetonSymbol
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
class
HandCreatureTest
{
/*
HandCreature
hand
=
new
HandCreature
();
@Test
public
void
testInitializationJeton
(){
Jeton j1 = new JetonArtemia();
Jeton j2 = new JetonCreature();
Jeton j3 = new JetonCible();
hand.initializationJeton();
assertTrue(hand.getJetons().contains(j1));
assertTrue(hand.getJetons().contains(j2));
assertTrue(hand.getJetons().contains(j3));
assertTrue
(
hand
.
getJetonSymbols
().
contains
(
JetonSymbol
.
ARTEMIA
));
assertTrue
(
hand
.
getJetonSymbols
().
contains
(
JetonSymbol
.
CREATURE
));
assertTrue
(
hand
.
getJetonSymbols
().
contains
(
JetonSymbol
.
CIBLE
));
assertTrue
(
hand
.
getJetonSymbolsPlayed
().
isEmpty
());
}
@Test
public
void
testAddTrackingCardToApplied
(){
TrackingCard
card
=
new
TrackingCard
(
CardName
.
INTERFERENCES
,
"InterferenceCard"
,
"The powers of the Beach and the Wreck are ineffective"
,
Phase
.
PHASE_2
);
hand
.
addTrackingCardToApplied
(
card
);
assertTrue
(
hand
.
getTrackingCardToApplied
().
contains
(
card
));
}
@Test
public
void
testAddTrackingCardToAppliedList
(){
TrackingCard
card
=
new
TrackingCard
(
CardName
.
INTERFERENCES
,
"InterferenceCard"
,
"The powers of the Beach and the Wreck are ineffective"
,
Phase
.
PHASE_2
);
List
<
TrackingCard
>
testCards
=
new
ArrayList
<>();
testCards
.
add
(
card
);
hand
.
addTrackingCardToApplied
(
testCards
);
assertTrue
(
hand
.
getTrackingCardToApplied
().
containsAll
(
testCards
));
}
@Test
public
void
testRemoveTrackingCardToApplied
(){
TrackingCard
card
=
new
TrackingCard
(
CardName
.
INTERFERENCES
,
"InterferenceCard"
,
"The powers of the Beach and the Wreck are ineffective"
,
Phase
.
PHASE_2
);
hand
.
addTrackingCardToApplied
(
card
);
hand
.
removeTrackingCardToApplied
(
card
);
assertFalse
(
hand
.
getTrackingCardToApplied
().
contains
(
card
));
}
@Test
public
void
testRemoveTrackingCardToAppliedList
(){
TrackingCard
card
=
new
TrackingCard
(
CardName
.
INTERFERENCES
,
"InterferenceCard"
,
"The powers of the Beach and the Wreck are ineffective"
,
Phase
.
PHASE_2
);
List
<
TrackingCard
>
testCards
=
new
ArrayList
<>();
testCards
.
add
(
card
);
hand
.
addTrackingCardToApplied
(
testCards
);
hand
.
removeTrackingCardToApplied
(
testCards
);
assertFalse
(
hand
.
getTrackingCardToApplied
().
containsAll
(
testCards
));
}
@Test
public
void
testGetTrackingCardToApplied
(){
assertEquals
(
hand
.
getTrackingCardToApplied
(),
new
ArrayList
<>());
}
@Test
public
void
testGetJetonSymbolsPlayed
(){
assertEquals
(
hand
.
getJetonSymbolsPlayed
(),
new
ArrayList
<>());
}
@Test
public
void
testGetJetonSymbols
(){
assertEquals
(
hand
.
getJetonSymbols
(),
new
ArrayList
<>(
Arrays
.
asList
(
JetonSymbol
.
CIBLE
,
JetonSymbol
.
CREATURE
,
JetonSymbol
.
ARTEMIA
)));
}
@Test
public
void
testPlayJeton
(){
Jeton j1 = new JetonArtemia();
hand.getJetons().add(j1);
Jeton result = hand.playJeton(j1);
assertFalse(hand.getJetons().contains(j1));
JetonSymbol
j1
=
JetonSymbol
.
ARTEMIA
;
boolean
result
=
hand
.
playJeton
(
j1
);
assertTrue
(
result
);
assertFalse
(
hand
.
getJetonSymbols
().
contains
(
j1
));
assertTrue
(
hand
.
getJetonSymbolsPlayed
().
contains
(
j1
));
}
@Test
public void testPlayJeton
Se
t(){
Jeton j1 =
new
Jeton
Artemia()
;
Se
t<Jeton> testjetons = new
HashSe
t<>();
public
void
testPlayJeton
Lis
t
(){
Jeton
Symbol
j1
=
Jeton
Symbol
.
ARTEMIA
;
Lis
t
<
Jeton
Symbol
>
testjetons
=
new
ArrayLis
t
<>();
testjetons
.
add
(
j1
);
hand.getJetons().add(j1);
Set<Jeton> result = hand.playJeton(testjetons);
assertFalse(hand.getJetons().containsAll(testjetons));
hand
.
getJetonSymbols
().
add
(
j1
);
boolean
result
=
hand
.
playJeton
(
testjetons
);
assertTrue
(
result
);
assertFalse
(
hand
.
getJetonSymbols
().
containsAll
(
testjetons
));
assertTrue
(
hand
.
getJetonSymbolsPlayed
().
containsAll
(
testjetons
));
}
@Test
public
void
testJetonSize
(){
assertEquals
(
3
,
hand
.
jetonsSize
());
}
@Test
public
void
testJetonsPlayedSize
(){
assertEquals
(
0
,
hand
.
jetonsPlayedSize
());
}
@Test
public
void
testJetonsIsEmpty
(){
assertFalse
(
hand
.
jetonsIsEmpty
());
}
@Test
public
void
testJetonsPlayedIsEmpty
(){
assertTrue
(
hand
.
jetonsPlayedIsEmpty
());
}
*/
@Test
public
void
testGetMaxTrackingCards
(){
assertEquals
(
3
,
hand
.
getMaxTrackingCards
());
}
@Test
public
void
testTrackingCardHandSize
(){
assertEquals
(
0
,
hand
.
trackingCardHandSize
());
}
@Test
public
void
testTrackingCardPlayedSize
(){
assertEquals
(
0
,
hand
.
trackingCardPlayedSize
());
}
@Test
public
void
testTrackingCardHandIsEmpty
(){
assertTrue
(
hand
.
trackingCardIsEmpty
());
}
@Test
public
void
testTrackingCardHandPlayedIsEmpty
(){
assertTrue
(
hand
.
trackingCardPlayedIsEmpty
());
}
@Test
public
void
testClearTrackingCardPlayed
(){
TrackingCard
card
=
new
TrackingCard
(
CardName
.
INTERFERENCES
,
"InterferenceCard"
,
"The powers of the Beach and the Wreck are ineffective"
,
Phase
.
PHASE_2
);
hand
.
addTrackingCard
(
card
);
hand
.
playTrackingCard
(
card
);
hand
.
clearTrackingCardPlayed
();
assertTrue
(
hand
.
trackingCardPlayedIsEmpty
());
}
@Test
public
void
testAddTrackingCard
(){
TrackingCard
card
=
new
TrackingCard
(
CardName
.
INTERFERENCES
,
"InterferenceCard"
,
"The powers of the Beach and the Wreck are ineffective"
,
Phase
.
PHASE_2
);
hand
.
addTrackingCard
(
card
);
assertTrue
(
hand
.
getTrackingCardHand
().
contains
(
card
));
}
@Test
public
void
testAddTrackingCardList
(){
TrackingCard
card
=
new
TrackingCard
(
CardName
.
INTERFERENCES
,
"InterferenceCard"
,
"The powers of the Beach and the Wreck are ineffective"
,
Phase
.
PHASE_2
);
List
<
TrackingCard
>
testCards
=
new
ArrayList
<>();
testCards
.
add
(
card
);
hand
.
addTrackingCard
(
testCards
);
assertTrue
(
hand
.
getTrackingCardHand
().
containsAll
(
testCards
));
}
@Test
public
void
testRemoveTrackingCard
(){
TrackingCard
card
=
new
TrackingCard
(
CardName
.
INTERFERENCES
,
"InterferenceCard"
,
"The powers of the Beach and the Wreck are ineffective"
,
Phase
.
PHASE_2
);
hand
.
addTrackingCard
(
card
);
hand
.
removeTrackingCard
(
card
);
assertFalse
(
hand
.
getTrackingCardHand
().
contains
(
card
));
}
@Test
public
void
testRemoveTrackingCardList
(){
TrackingCard
card
=
new
TrackingCard
(
CardName
.
INTERFERENCES
,
"InterferenceCard"
,
"The powers of the Beach and the Wreck are ineffective"
,
Phase
.
PHASE_2
);
List
<
TrackingCard
>
testCards
=
new
ArrayList
<>();
testCards
.
add
(
card
);
hand
.
addTrackingCard
(
testCards
);
hand
.
removeTrackingCard
(
testCards
);
assertFalse
(
hand
.
getTrackingCardHand
().
containsAll
(
testCards
));
}
@Test
public
void
testPlayTrackingCard
(){
TrackingCard
card
=
new
TrackingCard
(
CardName
.
INTERFERENCES
,
"InterferenceCard"
,
"The powers of the Beach and the Wreck are ineffective"
,
Phase
.
PHASE_2
);
hand
.
addTrackingCard
(
card
);
assertTrue
(
hand
.
playTrackingCard
(
card
));
assertFalse
(
hand
.
getTrackingCardHand
().
contains
(
card
));
assertTrue
(
hand
.
getTrackingCardsPlayed
().
contains
(
card
));
}
@Test
public
void
testPlayTrackingCardList
(){
TrackingCard
card
=
new
TrackingCard
(
CardName
.
INTERFERENCES
,
"InterferenceCard"
,
"The powers of the Beach and the Wreck are ineffective"
,
Phase
.
PHASE_2
);
List
<
TrackingCard
>
testCards
=
new
ArrayList
<>();
testCards
.
add
(
card
);
hand
.
addTrackingCard
(
testCards
);
assertTrue
(
hand
.
playTrackingCard
(
testCards
));
assertFalse
(
hand
.
getTrackingCardHand
().
containsAll
(
testCards
));
assertTrue
(
hand
.
getTrackingCardsPlayed
().
containsAll
(
testCards
));
}
}
\ No newline at end of file
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