From 49d77ab784b76d8e2f79531ca404812e7fdf5da5 Mon Sep 17 00:00:00 2001 From: Tristan Maat Date: Wed, 4 May 2022 03:33:38 +0100 Subject: [PATCH] PTUv2: Use strict equality checking for strings on attribute import Currently when using the import button, all attributes set to 0 will be skipped, because the [`==`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality) operator is silly and auto-converts strings into numbers. This is technically a backwards-incompatible change, since this could in theory be used to set some attributes to "please don't override this". I don't think that's useful, however, since simply omitting those attributes achieves the same effect, and if this was intentional I doubt it would be checked this way. Allowing these values to be changed on the other hand is useful for backup imports and other suchlike. --- PokemonTabletopUnited_v2/PTUv2.html | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/PokemonTabletopUnited_v2/PTUv2.html b/PokemonTabletopUnited_v2/PTUv2.html index 85355d0513..8880087a7f 100644 --- a/PokemonTabletopUnited_v2/PTUv2.html +++ b/PokemonTabletopUnited_v2/PTUv2.html @@ -3336,7 +3336,7 @@ The user is cured with a DC 16 Save." /> for (var property in char) { if (char.hasOwnProperty(property)) { - if(char[property] == undefined || char[property] == ""){ + if(char[property] == undefined || char[property] === ""){ continue; } if (property.match(/Move\s*\d*/gi) != null) { @@ -3347,7 +3347,7 @@ The user is cured with a DC 16 Save." /> for (var prop in char[property]){ if (char[property].hasOwnProperty(prop)){ - if(char[property][prop] == undefined || char[property][prop] == ""){ + if(char[property][prop] == undefined || char[property][prop] === ""){ continue; } @@ -3417,7 +3417,7 @@ The user is cured with a DC 16 Save." /> for (var prop in char[property]){ if (char[property].hasOwnProperty(prop)){ - if(char[property][prop] == undefined || char[property][prop] == ""){ + if(char[property][prop] == undefined || char[property][prop] === ""){ continue; } x = "repeating_features_".concat(i).concat("_Feature_").concat(prop); @@ -3430,7 +3430,7 @@ The user is cured with a DC 16 Save." /> i=generateRowID(); for (var prop in char[property]){ if (char[property].hasOwnProperty(prop)){ - if(char[property][prop] == undefined || char[property][prop] == ""){ + if(char[property][prop] == undefined || char[property][prop] === ""){ continue; } x = "repeating_abilities_".concat(i).concat("_Ability_").concat(prop); @@ -3443,7 +3443,7 @@ The user is cured with a DC 16 Save." /> i=generateRowID(); for (var prop in char[property]){ if (char[property].hasOwnProperty(prop)){ - if(char[property][prop] == undefined || char[property][prop] == ""){ + if(char[property][prop] == undefined || char[property][prop] === ""){ continue; } x = "repeating_edges_".concat(i).concat("_Edge").concat(prop); @@ -3456,7 +3456,7 @@ The user is cured with a DC 16 Save." /> x = 0; for (var prop in char[property]) { if (char[property].hasOwnProperty(prop)) { - if(char[property][prop] == undefined || char[property][prop] == ""){ + if(char[property][prop] == undefined || char[property][prop] === ""){ continue; } @@ -3490,43 +3490,43 @@ The user is cured with a DC 16 Save." /> } } } else if(property.match(/nickname/i)){ - if(char[property] == undefined || char[property] == ""){ + if(char[property] == undefined || char[property] === ""){ continue; } t["character_name"] = char[property]; } else if(property.match(/struggle_type/i)){ - if(char[property] == undefined || char[property] == ""){ + if(char[property] == undefined || char[property] === ""){ continue; } t["struggleType"] = char[property]; } else if(property.match(/struggle_dtype/i)){ - if(char[property] == undefined || char[property] == ""){ + if(char[property] == undefined || char[property] === ""){ continue; } t["struggleCat"] = char[property]; } else if(property.match(/struggle_db/i)){ - if(char[property] == undefined || char[property] == ""){ + if(char[property] == undefined || char[property] === ""){ continue; } t["struggle_db"] = parseInt(char[property],10)||0; } else if(property.match(/struggle_ac/i)){ - if(char[property] == undefined || char[property] == ""){ + if(char[property] == undefined || char[property] === ""){ continue; } t["struggleAC"] = parseInt(char[property],10)||0; } else if(property.match(/struggle_range/i)){ - if(char[property] == undefined || char[property] == ""){ + if(char[property] == undefined || char[property] === ""){ continue; } t["struggleRange"] = char[property]; }else { - if(char[property] == undefined || char[property] == ""){ + if(char[property] == undefined || char[property] === ""){ continue; } t[property]= char[property] ; @@ -4231,4 +4231,4 @@ The user is cured with a DC 16 Save." /> {{#desc}}
{{desc}}
{{/desc}} - \ No newline at end of file +