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
+22 -2

No files matched your search

+3 -2
View File
@@ -1,8 +1,8 @@
<html> <html>
<head> <head>
<title>GrimoireJS</title> <title>GrimoireJS</title>
<script src="./jquery-2.1.1.min.js"></script> <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="./lodash.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js"></script>
<script type="application/javascript" src="grimoire.js"></script> <script type="application/javascript" src="grimoire.js"></script>
<script type="application/javascript" src="intelligence.js"></script> <script type="application/javascript" src="intelligence.js"></script>
<script type="application/javascript" src="weapons.js"></script> <script type="application/javascript" src="weapons.js"></script>
@@ -57,6 +57,7 @@
<ul style="list-style-type:square"> <ul style="list-style-type:square">
<li>All get*() function take a "type" argument that can be either 'minor', 'medium', or 'major'</li> <li>All get*() function take a "type" argument that can be either 'minor', 'medium', or 'major'</li>
<li>Try running Grimoire.getItems(2,2,2) to generate several minor, medium, and major items</li> <li>Try running Grimoire.getItems(2,2,2) to generate several minor, medium, and major items</li>
<li>NOTE that all non-unique weapons are returned as "minor/medium/major melee/range weapon". It is up to the GM to determine what specific weapon this resolves to. It is recommend to check what proficiencies your players have. :)
<li>Many get*() functions also have an optional paramater "source" that specifies which source material to pull from. Currently, only "CRB" and "APG" are supported.</li> <li>Many get*() functions also have an optional paramater "source" that specifies which source material to pull from. Currently, only "CRB" and "APG" are supported.</li>
</ul> </ul>
<br/> <br/>
+19
View File
@@ -432,6 +432,9 @@ Weapons.getWeapon = function(type, wClass, final) {
'cost': newWeapon.cost + Weapons.data.bonusCost[newWeapon.bonus + special.bonus].cost - Weapons.data.bonusCost[newWeapon.bonus].cost, 'cost': newWeapon.cost + Weapons.data.bonusCost[newWeapon.bonus + special.bonus].cost - Weapons.data.bonusCost[newWeapon.bonus].cost,
}; };
} }
else {
weapon = newWeapon; //Don't apply the new special
}
break; break;
} }
} }
@@ -471,6 +474,9 @@ Weapons.getWeapon = function(type, wClass, final) {
'cost': newWeapon.cost + Weapons.data.bonusCost[newWeapon.bonus + special.bonus].cost - Weapons.data.bonusCost[newWeapon.bonus].cost, 'cost': newWeapon.cost + Weapons.data.bonusCost[newWeapon.bonus + special.bonus].cost - Weapons.data.bonusCost[newWeapon.bonus].cost,
}; };
} }
else {
weapon = newWeapon; //Don't apply the new special
}
break; break;
} }
} }
@@ -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, 'cost': newWeapon.cost + Weapons.data.bonusCost[newWeapon.bonus + special.bonus].cost - Weapons.data.bonusCost[newWeapon.bonus].cost,
}; };
} }
else {
weapon = newWeapon; //Don't apply the new special
}
break; 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('+'); var i = weapon.name.indexOf('+');
if(i != -1) { if(i != -1) {
//move the '+X' to the front //move the '+X' to the front