Resolve the 0.1% chance issue with Weapons not generating due to a too high bonus

This commit is contained in:
RussellChamp committed 2015-01-23 15:57:07 +00:00
1 parent c190be3236
commit 4655191030
2 files changed
+28 -8

No files matched your search

+24 -5
View File
@@ -107,7 +107,7 @@ Weapons.getSpecific = function(type) {
}
}
}; //end getSpecific
Weapons.data.meleeSpecial = [
{'name': 'Bane', 'bonus': 1},
{'name': 'Defending', 'bonus': 1},
@@ -432,7 +432,10 @@ Weapons.getWeapon = function(type, wClass, final) {
'cost': newWeapon.cost + Weapons.data.bonusCost[newWeapon.bonus + special.bonus].cost - Weapons.data.bonusCost[newWeapon.bonus].cost,
};
}
break;
else {
weapon = newWeapon; //Don't apply the new special
}
break;
}
}
else if(type == 'medium') {
@@ -471,7 +474,10 @@ Weapons.getWeapon = function(type, wClass, final) {
'cost': newWeapon.cost + Weapons.data.bonusCost[newWeapon.bonus + special.bonus].cost - Weapons.data.bonusCost[newWeapon.bonus].cost,
};
}
break;
else {
weapon = newWeapon; //Don't apply the new special
}
break;
}
}
else if(type == 'major') {
@@ -505,10 +511,23 @@ Weapons.getWeapon = function(type, wClass, final) {
'cost': newWeapon.cost + Weapons.data.bonusCost[newWeapon.bonus + special.bonus].cost - Weapons.data.bonusCost[newWeapon.bonus].cost,
};
}
break;
else {
weapon = newWeapon; //Don't apply the new special
}
break;
}
}
if(weapon === undefined || Object.keys(weapon).length === 0) {
var err = new Error();
console.log(type);
console.log(wClass);
console.log(final);
console.log("roll: " + roll);
console.log(newWeapon);
console.log(special);
return err.stack;
}
var i = weapon.name.indexOf('+');
if(i != -1) {
//move the '+X' to the front
@@ -542,4 +561,4 @@ Weapons.getWeapons = function (numMinor, numMedium, numMajor, wClass) {
weapons.push(Weapons.getWeapon('major', wClass));
});
return weapons;
};
};