mirror of
https://github.com/RussellChamp/Grimoire.git
synced 2026-10-28 00:22:32 +00:00
Added some "quick links", added Generate Spellbook, added some useless
libs to bower
This commit is contained in:
1 parent
34f8e9d532
commit
62cd506aee
4 files changed
+141
-13
No files matched your search
+92
-3
@@ -1,5 +1,5 @@
|
||||
/*global _:false */
|
||||
/*global Grimoire:false, Weapons:false, Potions:false, Rings:false, Scrolls:false, Wands:false, Rods:false, Staves:false, WondrousItems:false, Intelligence:false*/
|
||||
/*global Grimoire:false, Weapons:false, Potions:false, Rings:false, Scrolls:false, Wands:false, Rods:false, Staves:false, WondrousItems:false, Intelligence:false, Spells:false*/
|
||||
/*jshint forin: false */
|
||||
(function (angular) {
|
||||
'use strict';
|
||||
@@ -11,6 +11,10 @@
|
||||
var self = this;
|
||||
this.welcome = 'Welcome to the Grimoire App!';
|
||||
this.itemCount = [1,1,1];
|
||||
this.spellLevel = 0;
|
||||
this.spellType = "arcane";
|
||||
this.casterLevel = 1;
|
||||
this.baseCost = 1000;
|
||||
|
||||
this.sources = [
|
||||
{
|
||||
@@ -125,15 +129,100 @@
|
||||
|
||||
this.addItemList = function(list) {
|
||||
self.itemLists.push(list);
|
||||
self.scrollItemsBottom();
|
||||
setTimeout(function() { self.scrollItemsBottom(); }, 200);
|
||||
//otherwise the scroll will get ahead of the add
|
||||
};
|
||||
|
||||
this.scrollItemsBottom = function() {
|
||||
//BAD BAD ANGULAR FORM!
|
||||
//The slimscroll item didn't allow for a way to bind to an object
|
||||
//I'm not sure how to do this correctly
|
||||
$('#itemScroll').slimScroll({ scrollBy: 99999}); //just all the way
|
||||
//$('#itemScroll').slimScroll({ scrollBy: 99999}); //just all the way
|
||||
//I couldn't get {start: 'bottom'} to work right
|
||||
//$('#itemScroll').slimScroll({ start: 'bottom'});
|
||||
var height = $('#itemScroll').prop('scrollHeight') + 'px';
|
||||
$('#itemScroll').slimScroll({ scrollTo: height});
|
||||
};
|
||||
|
||||
this.getValue = function(list) {
|
||||
var sum = 0;
|
||||
_.forEach(list, function(item) { sum += item.cost;});
|
||||
return sum;
|
||||
};
|
||||
|
||||
this.getDeity = function() {
|
||||
self.itemLists.push({
|
||||
timestamp: new Date(),
|
||||
items: [
|
||||
{
|
||||
name: "Deity: " + Grimoire.getDeity()
|
||||
}
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
this.getEnergyType = function() {
|
||||
self.itemLists.push({
|
||||
timestamp: new Date(),
|
||||
items: [
|
||||
{
|
||||
name: "Energy Type: " + Grimoire.getEnergyResistance()
|
||||
}
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
this.getSpell = function(type, level) {
|
||||
//console.log(String(type) + " " + String(level));
|
||||
if(type && level > -1) {
|
||||
var itemList = {};
|
||||
itemList.spells = [];
|
||||
itemList.spells.push(Spells.getLevelSpell(level, type));
|
||||
itemList.timestamp = new Date();
|
||||
console.log(itemList);
|
||||
self.itemLists.push(itemList);
|
||||
}
|
||||
};
|
||||
|
||||
this.generateSpellbook = function(casterLevel) {
|
||||
if(casterLevel) {
|
||||
casterLevel = _.min([casterLevel, 20]);
|
||||
var itemList = {};
|
||||
itemList.spells = [];
|
||||
//there's really no precident for this.
|
||||
//I'm just going to assume Wizard only.
|
||||
//Assume ALL cantrips
|
||||
//Wizards know 3 + Int level 1 spells at level 1
|
||||
//Ever level, a wizard adds two new spells to his book
|
||||
//The minimum CL for a spell is (spell * 2 - 1)
|
||||
//We will just take a shot and say the following
|
||||
//Level 1 spells: 3 + 1/2 CL
|
||||
//Level 2 spells:
|
||||
var slvl = [2,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];
|
||||
//console.log("At Caster Level " + String(casterLevel) + " you get:");
|
||||
for(var spellLevel = 1; spellLevel <= 9; spellLevel++) {
|
||||
var numSpells = 0;
|
||||
if(casterLevel >= spellLevel * 2 - 1) { //minimum requirement
|
||||
numSpells = slvl[casterLevel - (spellLevel*2-1)];
|
||||
if(spellLevel === 1) {
|
||||
numSpells += 4; //since you start with 3 + Int first level spells
|
||||
}
|
||||
//console.log(String(numSpells) + " level " + String(spellLevel) + " spells");
|
||||
for(var i = 0; i < numSpells; i++) {
|
||||
var newSpell = {};
|
||||
do {
|
||||
newSpell = Spells.getLevelSpell(spellLevel, 'arcane');
|
||||
} while(itemList.spells.indexOf(newSpell) !== -1); //duplicate
|
||||
itemList.spells.push(newSpell);
|
||||
}
|
||||
}
|
||||
else
|
||||
break; //no point checking the higher levels
|
||||
}
|
||||
|
||||
itemList.timestamp = new Date();
|
||||
self.itemLists.push(itemList);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user