From 9fa380d4f932b8e150c378a84fc1a291f7fc60af Mon Sep 17 00:00:00 2001 From: Scott Bender Date: Sun, 15 Oct 2023 15:05:16 -0400 Subject: [PATCH] fix: handle canboat FieldType name change to FIELDTYPE_LOOKUP (#259) --- lib/fromPgn.js | 4 +++- lib/toPgn.js | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/fromPgn.js b/lib/fromPgn.js index 5fa522d..5ccd15a 100644 --- a/lib/fromPgn.js +++ b/lib/fromPgn.js @@ -611,6 +611,7 @@ function readField(options, runPostProcessor, pgn, field, bs, fields) { } if ( options.checkForInvalidFields !== false && max !== 'undefined' && field.FieldType !== 'LOOKUP' && + field.FieldType !== 'FIELDTYPE_LOOKUP' && field.BitLength > 1 && max - value <= 0 ) { //console.log(`Bad field ${field.Name} ${max - value}`) @@ -633,7 +634,8 @@ function readField(options, runPostProcessor, pgn, field, bs, fields) { value = Number.parseFloat(value.toFixed(precision)) } - if (field.FieldType === 'LOOKUP' && + if ((field.FieldType === 'LOOKUP' || + field.FieldType === 'FIELDTYPE_LOOKUP') && runPostProcessor && (_.isUndefined(options.resolveEnums) || options.resolveEnums)) { diff --git a/lib/toPgn.js b/lib/toPgn.js index 6335168..f5f0fc9 100644 --- a/lib/toPgn.js +++ b/lib/toPgn.js @@ -190,7 +190,8 @@ function writeField(bs, pgn_number, field, data, value, fields, bitLength) { } } else if ( type && fieldTypeMappers[type] ) { value = fieldTypeMappers[type](field, value) - } else if (field.FieldType === 'LOOKUP' && _.isString(value)) { + } else if ((field.FieldType === 'LOOKUP' || + field.FieldType === 'FIELDTYPE_LOOKUP') && _.isString(value)) { if (!(field.Id === "timeStamp" && value < 60)) { value = lookup(field, value) }