Updated the printing of intelligent items; added minimum value threshold

This commit is contained in:
Russell Champoux committed 2015-01-27 13:19:26 -05:00
1 parent 2219b0d69b
commit c6b80fb7d4
3 files changed
+68 -54

No files matched your search

+52 -42
View File
@@ -15,6 +15,7 @@
this.spellType = "arcane"; this.spellType = "arcane";
this.casterLevel = 1; this.casterLevel = 1;
this.baseCost = 1000; this.baseCost = 1000;
this.minimumTotalCost = 0;
this.sources = [ this.sources = [
{ {
@@ -80,41 +81,56 @@
}; };
this.generateItems = function() { this.generateItems = function() {
var tries = 10;
var itemList = {}; var itemList = {};
itemList.items = []; do {
itemList.items = [];
if(tries === 0) {
itemList.notes = "ERROR: Could not generate items over " + self.minimumTotalCost + "gp after 10 tries";
break;
}
if(self.radio) { if(self.radio) {
//console.log("Generating item from " + self.radio); //console.log("Generating item from " + self.radio);
var source = self.radio.split("|"); var source = self.radio.split("|");
var types = ["minor", "medium", "major"]; var types = ["minor", "medium", "major"];
for(var idx in types) { //for each item level for(var idx in types) { //for each item level
for(var i = 0; i < self.itemCount[idx]; i++) { for(var i = 0; i < self.itemCount[idx]; i++) {
itemList.items.push(self.generateItem(source[1], types[idx])); itemList.items.push(self.generateItem(source[1], types[idx]));
}
} }
} }
} else {
else { var ss = "";
var ss = ""; for( var idx in self.sources) {
for( var idx in self.sources) { var source = self.sources[idx];
var source = self.sources[idx]; if(source.selected) {
if(source.selected) { ss += source.shortName + " ";
ss += source.shortName + " "; }
}
if(ss) {
//console.log("Generating items from " + ss);
itemList.items = Grimoire.getItems(self.itemCount[0], self.itemCount[1], self.itemCount[2]);
}
else {
console.log("Error: No sources selected");
} }
} }
if(ss) { tries--;
//console.log("Generating items from " + ss); } while(self.minimumTotalCost && self.getValue(itemList.items) < self.minimumTotalCost);
itemList.items = Grimoire.getItems(self.itemCount[0], self.itemCount[1], self.itemCount[2]);
}
else {
console.log("Error: No sources selected");
}
}
itemList.timestamp = new Date();
self.addItemList(itemList); self.addItemList(itemList);
}; };
this.generateIntelligence = function(cost) { this.generateIntelligence = function(cost) {
var list = {}; var itemInt = Intelligence.getItemIntelligence(cost);
var list = {
items: [{
name: "Intelligent Item",
intelligence: itemInt,
cost: cost + itemInt.cost,
}],
};
/*
var stats = Intelligence.getItemIntelligence(cost).print().split(";"); var stats = Intelligence.getItemIntelligence(cost).print().split(";");
list.notes = ""; list.notes = "";
for(var s in stats) { for(var s in stats) {
@@ -124,10 +140,14 @@
} }
list.timestamp = new Date(); list.timestamp = new Date();
self.itemLists.push(list); */
self.addItemList(list);
}; };
this.addItemList = function(list) { this.addItemList = function(list) {
if(!list.timestamp) {
list.timestamp = new Date();
}
self.itemLists.push(list); self.itemLists.push(list);
setTimeout(function() { self.scrollItemsBottom(); }, 200); setTimeout(function() { self.scrollItemsBottom(); }, 200);
//otherwise the scroll will get ahead of the add //otherwise the scroll will get ahead of the add
@@ -151,24 +171,14 @@
}; };
this.getDeity = function() { this.getDeity = function() {
self.itemLists.push({ self.addItemList({
timestamp: new Date(), notes: "Deity: " + Grimoire.getDeity(),
items: [
{
name: "Deity: " + Grimoire.getDeity()
}
],
}); });
}; };
this.getEnergyType = function() { this.getEnergyType = function() {
self.itemLists.push({ self.addItemList({
timestamp: new Date(), notes: "Energy Type: " + Grimoire.getEnergyResistance()
items: [
{
name: "Energy Type: " + Grimoire.getEnergyResistance()
}
],
}); });
}; };
@@ -180,7 +190,7 @@
itemList.spells.push(Spells.getLevelSpell(level, type)); itemList.spells.push(Spells.getLevelSpell(level, type));
itemList.timestamp = new Date(); itemList.timestamp = new Date();
console.log(itemList); console.log(itemList);
self.itemLists.push(itemList); self.addItemList(itemList);
} }
}; };
@@ -221,7 +231,7 @@
} }
itemList.timestamp = new Date(); itemList.timestamp = new Date();
self.itemLists.push(itemList); self.addItemList(itemList);
} }
}; };
+5
View File
@@ -37,6 +37,7 @@
.footer { .footer {
height: 2em; height: 2em;
white-space:nowrap; white-space:nowrap;
padding-bottom:4em;
} }
.list-header { .list-header {
@@ -47,6 +48,10 @@ input.numberbox {
width: 4em; width: 4em;
display:inline-block; display:inline-block;
} }
input.largecount {
width: 10em;
display:inline-block;
}
.sourceItem { .sourceItem {
padding: .2em; padding: .2em;
+11 -12
View File
@@ -32,12 +32,7 @@
</ul> </ul>
</div> </div>
<div class="menu"> <div class="menu">
QUICK BUTTONS QUICK BUTTONS OR ADS?
Get Deity
Get Energy Type
Get Spell (level)
Generate Spell Book (caster level)
Generate Item Intelligence (price)
</div> </div>
</div> </div>
<!--LIST OF ITEM LISTS--> <!--LIST OF ITEM LISTS-->
@@ -51,9 +46,11 @@
<span ng-if="grimoire.getValue(list.items) > 0"><strong>Total Value: </strong>{{grimoire.getValue(list.items)|number}}gp</span> <span ng-if="grimoire.getValue(list.items) > 0"><strong>Total Value: </strong>{{grimoire.getValue(list.items)|number}}gp</span>
<ul> <ul>
<li ng-repeat="item in list.items track by $index">{{item.name}}<span ng-if="item.description"> {{item.description}}</span><span ng-if="item.cost > 0"> {{item.cost|number}}gp</span><a class="super" target="_blank" ng-if="item.url" href={{item.url}}>link</a> <li ng-repeat="item in list.items track by $index">{{item.name}}<span ng-if="item.description"> {{item.description}}</span><span ng-if="item.cost > 0"> {{item.cost|number}}gp</span><a class="super" target="_blank" ng-if="item.url" href={{item.url}}>link</a>
<ul ng-if="item.intelligence"><li>{{item.intelligence.print()}}</li></ul></li> <!--PRINT ITEM INTELLIGENCE-->
<ul ng-if="item.intelligence"><li ng-repeat="stat in item.intelligence.print().split(';')" ng-if="stat.split(':')[0] != 'Cost'"><strong>{{stat.split(':')[0]}}:</strong>{{stat.split(':')[1]}}</li></ul></li>
</ul> </ul>
<ul> <ul>
<!--START SPELLS LIST-->
<li ng-repeat="spell in list.spells track by $index">{{spell.name}} ({{spell.type}}, Level {{spell.level}}) {{spell.source}}</li> <li ng-repeat="spell in list.spells track by $index">{{spell.name}} ({{spell.type}}, Level {{spell.level}}) {{spell.source}}</li>
</ul> </ul>
{{list.notes}} {{list.notes}}
@@ -61,11 +58,13 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-12 big footer"> <div class="col-md-12 footer">
<div class="col-md-3 menu">Minor Item <input type="number" class="numberbox form-control" ng-model="grimoire.itemCount[0]"></div> <div class="col-md-7">
<div class="col-md-3 menu">Medium Item <input type="number" class="numberbox form-control" ng-model="grimoire.itemCount[1]"></div> <div class="col-md-4 big menu">Minor Item <input type="number" class="numberbox form-control" ng-model="grimoire.itemCount[0]"></div>
<div class="col-md-3 menu">Major Item <input type="number" class="numberbox form-control" ng-model="grimoire.itemCount[2]"></div> <div class="col-md-4 big menu">Medium Item <input type="number" class="numberbox form-control" ng-model="grimoire.itemCount[1]"></div>
<div class="col-md-3 menu"><input type="button" value="GO" ng-click="grimoire.generateItems()"></div> <div class="col-md-4 big menu">Major Item <input type="number" class="numberbox form-control" ng-model="grimoire.itemCount[2]"></div>
</div>
<div class="col-md-5 menu"><input type="button" value="GO" class="big" ng-click="grimoire.generateItems()">(Minimum Total Cost: <input type="number" class="largecount form-control" ng-model="grimoire.minimumTotalCost">gp)</div>
</div> </div>
<div class="col-md-12 footer"> <div class="col-md-12 footer">
<strong>Quick Links:</strong> <strong>Quick Links:</strong>