baseObject = object.getParserObject(BASE_HERO);
object.remove(BASE_HERO);
}
else throw new ParserException("The ParserObject is not a valid units object!");
Unit baseUnit = baseUnit(baseObject);
Units u = new Units();
List<Unit> units = u.getUnit();
for (Iterator i = object.keys(); i.hasNext();) {
String name = (String)i.next();
if (!name.startsWith("npc_dota_")) continue;
ParserObject unitObject = object.getParserObject(name);
Unit unit = new Unit(baseUnit);
unit.setName(name);
// Level
if (unitObject.has("Level"))
unit.setLevel(unitObject.getInt("Level"));
// Is ancient
if (unitObject.has("IsAncient"))
unit.setAncient(unitObject.getBoolean("IsAncient"));
// Is neutral
if (unitObject.has("IsNeutralUnitType"))
unit.setNeutral(unitObject.getBoolean("IsNeutralUnitType"));
// Abilities
for (Iterator j = unitObject.keys(); j.hasNext();) {
String key = (String)j.next();
if (key.startsWith("Ability") && !key.endsWith("Preview") && !unitObject.getString(key).isEmpty()) {
unit.getAbilities().getAbility().add(unitObject.getString(key));
}
}
// Armor
// Physical
if (unitObject.has("ArmorPhysical"))
unit.getArmor().setPhysical(unitObject.getDouble("ArmorPhysical"));
// Magical
if (unitObject.has("ArmorMagical"))
unit.getArmor().setMagical(unitObject.getDouble("ArmorMagical"));
// Attack
// AttackCapabilities
if (unitObject.has("AttackCapabilities"))
unit.getAttack().setAttackCapabilities(unitObject.getString("AttackCapabilities"));
// Damage
// Damage Type
if (unitObject.has("AttackDamageType"))
unit.getAttack().getDamage().setDamageType(unitObject.getString("AttackDamageType"));
// Min Damage
if (unitObject.has("AttackDamageMin"))
unit.getAttack().getDamage().setMin(unitObject.getInt("AttackDamageMin"));
// Max Damage
if (unitObject.has("AttackDamageMax"))
unit.getAttack().getDamage().setMax(unitObject.getInt("AttackDamageMax"));
// - End Damage
// Attack Rate
if (unitObject.has("AttackRate"))
unit.getAttack().setRate(unitObject.getDouble("AttackRate"));
// Attack Range
if (unitObject.has("AttackRange"))
unit.getAttack().setRange(unitObject.getInt("AttackRange"));
// Projectile Speed
if (unitObject.has("ProjectileSpeed"))
unit.getAttack().setProjectileSpeed(unitObject.getInt("ProjectileSpeed"));
// Attributes
// Primary
if (unitObject.has("AttributePrimary"))
unit.getAttributes().setPrimary(unitObject.getString("AttributePrimary"));
// Strength
if (unitObject.has("AttributeBaseStrength"))
unit.getAttributes().getStrength().setBase(unitObject.getInt("AttributeBaseStrength"));
if (unitObject.has("AttributeStrengthGain"))
unit.getAttributes().getStrength().setGain(unitObject.getDouble("AttributeStrengthGain"));
// Intelligence
if (unitObject.has("AttributeBaseIntelligence"))
unit.getAttributes().getIntelligence().setBase(unitObject.getInt("AttributeBaseIntelligence"));
if (unitObject.has("AttributeIntelligenceGain"))
unit.getAttributes().getIntelligence().setGain(unitObject.getDouble("AttributeIntelligenceGain"));
// Agility
if (unitObject.has("AttributeBaseAgility"))
unit.getAttributes().getAgility().setBase(unitObject.getInt("AttributeBaseAgility"));
if (unitObject.has("AttributeAgilityGain"))
unit.getAttributes().getAgility().setGain(unitObject.getDouble("AttributeAgilityGain"));
// Bounty
// XP
if (unitObject.has("BountyXP"))
unit.getBounty().setXp(unitObject.getInt("BountyXP"));
// Gold
if (unitObject.has("BountyGoldMin"))
unit.getBounty().getGold().setMin(unitObject.getInt("BountyGoldMin"));
if (unitObject.has("BountyGoldMax"))
unit.getBounty().getGold().setMax(unitObject.getInt("BountyGoldMax"));
// Movement
// Capabilities
if (unitObject.has("MovementCapabilities"))
unit.getMovement().setMovementCapabilities(unitObject.getString("MovementCapabilities"));
// Speed
if (unitObject.has("MovementSpeed"))
unit.getMovement().setSpeed(unitObject.getInt("MovementSpeed"));
// Turn rate
if (unitObject.has("MovementTurnRate"))
unit.getMovement().setTurnRate(unitObject.getDouble("MovementTurnRate"));
// Stats
// Health
if (unitObject.has("StatusHealth"))
unit.getStats().getHealth().setBase(unitObject.getInt("StatusHealth"));
// Health Regen
if (unitObject.has("StatusHealthRegen"))
unit.getStats().getHealth().setRegeneration(unitObject.getDouble("StatusHealthRegen"));
// Mana
if (unitObject.has("StatusMana"))
unit.getStats().getMana().setBase(unitObject.getInt("StatusMana"));
// Mana Regen
if (unitObject.has("StatusMana"))
unit.getStats().getMana().setRegeneration(unitObject.getDouble("StatusManaRegen"));
// Vision
// Day
if (unitObject.has("VisionDaytimeRange"))
unit.getVision().setDay(unitObject.getInt("VisionDaytimeRange"));
if (unitObject.has("VisionNighttimeRange"))
unit.getVision().setNight(unitObject.getInt("VisionNighttimeRange"));
units.add(unit);
}
return u;
}