|
|
@ -31,6 +31,7 @@ import engine.objects.PlayerCharacter; |
|
|
|
import engine.powers.effectmodifiers.*; |
|
|
|
import engine.powers.effectmodifiers.*; |
|
|
|
import engine.server.MBServerStatics; |
|
|
|
import engine.server.MBServerStatics; |
|
|
|
import engine.util.Hasher; |
|
|
|
import engine.util.Hasher; |
|
|
|
|
|
|
|
import engine.wpak.data.ConditionEntry; |
|
|
|
import engine.wpak.data.EffectEntry; |
|
|
|
import engine.wpak.data.EffectEntry; |
|
|
|
import engine.wpak.data.EffectModifier; |
|
|
|
import engine.wpak.data.EffectModifier; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
@ -39,6 +40,7 @@ import java.sql.Connection; |
|
|
|
import java.sql.PreparedStatement; |
|
|
|
import java.sql.PreparedStatement; |
|
|
|
import java.sql.ResultSet; |
|
|
|
import java.sql.ResultSet; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.sql.SQLException; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
@ -48,34 +50,34 @@ public class EffectsBase { |
|
|
|
public static HashMap<String, HashSet<AbstractEffectModifier>> modifiersMap = new HashMap<>(); |
|
|
|
public static HashMap<String, HashSet<AbstractEffectModifier>> modifiersMap = new HashMap<>(); |
|
|
|
public static HashMap<Integer, HashSet<mbEnums.DamageType>> EffectDamageTypes = new HashMap<>(); |
|
|
|
public static HashMap<Integer, HashSet<mbEnums.DamageType>> EffectDamageTypes = new HashMap<>(); |
|
|
|
private static ConcurrentHashMap<String, String> itemEffectsByName = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); |
|
|
|
private static ConcurrentHashMap<String, String> itemEffectsByName = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); |
|
|
|
private static int NewID = 3000; |
|
|
|
public static int NewID = 3000; |
|
|
|
private int UUID; |
|
|
|
public int UUID; |
|
|
|
private String IDString; |
|
|
|
public String IDString; |
|
|
|
// private String name;
|
|
|
|
// public String name;
|
|
|
|
private int token; |
|
|
|
public int token; |
|
|
|
private float amount; |
|
|
|
public float amount; |
|
|
|
private float amountRamp; |
|
|
|
public float amountRamp; |
|
|
|
// flags
|
|
|
|
// flags
|
|
|
|
private boolean isItemEffect; |
|
|
|
public boolean isItemEffect; |
|
|
|
private boolean isSpireEffect; |
|
|
|
public boolean isSpireEffect; |
|
|
|
private boolean ignoreNoMod; |
|
|
|
public boolean ignoreNoMod; |
|
|
|
private boolean dontSave; |
|
|
|
public boolean dontSave; |
|
|
|
private boolean cancelOnAttack = false; |
|
|
|
public boolean cancelOnAttack = false; |
|
|
|
private boolean cancelOnAttackSwing = false; |
|
|
|
public boolean cancelOnAttackSwing = false; |
|
|
|
private boolean cancelOnCast = false; |
|
|
|
public boolean cancelOnCast = false; |
|
|
|
private boolean cancelOnCastSpell = false; |
|
|
|
public boolean cancelOnCastSpell = false; |
|
|
|
private boolean cancelOnEquipChange = false; |
|
|
|
public boolean cancelOnEquipChange = false; |
|
|
|
private boolean cancelOnLogout = false; |
|
|
|
public boolean cancelOnLogout = false; |
|
|
|
private boolean cancelOnMove = false; |
|
|
|
public boolean cancelOnMove = false; |
|
|
|
private boolean cancelOnNewCharm = false; |
|
|
|
public boolean cancelOnNewCharm = false; |
|
|
|
private boolean cancelOnSit = false; |
|
|
|
public boolean cancelOnSit = false; |
|
|
|
private boolean cancelOnTakeDamage = false; |
|
|
|
public boolean cancelOnTakeDamage = false; |
|
|
|
private boolean cancelOnTerritoryClaim = false; |
|
|
|
public boolean cancelOnTerritoryClaim = false; |
|
|
|
private boolean cancelOnUnEquip = false; |
|
|
|
public boolean cancelOnUnEquip = false; |
|
|
|
private boolean useRampAdd; |
|
|
|
public boolean useRampAdd; |
|
|
|
private boolean isPrefix = false; //used by items
|
|
|
|
public boolean isPrefix = false; //used by items
|
|
|
|
private boolean isSuffix = false; //used by items
|
|
|
|
public boolean isSuffix = false; //used by items
|
|
|
|
private String name = ""; |
|
|
|
public String name = ""; |
|
|
|
public float value = 0; |
|
|
|
public float value = 0; |
|
|
|
private ConcurrentHashMap<mbEnums.ResourceType, Integer> resourceCosts = new ConcurrentHashMap<>(); |
|
|
|
private ConcurrentHashMap<mbEnums.ResourceType, Integer> resourceCosts = new ConcurrentHashMap<>(); |
|
|
|
private ConcurrentHashMap<String, Boolean> sourceTypes = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); |
|
|
|
private ConcurrentHashMap<String, Boolean> sourceTypes = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); |
|
|
@ -127,12 +129,108 @@ public class EffectsBase { |
|
|
|
this.effectSources.add(EffectSourceType.GetEffectSourceType(source)); |
|
|
|
this.effectSources.add(EffectSourceType.GetEffectSourceType(source)); |
|
|
|
|
|
|
|
|
|
|
|
//load fail conditions
|
|
|
|
//load fail conditions
|
|
|
|
for(String condition : entry.conditions.keySet()) |
|
|
|
for(ConditionEntry condition : entry.conditions){ |
|
|
|
this.effectFailCondition.add(PowerFailCondition.valueOf(condition)); |
|
|
|
PowerFailCondition failCondition = PowerFailCondition.valueOf(condition.condition); |
|
|
|
|
|
|
|
this.effectFailCondition.add(failCondition); |
|
|
|
|
|
|
|
loadFailConditions(failCondition,this,condition); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//TODO load damage types and slopes from conditions
|
|
|
|
//TODO load damage types and slopes from conditions
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void loadFailConditions(PowerFailCondition failCondition, EffectsBase eb, ConditionEntry entry){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (failCondition == null || eb == null) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (failCondition) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case TakeDamage: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// dont go any further.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (eb == null) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eb.cancelOnTakeDamage = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
eb.amount = entry.arg; |
|
|
|
|
|
|
|
eb.amountRamp = (float)entry.curveType.getValue(); |
|
|
|
|
|
|
|
eb.useRampAdd = (float)entry.curveType.getValue() != 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList<String> damageTypes = new ArrayList<>(); |
|
|
|
|
|
|
|
String damageType1 = ""; |
|
|
|
|
|
|
|
String damageType2 = ""; |
|
|
|
|
|
|
|
String damageType3 = ""; |
|
|
|
|
|
|
|
for(mbEnums.DamageType dt : entry.damageTypes){ |
|
|
|
|
|
|
|
damageTypes.add(dt.name()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (damageType1.isEmpty() && damageType2.isEmpty() && damageType3.isEmpty()) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(damageTypes.get(0) != null) |
|
|
|
|
|
|
|
damageType1 = damageTypes.get(0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(damageTypes.get(1) != null) |
|
|
|
|
|
|
|
damageType1 = damageTypes.get(1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(damageTypes.get(2) != null) |
|
|
|
|
|
|
|
damageType1 = damageTypes.get(2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!EffectsBase.EffectDamageTypes.containsKey(eb.getToken())) |
|
|
|
|
|
|
|
EffectsBase.EffectDamageTypes.put(eb.getToken(), new HashSet<>()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mbEnums.DamageType dt = mbEnums.DamageType.getDamageType(damageType1); |
|
|
|
|
|
|
|
if (dt != null) |
|
|
|
|
|
|
|
EffectsBase.EffectDamageTypes.get(eb.token).add(dt); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dt = mbEnums.DamageType.getDamageType(damageType2); |
|
|
|
|
|
|
|
if (dt != null) |
|
|
|
|
|
|
|
EffectsBase.EffectDamageTypes.get(eb.token).add(dt); |
|
|
|
|
|
|
|
dt = mbEnums.DamageType.getDamageType(damageType3); |
|
|
|
|
|
|
|
if (dt != null) |
|
|
|
|
|
|
|
EffectsBase.EffectDamageTypes.get(eb.token).add(dt); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case Attack: |
|
|
|
|
|
|
|
eb.cancelOnAttack = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case AttackSwing: |
|
|
|
|
|
|
|
eb.cancelOnAttackSwing = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case Cast: |
|
|
|
|
|
|
|
eb.cancelOnCast = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case CastSpell: |
|
|
|
|
|
|
|
eb.cancelOnCastSpell = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case EquipChange: |
|
|
|
|
|
|
|
eb.cancelOnEquipChange = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case Logout: |
|
|
|
|
|
|
|
eb.cancelOnLogout = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case Move: |
|
|
|
|
|
|
|
eb.cancelOnMove = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case NewCharm: |
|
|
|
|
|
|
|
eb.cancelOnNewCharm = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case Sit: |
|
|
|
|
|
|
|
eb.cancelOnSit = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case TerritoryClaim: |
|
|
|
|
|
|
|
eb.cancelOnTerritoryClaim = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case UnEquip: |
|
|
|
|
|
|
|
eb.cancelOnUnEquip = true; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public EffectsBase(EffectsBase copyEffect, int newToken, String IDString) { |
|
|
|
public EffectsBase(EffectsBase copyEffect, int newToken, String IDString) { |
|
|
|
|
|
|
|
|
|
|
|
UUID = NewID++; |
|
|
|
UUID = NewID++; |
|
|
@ -215,7 +313,7 @@ public class EffectsBase { |
|
|
|
// getFailConditions();
|
|
|
|
// getFailConditions();
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void getFailConditions(HashMap<String, EffectsBase> effects) { |
|
|
|
public static void loadFailConditions(HashMap<String, EffectsBase> effects) { |
|
|
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_failcondition WHERE powerOrEffect = 'Effect';")) { |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM static_power_failcondition WHERE powerOrEffect = 'Effect';")) { |
|
|
|