From f2038f44d3591b7862b0ee81e621db7b220f5779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Sat, 18 Oct 2014 13:58:46 +0200 Subject: [PATCH] Only Elements with battle info show the UI --- TODO | 2 +- assets/style.css | 2 +- index.html | 3 ++- src/jsds.js | 55 +++++++++++++++++++++++++++++++++++++--------- src/jsds_crafty.js | 12 +++++++++- 5 files changed, 60 insertions(+), 14 deletions(-) diff --git a/TODO b/TODO index 24ecf60..85171a5 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,7 @@ ToDo for JSDSH: - Implement FrontEnd (Add Player, etc) ? - Background and Wall Editing/Importing - - Basic Modifiers + * Basic Modifiers - on-the-fly-adding of characters - traps etc. - JSON instead of JavaScript importing diff --git a/assets/style.css b/assets/style.css index 72d3070..5c49eca 100644 --- a/assets/style.css +++ b/assets/style.css @@ -22,7 +22,7 @@ h1 { position:relative; } -#ui { +#uibon, #uiatt { right: 30px; } diff --git a/index.html b/index.html index 3881e76..bccd338 100644 --- a/index.html +++ b/index.html @@ -10,7 +10,8 @@

JSDSH - Javascript Dungeonslayers Helper

-
+
+
diff --git a/src/jsds.js b/src/jsds.js index 2a85bdb..251a8db 100644 --- a/src/jsds.js +++ b/src/jsds.js @@ -232,11 +232,6 @@ // Write out the UI for attack-selection, including binding. sel_att: function() { var outstr="

"; - outstr += "Boni?
"; - outstr += "Waffenbonus Nahkampf:
"; - outstr += "Waffenbonus Fernkampf:
"; - outstr += "Panzerungsbonus:
"; - outstr += "Zauberbonus:
"; outstr += "Angriffstyp?
"; outstr += "
"; - + outstr += "Abwehrbar? "; outstr += "
"; + outstr += "Waffenbonus Fernkampf:
"; + outstr += "Panzerungsbonus:
"; + outstr += "Zauberbonus:
"; + $('#uibon').html(outstr); + $('#wbn').attr("value", cur_sel.extern.weapon_near+"") + .bind("change", + function() {cur_sel.extern.weapon_near = this.value*1; + cur_sel.recalc_battle(); + cur_sel.printoutput(); + } + ); + $('#wbf').attr("value", cur_sel.extern.weapon_far) + .bind("change", + function() {cur_sel.extern.weapon_far = this.value*1; + cur_sel.recalc_battle(); + cur_sel.printoutput(); + } + ); + $('#pb').attr("value",cur_sel.extern.armor) + .bind("change", + function() {cur_sel.extern.armor = this.value*1; + cur_sel.recalc_battle(); + cur_sel.printoutput(); + } + ); + $('#zb').attr("value",cur_sel.extern.chant) + .bind("change", + function() {cur_sel.extern.chant = this.value*1; + cur_sel.recalc_battle(); + cur_sel.printoutput(); + } + ); + }, printoutput: function() { outstr = "

"; outstr += this.info.cname + " (gespielt von "+this.info.pname +")
"; outstr += "Greift derzeit durch " + this.att + " mit einer Stärke von " - + this.battle[this.att] + " an. (WB: "+ this.extern.defense +"
"; + + this.battle[this.att] + " an.
"; outstr += "Verteidigungsstärke: " + this.battle.defense + "
"; outstr += "Kraftpunkte: " + this.life; outstr += "

"; diff --git a/src/jsds_crafty.js b/src/jsds_crafty.js index 36edf97..c94888d 100644 --- a/src/jsds_crafty.js +++ b/src/jsds_crafty.js @@ -88,13 +88,23 @@ */ this.bind('MouseDown', function(e) { if(e.mouseButton === Crafty.mouseButtons.LEFT) { - this.calc_center(); + if( cur_sel != player[this.id] ) { + this.calc_center(); + }; this.old_pos["x"]=this.x; this.old_pos["y"]=this.y; Crafty("Creature").each( function() { this.disableControl(); }); cur_sel=player[this.id]; + if (! cur_sel.enem) { + $('#uibon').show(); + cur_sel.sel_bon(); + } + else { + console.log("Hide UIBON"); + $('#uibon').hide(); + } cur_sel.printoutput(); cur_sel.sel_att(); this.enableControl();