From 9a6e17496ecc235882a17f49a8f60ddc72355a6b Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Sun, 21 Apr 2019 03:52:36 -0700 Subject: [PATCH] Refactored attributes modified list with stat-internal modified field --- core/src/com/riiablo/item/Attributes.java | 21 +++++++++---------- core/src/com/riiablo/item/Item.java | 8 +++---- core/src/com/riiablo/item/Stat.java | 6 ++++++ .../src/com/riiablo/panel/CharacterPanel.java | 2 +- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/core/src/com/riiablo/item/Attributes.java b/core/src/com/riiablo/item/Attributes.java index 56974509..ab42586b 100644 --- a/core/src/com/riiablo/item/Attributes.java +++ b/core/src/com/riiablo/item/Attributes.java @@ -1,7 +1,6 @@ package com.riiablo.item; import com.badlogic.gdx.utils.Array; -import com.badlogic.gdx.utils.Bits; import com.riiablo.CharData; import com.riiablo.Riiablo; import com.riiablo.codec.excel.ItemStatCost; @@ -11,7 +10,7 @@ public class Attributes { final PropertyList agg = new PropertyList(); final PropertyList rem = new PropertyList(); final Array propertyLists = new Array<>(); - final Bits mod = new Bits(1 << Stat.BITS); + //final Bits mod = new Bits(1 << Stat.BITS); public PropertyList base() { return base; @@ -25,9 +24,9 @@ public class Attributes { return rem; } - public boolean isModified(int stat) { - return mod.get(stat); - } + //public boolean isModified(int stat) { + /// return mod.get(stat); + //} public int size() { return agg.size(); @@ -40,7 +39,7 @@ public class Attributes { public void reset() { agg.clear(); agg.deepCopy(base); - mod.clear(); + //mod.clear(); rem.clear(); propertyLists.clear(); } @@ -66,7 +65,7 @@ public class Attributes { rem.addCopy(stat); } else { agg.addCopy(stat); - mod.set(stat.id); + //mod.set(stat.id); } } } @@ -84,8 +83,8 @@ public class Attributes { int statId = Riiablo.files.ItemStatCost.index(op_stat); Stat opstat = agg.get(statId); if (opstat != null) { - opstat.val += op(charData, stat, base.get(statId), op, op_base, op_param); - mod.set(opstat.id); + opstat.add(op(charData, stat, base.get(statId), op, op_base, op_param)); + //mod.set(opstat.id); opCount++; } } @@ -103,12 +102,12 @@ public class Attributes { case 7: return 0; // by-time percent case 8: agg.addCopy(stat); - mod.set(stat.id); + //mod.set(stat.id); return stat.val * charData.getCharacterClass().entry().ManaPerMagic; // max mana case 9: if (opstat.id == Stat.maxhp) { // only increment vit on maxhp op agg.addCopy(stat); - mod.set(stat.id); + //mod.set(stat.id); } return stat.val // max hitpoints * (opstat.id == Stat.maxhp diff --git a/core/src/com/riiablo/item/Item.java b/core/src/com/riiablo/item/Item.java index 112879c1..0dc1b262 100644 --- a/core/src/com/riiablo/item/Item.java +++ b/core/src/com/riiablo/item/Item.java @@ -965,7 +965,7 @@ public class Item extends Actor implements Disposable { if ((prop = props.agg.get(Stat.armorclass)) != null) { Table table = new Table(); table.add(new Label(Riiablo.string.lookup("ItemStats1h") + " ", font)); - table.add(new Label(Integer.toString(prop.val), font, props.mod.get(Stat.armorclass) ? Riiablo.colors.blue : Riiablo.colors.white)); + table.add(new Label(Integer.toString(prop.val), font, props.get(Stat.armorclass).isModified() ? Riiablo.colors.blue : Riiablo.colors.white)); table.pack(); add(table).space(SPACING).row(); } @@ -982,21 +982,21 @@ public class Item extends Actor implements Disposable { if ((i & 1) != 0 && (prop = props.agg.get(Stat.maxdamage)) != null) { Table table = new Table(); table.add(new Label(Riiablo.string.lookup("ItemStats1l") + " ", font)); - table.add(new Label(props.get(Stat.mindamage).val + " to " + prop.val, font, props.mod.get(Stat.maxdamage) ? Riiablo.colors.blue : Riiablo.colors.white)); + table.add(new Label(props.get(Stat.mindamage).val + " to " + prop.val, font, props.get(Stat.maxdamage).isModified() ? Riiablo.colors.blue : Riiablo.colors.white)); table.pack(); add(table).space(SPACING).row(); } if ((i & 2) != 0 && (prop = props.agg.get(Stat.secondary_maxdamage)) != null) { Table table = new Table(); table.add(new Label(Riiablo.string.lookup("ItemStats1m") + " ", font)); - table.add(new Label(props.get(Stat.secondary_mindamage).val + " to " + prop.val, font, props.mod.get(Stat.secondary_maxdamage) ? Riiablo.colors.blue : Riiablo.colors.white)); + table.add(new Label(props.get(Stat.secondary_mindamage).val + " to " + prop.val, font, props.get(Stat.secondary_maxdamage).isModified() ? Riiablo.colors.blue : Riiablo.colors.white)); table.pack(); add(table).space(SPACING).row(); } if (typeEntry.Throwable && (prop = props.agg.get(Stat.item_throw_maxdamage)) != null) { Table table = new Table(); table.add(new Label(Riiablo.string.lookup("ItemStats1n") + " ", font)); - table.add(new Label(props.get(Stat.item_throw_mindamage).val + " to " + prop.val, font, props.mod.get(Stat.item_throw_maxdamage) ? Riiablo.colors.blue : Riiablo.colors.white)); + table.add(new Label(props.get(Stat.item_throw_mindamage).val + " to " + prop.val, font, props.get(Stat.item_throw_maxdamage).isModified() ? Riiablo.colors.blue : Riiablo.colors.white)); table.pack(); add(table).space(SPACING).row(); } diff --git a/core/src/com/riiablo/item/Stat.java b/core/src/com/riiablo/item/Stat.java index de9caad7..0e55c296 100644 --- a/core/src/com/riiablo/item/Stat.java +++ b/core/src/com/riiablo/item/Stat.java @@ -531,6 +531,10 @@ public class Stat implements Comparable, Pool.Poolable { return hash; } + public boolean isModified() { + return modified; + } + /** * Encodings: param -- value (in bits) * 0 : 0 | X @@ -561,6 +565,7 @@ public class Stat implements Comparable, Pool.Poolable { default: val += other.val; } + modified = true; return this; } @@ -576,6 +581,7 @@ public class Stat implements Comparable, Pool.Poolable { default: val += value; } + modified = true; return this; } diff --git a/core/src/com/riiablo/panel/CharacterPanel.java b/core/src/com/riiablo/panel/CharacterPanel.java index f9333250..28600429 100644 --- a/core/src/com/riiablo/panel/CharacterPanel.java +++ b/core/src/com/riiablo/panel/CharacterPanel.java @@ -282,7 +282,7 @@ public class CharacterPanel extends WidgetGroup implements Disposable { } } - if (mod && Riiablo.charData.getStats().isModified(stat.id)) { + if (mod && Riiablo.charData.getStats().get(stat.id).isModified()) { return Riiablo.colors.blue; }