Commit ab51c297 authored by Antoine Guérin's avatar Antoine Guérin
parents 927ff3e1 9310d321
package fr.univnantes.alma.game.composant.Pion;
public class Pion {
public abstract class Pion {
protected int position;
......@@ -16,10 +16,6 @@ public class Pion {
this.position = position;
}
public void decrementation(){
this.position--;
}
@Override
public String toString() {
return "Pion{" +
......
package fr.univnantes.alma.game.composant.Pion;
public class PionAssimilation extends Pion{
public PionAssimilation(int position) {
super(position);
}
public void decrementation() {
this.position--;
}
@Override
public String toString() {
return "PionAssimilation{" +
"position=" + super.position +
'}';
}
}
package fr.univnantes.alma.game.composant.Pion;
public class PionSecours extends Pion{
public PionSecours(int position) {
super(position);
}
public void decrementation() {
this.position--;
}
@Override
public String toString() {
return "PionSecours{" +
"position=" + super.position +
'}';
}
}
package fr.univnantes.alma.game.composant;
import fr.univnantes.alma.game.composant.Carte.*;
import fr.univnantes.alma.game.composant.Jeton.Jeton;
import fr.univnantes.alma.game.composant.Jeton.SymboleJeton;
import fr.univnantes.alma.game.composant.Pion.Pion;
import fr.univnantes.alma.game.composant.Pion.PionAssimilation;
import fr.univnantes.alma.game.composant.Pion.PionSecours;
import fr.univnantes.alma.game.database.Lieux.*;
import fr.univnantes.alma.game.database.Survie.*;
import fr.univnantes.alma.game.database.Traque.*;
......@@ -14,12 +18,13 @@ public class Plateau {
private ArrayList<CarteLieu> reserve;
private ArrayList<CarteSurvie> piocheSurvie;
private ArrayList<CarteTraque> piocheTraque;
private Pion pionAssimilation;
private Pion pionSecours;
private PionAssimilation pionAssimilation;
private PionSecours pionSecours;
private ArrayList<Jeton> plateauPion;
public Plateau(int numberPlayer){
//initialisation plateau Creature
this.plateauCarte = new ArrayList<CarteLieu>();
this.plateauCarte = new ArrayList<>();
this.plateauCarte.add(new Antre());
this.plateauCarte.add(new Jungle());
this.plateauCarte.add(new Riviere());
......@@ -122,9 +127,18 @@ public class Plateau {
this.piocheTraque.add(new Virus());
this.piocheTraque.add(new ZoneInterdite());
//Initialisation pion Assimilation
this.pionAssimilation = new Pion(numberPlayer);
this.pionAssimilation = new PionAssimilation(numberPlayer);
//Initialisation pion Secours
this.pionSecours = new Pion(numberPlayer);
this.pionSecours = new PionSecours(19-(7-numberPlayer));
//initialisation plateau de Pion
this.plateauPion = new ArrayList<>();
for(int i = 0; i<19; i++){
if(i<13 || i==19){
this.plateauPion.add(null);
}else{
this.plateauPion.add(13+i, new Jeton(SymboleJeton.ARTEMIA));
}
}
}
public ArrayList<CarteLieu> getPlateauCarte() {
......@@ -143,7 +157,11 @@ public class Plateau {
return piocheTraque;
}
public Pion getPionAssimilation() {
public ArrayList<Jeton> getPlateauPion() {
return plateauPion;
}
public PionAssimilation getPionAssimilation() {
return pionAssimilation;
}
......@@ -151,7 +169,7 @@ public class Plateau {
this.pionAssimilation.setPosition(newPosition);
}
public Pion getPionSecours() {
public PionSecours getPionSecours() {
return pionSecours;
}
......@@ -168,6 +186,7 @@ public class Plateau {
", piocheTraque=" + piocheTraque +
", pionAssimilation=" + pionAssimilation +
", pionSecours=" + pionSecours +
", plateauPion=" + plateauPion +
'}';
}
}
......@@ -8,38 +8,56 @@ public class PionTest {
@Test
public void testGetPosition(){
Pion pion = new Pion(7);
PionAssimilation pion = new PionAssimilation(7);
int nombre = 7;
int nombre2 = 3;
assertEquals(pion.getPosition(), nombre);
assertEquals(nombre, pion.getPosition());
assertNotEquals(nombre2, pion.getPosition());
PionSecours pionS = new PionSecours(7);
assertEquals(nombre, pionS.getPosition());
assertNotEquals(nombre2, pionS.getPosition());
}
@Test
public void testSetPosition(){
Pion pion = new Pion(7);
PionAssimilation pion = new PionAssimilation(7);
pion.setPosition(3);
int nombre = 7;
int nombre2 = 3;
assertEquals(pion.getPosition(), nombre2);
assertNotEquals(nombre, pion.getPosition());
PionSecours pionS = new PionSecours(7);
pionS.setPosition(3);
assertEquals(nombre2, pionS.getPosition());
assertNotEquals(nombre, pionS.getPosition());
}
@Test
public void testDecrementation(){
Pion pion = new Pion(7);
PionAssimilation pion = new PionAssimilation(7);
pion.decrementation();
PionSecours pion2 = new PionSecours(7);
pion2.decrementation();
assertEquals(6, pion.getPosition());
assertEquals(6, pion2.getPosition());
}
@Test
public void testToString(){
Pion pion = new Pion(7);
String message = "Pion{" + "position=" + pion.getPosition() + '}';
PionAssimilation pion = new PionAssimilation(7);
String message = "PionAssimilation{" + "position=" + pion.getPosition() + '}';
assertEquals(message, pion.toString());
PionSecours pion2 = new PionSecours(7);
String message2 = "PionSecours{" + "position=" + pion.getPosition() + '}';
assertEquals(message2, pion2.toString());
}
}
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