Improved stat and skill update support

This commit is contained in:
Collin Smith 2019-04-12 02:14:47 -07:00
parent 652b748553
commit 2a6ab418ed
2 changed files with 28 additions and 3 deletions

View File

@ -174,15 +174,33 @@ public class CharData {
cursor = null;
stats.reset();
for (Item item : d2s.items.items) {
addItem(item);
addItem(item); // A lot of this code is redundant
//item.load();
}
stats.update(this);
updateStats();
}
private void updateStats() {
stats.reset();
final int alternate = getAlternate();
for (Item item : equipped.values()) {
item.update();
if (item.bodyLoc == BodyLoc.getAlternate(item.bodyLoc, alternate)) {
stats.add(item.props.remaining());
Stat stat;
if ((stat = item.props.get(Stat.armorclass)) != null) {
stats.aggregate().addCopy(stat);
}
}
}
for (Item item : store.get(StoreLoc.INVENTORY)) {
if (item.type.is(Type.CHAR)) {
stats.add(item.props.remaining());
}
}
stats.update(this);
// This appears to be hard-coded in the original client
int dex = stats.get(Stat.dexterity).value();
stats.aggregate().get(Stat.armorclass).add(dex / 4);
@ -300,6 +318,7 @@ public class CharData {
Item oldItem = equipped.put(bodyLoc, item);
if (item != null) item.update();
updateSets(oldItem, item);
updateStats();
notifyEquippedChanged(bodyLoc, oldItem, item);
return oldItem;
}
@ -317,6 +336,7 @@ public class CharData {
d2s.header.alternate = alternate;
Item LH = getEquipped(alternate > 0 ? BodyLoc.LARM2 : BodyLoc.LARM);
Item RH = getEquipped(alternate > 0 ? BodyLoc.RARM2 : BodyLoc.RARM);
updateStats();
notifyEquippedAlternated(alternate, LH, RH);
}
}

View File

@ -4,6 +4,7 @@ import com.badlogic.gdx.Application;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.assets.AssetDescriptor;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
@ -126,7 +127,11 @@ public class SpellsQuickPanel extends Table implements Disposable, CharData.Skil
@Override
public void onChanged(CharData client, IntIntMap skills) {
for (IntIntMap.Entry skillId : Riiablo.charData.getSkills()) {
for (Table table : tables) {
for (Actor child : table.getChildren()) child.clear();
table.clear();
}
for (IntIntMap.Entry skillId : skills) {
if (skillId.value <= 0) continue; // level <= 0
final Skills.Entry skill = Riiablo.files.skills.get(skillId.key);