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.
This commit is contained in:
@@ -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}}<div class="sheet-desc">{{desc}}</div>{{/desc}}
|
||||
</div>
|
||||
</div>
|
||||
</rolltemplate>
|
||||
</rolltemplate>
|
||||
|
||||
Reference in New Issue
Block a user