Revision: 340
Author: todd.chambery
Date: Wed Sep 30 20:19:16 2009
Log: filter weapons
http://code.google.com/p/charactermanager/source/detail?r=340
Modified:
/trunk/charmgrjs/edit.js
/trunk/charmgrjs/spells.js
=======================================
--- /trunk/charmgrjs/edit.js Sat Sep 26 05:45:25 2009
+++ /trunk/charmgrjs/edit.js Wed Sep 30 20:19:16 2009
@@ -319,7 +319,7 @@
});
var name = "weapon_" + (parseInt(weapon_idx) + 1);
var weapon_html = "<div id='" + name + "_div' class='new_weapon'>";
- weapon_html += c_s('weaponspart', name,
weapons, "update_weapon(chardata, \"" + name
+ "\")", "update_weapon_override(chardata, " + i + ")",
["Name", "Att", "Dam", "Crit", "Note" ], true);
+ weapon_html += c_s('weaponspart', name,
get_available_weapons(chardata), "update_weapon(chardata, \"" + name
+ "\")", "update_weapon_override(chardata, " + i + ")",
["Name", "Att", "Dam", "Crit", "Note" ], true);
weapon_html += "</div>";
$('#weaponspart').append(weapon_html);
}
@@ -343,7 +343,7 @@
for ( var i in char_weapons) {
weapons_html += "<div id='weapon_" + i + "_div'>";
var name = 'weapon_' + i;
- weapons_html += c_s('weaponspart', name,
weapons, "update_weapon(chardata, \"" + name
+ "\")", "update_weapon_override(chardata, " + i + ")",
["Name", "Att", "Dam",
+ weapons_html += c_s('weaponspart', name,
get_available_weapons(chardata), "update_weapon(chardata, \"" + name
+ "\")", "update_weapon_override(chardata, " + i + ")",
["Name", "Att", "Dam",
"Crit", "Note" ], true);
weapons_html += "</div>";
}
@@ -352,7 +352,7 @@
var new_weapon_idx = (char_weapons != null ? char_weapons.length : 0);
weapons_html += "<div id='weapon_" + new_weapon_idx + "_div'
class=\'new_weapon\'>";
var name = 'weapon_' + new_weapon_idx;
- weapons_html += c_s('weaponspart', name,
weapons, "update_weapon(chardata, \"" + name
+ "\")", "update_weapon_override(chardata, " + i + ")",
[ "Name", "Att", "Dam", "Crit",
+ weapons_html += c_s('weaponspart', name,
get_available_weapons(chardata), "update_weapon(chardata, \"" + name
+ "\")", "update_weapon_override(chardata, " + i + ")",
[ "Name", "Att", "Dam", "Crit",
"Note" ], true);
weapons_html += "</div>";
$('#weaponspart').html(weapons_html);
@@ -408,10 +408,10 @@
}
}
-function c_s(part_id, name, table, onchange_action, onblur_action,
addl_data, include_empty) {
+function c_s(part_id, name, items, onchange_action, onblur_action,
addl_data, include_empty) {
var addl_data = (addl_data == null ? [] : addl_data);
var table_html = "<table border='0'><tr>";
- var select = create_select(name, table.get(), onchange_action,
include_empty, "width: 185px;");
+ var select = create_select(name, items, onchange_action,
include_empty, "width: 185px;");
table_html += "<td colspan='2'>" + select + "</td></tr>";
for (i in addl_data) {
table_html += "<tr><td>" + addl_data[i] + "</td><td><input id='" + name
+ addl_data[i]
@@ -433,6 +433,33 @@
$('#' + part_id).append(table_html);
$('table#' + name).show();
}
+
+function get_available_weapons(chardata) {
+ var simple_weapons = weapons.get({ category: "simple" });
+ var exotic_weapons = [];
+ var martial_weapons = [];
+ if(chardata.feats) {
+ var exotic_weapons_feat = chardata.feats.first({ feat_id: 24 });
+ if(exotic_weapons_feat) {
+ for(var i in exotic_weapons_feat.multi) {
+ exotic_weapons.push(feats.first({ id: exotic_weapons_feat.multi[i] }));
+ }
+ }
+ }
+ // check class feat
+ if(is_class_feat(chardata.class_id, 43, chardata.xp)) {
+ martial_weapons = weapons.get({ category: "martial" });
+ } else if(chardata.feats){
+ var martial_weapons_feat = chardata.feats.first({ feat_id: 43 });
+ if(martial_weapons_feat) {
+ for(var i in martial_weapons_feat.multi) {
+ martial_weapons.push(feats.first({ id: martial_weapons_feat.multi[i]
}));
+ }
+ }
+ }
+
+ return simple_weapons.concat(martial_weapons).concat(exotic_weapons);
+}
function update_log(chardata){
if (chardata.xp_log == null) {
=======================================
--- /trunk/charmgrjs/spells.js Mon Sep 28 05:11:11 2009
+++ /trunk/charmgrjs/spells.js Wed Sep 30 20:19:16 2009
@@ -3437,7 +3437,7 @@
save: "-",
sr: "-",
phb: 235,
- detail: ""
+ detail: "Your speech becomes fluent and more believable. You gain a
+30 bonus on Bluff checks made to convince another of the truth of your
words. (This bonus doesn’t apply to other uses of the Bluff skill, such as
feinting in combat, creating a diversion to hide, or communicating a hidden
message via innuendo.) <p class=sub>If a divination is attempted against
you that would detect your lies or force you to speak the truth (such as
<i>discern lies</i> or <i>zone of truth</i>), the caster of the divination
must succeed on a caster level check (1d20 + caster level) against a DC of
15 + your caster level to succeed. Failure means the divination does not
detect your lies or force you to speak only the truth."
}, {
id: 227,
name: "Glitterdust",
@@ -3452,7 +3452,7 @@
save: "Will negs",
sr: "-",
phb: 236,
- detail: ""
+ detail: "A cloud of golden particles covers everyone and everything in
the area, causing creatures to become blinded and visibly outlining
invisible things for the duration of the spell. All within the area are
covered by the dust, which cannot be removed and continues to sparkle until
it fades. <p class=sub>Any creature covered by the dust takes a -40 penalty
on Hide checks. <p class=sub><i>Material Component</i>: Ground mica."
}, {
id: 228,
name: "Globe of Invulnerability",
@@ -3467,7 +3467,7 @@
save: "-",
sr: "-",
phb: 236,
- detail: ""
+ detail: "This spell functions like <i>lesser globe of
invulnerability</i>, except that it also excludes 4th-level spells and
spell-like effects."
}, {
id: 229,
name: "Globe of Invulnerability, Lesser",
@@ -3482,7 +3482,7 @@
save: "-",
sr: "-",
phb: 236,
- detail: ""
+ detail: "An immobile, faintly shimmering magical sphere surrounds you
and excludes all spell effects of 3rd level or lower. The area or effect of
any such spells does not include the area of the <i>lesser globe of
invulnerability</i>. Such spells fail to affect any target located within
the globe. Excluded effects include spell-like abilities and spells or
spell-like effects from items. However, any type of spell can be cast
through or out of the magical globe. Spells of 4th level and higher are not
affected by the globe, nor are spells already in effect when the globe is
cast. The globe can be brought down by a targeted <i>dispel magic</i>
spell, but not by an area <i>dispel magic</i>. You can leave and return to
the globe without penalty. <p class=sub>Note that spell effects are not
disrupted unless their effects enter the globe, and even then they are
merely suppressed, not dispelled. For example, creatures inside the globe
would still see a <i>mirror image</i> created by a caster outside the
globe. If that caster then entered the globe, the images would wink out, to
reappear when the caster exited the globe. Likewise, a caster standing in
the area of a <i>light</i> spell would still receive sufficient
illumination for vision, even though that part of the <i>light</i> spell’s
area that lies within the globe would not be luminous. <p class=sub>If a
given spell has more than one level depending on which character class is
casting it, use the level appropriate to the caster to determine whether
<i>lesser globe of invulnerability</i> stops it. <p class=sub><i>Material
Component</i>: A glass or crystal bead that shatters at the expiration of
the spell."
}, {
id: 230,
name: "Glyph of Warding",
@@ -3497,7 +3497,7 @@
save: "Special",
sr: "Yes",
phb: 236,
- detail: ""
+ detail: "This powerful inscription harms those who enter, pass, or
open the warded area or object. A <i>glyph of warding</i> can guard a
bridge or passage, ward a portal, trap a chest or box, and so on. <p
class=sub>You set the conditions of the ward. Typically, any creature
entering the warded area or opening the warded object without speaking a
password (which you set when casting the spell) is subject to the magic it
stores. Alternatively or in addition to a password trigger, <i>glyphs</i>
can be set according to physical characteristics (such as height or weight)
or creature type, subtype, or kind (such as aberration, drow, or red
dragon). <i>Glyphs</i> can also be set with respect to good, evil, law, or
chaos, or to pass those of your religion. They cannot be set according to
class, Hit Dice, or level. Glyphs respond to invisible creatures normally
but are not triggered by those who travel past them ethereally. Multiple
<i>glyphs</i> cannot be cast on the same area. However, if a cabinet has
three drawers, each can be separately warded. <p class=sub>When casting the
spell, you weave a tracery of faintly glowing lines around the warding
sigil. A <i>glyph</i> can be placed to conform to any shape up to the
limitations of your total square footage. When the spell is completed, the
<i>glyph</i> and tracery become nearly invisible. <p
class=sub><i>Glyphs</i> cannot be affected or bypassed by such means as
physical or magical probing, though they can be dispelled. <i>Mislead</i>,
<i>polymorph</i>, and <i>nondetection</i> (and similar magical effects) can
fool a <i>glyph</i>, though non-magical disguises and the like can’t. <p
class=sub><i>Read magic</i> allows you to identify a <i>glyph of
warding</i> with a DC 13 Spellcraft check. Identifying the <i>glyph</i>
does not discharge it and allows you to know the basic nature of the
<i>glyph</i> (version, type of damage caused, what spell is stored). <p
class=sub>The DM may decide that the exact <i>glyphs</i> available to you
depend on your deity. He or she might also make new <i>glyphs</i> available
according to the magical research rules in the <i>Dungeon Master’s
Guide</i>. <p class=sub><i>Note</i>: Magic traps such as <i>glyph of
warding</i> are hard to detect and disable. A rogue (only) can use the
Search skill to find the glyph and Disable Device to thwart it. The DC in
each case is 25 + spell level, or 28 for <i>glyph of warding</i>. <p
class=sub>Depending on the version selected, a <i>glyph</i> either blasts
the intruder or activates a spell. <p class=sub><i>Blast Glyph</i>: A
<i>blast glyph</i> deals 1d8 points of damage per two caster levels
(maximum 5d8) to the intruder and to all within 5 feet of him or her. This
damage is acid, cold, fire, electricity, or sonic (caster’s choice, made at
time of casting). Each creature affected can attempt a Reflex save to take
half damage. Spell resistance applies against this effect. <p
class=sub><i>Spell Glyph</i>: You can store any harmful spell of 3rd level
or lower that you know. All level-dependent features of the spell are based
on your caster level at the time of casting the <i>glyph</i>. If the spell
has a target, it targets the intruder. If the spell has an area or an
amorphous effect (such as a cloud), the area or effect is centered on the
intruder. If the spell summons creatures, they appear as close as possible
to the intruder and attack. Saving throws and spell resistance operate as
normal, except that the DC is based on the level of the spell stored in the
<i>glyph</i>.<p class=sub><i>Material Component</i>: You trace the
<i>glyph</i> with incense, which must first be sprinkled with powdered
diamond worth at least 200 gp."
}, {
id: 231,
name: "Glyph of Warding, Greater",
@@ -3512,7 +3512,7 @@
save: "Special",
sr: "Yes",
phb: 237,
- detail: ""
+ detail: "This spell functions like <i>glyph of warding</i>, except
that a <i>greater blast glyph</i> deals up to 10d8 points of damage, and a
<i>greater spell glyph</i> can store a spell of 6th level or lower. <p
class=sub><i>Material Component</i>: You trace the <i>glyph</i> with
incense, which must first be sprinkled with powdered diamond worth at least
400 gp."
}, {
id: 232,
name: "Goodberry",
@@ -3527,7 +3527,7 @@
save: "-",
sr: "Yes",
phb: 237,
- detail: ""
+ detail: "Casting <i>goodberry</i> upon a handful of freshly picked
berries makes 2d4 of them magical. You (as well as any other druid of 3rd
or higher level) can immediately discern which berries are affected. Each
trans-muted berry provides nourishment as if it were a normal meal for a
Medium creature. The berry also cures 1 point of damage when eaten, subject
to a maximum of 8 points of such curing in any 24-hour period."
}, {
id: 233,
name: "Good Hope",