From 517a798b6f7b2d2902ab0c2922627c75970eb8fd Mon Sep 17 00:00:00 2001 From: OMGeeky Date: Mon, 23 Jun 2025 14:31:06 +0200 Subject: [PATCH] extract BasicEffect and rename TimedConditionEffect to TimedActorConditionEffect --- .../model/gamedata/Common.java | 52 +- .../atcontentstudio/model/gamedata/Item.java | 28 +- .../atcontentstudio/model/gamedata/NPC.java | 1162 ++++++++--------- .../gpl/rpg/atcontentstudio/ui/Editor.java | 9 +- .../ui/gamedataeditors/ItemEditor.java | 106 +- .../ui/gamedataeditors/NPCEditor.java | 84 +- .../atcontentstudio/ui/tools/GDEVisitor.java | 10 +- 7 files changed, 727 insertions(+), 724 deletions(-) diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Common.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Common.java index 0c58eea..50acb0a 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Common.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Common.java @@ -9,22 +9,22 @@ import java.util.Map; public final class Common { - public static void linkConditions(List conditions, Project proj, GameDataElement backlink) { + public static void linkConditions(List conditions, Project proj, GameDataElement backlink) { if (conditions != null) { - for (ConditionEffect ce : conditions) { + for (ActorConditionEffect ce : conditions) { if (ce.condition_id != null) ce.condition = proj.getActorCondition(ce.condition_id); if (ce.condition != null) ce.condition.addBacklink(backlink); } } } - public static class TimedConditionEffect extends ConditionEffect { + public static class TimedActorConditionEffect extends ActorConditionEffect { //Available from parsed state public Integer duration = null; public Double chance = null; - public TimedConditionEffect createClone() { - TimedConditionEffect cclone = new TimedConditionEffect(); + public TimedActorConditionEffect createClone() { + TimedActorConditionEffect cclone = new TimedActorConditionEffect(); cclone.magnitude = this.magnitude; cclone.condition_id = this.condition_id; cclone.condition = this.condition; @@ -34,7 +34,7 @@ public final class Common { } } - public static class ConditionEffect { + public static class ActorConditionEffect { //Available from parsed state public Integer magnitude = null; public String condition_id = null; @@ -44,13 +44,13 @@ public final class Common { } @SuppressWarnings("rawtypes") - public static ArrayList parseTimedConditionEffects(List conditionsSourceJson) { - ArrayList conditions_source; + public static ArrayList parseTimedConditionEffects(List conditionsSourceJson) { + ArrayList conditions_source; if (conditionsSourceJson != null && !conditionsSourceJson.isEmpty()) { conditions_source = new ArrayList<>(); for (Object conditionJsonObj : conditionsSourceJson) { Map conditionJson = (Map) conditionJsonObj; - TimedConditionEffect condition = new TimedConditionEffect(); + TimedActorConditionEffect condition = new TimedActorConditionEffect(); readConditionEffect(condition, conditionJson); condition.duration = JSONElement.getInteger((Number) conditionJson.get("duration")); if (conditionJson.get("chance") != null) @@ -64,7 +64,7 @@ public final class Common { } @SuppressWarnings("rawtypes") - private static void readConditionEffect(ConditionEffect condition, Map conditionJson) { + private static void readConditionEffect(ActorConditionEffect condition, Map conditionJson) { condition.condition_id = (String) conditionJson.get("condition"); condition.magnitude = JSONElement.getInteger((Number) conditionJson.get("magnitude")); } @@ -119,19 +119,21 @@ public final class Common { hit_effect.conditions_target = parseTimedConditionEffects(conditionsTargetJson); } - - public static class DeathEffect { - //Available from parsed state + public static class BasicEffect { public Integer hp_boost_min = null; public Integer hp_boost_max = null; public Integer ap_boost_min = null; public Integer ap_boost_max = null; - public List conditions_source = null; + } + + public static class DeathEffect extends BasicEffect { + //Available from parsed state + public List conditions_source = null; } public static class HitEffect extends DeathEffect { //Available from parsed state - public List conditions_target = null; + public List conditions_target = null; } public static class HitReceivedEffect extends Common.HitEffect { @@ -144,14 +146,11 @@ public final class Common { public static void copyDeathEffectValues(Common.DeathEffect target, Common.DeathEffect source, GameDataElement backlink) { - target.ap_boost_max = source.ap_boost_max; - target.ap_boost_min = source.ap_boost_min; - target.hp_boost_max = source.hp_boost_max; - target.hp_boost_min = source.hp_boost_min; + copyEffectValues(target, source); if (source.conditions_source != null) { target.conditions_source = new ArrayList<>(); - for (Common.TimedConditionEffect c : source.conditions_source) { - Common.TimedConditionEffect cclone = c.createClone(); + for (TimedActorConditionEffect c : source.conditions_source) { + TimedActorConditionEffect cclone = c.createClone(); if (cclone.condition != null) { cclone.condition.addBacklink(backlink); } @@ -160,12 +159,19 @@ public final class Common { } } + private static void copyEffectValues(BasicEffect target, BasicEffect source) { + target.ap_boost_max = source.ap_boost_max; + target.ap_boost_min = source.ap_boost_min; + target.hp_boost_max = source.hp_boost_max; + target.hp_boost_min = source.hp_boost_min; + } + public static void copyHitEffectValues(Common.HitEffect target, Common.HitEffect source, GameDataElement backlink) { copyDeathEffectValues(target, source, backlink); if (source.conditions_target != null) { target.conditions_target = new ArrayList<>(); - for (Common.TimedConditionEffect c : source.conditions_target) { - Common.TimedConditionEffect cclone = c.createClone(); + for (TimedActorConditionEffect c : source.conditions_target) { + TimedActorConditionEffect cclone = c.createClone(); if (cclone.condition != null) { cclone.condition.addBacklink(backlink); } diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Item.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Item.java index 1daaeda..d4c17f3 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/Item.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/Item.java @@ -49,7 +49,7 @@ public class Item extends JSONElement { public Integer damage_boost_max = null; public Integer max_hp_boost = null; public Integer max_ap_boost = null; - public List conditions = null; + public List conditions = null; public Integer increase_move_cost = null; public Integer increase_use_item_cost = null; public Integer increase_reequip_cost = null; @@ -174,7 +174,7 @@ public class Item extends JSONElement { this.equip_effect.conditions = new ArrayList<>(); for (Object conditionJsonObj : conditionsJson) { Map conditionJson = (Map) conditionJsonObj; - ConditionEffect condition = new ConditionEffect(); + ActorConditionEffect condition = new ActorConditionEffect(); condition.condition_id = (String) conditionJson.get("condition"); condition.magnitude = JSONElement.getInteger((Number) conditionJson.get("magnitude")); this.equip_effect.conditions.add(condition); @@ -286,8 +286,8 @@ public class Item extends JSONElement { clone.equip_effect.max_hp_boost = this.equip_effect.max_hp_boost; if (this.equip_effect.conditions != null) { clone.equip_effect.conditions = new ArrayList<>(); - for (ConditionEffect c : this.equip_effect.conditions) { - ConditionEffect cclone = new ConditionEffect(); + for (ActorConditionEffect c : this.equip_effect.conditions) { + ActorConditionEffect cclone = new ActorConditionEffect(); cclone.magnitude = c.magnitude; cclone.condition_id = c.condition_id; cclone.condition = c.condition; @@ -321,7 +321,7 @@ public class Item extends JSONElement { if (newOne != null) newOne.addBacklink(this); } else { if (this.equip_effect != null && this.equip_effect.conditions != null) { - for (ConditionEffect c : this.equip_effect.conditions) { + for (ActorConditionEffect c : this.equip_effect.conditions) { if (c.condition == oldOne) { oldOne.removeBacklink(this); c.condition = (ActorCondition) newOne; @@ -330,7 +330,7 @@ public class Item extends JSONElement { } } if (this.hit_effect != null && this.hit_effect.conditions_source != null) { - for (TimedConditionEffect c : this.hit_effect.conditions_source) { + for (TimedActorConditionEffect c : this.hit_effect.conditions_source) { if (c.condition == oldOne) { oldOne.removeBacklink(this); c.condition = (ActorCondition) newOne; @@ -339,7 +339,7 @@ public class Item extends JSONElement { } } if (this.hit_effect != null && this.hit_effect.conditions_target != null) { - for (TimedConditionEffect c : this.hit_effect.conditions_target) { + for (TimedActorConditionEffect c : this.hit_effect.conditions_target) { if (c.condition == oldOne) { oldOne.removeBacklink(this); c.condition = (ActorCondition) newOne; @@ -349,7 +349,7 @@ public class Item extends JSONElement { } if (this.kill_effect != null && this.kill_effect.conditions_source != null) { - for (TimedConditionEffect c : this.kill_effect.conditions_source) { + for (TimedActorConditionEffect c : this.kill_effect.conditions_source) { if (c.condition == oldOne) { oldOne.removeBacklink(this); c.condition = (ActorCondition) newOne; @@ -417,7 +417,7 @@ public class Item extends JSONElement { if (this.equip_effect.conditions != null) { List conditionsJson = new ArrayList(); equipEffectJson.put("addedConditions", conditionsJson); - for (ConditionEffect condition : this.equip_effect.conditions) { + for (ActorConditionEffect condition : this.equip_effect.conditions) { Map conditionJson = new LinkedHashMap(); conditionsJson.add(conditionJson); if (condition.condition != null) { @@ -451,7 +451,7 @@ public class Item extends JSONElement { if (this.hit_effect.conditions_source != null) { List conditionsSourceJson = new ArrayList(); hitEffectJson.put("conditionsSource", conditionsSourceJson); - for (TimedConditionEffect condition : this.hit_effect.conditions_source) { + for (TimedActorConditionEffect condition : this.hit_effect.conditions_source) { Map conditionJson = new LinkedHashMap(); conditionsSourceJson.add(conditionJson); if (condition.condition != null) { @@ -468,7 +468,7 @@ public class Item extends JSONElement { if (this.hit_effect.conditions_target != null) { List conditionsTargetJson = new ArrayList(); hitEffectJson.put("conditionsTarget", conditionsTargetJson); - for (TimedConditionEffect condition : this.hit_effect.conditions_target) { + for (TimedActorConditionEffect condition : this.hit_effect.conditions_target) { Map conditionJson = new LinkedHashMap(); conditionsTargetJson.add(conditionJson); if (condition.condition != null) { @@ -529,7 +529,7 @@ public class Item extends JSONElement { if (this.hit_received_effect.conditions_source != null) { List conditionsSourceJson = new ArrayList(); hitReceivedEffectJson.put("conditionsSource", conditionsSourceJson); - for (TimedConditionEffect condition : this.hit_received_effect.conditions_source) { + for (TimedActorConditionEffect condition : this.hit_received_effect.conditions_source) { Map conditionJson = new LinkedHashMap(); conditionsSourceJson.add(conditionJson); if (condition.condition != null) { @@ -546,7 +546,7 @@ public class Item extends JSONElement { if (this.hit_received_effect.conditions_target != null) { List conditionsTargetJson = new ArrayList(); hitReceivedEffectJson.put("conditionsTarget", conditionsTargetJson); - for (TimedConditionEffect condition : this.hit_received_effect.conditions_target) { + for (TimedActorConditionEffect condition : this.hit_received_effect.conditions_target) { Map conditionJson = new LinkedHashMap(); conditionsTargetJson.add(conditionJson); if (condition.condition != null) { @@ -587,7 +587,7 @@ public class Item extends JSONElement { if (this.kill_effect.conditions_source != null) { List conditionsSourceJson = new ArrayList(); killEffectJson.put("conditionsSource", conditionsSourceJson); - for (TimedConditionEffect condition : this.kill_effect.conditions_source) { + for (TimedActorConditionEffect condition : this.kill_effect.conditions_source) { Map conditionJson = new LinkedHashMap(); conditionsSourceJson.add(conditionJson); if (condition.condition != null) { diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/NPC.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/NPC.java index 505c2d9..db1b6dc 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/NPC.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/NPC.java @@ -1,581 +1,581 @@ -package com.gpl.rpg.atcontentstudio.model.gamedata; - -import com.gpl.rpg.atcontentstudio.Notification; -import com.gpl.rpg.atcontentstudio.model.GameDataElement; -import com.gpl.rpg.atcontentstudio.model.GameSource; -import com.gpl.rpg.atcontentstudio.model.Project; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; - -import java.awt.*; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import static com.gpl.rpg.atcontentstudio.model.gamedata.Common.*; - -public class NPC extends JSONElement { - - private static final long serialVersionUID = 1093728879485491933L; - - //Available from init state - //public String id = null; inherited. - public String name = null; - public String icon_id = null; - - //Available from parsed state - public Integer max_hp = null; - public Integer max_ap = null; - public Integer move_cost = null; - public Integer unique = null; - public MonsterClass monster_class = null; - public MovementType movement_type = null; - public Integer attack_damage_max = null; - public Integer attack_damage_min = null; - public String spawngroup_id = null; - public String faction_id = null; - public String dialogue_id = null; - public String droplist_id = null; - public Integer attack_cost = null; - public Integer attack_chance = null; - public Integer critical_skill = null; - public Double critical_multiplier = null; - public Integer block_chance = null; - public Integer damage_resistance = null; - public HitEffect hit_effect = null; - public HitReceivedEffect hit_received_effect = null; - public DeathEffect death_effect = null; - - //Available from linked state - public Dialogue dialogue = null; - public Droplist droplist = null; - - public enum MonsterClass { - humanoid, - insect, - demon, - construct, - animal, - giant, - undead, - reptile, - ghost - } - - public enum MovementType { - none, - helpOthers, - protectSpawn, - wholeMap - } - - @Override - public String getDesc() { - return (needsSaving() ? "*" : "") + name + " (" + id + ")"; - } - - public static String getStaticDesc() { - return "NPCs"; - } - - - @SuppressWarnings("rawtypes") - public static void fromJson(File jsonFile, GameDataCategory category) { - JSONParser parser = new JSONParser(); - FileReader reader = null; - try { - reader = new FileReader(jsonFile); - List npcs = (List) parser.parse(reader); - for (Object obj : npcs) { - Map npcJson = (Map) obj; - NPC npc = fromJson(npcJson); - npc.jsonFile = jsonFile; - npc.parent = category; - if (npc.getDataType() == GameSource.Type.created || npc.getDataType() == GameSource.Type.altered) { - npc.writable = true; - } - category.add(npc); - } - } catch (FileNotFoundException e) { - Notification.addError("Error while parsing JSON file " + jsonFile.getAbsolutePath() + ": " + e.getMessage()); - e.printStackTrace(); - } catch (IOException e) { - Notification.addError("Error while parsing JSON file " + jsonFile.getAbsolutePath() + ": " + e.getMessage()); - e.printStackTrace(); - } catch (ParseException e) { - Notification.addError("Error while parsing JSON file " + jsonFile.getAbsolutePath() + ": " + e.getMessage()); - e.printStackTrace(); - } finally { - if (reader != null) - try { - reader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - @SuppressWarnings("rawtypes") - public static NPC fromJson(String jsonString) throws ParseException { - Map npcJson = (Map) new JSONParser().parse(jsonString); - NPC npc = fromJson(npcJson); - npc.parse(npcJson); - return npc; - } - - @SuppressWarnings("rawtypes") - public static NPC fromJson(Map npcJson) { - NPC npc = new NPC(); - npc.icon_id = (String) npcJson.get("iconID"); - npc.id = (String) npcJson.get("id"); - npc.name = (String) npcJson.get("name"); - return npc; - } - - - @SuppressWarnings("rawtypes") - @Override - public void parse(Map npcJson) { - - this.max_hp = JSONElement.getInteger((Number) npcJson.get("maxHP")); - this.max_ap = JSONElement.getInteger((Number) npcJson.get("maxAP")); - this.move_cost = JSONElement.getInteger((Number) npcJson.get("moveCost")); - this.unique = JSONElement.getInteger((Number) npcJson.get("unique")); - if (npcJson.get("monsterClass") != null) - this.monster_class = MonsterClass.valueOf((String) npcJson.get("monsterClass")); - if (npcJson.get("movementAggressionType") != null) - this.movement_type = MovementType.valueOf((String) npcJson.get("movementAggressionType")); - if (npcJson.get("attackDamage") != null) { - this.attack_damage_min = JSONElement.getInteger((Number) (((Map) npcJson.get("attackDamage")).get("min"))); - this.attack_damage_max = JSONElement.getInteger((Number) (((Map) npcJson.get("attackDamage")).get("max"))); - } - this.spawngroup_id = (String) npcJson.get("spawnGroup"); - this.faction_id = (String) npcJson.get("faction"); - this.dialogue_id = (String) npcJson.get("phraseID"); - this.droplist_id = (String) npcJson.get("droplistID"); - this.attack_cost = JSONElement.getInteger((Number) npcJson.get("attackCost")); - this.attack_chance = JSONElement.getInteger((Number) npcJson.get("attackChance")); - this.critical_skill = JSONElement.getInteger((Number) npcJson.get("criticalSkill")); - //TODO correct game data, to unify format. -// this.critical_multiplier = JSONElement.getDouble((Number) npcJson.get("criticalMultiplier")); - if (npcJson.get("criticalMultiplier") != null) - this.critical_multiplier = JSONElement.getDouble(Double.parseDouble(npcJson.get("criticalMultiplier").toString())); - - this.block_chance = JSONElement.getInteger((Number) npcJson.get("blockChance")); - this.damage_resistance = JSONElement.getInteger((Number) npcJson.get("damageResistance")); - - Map hitEffect = (Map) npcJson.get("hitEffect"); - if (hitEffect != null) { - this.hit_effect = new HitEffect(); - if (hitEffect.get("increaseCurrentHP") != null) { - this.hit_effect.hp_boost_max = JSONElement.getInteger((Number) (((Map) hitEffect.get("increaseCurrentHP")).get("max"))); - this.hit_effect.hp_boost_min = JSONElement.getInteger((Number) (((Map) hitEffect.get("increaseCurrentHP")).get("min"))); - } - if (hitEffect.get("increaseCurrentAP") != null) { - this.hit_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map) hitEffect.get("increaseCurrentAP")).get("max"))); - this.hit_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map) hitEffect.get("increaseCurrentAP")).get("min"))); - } - List conditionsSourceJson = (List) hitEffect.get("conditionsSource"); - this.hit_effect.conditions_source = parseTimedConditionEffects(conditionsSourceJson); - List conditionsTargetJson = (List) hitEffect.get("conditionsTarget"); - this.hit_effect.conditions_target = parseTimedConditionEffects(conditionsTargetJson); - } - - Map hitReceivedEffect = (Map) npcJson.get("hitReceivedEffect"); - if (hitReceivedEffect != null) { - this.hit_received_effect = parseHitReceivedEffect(hitReceivedEffect); - } - - Map deathEffect = (Map) npcJson.get("deathEffect"); - if (deathEffect != null) { - this.death_effect = new HitEffect(); - if (deathEffect.get("increaseCurrentHP") != null) { - this.death_effect.hp_boost_max = JSONElement.getInteger((Number) (((Map) deathEffect.get("increaseCurrentHP")).get("max"))); - this.death_effect.hp_boost_min = JSONElement.getInteger((Number) (((Map) deathEffect.get("increaseCurrentHP")).get("min"))); - } - if (deathEffect.get("increaseCurrentAP") != null) { - this.death_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map) deathEffect.get("increaseCurrentAP")).get("max"))); - this.death_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map) deathEffect.get("increaseCurrentAP")).get("min"))); - } - List conditionsSourceJson = (List) deathEffect.get("conditionsSource"); - this.death_effect.conditions_source = parseTimedConditionEffects(conditionsSourceJson); - } - - } - - @Override - public void link() { - if (shouldSkipParseOrLink()) { - return; - } - ensureParseIfNeeded(); - Project proj = getProject(); - if (proj == null) { - Notification.addError("Error linking item " + id + ". No parent project found."); - return; - } - if (this.icon_id != null) { - String spritesheetId = this.icon_id.split(":")[0]; - proj.getSpritesheet(spritesheetId).addBacklink(this); - } - - if (this.dialogue_id != null) this.dialogue = proj.getDialogue(this.dialogue_id); - if (this.dialogue != null) this.dialogue.addBacklink(this); - - if (this.droplist_id != null) this.droplist = proj.getDroplist(this.droplist_id); - if (this.droplist != null) this.droplist.addBacklink(this); - - if (this.hit_effect != null) { - linkConditions(this.hit_effect.conditions_source, proj, this); - linkConditions(this.hit_effect.conditions_target, proj, this); - } - if (this.hit_received_effect != null) { - linkConditions(this.hit_received_effect.conditions_source, proj, this); - linkConditions(this.hit_received_effect.conditions_target, proj, this); - } - if (this.death_effect != null) { - linkConditions(this.death_effect.conditions_source, proj, this); - } - this.state = State.linked; - } - - @Override - public Image getIcon() { - return getProject().getIcon(icon_id); - } - - public Image getImage() { - return getProject().getImage(icon_id); - } - - @Override - public GameDataElement clone() { - NPC clone = new NPC(); - clone.jsonFile = this.jsonFile; - clone.state = this.state; - clone.id = this.id; - clone.name = this.name; - clone.icon_id = this.icon_id; - clone.attack_chance = this.attack_chance; - clone.attack_cost = this.attack_cost; - clone.attack_damage_min = this.attack_damage_min; - clone.attack_damage_max = this.attack_damage_max; - clone.block_chance = this.block_chance; - clone.critical_multiplier = this.critical_multiplier; - clone.critical_skill = this.critical_skill; - clone.damage_resistance = this.damage_resistance; - clone.dialogue = this.dialogue; - if (clone.dialogue != null) { - clone.dialogue.addBacklink(clone); - } - clone.dialogue_id = this.dialogue_id; - clone.droplist = this.droplist; - if (clone.droplist != null) { - clone.droplist.addBacklink(clone); - } - clone.droplist_id = this.droplist_id; - clone.faction_id = this.faction_id; - if (this.hit_effect != null) { - clone.hit_effect = new HitEffect(); - copyHitEffectValues(clone.hit_effect, this.hit_effect, clone); - } - if (this.hit_received_effect != null) { - clone.hit_received_effect = new HitReceivedEffect(); - copyHitReceivedEffectValues(clone.hit_received_effect, this.hit_received_effect, clone); - } - if (this.death_effect != null) { - clone.death_effect = new DeathEffect(); - copyDeathEffectValues(clone.death_effect, this.death_effect, clone); - } - clone.max_ap = this.max_ap; - clone.max_hp = this.max_hp; - clone.monster_class = this.monster_class; - clone.move_cost = this.move_cost; - clone.movement_type = this.movement_type; - clone.spawngroup_id = this.spawngroup_id; - clone.unique = this.unique; - return clone; - } - - @Override - public void elementChanged(GameDataElement oldOne, GameDataElement newOne) { - if (dialogue == oldOne) { - oldOne.removeBacklink(this); - this.dialogue = (Dialogue) newOne; - if (newOne != null) newOne.addBacklink(this); - } else { - if (this.droplist == oldOne) { - oldOne.removeBacklink(this); - this.droplist = (Droplist) newOne; - if (newOne != null) newOne.addBacklink(this); - } else { - if (this.hit_effect != null && this.hit_effect.conditions_source != null) { - for (TimedConditionEffect tce : this.hit_effect.conditions_source) { - if (tce.condition == oldOne) { - oldOne.removeBacklink(this); - tce.condition = (ActorCondition) newOne; - if (newOne != null) newOne.addBacklink(this); - } - } - } - if (this.hit_effect != null && this.hit_effect.conditions_target != null) { - for (TimedConditionEffect tce : this.hit_effect.conditions_target) { - if (tce.condition == oldOne) { - oldOne.removeBacklink(this); - tce.condition = (ActorCondition) newOne; - if (newOne != null) newOne.addBacklink(this); - } - } - } - } - } - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - @Override - public Map toJson() { - Map npcJson = new LinkedHashMap(); - npcJson.put("id", this.id); - if (this.name != null) npcJson.put("name", this.name); - if (this.icon_id != null) npcJson.put("iconID", this.icon_id); - if (this.max_hp != null) npcJson.put("maxHP", this.max_hp); - if (this.max_ap != null) npcJson.put("maxAP", this.max_ap); - if (this.move_cost != null) npcJson.put("moveCost", this.move_cost); - if (this.unique != null) npcJson.put("unique", this.unique); - if (this.monster_class != null) npcJson.put("monsterClass", this.monster_class.toString()); - if (this.movement_type != null) npcJson.put("movementAggressionType", this.movement_type.toString()); - if (this.attack_damage_min != null || this.attack_damage_max != null) { - Map adJson = new LinkedHashMap(); - npcJson.put("attackDamage", adJson); - if (this.attack_damage_min != null) adJson.put("min", this.attack_damage_min); - else adJson.put("min", 0); - if (this.attack_damage_max != null) adJson.put("max", this.attack_damage_max); - else adJson.put("max", 0); - } - if (this.spawngroup_id != null) npcJson.put("spawnGroup", this.spawngroup_id); - if (this.faction_id != null) npcJson.put("faction", this.faction_id); - if (this.dialogue != null) { - npcJson.put("phraseID", this.dialogue.id); - } else if (this.dialogue_id != null) { - npcJson.put("phraseID", this.dialogue_id); - } - if (this.droplist != null) { - npcJson.put("droplistID", this.droplist.id); - } else if (this.droplist_id != null) { - npcJson.put("droplistID", this.droplist_id); - } - if (this.attack_cost != null) npcJson.put("attackCost", this.attack_cost); - if (this.attack_chance != null) npcJson.put("attackChance", this.attack_chance); - if (this.critical_skill != null) npcJson.put("criticalSkill", this.critical_skill); - if (this.critical_multiplier != null) npcJson.put("criticalMultiplier", this.critical_multiplier); - if (this.block_chance != null) npcJson.put("blockChance", this.block_chance); - if (this.damage_resistance != null) npcJson.put("damageResistance", this.damage_resistance); - if (this.hit_effect != null) { - Map hitEffectJson = new LinkedHashMap(); - npcJson.put("hitEffect", hitEffectJson); - if (this.hit_effect.hp_boost_min != null || this.hit_effect.hp_boost_max != null) { - Map hpJson = new LinkedHashMap(); - hitEffectJson.put("increaseCurrentHP", hpJson); - if (this.hit_effect.hp_boost_min != null) hpJson.put("min", this.hit_effect.hp_boost_min); - else hpJson.put("min", 0); - if (this.hit_effect.hp_boost_max != null) hpJson.put("max", this.hit_effect.hp_boost_max); - else hpJson.put("max", 0); - } - if (this.hit_effect.ap_boost_min != null || this.hit_effect.ap_boost_max != null) { - Map apJson = new LinkedHashMap(); - hitEffectJson.put("increaseCurrentAP", apJson); - if (this.hit_effect.ap_boost_min != null) apJson.put("min", this.hit_effect.ap_boost_min); - else apJson.put("min", 0); - if (this.hit_effect.ap_boost_max != null) apJson.put("max", this.hit_effect.ap_boost_max); - else apJson.put("max", 0); - } - if (this.hit_effect.conditions_source != null) { - List conditionsSourceJson = new ArrayList(); - hitEffectJson.put("conditionsSource", conditionsSourceJson); - for (TimedConditionEffect condition : this.hit_effect.conditions_source) { - Map conditionJson = new LinkedHashMap(); - conditionsSourceJson.add(conditionJson); - if (condition.condition != null) { - conditionJson.put("condition", condition.condition.id); - } else if (condition.condition_id != null) { - conditionJson.put("condition", condition.condition_id); - } - if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude); - if (condition.duration != null) conditionJson.put("duration", condition.duration); - if (condition.chance != null) - conditionJson.put("chance", JSONElement.printJsonChance(condition.chance)); - } - } - if (this.hit_effect.conditions_target != null) { - List conditionsTargetJson = new ArrayList(); - hitEffectJson.put("conditionsTarget", conditionsTargetJson); - for (TimedConditionEffect condition : this.hit_effect.conditions_target) { - Map conditionJson = new LinkedHashMap(); - conditionsTargetJson.add(conditionJson); - if (condition.condition != null) { - conditionJson.put("condition", condition.condition.id); - } else if (condition.condition_id != null) { - conditionJson.put("condition", condition.condition_id); - } - if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude); - if (condition.duration != null) conditionJson.put("duration", condition.duration); - if (condition.chance != null) - conditionJson.put("chance", JSONElement.printJsonChance(condition.chance)); - } - } - } - if (this.hit_received_effect != null) { - Map hitReceivedEffectJson = new LinkedHashMap(); - npcJson.put("hitReceivedEffect", hitReceivedEffectJson); - if (this.hit_received_effect.hp_boost_min != null || this.hit_received_effect.hp_boost_max != null) { - Map hpJson = new LinkedHashMap(); - hitReceivedEffectJson.put("increaseCurrentHP", hpJson); - if (this.hit_received_effect.hp_boost_min != null) - hpJson.put("min", this.hit_received_effect.hp_boost_min); - else hpJson.put("min", 0); - if (this.hit_received_effect.hp_boost_max != null) - hpJson.put("max", this.hit_received_effect.hp_boost_max); - else hpJson.put("max", 0); - } - if (this.hit_received_effect.ap_boost_min != null || this.hit_received_effect.ap_boost_max != null) { - Map apJson = new LinkedHashMap(); - hitReceivedEffectJson.put("increaseCurrentAP", apJson); - if (this.hit_received_effect.ap_boost_min != null) - apJson.put("min", this.hit_received_effect.ap_boost_min); - else apJson.put("min", 0); - if (this.hit_received_effect.ap_boost_max != null) - apJson.put("max", this.hit_received_effect.ap_boost_max); - else apJson.put("max", 0); - } - if (this.hit_received_effect.hp_boost_min_target != null || this.hit_received_effect.hp_boost_max_target != null) { - Map hpJson = new LinkedHashMap(); - hitReceivedEffectJson.put("increaseAttackerCurrentHP", hpJson); - if (this.hit_received_effect.hp_boost_min_target != null) - hpJson.put("min", this.hit_received_effect.hp_boost_min_target); - else hpJson.put("min", 0); - if (this.hit_received_effect.hp_boost_max_target != null) - hpJson.put("max", this.hit_received_effect.hp_boost_max_target); - else hpJson.put("max", 0); - } - if (this.hit_received_effect.ap_boost_min_target != null || this.hit_received_effect.ap_boost_max_target != null) { - Map apJson = new LinkedHashMap(); - hitReceivedEffectJson.put("increaseAttackerCurrentAP", apJson); - if (this.hit_received_effect.ap_boost_min_target != null) - apJson.put("min", this.hit_received_effect.ap_boost_min_target); - else apJson.put("min", 0); - if (this.hit_received_effect.ap_boost_max_target != null) - apJson.put("max", this.hit_received_effect.ap_boost_max_target); - else apJson.put("max", 0); - } - if (this.hit_received_effect.conditions_source != null) { - List conditionsSourceJson = new ArrayList(); - hitReceivedEffectJson.put("conditionsSource", conditionsSourceJson); - for (TimedConditionEffect condition : this.hit_received_effect.conditions_source) { - Map conditionJson = new LinkedHashMap(); - conditionsSourceJson.add(conditionJson); - if (condition.condition != null) { - conditionJson.put("condition", condition.condition.id); - } else if (condition.condition_id != null) { - conditionJson.put("condition", condition.condition_id); - } - if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude); - if (condition.duration != null) conditionJson.put("duration", condition.duration); - if (condition.chance != null) - conditionJson.put("chance", JSONElement.printJsonChance(condition.chance)); - } - } - if (this.hit_received_effect.conditions_target != null) { - List conditionsTargetJson = new ArrayList(); - hitReceivedEffectJson.put("conditionsTarget", conditionsTargetJson); - for (TimedConditionEffect condition : this.hit_received_effect.conditions_target) { - Map conditionJson = new LinkedHashMap(); - conditionsTargetJson.add(conditionJson); - if (condition.condition != null) { - conditionJson.put("condition", condition.condition.id); - } else if (condition.condition_id != null) { - conditionJson.put("condition", condition.condition_id); - } - if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude); - if (condition.duration != null) conditionJson.put("duration", condition.duration); - if (condition.chance != null) - conditionJson.put("chance", JSONElement.printJsonChance(condition.chance)); - } - } - } - if (this.death_effect != null) { - Map deathEffectJson = new LinkedHashMap(); - npcJson.put("deathEffect", deathEffectJson); - if (this.death_effect.hp_boost_min != null || this.death_effect.hp_boost_max != null) { - Map hpJson = new LinkedHashMap(); - deathEffectJson.put("increaseCurrentHP", hpJson); - if (this.death_effect.hp_boost_min != null) hpJson.put("min", this.death_effect.hp_boost_min); - else hpJson.put("min", 0); - if (this.death_effect.hp_boost_max != null) hpJson.put("max", this.death_effect.hp_boost_max); - else hpJson.put("max", 0); - } - if (this.death_effect.ap_boost_min != null || this.death_effect.ap_boost_max != null) { - Map apJson = new LinkedHashMap(); - deathEffectJson.put("increaseCurrentAP", apJson); - if (this.death_effect.ap_boost_min != null) apJson.put("min", this.death_effect.ap_boost_min); - else apJson.put("min", 0); - if (this.death_effect.ap_boost_max != null) apJson.put("max", this.death_effect.ap_boost_max); - else apJson.put("max", 0); - } - if (this.death_effect.conditions_source != null) { - List conditionsSourceJson = new ArrayList(); - deathEffectJson.put("conditionsSource", conditionsSourceJson); - for (TimedConditionEffect condition : this.death_effect.conditions_source) { - Map conditionJson = new LinkedHashMap(); - conditionsSourceJson.add(conditionJson); - if (condition.condition != null) { - conditionJson.put("condition", condition.condition.id); - } else if (condition.condition_id != null) { - conditionJson.put("condition", condition.condition_id); - } - if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude); - if (condition.duration != null) conditionJson.put("duration", condition.duration); - if (condition.chance != null) - conditionJson.put("chance", JSONElement.printJsonChance(condition.chance)); - } - } - } - return npcJson; - } - - - @Override - public String getProjectFilename() { - return "monsterlist_" + getProject().name + ".json"; - } - - public int getMonsterExperience() { - double EXP_FACTOR_DAMAGERESISTANCE = 9; - double EXP_FACTOR_SCALING = 0.7; - - double attacksPerTurn = Math.floor((double) (max_ap != null ? max_ap : 10.0) / (double) (attack_cost != null ? attack_cost : 10.0)); - double avgDamagePotential = 0; - if (attack_damage_min != null || attack_damage_max != null) { - avgDamagePotential = ((double) (attack_damage_min != null ? attack_damage_min : 0) + (double) (attack_damage_max != null ? attack_damage_max : 0)) / 2.0; - } - double avgCrit = 0; - if (critical_skill != null && critical_multiplier != null) { - avgCrit = (double) (critical_skill / 100.0) * critical_multiplier; - } - double avgAttackHP = attacksPerTurn * ((double) (attack_chance != null ? attack_chance : 0) / 100.0) * avgDamagePotential * (1 + avgCrit); - double avgDefenseHP = ((max_hp != null ? max_hp : 1) * (1 + ((double) (block_chance != null ? block_chance : 0) / 100.0))) + (EXP_FACTOR_DAMAGERESISTANCE * (damage_resistance != null ? damage_resistance : 0)); - double attackConditionBonus = 0; - if (hit_effect != null && hit_effect.conditions_target != null && hit_effect.conditions_target.size() > 0) { - attackConditionBonus = 50; - } - double experience = (((avgAttackHP * 3) + avgDefenseHP) * EXP_FACTOR_SCALING) + attackConditionBonus; - - return new Double(Math.ceil(experience)).intValue(); - } - - -} +package com.gpl.rpg.atcontentstudio.model.gamedata; + +import com.gpl.rpg.atcontentstudio.Notification; +import com.gpl.rpg.atcontentstudio.model.GameDataElement; +import com.gpl.rpg.atcontentstudio.model.GameSource; +import com.gpl.rpg.atcontentstudio.model.Project; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; + +import java.awt.*; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import static com.gpl.rpg.atcontentstudio.model.gamedata.Common.*; + +public class NPC extends JSONElement { + + private static final long serialVersionUID = 1093728879485491933L; + + //Available from init state + //public String id = null; inherited. + public String name = null; + public String icon_id = null; + + //Available from parsed state + public Integer max_hp = null; + public Integer max_ap = null; + public Integer move_cost = null; + public Integer unique = null; + public MonsterClass monster_class = null; + public MovementType movement_type = null; + public Integer attack_damage_max = null; + public Integer attack_damage_min = null; + public String spawngroup_id = null; + public String faction_id = null; + public String dialogue_id = null; + public String droplist_id = null; + public Integer attack_cost = null; + public Integer attack_chance = null; + public Integer critical_skill = null; + public Double critical_multiplier = null; + public Integer block_chance = null; + public Integer damage_resistance = null; + public HitEffect hit_effect = null; + public HitReceivedEffect hit_received_effect = null; + public DeathEffect death_effect = null; + + //Available from linked state + public Dialogue dialogue = null; + public Droplist droplist = null; + + public enum MonsterClass { + humanoid, + insect, + demon, + construct, + animal, + giant, + undead, + reptile, + ghost + } + + public enum MovementType { + none, + helpOthers, + protectSpawn, + wholeMap + } + + @Override + public String getDesc() { + return (needsSaving() ? "*" : "") + name + " (" + id + ")"; + } + + public static String getStaticDesc() { + return "NPCs"; + } + + + @SuppressWarnings("rawtypes") + public static void fromJson(File jsonFile, GameDataCategory category) { + JSONParser parser = new JSONParser(); + FileReader reader = null; + try { + reader = new FileReader(jsonFile); + List npcs = (List) parser.parse(reader); + for (Object obj : npcs) { + Map npcJson = (Map) obj; + NPC npc = fromJson(npcJson); + npc.jsonFile = jsonFile; + npc.parent = category; + if (npc.getDataType() == GameSource.Type.created || npc.getDataType() == GameSource.Type.altered) { + npc.writable = true; + } + category.add(npc); + } + } catch (FileNotFoundException e) { + Notification.addError("Error while parsing JSON file " + jsonFile.getAbsolutePath() + ": " + e.getMessage()); + e.printStackTrace(); + } catch (IOException e) { + Notification.addError("Error while parsing JSON file " + jsonFile.getAbsolutePath() + ": " + e.getMessage()); + e.printStackTrace(); + } catch (ParseException e) { + Notification.addError("Error while parsing JSON file " + jsonFile.getAbsolutePath() + ": " + e.getMessage()); + e.printStackTrace(); + } finally { + if (reader != null) + try { + reader.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + @SuppressWarnings("rawtypes") + public static NPC fromJson(String jsonString) throws ParseException { + Map npcJson = (Map) new JSONParser().parse(jsonString); + NPC npc = fromJson(npcJson); + npc.parse(npcJson); + return npc; + } + + @SuppressWarnings("rawtypes") + public static NPC fromJson(Map npcJson) { + NPC npc = new NPC(); + npc.icon_id = (String) npcJson.get("iconID"); + npc.id = (String) npcJson.get("id"); + npc.name = (String) npcJson.get("name"); + return npc; + } + + + @SuppressWarnings("rawtypes") + @Override + public void parse(Map npcJson) { + + this.max_hp = JSONElement.getInteger((Number) npcJson.get("maxHP")); + this.max_ap = JSONElement.getInteger((Number) npcJson.get("maxAP")); + this.move_cost = JSONElement.getInteger((Number) npcJson.get("moveCost")); + this.unique = JSONElement.getInteger((Number) npcJson.get("unique")); + if (npcJson.get("monsterClass") != null) + this.monster_class = MonsterClass.valueOf((String) npcJson.get("monsterClass")); + if (npcJson.get("movementAggressionType") != null) + this.movement_type = MovementType.valueOf((String) npcJson.get("movementAggressionType")); + if (npcJson.get("attackDamage") != null) { + this.attack_damage_min = JSONElement.getInteger((Number) (((Map) npcJson.get("attackDamage")).get("min"))); + this.attack_damage_max = JSONElement.getInteger((Number) (((Map) npcJson.get("attackDamage")).get("max"))); + } + this.spawngroup_id = (String) npcJson.get("spawnGroup"); + this.faction_id = (String) npcJson.get("faction"); + this.dialogue_id = (String) npcJson.get("phraseID"); + this.droplist_id = (String) npcJson.get("droplistID"); + this.attack_cost = JSONElement.getInteger((Number) npcJson.get("attackCost")); + this.attack_chance = JSONElement.getInteger((Number) npcJson.get("attackChance")); + this.critical_skill = JSONElement.getInteger((Number) npcJson.get("criticalSkill")); + //TODO correct game data, to unify format. +// this.critical_multiplier = JSONElement.getDouble((Number) npcJson.get("criticalMultiplier")); + if (npcJson.get("criticalMultiplier") != null) + this.critical_multiplier = JSONElement.getDouble(Double.parseDouble(npcJson.get("criticalMultiplier").toString())); + + this.block_chance = JSONElement.getInteger((Number) npcJson.get("blockChance")); + this.damage_resistance = JSONElement.getInteger((Number) npcJson.get("damageResistance")); + + Map hitEffect = (Map) npcJson.get("hitEffect"); + if (hitEffect != null) { + this.hit_effect = new HitEffect(); + if (hitEffect.get("increaseCurrentHP") != null) { + this.hit_effect.hp_boost_max = JSONElement.getInteger((Number) (((Map) hitEffect.get("increaseCurrentHP")).get("max"))); + this.hit_effect.hp_boost_min = JSONElement.getInteger((Number) (((Map) hitEffect.get("increaseCurrentHP")).get("min"))); + } + if (hitEffect.get("increaseCurrentAP") != null) { + this.hit_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map) hitEffect.get("increaseCurrentAP")).get("max"))); + this.hit_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map) hitEffect.get("increaseCurrentAP")).get("min"))); + } + List conditionsSourceJson = (List) hitEffect.get("conditionsSource"); + this.hit_effect.conditions_source = parseTimedConditionEffects(conditionsSourceJson); + List conditionsTargetJson = (List) hitEffect.get("conditionsTarget"); + this.hit_effect.conditions_target = parseTimedConditionEffects(conditionsTargetJson); + } + + Map hitReceivedEffect = (Map) npcJson.get("hitReceivedEffect"); + if (hitReceivedEffect != null) { + this.hit_received_effect = parseHitReceivedEffect(hitReceivedEffect); + } + + Map deathEffect = (Map) npcJson.get("deathEffect"); + if (deathEffect != null) { + this.death_effect = new HitEffect(); + if (deathEffect.get("increaseCurrentHP") != null) { + this.death_effect.hp_boost_max = JSONElement.getInteger((Number) (((Map) deathEffect.get("increaseCurrentHP")).get("max"))); + this.death_effect.hp_boost_min = JSONElement.getInteger((Number) (((Map) deathEffect.get("increaseCurrentHP")).get("min"))); + } + if (deathEffect.get("increaseCurrentAP") != null) { + this.death_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map) deathEffect.get("increaseCurrentAP")).get("max"))); + this.death_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map) deathEffect.get("increaseCurrentAP")).get("min"))); + } + List conditionsSourceJson = (List) deathEffect.get("conditionsSource"); + this.death_effect.conditions_source = parseTimedConditionEffects(conditionsSourceJson); + } + + } + + @Override + public void link() { + if (shouldSkipParseOrLink()) { + return; + } + ensureParseIfNeeded(); + Project proj = getProject(); + if (proj == null) { + Notification.addError("Error linking item " + id + ". No parent project found."); + return; + } + if (this.icon_id != null) { + String spritesheetId = this.icon_id.split(":")[0]; + proj.getSpritesheet(spritesheetId).addBacklink(this); + } + + if (this.dialogue_id != null) this.dialogue = proj.getDialogue(this.dialogue_id); + if (this.dialogue != null) this.dialogue.addBacklink(this); + + if (this.droplist_id != null) this.droplist = proj.getDroplist(this.droplist_id); + if (this.droplist != null) this.droplist.addBacklink(this); + + if (this.hit_effect != null) { + linkConditions(this.hit_effect.conditions_source, proj, this); + linkConditions(this.hit_effect.conditions_target, proj, this); + } + if (this.hit_received_effect != null) { + linkConditions(this.hit_received_effect.conditions_source, proj, this); + linkConditions(this.hit_received_effect.conditions_target, proj, this); + } + if (this.death_effect != null) { + linkConditions(this.death_effect.conditions_source, proj, this); + } + this.state = State.linked; + } + + @Override + public Image getIcon() { + return getProject().getIcon(icon_id); + } + + public Image getImage() { + return getProject().getImage(icon_id); + } + + @Override + public GameDataElement clone() { + NPC clone = new NPC(); + clone.jsonFile = this.jsonFile; + clone.state = this.state; + clone.id = this.id; + clone.name = this.name; + clone.icon_id = this.icon_id; + clone.attack_chance = this.attack_chance; + clone.attack_cost = this.attack_cost; + clone.attack_damage_min = this.attack_damage_min; + clone.attack_damage_max = this.attack_damage_max; + clone.block_chance = this.block_chance; + clone.critical_multiplier = this.critical_multiplier; + clone.critical_skill = this.critical_skill; + clone.damage_resistance = this.damage_resistance; + clone.dialogue = this.dialogue; + if (clone.dialogue != null) { + clone.dialogue.addBacklink(clone); + } + clone.dialogue_id = this.dialogue_id; + clone.droplist = this.droplist; + if (clone.droplist != null) { + clone.droplist.addBacklink(clone); + } + clone.droplist_id = this.droplist_id; + clone.faction_id = this.faction_id; + if (this.hit_effect != null) { + clone.hit_effect = new HitEffect(); + copyHitEffectValues(clone.hit_effect, this.hit_effect, clone); + } + if (this.hit_received_effect != null) { + clone.hit_received_effect = new HitReceivedEffect(); + copyHitReceivedEffectValues(clone.hit_received_effect, this.hit_received_effect, clone); + } + if (this.death_effect != null) { + clone.death_effect = new DeathEffect(); + copyDeathEffectValues(clone.death_effect, this.death_effect, clone); + } + clone.max_ap = this.max_ap; + clone.max_hp = this.max_hp; + clone.monster_class = this.monster_class; + clone.move_cost = this.move_cost; + clone.movement_type = this.movement_type; + clone.spawngroup_id = this.spawngroup_id; + clone.unique = this.unique; + return clone; + } + + @Override + public void elementChanged(GameDataElement oldOne, GameDataElement newOne) { + if (dialogue == oldOne) { + oldOne.removeBacklink(this); + this.dialogue = (Dialogue) newOne; + if (newOne != null) newOne.addBacklink(this); + } else { + if (this.droplist == oldOne) { + oldOne.removeBacklink(this); + this.droplist = (Droplist) newOne; + if (newOne != null) newOne.addBacklink(this); + } else { + if (this.hit_effect != null && this.hit_effect.conditions_source != null) { + for (TimedActorConditionEffect tce : this.hit_effect.conditions_source) { + if (tce.condition == oldOne) { + oldOne.removeBacklink(this); + tce.condition = (ActorCondition) newOne; + if (newOne != null) newOne.addBacklink(this); + } + } + } + if (this.hit_effect != null && this.hit_effect.conditions_target != null) { + for (TimedActorConditionEffect tce : this.hit_effect.conditions_target) { + if (tce.condition == oldOne) { + oldOne.removeBacklink(this); + tce.condition = (ActorCondition) newOne; + if (newOne != null) newOne.addBacklink(this); + } + } + } + } + } + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + @Override + public Map toJson() { + Map npcJson = new LinkedHashMap(); + npcJson.put("id", this.id); + if (this.name != null) npcJson.put("name", this.name); + if (this.icon_id != null) npcJson.put("iconID", this.icon_id); + if (this.max_hp != null) npcJson.put("maxHP", this.max_hp); + if (this.max_ap != null) npcJson.put("maxAP", this.max_ap); + if (this.move_cost != null) npcJson.put("moveCost", this.move_cost); + if (this.unique != null) npcJson.put("unique", this.unique); + if (this.monster_class != null) npcJson.put("monsterClass", this.monster_class.toString()); + if (this.movement_type != null) npcJson.put("movementAggressionType", this.movement_type.toString()); + if (this.attack_damage_min != null || this.attack_damage_max != null) { + Map adJson = new LinkedHashMap(); + npcJson.put("attackDamage", adJson); + if (this.attack_damage_min != null) adJson.put("min", this.attack_damage_min); + else adJson.put("min", 0); + if (this.attack_damage_max != null) adJson.put("max", this.attack_damage_max); + else adJson.put("max", 0); + } + if (this.spawngroup_id != null) npcJson.put("spawnGroup", this.spawngroup_id); + if (this.faction_id != null) npcJson.put("faction", this.faction_id); + if (this.dialogue != null) { + npcJson.put("phraseID", this.dialogue.id); + } else if (this.dialogue_id != null) { + npcJson.put("phraseID", this.dialogue_id); + } + if (this.droplist != null) { + npcJson.put("droplistID", this.droplist.id); + } else if (this.droplist_id != null) { + npcJson.put("droplistID", this.droplist_id); + } + if (this.attack_cost != null) npcJson.put("attackCost", this.attack_cost); + if (this.attack_chance != null) npcJson.put("attackChance", this.attack_chance); + if (this.critical_skill != null) npcJson.put("criticalSkill", this.critical_skill); + if (this.critical_multiplier != null) npcJson.put("criticalMultiplier", this.critical_multiplier); + if (this.block_chance != null) npcJson.put("blockChance", this.block_chance); + if (this.damage_resistance != null) npcJson.put("damageResistance", this.damage_resistance); + if (this.hit_effect != null) { + Map hitEffectJson = new LinkedHashMap(); + npcJson.put("hitEffect", hitEffectJson); + if (this.hit_effect.hp_boost_min != null || this.hit_effect.hp_boost_max != null) { + Map hpJson = new LinkedHashMap(); + hitEffectJson.put("increaseCurrentHP", hpJson); + if (this.hit_effect.hp_boost_min != null) hpJson.put("min", this.hit_effect.hp_boost_min); + else hpJson.put("min", 0); + if (this.hit_effect.hp_boost_max != null) hpJson.put("max", this.hit_effect.hp_boost_max); + else hpJson.put("max", 0); + } + if (this.hit_effect.ap_boost_min != null || this.hit_effect.ap_boost_max != null) { + Map apJson = new LinkedHashMap(); + hitEffectJson.put("increaseCurrentAP", apJson); + if (this.hit_effect.ap_boost_min != null) apJson.put("min", this.hit_effect.ap_boost_min); + else apJson.put("min", 0); + if (this.hit_effect.ap_boost_max != null) apJson.put("max", this.hit_effect.ap_boost_max); + else apJson.put("max", 0); + } + if (this.hit_effect.conditions_source != null) { + List conditionsSourceJson = new ArrayList(); + hitEffectJson.put("conditionsSource", conditionsSourceJson); + for (TimedActorConditionEffect condition : this.hit_effect.conditions_source) { + Map conditionJson = new LinkedHashMap(); + conditionsSourceJson.add(conditionJson); + if (condition.condition != null) { + conditionJson.put("condition", condition.condition.id); + } else if (condition.condition_id != null) { + conditionJson.put("condition", condition.condition_id); + } + if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude); + if (condition.duration != null) conditionJson.put("duration", condition.duration); + if (condition.chance != null) + conditionJson.put("chance", JSONElement.printJsonChance(condition.chance)); + } + } + if (this.hit_effect.conditions_target != null) { + List conditionsTargetJson = new ArrayList(); + hitEffectJson.put("conditionsTarget", conditionsTargetJson); + for (TimedActorConditionEffect condition : this.hit_effect.conditions_target) { + Map conditionJson = new LinkedHashMap(); + conditionsTargetJson.add(conditionJson); + if (condition.condition != null) { + conditionJson.put("condition", condition.condition.id); + } else if (condition.condition_id != null) { + conditionJson.put("condition", condition.condition_id); + } + if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude); + if (condition.duration != null) conditionJson.put("duration", condition.duration); + if (condition.chance != null) + conditionJson.put("chance", JSONElement.printJsonChance(condition.chance)); + } + } + } + if (this.hit_received_effect != null) { + Map hitReceivedEffectJson = new LinkedHashMap(); + npcJson.put("hitReceivedEffect", hitReceivedEffectJson); + if (this.hit_received_effect.hp_boost_min != null || this.hit_received_effect.hp_boost_max != null) { + Map hpJson = new LinkedHashMap(); + hitReceivedEffectJson.put("increaseCurrentHP", hpJson); + if (this.hit_received_effect.hp_boost_min != null) + hpJson.put("min", this.hit_received_effect.hp_boost_min); + else hpJson.put("min", 0); + if (this.hit_received_effect.hp_boost_max != null) + hpJson.put("max", this.hit_received_effect.hp_boost_max); + else hpJson.put("max", 0); + } + if (this.hit_received_effect.ap_boost_min != null || this.hit_received_effect.ap_boost_max != null) { + Map apJson = new LinkedHashMap(); + hitReceivedEffectJson.put("increaseCurrentAP", apJson); + if (this.hit_received_effect.ap_boost_min != null) + apJson.put("min", this.hit_received_effect.ap_boost_min); + else apJson.put("min", 0); + if (this.hit_received_effect.ap_boost_max != null) + apJson.put("max", this.hit_received_effect.ap_boost_max); + else apJson.put("max", 0); + } + if (this.hit_received_effect.hp_boost_min_target != null || this.hit_received_effect.hp_boost_max_target != null) { + Map hpJson = new LinkedHashMap(); + hitReceivedEffectJson.put("increaseAttackerCurrentHP", hpJson); + if (this.hit_received_effect.hp_boost_min_target != null) + hpJson.put("min", this.hit_received_effect.hp_boost_min_target); + else hpJson.put("min", 0); + if (this.hit_received_effect.hp_boost_max_target != null) + hpJson.put("max", this.hit_received_effect.hp_boost_max_target); + else hpJson.put("max", 0); + } + if (this.hit_received_effect.ap_boost_min_target != null || this.hit_received_effect.ap_boost_max_target != null) { + Map apJson = new LinkedHashMap(); + hitReceivedEffectJson.put("increaseAttackerCurrentAP", apJson); + if (this.hit_received_effect.ap_boost_min_target != null) + apJson.put("min", this.hit_received_effect.ap_boost_min_target); + else apJson.put("min", 0); + if (this.hit_received_effect.ap_boost_max_target != null) + apJson.put("max", this.hit_received_effect.ap_boost_max_target); + else apJson.put("max", 0); + } + if (this.hit_received_effect.conditions_source != null) { + List conditionsSourceJson = new ArrayList(); + hitReceivedEffectJson.put("conditionsSource", conditionsSourceJson); + for (TimedActorConditionEffect condition : this.hit_received_effect.conditions_source) { + Map conditionJson = new LinkedHashMap(); + conditionsSourceJson.add(conditionJson); + if (condition.condition != null) { + conditionJson.put("condition", condition.condition.id); + } else if (condition.condition_id != null) { + conditionJson.put("condition", condition.condition_id); + } + if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude); + if (condition.duration != null) conditionJson.put("duration", condition.duration); + if (condition.chance != null) + conditionJson.put("chance", JSONElement.printJsonChance(condition.chance)); + } + } + if (this.hit_received_effect.conditions_target != null) { + List conditionsTargetJson = new ArrayList(); + hitReceivedEffectJson.put("conditionsTarget", conditionsTargetJson); + for (TimedActorConditionEffect condition : this.hit_received_effect.conditions_target) { + Map conditionJson = new LinkedHashMap(); + conditionsTargetJson.add(conditionJson); + if (condition.condition != null) { + conditionJson.put("condition", condition.condition.id); + } else if (condition.condition_id != null) { + conditionJson.put("condition", condition.condition_id); + } + if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude); + if (condition.duration != null) conditionJson.put("duration", condition.duration); + if (condition.chance != null) + conditionJson.put("chance", JSONElement.printJsonChance(condition.chance)); + } + } + } + if (this.death_effect != null) { + Map deathEffectJson = new LinkedHashMap(); + npcJson.put("deathEffect", deathEffectJson); + if (this.death_effect.hp_boost_min != null || this.death_effect.hp_boost_max != null) { + Map hpJson = new LinkedHashMap(); + deathEffectJson.put("increaseCurrentHP", hpJson); + if (this.death_effect.hp_boost_min != null) hpJson.put("min", this.death_effect.hp_boost_min); + else hpJson.put("min", 0); + if (this.death_effect.hp_boost_max != null) hpJson.put("max", this.death_effect.hp_boost_max); + else hpJson.put("max", 0); + } + if (this.death_effect.ap_boost_min != null || this.death_effect.ap_boost_max != null) { + Map apJson = new LinkedHashMap(); + deathEffectJson.put("increaseCurrentAP", apJson); + if (this.death_effect.ap_boost_min != null) apJson.put("min", this.death_effect.ap_boost_min); + else apJson.put("min", 0); + if (this.death_effect.ap_boost_max != null) apJson.put("max", this.death_effect.ap_boost_max); + else apJson.put("max", 0); + } + if (this.death_effect.conditions_source != null) { + List conditionsSourceJson = new ArrayList(); + deathEffectJson.put("conditionsSource", conditionsSourceJson); + for (TimedActorConditionEffect condition : this.death_effect.conditions_source) { + Map conditionJson = new LinkedHashMap(); + conditionsSourceJson.add(conditionJson); + if (condition.condition != null) { + conditionJson.put("condition", condition.condition.id); + } else if (condition.condition_id != null) { + conditionJson.put("condition", condition.condition_id); + } + if (condition.magnitude != null) conditionJson.put("magnitude", condition.magnitude); + if (condition.duration != null) conditionJson.put("duration", condition.duration); + if (condition.chance != null) + conditionJson.put("chance", JSONElement.printJsonChance(condition.chance)); + } + } + } + return npcJson; + } + + + @Override + public String getProjectFilename() { + return "monsterlist_" + getProject().name + ".json"; + } + + public int getMonsterExperience() { + double EXP_FACTOR_DAMAGERESISTANCE = 9; + double EXP_FACTOR_SCALING = 0.7; + + double attacksPerTurn = Math.floor((double) (max_ap != null ? max_ap : 10.0) / (double) (attack_cost != null ? attack_cost : 10.0)); + double avgDamagePotential = 0; + if (attack_damage_min != null || attack_damage_max != null) { + avgDamagePotential = ((double) (attack_damage_min != null ? attack_damage_min : 0) + (double) (attack_damage_max != null ? attack_damage_max : 0)) / 2.0; + } + double avgCrit = 0; + if (critical_skill != null && critical_multiplier != null) { + avgCrit = (double) (critical_skill / 100.0) * critical_multiplier; + } + double avgAttackHP = attacksPerTurn * ((double) (attack_chance != null ? attack_chance : 0) / 100.0) * avgDamagePotential * (1 + avgCrit); + double avgDefenseHP = ((max_hp != null ? max_hp : 1) * (1 + ((double) (block_chance != null ? block_chance : 0) / 100.0))) + (EXP_FACTOR_DAMAGERESISTANCE * (damage_resistance != null ? damage_resistance : 0)); + double attackConditionBonus = 0; + if (hit_effect != null && hit_effect.conditions_target != null && hit_effect.conditions_target.size() > 0) { + attackConditionBonus = 50; + } + double experience = (((avgAttackHP * 3) + avgDefenseHP) * EXP_FACTOR_SCALING) + attackConditionBonus; + + return new Double(Math.ceil(experience)).intValue(); + } + + +} diff --git a/src/com/gpl/rpg/atcontentstudio/ui/Editor.java b/src/com/gpl/rpg/atcontentstudio/ui/Editor.java index 01fb226..b971732 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/Editor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/Editor.java @@ -19,7 +19,6 @@ import javax.swing.text.DefaultFormatter; import javax.swing.text.JTextComponent; import java.awt.*; import java.awt.event.*; -import java.io.Console; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @@ -1106,10 +1105,10 @@ public abstract class Editor extends JPanel implements ProjectElementListener { } - protected > void updateConditionEffect(ActorCondition value, - GameDataElement backlink, - E selectedHitEffectTargetCondition, - T hitTargetConditionsModel) { + protected > void updateConditionEffect(ActorCondition value, + GameDataElement backlink, + E selectedHitEffectTargetCondition, + T hitTargetConditionsModel) { if (selectedHitEffectTargetCondition.condition != null) { selectedHitEffectTargetCondition.condition.removeBacklink(backlink); } diff --git a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ItemEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ItemEditor.java index 277af68..2c0f18f 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ItemEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ItemEditor.java @@ -14,8 +14,6 @@ import com.gpl.rpg.atcontentstudio.utils.UiUtils; import com.jidesoft.swing.JideBoxLayout; import javax.swing.*; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -33,12 +31,12 @@ public class ItemEditor extends JSONElementEditor { private static final String useLabel = "Effect on use: "; - private Common.ConditionEffect selectedEquipEffectCondition; - private Common.TimedConditionEffect selectedHitEffectSourceCondition; - private Common.TimedConditionEffect selectedHitEffectTargetCondition; - private Common.TimedConditionEffect selectedKillEffectCondition; - private Common.TimedConditionEffect selectedHitReceivedEffectSourceCondition; - private Common.TimedConditionEffect selectedHitReceivedEffectTargetCondition; + private Common.ActorConditionEffect selectedEquipEffectCondition; + private Common.TimedActorConditionEffect selectedHitEffectSourceCondition; + private Common.TimedActorConditionEffect selectedHitEffectTargetCondition; + private Common.TimedActorConditionEffect selectedKillEffectCondition; + private Common.TimedActorConditionEffect selectedHitReceivedEffectSourceCondition; + private Common.TimedActorConditionEffect selectedHitReceivedEffectTargetCondition; private JButton itemIcon; @@ -84,7 +82,7 @@ public class ItemEditor extends JSONElementEditor { private JSpinner hitAPMax; private SourceTimedConditionsListModel hitSourceConditionsModel; @SuppressWarnings("rawtypes") - private JList hitSourceConditionsList; + private JList hitSourceConditionsList; private MyComboBox hitSourceConditionBox; private JSpinner hitSourceConditionChance; private JRadioButton hitSourceConditionClear; @@ -214,8 +212,8 @@ public class ItemEditor extends JSONElementEditor { String titleEquipConditions = "Actor Conditions applied when equipped: "; equipConditionsModel = new ConditionsListModel(equipEffect); ConditionsCellRenderer cellRendererEquipConditions = new ConditionsCellRenderer(); - BasicLambdaWithArg selectedSetEquipConditions = (value)->selectedEquipEffectCondition = value; - BasicLambdaWithReturn selectedGetEquipConditions = ()->selectedEquipEffectCondition ; + BasicLambdaWithArg selectedSetEquipConditions = (value)->selectedEquipEffectCondition = value; + BasicLambdaWithReturn selectedGetEquipConditions = ()->selectedEquipEffectCondition ; BasicLambda selectedResetEquipConditions = ()->selectedEquipEffectCondition = null; BasicLambdaWithArg updatePaneEquipConditions = (editorPane) -> updateEquipConditionEditorPane(editorPane, selectedEquipEffectCondition, listener); var resultEquipConditions = UiUtils.getCollapsibleItemList(listener, @@ -226,7 +224,7 @@ public class ItemEditor extends JSONElementEditor { (x) -> {}, updatePaneEquipConditions, item.writable, - Common.ConditionEffect::new, + Common.ActorConditionEffect::new, cellRendererEquipConditions, titleEquipConditions, (x) -> null); @@ -255,11 +253,11 @@ public class ItemEditor extends JSONElementEditor { hitAPMax = addIntegerField(hitEffectPane, "AP bonus max: ", hitEffect.ap_boost_max, true, item.writable, listener); hitSourceConditionsModel = new SourceTimedConditionsListModel(hitEffect); - BasicLambdaWithReturn getSelected = () -> hitSourceConditionsList.getSelectedValue(); + BasicLambdaWithReturn getSelected = () -> hitSourceConditionsList.getSelectedValue(); BasicLambda resetSelected = () -> { selectedHitEffectSourceCondition = null; }; - BasicLambdaWithArg setSelected = (selectedItem) -> { + BasicLambdaWithArg setSelected = (selectedItem) -> { selectedHitEffectSourceCondition = selectedItem; }; BasicLambdaWithArg valueChanged = (selectedReply) -> { @@ -276,7 +274,7 @@ public class ItemEditor extends JSONElementEditor { valueChanged, updateEditorPane, item.writable, - Common.TimedConditionEffect::new, + Common.TimedActorConditionEffect::new, cellRenderer, title, (x) -> null @@ -290,8 +288,8 @@ public class ItemEditor extends JSONElementEditor { String titleHitTargetConditions = "Actor Conditions applied to the target: "; hitTargetConditionsModel = new TargetTimedConditionsListModel(hitEffect); ConditionsCellRenderer cellRendererHitTargetConditions = new ConditionsCellRenderer(); - BasicLambdaWithArg selectedSetHitTargetConditions = (value)->selectedHitEffectTargetCondition = value; - BasicLambdaWithReturn selectedGetHitTargetConditions = ()->selectedHitEffectTargetCondition ; + BasicLambdaWithArg selectedSetHitTargetConditions = (value)->selectedHitEffectTargetCondition = value; + BasicLambdaWithReturn selectedGetHitTargetConditions = ()->selectedHitEffectTargetCondition ; BasicLambda selectedResetHitTargetConditions = ()->selectedHitEffectTargetCondition = null; BasicLambdaWithArg updatePaneHitTargetConditions = (editorPane) -> updateHitTargetTimedConditionEditorPane(editorPane, selectedHitEffectTargetCondition, listener); var resultHitTargetConditions = UiUtils.getCollapsibleItemList(listener, @@ -302,7 +300,7 @@ public class ItemEditor extends JSONElementEditor { (x) -> {}, updatePaneHitTargetConditions, item.writable, - Common.TimedConditionEffect::new, + Common.TimedActorConditionEffect::new, cellRendererHitTargetConditions, titleHitTargetConditions, (x) -> null); @@ -333,8 +331,8 @@ public class ItemEditor extends JSONElementEditor { String titleKillSourceConditions = "Actor Conditions applied to the source: "; killSourceConditionsModel = new SourceTimedConditionsListModel(killEffect); TimedConditionsCellRenderer cellRendererKillSourceConditions = new TimedConditionsCellRenderer(); - BasicLambdaWithArg selectedSetKillSourceConditions = (value)->selectedKillEffectCondition = value; - BasicLambdaWithReturn selectedGetKillSourceConditions = ()->selectedKillEffectCondition ; + BasicLambdaWithArg selectedSetKillSourceConditions = (value)->selectedKillEffectCondition = value; + BasicLambdaWithReturn selectedGetKillSourceConditions = ()->selectedKillEffectCondition ; BasicLambda selectedResetKillSourceConditions = ()->selectedKillEffectCondition = null; BasicLambdaWithArg updatePaneKillSourceConditions = (editorPane) -> updateKillSourceTimedConditionEditorPane(editorPane, selectedKillEffectCondition, listener); var resultKillSourceConditions = UiUtils.getCollapsibleItemList(listener, @@ -345,7 +343,7 @@ public class ItemEditor extends JSONElementEditor { (x) -> {}, updatePaneKillSourceConditions, item.writable, - Common.TimedConditionEffect::new, + Common.TimedActorConditionEffect::new, cellRendererKillSourceConditions, titleKillSourceConditions, (x) -> null); @@ -373,16 +371,17 @@ public class ItemEditor extends JSONElementEditor { hitReceivedHPMax = addIntegerField(hitReceivedEffectPane, "Player HP bonus max: ", hitReceivedEffect.hp_boost_max, true, item.writable, listener); hitReceivedAPMin = addIntegerField(hitReceivedEffectPane, "Player AP bonus min: ", hitReceivedEffect.ap_boost_min, true, item.writable, listener); hitReceivedAPMax = addIntegerField(hitReceivedEffectPane, "Player AP bonus max: ", hitReceivedEffect.ap_boost_max, true, item.writable, listener); - hitReceivedHPMinTarget = addIntegerField(hitReceivedEffectPane, "Attacker HP bonus min: ", hitReceivedEffect.hp_boost_min_target, true, item.writable, listener); - hitReceivedHPMaxTarget = addIntegerField(hitReceivedEffectPane, "Attacker HP bonus max: ", hitReceivedEffect.hp_boost_max_target, true, item.writable, listener); - hitReceivedAPMinTarget = addIntegerField(hitReceivedEffectPane, "Attacker AP bonus min: ", hitReceivedEffect.ap_boost_min_target, true, item.writable, listener); - hitReceivedAPMaxTarget = addIntegerField(hitReceivedEffectPane, "Attacker AP bonus max: ", hitReceivedEffect.ap_boost_max_target, true, item.writable, listener); + String roleHitReceivedTarget = "Attacker"; + hitReceivedHPMinTarget = addIntegerField(hitReceivedEffectPane, roleHitReceivedTarget + " HP bonus min: ", hitReceivedEffect.target.hp_boost_min, true, item.writable, listener); + hitReceivedHPMaxTarget = addIntegerField(hitReceivedEffectPane, roleHitReceivedTarget + " HP bonus max: ", hitReceivedEffect.target.hp_boost_max, true, item.writable, listener); + hitReceivedAPMinTarget = addIntegerField(hitReceivedEffectPane, roleHitReceivedTarget + " AP bonus min: ", hitReceivedEffect.target.ap_boost_min, true, item.writable, listener); + hitReceivedAPMaxTarget = addIntegerField(hitReceivedEffectPane, roleHitReceivedTarget + " AP bonus max: ", hitReceivedEffect.target.ap_boost_max, true, item.writable, listener); String titleHitReceivedSourceConditions = "Actor Conditions applied to the player: "; hitReceivedSourceConditionsModel = new SourceTimedConditionsListModel(killEffect); TimedConditionsCellRenderer cellRendererHitReceivedSourceConditions = new TimedConditionsCellRenderer(); - BasicLambdaWithArg selectedSetHitReceivedSourceConditions = (value)->selectedHitReceivedEffectSourceCondition = value; - BasicLambdaWithReturn selectedGetHitReceivedSourceConditions = ()->selectedHitReceivedEffectSourceCondition ; + BasicLambdaWithArg selectedSetHitReceivedSourceConditions = (value)->selectedHitReceivedEffectSourceCondition = value; + BasicLambdaWithReturn selectedGetHitReceivedSourceConditions = ()->selectedHitReceivedEffectSourceCondition ; BasicLambda selectedResetHitReceivedSourceConditions = ()->selectedHitReceivedEffectSourceCondition = null; BasicLambdaWithArg updatePaneHitReceivedSourceConditions = (editorPane) -> updateHitReceivedSourceTimedConditionEditorPane(editorPane, selectedHitReceivedEffectSourceCondition, listener); var resultHitReceivedSourceConditions = UiUtils.getCollapsibleItemList(listener, @@ -393,7 +392,7 @@ public class ItemEditor extends JSONElementEditor { (x) -> {}, updatePaneHitReceivedSourceConditions, item.writable, - Common.TimedConditionEffect::new, + Common.TimedActorConditionEffect::new, cellRendererHitReceivedSourceConditions, titleHitReceivedSourceConditions, (x) -> null); @@ -407,8 +406,8 @@ public class ItemEditor extends JSONElementEditor { String titleHitReceivedTargetConditions = "Actor Conditions applied to the attacker: "; hitReceivedTargetConditionsModel = new TargetTimedConditionsListModel(hitReceivedEffect); TimedConditionsCellRenderer cellRendererHitReceivedTargetConditions = new TimedConditionsCellRenderer(); - BasicLambdaWithArg selectedSetHitReceivedTargetConditions = (value)->selectedHitReceivedEffectTargetCondition = value; - BasicLambdaWithReturn selectedGetHitReceivedTargetConditions = ()->selectedHitReceivedEffectTargetCondition ; + BasicLambdaWithArg selectedSetHitReceivedTargetConditions = (value)->selectedHitReceivedEffectTargetCondition = value; + BasicLambdaWithReturn selectedGetHitReceivedTargetConditions = ()->selectedHitReceivedEffectTargetCondition ; BasicLambda selectedResetHitReceivedTargetConditions = ()->selectedHitReceivedEffectTargetCondition = null; BasicLambdaWithArg updatePaneHitReceivedTargetConditions = (editorPane) -> updateHitReceivedTargetTimedConditionEditorPane(editorPane, selectedHitReceivedEffectTargetCondition, listener); var resultHitReceivedTargetConditions = UiUtils.getCollapsibleItemList(listener, @@ -419,7 +418,7 @@ public class ItemEditor extends JSONElementEditor { (x) -> {}, updatePaneHitReceivedTargetConditions, item.writable, - Common.TimedConditionEffect::new, + Common.TimedActorConditionEffect::new, cellRendererHitReceivedTargetConditions, titleHitReceivedTargetConditions, (x) -> null); @@ -458,7 +457,7 @@ public class ItemEditor extends JSONElementEditor { } - public void updateHitSourceTimedConditionEditorPane(JPanel pane, Common.TimedConditionEffect condition, final FieldUpdateListener listener) { + public void updateHitSourceTimedConditionEditorPane(JPanel pane, Common.TimedActorConditionEffect condition, final FieldUpdateListener listener) { pane.removeAll(); if (hitSourceConditionBox != null) { removeElementListener(hitSourceConditionBox); @@ -536,7 +535,7 @@ public class ItemEditor extends JSONElementEditor { pane.repaint(); } - public void updateHitSourceTimedConditionWidgets(Common.TimedConditionEffect condition) { + public void updateHitSourceTimedConditionWidgets(Common.TimedActorConditionEffect condition) { boolean immunity = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration != null && condition.duration > ActorCondition.DURATION_NONE); boolean clear = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration == null || condition.duration == ActorCondition.DURATION_NONE); @@ -554,7 +553,7 @@ public class ItemEditor extends JSONElementEditor { hitSourceConditionForever.setEnabled(!clear); } - public void updateHitTargetTimedConditionEditorPane(JPanel pane, Common.TimedConditionEffect condition, final FieldUpdateListener listener) { + public void updateHitTargetTimedConditionEditorPane(JPanel pane, Common.TimedActorConditionEffect condition, final FieldUpdateListener listener) { pane.removeAll(); if (hitTargetConditionBox != null) { removeElementListener(hitTargetConditionBox); @@ -632,7 +631,7 @@ public class ItemEditor extends JSONElementEditor { pane.repaint(); } - public void updateHitTargetTimedConditionWidgets(Common.TimedConditionEffect condition) { + public void updateHitTargetTimedConditionWidgets(Common.TimedActorConditionEffect condition) { boolean immunity = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration != null && condition.duration > ActorCondition.DURATION_NONE); boolean clear = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration == null || condition.duration == ActorCondition.DURATION_NONE); @@ -650,7 +649,7 @@ public class ItemEditor extends JSONElementEditor { hitTargetConditionForever.setEnabled(!clear); } - public void updateKillSourceTimedConditionEditorPane(JPanel pane, Common.TimedConditionEffect condition, final FieldUpdateListener listener) { + public void updateKillSourceTimedConditionEditorPane(JPanel pane, Common.TimedActorConditionEffect condition, final FieldUpdateListener listener) { pane.removeAll(); if (killSourceConditionBox != null) { removeElementListener(killSourceConditionBox); @@ -728,7 +727,7 @@ public class ItemEditor extends JSONElementEditor { pane.repaint(); } - public void updateKillSourceTimedConditionWidgets(Common.TimedConditionEffect condition) { + public void updateKillSourceTimedConditionWidgets(Common.TimedActorConditionEffect condition) { boolean immunity = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration != null && condition.duration > ActorCondition.DURATION_NONE); boolean clear = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration == null || condition.duration == ActorCondition.DURATION_NONE); @@ -746,7 +745,7 @@ public class ItemEditor extends JSONElementEditor { killSourceConditionForever.setEnabled(!clear); } - public void updateEquipConditionEditorPane(JPanel pane, Common.ConditionEffect condition, final FieldUpdateListener listener) { + public void updateEquipConditionEditorPane(JPanel pane, Common.ActorConditionEffect condition, final FieldUpdateListener listener) { pane.removeAll(); if (equipConditionBox != null) { removeElementListener(equipConditionBox); @@ -794,7 +793,7 @@ public class ItemEditor extends JSONElementEditor { pane.repaint(); } - public void updateHitReceivedSourceTimedConditionEditorPane(JPanel pane, Common.TimedConditionEffect condition, final FieldUpdateListener listener) { + public void updateHitReceivedSourceTimedConditionEditorPane(JPanel pane, Common.TimedActorConditionEffect condition, final FieldUpdateListener listener) { pane.removeAll(); if (hitReceivedSourceConditionBox != null) { removeElementListener(hitReceivedSourceConditionBox); @@ -872,7 +871,7 @@ public class ItemEditor extends JSONElementEditor { pane.repaint(); } - public void updateHitReceivedSourceTimedConditionWidgets(Common.TimedConditionEffect condition) { + public void updateHitReceivedSourceTimedConditionWidgets(Common.TimedActorConditionEffect condition) { boolean immunity = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration != null && condition.duration > ActorCondition.DURATION_NONE); boolean clear = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration == null || condition.duration == ActorCondition.DURATION_NONE); @@ -890,7 +889,7 @@ public class ItemEditor extends JSONElementEditor { hitReceivedSourceConditionForever.setEnabled(!clear); } - public void updateHitReceivedTargetTimedConditionEditorPane(JPanel pane, Common.TimedConditionEffect condition, final FieldUpdateListener listener) { + public void updateHitReceivedTargetTimedConditionEditorPane(JPanel pane, Common.TimedActorConditionEffect condition, final FieldUpdateListener listener) { pane.removeAll(); if (hitReceivedTargetConditionBox != null) { removeElementListener(hitReceivedTargetConditionBox); @@ -968,7 +967,7 @@ public class ItemEditor extends JSONElementEditor { pane.repaint(); } - public void updateHitReceivedTargetTimedConditionWidgets(Common.TimedConditionEffect condition) { + public void updateHitReceivedTargetTimedConditionWidgets(Common.TimedActorConditionEffect condition) { boolean immunity = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration != null && condition.duration > ActorCondition.DURATION_NONE); boolean clear = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration == null || condition.duration == ActorCondition.DURATION_NONE); @@ -987,34 +986,34 @@ public class ItemEditor extends JSONElementEditor { } - public static class SourceTimedConditionsListModel extends OrderedListenerListModel { + public static class SourceTimedConditionsListModel extends OrderedListenerListModel { public SourceTimedConditionsListModel(Common.DeathEffect effect) { super(effect); } @Override - protected List getItems() { + protected List getItems() { return source.conditions_source; } @Override - protected void setItems(List items) { + protected void setItems(List items) { source.conditions_source = items; } } - public static class TargetTimedConditionsListModel extends OrderedListenerListModel { + public static class TargetTimedConditionsListModel extends OrderedListenerListModel { public TargetTimedConditionsListModel(Common.HitEffect effect) { super(effect); } @Override - protected List getItems() { + protected List getItems() { return source.conditions_target; } @Override - protected void setItems(List items) { + protected void setItems(List items) { source.conditions_target = items; } } @@ -1027,7 +1026,7 @@ public class ItemEditor extends JSONElementEditor { Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (c instanceof JLabel) { JLabel label = ((JLabel) c); - Common.TimedConditionEffect effect = (Common.TimedConditionEffect) value; + Common.TimedActorConditionEffect effect = (Common.TimedActorConditionEffect) value; if (effect.condition != null) { @@ -1053,18 +1052,18 @@ public class ItemEditor extends JSONElementEditor { } } - public static class ConditionsListModel extends OrderedListenerListModel { + public static class ConditionsListModel extends OrderedListenerListModel { public ConditionsListModel(Item.EquipEffect equipEffect) { super(equipEffect); } @Override - protected List getItems() { + protected List getItems() { return source.conditions; } @Override - protected void setItems(List conditions) { + protected void setItems(List conditions) { source.conditions = conditions; } } @@ -1077,7 +1076,7 @@ public class ItemEditor extends JSONElementEditor { Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (c instanceof JLabel) { JLabel label = ((JLabel) c); - Common.ConditionEffect effect = (Common.ConditionEffect) value; + Common.ActorConditionEffect effect = (Common.ActorConditionEffect) value; if (effect.condition != null) { if (effect.magnitude == ActorCondition.MAGNITUDE_CLEAR) { @@ -1703,6 +1702,7 @@ public class ItemEditor extends JSONElementEditor { } + } } diff --git a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/NPCEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/NPCEditor.java index 23274ce..6583a04 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/NPCEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/NPCEditor.java @@ -15,8 +15,6 @@ import com.gpl.rpg.atcontentstudio.utils.UiUtils; import com.jidesoft.swing.JideBoxLayout; import javax.swing.*; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -31,11 +29,11 @@ public class NPCEditor extends JSONElementEditor { private static final String json_view_id = "JSON"; private static final String dialogue_tree_id = "Dialogue Tree"; - private Common.TimedConditionEffect selectedHitEffectSourceCondition; - private Common.TimedConditionEffect selectedHitEffectTargetCondition; - private Common.TimedConditionEffect selectedHitReceivedEffectSourceCondition; - private Common.TimedConditionEffect selectedHitReceivedEffectTargetCondition; - private Common.TimedConditionEffect selectedDeathEffectSourceCondition; + private Common.TimedActorConditionEffect selectedHitEffectSourceCondition; + private Common.TimedActorConditionEffect selectedHitEffectTargetCondition; + private Common.TimedActorConditionEffect selectedHitReceivedEffectSourceCondition; + private Common.TimedActorConditionEffect selectedHitReceivedEffectTargetCondition; + private Common.TimedActorConditionEffect selectedDeathEffectSourceCondition; private JButton npcIcon; private JTextField idField; @@ -254,8 +252,8 @@ public class NPCEditor extends JSONElementEditor { String titleSource = "Actor Conditions applied to the source: "; hitSourceConditionsListModel = new SourceTimedConditionsListModel(hitEffect); TimedConditionsCellRenderer cellRendererSource = new TimedConditionsCellRenderer(); - BasicLambdaWithArg selectedSetSource = (value)->selectedHitEffectSourceCondition = value; - BasicLambdaWithReturn selectedGetSource = ()->selectedHitEffectSourceCondition ; + BasicLambdaWithArg selectedSetSource = (value)->selectedHitEffectSourceCondition = value; + BasicLambdaWithReturn selectedGetSource = ()->selectedHitEffectSourceCondition ; BasicLambda selectedResetSource = ()->selectedHitEffectSourceCondition = null; BasicLambdaWithArg updatePaneSource = (editorPane) -> updateHitSourceTimedConditionEditorPane(editorPane, selectedHitEffectSourceCondition, listener); @@ -267,7 +265,7 @@ public class NPCEditor extends JSONElementEditor { (x) -> {}, updatePaneSource, npc.writable, - Common.TimedConditionEffect::new, + Common.TimedActorConditionEffect::new, cellRendererSource, titleSource, (x) -> null); @@ -281,8 +279,8 @@ public class NPCEditor extends JSONElementEditor { String titleTarget = "Actor Conditions applied to the target: "; hitTargetConditionsListModel = new TargetTimedConditionsListModel(hitEffect); TimedConditionsCellRenderer cellRendererTarget = new TimedConditionsCellRenderer(); - BasicLambdaWithArg selectedSetTarget = (value)->selectedHitEffectTargetCondition = value; - BasicLambdaWithReturn selectedGetTarget = ()->selectedHitEffectTargetCondition ; + BasicLambdaWithArg selectedSetTarget = (value)->selectedHitEffectTargetCondition = value; + BasicLambdaWithReturn selectedGetTarget = ()->selectedHitEffectTargetCondition ; BasicLambda selectedResetTarget = ()->selectedHitEffectTargetCondition = null; BasicLambdaWithArg updatePaneTarget = (editorPane) -> updateHitTargetTimedConditionEditorPane(editorPane, selectedHitEffectTargetCondition, listener); var resultTarget = UiUtils.getCollapsibleItemList(listener, @@ -293,7 +291,7 @@ public class NPCEditor extends JSONElementEditor { (x) -> {}, updatePaneTarget, npc.writable, - Common.TimedConditionEffect::new, + Common.TimedActorConditionEffect::new, cellRendererTarget, titleTarget, (x) -> null); @@ -315,16 +313,16 @@ public class NPCEditor extends JSONElementEditor { hitReceivedEffectHPMax = addIntegerField(hitReceivedEffectPane, "NPC HP bonus max: ", hitReceivedEffect.hp_boost_max, true, npc.writable, listener); hitReceivedEffectAPMin = addIntegerField(hitReceivedEffectPane, "NPC AP bonus min: ", hitReceivedEffect.ap_boost_min, true, npc.writable, listener); hitReceivedEffectAPMax = addIntegerField(hitReceivedEffectPane, "NPC AP bonus max: ", hitReceivedEffect.ap_boost_max, true, npc.writable, listener); - hitReceivedEffectHPMinTarget = addIntegerField(hitReceivedEffectPane, "Attacker HP bonus min: ", hitReceivedEffect.hp_boost_min_target, true, npc.writable, listener); - hitReceivedEffectHPMaxTarget = addIntegerField(hitReceivedEffectPane, "Attacker HP bonus max: ", hitReceivedEffect.hp_boost_max_target, true, npc.writable, listener); - hitReceivedEffectAPMinTarget = addIntegerField(hitReceivedEffectPane, "Attacker AP bonus min: ", hitReceivedEffect.ap_boost_min_target, true, npc.writable, listener); - hitReceivedEffectAPMaxTarget = addIntegerField(hitReceivedEffectPane, "Attacker AP bonus max: ", hitReceivedEffect.ap_boost_max_target, true, npc.writable, listener); + hitReceivedEffectHPMinTarget = addIntegerField(hitReceivedEffectPane, "Attacker HP bonus min: ", hitReceivedEffect.target.hp_boost_min, true, npc.writable, listener); + hitReceivedEffectHPMaxTarget = addIntegerField(hitReceivedEffectPane, "Attacker HP bonus max: ", hitReceivedEffect.target.hp_boost_max, true, npc.writable, listener); + hitReceivedEffectAPMinTarget = addIntegerField(hitReceivedEffectPane, "Attacker AP bonus min: ", hitReceivedEffect.target.ap_boost_min, true, npc.writable, listener); + hitReceivedEffectAPMaxTarget = addIntegerField(hitReceivedEffectPane, "Attacker AP bonus max: ", hitReceivedEffect.target.ap_boost_max, true, npc.writable, listener); String titleReceivedSource = "Actor Conditions applied to this NPC: "; hitReceivedSourceConditionsListModel = new SourceTimedConditionsListModel(hitReceivedEffect); TimedConditionsCellRenderer cellRendererReceivedSource = new TimedConditionsCellRenderer(); - BasicLambdaWithArg selectedSetReceivedSource = (value)->selectedHitReceivedEffectSourceCondition = value; - BasicLambdaWithReturn selectedGetReceivedSource = ()->selectedHitReceivedEffectSourceCondition ; + BasicLambdaWithArg selectedSetReceivedSource = (value)->selectedHitReceivedEffectSourceCondition = value; + BasicLambdaWithReturn selectedGetReceivedSource = ()->selectedHitReceivedEffectSourceCondition ; BasicLambda selectedResetReceivedSource = ()->selectedHitReceivedEffectSourceCondition = null; BasicLambdaWithArg updatePaneReceivedSource = (editorPane) -> updateHitReceivedSourceTimedConditionEditorPane(editorPane, selectedHitReceivedEffectSourceCondition, listener); var resultReceivedSource = UiUtils.getCollapsibleItemList(listener, @@ -335,7 +333,7 @@ public class NPCEditor extends JSONElementEditor { (x) -> {}, updatePaneReceivedSource, npc.writable, - Common.TimedConditionEffect::new, + Common.TimedActorConditionEffect::new, cellRendererReceivedSource, titleReceivedSource, (x) -> null); @@ -349,8 +347,8 @@ public class NPCEditor extends JSONElementEditor { String titleReceivedTarget = "Actor Conditions applied to the attacker: "; hitReceivedTargetConditionsListModel = new TargetTimedConditionsListModel(hitReceivedEffect); TimedConditionsCellRenderer cellRendererReceivedTarget = new TimedConditionsCellRenderer(); - BasicLambdaWithArg selectedSetReceivedTarget = (value)->selectedHitReceivedEffectTargetCondition = value; - BasicLambdaWithReturn selectedGetReceivedTarget = ()->selectedHitReceivedEffectTargetCondition ; + BasicLambdaWithArg selectedSetReceivedTarget = (value)->selectedHitReceivedEffectTargetCondition = value; + BasicLambdaWithReturn selectedGetReceivedTarget = ()->selectedHitReceivedEffectTargetCondition ; BasicLambda selectedResetReceivedTarget = ()->selectedHitReceivedEffectTargetCondition = null; BasicLambdaWithArg updatePaneReceivedTarget = (editorPane) -> updateHitReceivedTargetTimedConditionEditorPane(editorPane, selectedHitReceivedEffectTargetCondition, listener); var resultReceivedTarget = UiUtils.getCollapsibleItemList(listener, @@ -361,7 +359,7 @@ public class NPCEditor extends JSONElementEditor { (x) -> {}, updatePaneReceivedTarget, npc.writable, - Common.TimedConditionEffect::new, + Common.TimedActorConditionEffect::new, cellRendererReceivedTarget, titleReceivedTarget, (x) -> null); @@ -387,8 +385,8 @@ public class NPCEditor extends JSONElementEditor { String titleDeathSource = "Actor Conditions applied to the killer: "; deathSourceConditionsListModel = new SourceTimedConditionsListModel(deathEffect); TimedConditionsCellRenderer cellRendererDeathSource = new TimedConditionsCellRenderer(); - BasicLambdaWithArg selectedSetDeathSource = (value)->selectedDeathEffectSourceCondition = value; - BasicLambdaWithReturn selectedGetDeathSource = ()->selectedDeathEffectSourceCondition ; + BasicLambdaWithArg selectedSetDeathSource = (value)->selectedDeathEffectSourceCondition = value; + BasicLambdaWithReturn selectedGetDeathSource = ()->selectedDeathEffectSourceCondition ; BasicLambda selectedResetDeathSource = ()->selectedDeathEffectSourceCondition = null; BasicLambdaWithArg updatePaneDeathSource = (editorPane) -> updateDeathSourceTimedConditionEditorPane(editorPane, selectedDeathEffectSourceCondition, listener); var resultDeathSource = UiUtils.getCollapsibleItemList(listener, @@ -399,7 +397,7 @@ public class NPCEditor extends JSONElementEditor { (x) -> {}, updatePaneDeathSource, npc.writable, - Common.TimedConditionEffect::new, + Common.TimedActorConditionEffect::new, cellRendererDeathSource, titleDeathSource, (x) -> null); @@ -415,7 +413,7 @@ public class NPCEditor extends JSONElementEditor { pane.add(combatTraitPane, JideBoxLayout.FIX); } - public void updateHitSourceTimedConditionEditorPane(JPanel pane, Common.TimedConditionEffect condition, final FieldUpdateListener listener) { + public void updateHitSourceTimedConditionEditorPane(JPanel pane, Common.TimedActorConditionEffect condition, final FieldUpdateListener listener) { pane.removeAll(); if (hitSourceConditionBox != null) { removeElementListener(hitSourceConditionBox); @@ -487,7 +485,7 @@ public class NPCEditor extends JSONElementEditor { pane.repaint(); } - public void updateHitSourceTimedConditionWidgets(Common.TimedConditionEffect condition) { + public void updateHitSourceTimedConditionWidgets(Common.TimedActorConditionEffect condition) { boolean immunity = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration != null && condition.duration > ActorCondition.DURATION_NONE); boolean clear = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration == null || condition.duration == ActorCondition.DURATION_NONE); @@ -506,7 +504,7 @@ public class NPCEditor extends JSONElementEditor { } - public void updateHitTargetTimedConditionEditorPane(JPanel pane, Common.TimedConditionEffect condition, final FieldUpdateListener listener) { + public void updateHitTargetTimedConditionEditorPane(JPanel pane, Common.TimedActorConditionEffect condition, final FieldUpdateListener listener) { pane.removeAll(); if (hitTargetConditionBox != null) { removeElementListener(hitTargetConditionBox); @@ -577,7 +575,7 @@ public class NPCEditor extends JSONElementEditor { pane.repaint(); } - public void updateHitTargetTimedConditionWidgets(Common.TimedConditionEffect condition) { + public void updateHitTargetTimedConditionWidgets(Common.TimedActorConditionEffect condition) { boolean immunity = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration != null && condition.duration > ActorCondition.DURATION_NONE); boolean clear = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration == null || condition.duration == ActorCondition.DURATION_NONE); @@ -596,7 +594,7 @@ public class NPCEditor extends JSONElementEditor { } - public void updateHitReceivedSourceTimedConditionEditorPane(JPanel pane, Common.TimedConditionEffect condition, final FieldUpdateListener listener) { + public void updateHitReceivedSourceTimedConditionEditorPane(JPanel pane, Common.TimedActorConditionEffect condition, final FieldUpdateListener listener) { pane.removeAll(); if (hitReceivedSourceConditionBox != null) { removeElementListener(hitReceivedSourceConditionBox); @@ -668,7 +666,7 @@ public class NPCEditor extends JSONElementEditor { pane.repaint(); } - public void updateHitReceivedSourceTimedConditionWidgets(Common.TimedConditionEffect condition) { + public void updateHitReceivedSourceTimedConditionWidgets(Common.TimedActorConditionEffect condition) { boolean immunity = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration != null && condition.duration > ActorCondition.DURATION_NONE); boolean clear = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration == null || condition.duration == ActorCondition.DURATION_NONE); @@ -687,7 +685,7 @@ public class NPCEditor extends JSONElementEditor { } - public void updateHitReceivedTargetTimedConditionEditorPane(JPanel pane, Common.TimedConditionEffect condition, final FieldUpdateListener listener) { + public void updateHitReceivedTargetTimedConditionEditorPane(JPanel pane, Common.TimedActorConditionEffect condition, final FieldUpdateListener listener) { pane.removeAll(); if (hitReceivedTargetConditionBox != null) { removeElementListener(hitReceivedTargetConditionBox); @@ -758,7 +756,7 @@ public class NPCEditor extends JSONElementEditor { pane.repaint(); } - public void updateHitReceivedTargetTimedConditionWidgets(Common.TimedConditionEffect condition) { + public void updateHitReceivedTargetTimedConditionWidgets(Common.TimedActorConditionEffect condition) { boolean immunity = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration != null && condition.duration > ActorCondition.DURATION_NONE); boolean clear = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration == null || condition.duration == ActorCondition.DURATION_NONE); @@ -776,7 +774,7 @@ public class NPCEditor extends JSONElementEditor { hitReceivedTargetConditionForever.setEnabled(!clear); } - public void updateDeathSourceTimedConditionEditorPane(JPanel pane, Common.TimedConditionEffect condition, final FieldUpdateListener listener) { + public void updateDeathSourceTimedConditionEditorPane(JPanel pane, Common.TimedActorConditionEffect condition, final FieldUpdateListener listener) { pane.removeAll(); if (deathSourceConditionBox != null) { removeElementListener(deathSourceConditionBox); @@ -848,7 +846,7 @@ public class NPCEditor extends JSONElementEditor { pane.repaint(); } - public void updateDeathSourceTimedConditionWidgets(Common.TimedConditionEffect condition) { + public void updateDeathSourceTimedConditionWidgets(Common.TimedActorConditionEffect condition) { boolean immunity = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration != null && condition.duration > ActorCondition.DURATION_NONE); boolean clear = (condition.magnitude == null || condition.magnitude == ActorCondition.MAGNITUDE_CLEAR) && (condition.duration == null || condition.duration == ActorCondition.DURATION_NONE); @@ -866,34 +864,34 @@ public class NPCEditor extends JSONElementEditor { deathSourceConditionForever.setEnabled(!clear); } - public static class TargetTimedConditionsListModel extends OrderedListenerListModel { + public static class TargetTimedConditionsListModel extends OrderedListenerListModel { public TargetTimedConditionsListModel(Common.HitEffect effect) { super(effect); } @Override - protected List getItems() { + protected List getItems() { return source.conditions_target; } @Override - protected void setItems(List items) { + protected void setItems(List items) { source.conditions_target = items; } } - public static class SourceTimedConditionsListModel extends OrderedListenerListModel { + public static class SourceTimedConditionsListModel extends OrderedListenerListModel { public SourceTimedConditionsListModel(Common.DeathEffect effect) { super(effect); } @Override - protected List getItems() { + protected List getItems() { return source.conditions_source; } @Override - protected void setItems(List items) { + protected void setItems(List items) { source.conditions_source = items; } } @@ -906,7 +904,7 @@ public class NPCEditor extends JSONElementEditor { Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (c instanceof JLabel) { JLabel label = ((JLabel) c); - Common.TimedConditionEffect effect = (Common.TimedConditionEffect) value; + Common.TimedActorConditionEffect effect = (Common.TimedActorConditionEffect) value; if (effect.condition != null) { diff --git a/src/com/gpl/rpg/atcontentstudio/ui/tools/GDEVisitor.java b/src/com/gpl/rpg/atcontentstudio/ui/tools/GDEVisitor.java index e8d7e76..39c32ea 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/tools/GDEVisitor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/tools/GDEVisitor.java @@ -96,18 +96,18 @@ public class GDEVisitor { if (element.icon_id != null) visit(element.getProject().getSpritesheet(element.icon_id.split(":")[0]), visited, includeSource); if (element.equip_effect != null && element.equip_effect.conditions != null) { - for (Common.ConditionEffect condEffect : element.equip_effect.conditions) { + for (Common.ActorConditionEffect condEffect : element.equip_effect.conditions) { visit(condEffect.condition, visited, includeSource); } } if (element.hit_effect != null) { if (element.hit_effect.conditions_source != null) { - for (Common.ConditionEffect condEffect : element.hit_effect.conditions_source) { + for (Common.ActorConditionEffect condEffect : element.hit_effect.conditions_source) { visit(condEffect.condition, visited, includeSource); } } if (element.hit_effect.conditions_target != null) { - for (Common.ConditionEffect condEffect : element.hit_effect.conditions_target) { + for (Common.ActorConditionEffect condEffect : element.hit_effect.conditions_target) { visit(condEffect.condition, visited, includeSource); } } @@ -130,12 +130,12 @@ public class GDEVisitor { visit(element.getProject().getSpritesheet(element.icon_id.split(":")[0]), visited, includeSource); if (element.hit_effect != null) { if (element.hit_effect.conditions_source != null) { - for (Common.TimedConditionEffect condEffect : element.hit_effect.conditions_source) { + for (Common.TimedActorConditionEffect condEffect : element.hit_effect.conditions_source) { visit(condEffect.condition, visited, includeSource); } } if (element.hit_effect.conditions_target != null) { - for (Common.TimedConditionEffect condEffect : element.hit_effect.conditions_target) { + for (Common.TimedActorConditionEffect condEffect : element.hit_effect.conditions_target) { visit(condEffect.condition, visited, includeSource); } }