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.att = "melee";
this.defendible = true;
},
attack: function(enem) {
@ -136,23 +137,27 @@
output.append('Angriff Fehlgeschlagen!<br>');
}
else {
output.append(this.info.cname + " trifft mit " + attack_val + "<br>");
var defense_val = dice(this.battle.defense);
console.log(attack_val + ", " + defense_val);
attack_val -= defense_val;
attack_val = Math.max(attack_val, 0);
if ( ! defense_val ) {
output.append(enem.info.cname + " kann sich nicht wehren!<br>");
output.append(this.info.cname + " trifft mit " + attack_val + "<br>");
if ( this.defendible ) {
var defense_val = dice(this.battle.defense);
console.log(attack_val + ", " + defense_val);
attack_val -= defense_val;
attack_val = Math.max(attack_val, 0);
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 {
output.append(enem.info.cname + " wehrt sich mit " + defense_val+".<br>");
}
if ( attack_val === 0 ) {
output.append("Vollständig Abgewehrt!<br>");
}
else {
output.append("Schaden: "+attack_val+"<br>");
output.append("Nicht abwehrbar!<br>");
};
output.append("Schaden: "+attack_val+"<br>");
enem.life -= attack_val;
if( enem.life <= 0 ) {
if ( enem.enem ){
@ -191,14 +196,20 @@
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>";
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);
$('#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";
}
});
var Player = Creature.extend({
init: function(info,attributes,properties,drawinfo,battle){ // x,y,w,h,col) {
/* info: pname, cname,class, level, experience, race, size