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

+4 -3
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/>
@@ -71,4 +72,4 @@ Create an intelligence by running Intelligence.getItemIntelligence().print()</di
<li>Already input spells for wizard/sorceror, cleric, and druid. Check for other arcane and divine spells from other classes</li> <li>Already input spells for wizard/sorceror, cleric, and druid. Check for other arcane and divine spells from other classes</li>
</ul> </ul>
</body> </body>
</html> </html>
+24 -5
View File
@@ -107,7 +107,7 @@ Weapons.getSpecific = function(type) {
} }
} }
}; //end getSpecific }; //end getSpecific
Weapons.data.meleeSpecial = [ Weapons.data.meleeSpecial = [
{'name': 'Bane', 'bonus': 1}, {'name': 'Bane', 'bonus': 1},
{'name': 'Defending', '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, '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') { 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, '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') { 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, '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('+'); var i = weapon.name.indexOf('+');
if(i != -1) { if(i != -1) {
//move the '+X' to the front //move the '+X' to the front
@@ -542,4 +561,4 @@ Weapons.getWeapons = function (numMinor, numMedium, numMajor, wClass) {
weapons.push(Weapons.getWeapon('major', wClass)); weapons.push(Weapons.getWeapon('major', wClass));
}); });
return weapons; return weapons;
}; };