-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
106 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,55 @@ | ||
package edu.fiuba.algo3.modelo; | ||
|
||
import edu.fiuba.algo3.modelo.camino.CaminoTipo; | ||
import edu.fiuba.algo3.modelo.interactuables.InteractuableCasilla; | ||
|
||
import java.util.Objects; | ||
|
||
public class Casilla { | ||
private Casilla siguiente; | ||
private Casilla anterior; | ||
private InteractuableCasilla interactuable; | ||
|
||
private final Efecto efecto; | ||
private final CaminoTipo tipo; | ||
public Casilla(Casilla siguiente, InteractuableCasilla interactuable) { | ||
this.siguiente = siguiente; | ||
this.interactuable = interactuable; | ||
this.anterior = null; | ||
siguiente.setAnterior(this); | ||
} | ||
|
||
public Casilla(InteractuableCasilla interactuable) { | ||
this.siguiente = null; | ||
this.interactuable = interactuable; | ||
this.anterior = null; | ||
} | ||
|
||
public Casilla obtenerSiguiente() { | ||
// Exeception si no hay siguiente | ||
return this.siguiente; | ||
} | ||
|
||
public Casilla obtenerAnterior(){ | ||
// Exeception si no hay anterior | ||
return this.anterior; | ||
} | ||
|
||
public void interactuar(Gladiador gladiador) { | ||
this.interactuable.interactuar(gladiador); | ||
} | ||
|
||
public Casilla(Efecto e, CaminoTipo t) { | ||
this.efecto = e; | ||
this.tipo = t; | ||
public void setAnterior(Casilla anterior) { | ||
this.anterior = anterior; | ||
} | ||
|
||
public void aplicarEfecto(Gladiador g) { | ||
this.efecto.aplicar(g); | ||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
Casilla casilla = (Casilla) o; | ||
return Objects.equals(siguiente, casilla.siguiente) && Objects.equals(anterior, casilla.anterior) && Objects.equals(interactuable, casilla.interactuable); | ||
} | ||
|
||
//para la interfaz grafica | ||
public void pintar() { | ||
this.tipo.pintar(); | ||
@Override | ||
public int hashCode() { | ||
return Objects.hash(siguiente, anterior, interactuable); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,5 @@ | ||
package edu.fiuba.algo3.modelo; | ||
|
||
import edu.fiuba.algo3.modelo.efectos.Fiera; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
|
||
public class Tablero { | ||
private final HashMap<String, Posicion> casillerosGladiadores; | ||
private final HashMap<Posicion, Fiera> casilleros; // Deberia ser un generico de Casillero. | ||
|
||
public Tablero(ArrayList<Gladiador> gladiadores, ArrayList<Fiera> fieras){ | ||
casillerosGladiadores = new HashMap<String, Posicion>(); | ||
casilleros = new HashMap<Posicion, Fiera>(); | ||
for(Gladiador gladiador: gladiadores){ | ||
casillerosGladiadores.put(gladiador.obtenerNombre(), new Posicion(0)); | ||
} | ||
} | ||
|
||
public void avanzar(Gladiador gladiador, Dado dado){ | ||
if(gladiador.tenesPuntosDeEnegia(0)) return; | ||
int cantidadDeCasilleros = dado.tirar(); | ||
Posicion posicionActual = casillerosGladiadores.get(gladiador.obtenerNombre()); | ||
Fiera fiera = casilleros.get(posicionActual); | ||
posicionActual.avanzar(cantidadDeCasilleros); | ||
} | ||
public Posicion obtenerPosicionGladiador(Gladiador gladiador){ | ||
return casillerosGladiadores.get(gladiador.obtenerNombre()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/edu/fiuba/algo3/modelo/interactuables/FieraInteractuable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package edu.fiuba.algo3.modelo.interactuables; | ||
|
||
import edu.fiuba.algo3.modelo.Gladiador; | ||
|
||
public class FieraInteractuable implements InteractuableCasilla{ | ||
@Override | ||
public void interactuar(Gladiador gladiador) { | ||
gladiador.esAtacado(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/edu/fiuba/algo3/modelo/interactuables/InteractuableCasilla.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package edu.fiuba.algo3.modelo.interactuables; | ||
|
||
import edu.fiuba.algo3.modelo.Gladiador; | ||
|
||
public interface InteractuableCasilla { | ||
void interactuar (Gladiador gladiador); | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/edu/fiuba/algo3/modelo/interactuables/SinInteraccion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package edu.fiuba.algo3.modelo.interactuables; | ||
|
||
import edu.fiuba.algo3.modelo.Gladiador; | ||
|
||
public class SinInteraccion implements InteractuableCasilla{ | ||
@Override | ||
public void interactuar(Gladiador gladiador) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.