Attacks may now be undefendible

This commit is contained in:
Oliver Rümpelein 2014-09-25 16:19:12 +02:00
parent e2d4a73d81
commit b57936ab3b

View file

@ -125,6 +125,7 @@
}; };
this.life = this.battle["life"]*1; this.life = this.battle["life"]*1;
this.att = "melee"; this.att = "melee";
this.defendible = true;
}, },
attack: function(enem) { attack: function(enem) {
@ -136,23 +137,27 @@
output.append('Angriff Fehlgeschlagen!<br>'); output.append('Angriff Fehlgeschlagen!<br>');
} }
else { else {
output.append(this.info.cname + " trifft mit " + attack_val + "<br>"); output.append(this.info.cname + " trifft mit " + attack_val + "<br>");
var defense_val = dice(this.battle.defense); if ( this.defendible ) {
console.log(attack_val + ", " + defense_val); var defense_val = dice(this.battle.defense);
attack_val -= defense_val; console.log(attack_val + ", " + defense_val);
attack_val = Math.max(attack_val, 0); attack_val -= defense_val;
if ( ! defense_val ) { attack_val = Math.max(attack_val, 0);
output.append(enem.info.cname + " kann sich nicht wehren!<br>"); if ( ! defense_val ) {
output.append(enem.info.cname + " kann sich nicht wehren!<br>");
}
else {
output.append(enem.info.cname + " wehrt sich mit " + defense_val+".<br>");
}
if ( attack_val === 0 ) {
output.append("Vollständig Abgewehrt!<br>");
return;
}
} }
else { else {
output.append(enem.info.cname + " wehrt sich mit " + defense_val+".<br>"); output.append("Nicht abwehrbar!<br>");
}
if ( attack_val === 0 ) {
output.append("Vollständig Abgewehrt!<br>");
}
else {
output.append("Schaden: "+attack_val+"<br>");
}; };
output.append("Schaden: "+attack_val+"<br>");
enem.life -= attack_val; enem.life -= attack_val;
if( enem.life <= 0 ) { if( enem.life <= 0 ) {
if ( enem.enem ){ if ( enem.enem ){
@ -191,12 +196,18 @@
outstr += "<option value='shoot' id='shoot'>Schuss (" + this.battle["shoot"] + ")</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"] outstr += "<option value='shoot_chant' id='shoot_chant'>Zielzauber (" +this.battle["shoot_chant"]
+")</option>"; +")</option>";
outstr += "</select>"; outstr += "</select><br>";
outstr += "Abwehrbar? ";
outstr += "<select id='defendible'>";
outstr += "<option value=true selected=true>Ja</option>";
outstr += "<option value=false>Nein</option>";
$('#ui').html(outstr); $('#ui').html(outstr);
$('#att').bind("change", function() {cur_sel.att=this.value;}); $('#att').bind("change", function() {cur_sel.att=this.value;});
$('#defendible').bind("change", function() { cur_sel.defendible = (this.value === "true" ? true : false);});
$("#"+this.att).get(0).selected="true"; $("#"+this.att).get(0).selected="true";
} }
}); });
var Player = Creature.extend({ var Player = Creature.extend({