mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-12 20:34:36 +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;
|
||||
|
||||
198
src/main/resources/defs/CharGemAttrGroups.json
Normal file
198
src/main/resources/defs/CharGemAttrGroups.json
Normal file
@@ -0,0 +1,198 @@
|
||||
[
|
||||
{
|
||||
"Id": 5,
|
||||
"Weight": 3000,
|
||||
"AttrTypes": [
|
||||
60,
|
||||
61,
|
||||
62,
|
||||
63,
|
||||
64,
|
||||
65
|
||||
]
|
||||
},
|
||||
{
|
||||
"Id": 7,
|
||||
"Weight": 3435,
|
||||
"AttrTypes": [
|
||||
66,
|
||||
68,
|
||||
69,
|
||||
70,
|
||||
71,
|
||||
72,
|
||||
73,
|
||||
80,
|
||||
81,
|
||||
82,
|
||||
83,
|
||||
84,
|
||||
85
|
||||
]
|
||||
},
|
||||
{
|
||||
"Id": 3,
|
||||
"Weight": 3435,
|
||||
"AttrTypes": [
|
||||
7,
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
21,
|
||||
22,
|
||||
23,
|
||||
24,
|
||||
25,
|
||||
26
|
||||
]
|
||||
},
|
||||
{
|
||||
"Id": 1,
|
||||
"Weight": 3000,
|
||||
"AttrTypes": [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6
|
||||
]
|
||||
},
|
||||
{
|
||||
"Id": 10,
|
||||
"Weight": 4883,
|
||||
"AttrTypes": [
|
||||
100,
|
||||
101,
|
||||
102,
|
||||
103,
|
||||
104,
|
||||
105,
|
||||
106,
|
||||
107,
|
||||
108,
|
||||
109,
|
||||
110,
|
||||
111,
|
||||
112
|
||||
]
|
||||
},
|
||||
{
|
||||
"Id": 11,
|
||||
"Weight": 0,
|
||||
"AttrTypes": [
|
||||
35,
|
||||
36,
|
||||
37,
|
||||
38
|
||||
],
|
||||
"UniqueAttrNumWeights": {
|
||||
"1": 7500,
|
||||
"2": 2000,
|
||||
"3": 450,
|
||||
"4": 50
|
||||
}
|
||||
},
|
||||
{
|
||||
"Id": 9,
|
||||
"Weight": 5117,
|
||||
"AttrTypes": [
|
||||
94,
|
||||
95,
|
||||
96,
|
||||
97,
|
||||
98,
|
||||
99
|
||||
]
|
||||
},
|
||||
{
|
||||
"Id": 8,
|
||||
"Weight": 800,
|
||||
"AttrTypes": [
|
||||
67,
|
||||
74,
|
||||
75,
|
||||
76,
|
||||
77,
|
||||
78,
|
||||
79,
|
||||
86,
|
||||
87
|
||||
]
|
||||
},
|
||||
{
|
||||
"Id": 12,
|
||||
"Weight": 0,
|
||||
"AttrTypes": [
|
||||
39,
|
||||
40,
|
||||
41,
|
||||
42,
|
||||
43,
|
||||
44,
|
||||
45,
|
||||
46,
|
||||
47,
|
||||
48,
|
||||
49,
|
||||
50,
|
||||
51,
|
||||
52,
|
||||
53,
|
||||
54,
|
||||
55,
|
||||
56,
|
||||
57,
|
||||
58,
|
||||
59
|
||||
],
|
||||
"UniqueAttrNumWeights": {
|
||||
"1": 6700,
|
||||
"2": 2650,
|
||||
"3": 500,
|
||||
"4": 150
|
||||
}
|
||||
},
|
||||
{
|
||||
"Id": 4,
|
||||
"Weight": 800,
|
||||
"AttrTypes": [
|
||||
8,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
20,
|
||||
27,
|
||||
28
|
||||
]
|
||||
},
|
||||
{
|
||||
"Id": 6,
|
||||
"Weight": 2765,
|
||||
"AttrTypes": [
|
||||
88,
|
||||
89,
|
||||
90,
|
||||
91,
|
||||
92,
|
||||
93
|
||||
]
|
||||
},
|
||||
{
|
||||
"Id": 2,
|
||||
"Weight": 2765,
|
||||
"AttrTypes": [
|
||||
29,
|
||||
30,
|
||||
31,
|
||||
32,
|
||||
33,
|
||||
34
|
||||
]
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user