From 42207b8b813ee661a4e770a201b5c198d321e75c Mon Sep 17 00:00:00 2001 From: NeumimTo Date: Thu, 15 Mar 2018 23:26:19 +0100 Subject: [PATCH] fixed projectile damage --- .../neumimto/rpg/players/ActiveCharacter.java | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/Plugin/src/main/java/cz/neumimto/rpg/players/ActiveCharacter.java b/Plugin/src/main/java/cz/neumimto/rpg/players/ActiveCharacter.java index ce5f74bc4..9cecef446 100644 --- a/Plugin/src/main/java/cz/neumimto/rpg/players/ActiveCharacter.java +++ b/Plugin/src/main/java/cz/neumimto/rpg/players/ActiveCharacter.java @@ -23,11 +23,7 @@ import cz.neumimto.rpg.effects.EffectSourceType; import cz.neumimto.rpg.effects.IEffect; import cz.neumimto.rpg.effects.IEffectContainer; -import cz.neumimto.rpg.inventory.Armor; -import cz.neumimto.rpg.inventory.ConfigRPGItemType; -import cz.neumimto.rpg.inventory.HotbarObject; -import cz.neumimto.rpg.inventory.RPGItemType; -import cz.neumimto.rpg.inventory.Weapon; +import cz.neumimto.rpg.inventory.*; import cz.neumimto.rpg.persistance.model.CharacterClass; import cz.neumimto.rpg.players.groups.ConfigClass; import cz.neumimto.rpg.players.groups.Guild; @@ -36,13 +32,7 @@ import cz.neumimto.rpg.players.parties.Party; import cz.neumimto.rpg.players.properties.DefaultProperties; import cz.neumimto.rpg.players.properties.PropertyService; -import cz.neumimto.rpg.skills.ExtendedSkillInfo; -import cz.neumimto.rpg.skills.ISkill; -import cz.neumimto.rpg.skills.ItemAccessSkill; -import cz.neumimto.rpg.skills.SkillData; -import cz.neumimto.rpg.skills.SkillTreeSpecialization; -import cz.neumimto.rpg.skills.StartingPoint; -import org.spongepowered.api.Sponge; +import cz.neumimto.rpg.skills.*; import org.spongepowered.api.entity.EntityType; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.event.cause.entity.damage.DamageType; @@ -53,13 +43,7 @@ import org.spongepowered.api.text.chat.ChatType; import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; @@ -456,13 +440,13 @@ public double getBaseProjectileDamage(EntityType id) { public IActiveCharacter updateItemRestrictions() { allowedWeapons.clear(); - Map> weapons = getRace().getWeapons(); allowedWeapons.putAll(weapons.entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> RPGItemWrapper.createFromSet(e.getValue())))); + //mergeWeapons(getGuild()); mergeWeapons(getPrimaryClass().getConfigClass()); //could be problematic, but its not called too often @@ -486,6 +470,26 @@ public IActiveCharacter updateItemRestrictions() { //allowedArmorIds.addAll(getGuild().getAllowedArmor()); allowedArmorIds.addAll(getPrimaryClass().getConfigClass().getAllowedArmor()); + + getProjectileDamages().clear(); + + getProjectileDamages().putAll(getRace().getProjectileDamage()); + + for (ExtendedNClass extendedNClass : getClasses()) { + ConfigClass configClass = extendedNClass.getConfigClass(); + Map projectileDamage = configClass.getProjectileDamage(); + for (Map.Entry entityType : projectileDamage.entrySet()) { + Double aDouble = getProjectileDamages().get(entityType.getKey()); + if (aDouble == null) { + getProjectileDamages().put(entityType.getKey(), entityType.getValue()); + } else if (PluginConfig.WEAPON_MERGE_STRATEGY == 1) { + getProjectileDamages().put(entityType.getKey(), aDouble + entityType.getValue()); + } else if (PluginConfig.WEAPON_MERGE_STRATEGY == 2) { + getProjectileDamages().put(entityType.getKey(), Math.max(aDouble, entityType.getValue())); + } + } + } + return this; }