Herr JavaScript: Kleine Korrektur ...

Beitrag lesen

Hab doch noch was falsch gemacht gehabt.

<script language="JavaScript">

  
var messages = new Array();  
messages["geheilt"] = "Der Charakter wurde voll geheilt!"  
messages["geheilt2"] = "Der Charakter wurde geheilt!"  
function Character (hp_aktuell, hp_max, exp_aktuell, exp_max, angriffskraft, verteidigungskraft, avatar) {  
   this.kampffaehig = true;  
   this.level = 1;  
   this.hp_aktuell = hp_aktuell;  
   this.hp_max = hp_max;  
   this.ep_aktuell = exp_aktuell;  
   this.ep_max = (25.1562/0.6234)*this.level;  
   this.atk = angriffskraft;  
   this.def = verteidigungskraft;  
   this.avatar = avatar;  
   this.heal = function (wert) {if (wert != "full") {this.hp_aktuell += (this.hp_max - this.hp_aktuell < wert) ? hp_max - hp_aktuell : wert;} else {hp_aktuell = hp_max;}};  
   this.treffer = function (wert) {if(this.hp_aktuell-wert <= 0) {this.kampffaehig=false;} else {if(Math.round(Math.random()*100)>25) {this.hp_aktuell-=wert;}this.kampffaehig=true;}}  
   this.lvup = function () {if(this.ep_aktuell >= this.ep_max){this.atk = (this.atk/100)*108;this.def = (this.def/100)*108;this.hp_max = (this.hp_max/100)*170;this.hp_aktuell = this.hp_max;this.level++;this.ep_aktuell -= this.ep_max;this.ep_max = (25.1562/0.6234)*this.level;}}  
   this.specup = function (wert,ziel) {switch (ziel) {case "1":this.atk+=wert;break;case "2":this.def+=wert;break;case "3":this.hp_max+=wert;this.hp_aktuell=this.hp_max;break;default:this.atk = this.atk;break;}}  
 // Hier stand ein } zu viel ...  
}  
  
var chars = new Array();  
chars[0] = new Character(10,100,0,100,6,6,"IMGS/gesichter_5_012.gif");  
chars[1] = new Character(60,100,0,100,5,6,"IMGS/gesichter_5_009.gif");  
chars[2] = new Character(30,100,0,100,3,7,"IMGS/gesichter_5_008.gif");  
document.write("<table style='table-layout:fixed;' width=300px border=0 cellspacing=0 cellpadding=0>")  
for(var i=0;i<chars.length;i++)  
{  
 document.write("<tr>")  
 document.write("<td rowspan=3 width=48><img src=\""+chars[i].avatar + "\"></td>")  
 var x = (chars[i].hp_aktuell/chars[i].hp_max)*100  
 var col = (x < 30)?"#E80000":(x >= 30 && x < 70)?"#DAB10E":"#4AC820";  
 document.write('<td colspan=2 height=1 style="overflow:hidden;height:5px;"><div style="display:block;border:1px outset;background:#c0c0c0;width:100%;overflow:hidden;height:7px;"> <div style="border:1px inset;background:'+col+';width:'+x+'%;overflow:hidden;height:100%;"></div></div></td></tr><tr>')  
 x = (chars[i].ep_aktuell/chars[i].ep_max)*100  
 document.write('<td colspan=2 height=1 style="overflow:hidden;height:5px;"><div style="display:block;border:1px outset;background:#c0c0c0;width:100%;overflow:hidden;height:7px;"> <div style="border:1px inset;background:#7CC6FC;width:'+x+'%;overflow:hidden;height:100%;"></div></div></td></tr><tr>')  
 document.write("<td>"+Math.floor(chars[i].hp_aktuell) + "/" + Math.floor(chars[i].hp_max)+"</td>")  
 document.write("<td>"+Math.floor(chars[i].ep_aktuell) + "/" + Math.ceil(chars[i].ep_max)+"</td>")  
 document.write("</tr>")  
}  
document.write("</table>")  

</script>