Commit 5cd76d74 authored by Mamadou Diallo's avatar Mamadou Diallo

Ajout du plateau et cases + quelques implémentations de fonctions

parent b8ae4126
package fr.univnantes.alma.model.board;
import java.util.ArrayList;
import java.util.List;
public class Board {
private int nbLines;
private int nbColumns;
private List<Box> boxes;
public Board(int nbLines, int nbColumns) {
this.nbLines = nbLines;
this.nbColumns = nbColumns;
boxes = new ArrayList<>();
this.initBoard();
}
public int getNbLines() {
return nbLines;
}
public int getNbColumns() {
return nbColumns;
}
public List<Box> getBoxes() {
return boxes;
}
public void initBoard(){
for (int i = 0; i<this.nbLines; i++){
for(int j=0; j<this.nbColumns; j++){
Box box = new Box(i, j);
this.boxes.add(box);
}
}
}
}
package fr.univnantes.alma.model.board;
/**
* Une case sur le plateau
*/
public class Box {
private int line;
private int column;
public Box(int line, int column) {
this.line = line;
this.column = column;
}
public int getLine() {
return line;
}
public int getColumn() {
return column;
}
}
......@@ -7,36 +7,33 @@ import fr.univnantes.alma.model.utlis.Phase;
import java.util.UUID;
public abstract class Card implements CardInterface {
private Object title;
private Phase phase;
private Object name;
private String description;
private UUID id;
private boolean power;
public Card(Object title, Phase phase) {
this.title = title;
this.phase = phase;
public Card(Object title) {
this.name = title;
this.power = false;
this.description = this.addDescription(title);
this.id = this.generateId();
//this.id = this.generateId();
}
public UUID generateId(){
UUID uniqID = UUID.randomUUID();
return uniqID;
}
@Override
public UUID getId() {
return id;
public boolean getPower(){
return this.power;
}
@Override
public Object getTitle() {
return title;
public void setPower(boolean power){
this.power = power;
}
@Override
public Phase getPhase() {
return phase;
public Object getName() {
return name;
}
@Override
public String getDescription() {
return description;
......@@ -44,7 +41,7 @@ public abstract class Card implements CardInterface {
@Override
public String toString(){
return "["+this.title+"\n"+this.description+"\n"+this.phase+"]";
return "["+this.name +"\n"+this.description+"]";
}
public abstract String addDescription(Object cardTitle);
......
package fr.univnantes.alma.model.cards;
import fr.univnantes.alma.model.utlis.LieuTitle;
import fr.univnantes.alma.model.utlis.Phase;
import java.util.UUID;
public class Lieu extends Card{
public Lieu(LieuTitle title, Phase phase) {
super(title, phase);
private UUID id;
public Lieu(LieuTitle title) {
super(title);
this.id = this.generateId();
}
public UUID generateId(){
UUID uniqID = UUID.randomUUID();
return uniqID;
}
public UUID getId() {
return id;
}
@Override
public String addDescription(Object object){
LieuTitle value = (LieuTitle)object;
......
......@@ -4,10 +4,19 @@ import fr.univnantes.alma.model.utlis.Phase;
import fr.univnantes.alma.model.utlis.SurvieTitle;
public class Survie extends Card {
private Phase phase;
public Survie(SurvieTitle title, Phase phase) {
super(title, phase);
super(title);
this.phase = phase;
}
public Phase getPhase() {
return phase;
}
@Override
public String addDescription(Object cardTitle) {
SurvieTitle value = (SurvieTitle)cardTitle;
......
package fr.univnantes.alma.model.cards;
import fr.univnantes.alma.model.utlis.Phase;
import fr.univnantes.alma.model.utlis.Symbole;
import fr.univnantes.alma.model.utlis.TraqueTitle;
public class Traque extends Card{
private Phase phase;
private Symbole symbole;
public Traque(TraqueTitle title, Phase phase) {
super(title, phase);
super(title);
this.phase = phase;
}
public Symbole getSymbole() {
return symbole;
}
public Traque(TraqueTitle title, Phase phase, Symbole symbole){
this(title, phase);
this.symbole = symbole;
}
public Phase getPhase() {
return phase;
}
@Override
......
package fr.univnantes.alma.model.inerfaces;
import fr.univnantes.alma.model.utlis.Phase;
import java.util.UUID;
public interface CardInterface {
public UUID getId();
public Phase getPhase();
public String getDescription();
public Object getTitle();
public Object getName();
public boolean getPower();
public void setPower(boolean power);
}
package fr.univnantes.alma.model.pawns;
public class Pawn {
private PawnName name;
public Pawn(PawnName pawnName) {
this.name = pawnName;
}
public PawnName getName() {
return name;
}
public void effect(PawnName name){
switch (name){
case BALISE:
this.baliseEffect();
break;
case SECOURS:
this.secoursEffect();
break;
case VOLONTE:
this.volonteEffect();
break;
case ASSIMILATION:
this.assimilationEffect();
}
}
public void baliseEffect(){
}
public void secoursEffect(){
}
public void volonteEffect(){
}
public void assimilationEffect(){
}
}
package fr.univnantes.alma.model.utlis;
package fr.univnantes.alma.model.pawns;
// Mettre tous les pions volontés dans la liste
public enum Pawn {
public enum PawnName {
BALISE, ASSIMILATION, SECOURS, VOLONTE
}
package fr.univnantes.alma.model.players;
import fr.univnantes.alma.model.cards.Traque;
import fr.univnantes.alma.model.inerfaces.CardInterface;
public class Creature extends Player{
......@@ -9,10 +10,28 @@ public class Creature extends Player{
}
@Override
public void initialize() {
public void init() {
}
public void toTraque(Tracked tracked){
CardInterface card = null;
int i = 0;
while (i<this.getHand().size() && card==null){
if(this.getHand().get(i) instanceof Traque){
card = this.getHand().get(i);
}
i++;
}
if(card != null && !tracked.resist()){
this.getHand().get(i).setPower(true);
this.assimilate(tracked);
this.getHand().remove(card);
}
}
public void assimilate(Tracked palyer){
}
}
......@@ -20,7 +20,7 @@ public abstract class Player implements PlayerInterface {
this.discards = new ArrayList<>();
this.playedCards = new ArrayList<>();
this.id = this.generateId();
this.initialize();
this.init();
}
public UUID generateId(){
......@@ -28,8 +28,6 @@ public abstract class Player implements PlayerInterface {
return uniqID;
}
public abstract void initialize();
@Override
public List<CardInterface> getHand() {
return hand;
......@@ -72,4 +70,6 @@ public abstract class Player implements PlayerInterface {
public String toString(){
return this.id+"\n"+this.name;
}
public abstract void init();
}
package fr.univnantes.alma.model.players;
import fr.univnantes.alma.model.cards.Lieu;
import fr.univnantes.alma.model.cards.Survie;
import fr.univnantes.alma.model.inerfaces.CardInterface;
public class Tracked extends Player{
public Tracked(String name) {
super(name);
}
@Override
public void initialize() {
public void init() {
}
......@@ -20,7 +24,37 @@ public class Tracked extends Player{
/**
* résister
*/
public void resist(){
public boolean resist(){
CardInterface card = null;
for(CardInterface cardSurvie: this.getHand()){
if(cardSurvie instanceof Survie){
card = cardSurvie;
}
}
if(card != null){
this.getHand().remove(card);
return true;
}
return false;
}
public boolean exploreArtemia(){
CardInterface card = null;
int i = 0;
while (i<this.getHand().size() && card==null){
if(this.getHand().get(i) instanceof Lieu){
card = this.getHand().get(i);
}
i++;
}
if(card != null){
this.getHand().get(i).setPower(true);
this.getHand().remove(card);
return true;
}
return false;
}
}
package fr.univnantes.alma.model.tokens;
public class Token {
private TokenName name;
public Token(TokenName name) {
this.name = name;
}
public TokenName getName() {
return name;
}
public void effect(TokenName name){
switch (name){
case CIBLE:
this.cibleEffect();
break;
case ARTEMIA:
this.artemiaEffect();
break;
case CREATURE:
this.creatureEffect();
}
}
public void cibleEffect(){
}
public void artemiaEffect(){
}
public void creatureEffect(){
}
}
package fr.univnantes.alma.model.tokens;
public enum TokenName {
CIBLE, CREATURE, ARTEMIA
}
package fr.univnantes.alma.model.utlis;
public enum Token {
CIBLE, CREATURE, ARTEMIA
public enum Symbole {
CIBLE, ARTEMIA
}
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