2018-09-13 12:03:28 -04:00
|
|
|
package noppes.npcs.scripted;
|
|
|
|
|
|
|
|
|
|
import noppes.npcs.controllers.Faction;
|
2022-05-24 03:06:16 -05:00
|
|
|
import noppes.npcs.controllers.FactionController;
|
2021-10-18 06:33:39 -05:00
|
|
|
import noppes.npcs.scripted.entity.ScriptNpc;
|
|
|
|
|
import noppes.npcs.scripted.entity.ScriptPlayer;
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
public class ScriptFaction {
|
2022-05-24 03:06:16 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
private Faction faction;
|
2022-05-24 03:06:16 -05:00
|
|
|
|
|
|
|
|
public void saveFaction() {
|
|
|
|
|
FactionController.getInstance().saveFaction(faction);
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
public ScriptFaction(Faction faction){
|
|
|
|
|
this.faction = faction;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Returns the factions id
|
|
|
|
|
*/
|
|
|
|
|
public int getId(){
|
|
|
|
|
return faction.id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Return the factions name
|
|
|
|
|
*/
|
|
|
|
|
public String getName(){
|
|
|
|
|
return faction.name;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public void setName(String name) {
|
|
|
|
|
faction.name = name;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public int getDefaultPoints(){
|
|
|
|
|
return faction.defaultPoints;
|
|
|
|
|
}
|
2022-05-24 03:06:16 -05:00
|
|
|
|
|
|
|
|
public void setDefaultPoints(int p) {
|
|
|
|
|
faction.defaultPoints = p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getFriendlyPoints() {
|
|
|
|
|
return faction.friendlyPoints;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setFriendlyPoints(int p) {
|
|
|
|
|
faction.friendlyPoints = p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getNeutralPoints() {
|
|
|
|
|
return faction.neutralPoints;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setNeutralPoints(int p) {
|
|
|
|
|
faction.neutralPoints = p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean getHideFaction() {
|
|
|
|
|
return faction.hideFaction;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setHideFaction(boolean b) {
|
|
|
|
|
faction.hideFaction = b;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean getGetsAttacked() {
|
|
|
|
|
return faction.getsAttacked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setGetsAttacked(boolean b) {
|
|
|
|
|
faction.getsAttacked = b;
|
|
|
|
|
}
|
2018-09-13 12:03:28 -04:00
|
|
|
|
|
|
|
|
public int getColor(){
|
|
|
|
|
return faction.color;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-24 03:06:16 -05:00
|
|
|
public void setColor(int c) {
|
|
|
|
|
faction.color = c;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
public boolean isFriendlyToPlayer(ScriptPlayer player){
|
|
|
|
|
return faction.isFriendlyToPlayer(player.player);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isNeutralToPlayer(ScriptPlayer player){
|
|
|
|
|
return faction.isNeutralToPlayer(player.player);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isAggressiveToPlayer(ScriptPlayer player){
|
|
|
|
|
return faction.isAggressiveToPlayer(player.player);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isAggressiveToNpc(ScriptNpc npc){
|
|
|
|
|
return faction.isAggressiveToNpc(npc.npc);
|
|
|
|
|
}
|
2022-05-24 03:06:16 -05:00
|
|
|
|
2022-05-26 20:47:46 -05:00
|
|
|
public Integer[] getEnemyFactionIds() {
|
2022-05-26 03:52:44 -05:00
|
|
|
if (faction.attackFactions == null) return new Integer[0];
|
|
|
|
|
return faction.attackFactions.toArray(new Integer[faction.attackFactions.size()]);
|
2022-05-24 03:06:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isEnemyFaction(int id) {
|
|
|
|
|
if (faction.attackFactions == null) return false;
|
2022-05-26 20:47:46 -05:00
|
|
|
Integer[] enemies = getEnemyFactionIds();
|
2022-05-24 03:06:16 -05:00
|
|
|
for (int i = 0; i < enemies.length; ++i) {
|
|
|
|
|
if (enemies[i] == id) return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addFactionEnemy(int id) {
|
|
|
|
|
if (!faction.attackFactions.contains(id)) faction.attackFactions.add(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void removeFactionEnemy(int id) {
|
|
|
|
|
faction.attackFactions.remove(id);
|
|
|
|
|
}
|
2022-05-26 20:47:46 -05:00
|
|
|
|
2018-09-13 12:03:28 -04:00
|
|
|
}
|