Refactored god item definitions to be more general purpose
This commit is contained in:
@@ -1,17 +1,21 @@
|
|||||||
package core.game.content.activity.gwd;
|
package core.game.content.activity.gwd;
|
||||||
|
|
||||||
|
import api.ContentAPIKt;
|
||||||
|
import api.God;
|
||||||
import core.game.node.entity.player.Player;
|
import core.game.node.entity.player.Player;
|
||||||
import core.game.node.item.Item;
|
import core.game.node.item.Item;
|
||||||
|
|
||||||
|
import static api.ContentAPIKt.hasGodItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The god wars factions.
|
* The god wars factions.
|
||||||
* @author Emperor
|
* @author Emperor
|
||||||
*/
|
*/
|
||||||
public enum GodWarsFaction {
|
public enum GodWarsFaction {
|
||||||
ARMADYL(6222, 6246, 87, 11694, 11718, 11720, 11722, 12670, 12671, 14671),
|
ARMADYL(6222, 6246, God.ARMADYL),
|
||||||
BANDOS(6260, 6283, 11061, 11696, 11724, 11726, 11728),
|
BANDOS(6260, 6283, God.BANDOS),
|
||||||
SARADOMIN(6247, 6259, 1718, 2412, 2415, 2661, 2663, 2665, 2667, 3479, 3675, 3489, 3840, 4682, 6762, 8055, 10384, 10386, 10388, 10390, 10440, 10446, 10452, 10458, 10464, 10470, 11181, 11698, 11730,542,544),
|
SARADOMIN(6247, 6259, God.SARADOMIN),
|
||||||
ZAMORAK(6203, 6221, 11716, 11700, 1724, 2414, 2417, 2653, 2655, 2657, 2659, 3478, 3674, 3841, 3842, 3852, 4683, 6764, 8056, 10368, 10370, 10372, 10374, 10444, 10450, 10456, 10460, 10468, 10474, 10776, 10786, 10790, 14662);
|
ZAMORAK(6203, 6221, God.ZAMORAK);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The start NPC id.
|
* The start NPC id.
|
||||||
@@ -24,20 +28,20 @@ public enum GodWarsFaction {
|
|||||||
private final int endId;
|
private final int endId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The protection items.
|
* The god this faction represents
|
||||||
*/
|
*/
|
||||||
private final int[] protectionItems;
|
private final God god;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new {@code GodWarsFaction} {@code Object}.
|
* Constructs a new {@code GodWarsFaction} {@code Object}.
|
||||||
* @param startId The start NPC id.
|
* @param startId The start NPC id.
|
||||||
* @param endId The end NPC id.
|
* @param endId The end NPC id.
|
||||||
* @param protectionItems The protection items for this faction.
|
* @param god The god this faction represents.
|
||||||
*/
|
*/
|
||||||
private GodWarsFaction(int startId, int endId, int... protectionItems) {
|
private GodWarsFaction(int startId, int endId, God god) {
|
||||||
this.startId = startId;
|
this.startId = startId;
|
||||||
this.endId = endId;
|
this.endId = endId;
|
||||||
this.protectionItems = protectionItems;
|
this.god = god;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,16 +65,7 @@ public enum GodWarsFaction {
|
|||||||
* player.
|
* player.
|
||||||
*/
|
*/
|
||||||
public boolean isProtected(Player player) {
|
public boolean isProtected(Player player) {
|
||||||
for (Item item : player.getEquipment().toArray()) {
|
return hasGodItem(player, god);
|
||||||
if (item != null) {
|
|
||||||
for (int id : protectionItems) {
|
|
||||||
if (item.getId() == id) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -88,12 +83,4 @@ public enum GodWarsFaction {
|
|||||||
public int getEndId() {
|
public int getEndId() {
|
||||||
return endId;
|
return endId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the protectionItems.
|
|
||||||
* @return The protectionItems.
|
|
||||||
*/
|
|
||||||
public int[] getProtectionItems() {
|
|
||||||
return protectionItems;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -261,6 +261,18 @@ fun inEquipment(player: Player, item: Int, amount: Int = 1): Boolean {
|
|||||||
return player.equipment.contains(item, amount)
|
return player.equipment.contains(item, amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a player has an item equipped which corresponds to the given God
|
||||||
|
* @param player the player to check
|
||||||
|
* @param god the God whose equipment we are checking for
|
||||||
|
* @return true if the player has an item corresponding to the given god, false otherwise
|
||||||
|
*/
|
||||||
|
fun hasGodItem(player: Player, god: God): Boolean
|
||||||
|
{
|
||||||
|
god.validItems.forEach { if(amountInEquipment(player, it) > 0) return true }
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get number of free slots in a player's inventory
|
* Get number of free slots in a player's inventory
|
||||||
* @param player the player to check
|
* @param player the player to check
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
enum class God(vararg val validItems: Int) {
|
||||||
|
ARMADYL(87, 11694, 11718, 11720, 11722, 12670, 12671, 14671),
|
||||||
|
BANDOS(11061, 11696, 11724, 11726, 11728),
|
||||||
|
SARADOMIN(1718, 2412, 2415, 2661, 2663, 2665, 2667, 3479, 3675, 3489, 3840, 4682, 6762, 8055, 10384, 10386, 10388, 10390, 10440, 10446, 10452, 10458, 10464, 10470, 11181, 11698, 11730,542,544),
|
||||||
|
ZAMORAK(11716, 11700, 1724, 2414, 2417, 2653, 2655, 2657, 2659, 3478, 3674, 3841, 3842, 3852, 4683, 6764, 8056, 10368, 10370, 10372, 10374, 10444, 10450, 10456, 10460, 10468, 10474, 10776, 10786, 10790, 14662),
|
||||||
|
GUTHIX,
|
||||||
|
ZAROS
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user