84 Zeilen
2.8 KiB
Java
84 Zeilen
2.8 KiB
Java
/*
|
|
This file is a part of the SteamWar software.
|
|
|
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package de.steamwar.fightsystem.winconditions;
|
|
|
|
import de.steamwar.fightsystem.Config;
|
|
import de.steamwar.fightsystem.fight.Fight;
|
|
import de.steamwar.fightsystem.fight.FightTeam;
|
|
import de.steamwar.fightsystem.states.FightState;
|
|
import de.steamwar.fightsystem.states.StateDependentTask;
|
|
import de.steamwar.inventory.SWItem;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.World;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
public class WinconditionPumpkinTechKO extends Wincondition implements PrintableWincondition {
|
|
|
|
private static final World world = Bukkit.getWorlds().get(0);
|
|
private static final Material PUMPKIN_LANTERN = SWItem.getMaterial("JACK_O_LANTERN");
|
|
|
|
private final Map<FightTeam, TeamPumpkin> teamMap = new HashMap<>();
|
|
|
|
public WinconditionPumpkinTechKO(){
|
|
super("PumpkinTechKO", "§cDas Team ", " §cist Tech K.O.!");
|
|
teamMap.put(Fight.getRedTeam(), new TeamPumpkin(Fight.getRedTeam()));
|
|
teamMap.put(Fight.getBlueTeam(), new TeamPumpkin(Fight.getBlueTeam()));
|
|
|
|
new StateDependentTask(Winconditions.PUMPKIN_TECH_KO, FightState.Ingame, this::check, 0, 200);
|
|
if(Config.ActiveWinconditions.contains(Winconditions.PUMPKIN_TECH_KO)){
|
|
printableWinconditions.add(this);
|
|
}
|
|
}
|
|
|
|
private void check(){
|
|
teamMap.values().forEach(TeamPumpkin::check);
|
|
}
|
|
|
|
@Override
|
|
public String getDisplay(FightTeam team) {
|
|
return team.getPrefix() + "Kanonen: " + teamMap.get(team).pumpkins;
|
|
}
|
|
|
|
private class TeamPumpkin {
|
|
private final FightTeam team;
|
|
|
|
private int pumpkins;
|
|
|
|
private TeamPumpkin (FightTeam team) {
|
|
this.team = team;
|
|
}
|
|
|
|
private void check(){
|
|
pumpkins = 0;
|
|
team.getSchemRegion().forEach((x, y, z) -> {
|
|
if (world.getBlockAt(x, y, z).getType() == PUMPKIN_LANTERN)
|
|
pumpkins++;
|
|
});
|
|
|
|
if(pumpkins == 0) {
|
|
win(Fight.getOpposite(team));
|
|
}
|
|
}
|
|
}
|
|
}
|