mirror of
https://github.com/OMGeeky/andors-trail.git
synced 2026-01-20 02:21:11 +01:00
Refactored how item stats are applied to actors, in preparation of fighting style skills.
This commit is contained in:
@@ -137,10 +137,14 @@ public final class HeroinfoActivity_Inventory extends Activity {
|
||||
|
||||
private static int suggestInventorySlot(ItemType itemType, Player player) {
|
||||
int slot = itemType.category.inventorySlot;
|
||||
if (player.inventory.isEmptySlot(slot)) return slot;
|
||||
|
||||
if (slot == Inventory.WEARSLOT_RING) {
|
||||
if (!player.inventory.isEmptySlot(slot)) return slot + 1;
|
||||
} else if (itemType.isOffhandCapableWeapon()) {
|
||||
if (player.inventory.isEmptySlot(Inventory.WEARSLOT_SHIELD)) return Inventory.WEARSLOT_SHIELD;
|
||||
return slot + 1;
|
||||
} else if (itemType.isOffhandCapableWeapon()) {
|
||||
ItemType mainWeapon = player.inventory.wear[Inventory.WEARSLOT_WEAPON];
|
||||
if (mainWeapon != null && mainWeapon.isTwohandWeapon()) return slot;
|
||||
else if (player.inventory.isEmptySlot(Inventory.WEARSLOT_SHIELD)) return Inventory.WEARSLOT_SHIELD;
|
||||
}
|
||||
return slot;
|
||||
}
|
||||
|
||||
@@ -146,33 +146,29 @@ public class ActorStatsController {
|
||||
|
||||
private static void applyEffectsFromCurrentConditions(Actor actor) {
|
||||
for (ActorCondition c : actor.conditions) {
|
||||
applyAbilityEffects(actor, c.conditionType.abilityEffect, false, c.magnitude);
|
||||
applyAbilityEffects(actor, c.conditionType.abilityEffect, c.magnitude);
|
||||
}
|
||||
actor.health.capAtMax();
|
||||
actor.ap.capAtMax();
|
||||
}
|
||||
|
||||
public static void applyAbilityEffects(Actor actor, AbilityModifierTraits effects, boolean isWeapon, int magnitude) {
|
||||
public static void applyAbilityEffects(Actor actor, AbilityModifierTraits effects, int multiplier) {
|
||||
if (effects == null) return;
|
||||
|
||||
CombatTraits actorCombatTraits = actor.combatTraits;
|
||||
|
||||
actor.health.addToMax(effects.maxHPBoost * magnitude);
|
||||
actor.ap.addToMax(effects.maxAPBoost * magnitude);
|
||||
actor.actorTraits.moveCost += (effects.moveCostPenalty * magnitude);
|
||||
actor.health.addToMax(effects.maxHPBoost * multiplier);
|
||||
actor.ap.addToMax(effects.maxAPBoost * multiplier);
|
||||
actor.actorTraits.moveCost += effects.moveCostPenalty * multiplier;
|
||||
|
||||
CombatTraits combatTraits = effects.combatProficiency;
|
||||
if (combatTraits != null) {
|
||||
if (!isWeapon) { // For weapons, these stats are modified elsewhere (since they are not cumulative)
|
||||
actorCombatTraits.attackCost += (combatTraits.attackCost * magnitude);
|
||||
actorCombatTraits.criticalMultiplier += (combatTraits.criticalMultiplier * magnitude);
|
||||
}
|
||||
actorCombatTraits.attackChance += (combatTraits.attackChance * magnitude);
|
||||
actorCombatTraits.criticalSkill += (combatTraits.criticalSkill * magnitude);
|
||||
actorCombatTraits.damagePotential.add(combatTraits.damagePotential.current * magnitude, true);
|
||||
actorCombatTraits.damagePotential.max += (combatTraits.damagePotential.max * magnitude);
|
||||
actorCombatTraits.blockChance += (combatTraits.blockChance * magnitude);
|
||||
actorCombatTraits.damageResistance += (combatTraits.damageResistance * magnitude);
|
||||
actorCombatTraits.attackCost += combatTraits.attackCost * multiplier;
|
||||
//criticalMultiplier should not be increased. It is always defined by the weapon in use.
|
||||
actorCombatTraits.attackChance += combatTraits.attackChance * multiplier;
|
||||
actorCombatTraits.criticalSkill += combatTraits.criticalSkill * multiplier;
|
||||
actorCombatTraits.damagePotential.add(combatTraits.damagePotential.current * multiplier, true);
|
||||
actorCombatTraits.damagePotential.addToMax(combatTraits.damagePotential.max * multiplier);
|
||||
actorCombatTraits.blockChance += combatTraits.blockChance * multiplier;
|
||||
actorCombatTraits.damageResistance += combatTraits.damageResistance * multiplier;
|
||||
}
|
||||
|
||||
if (actorCombatTraits.attackCost <= 0) actorCombatTraits.attackCost = 1;
|
||||
@@ -189,6 +185,8 @@ public class ActorStatsController {
|
||||
if (actor.isPlayer) SkillController.applySkillEffects((Player) actor);
|
||||
applyEffectsFromCurrentConditions(actor);
|
||||
if (actor.isPlayer) ItemController.recalculateHitEffectsFromWornItems((Player) actor);
|
||||
actor.health.capAtMax();
|
||||
actor.ap.capAtMax();
|
||||
}
|
||||
|
||||
public void applyConditionsToPlayer(Player player, boolean isFullRound) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import android.view.View;
|
||||
import com.gpl.rpg.AndorsTrail.Dialogs;
|
||||
import com.gpl.rpg.AndorsTrail.context.ViewContext;
|
||||
import com.gpl.rpg.AndorsTrail.context.WorldContext;
|
||||
import com.gpl.rpg.AndorsTrail.model.CombatTraits;
|
||||
import com.gpl.rpg.AndorsTrail.model.ModelContainer;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.ActorConditionEffect;
|
||||
import com.gpl.rpg.AndorsTrail.model.ability.SkillCollection;
|
||||
@@ -101,24 +100,41 @@ public final class ItemController {
|
||||
}
|
||||
|
||||
public static void applyInventoryEffects(Player player) {
|
||||
ItemType weapon = player.inventory.wear[Inventory.WEARSLOT_WEAPON];
|
||||
ItemType weapon = getMainWeapon(player);
|
||||
if (weapon != null) {
|
||||
if (weapon.effects_equip != null) {
|
||||
CombatTraits weaponTraits = weapon.effects_equip.combatProficiency;
|
||||
if (weaponTraits != null) {
|
||||
player.combatTraits.attackCost = weaponTraits.attackCost;
|
||||
player.combatTraits.criticalMultiplier = weaponTraits.criticalMultiplier;
|
||||
}
|
||||
}
|
||||
player.combatTraits.attackCost = 0;
|
||||
player.combatTraits.criticalMultiplier = weapon.effects_equip.combatProficiency.criticalMultiplier;
|
||||
}
|
||||
|
||||
for (int i = 0; i < Inventory.NUM_WORN_SLOTS; ++i) {
|
||||
ItemType type = player.inventory.wear[i];
|
||||
if (type == null) continue;
|
||||
|
||||
final boolean isWeapon = type.isWeapon();
|
||||
ActorStatsController.applyAbilityEffects(player, type.effects_equip, isWeapon, 1);
|
||||
applyInventoryEffects(player, Inventory.WEARSLOT_WEAPON);
|
||||
applyInventoryEffects(player, Inventory.WEARSLOT_SHIELD);
|
||||
applyInventoryEffects(player, Inventory.WEARSLOT_HEAD);
|
||||
applyInventoryEffects(player, Inventory.WEARSLOT_BODY);
|
||||
applyInventoryEffects(player, Inventory.WEARSLOT_HAND);
|
||||
applyInventoryEffects(player, Inventory.WEARSLOT_FEET);
|
||||
applyInventoryEffects(player, Inventory.WEARSLOT_NECK);
|
||||
applyInventoryEffects(player, Inventory.WEARSLOT_RING);
|
||||
|
||||
SkillController.applySkillEffectsFromItemProficiencies(player);
|
||||
SkillController.applySkillEffectsFromFightingStyles(player);
|
||||
}
|
||||
public static ItemType getMainWeapon(Player player) {
|
||||
ItemType itemType = player.inventory.wear[Inventory.WEARSLOT_WEAPON];
|
||||
if (itemType != null) return itemType;
|
||||
itemType = player.inventory.wear[Inventory.WEARSLOT_SHIELD];
|
||||
if (itemType != null && itemType.isWeapon()) return itemType;
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void applyInventoryEffects(Player player, int slot) {
|
||||
ItemType type = player.inventory.wear[slot];
|
||||
if (type == null) return;
|
||||
if (slot == Inventory.WEARSLOT_SHIELD) {
|
||||
ItemType mainHandItem = player.inventory.wear[Inventory.WEARSLOT_WEAPON];
|
||||
// The stats for off-hand weapons will be added later in SkillController.applySkillEffectsFromFightingStyles
|
||||
if (SkillController.isDualWielding(mainHandItem, type)) return;
|
||||
}
|
||||
ActorStatsController.applyAbilityEffects(player, type.effects_equip, 1);
|
||||
}
|
||||
|
||||
public static void recalculateHitEffectsFromWornItems(Player player) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.gpl.rpg.AndorsTrail.model.ability.SkillInfo;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Actor;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Monster;
|
||||
import com.gpl.rpg.AndorsTrail.model.actor.Player;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemType;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.ItemTypeCollection;
|
||||
import com.gpl.rpg.AndorsTrail.model.item.DropList.DropItem;
|
||||
import com.gpl.rpg.AndorsTrail.util.ConstRange;
|
||||
@@ -152,4 +153,14 @@ public final class SkillController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void applySkillEffectsFromItemProficiencies(Player player) {
|
||||
}
|
||||
|
||||
public static void applySkillEffectsFromFightingStyles(Player player) {
|
||||
}
|
||||
|
||||
public static boolean isDualWielding(ItemType mainHandItem, ItemType offHandItem) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,4 +21,8 @@ public class ActorConditionTypeCollection {
|
||||
public void initialize(final ActorConditionsTypeParser parser, String input) {
|
||||
parser.parseRows(input, conditionTypes);
|
||||
}
|
||||
|
||||
public HashMap<String, ActorConditionType> UNITTEST_getAllActorConditionsTypes() {
|
||||
return conditionTypes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,14 @@ public final class Inventory extends ItemContainer {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isArmorSlot(int slot) {
|
||||
if (slot == WEARSLOT_HEAD) return true;
|
||||
else if (slot == WEARSLOT_BODY) return true;
|
||||
else if (slot == WEARSLOT_HAND) return true;
|
||||
else if (slot == WEARSLOT_FEET) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
||||
// ====== PARCELABLE ===================================================================
|
||||
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.gpl.rpg.AndorsTrail.model.item;
|
||||
|
||||
public final class ItemCategory {
|
||||
private static final int SIZE_NONE = 0;
|
||||
private static final int SIZE_LIGHT = 1;
|
||||
private static final int SIZE_STD = 2;
|
||||
private static final int SIZE_LARGE = 3;
|
||||
public static final int SIZE_NONE = 0;
|
||||
public static final int SIZE_LIGHT = 1;
|
||||
public static final int SIZE_STD = 2;
|
||||
public static final int SIZE_LARGE = 3;
|
||||
|
||||
public final String id;
|
||||
public final String displayName;
|
||||
public final int inventorySlot;
|
||||
private final int actionType;
|
||||
private final int size;
|
||||
public final int size;
|
||||
|
||||
public ItemCategory(String id, String displayName, int actionType, int inventorySlot, int size) {
|
||||
this.id = id;
|
||||
@@ -26,15 +26,17 @@ public final class ItemCategory {
|
||||
public boolean isEquippable() { return actionType == ACTIONTYPE_EQUIP; }
|
||||
public boolean isUsable() { return actionType == ACTIONTYPE_USE; }
|
||||
public boolean isWeapon() { return inventorySlot == Inventory.WEARSLOT_WEAPON; }
|
||||
public boolean isShield() { return inventorySlot == Inventory.WEARSLOT_SHIELD; }
|
||||
public boolean isArmor() { return Inventory.isArmorSlot(inventorySlot); }
|
||||
public boolean isTwohandWeapon() {
|
||||
if (!isWeapon()) return false;
|
||||
/*if (!isWeapon()) return false;
|
||||
else if (size == SIZE_LARGE) return true;
|
||||
else return false;
|
||||
else*/ return false;
|
||||
}
|
||||
public boolean isOffhandCapableWeapon() {
|
||||
if (!isWeapon()) return false;
|
||||
/*if (!isWeapon()) return false;
|
||||
else if (size == SIZE_LIGHT) return true;
|
||||
else if (size == SIZE_STD) return true;
|
||||
else return false;
|
||||
else*/ return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ public final class ItemType {
|
||||
public boolean isQuestItem() { return displayType == DISPLAYTYPE_QUEST; }
|
||||
public boolean isOrdinaryItem() { return displayType == DISPLAYTYPE_ORDINARY; }
|
||||
public boolean isWeapon() { return category.isWeapon(); }
|
||||
public boolean isArmor() { return category.isArmor(); }
|
||||
public boolean isShield() { return category.isShield(); }
|
||||
public boolean isTwohandWeapon() { return category.isTwohandWeapon(); }
|
||||
public boolean isOffhandCapableWeapon() { return category.isOffhandCapableWeapon(); }
|
||||
public boolean isSellable() {
|
||||
|
||||
Reference in New Issue
Block a user