Commit 197a2424 authored by Alexandre DESMONTILS's avatar Alexandre DESMONTILS
Browse files

fin de la phase 3 + phase 4 + mise en place

parent e01f4372
......@@ -49,4 +49,6 @@ public interface GameInterface {
String piocherSurvie(int idGame, int id);
void defausserCarteSurvie(int idGame, CarteSurvie carte);
boolean piocherReserve(int idGame, Lieu lieu);
}
......@@ -9,6 +9,7 @@ import fr.univnantes.alma.game.exceptions.TooManyLocationsException;
import fr.univnantes.alma.player.Creature;
import fr.univnantes.alma.player.PlayerProxy;
import fr.univnantes.alma.player.Traque;
import org.apache.http.client.AuthCache;
import org.atlanmod.commons.log.Log;
import java.util.*;
......@@ -62,6 +63,7 @@ public class Game{
private Hashtable<Integer, Traque> listTraque;
private Creature joueurCreature;
private boolean isArtemiaActivated;
private List<Integer> reserve;
//----------------------------------------------------------------------------
......@@ -85,30 +87,13 @@ public class Game{
//les roles demandés par les utilisateurs
this.rolesAsked = new Hashtable<>();
if (expectedPlayers == 7) this.secours = 18;
if (expectedPlayers == 6) this.secours = 17;
if (expectedPlayers == 5) this.secours = 16;
if (expectedPlayers == 4) this.secours = 15;
if (expectedPlayers == 3) this.secours = 14;
if (expectedPlayers == 2) this.secours = 13;
if (expectedPlayers == 7) this.assimilation = 12;
if (expectedPlayers == 6) this.assimilation = 11;
if (expectedPlayers == 5) this.assimilation = 10;
if (expectedPlayers == 4) this.assimilation = 9;
if (expectedPlayers == 3) this.assimilation = 8;
if (expectedPlayers == 2) this.assimilation = 7;
this.piocheSurvie = new Stack<>();
this.piocheTraque = new Stack<>();
this.defausseSurvie = new Stack<>();
this.defausseTraque = new Stack<>();
this.isArtemiaActivated = false;
//remplissage de la pioche survie
this.initPiocheSurvie();
//remplissage de la pioche traque
this.initPiocheTraque();
this.reserve = new ArrayList<>();
play = new Thread(() -> this.start());
play.start();
......@@ -182,7 +167,6 @@ public class Game{
for (PlayerProxy i : players) {
i.askRole();
}
this.distributionDesRoles();
this.miseEnPlace();
while (!this.isFinished()) {
......@@ -229,6 +213,7 @@ public class Game{
}
}
//les effets des jetons dépendent principalement des cartes traques et survie jouées aux phases et tours précédents
//effet du jeton cible en phase 3
private void cibleEffect(int selectedPlayer) {
}
......@@ -282,6 +267,42 @@ public class Game{
}
private void miseEnPlace() {
this.distributionDesRoles();
if (this.expectedPlayers.intValue() == 7) this.secours = 18;
if (this.expectedPlayers.intValue() == 6) this.secours = 17;
if (this.expectedPlayers.intValue() == 5) this.secours = 16;
if (this.expectedPlayers.intValue() == 4) this.secours = 15;
if (this.expectedPlayers.intValue() == 3) this.secours = 14;
if (this.expectedPlayers.intValue() == 2) this.secours = 13;
if (this.expectedPlayers.intValue() == 7) this.assimilation = 12;
if (this.expectedPlayers.intValue() == 6) this.assimilation = 11;
if (this.expectedPlayers.intValue() == 5) this.assimilation = 10;
if (this.expectedPlayers.intValue() == 4) this.assimilation = 9;
if (this.expectedPlayers.intValue() == 3) this.assimilation = 8;
if (this.expectedPlayers.intValue() == 2) this.assimilation = 7;
//remplissage de la pioche survie
this.initPiocheSurvie();
//remplissage de la pioche traque
this.initPiocheTraque();
//mise en place de la réserve de carte lieu en fct des joueurs
int nbExemplaireCarteReserve;
if (listTraque.size() == 1) {
nbExemplaireCarteReserve = 1;
} else {
if (listTraque.size() == 2 || listTraque.size() == 3) {
nbExemplaireCarteReserve = 2;
} else {
nbExemplaireCarteReserve = 3;
}
}
for (int i = 0; i < 5; i++) {
this.reserve.add(i, nbExemplaireCarteReserve);
}
}
......@@ -467,4 +488,12 @@ public class Game{
}
return piocheSurvie.pop().getName();
}
public boolean piocherReserve(Lieu lieu) {
if (reserve.get(lieu.getId()-6) > 0) {
reserve.set(lieu.getId()-6, reserve.get(lieu.getId()-6) - 1);
return true;
}
return false;
}
}
......@@ -113,4 +113,9 @@ public class GameController implements GameInterface {
this.games.get(idGame).defausserCarteSurvie(carte);
}
@Override
public boolean piocherReserve(int idGame, Lieu lieu) {
return this.games.get(idGame).piocherReserve(lieu);
}
}
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