Dateien nach "src/main/java/pb/ajneb97/juego" hochladen
This commit is contained in:
74
src/main/java/pb/ajneb97/juego/ElementosGuardados.java
Normal file
74
src/main/java/pb/ajneb97/juego/ElementosGuardados.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package pb.ajneb97.juego;
|
||||
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class ElementosGuardados {
|
||||
|
||||
private ItemStack[] inventarioGuardado;
|
||||
private ItemStack[] equipamientoGuardado;
|
||||
private GameMode gamemodeGuardado;
|
||||
private float experienciaGuardada;
|
||||
private int levelGuardado;
|
||||
private int hambreGuardada;
|
||||
private double vidaGuardada;
|
||||
private double maxVidaGuardada;
|
||||
private boolean allowFlight;
|
||||
private boolean isFlying;
|
||||
|
||||
public ElementosGuardados(ItemStack[] inventarioGuardado,ItemStack[] equipamientoGuardado,GameMode gamemodeGuardado,float experienciaGuardada,int levelGuardado,int hambreGuardada,
|
||||
double vidaGuardada,double maxVidaGuardada,boolean allowFlight,boolean isFlying) {
|
||||
this.inventarioGuardado = inventarioGuardado;
|
||||
this.equipamientoGuardado = equipamientoGuardado;
|
||||
this.gamemodeGuardado = gamemodeGuardado;
|
||||
this.experienciaGuardada = experienciaGuardada;
|
||||
this.levelGuardado = levelGuardado;
|
||||
this.hambreGuardada = hambreGuardada;
|
||||
this.vidaGuardada = vidaGuardada;
|
||||
this.maxVidaGuardada = maxVidaGuardada;
|
||||
this.allowFlight = allowFlight;
|
||||
this.isFlying = isFlying;
|
||||
}
|
||||
|
||||
public boolean isAllowFlight() {
|
||||
return allowFlight;
|
||||
}
|
||||
|
||||
public boolean isFlying() {
|
||||
return isFlying;
|
||||
}
|
||||
|
||||
public ItemStack[] getInventarioGuardado() {
|
||||
return inventarioGuardado;
|
||||
}
|
||||
|
||||
public ItemStack[] getEquipamientoGuardado() {
|
||||
return equipamientoGuardado;
|
||||
}
|
||||
|
||||
public GameMode getGamemodeGuardado() {
|
||||
return gamemodeGuardado;
|
||||
}
|
||||
|
||||
public float getXPGuardada() {
|
||||
return experienciaGuardada;
|
||||
}
|
||||
|
||||
public int getLevelGuardado() {
|
||||
return this.levelGuardado;
|
||||
}
|
||||
|
||||
public int getHambreGuardada() {
|
||||
return this.hambreGuardada;
|
||||
}
|
||||
|
||||
public double getVidaGuardada() {
|
||||
return vidaGuardada;
|
||||
}
|
||||
|
||||
public double getMaxVidaGuardada() {
|
||||
return maxVidaGuardada;
|
||||
}
|
||||
}
|
109
src/main/java/pb/ajneb97/juego/Equipo.java
Normal file
109
src/main/java/pb/ajneb97/juego/Equipo.java
Normal file
@@ -0,0 +1,109 @@
|
||||
package pb.ajneb97.juego;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
|
||||
public class Equipo {
|
||||
|
||||
private ArrayList<JugadorPaintball> jugadores;
|
||||
private String tipoEquipo;
|
||||
//Tipos: blue,red,yellow,green,orange,purple,black,white
|
||||
//brown,magenta,light_blue,lime,pink,gray,light_gray,cyan
|
||||
private Location spawn;
|
||||
private int vidasActuales;
|
||||
private boolean random;
|
||||
|
||||
|
||||
public Equipo(String tipoEquipo) {
|
||||
this.jugadores = new ArrayList<JugadorPaintball>();
|
||||
this.tipoEquipo = tipoEquipo;
|
||||
this.vidasActuales = 0;
|
||||
}
|
||||
|
||||
public boolean esRandom() {
|
||||
return this.random;
|
||||
}
|
||||
|
||||
public void setRandom(boolean random) {
|
||||
this.random = random;
|
||||
}
|
||||
|
||||
public int getVidas() {
|
||||
return this.vidasActuales;
|
||||
}
|
||||
|
||||
public void disminuirVidas(int cantidad) {
|
||||
this.vidasActuales = this.vidasActuales-cantidad;
|
||||
}
|
||||
|
||||
public void aumentarVidas(int cantidad) {
|
||||
this.vidasActuales = this.vidasActuales+cantidad;
|
||||
}
|
||||
|
||||
public void setVidas(int cantidad) {
|
||||
this.vidasActuales = cantidad;
|
||||
}
|
||||
|
||||
public void setTipo(String tipo) {
|
||||
this.tipoEquipo = tipo;
|
||||
}
|
||||
|
||||
public String getTipo() {
|
||||
return this.tipoEquipo;
|
||||
}
|
||||
|
||||
public boolean contieneJugador(String jugador) {
|
||||
for(int i=0;i<jugadores.size();i++) {
|
||||
if(jugadores.get(i).getJugador().getName().equals(jugador)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean agregarJugador(JugadorPaintball jugador) {
|
||||
if(!contieneJugador(jugador.getJugador().getName())) {
|
||||
this.jugadores.add(jugador);
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean removerJugador(String jugador) {
|
||||
for(int i=0;i<jugadores.size();i++) {
|
||||
if(jugadores.get(i).getJugador().getName().equals(jugador)) {
|
||||
jugadores.remove(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ArrayList<JugadorPaintball> getJugadores(){
|
||||
return this.jugadores;
|
||||
}
|
||||
|
||||
public int getCantidadJugadores() {
|
||||
return this.jugadores.size();
|
||||
}
|
||||
|
||||
public Location getSpawn() {
|
||||
return this.spawn;
|
||||
}
|
||||
|
||||
public void setSpawn(Location l) {
|
||||
this.spawn = l;
|
||||
}
|
||||
|
||||
public int getAsesinatosTotales() {
|
||||
int kills = 0;
|
||||
for(JugadorPaintball j : this.jugadores) {
|
||||
kills = kills+j.getAsesinatos();
|
||||
}
|
||||
return kills;
|
||||
}
|
||||
}
|
9
src/main/java/pb/ajneb97/juego/EstadoPartida.java
Normal file
9
src/main/java/pb/ajneb97/juego/EstadoPartida.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package pb.ajneb97.juego;
|
||||
|
||||
public enum EstadoPartida {
|
||||
ESPERANDO,
|
||||
COMENZANDO,
|
||||
JUGANDO,
|
||||
TERMINANDO,
|
||||
DESACTIVADA
|
||||
}
|
172
src/main/java/pb/ajneb97/juego/JugadorPaintball.java
Normal file
172
src/main/java/pb/ajneb97/juego/JugadorPaintball.java
Normal file
@@ -0,0 +1,172 @@
|
||||
package pb.ajneb97.juego;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class JugadorPaintball {
|
||||
|
||||
private Player jugador;
|
||||
private int asesinatos;
|
||||
private int muertes;
|
||||
private ElementosGuardados guardados;
|
||||
private boolean asesinadoRecientemente;
|
||||
private String preferenciaTeam;
|
||||
private int coins;
|
||||
private ArrayList<Killstreak> killstreaks;
|
||||
private Location deathLocation;
|
||||
|
||||
private String selectedHat;
|
||||
private boolean efectoHatActivado;
|
||||
private boolean efectoHatEnCooldown;
|
||||
private int tiempoEfectoHat;
|
||||
private String lastKilledBy;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public JugadorPaintball(Player jugador) {
|
||||
this.jugador = jugador;
|
||||
this.guardados = new ElementosGuardados(jugador.getInventory().getContents().clone(),jugador.getEquipment().getArmorContents().clone(),jugador.getGameMode()
|
||||
,jugador.getExp(),jugador.getLevel(),jugador.getFoodLevel(),jugador.getHealth(),jugador.getMaxHealth(),jugador.getAllowFlight(),jugador.isFlying());
|
||||
this.asesinadoRecientemente = false;
|
||||
this.muertes = 0;
|
||||
this.asesinatos = 0;
|
||||
this.coins = 0;
|
||||
this.killstreaks = new ArrayList<Killstreak>();
|
||||
this.efectoHatActivado = false;
|
||||
this.efectoHatEnCooldown = false;
|
||||
this.tiempoEfectoHat = 0;
|
||||
this.selectedHat = "";
|
||||
}
|
||||
|
||||
public String getLastKilledBy() {
|
||||
return lastKilledBy;
|
||||
}
|
||||
|
||||
public void setLastKilledBy(String lastKilledBy) {
|
||||
this.lastKilledBy = lastKilledBy;
|
||||
}
|
||||
|
||||
public boolean isEfectoHatActivado() {
|
||||
return efectoHatActivado;
|
||||
}
|
||||
|
||||
public void setEfectoHatActivado(boolean efectoHatActivado) {
|
||||
this.efectoHatActivado = efectoHatActivado;
|
||||
}
|
||||
|
||||
public boolean isEfectoHatEnCooldown() {
|
||||
return efectoHatEnCooldown;
|
||||
}
|
||||
|
||||
public void setEfectoHatEnCooldown(boolean efectoHatEnCooldown) {
|
||||
this.efectoHatEnCooldown = efectoHatEnCooldown;
|
||||
}
|
||||
|
||||
public int getTiempoEfectoHat() {
|
||||
return tiempoEfectoHat;
|
||||
}
|
||||
|
||||
public void setTiempoEfectoHat(int tiempoEfectoHat) {
|
||||
this.tiempoEfectoHat = tiempoEfectoHat;
|
||||
}
|
||||
|
||||
public void setSelectedHat(String hat) {
|
||||
this.selectedHat = hat;
|
||||
}
|
||||
|
||||
public String getSelectedHat() {
|
||||
return this.selectedHat;
|
||||
}
|
||||
|
||||
public void setDeathLocation(Location l) {
|
||||
this.deathLocation = l;
|
||||
}
|
||||
|
||||
public Location getDeathLocation() {
|
||||
return this.deathLocation;
|
||||
}
|
||||
|
||||
public void agregarKillstreak(Killstreak k) {
|
||||
this.killstreaks.add(k);
|
||||
}
|
||||
|
||||
public Killstreak getKillstreak(String tipo) {
|
||||
for(Killstreak k : this.killstreaks) {
|
||||
if(k.getTipo().equals(tipo)) {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void removerKillstreak(String tipo) {
|
||||
for(int i=0;i<killstreaks.size();i++) {
|
||||
if(killstreaks.get(i).getTipo().equals(tipo)) {
|
||||
this.killstreaks.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Killstreak getUltimaKillstreak() {
|
||||
if(killstreaks.isEmpty()) {
|
||||
return null;
|
||||
}else {
|
||||
return killstreaks.get(killstreaks.size()-1);
|
||||
}
|
||||
}
|
||||
|
||||
public int getCoins() {
|
||||
return this.coins;
|
||||
}
|
||||
|
||||
public void agregarCoins(int cantidad) {
|
||||
this.coins = this.coins+cantidad;
|
||||
}
|
||||
|
||||
public void disminuirCoins(int cantidad) {
|
||||
this.coins = this.coins-cantidad;
|
||||
}
|
||||
|
||||
public void setPreferenciaTeam(String team) {
|
||||
this.preferenciaTeam = team;
|
||||
}
|
||||
|
||||
public String getPreferenciaTeam() {
|
||||
return this.preferenciaTeam;
|
||||
}
|
||||
|
||||
public ElementosGuardados getGuardados() {
|
||||
return this.guardados;
|
||||
}
|
||||
|
||||
public void aumentarAsesinatos() {
|
||||
this.asesinatos++;
|
||||
}
|
||||
|
||||
public void aumentarMuertes() {
|
||||
this.muertes++;
|
||||
}
|
||||
|
||||
public int getAsesinatos() {
|
||||
return this.asesinatos;
|
||||
}
|
||||
|
||||
public int getMuertes() {
|
||||
return this.muertes;
|
||||
}
|
||||
|
||||
public Player getJugador() {
|
||||
return this.jugador;
|
||||
}
|
||||
|
||||
public void setAsesinadoRecientemente(boolean asesinadoRecientemente) {
|
||||
this.asesinadoRecientemente = asesinadoRecientemente;
|
||||
}
|
||||
|
||||
public boolean haSidoAsesinadoRecientemente() {
|
||||
return this.asesinadoRecientemente;
|
||||
}
|
||||
|
||||
}
|
62
src/main/java/pb/ajneb97/juego/JugadorPaintballDatos.java
Normal file
62
src/main/java/pb/ajneb97/juego/JugadorPaintballDatos.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package pb.ajneb97.juego;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import pb.ajneb97.api.Hat;
|
||||
import pb.ajneb97.api.Perk;
|
||||
|
||||
public class JugadorPaintballDatos {
|
||||
|
||||
private int wins;
|
||||
private int loses;
|
||||
private int ties;
|
||||
private int kills;
|
||||
private ArrayList<Hat> hats;
|
||||
private ArrayList<Perk> perks;
|
||||
public JugadorPaintballDatos(int wins, int loses, int ties, int kills, ArrayList<Hat> hats, ArrayList<Perk> perks) {
|
||||
this.wins = wins;
|
||||
this.loses = loses;
|
||||
this.kills = kills;
|
||||
this.ties = ties;
|
||||
this.hats = hats;
|
||||
this.perks = perks;
|
||||
}
|
||||
public int getWins() {
|
||||
return wins;
|
||||
}
|
||||
public int getKills() {
|
||||
return kills;
|
||||
}
|
||||
public void setKills(int kills) {
|
||||
this.kills = kills;
|
||||
}
|
||||
public void setWins(int wins) {
|
||||
this.wins = wins;
|
||||
}
|
||||
public int getLoses() {
|
||||
return loses;
|
||||
}
|
||||
public void setLoses(int loses) {
|
||||
this.loses = loses;
|
||||
}
|
||||
public int getTies() {
|
||||
return ties;
|
||||
}
|
||||
public void setTies(int ties) {
|
||||
this.ties = ties;
|
||||
}
|
||||
public ArrayList<Hat> getHats() {
|
||||
return hats;
|
||||
}
|
||||
public void setHats(ArrayList<Hat> hats) {
|
||||
this.hats = hats;
|
||||
}
|
||||
public ArrayList<Perk> getPerks() {
|
||||
return perks;
|
||||
}
|
||||
public void setPerks(ArrayList<Perk> perks) {
|
||||
this.perks = perks;
|
||||
}
|
||||
|
||||
|
||||
}
|
30
src/main/java/pb/ajneb97/juego/Killstreak.java
Normal file
30
src/main/java/pb/ajneb97/juego/Killstreak.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package pb.ajneb97.juego;
|
||||
|
||||
|
||||
public class Killstreak {
|
||||
|
||||
private String tipo;
|
||||
private int tiempo;
|
||||
|
||||
public Killstreak(String tipo, int tiempo) {
|
||||
this.tipo = tipo;
|
||||
this.tiempo = tiempo;
|
||||
}
|
||||
|
||||
public String getTipo() {
|
||||
return tipo;
|
||||
}
|
||||
|
||||
public void setTipo(String tipo) {
|
||||
this.tipo = tipo;
|
||||
}
|
||||
|
||||
public int getTiempo() {
|
||||
return tiempo;
|
||||
}
|
||||
|
||||
public void setTiempo(int tiempo) {
|
||||
this.tiempo = tiempo;
|
||||
}
|
||||
|
||||
}
|
352
src/main/java/pb/ajneb97/juego/Partida.java
Normal file
352
src/main/java/pb/ajneb97/juego/Partida.java
Normal file
@@ -0,0 +1,352 @@
|
||||
package pb.ajneb97.juego;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
|
||||
|
||||
|
||||
public class Partida {
|
||||
|
||||
private Equipo team1;
|
||||
private Equipo team2;
|
||||
private String nombre;
|
||||
private int cantidadMaximaJugadores;
|
||||
private int cantidadMinimaJugadores;
|
||||
private int cantidadActualJugadores;
|
||||
private EstadoPartida estado;
|
||||
private Location lobby;
|
||||
private int tiempo;
|
||||
private int tiempoMaximo;
|
||||
private int vidasIniciales;
|
||||
private boolean enNuke;
|
||||
|
||||
public Partida(String nombre,int tiempoMaximo,String equipo1, String equipo2, int vidasIniciales) {
|
||||
//por defecto
|
||||
this.team1 = new Equipo(equipo1);
|
||||
this.team2 = new Equipo(equipo2);
|
||||
this.nombre = nombre;
|
||||
this.cantidadMaximaJugadores = 16;
|
||||
this.cantidadMinimaJugadores = 4;
|
||||
this.cantidadActualJugadores = 0;
|
||||
this.estado = EstadoPartida.DESACTIVADA;
|
||||
this.tiempo = 0;
|
||||
this.tiempoMaximo = tiempoMaximo;
|
||||
this.vidasIniciales = vidasIniciales;
|
||||
this.enNuke = false;
|
||||
}
|
||||
|
||||
// // <<<<<< NEU: Scoreboards für alle Spieler erstellen
|
||||
// public void createScoreboardsForAllPlayers(PaintballListener paintballListener) {
|
||||
// for(JugadorPaintball spieler : getJugadores()) {
|
||||
// Player player = spieler.getJugador();
|
||||
// paintballListener.createGameBoard(
|
||||
// player,
|
||||
// "InGame", // ggf. dynamisch anpassen
|
||||
// team1.getTipo(), team1.getVidas(),
|
||||
// team2.getTipo(), team2.getVidas(),
|
||||
// spieler.getAsesinatos(),
|
||||
// getNombre(),
|
||||
// getCantidadActualJugadores(),
|
||||
// getCantidadMaximaJugadores()
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public boolean isEnNuke() {
|
||||
return enNuke;
|
||||
}
|
||||
|
||||
public void setEnNuke(boolean enNuke) {
|
||||
this.enNuke = enNuke;
|
||||
}
|
||||
|
||||
public void setVidasIniciales(int cantidad) {
|
||||
this.vidasIniciales = cantidad;
|
||||
}
|
||||
|
||||
public int getVidasIniciales() {
|
||||
return this.vidasIniciales;
|
||||
}
|
||||
|
||||
public void setTiempoMaximo(int tiempo) {
|
||||
this.tiempoMaximo = tiempo;
|
||||
}
|
||||
|
||||
public int getTiempoMaximo() {
|
||||
return this.tiempoMaximo;
|
||||
}
|
||||
|
||||
public void disminuirTiempo() {
|
||||
this.tiempo--;
|
||||
}
|
||||
|
||||
public void aumentarTiempo() {
|
||||
this.tiempo++;
|
||||
}
|
||||
|
||||
public void setTiempo(int tiempo) {
|
||||
this.tiempo = tiempo;
|
||||
}
|
||||
|
||||
public int getTiempo() {
|
||||
return this.tiempo;
|
||||
}
|
||||
|
||||
public String getNombre() {
|
||||
return this.nombre;
|
||||
}
|
||||
|
||||
public void agregarJugador(JugadorPaintball player) {
|
||||
//ANTES DE INICIAR LA PARTIDA TODOS ESTAN EN EL TEAM 1 Y LUEGO SE REPARTEN LOS DEMAS AL TEAM 2
|
||||
if(team1.agregarJugador(player)) {
|
||||
this.cantidadActualJugadores++;
|
||||
}
|
||||
}
|
||||
|
||||
public void repartirJugadorTeam2(JugadorPaintball player) {
|
||||
this.team1.removerJugador(player.getJugador().getName());
|
||||
this.team2.agregarJugador(player);
|
||||
}
|
||||
|
||||
public void removerJugador(String player) {
|
||||
if(team1.removerJugador(player) || team2.removerJugador(player)) {
|
||||
this.cantidadActualJugadores--;
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<JugadorPaintball> getJugadores(){
|
||||
ArrayList<JugadorPaintball> jugadores = new ArrayList<JugadorPaintball>();
|
||||
|
||||
ArrayList<JugadorPaintball> jugadoresTeam1 = team1.getJugadores();
|
||||
for(int i=0;i<jugadoresTeam1.size();i++) {
|
||||
jugadores.add(jugadoresTeam1.get(i));
|
||||
}
|
||||
ArrayList<JugadorPaintball> jugadoresTeam2 = team2.getJugadores();
|
||||
for(int i=0;i<jugadoresTeam2.size();i++) {
|
||||
jugadores.add(jugadoresTeam2.get(i));
|
||||
}
|
||||
|
||||
return jugadores;
|
||||
}
|
||||
|
||||
public JugadorPaintball getJugador(String jugador) {
|
||||
for(int i=0;i<getJugadores().size();i++) {
|
||||
if(getJugadores().get(i).getJugador().getName().equals(jugador)) {
|
||||
return getJugadores().get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Equipo getEquipoJugador(String jugador) {
|
||||
ArrayList<JugadorPaintball> jugadoresTeam1 = team1.getJugadores();
|
||||
for(int i=0;i<jugadoresTeam1.size();i++) {
|
||||
if(jugadoresTeam1.get(i).getJugador().getName().equals(jugador)) {
|
||||
return this.team1;
|
||||
}
|
||||
}
|
||||
ArrayList<JugadorPaintball> jugadoresTeam2 = team2.getJugadores();
|
||||
for(int i=0;i<jugadoresTeam2.size();i++) {
|
||||
if(jugadoresTeam2.get(i).getJugador().getName().equals(jugador)){
|
||||
return this.team2;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Equipo getTeam1() {
|
||||
return this.team1;
|
||||
}
|
||||
|
||||
public Equipo getTeam2() {
|
||||
return this.team2;
|
||||
}
|
||||
|
||||
public int getCantidadMaximaJugadores() {
|
||||
return this.cantidadMaximaJugadores;
|
||||
}
|
||||
|
||||
public void setCantidadMaximaJugadores(int max) {
|
||||
this.cantidadMaximaJugadores = max;
|
||||
}
|
||||
|
||||
public int getCantidadMinimaJugadores() {
|
||||
return this.cantidadMinimaJugadores;
|
||||
}
|
||||
|
||||
public void setCantidadMinimaJugadores(int min) {
|
||||
this.cantidadMinimaJugadores = min;
|
||||
}
|
||||
|
||||
public int getCantidadActualJugadores() {
|
||||
return this.cantidadActualJugadores;
|
||||
}
|
||||
|
||||
public EstadoPartida getEstado() {
|
||||
return this.estado;
|
||||
}
|
||||
|
||||
public void setEstado(EstadoPartida estado) {
|
||||
this.estado = estado;
|
||||
}
|
||||
|
||||
public boolean estaIniciada() {
|
||||
if(!this.estado.equals(EstadoPartida.ESPERANDO) && !this.estado.equals(EstadoPartida.COMENZANDO)) {
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean estaLlena() {
|
||||
if(this.cantidadActualJugadores == this.cantidadMaximaJugadores) {
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean estaActivada() {
|
||||
if(this.estado.equals(EstadoPartida.DESACTIVADA)) {
|
||||
return false;
|
||||
}else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void setLobby(Location l) {
|
||||
this.lobby = l;
|
||||
}
|
||||
|
||||
public Location getLobby() {
|
||||
return this.lobby;
|
||||
}
|
||||
|
||||
public Equipo getGanador() {
|
||||
if(team1.getJugadores().size() == 0) {
|
||||
return team2;
|
||||
}
|
||||
if(team2.getJugadores().size() == 0) {
|
||||
return team1;
|
||||
}
|
||||
|
||||
int vidasTeam1 = team1.getVidas();
|
||||
int vidasTeam2 = team2.getVidas();
|
||||
if(vidasTeam1 > vidasTeam2) {
|
||||
return team1;
|
||||
}else if(vidasTeam2 > vidasTeam1) {
|
||||
return team2;
|
||||
}else {
|
||||
return null; //empate
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<JugadorPaintball> getJugadoresKills() {
|
||||
ArrayList<JugadorPaintball> nuevo = new ArrayList<JugadorPaintball>();
|
||||
for(int i=0;i<getJugadores().size();i++) {
|
||||
nuevo.add(getJugadores().get(i));
|
||||
}
|
||||
|
||||
for(int i=0;i<nuevo.size();i++) {
|
||||
for(int c=i+1;c<nuevo.size();c++) {
|
||||
if(nuevo.get(i).getAsesinatos() < nuevo.get(c).getAsesinatos()) {
|
||||
JugadorPaintball j = nuevo.get(i);
|
||||
nuevo.set(i, nuevo.get(c));
|
||||
nuevo.set(c, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nuevo;
|
||||
}
|
||||
|
||||
public boolean puedeSeleccionarEquipo(String equipo) {
|
||||
int mitad = 0;
|
||||
if(this.cantidadActualJugadores % 2 != 0) {
|
||||
mitad = ((int)this.cantidadActualJugadores/2) + 1;
|
||||
}else {
|
||||
mitad = (int)this.cantidadActualJugadores/2;
|
||||
}
|
||||
if(equipo.equals(this.team1.getTipo())) {
|
||||
int cantidadPreferenciaTeam1 = 0;
|
||||
for(JugadorPaintball j : this.getJugadores()) {
|
||||
if(j.getPreferenciaTeam() != null && j.getPreferenciaTeam().equals(this.team1.getTipo())) {
|
||||
cantidadPreferenciaTeam1++;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.cantidadActualJugadores == 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if(cantidadPreferenciaTeam1 >= mitad) {
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
int cantidadPreferenciaTeam2 = 0;
|
||||
for(JugadorPaintball j : this.getJugadores()) {
|
||||
if(j.getPreferenciaTeam() != null && j.getPreferenciaTeam().equals(this.team2.getTipo())) {
|
||||
cantidadPreferenciaTeam2++;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.cantidadActualJugadores == 1) {
|
||||
return true;
|
||||
}
|
||||
if(cantidadPreferenciaTeam2 >= mitad) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void modificarTeams(FileConfiguration config) {
|
||||
Equipo team1 = this.team1;
|
||||
Equipo team2 = this.team2;
|
||||
String nTeam1 = team1.getTipo();
|
||||
String nTeam2 = team2.getTipo();
|
||||
Random r = new Random();
|
||||
ArrayList<String> nombres = new ArrayList<String>();
|
||||
for(String key : config.getConfigurationSection("teams").getKeys(false)) {
|
||||
nombres.add(key);
|
||||
}
|
||||
|
||||
int max = nombres.size();
|
||||
if(team1.esRandom() && !team2.esRandom()) {
|
||||
int num = r.nextInt(max);
|
||||
nTeam1 = nombres.get(num);
|
||||
while(nTeam1.equals(nTeam2)) {
|
||||
num = r.nextInt(max);
|
||||
nTeam1 = nombres.get(num);
|
||||
}
|
||||
team1.setTipo(nTeam1);
|
||||
}else if(!team1.esRandom() && team2.esRandom()) {
|
||||
int num = r.nextInt(max);
|
||||
nTeam2 = nombres.get(num);
|
||||
while(nTeam2.equals(nTeam1)) {
|
||||
num = r.nextInt(max);
|
||||
nTeam2 = nombres.get(num);
|
||||
}
|
||||
team2.setTipo(nTeam2);
|
||||
}else if(team1.esRandom() && team2.esRandom()) {
|
||||
int num = r.nextInt(max);
|
||||
nTeam1 = nombres.get(num);
|
||||
num = r.nextInt(max);
|
||||
nTeam2 = nombres.get(num);
|
||||
while(nTeam2.equals(nTeam1)) {
|
||||
num = r.nextInt(max);
|
||||
nTeam2 = nombres.get(num);
|
||||
}
|
||||
team1.setTipo(nTeam1);
|
||||
team2.setTipo(nTeam2);
|
||||
}
|
||||
}
|
||||
}
|
33
src/main/java/pb/ajneb97/juego/PartidaEditando.java
Normal file
33
src/main/java/pb/ajneb97/juego/PartidaEditando.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package pb.ajneb97.juego;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PartidaEditando {
|
||||
|
||||
private Player jugador;
|
||||
private Partida partida;
|
||||
private String paso;
|
||||
public PartidaEditando(Player jugador, Partida partida) {
|
||||
this.jugador = jugador;
|
||||
this.partida = partida;
|
||||
this.paso = "";
|
||||
}
|
||||
public Player getJugador() {
|
||||
return jugador;
|
||||
}
|
||||
public void setJugador(Player jugador) {
|
||||
this.jugador = jugador;
|
||||
}
|
||||
public Partida getPartida() {
|
||||
return partida;
|
||||
}
|
||||
public void setPartida(Partida partida) {
|
||||
this.partida = partida;
|
||||
}
|
||||
public void setPaso(String paso) {
|
||||
this.paso = paso;
|
||||
}
|
||||
public String getPaso() {
|
||||
return this.paso;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user