Committing ParserMapper and RunesMapper implementation

Deprecated, but a good start if ever moved forward with
This commit is contained in:
Collin Smith 2020-12-27 20:03:37 -08:00
parent dedc07799e
commit 257a8d3b40
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,36 @@
package com.riiablo.table.parser;
import io.netty.util.AsciiString;
import com.riiablo.logger.LogManager;
import com.riiablo.logger.Logger;
import com.riiablo.table.ParserMapper;
@Deprecated
public final class RunesMapper implements ParserMapper<RunesParser> {
private static final Logger log = LogManager.getLogger(RunesMapper.class);
private static final int PREFIX_LENGTH = "RUNEWORD".length();
@Override
public int map(RunesParser parser, final String recordName) {
final String idString = recordName.substring(PREFIX_LENGTH);
final int oldId = Integer.parseInt(idString);
final int newId;
if (oldId == 22) {
// Delerium
newId = 2718;
} else if (oldId == 95) {
// Passion / Patience duplicate
final CharSequence Rune_Name = parser.parser().token(-1, parser.fieldIds[1]);
newId = AsciiString.contentEqualsIgnoreCase(Rune_Name, "Passion")
? 95
: 96;
} else {
newId = oldId;
}
if (oldId != newId) log.debug("{}: {} -> {}", recordName, oldId, newId);
return newId;
}
}

View File

@ -0,0 +1,9 @@
package com.riiablo.table;
/**
* @deprecated unused -- attempt to create automatic mapping of txt parser records to indexes
*/
@Deprecated
public interface ParserMapper<P extends Parser<?>> {
int map(P parser, String recordName);
}