Attack is selectable
This commit is contained in:
parent
e090551214
commit
3a37375cf2
3 changed files with 27 additions and 7 deletions
|
@ -8,9 +8,9 @@
|
|||
<h1>JSDSH - Javascript Dungeonslayers Helper</h1>
|
||||
|
||||
<div id="game"></div>
|
||||
<div id="ui"></div>
|
||||
<button id="load">Load</button>
|
||||
<div id="output"></div>
|
||||
<div id="ui">
|
||||
</div>
|
||||
<script type="text/javascript" src="lib/crafty.js"></script>
|
||||
<script type="text/javascript" src="lib/jquery-1.11.1.min.js"></script>
|
||||
|
|
29
src/jsds.js
29
src/jsds.js
|
@ -1,5 +1,8 @@
|
|||
{
|
||||
// OOP-Setup
|
||||
// OOP-Setup, thanks to Florian Rappl for this piece of Code
|
||||
// Source:
|
||||
// http://www.florian-rappl.de/Articles/Page/116/super-mario5-article
|
||||
|
||||
var reflection = {};
|
||||
|
||||
(function(){
|
||||
|
@ -72,13 +75,10 @@
|
|||
* properties: strength, hardness, movement, skill, mind, aura
|
||||
* drawinfo: x,y,w,h,col
|
||||
*/
|
||||
console.log("Creature called!");
|
||||
this.info = {"pname": info["pname"]+"", "experience": info["experience"]*1, "race":info["race"]+"",
|
||||
"size":info["size"]*1};
|
||||
console.log("Creature Ready!");
|
||||
this.attributes = {"body": attributes["body"]*1, "agility": attributes["agility"]*1,
|
||||
"spirit": attributes["spirit"]*1};
|
||||
console.log("Problem?");
|
||||
this.properties = {"strength": properties["strength"]*1 , "hardness": properties["hardness"]*1,
|
||||
"movement": properties["movement"]*1, "skill": properties["skill"]*1,
|
||||
"mind": properties["mind"]*1, "aura": properties["aura"]*1};
|
||||
|
@ -102,12 +102,29 @@
|
|||
this.battle["shoot_chant"] = this.attributes.spirit + this.properties.skill;
|
||||
};
|
||||
this.life = this.battle["life"]*1;
|
||||
this.att = "melee";
|
||||
console.log("Attack: "+this.att);
|
||||
},
|
||||
attack: function(enem) {
|
||||
//console.log("attack");
|
||||
console.log(this.info.cname+" greift "+enem.info.cname+" an!");
|
||||
console.log("Ergebnis: " + this.battle.melee + ( this.battle.melee > enem.battle.defense ? " > " : " < ") + enem.battle.defense);
|
||||
console.log("Ergebnis: " + this.battle[this.att]
|
||||
+ ( this.battle[this.att] > enem.battle.defense ? " > " : " < ") + enem.battle.defense);
|
||||
},
|
||||
sel_att: function() {
|
||||
var outstr="";
|
||||
outstr += "Angriffstyp?<br>";
|
||||
outstr += "<select id='att'>";
|
||||
outstr += "<option value='melee' id='melee'>Melee (" + this.battle["melee"] + ")</option>";
|
||||
outstr += "<option value='shoot' id='shoot'>Schuss (" + this.battle["shoot"] + ")</option>";
|
||||
outstr += "<option value='shoot_chant' id='shoot_chant'>Zielzauber (" +this.battle["shoot_chant"]
|
||||
+")</option>";
|
||||
outstr += "</select>";
|
||||
$('#ui').html(outstr);
|
||||
$('#att').bind("change", function() {cur_sel.att=this.value;});
|
||||
$("#"+this.att).get(0).selected="true";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var Player = Creature.extend({
|
||||
|
@ -133,6 +150,7 @@
|
|||
},
|
||||
printoutput: function() {
|
||||
$('#output').empty();
|
||||
$('#ui').empty();
|
||||
$('#output').html(this.info.cname+"<br>"+this.info.pname);
|
||||
}
|
||||
});
|
||||
|
@ -151,6 +169,7 @@
|
|||
},
|
||||
printoutput: function() {
|
||||
$('#output').empty();
|
||||
$('#ui').empty();
|
||||
$('#output').html(this.info.race+"<br>"+this.info.pname);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -81,6 +81,7 @@
|
|||
if ( !cur_sel ) { return; };
|
||||
if ( cur_sel == player[this.id] )
|
||||
{
|
||||
cur_sel.sel_att();
|
||||
}
|
||||
else {
|
||||
cur_sel.attack(player[this.id]);
|
||||
|
|
Loading…
Reference in a new issue