Skip to content

Commit

Permalink
"Tag" raider on death
Browse files Browse the repository at this point in the history
  • Loading branch information
AubriTheHuman committed Apr 3, 2023
1 parent 4a4bcc0 commit f260e28
Showing 1 changed file with 40 additions and 11 deletions.
51 changes: 40 additions & 11 deletions src/main/java/me/ShermansWorld/AlathraWar/Raid.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.palmergames.bukkit.towny.object.Town;
import com.palmergames.bukkit.towny.object.TownBlock;
import com.palmergames.bukkit.towny.object.WorldCoord;
import com.sun.tools.javac.util.Pair;
import me.ShermansWorld.AlathraWar.commands.RaidCommands;
import me.ShermansWorld.AlathraWar.data.RaidPhase;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -36,11 +37,11 @@
v/ Defenders are given time to get to the town. (travel is announced way in ahead)
- COMBAT PHASE
v/ Raiders go to town
- Combat occurs
v/ Combat occurs
- Decides outcome of raid
TODO LIST:
- No teleporting by raiders
v/ No teleporting by raiders (also defenders)
v/ Points management
v/ Raider death is negative score
v/ Defender death is positive score
Expand Down Expand Up @@ -75,7 +76,7 @@ public class Raid {
int[] bukkitId;
public ArrayList<String> raiderPlayers;
public ArrayList<String> defenderPlayers;
public ArrayList<String> activeRaiders;
public ArrayList<Pair<String,Boolean>> activeRaiders;

// Constructs raid for staging phase
public Raid(final int id, final War war, final Town raidedTown, final Town gatherTown, final String raiders, final String defenders,
Expand All @@ -85,7 +86,7 @@ public Raid(final int id, final War war, final Town raidedTown, final Town gathe
this.bukkitId = new int[1];
this.raiderPlayers = new ArrayList<String>();
this.defenderPlayers = new ArrayList<String>();
this.activeRaiders = new ArrayList<String>();
this.activeRaiders = new ArrayList<Pair<String,Boolean>>();
this.war = war;
this.raidedTown = raidedTown;
this.gatherTown = gatherTown;
Expand Down Expand Up @@ -282,7 +283,8 @@ private void startCombat() {
}

/**
* Need to add call to KillsListener (defined seperate from Siege)
* Use only during combat phase of raid
* @param event
*/
public void raiderKilledInCombat(PlayerDeathEvent event) {

Expand Down Expand Up @@ -311,10 +313,20 @@ public void raiderKilledInCombat(PlayerDeathEvent event) {
throw new RuntimeException(e);
}
}

//Tag that the player has been killed in the raid
for(Pair<String,Boolean> p : this.activeRaiders) {
if(p.fst.equals(killed.getName()) && !p.snd) {
Pair<String,Boolean> newP = new Pair<String,Boolean>(p.fst, true);
this.activeRaiders.remove(p);
this.activeRaiders.add(newP);
}
}
}

/**
* Need to add call to KillsListener (defined seperate from Siege)
* Use only during combat phase of raid
* @param event
*/
public void defenderKilledInCombat(PlayerDeathEvent event) {
this.addPointsToRaidScore(20);
Expand Down Expand Up @@ -344,7 +356,8 @@ public void defenderKilledInCombat(PlayerDeathEvent event) {
}

/**
* Need to add call to KillsListener (defined seperate from Siege)
* Use only out of combat phase of raid
* @param event
*/
public void raiderKilledOutofCombat(PlayerDeathEvent event) {

Expand Down Expand Up @@ -375,7 +388,8 @@ public void raiderKilledOutofCombat(PlayerDeathEvent event) {
}

/**
* Need to add call to KillsListener (defined seperate from Siege)
* Use only out of combat phase of raid
* @param event
*/
public void defenderKilledOutofCombat(PlayerDeathEvent event) {
for (final String playerName : this.getActiveRaiders()) {
Expand Down Expand Up @@ -523,18 +537,33 @@ public void setRaidPhase(final RaidPhase phase) {
}

public ArrayList<String> getActiveRaiders() {
ArrayList<String> raidersNames = new ArrayList<>();
for(Pair<String,Boolean> p : this.activeRaiders) {
raidersNames.add(p.fst);
}
return raidersNames;
}

public ArrayList<Pair<String,Boolean>> getActiveRaidersRaw() {
return this.activeRaiders;
}

public void setActiveRaiders(ArrayList<String> activeRaiders) {
public void setActiveRaiders(ArrayList<Pair<String,Boolean>> activeRaiders) {
this.activeRaiders = activeRaiders;
}

public void addActiveRaider(String player) {
this.activeRaiders.add(player);
this.activeRaiders.add(new Pair<String,Boolean>(player, false));
}

/**
* Finds first!!!! and removes
* @param name
*/
public void removeActiveRaider(String name) {
this.activeRaiders.remove(name);
for(Pair<String,Boolean> p : this.activeRaiders) {
if(p.fst.equals(name)) this.activeRaiders.remove(p);
return;
}
}
}

0 comments on commit f260e28

Please sign in to comment.