mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-16 06:15:20 +01:00
Hardcode emblem attribute values
(They were removed from the data files)
This commit is contained in:
@@ -32,7 +32,6 @@ public class GameData {
|
||||
@Getter private static DataTable<CharGemDef> CharGemDataTable = new DataTable<>();
|
||||
@Getter private static DataTable<CharGemSlotControlDef> CharGemSlotControlDataTable = new DataTable<>();
|
||||
@Getter private static DataTable<CharGemAttrGroupDef> CharGemAttrGroupDataTable = new DataTable<>();
|
||||
@Getter private static DataTable<CharGemAttrTypeDef> CharGemAttrTypeDataTable = new DataTable<>();
|
||||
@Getter private static DataTable<CharGemAttrValueDef> CharGemAttrValueDataTable = new DataTable<>();
|
||||
|
||||
// Character affinity
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package emu.nebula.data;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -54,9 +55,26 @@ public class ResourceLoader {
|
||||
int count = 0;
|
||||
|
||||
try {
|
||||
var json = JsonUtils.loadToMap(Nebula.getConfig().resourceDir + "/bin/" + type.name(), String.class, resourceClass);
|
||||
// Init defs collection
|
||||
Iterable<?> defs = null;
|
||||
|
||||
// Load resource file
|
||||
if (type.useInternal()) {
|
||||
// Load from internal resources in jar
|
||||
try (var in = ResourceLoader.class.getResourceAsStream("/defs/" + type.name()); var reader = new InputStreamReader(in)) {
|
||||
defs = JsonUtils.loadToList(reader, resourceClass);
|
||||
} catch (Exception e) {
|
||||
// Ignored
|
||||
}
|
||||
} else {
|
||||
// Load json from ./resources/bin/ folder
|
||||
var json = JsonUtils.loadToMap(Nebula.getConfig().resourceDir + "/bin/" + type.name(), String.class, resourceClass);
|
||||
|
||||
// Get json values
|
||||
defs = json.values();
|
||||
}
|
||||
|
||||
for (Object o : json.values()) {
|
||||
for (Object o : defs) {
|
||||
BaseDef res = (BaseDef) o;
|
||||
|
||||
if (res == null) {
|
||||
|
||||
@@ -10,13 +10,15 @@ public @interface ResourceType {
|
||||
String name();
|
||||
|
||||
/**
|
||||
* Load priority - dictates which order to load this resource, with "highest"
|
||||
* being loaded first
|
||||
* Load priority - dictates which order to load this resource, with "highest" being loaded first
|
||||
*/
|
||||
LoadPriority loadPriority() default LoadPriority.NORMAL;
|
||||
|
||||
Class<?> keyType() default int.class;
|
||||
|
||||
/**
|
||||
* Loads the resource file from inside the jar (./resources/defs/) if set to true
|
||||
*/
|
||||
boolean useInternal() default false;
|
||||
|
||||
public enum LoadPriority {
|
||||
HIGHEST(4), HIGH(3), NORMAL(2), LOW(1), LOWEST(0);
|
||||
|
||||
|
||||
@@ -1,32 +1,36 @@
|
||||
package emu.nebula.data.resources;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import emu.nebula.data.BaseDef;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.data.ResourceType;
|
||||
import emu.nebula.data.ResourceType.LoadPriority;
|
||||
import emu.nebula.util.JsonUtils;
|
||||
import emu.nebula.util.WeightedList;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@ResourceType(name = "CharGemAttrGroup.json", loadPriority = LoadPriority.HIGH)
|
||||
@ResourceType(name = "CharGemAttrGroups.json", useInternal = true)
|
||||
public class CharGemAttrGroupDef extends BaseDef {
|
||||
private int GroupId;
|
||||
private int GroupType;
|
||||
private int Id;
|
||||
private int Weight;
|
||||
private String UniqueAttrNumWeight;
|
||||
private IntArrayList AttrTypes;
|
||||
private Map<Integer, Integer> UniqueAttrNumWeights;
|
||||
|
||||
private transient WeightedList<Integer> uniqueAttrNum;
|
||||
private transient List<CharGemAttrTypeDef> attributeTypes;
|
||||
private transient List<CharGemAttrTypeData> attributeTypes;
|
||||
|
||||
public CharGemAttrGroupDef() {
|
||||
this.AttrTypes = new IntArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return GroupId;
|
||||
return Id;
|
||||
}
|
||||
|
||||
public int getRandomUniqueAttrNum() {
|
||||
@@ -37,7 +41,7 @@ public class CharGemAttrGroupDef extends BaseDef {
|
||||
return this.uniqueAttrNum.next();
|
||||
}
|
||||
|
||||
public CharGemAttrTypeDef getRandomAttributeType(IntList list) {
|
||||
public CharGemAttrTypeData getRandomAttributeType(IntList list) {
|
||||
// Setup blacklist to prevent the same attribute from showing up twice
|
||||
var blacklist = new IntOpenHashSet();
|
||||
|
||||
@@ -50,7 +54,7 @@ public class CharGemAttrGroupDef extends BaseDef {
|
||||
}
|
||||
|
||||
// Create random generator
|
||||
var random = new WeightedList<CharGemAttrTypeDef>();
|
||||
var random = new WeightedList<CharGemAttrTypeData>();
|
||||
|
||||
for (var type : this.getAttributeTypes()) {
|
||||
if (blacklist.contains(type.getId())) {
|
||||
@@ -65,15 +69,44 @@ public class CharGemAttrGroupDef extends BaseDef {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
// Init unique attribute weights
|
||||
this.uniqueAttrNum = new WeightedList<>();
|
||||
this.attributeTypes = new ObjectArrayList<>();
|
||||
|
||||
if (this.UniqueAttrNumWeight != null) {
|
||||
var json = JsonUtils.decodeMap(this.UniqueAttrNumWeight, Integer.class, Integer.class);
|
||||
|
||||
for (var entry : json.entrySet()) {
|
||||
if (this.UniqueAttrNumWeights != null) {
|
||||
for (var entry : this.UniqueAttrNumWeights.entrySet()) {
|
||||
this.uniqueAttrNum.add(entry.getValue(), entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
// Init attribute types
|
||||
this.attributeTypes = new ObjectArrayList<>();
|
||||
|
||||
for (int id : this.getAttrTypes()) {
|
||||
var type = new CharGemAttrTypeData(id);
|
||||
this.attributeTypes.add(type);
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class CharGemAttrTypeData {
|
||||
private int id;
|
||||
private WeightedList<CharGemAttrValueDef> values;
|
||||
|
||||
public CharGemAttrTypeData(int id) {
|
||||
this.id = id;
|
||||
this.values = new WeightedList<>();
|
||||
}
|
||||
|
||||
protected void addValue(CharGemAttrValueDef value) {
|
||||
this.values.add(value.getRarity(), value);
|
||||
}
|
||||
|
||||
public CharGemAttrValueDef getRandomValueData() {
|
||||
return this.getValues().next();
|
||||
}
|
||||
|
||||
public int getRandomValue() {
|
||||
return this.getRandomValueData().getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package emu.nebula.data.resources;
|
||||
|
||||
import emu.nebula.data.BaseDef;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.data.ResourceType;
|
||||
import emu.nebula.util.WeightedList;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@ResourceType(name = "CharGemAttrType.json")
|
||||
public class CharGemAttrTypeDef extends BaseDef {
|
||||
private int Id;
|
||||
private int GroupId;
|
||||
|
||||
private transient WeightedList<CharGemAttrValueDef> values;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return Id;
|
||||
}
|
||||
|
||||
public CharGemAttrValueDef getRandomValueData() {
|
||||
return this.getValues().next();
|
||||
}
|
||||
|
||||
public int getRandomValue() {
|
||||
return this.getRandomValueData().getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
this.values = new WeightedList<>();
|
||||
|
||||
var data = GameData.getCharGemAttrGroupDataTable().get(this.GroupId);
|
||||
if (data != null) {
|
||||
data.getAttributeTypes().add(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,6 @@ public class CharGemAttrValueDef extends BaseDef {
|
||||
private int Id;
|
||||
private int TypeId;
|
||||
private int AttrType;
|
||||
private int AttrTypeFirstSubtype;
|
||||
private int AttrTypeSecondSubtype;
|
||||
private int Rarity;
|
||||
|
||||
@Override
|
||||
@@ -23,9 +21,18 @@ public class CharGemAttrValueDef extends BaseDef {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
var data = GameData.getCharGemAttrTypeDataTable().get(this.TypeId);
|
||||
if (data != null) {
|
||||
data.getValues().add(this.getRarity(), this);
|
||||
// Cache attribute values into attribute group defs
|
||||
// Honestly a horrible/inefficient way of doing this
|
||||
for (var data : GameData.getCharGemAttrGroupDataTable()) {
|
||||
for (var type : data.getAttributeTypes()) {
|
||||
// Skip if type id doesnt match
|
||||
if (type.getId() != this.getTypeId()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add
|
||||
type.addValue(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import emu.nebula.data.BaseDef;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.data.ResourceType;
|
||||
import emu.nebula.util.CustomIntArray;
|
||||
import emu.nebula.util.Utils;
|
||||
import emu.nebula.util.WeightedList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import lombok.Getter;
|
||||
@@ -19,16 +20,15 @@ public class CharGemSlotControlDef extends BaseDef {
|
||||
private int GeneratenCostQty;
|
||||
private int RefreshCostQty;
|
||||
|
||||
private int UniqueAttrGroupProb;
|
||||
private int UniqueAttrGroupId;
|
||||
private int GuaranteeCount;
|
||||
|
||||
private int[] AttrGroupId;
|
||||
|
||||
private int LockableNum;
|
||||
private int LockItemTid;
|
||||
private int LockItemQty;
|
||||
|
||||
// These have to be hardcoded now
|
||||
private transient int UniqueAttrGroupProb;
|
||||
private transient int UniqueAttrGroupId;
|
||||
private transient int[] AttrGroupId;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return Id;
|
||||
@@ -38,9 +38,15 @@ public class CharGemSlotControlDef extends BaseDef {
|
||||
return this.generateAttributes(new CustomIntArray());
|
||||
}
|
||||
|
||||
// Check if we should add unique attributes based on the probablity
|
||||
private boolean shouldAddUniqueAttr() {
|
||||
int random = Utils.randomRange(1, 10000);
|
||||
return random <= this.UniqueAttrGroupProb;
|
||||
}
|
||||
|
||||
public IntList generateAttributes(CustomIntArray list) {
|
||||
// Add unique attributes
|
||||
if (this.UniqueAttrGroupId > 0) {
|
||||
if (this.UniqueAttrGroupId > 0 && this.shouldAddUniqueAttr()) {
|
||||
var group = GameData.getCharGemAttrGroupDataTable().get(this.UniqueAttrGroupId);
|
||||
int num = group.getRandomUniqueAttrNum();
|
||||
|
||||
@@ -76,4 +82,25 @@ public class CharGemSlotControlDef extends BaseDef {
|
||||
// Complete
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
// Hard coded values
|
||||
switch (this.Id) {
|
||||
case 3:
|
||||
this.UniqueAttrGroupProb = 3300;
|
||||
this.UniqueAttrGroupId = 12;
|
||||
this.AttrGroupId = new int[] {9, 10};
|
||||
break;
|
||||
case 2:
|
||||
this.UniqueAttrGroupProb = 4000;
|
||||
this.UniqueAttrGroupId = 11;
|
||||
this.AttrGroupId = new int[] {5, 6, 7, 8};
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
this.AttrGroupId = new int[] {1, 2, 3, 4};
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import lombok.Getter;
|
||||
@Getter
|
||||
@ResourceType(name = "StarTowerFloorExp.json")
|
||||
public class StarTowerFloorExpDef extends BaseDef {
|
||||
private int Id;
|
||||
private int StarTowerId;
|
||||
private int Stage;
|
||||
private int NormalExp;
|
||||
|
||||
Reference in New Issue
Block a user