diff --git a/src/lib/orianna/api/JSONConverter.java b/src/lib/orianna/api/JSONConverter.java index d4018534d..cbfb6ba9b 100644 --- a/src/lib/orianna/api/JSONConverter.java +++ b/src/lib/orianna/api/JSONConverter.java @@ -9,6 +9,8 @@ import java.util.List; import java.util.Map; import java.util.function.Function; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import lib.orianna.type.champion.ChampionStatus; import lib.orianna.type.game.Game; @@ -72,6 +74,8 @@ * @author Rob Rua (FatalElement - NA) (robrua@alumni.cmu.edu) */ public class JSONConverter { + private static final Pattern ITEM_CDR_PATTERN = Pattern.compile("\\+(\\d+)% Cooldown Reduction *(
||$)"); + private static Integer convertInteger(final Object object) { final Long longVersion = (Long)object; if(longVersion == null) { @@ -590,6 +594,7 @@ public BasicDataStats getBasicDataStatsFromJSON(final JSONObject basicDataStatsI final Double percentArmorMod = (Double)basicDataStatsInfo.get("PercentArmorMod"); final Double percentAttackSpeedMod = (Double)basicDataStatsInfo.get("PercentAttackSpeedMod"); final Double percentBlockMod = (Double)basicDataStatsInfo.get("PercentBlockMod"); + final Double percentCooldownMod = (Double)basicDataStatsInfo.get("PercentCooldownMod"); final Double percentCritChanceMod = (Double)basicDataStatsInfo.get("PercentCritChanceMod"); final Double percentCritDamageMod = (Double)basicDataStatsInfo.get("PercentCritDamageMod"); final Double percentDodgeMod = (Double)basicDataStatsInfo.get("PercentDodgeMod"); @@ -639,16 +644,16 @@ public BasicDataStats getBasicDataStatsFromJSON(final JSONObject basicDataStatsI return new BasicDataStats(flatArmorMod, flatAttackSpeedMod, flatBlockMod, flatCritChanceMod, flatCritDamageMod, flatEXPBonus, flatEnergyPoolMod, flatEnergyRegenMod, flatHPPoolMod, flatHPRegenMod, flatMPPoolMod, flatMPRegenMod, flatMagicDamageMod, flatMovementSpeedMod, - flatPhysicalDamageMod, flatSpellBlockMod, percentArmorMod, percentAttackSpeedMod, percentBlockMod, percentCritChanceMod, percentCritDamageMod, - percentDodgeMod, percentEXPBonus, percentHPPoolMod, percentHPRegenMod, percentLifeStealMod, percentMPPoolMod, percentMPRegenMod, - percentMagicDamageMod, percentMovementSpeedMod, percentPhysicalDamageMod, percentSpellBlockMod, percentSpellVampMod, rFlatArmorModPerLevel, - rFlatArmorPenetrationMod, rFlatArmorPenetrationModPerLevel, rFlatCritChanceModPerLevel, rFlatCritDamageModPerLevel, rFlatDodgeMod, - rFlatDodgeModPerLevel, rFlatEnergyModPerLevel, rFlatEnergyRegenModPerLevel, rFlatGoldPer10Mod, rFlatHPModPerLevel, rFlatHPRegenModPerLevel, - rFlatMPModPerLevel, rFlatMPRegenModPerLevel, rFlatMagicDamageModPerLevel, rFlatMagicPenetrationMod, rFlatMagicPenetrationModPerLevel, - rFlatMovementSpeedModPerLevel, rFlatPhysicalDamageModPerLevel, rFlatSpellBlockModPerLevel, rFlatTimeDeadMod, rFlatTimeDeadModPerLevel, - rPercentArmorPenetrationMod, rPercentArmorPenetrationModPerLevel, rPercentAttackSpeedModPerLevel, rPercentCooldownMod, - rPercentCooldownModPerLevel, rPercentMagicPenetrationMod, rPercentMagicPenetrationModPerLevel, rPercentMovementSpeedModPerLevel, - rPercentTimeDeadMod, rPercentTimeDeadModPerLevel); + flatPhysicalDamageMod, flatSpellBlockMod, percentArmorMod, percentAttackSpeedMod, percentBlockMod, percentCooldownMod, percentCritChanceMod, + percentCritDamageMod, percentDodgeMod, percentEXPBonus, percentHPPoolMod, percentHPRegenMod, percentLifeStealMod, percentMPPoolMod, + percentMPRegenMod, percentMagicDamageMod, percentMovementSpeedMod, percentPhysicalDamageMod, percentSpellBlockMod, percentSpellVampMod, + rFlatArmorModPerLevel, rFlatArmorPenetrationMod, rFlatArmorPenetrationModPerLevel, rFlatCritChanceModPerLevel, rFlatCritDamageModPerLevel, + rFlatDodgeMod, rFlatDodgeModPerLevel, rFlatEnergyModPerLevel, rFlatEnergyRegenModPerLevel, rFlatGoldPer10Mod, rFlatHPModPerLevel, + rFlatHPRegenModPerLevel, rFlatMPModPerLevel, rFlatMPRegenModPerLevel, rFlatMagicDamageModPerLevel, rFlatMagicPenetrationMod, + rFlatMagicPenetrationModPerLevel, rFlatMovementSpeedModPerLevel, rFlatPhysicalDamageModPerLevel, rFlatSpellBlockModPerLevel, rFlatTimeDeadMod, + rFlatTimeDeadModPerLevel, rPercentArmorPenetrationMod, rPercentArmorPenetrationModPerLevel, rPercentAttackSpeedModPerLevel, + rPercentCooldownMod, rPercentCooldownModPerLevel, rPercentMagicPenetrationMod, rPercentMagicPenetrationModPerLevel, + rPercentMovementSpeedModPerLevel, rPercentTimeDeadMod, rPercentTimeDeadModPerLevel); } public Block getBlockFromJSON(final JSONObject blockInfo) { @@ -905,7 +910,6 @@ public Item getItemFromJSON(final JSONObject itemInfo) { final Gold gold = getGoldFromJSON((JSONObject)itemInfo.get("gold")); final Image image = getImageFromJSON((JSONObject)itemInfo.get("image")); final MetaData rune = getMetaDataFromJSON((JSONObject)itemInfo.get("rune")); - final BasicDataStats stats = getBasicDataStatsFromJSON((JSONObject)itemInfo.get("stats")); final List from = getStringList(itemInfo, "from"); final List into = getStringList(itemInfo, "into"); final List tags = getStringList(itemInfo, "tags"); @@ -914,6 +918,18 @@ public Item getItemFromJSON(final JSONObject itemInfo) { maps = Collections.unmodifiableMap(maps); } + final JSONObject statsObj = (JSONObject)itemInfo.get("stats"); + /* + * Riot doesn't send CDR for items as a stat yet, so we have to parse it + * out of the description and add it ourselves. + */ + // TODO: Remove this after rito fixes it. + final Matcher matcher = ITEM_CDR_PATTERN.matcher(description); + if(matcher.find()) { + statsObj.put("PercentCooldownMod", new Double(matcher.group(1))); + } + final BasicDataStats stats = getBasicDataStatsFromJSON((JSONObject)itemInfo.get("stats")); + return new Item(colloq, description, group, name, plaintext, requiredChampion, sanitizedDescription, consumeOnFull, consumed, hideFromAll, inStore, depth, ID, specialRecipe, stacks, from, into, tags, gold, image, maps, rune, stats); } diff --git a/src/lib/orianna/type/staticdata/BasicDataStats.java b/src/lib/orianna/type/staticdata/BasicDataStats.java index 270f301ba..f78fdcd2e 100644 --- a/src/lib/orianna/type/staticdata/BasicDataStats.java +++ b/src/lib/orianna/type/staticdata/BasicDataStats.java @@ -6,37 +6,39 @@ import java.util.Map; public class BasicDataStats implements Serializable { - private static final long serialVersionUID = 1594413878340877864L; + private static final long serialVersionUID = -2608389900646702437L; public final Double flatArmorMod, flatAttackSpeedMod, flatBlockMod, flatCritChanceMod, flatCritDamageMod, flatEXPBonus, flatEnergyPoolMod, flatEnergyRegenMod, flatHPPoolMod, flatHPRegenMod, flatMPPoolMod, flatMPRegenMod, flatMagicDamageMod, flatMovementSpeedMod, flatPhysicalDamageMod, - flatSpellBlockMod, percentArmorMod, percentAttackSpeedMod, percentBlockMod, percentCritChanceMod, percentCritDamageMod, percentDodgeMod, - percentEXPBonus, percentHPPoolMod, percentHPRegenMod, percentLifeStealMod, percentMPPoolMod, percentMPRegenMod, percentMagicDamageMod, - percentMovementSpeedMod, percentPhysicalDamageMod, percentSpellBlockMod, percentSpellVampMod, rFlatArmorModPerLevel, rFlatArmorPenetrationMod, - rFlatArmorPenetrationModPerLevel, rFlatCritChanceModPerLevel, rFlatCritDamageModPerLevel, rFlatDodgeMod, rFlatDodgeModPerLevel, - rFlatEnergyModPerLevel, rFlatEnergyRegenModPerLevel, rFlatGoldPer10Mod, rFlatHPModPerLevel, rFlatHPRegenModPerLevel, rFlatMPModPerLevel, - rFlatMPRegenModPerLevel, rFlatMagicDamageModPerLevel, rFlatMagicPenetrationMod, rFlatMagicPenetrationModPerLevel, rFlatMovementSpeedModPerLevel, - rFlatPhysicalDamageModPerLevel, rFlatSpellBlockModPerLevel, rFlatTimeDeadMod, rFlatTimeDeadModPerLevel, rPercentArmorPenetrationMod, - rPercentArmorPenetrationModPerLevel, rPercentAttackSpeedModPerLevel, rPercentCooldownMod, rPercentCooldownModPerLevel, rPercentMagicPenetrationMod, - rPercentMagicPenetrationModPerLevel, rPercentMovementSpeedModPerLevel, rPercentTimeDeadMod, rPercentTimeDeadModPerLevel; + flatSpellBlockMod, percentArmorMod, percentAttackSpeedMod, percentBlockMod, percentCooldownMod, percentCritChanceMod, percentCritDamageMod, + percentDodgeMod, percentEXPBonus, percentHPPoolMod, percentHPRegenMod, percentLifeStealMod, percentMPPoolMod, percentMPRegenMod, + percentMagicDamageMod, percentMovementSpeedMod, percentPhysicalDamageMod, percentSpellBlockMod, percentSpellVampMod, rFlatArmorModPerLevel, + rFlatArmorPenetrationMod, rFlatArmorPenetrationModPerLevel, rFlatCritChanceModPerLevel, rFlatCritDamageModPerLevel, rFlatDodgeMod, + rFlatDodgeModPerLevel, rFlatEnergyModPerLevel, rFlatEnergyRegenModPerLevel, rFlatGoldPer10Mod, rFlatHPModPerLevel, rFlatHPRegenModPerLevel, + rFlatMPModPerLevel, rFlatMPRegenModPerLevel, rFlatMagicDamageModPerLevel, rFlatMagicPenetrationMod, rFlatMagicPenetrationModPerLevel, + rFlatMovementSpeedModPerLevel, rFlatPhysicalDamageModPerLevel, rFlatSpellBlockModPerLevel, rFlatTimeDeadMod, rFlatTimeDeadModPerLevel, + rPercentArmorPenetrationMod, rPercentArmorPenetrationModPerLevel, rPercentAttackSpeedModPerLevel, rPercentCooldownMod, rPercentCooldownModPerLevel, + rPercentMagicPenetrationMod, rPercentMagicPenetrationModPerLevel, rPercentMovementSpeedModPerLevel, rPercentTimeDeadMod, + rPercentTimeDeadModPerLevel; public BasicDataStats(final Double flatArmorMod, final Double flatAttackSpeedMod, final Double flatBlockMod, final Double flatCritChanceMod, final Double flatCritDamageMod, final Double flatEXPBonus, final Double flatEnergyPoolMod, final Double flatEnergyRegenMod, final Double flatHPPoolMod, final Double flatHPRegenMod, final Double flatMPPoolMod, final Double flatMPRegenMod, final Double flatMagicDamageMod, final Double flatMovementSpeedMod, final Double flatPhysicalDamageMod, final Double flatSpellBlockMod, final Double percentArmorMod, - final Double percentAttackSpeedMod, final Double percentBlockMod, final Double percentCritChanceMod, final Double percentCritDamageMod, - final Double percentDodgeMod, final Double percentEXPBonus, final Double percentHPPoolMod, final Double percentHPRegenMod, - final Double percentLifeStealMod, final Double percentMPPoolMod, final Double percentMPRegenMod, final Double percentMagicDamageMod, - final Double percentMovementSpeedMod, final Double percentPhysicalDamageMod, final Double percentSpellBlockMod, final Double percentSpellVampMod, - final Double rFlatArmorModPerLevel, final Double rFlatArmorPenetrationMod, final Double rFlatArmorPenetrationModPerLevel, - final Double rFlatCritChanceModPerLevel, final Double rFlatCritDamageModPerLevel, final Double rFlatDodgeMod, final Double rFlatDodgeModPerLevel, - final Double rFlatEnergyModPerLevel, final Double rFlatEnergyRegenModPerLevel, final Double rFlatGoldPer10Mod, final Double rFlatHPModPerLevel, - final Double rFlatHPRegenModPerLevel, final Double rFlatMPModPerLevel, final Double rFlatMPRegenModPerLevel, - final Double rFlatMagicDamageModPerLevel, final Double rFlatMagicPenetrationMod, final Double rFlatMagicPenetrationModPerLevel, - final Double rFlatMovementSpeedModPerLevel, final Double rFlatPhysicalDamageModPerLevel, final Double rFlatSpellBlockModPerLevel, - final Double rFlatTimeDeadMod, final Double rFlatTimeDeadModPerLevel, final Double rPercentArmorPenetrationMod, - final Double rPercentArmorPenetrationModPerLevel, final Double rPercentAttackSpeedModPerLevel, final Double rPercentCooldownMod, - final Double rPercentCooldownModPerLevel, final Double rPercentMagicPenetrationMod, final Double rPercentMagicPenetrationModPerLevel, - final Double rPercentMovementSpeedModPerLevel, final Double rPercentTimeDeadMod, final Double rPercentTimeDeadModPerLevel) { + final Double percentAttackSpeedMod, final Double percentBlockMod, final Double percentCooldownMod, final Double percentCritChanceMod, + final Double percentCritDamageMod, final Double percentDodgeMod, final Double percentEXPBonus, final Double percentHPPoolMod, + final Double percentHPRegenMod, final Double percentLifeStealMod, final Double percentMPPoolMod, final Double percentMPRegenMod, + final Double percentMagicDamageMod, final Double percentMovementSpeedMod, final Double percentPhysicalDamageMod, final Double percentSpellBlockMod, + final Double percentSpellVampMod, final Double rFlatArmorModPerLevel, final Double rFlatArmorPenetrationMod, + final Double rFlatArmorPenetrationModPerLevel, final Double rFlatCritChanceModPerLevel, final Double rFlatCritDamageModPerLevel, + final Double rFlatDodgeMod, final Double rFlatDodgeModPerLevel, final Double rFlatEnergyModPerLevel, final Double rFlatEnergyRegenModPerLevel, + final Double rFlatGoldPer10Mod, final Double rFlatHPModPerLevel, final Double rFlatHPRegenModPerLevel, final Double rFlatMPModPerLevel, + final Double rFlatMPRegenModPerLevel, final Double rFlatMagicDamageModPerLevel, final Double rFlatMagicPenetrationMod, + final Double rFlatMagicPenetrationModPerLevel, final Double rFlatMovementSpeedModPerLevel, final Double rFlatPhysicalDamageModPerLevel, + final Double rFlatSpellBlockModPerLevel, final Double rFlatTimeDeadMod, final Double rFlatTimeDeadModPerLevel, + final Double rPercentArmorPenetrationMod, final Double rPercentArmorPenetrationModPerLevel, final Double rPercentAttackSpeedModPerLevel, + final Double rPercentCooldownMod, final Double rPercentCooldownModPerLevel, final Double rPercentMagicPenetrationMod, + final Double rPercentMagicPenetrationModPerLevel, final Double rPercentMovementSpeedModPerLevel, final Double rPercentTimeDeadMod, + final Double rPercentTimeDeadModPerLevel) { this.flatArmorMod = flatArmorMod; this.flatAttackSpeedMod = flatAttackSpeedMod; this.flatBlockMod = flatBlockMod; @@ -56,6 +58,7 @@ public BasicDataStats(final Double flatArmorMod, final Double flatAttackSpeedMod this.percentArmorMod = percentArmorMod; this.percentAttackSpeedMod = percentAttackSpeedMod; this.percentBlockMod = percentBlockMod; + this.percentCooldownMod = percentCooldownMod; this.percentCritChanceMod = percentCritChanceMod; this.percentCritDamageMod = percentCritDamageMod; this.percentDodgeMod = percentDodgeMod; @@ -268,6 +271,14 @@ else if(!percentAttackSpeedMod.equals(other.percentAttackSpeedMod)) { else if(!percentBlockMod.equals(other.percentBlockMod)) { return false; } + if(percentCooldownMod == null) { + if(other.percentCooldownMod != null) { + return false; + } + } + else if(!percentCooldownMod.equals(other.percentCooldownMod)) { + return false; + } if(percentCritChanceMod == null) { if(other.percentCritChanceMod != null) { return false; @@ -662,6 +673,7 @@ public int hashCode() { result = prime * result + (percentArmorMod == null ? 0 : percentArmorMod.hashCode()); result = prime * result + (percentAttackSpeedMod == null ? 0 : percentAttackSpeedMod.hashCode()); result = prime * result + (percentBlockMod == null ? 0 : percentBlockMod.hashCode()); + result = prime * result + (percentCooldownMod == null ? 0 : percentCooldownMod.hashCode()); result = prime * result + (percentCritChanceMod == null ? 0 : percentCritChanceMod.hashCode()); result = prime * result + (percentCritDamageMod == null ? 0 : percentCritDamageMod.hashCode()); result = prime * result + (percentDodgeMod == null ? 0 : percentDodgeMod.hashCode()); @@ -775,6 +787,9 @@ public Map nonNullStats() { if(percentBlockMod != null) { nonNull.put("percentBlockMod", percentBlockMod); } + if(percentCooldownMod != null) { + nonNull.put("percentCooldownMod", percentCooldownMod); + } if(percentCritChanceMod != null) { nonNull.put("percentCritChanceMod", percentCritChanceMod); }