mirror of
https://github.com/OMGeeky/ATCS.git
synced 2025-12-26 23:57:25 +01:00
extract actorConditionElementChanged + some parse stuff
This commit is contained in:
@@ -10,6 +10,18 @@ import java.util.Map;
|
||||
|
||||
public final class Common {
|
||||
|
||||
public static <T extends ActorConditionEffect> void actorConditionElementChanged(List<T> list, GameDataElement oldOne, GameDataElement newOne,GameDataElement backlink){
|
||||
if (list != null) {
|
||||
for (T c : list) {
|
||||
if (c.condition == oldOne) {
|
||||
oldOne.removeBacklink(backlink);
|
||||
c.condition = (ActorCondition) newOne;
|
||||
if (newOne != null) newOne.addBacklink(backlink);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//region link common stuff
|
||||
public static void linkConditions(List<? extends ActorConditionEffect> conditions, Project proj, GameDataElement backlink) {
|
||||
if (conditions != null) {
|
||||
|
||||
@@ -308,42 +308,18 @@ public class Item extends JSONElement {
|
||||
this.category = (ItemCategory) newOne;
|
||||
if (newOne != null) newOne.addBacklink(this);
|
||||
} else {
|
||||
if (this.equip_effect != null && this.equip_effect.conditions != null) {
|
||||
for (ActorConditionEffect c : this.equip_effect.conditions) {
|
||||
if (c.condition == oldOne) {
|
||||
oldOne.removeBacklink(this);
|
||||
c.condition = (ActorCondition) newOne;
|
||||
if (newOne != null) newOne.addBacklink(this);
|
||||
}
|
||||
if (this.equip_effect != null) {
|
||||
if (this.equip_effect.conditions != null) {
|
||||
actorConditionElementChanged(this.equip_effect.conditions, oldOne, newOne, this);
|
||||
}
|
||||
}
|
||||
if (this.hit_effect != null && this.hit_effect.conditions_source != null) {
|
||||
for (TimedActorConditionEffect c : this.hit_effect.conditions_source) {
|
||||
if (c.condition == oldOne) {
|
||||
oldOne.removeBacklink(this);
|
||||
c.condition = (ActorCondition) newOne;
|
||||
if (newOne != null) newOne.addBacklink(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.hit_effect != null && this.hit_effect.conditions_target != null) {
|
||||
for (TimedActorConditionEffect c : this.hit_effect.conditions_target) {
|
||||
if (c.condition == oldOne) {
|
||||
oldOne.removeBacklink(this);
|
||||
c.condition = (ActorCondition) newOne;
|
||||
if (newOne != null) newOne.addBacklink(this);
|
||||
}
|
||||
}
|
||||
if (this.hit_effect != null) {
|
||||
actorConditionElementChanged(this.hit_effect.conditions_source, oldOne, newOne, this);
|
||||
actorConditionElementChanged(this.hit_effect.conditions_target, oldOne, newOne, this);
|
||||
}
|
||||
|
||||
if (this.kill_effect != null && this.kill_effect.conditions_source != null) {
|
||||
for (TimedActorConditionEffect c : this.kill_effect.conditions_source) {
|
||||
if (c.condition == oldOne) {
|
||||
oldOne.removeBacklink(this);
|
||||
c.condition = (ActorCondition) newOne;
|
||||
if (newOne != null) newOne.addBacklink(this);
|
||||
}
|
||||
}
|
||||
if (this.kill_effect != null) {
|
||||
actorConditionElementChanged(this.kill_effect.conditions_source, oldOne, newOne, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,19 +171,7 @@ public class NPC extends JSONElement {
|
||||
|
||||
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);
|
||||
this.hit_effect = parseHitEffect(hitEffect);
|
||||
}
|
||||
|
||||
Map hitReceivedEffect = (Map) npcJson.get("hitReceivedEffect");
|
||||
@@ -193,19 +181,8 @@ public class NPC extends JSONElement {
|
||||
|
||||
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);
|
||||
this.death_effect = parseDeathEffect(deathEffect);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -302,23 +279,9 @@ public class NPC extends JSONElement {
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (this.hit_effect != null) {
|
||||
actorConditionElementChanged(this.hit_effect.conditions_source, oldOne, newOne, this);
|
||||
actorConditionElementChanged(this.hit_effect.conditions_target, oldOne, newOne, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user