Permalink
Browse files

- Update playerProcess php & javascript methods to handle power charges.

- Update power table on player page to display current charges (for charged powers)
- Tweak statblock CSS to make regular labels wider, and 'shortStatBlock' labels shorter, hopefully this should resolve some display issues on chrome (how does this even render differnetly than safari, gah!)
- (Partially) fix a bug with refreshing powers.
  • Loading branch information...
1 parent 52b9dcd commit 9df980d948499d45ada3bae9fd867c9baf30f342 @duaiwe committed Dec 21, 2009
Showing with 181 additions and 150 deletions.
  1. +9 −4 htdocs/ajax/playerProcess.php
  2. +5 −1 htdocs/css/default.css
  3. +10 −6 htdocs/css/statBlock.css
  4. +34 −27 htdocs/javascript/playerProcess.js
  5. +21 −15 htdocs/player.html
  6. +102 −97 includes/models/Power.php
@@ -25,7 +25,7 @@
case 'spendSurge':
$success = $char->useSurge((int)@$data['surge_bonus']);
$result['surges_cur'] = $char->surges_cur;
- $result['health_cur'] = $char->health_cur;
+ $result['health_cur'] = $char->health_cur;
break;
case 'damage':
$success = $char->takeDamage((int)@$data['health']);
@@ -80,8 +80,12 @@
else {
$success = $p->togglePower();
}
- $result['power'] = array('pID' => $p->id, 'status' => $p->getUsageStatus());
- if( $mi_use != $char->magic_item_uses )
+ $result['power'] = array(
+ 'pID' => $p->id,
+ 'status' => $p->getUsageStatus(),
+ 'uses' => $p->uses
+ );
+ if( $mi_use != $char->magic_item_uses )
$result['magic_item_uses'] = $char->magic_item_uses;
if( $surges != $char->surges_cur )
$result['surges_cur'] = $char->surges_cur;
@@ -115,4 +119,5 @@
$msg->clear();
print_r(json_encode($result));
-?>
+?>
+
View
@@ -285,6 +285,9 @@ li.noCheck div.listLabel {
#PowerTable .powerRow {
height : 20px;
}
+#PowerTable .powerUsesMax {
+ display : none;
+}
#PowerTable tr.Disabled {
}
@@ -336,4 +339,5 @@ li.noCheck div.listLabel {
}
#FeatDiv {
margin-left : 450px;
-}
+}
+
View
@@ -45,10 +45,15 @@ div.statRow label.statLabel {
font-weight : bold;
text-align : right;
margin : 0 10px 0 0;
- width : 70px;
display : block;
float : left;
}
+.statColumn label.statLabel {
+ width : 85px;
+}
+.shortStatColumn label.statLabel {
+ width : 55px;
+}
div.statRow input[type="text"] {
font-family : Courier, monospaced;
@@ -133,18 +138,18 @@ a.ajaxLink:active {
}
#SpellbookDailyTable, #SpellbookUtilityTable {
- margin : 0 5px;
+ margin : 0 5px;
padding : 0;
border-spacing : 0 1px;
- width : 240px;
+ width : 240px;
}
#SpellbookDailyTable {
- float: left;
+ float: left;
}
#SpellbookUtilityTable {
}
-#SpellbookDailyTable td, #SpellbookUtilityTable td,
+#SpellbookDailyTable td, #SpellbookUtilityTable td,
#SpellbookDailyTable th, #SpellbookUtilityTable th {
padding : 1px 4px;
}
@@ -159,4 +164,3 @@ a.ajaxLink:active {
cursor : pointer;
}
-
@@ -24,14 +24,14 @@ function parseProcessResult(data, textStatus) {
setActivePower(v.pID, v.level);
break;
case 'refreshPowers':
- animatePower('#PowerTable tr.Encounter');
+ animatePower('#PowerTable tr.Encounter-bg');
if( v ) {
animatePower('#PowerTable tr.Daily');
animatePower('#PowerTable tr.Healing-Surge');
}
break;
case 'power':
- animatePower('#r'+v.pID, v.status);
+ animatePower('#r'+v.pID, v.status, v.uses);
break;
case 'player_notes':
notes_tmp = v;
@@ -46,7 +46,7 @@ function parseProcessResult(data, textStatus) {
break;
case 'magic_item_uses':
animatePower('#PowerTable tr.Daily-bg.Item:not(.Used)', (!v?'Disabled':''));
- updateText('#'+k, v);
+ updateText('#'+k, v);
break;
case 'errors':
printMessage(v);
@@ -71,11 +71,11 @@ function updateCurrentHealth(health_cur) {
var health_max = $('#health_max').text();
var bloodied_val = Math.floor(health_max/2);
-
+
$('#health_cur').removeClass();
$('#health_status').removeClass();
$('#health_status').text('');
-
+
// Are we Dead?
if( health_cur < -1*bloodied_val ) {
$('#health_cur').addClass(STATUS_DEAD);
@@ -91,7 +91,7 @@ function updateCurrentHealth(health_cur) {
$('#health_cur').addClass(STATUS_BLOODIED);
$('#health_status').addClass(STATUS_BLOODIED);
$('#health_status').text(STATUS_BLOODIED);
- }
+ }
}
function updateTempHealth(health_tmp) {
if( health_tmp > 0 ) {
@@ -102,7 +102,7 @@ function updateTempHealth(health_tmp) {
}
}
-function animatePower(row, status) {
+function animatePower(row, status, charges) {
var icon = POWER_ICON;
var opacity = 1;
switch(status) {
@@ -114,9 +114,15 @@ function animatePower(row, status) {
icon = POWER_ICON_DISABLED;
break;
}
-
+
$(row+' img.power_icon').fadeOut('fast', function() {
$(this).attr('src', icon);
+ if( charges ) {
+ $(row).find('span.powerUses').text('('+charges+')');
+ }
+ else {
+ $(row).find('span.powerUses').text('('+$(row).find('span.powerUsesMax').text()+')');
+ }
$(row).removeClass('Used Disabled');
$(row).addClass(status);
$(row).fadeTo('fast', opacity, function() {
@@ -133,17 +139,17 @@ function setActivePower(pID, level) {
//var levelSelect = '.l'+level;
//var powerRow = '#b'+pID;
-
+
// Add click bindings for all the spells of this level
$(spellBookLevelRows+' td.powerName').click(function(){ playerProcessRequest('setActivePower', {
p_id: $(this).parent().attr('id').substring(1) }); });
// Remove the binding for our active power;
$(spellBookPowerRow+' td.powerName').unbind('click');
-
+
$(spellBookLevelRows).fadeTo('fast', .5, function() {
$(powerTableLevelRows).hide().addClass('InActive');
$(powerTableRow).removeClass('InActive').show();
-
+
$(spellBookLevelRows).addClass('InActive');
$(spellBookPowerRow).removeClass('InActive').fadeTo('fast', 1);
});
@@ -160,26 +166,26 @@ $(window).load(function() {
var img_disabld = $('<img />').attr('src', POWER_ICON_DISABLED);
var img_used = $('<img />').attr('src', POWER_ICON_USED);
var img_usable = $('<img />').attr('src', POWER_ICON);
-
+
// Fill the notes_tmp variable
notes_tmp = $('#player_notes').val();
// Handle dirty notification for player notes
$('#player_notes').keyup(function(k) { notesDirtyCheck() });
-
+
// Healing Surges
$('#surgePlus').click(function(){ playerProcessRequest('addSurge'); });
$('#surgeMinus').click(function(){ playerProcessRequest('subtractSurge'); });
$('#spendSurge').click(function(){ playerProcessRequest('spendSurge', {
surge_bonus: $('#surge_bonus').val() }); });
// Enable Enter/Return activating the click fcn.
$('#surge_bonus').keyup(function(e){ if(e.keyCode==13) $('#spendSurge').click(); });
-
+
// Taking Damage
$('#takeDamage').click(function(){ playerProcessRequest('damage', {
health: $('#damage_value').val() }); });
// Enable Enter/Return activating the click fcn.
$('#damage_value').keyup(function(e){ if(e.keyCode==13) $('#takeDamage').click(); });
-
+
// Temporary Health
$('#tempHealth').click(function(){ playerProcessRequest('tempHealth', {
health: $('#health').val() }); });
@@ -193,23 +199,23 @@ $(window).load(function() {
// Magic Item Uses
$('#miPlus').click(function(){ playerProcessRequest('addMagicItemUse') });
$('#miMinus').click(function(){ playerProcessRequest('subtractMagicItemUse') });
-
+
// Rest Actions
$('#shortRest').click(function(){ playerProcessRequest('shortRest') });
- $('#extendedRest').click(function(){ playerProcessRequest('extendedRest') });
-
+ $('#extendedRest').click(function(){ playerProcessRequest('extendedRest') });
+
// Player notes
$('#updateNotes').click(function() { playerProcessRequest('updateNotes', {
notes: $('#player_notes').val() }); });
-
+
// Power Usage
$('#PowerTable img.power_icon').click(function() {
playerProcessRequest('togglePower', {p_id: this.id.substring(1)}) });
-
+
// Spellbook Power Activation
$('.spellBookRow.InActive td.powerName').click(function(){ playerProcessRequest('setActivePower', {
p_id: $(this).parent().attr('id').substring(1) }); });
-
+
// Tab Show/Hide
$('#powerTabLink').click(function() {
$('#PlayerPowers').show();
@@ -232,7 +238,7 @@ $(window).load(function() {
$('#PlayerTabs li.selectedTab').removeClass('selectedTab');
$('#sbookTab').addClass('selectedTab');
});
-
+
// Power Tooltips
$('img.power_view').each(function(i) {
var id = this.id.substring(1);
@@ -245,8 +251,8 @@ $(window).load(function() {
p_id: id
}
},
- position: {
- adjust: {
+ position: {
+ adjust: {
screen: true
},
corner: {
@@ -269,14 +275,14 @@ $(window).load(function() {
width: 308,
padding: 0,
background: '#FFFFFF',
- border: {
+ border: {
width: 1,
radius: 3
}
}
}); // End qTip()
}); //end each()
-
+
$('img.feat_view').each(function(i) {
$(this).qtip({
show: {
@@ -292,4 +298,5 @@ $(window).load(function() {
}
});
});
-}); //end ready()
+}); //end ready()
+
Oops, something went wrong.

0 comments on commit 9df980d

Please sign in to comment.