Implemented Runes schema with custom RunesTable indexer and tests

This commit is contained in:
Collin Smith 2020-12-27 20:02:23 -08:00
parent cc807f60fa
commit dedc07799e
3 changed files with 327 additions and 0 deletions

View File

@ -0,0 +1,71 @@
package com.riiablo.table.schema;
import com.riiablo.table.annotation.Format;
import com.riiablo.table.annotation.PrimaryKey;
import com.riiablo.table.annotation.Schema;
import com.riiablo.table.annotation.Table;
import com.riiablo.table.table.RunesTable;
@Schema(
offset = 26,
preload = true
)
@Table(RunesTable.class)
@SuppressWarnings("unused")
public class Runes {
private static final String TAG = "Runes";
private static final boolean DEBUG = !true;
@Override
public String toString() {
return Rune_Name;
}
@PrimaryKey
public String Name;
@Format(format = "Rune Name")
public String Rune_Name;
public boolean complete;
public boolean server;
@Format(
startIndex = 1,
endIndex = 7)
public String itype[];
@Format(
startIndex = 1,
endIndex = 4)
public String etype[];
@Format(format = "*runes")
public String _runes;
@Format(
startIndex = 1,
endIndex = 7)
public String Rune[];
@Format(
startIndex = 1,
endIndex = 8)
public String T1Code[];
@Format(
startIndex = 1,
endIndex = 8)
public String T1Param[];
@Format(
startIndex = 1,
endIndex = 8)
public String T1Min[];
@Format(
startIndex = 1,
endIndex = 8)
public String T1Max[];
}

View File

@ -0,0 +1,169 @@
// automatically generated by TableCodeGenerator, do not modify
package com.riiablo.table.table;
import javax.annotation.Generated;
import com.badlogic.gdx.utils.IntMap;
import com.riiablo.logger.LogManager;
import com.riiablo.logger.Logger;
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.RunesParser;
import com.riiablo.table.schema.Runes;
import com.riiablo.table.serializer.RunesSerializer;
@Generated(
value = "com.riiablo.table.annotation.TableCodeGenerator",
date = "2020-12-20T01:19:44-08:00",
comments = "com.riiablo.table.schema.Runes"
)
public final class RunesTable extends Table<Runes> {
private static final Logger log = LogManager.getLogger(RunesTable.class);
public RunesTable() {
super(Runes.class, 53, 0.8f);
}
@Override
protected Runes newRecord() {
return new Runes();
}
@Override
protected Parser<Runes> newParser(ParserInput arg0) {
return new RunesParser(arg0);
}
@Override
protected Serializer<Runes> newSerializer() {
return new RunesSerializer();
}
@Override
protected int offset() {
return 26;
}
@Override
protected boolean indexed() {
return false;
}
@Override
protected boolean preload() {
return true;
}
@Override
protected String primaryKey() {
return "Name";
}
private int map(Runes record) {
final int oldId = Integer.parseInt(record.Name.substring(8)); // "Runeword"
switch (oldId) {
case 1: return 27; // Ancient's Pledge
case 4: return 30; // Beast (The Beast)
case 6: return 32; // Black
case 8: return 34; // Bone
case 9: return 35; // Bramble
case 10: return 36; // Brand
case 11: return 37; // Breath of the Dying
case 13: return 39; // Call to Arms
case 14: return 40; // Chains of Honor (Bound by Duty)
case 16: return 42; // Chaos
case 17: return 43; // Crescent Moon
case 20: return 46; // Death
case 22: return 2718; // Delirium
case 25: return 51; // Destruction
case 26: return 52; // Doom (Doomsayer)
case 27: return 53; // Dragon
case 29: return 55; // Dream
case 30: return 56; // Duress
case 31: return 57; // Edge
case 33: return 59; // Enigma
case 34: return 60; // Enlightenment
case 36: return 62; // Eternity
case 37: return 63; // Exile (Exile's Path)
case 38: return 64; // Faith
case 39: return 65; // Famine
case 41: return 67; // Fortitude
case 44: return 70; // Fury
case 45: return 71; // Gloom
case 47: return 73; // Widowmaker
case 48: return 74; // Hand of Justice
case 49: return 75; // Harmony
case 51: return 77; // Heart of the Oak
case 54: return 80; // Holy Thunder
case 55: return 81; // Honor
case 59: return 85; // Ice
case 60: return 86; // Infinity
case 62: return 88; // Insight
case 65: return 91; // King's Grace
case 66: return 92; // Kingslayer
case 69: return 95; // Last Wish
case 71: return 97; // Lawbringer
case 72: return 98; // Leaf
case 74: return 100; // Lionheart
case 75: return 101; // Lore
case 81: return 106; // Malice
case 82: return 107; // Melody
case 83: return 108; // Memory
case 87: return 112; // Myth
case 88: return 113; // Nadir
case 91: return 116; // Oath
case 92: return 117; // Obedience
case 95:
if (record.Rune_Name.equalsIgnoreCase("PASSION")) {
return 120; // Passion
} else {
return -1; // Patience
}
case 98: return 123; // Peace
case 99: return 124; // Winter
case 103: return 128; // Phoenix
case 109: return 134; // Pride
case 110: return 135; // Principle
case 112: return 137; // Prudence
case 116: return 141; // Radiance
case 117: return 142; // Rain
case 120: return 145; // Rhyme
case 121: return 146; // Rift
case 122: return 147; // Sanctuary
case 126: return 151; // Silence
case 128: return 153; // Smoke
case 130: return 155; // Spirit
case 131: return 156; // Splendor
case 133: return 158; // Stealth
case 134: return 159; // Steel
case 137: return 162; // Stone
case 139: return 164; // Strength
case 148: return 173; // Treachery
case 154: return 179; // Venom
case 160: return 185; // Wealth
case 162: return 187; // White
case 163: return 188; // Wind
case 168: return 193; // Wrath
case 170: return 195; // Zephyr
default: return -1;
}
}
@Override
protected void initialize() {
log.trace("initializing...");
final int offset = offset();
IntMap<Runes> remap = new IntMap<>();
for (Runes record : records.values()) {
final int newId = map(record);
log.trace("{}: {} -> {}", record.Name, record.Rune_Name, newId);
if (newId >= 0) remap.put(newId, record);
}
records = remap;
log.debug("initialized {} records", records.size);
}
}

View File

@ -14,6 +14,7 @@ import com.riiablo.logger.LogManager;
import com.riiablo.table.schema.MonStats;
import com.riiablo.table.schema.Weapons;
import com.riiablo.table.table.MonStatsTable;
import com.riiablo.table.table.RunesTable;
import com.riiablo.table.table.WeaponsTable;
public class TablesTest extends RiiabloTest {
@ -75,4 +76,90 @@ public class TablesTest extends RiiabloTest {
record = table.get(240);
Assert.assertEquals("Flying Axe", record.name);
}
@Test
public void runes() {
LogManager.setLevel("com.riiablo.table.table.RunesTable", Level.TRACE);
TableManifest.runes.parser = null;
FileHandle handle = Gdx.files.internal("test/runes.txt");
RunesTable table = Tables.loadTsv(TableManifest.runes, handle);
Assert.assertEquals("Ancient's Pledge", table.get(27).Rune_Name);
Assert.assertEquals("The Beast", table.get(30).Rune_Name);
Assert.assertEquals("Black", table.get(32).Rune_Name);
Assert.assertEquals("Bone", table.get(34).Rune_Name);
Assert.assertEquals("Bramble", table.get(35).Rune_Name);
Assert.assertEquals("Brand", table.get(36).Rune_Name);
Assert.assertEquals("Breath of the Dying", table.get(37).Rune_Name);
Assert.assertEquals("Call to Arms", table.get(39).Rune_Name);
Assert.assertEquals("Bound by Duty", table.get(40).Rune_Name);
Assert.assertEquals("Chaos", table.get(42).Rune_Name);
Assert.assertEquals("Crescent Moon", table.get(43).Rune_Name);
Assert.assertEquals("Death", table.get(46).Rune_Name);
Assert.assertEquals("Delirium", table.get(2718).Rune_Name);
Assert.assertEquals("Destruction", table.get(51).Rune_Name);
Assert.assertEquals("Doomsayer", table.get(52).Rune_Name);
Assert.assertEquals("Dragon", table.get(53).Rune_Name);
Assert.assertEquals("Dream", table.get(55).Rune_Name);
Assert.assertEquals("Duress", table.get(56).Rune_Name);
Assert.assertEquals("Edge", table.get(57).Rune_Name);
Assert.assertEquals("Enigma", table.get(59).Rune_Name);
Assert.assertEquals("Enlightenment", table.get(60).Rune_Name);
Assert.assertEquals("Eternity", table.get(62).Rune_Name);
Assert.assertEquals("Exile's Path", table.get(63).Rune_Name);
Assert.assertEquals("Faith", table.get(64).Rune_Name);
Assert.assertEquals("Famine", table.get(65).Rune_Name);
Assert.assertEquals("Fortitude", table.get(67).Rune_Name);
Assert.assertEquals("Fury", table.get(70).Rune_Name);
Assert.assertEquals("Gloom", table.get(71).Rune_Name);
Assert.assertEquals("Widowmaker", table.get(73).Rune_Name);
Assert.assertEquals("Hand of Justice", table.get(74).Rune_Name);
Assert.assertEquals("Harmony", table.get(75).Rune_Name);
Assert.assertEquals("Heart of the Oak", table.get(77).Rune_Name);
Assert.assertEquals("Holy Thunder", table.get(80).Rune_Name);
Assert.assertEquals("Honor", table.get(81).Rune_Name);
Assert.assertEquals("Ice", table.get(85).Rune_Name);
Assert.assertEquals("Infinity", table.get(86).Rune_Name);
Assert.assertEquals("Insight", table.get(88).Rune_Name);
Assert.assertEquals("King's Grace", table.get(91).Rune_Name);
Assert.assertEquals("Kingslayer", table.get(92).Rune_Name);
Assert.assertEquals("Last Wish", table.get(95).Rune_Name);
Assert.assertEquals("Lawbringer", table.get(97).Rune_Name);
Assert.assertEquals("Leaf", table.get(98).Rune_Name);
Assert.assertEquals("Lionheart", table.get(100).Rune_Name);
Assert.assertEquals("Lore", table.get(101).Rune_Name);
Assert.assertEquals("Malice", table.get(106).Rune_Name);
Assert.assertEquals("Melody", table.get(107).Rune_Name);
Assert.assertEquals("Memory", table.get(108).Rune_Name);
Assert.assertEquals("Myth", table.get(112).Rune_Name);
Assert.assertEquals("Nadir", table.get(113).Rune_Name);
Assert.assertEquals("Oath", table.get(116).Rune_Name);
Assert.assertEquals("Obedience", table.get(117).Rune_Name);
Assert.assertEquals("Passion", table.get(120).Rune_Name);
Assert.assertEquals("Peace", table.get(123).Rune_Name);
Assert.assertEquals("Winter", table.get(124).Rune_Name);
Assert.assertEquals("Phoenix", table.get(128).Rune_Name);
Assert.assertEquals("Pride", table.get(134).Rune_Name);
Assert.assertEquals("Principle", table.get(135).Rune_Name);
Assert.assertEquals("Prudence", table.get(137).Rune_Name);
Assert.assertEquals("Radiance", table.get(141).Rune_Name);
Assert.assertEquals("Rain", table.get(142).Rune_Name);
Assert.assertEquals("Rhyme", table.get(145).Rune_Name);
Assert.assertEquals("Rift", table.get(146).Rune_Name);
Assert.assertEquals("Sanctuary", table.get(147).Rune_Name);
Assert.assertEquals("Silence", table.get(151).Rune_Name);
Assert.assertEquals("Smoke", table.get(153).Rune_Name);
Assert.assertEquals("Spirit", table.get(155).Rune_Name);
Assert.assertEquals("Splendor", table.get(156).Rune_Name);
Assert.assertEquals("Stealth", table.get(158).Rune_Name);
Assert.assertEquals("Steel", table.get(159).Rune_Name);
Assert.assertEquals("Stone", table.get(162).Rune_Name);
Assert.assertEquals("Strength", table.get(164).Rune_Name);
Assert.assertEquals("Treachery", table.get(173).Rune_Name);
Assert.assertEquals("Venom", table.get(179).Rune_Name);
Assert.assertEquals("Wealth", table.get(185).Rune_Name);
Assert.assertEquals("White", table.get(187).Rune_Name);
Assert.assertEquals("Wind", table.get(188).Rune_Name);
Assert.assertEquals("Wrath", table.get(193).Rune_Name);
Assert.assertEquals("Zephyr", table.get(195).Rune_Name);
}
}