Commit 52c6a880 authored by Thomas DENIS's avatar Thomas DENIS
Browse files

Merge remote-tracking branch 'origin/master'

parents 4c252752 000a01d9
...@@ -185,7 +185,7 @@ public class Game implements GameInterface { ...@@ -185,7 +185,7 @@ public class Game implements GameInterface {
this.playersMap.put(pair.getKey(), traque); this.playersMap.put(pair.getKey(), traque);
} }
else { else {
this.creature = new Creature("Player" + creatureId, creatureId); this.creature = new Creature(pair.getValue(), pair.getKey());
this.playersMap.put(creatureId, this.creature); this.playersMap.put(creatureId, this.creature);
} }
} }
...@@ -815,7 +815,7 @@ public class Game implements GameInterface { ...@@ -815,7 +815,7 @@ public class Game implements GameInterface {
canPlay = false; canPlay = false;
} }
} }
canPlay = canPlay && creature.getHand().trackingCardPlayedSize() + toPlay.size() > creature.getMaxTrackingCardPlayable(); canPlay = canPlay && creature.getHand().trackingCardPlayedSize() + toPlay.size() <= creature.getMaxTrackingCardPlayable();
return canPlay && creature.getTrackingCardHand().containsAll(toPlay); return canPlay && creature.getTrackingCardHand().containsAll(toPlay);
} }
......
...@@ -8,7 +8,7 @@ import javassist.NotFoundException; ...@@ -8,7 +8,7 @@ import javassist.NotFoundException;
import java.util.*; import java.util.*;
public class Reserve { public class Reserve {
private Map<Integer, Pair<PlaceCard, Integer>> placeCards; private final Map<Integer, Pair<PlaceCard, Integer>> placeCards;
public Reserve(List<PlaceCard> cards, int playerNumber) { public Reserve(List<PlaceCard> cards, int playerNumber) {
placeCards = new HashMap<>(); placeCards = new HashMap<>();
...@@ -112,10 +112,40 @@ public class Reserve { ...@@ -112,10 +112,40 @@ public class Reserve {
public void add(PlaceCard placeCard) { public void add(PlaceCard placeCard) {
int cardNumber = placeCard.getNumber(); int cardNumber = placeCard.getNumber();
if(cardNumber<= 5 && cardNumber > 10) { if(cardNumber<= 5 || cardNumber > 10) {
throw new IllegalArgumentException("PlaceCard in reserve are place cards 6 to 10"); throw new IllegalArgumentException("PlaceCard in reserve are place cards 6 to 10");
} }
int number = placeCards.get(cardNumber).getValue() + 1; int number = placeCards.get(cardNumber).getValue() + 1;
placeCards.put(cardNumber, new Pair<>(placeCard, number)); placeCards.put(cardNumber, new Pair<>(placeCard, number));
} }
@Override
public boolean equals(Object obj) {
if(obj == this){
return true;
}
if(obj == null || ! (obj instanceof Reserve)){
return false;
}
System.out.println("ok");
Reserve reserve = (Reserve) obj;
return placeCards.equals(reserve.getPlaceCards());
}
@Override
public String toString() {
String res = "Reserve(";
Iterator<Map.Entry<Integer, Pair<PlaceCard, Integer>>> iterator = placeCards.entrySet().iterator();
Map.Entry<Integer, Pair<PlaceCard, Integer>> aux;
while (iterator.hasNext()) {
aux = iterator.next();
res += aux.getValue().getKey() + "(" + aux.getValue().getValue() + ")";
if(iterator.hasNext()) {
res += ", ";
}
}
res += ")";
return res;
}
} }
package fr.univnantes.alma.server.game; package fr.univnantes.alma.server.game;
import fr.univnantes.alma.server.game.item.Phase; import fr.univnantes.alma.server.game.item.Phase;
import fr.univnantes.alma.server.game.item.board.Board;
import fr.univnantes.alma.server.game.utilitary.request.*; import fr.univnantes.alma.server.game.utilitary.request.*;
import fr.univnantes.alma.server.user.User; import fr.univnantes.alma.server.user.User;
import fr.univnantes.alma.thrift.GameNotFound; import fr.univnantes.alma.thrift.GameNotFound;
import fr.univnantes.alma.thrift.InvalidOperationException; import fr.univnantes.alma.thrift.InvalidOperationException;
import fr.univnantes.alma.thrift.Response; import fr.univnantes.alma.thrift.Response;
import org.checkerframework.checker.units.qual.A;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
...@@ -42,7 +40,7 @@ class RoomServiceControllerTest { ...@@ -42,7 +40,7 @@ class RoomServiceControllerTest {
} }
@Test @Test
void testAddRoom_alreadyExist() throws InvalidOperationException { void testAddRoom_alreadyExist() {
Room room = mock(Room.class); Room room = mock(Room.class);
when(room.getRoomId()).thenReturn("900"); when(room.getRoomId()).thenReturn("900");
assertFalse(roomServiceController.addRoom(room)); assertFalse(roomServiceController.addRoom(room));
...@@ -93,7 +91,7 @@ class RoomServiceControllerTest { ...@@ -93,7 +91,7 @@ class RoomServiceControllerTest {
} }
@Test @Test
void testStartGame_playerNotInARoom() throws GameNotFound { void testStartGame_playerNotInARoom() {
Response response = roomServiceController.startGame(user1, 1, null, null); Response response = roomServiceController.startGame(user1, 1, null, null);
assertEquals(new Response(false, "Player is not in a room"), response); assertEquals(new Response(false, "Player is not in a room"), response);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment