Created monstats schema and custom table impl and tests

This commit is contained in:
Collin Smith 2020-12-30 23:48:43 -08:00
parent 2afc050f6f
commit cb31a45ed4
3 changed files with 123 additions and 0 deletions

View File

@ -0,0 +1,22 @@
package com.riiablo.table.schema;
import com.riiablo.table.annotation.PrimaryKey;
import com.riiablo.table.annotation.Schema;
import com.riiablo.table.annotation.Table;
import com.riiablo.table.table.MonPresetTable;
@Schema(
preload = true
)
@Table(MonPresetTable.class)
public class MonPreset {
@Override
public String toString() {
return Place;
}
@PrimaryKey
public int Act;
public String Place;
}

View File

@ -0,0 +1,89 @@
// automatically generated by TableCodeGenerator, do not modify
package com.riiablo.table.table;
import javax.annotation.Generated;
import com.badlogic.gdx.utils.IntArray;
import com.riiablo.Riiablo;
import com.riiablo.table.Parser;
import com.riiablo.table.ParserInput;
import com.riiablo.table.Serializer;
import com.riiablo.table.Table;
import com.riiablo.table.parser.MonPresetParser;
import com.riiablo.table.schema.MonPreset;
import com.riiablo.table.serializer.MonPresetSerializer;
@Generated(
value = "com.riiablo.table.annotation.TableCodeGenerator",
date = "2020-12-30T23:38:56-08:00",
comments = "com.riiablo.table.schema.MonPreset"
)
public final class MonPresetTable extends Table<MonPreset> {
public MonPresetTable() {
super(MonPreset.class, 53, 0.8f);
}
@Override
protected MonPreset newRecord() {
return new MonPreset();
}
@Override
protected Parser<MonPreset> newParser(ParserInput arg0) {
return new MonPresetParser(arg0);
}
@Override
protected Serializer<MonPreset> newSerializer() {
return new MonPresetSerializer();
}
@Override
protected int offset() {
return 0;
}
@Override
protected boolean indexed() {
return false;
}
@Override
protected boolean preload() {
return true;
}
@Override
protected String primaryKey() {
return "Act";
}
private static final int NUM_ACTS = Riiablo.NUM_ACTS;
private static final int INITIAL_ENTRIES = 60;
/** stores act-specific list of mon place codes */
private static final IntArray[] lookup = new IntArray[NUM_ACTS + 1]; {
for (int act = 1; act <= NUM_ACTS; act++) {
lookup[act] = new IntArray(INITIAL_ENTRIES);
}
}
@Override
protected void put(int id, MonPreset record) {
super.put(id, record);
lookup[record.Act].add(id);
}
public MonPreset get(int act, int id) {
return get(lookup[act].get(id));
}
public String getPlace(int act, int id) {
return get(act, id).Place;
}
public int getSize(int act) {
return lookup[act].size;
}
}

View File

@ -19,6 +19,7 @@ import com.riiablo.table.schema.Sounds;
import com.riiablo.table.schema.Weapons;
import com.riiablo.table.table.BodyLocsTable;
import com.riiablo.table.table.ItemStatCostTable;
import com.riiablo.table.table.MonPresetTable;
import com.riiablo.table.table.MonStatsTable;
import com.riiablo.table.table.RunesTable;
import com.riiablo.table.table.SoundsTable;
@ -205,4 +206,15 @@ public class TablesTest extends RiiabloTest {
Assert.assertSame(record, table.get(record.ID));
}
}
@Test
public void monpreset() {
LogManager.setLevel("com.riiablo.table.table.MonPresetTable", Level.TRACE);
TableManifest.monpreset.parser = null;
FileHandle handle = Gdx.files.internal("test/monpreset.txt");
MonPresetTable table = Tables.loadTsv(TableManifest.monpreset, handle);
for (int i = 0, s = table.parser.parser().numRecords(); i < s; i++) {
System.out.println(table.get(i));
}
}
}