101 lines
2.4 KiB
Java
101 lines
2.4 KiB
Java
import java.util.ArrayDeque;
|
|
import java.util.Deque;
|
|
|
|
import it.kibo.fp.lib.RandomDraws;
|
|
|
|
public class Cavallo {
|
|
private String nome;
|
|
private String colore;
|
|
private Deque <Tessera> tessere = new ArrayDeque<>();
|
|
private int posizione;
|
|
private boolean matto;
|
|
|
|
public Cavallo(){
|
|
nome = null;
|
|
colore = null;
|
|
}
|
|
|
|
public Cavallo(String nome, String colore, boolean m, Mappa mappa){
|
|
this.nome = nome;
|
|
this.colore = colore;
|
|
if (m == true){
|
|
this.matto = true;
|
|
this.posizione = RandomDraws.drawInteger(14, 16);
|
|
}
|
|
else{
|
|
this.matto = false;
|
|
this.posizione = RandomDraws.drawInteger(1, 3);
|
|
}
|
|
}
|
|
|
|
public String getNome() {
|
|
return nome;
|
|
}
|
|
public String getColore() {
|
|
return colore;
|
|
}
|
|
public int getPosizione() {
|
|
return posizione;
|
|
}
|
|
public boolean isMatto() {
|
|
return matto;
|
|
}
|
|
public int getTessereSize(){
|
|
return tessere.size();
|
|
}
|
|
|
|
public void setNome(String nome) {
|
|
this.nome = nome;
|
|
}
|
|
public void setColore(String colore) {
|
|
this.colore = colore;
|
|
}
|
|
public void setPosizione(int posizione) {
|
|
this.posizione = posizione;
|
|
}
|
|
public void setMatto(boolean matto) {
|
|
this.matto = matto;
|
|
}
|
|
public void svuotaTessere(){
|
|
while(!tessere.isEmpty()){
|
|
tessere.remove();
|
|
}
|
|
}
|
|
|
|
|
|
public Tessera getTessera(){
|
|
return tessere.getFirst();
|
|
}
|
|
|
|
public void togliTessera(){
|
|
tessere.removeFirst();
|
|
}
|
|
|
|
public void addTessera(Giocatore g){
|
|
tessere.add(new Tessera(g));
|
|
}
|
|
|
|
public void spostaCasella(Mappa mappa, int i){
|
|
this.posizione += i;
|
|
if(mappa.getCasella(posizione).getTifoInveimento() == 1){
|
|
this.posizione += 1;
|
|
mappa.getCasella(posizione).getGiocatoreTessera().aggiungiSbleuro();
|
|
}
|
|
if(mappa.getCasella(posizione).getTifoInveimento() == -1){
|
|
this.posizione -= 1;
|
|
mappa.getCasella(posizione).getGiocatoreTessera().aggiungiSbleuro();
|
|
}
|
|
mappa.getCasella(this.posizione).aggiungiCavallo(this);
|
|
|
|
}
|
|
|
|
public void aggiungiTessera(Giocatore g){
|
|
tessere.addFirst(new Tessera(g));
|
|
}
|
|
|
|
public String toString(){
|
|
String stringa = this.getNome()+" "+ this.getColore() + " in posizione "+ this.getPosizione();
|
|
return stringa;
|
|
}
|
|
|
|
}
|