mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-21 20:18:14 +07:00
This commit is contained in:
parent
7f6befd4d0
commit
207fe4fe97
@ -19,11 +19,9 @@ import com.riiablo.codec.excel.Armor;
|
|||||||
import com.riiablo.codec.excel.Gems;
|
import com.riiablo.codec.excel.Gems;
|
||||||
import com.riiablo.codec.excel.Inventory;
|
import com.riiablo.codec.excel.Inventory;
|
||||||
import com.riiablo.codec.excel.ItemEntry;
|
import com.riiablo.codec.excel.ItemEntry;
|
||||||
import com.riiablo.codec.excel.ItemStatCost;
|
|
||||||
import com.riiablo.codec.excel.ItemTypes;
|
import com.riiablo.codec.excel.ItemTypes;
|
||||||
import com.riiablo.codec.excel.MagicAffix;
|
import com.riiablo.codec.excel.MagicAffix;
|
||||||
import com.riiablo.codec.excel.Misc;
|
import com.riiablo.codec.excel.Misc;
|
||||||
import com.riiablo.codec.excel.Properties;
|
|
||||||
import com.riiablo.codec.excel.SetItems;
|
import com.riiablo.codec.excel.SetItems;
|
||||||
import com.riiablo.codec.excel.UniqueItems;
|
import com.riiablo.codec.excel.UniqueItems;
|
||||||
import com.riiablo.codec.excel.Weapons;
|
import com.riiablo.codec.excel.Weapons;
|
||||||
@ -79,6 +77,12 @@ public class Item extends Actor implements Disposable {
|
|||||||
private static final int SET_6_PROPS_FLAG = 1 << SET_PROPS + 4;
|
private static final int SET_6_PROPS_FLAG = 1 << SET_PROPS + 4;
|
||||||
private static final int RUNE_PROPS_FLAG = 1 << RUNE_PROPS;
|
private static final int RUNE_PROPS_FLAG = 1 << RUNE_PROPS;
|
||||||
|
|
||||||
|
private static final int WEAPON_PROPS = 0;
|
||||||
|
private static final int ARMOR_PROPS = 1;
|
||||||
|
private static final int HELM_PROPS = 2;
|
||||||
|
private static final int SHIELD_PROPS = 3;
|
||||||
|
private static final int NUM_GEM_PROPS = 4;
|
||||||
|
|
||||||
private static final PropertyList[] EMPTY_STAT_ARRAY = new PropertyList[NUM_PROPS];
|
private static final PropertyList[] EMPTY_STAT_ARRAY = new PropertyList[NUM_PROPS];
|
||||||
|
|
||||||
private static final ObjectMap<String, String> WEAPON_DESC = new ObjectMap<>();
|
private static final ObjectMap<String, String> WEAPON_DESC = new ObjectMap<>();
|
||||||
@ -213,7 +217,16 @@ public class Item extends Actor implements Disposable {
|
|||||||
qualityData = null;
|
qualityData = null;
|
||||||
runewordData = 0;
|
runewordData = 0;
|
||||||
inscription = null;
|
inscription = null;
|
||||||
stats = EMPTY_STAT_ARRAY;
|
if (type.is("gem") || type.is("rune")) {
|
||||||
|
Gems.Entry gem = Riiablo.files.Gems.get(base.code);
|
||||||
|
stats = new PropertyList[NUM_GEM_PROPS];
|
||||||
|
stats[WEAPON_PROPS] = new PropertyList().add(gem.weaponModCode, gem.weaponModParam, gem.weaponModMin, gem.weaponModMax);
|
||||||
|
stats[ARMOR_PROPS ] = new PropertyList().add(gem.helmModCode, gem.helmModParam, gem.helmModMin, gem.helmModMax);
|
||||||
|
stats[HELM_PROPS ] = stats[ARMOR_PROPS];
|
||||||
|
stats[SHIELD_PROPS] = new PropertyList().add(gem.shieldModCode, gem.shieldModParam, gem.shieldModMin, gem.shieldModMax);
|
||||||
|
} else {
|
||||||
|
stats = EMPTY_STAT_ARRAY;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
id = bitStream.read32BitsOrLess(Integer.SIZE);
|
id = bitStream.read32BitsOrLess(Integer.SIZE);
|
||||||
level = bitStream.readUnsigned7OrLess(7);
|
level = bitStream.readUnsigned7OrLess(7);
|
||||||
@ -846,29 +859,12 @@ public class Item extends Actor implements Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Item.this.type.is("gem") || Item.this.type.is("rune")) {
|
if (Item.this.type.is("gem") || Item.this.type.is("rune")) {
|
||||||
|
assert stats.length == NUM_GEM_PROPS;
|
||||||
add().height(font.getLineHeight()).space(SPACING).row();
|
add().height(font.getLineHeight()).space(SPACING).row();
|
||||||
|
add(new Label(Riiablo.string.lookup("GemXp3") + " " + stats[WEAPON_PROPS].copy().reduce().get().format(), font, Riiablo.colors.white)).center().space(SPACING).row();
|
||||||
Gems.Entry gem = Riiablo.files.Gems.get(base.code);
|
add(new Label(Riiablo.string.lookup("GemXp4") + " " + stats[ARMOR_PROPS ].copy().reduce().get().format(), font, Riiablo.colors.white)).center().space(SPACING).row();
|
||||||
//System.out.println(gem);
|
add(new Label(Riiablo.string.lookup("GemXp1") + " " + stats[HELM_PROPS ].copy().reduce().get().format(), font, Riiablo.colors.white)).center().space(SPACING).row();
|
||||||
PropertyList tmp = new PropertyList();
|
add(new Label(Riiablo.string.lookup("GemXp2") + " " + stats[SHIELD_PROPS].copy().reduce().get().format(), font, Riiablo.colors.white)).center().space(SPACING).row();
|
||||||
|
|
||||||
// weapon
|
|
||||||
formatProperty(tmp, gem.weaponModCode, gem.weaponModParam, gem.weaponModMin, gem.weaponModMax);
|
|
||||||
tmp.reduce();
|
|
||||||
add(new Label(Riiablo.string.lookup("GemXp3") + " " + tmp.get().format(), font, Riiablo.colors.white)).center().space(SPACING).row();
|
|
||||||
|
|
||||||
tmp.clear();
|
|
||||||
formatProperty(tmp, gem.helmModCode, gem.helmModParam, gem.helmModMin, gem.helmModMax);
|
|
||||||
tmp.reduce();
|
|
||||||
String text = tmp.get().format();
|
|
||||||
add(new Label(Riiablo.string.lookup("GemXp4") + " " + text, font, Riiablo.colors.white)).center().space(SPACING).row();
|
|
||||||
add(new Label(Riiablo.string.lookup("GemXp1") + " " + text, font, Riiablo.colors.white)).center().space(SPACING).row();
|
|
||||||
|
|
||||||
tmp.clear();
|
|
||||||
formatProperty(tmp, gem.shieldModCode, gem.shieldModParam, gem.shieldModMin, gem.shieldModMax);
|
|
||||||
tmp.reduce();
|
|
||||||
add(new Label(Riiablo.string.lookup("GemXp2") + " " + tmp.get().format(), font, Riiablo.colors.white)).center().space(SPACING).row();
|
|
||||||
|
|
||||||
add().height(font.getLineHeight()).space(SPACING).row();
|
add().height(font.getLineHeight()).space(SPACING).row();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -928,28 +924,30 @@ public class Item extends Actor implements Disposable {
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
// magic props
|
// magic props
|
||||||
PropertyList magicProps = stats[MAGIC_PROPS];
|
if ((flags & COMPACT) == 0) {
|
||||||
PropertyList runeProps = stats[RUNE_PROPS];
|
PropertyList magicProps = stats[MAGIC_PROPS];
|
||||||
if (magicProps != null) {
|
PropertyList runeProps = stats[RUNE_PROPS];
|
||||||
PropertyList magicPropsAggregate = magicProps.copy();
|
if (magicProps != null) {
|
||||||
if (runeProps != null) magicPropsAggregate.addAll(runeProps);
|
PropertyList magicPropsAggregate = magicProps.copy();
|
||||||
magicPropsAggregate.reduce();
|
if (runeProps != null) magicPropsAggregate.addAll(runeProps);
|
||||||
System.out.println(Item.this.getName());
|
magicPropsAggregate.reduce();
|
||||||
for (Stat.Instance stat : magicPropsAggregate.props.values()) {
|
System.out.println(Item.this.getName());
|
||||||
System.out.println(stat);
|
for (Stat.Instance stat : magicPropsAggregate.props.values()) {
|
||||||
}
|
System.out.println(stat);
|
||||||
|
}
|
||||||
Array<Stat.Instance> aggregate = magicPropsAggregate.toArray();
|
|
||||||
aggregate.sort(new Comparator<Stat.Instance>() {
|
Array<Stat.Instance> aggregate = magicPropsAggregate.toArray();
|
||||||
@Override
|
aggregate.sort(new Comparator<Stat.Instance>() {
|
||||||
public int compare(Stat.Instance o1, Stat.Instance o2) {
|
@Override
|
||||||
return o2.entry.descpriority - o1.entry.descpriority;
|
public int compare(Stat.Instance o1, Stat.Instance o2) {
|
||||||
|
return o2.entry.descpriority - o1.entry.descpriority;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for (Stat.Instance stat : aggregate) {
|
||||||
|
String text = stat.format();
|
||||||
|
if (text == null) continue;
|
||||||
|
add(new Label(text, font, Riiablo.colors.blue)).center().space(SPACING).row();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
for (Stat.Instance stat : aggregate) {
|
|
||||||
String text = stat.format();
|
|
||||||
if (text == null) continue;
|
|
||||||
add(new Label(text, font, Riiablo.colors.blue)).center().space(SPACING).row();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -988,22 +986,5 @@ public class Item extends Actor implements Disposable {
|
|||||||
|
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void formatProperty(PropertyList props, String[] modCode, int[] modParam, int[] modMin, int[] modMax) {
|
|
||||||
for (int i = 0; i < modCode.length; i++) {
|
|
||||||
String code = modCode[i];
|
|
||||||
if (code.isEmpty()) break;
|
|
||||||
Properties.Entry prop = Riiablo.files.Properties.get(code);
|
|
||||||
for (int j = 0; j < prop.stat.length; j++) {
|
|
||||||
int[] mod = j == 0 ? modMin : modMax;
|
|
||||||
String stat = prop.stat[j];
|
|
||||||
if (stat.isEmpty()) break;
|
|
||||||
ItemStatCost.Entry desc = Riiablo.files.ItemStatCost.get(stat);
|
|
||||||
Stat.Instance inst = Stat.create(desc.ID, modParam[i], mod[i]);
|
|
||||||
props.add(inst);
|
|
||||||
//System.out.println(inst);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,9 @@ package com.riiablo.item;
|
|||||||
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.badlogic.gdx.utils.IntMap;
|
import com.badlogic.gdx.utils.IntMap;
|
||||||
|
import com.riiablo.Riiablo;
|
||||||
|
import com.riiablo.codec.excel.ItemStatCost;
|
||||||
|
import com.riiablo.codec.excel.Properties;
|
||||||
import com.riiablo.codec.util.BitStream;
|
import com.riiablo.codec.util.BitStream;
|
||||||
|
|
||||||
public class PropertyList {
|
public class PropertyList {
|
||||||
@ -35,10 +38,6 @@ public class PropertyList {
|
|||||||
props.put(stat, Stat.create(stat, value));
|
props.put(stat, Stat.create(stat, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(Stat.Instance stat) {
|
|
||||||
props.put(stat.hash, stat);
|
|
||||||
}
|
|
||||||
|
|
||||||
Stat.Instance get() {
|
Stat.Instance get() {
|
||||||
assert props.size == 1;
|
assert props.size == 1;
|
||||||
return props.entries().next().value;
|
return props.entries().next().value;
|
||||||
@ -163,4 +162,23 @@ public class PropertyList {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PropertyList add(String[] code, int[] param, int[] min, int[] max) {
|
||||||
|
for (int i = 0; i < code.length; i++) {
|
||||||
|
String c = code[i];
|
||||||
|
if (c.isEmpty()) break;
|
||||||
|
Properties.Entry prop = Riiablo.files.Properties.get(c);
|
||||||
|
for (int j = 0; j < prop.stat.length; j++) {
|
||||||
|
int[] value = j == 0 ? min : max;
|
||||||
|
String stat = prop.stat[j];
|
||||||
|
if (stat.isEmpty()) break;
|
||||||
|
ItemStatCost.Entry desc = Riiablo.files.ItemStatCost.get(stat);
|
||||||
|
Stat.Instance inst = Stat.create(desc.ID, param[i], value[i]);
|
||||||
|
props.put(inst.hash, inst);
|
||||||
|
//System.out.println(inst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user