{
function Creature(info,attributes,properties,drawinfo,battle){
/* info: pname, cname,class, level, experience, race, size
* attributes: body, agility, spirit
* properties: strength, hardness, movement, skill, mind, aura
* drawinfo: x,y,w,h,col
*/
this.info = {"pname": info["pname"]+"", "experience": info["experience"]*1, "race":info["race"]+"",
"size":info["size"]*1};
console.log("Info ready");
this.attributes = {"body": attributes["body"]*1, "agility": attributes["agility"]*1,
"spirit": attributes["spirit"]*1};
console.log("Attr ready");
this.properties = {"strength": properties["strength"]*1 , "hardness": info["hardness"]*1,
"movement": info["movement"]*1, "skill": properties["skill"]*1,
"mind": properties["mind"]*1, "aura": properties["aura"]*1};
console.log("Prop ready");
this.graphelement = Crafty.e("Creature").creature(this.info["pname"],drawinfo["x"],drawinfo["y"],
drawinfo["w"],drawinfo["h"],drawinfo["col"]);
console.log("Graph ready");
this.battle = {};
if(battle) {
this.battle={"life": battle["life"], "defense": battle["defense"],"ini":battle["ini"],
"walk": battle["walk"], "melee": battle["melee"], "shoot": battle["shoot"],
"chant": battle["chant"], "shoot_chant": battle["shoot_chant"]};
console.log("Battle ready");
}
else {
this.battle["life"] = this.attributes.body + this.properties.strength + 10;
this.battle["defense"] = this.attributes.body + this.properties.hardness;
this.battle["ini"] = this.attributes.agility + this.properties.movement;
this.battle["walk"] = (this.attributes.agility / 2) +1;
this.battle["melee"] = this.attributes.body + this.properties.strength;
this.battle["shoot"] = this.attributes.agility + this.properties.mind;
this.battle["chant"] = this.attributes.spirit + this.properties.aura;
this.battle["shoot_chant"] = this.attributes.spirit + this.properties.skill;
console.log("Battle ready");
};
this.life = this.battle["life"]*1;
};
/* Creature.prototype.attack(enem) {
return enem.*/
function Player(info,attributes,properties,drawinfo,battle){ // x,y,w,h,col) {
/* info: pname, cname,class, level, experience, race, size
* attributes: body, agility, spirit
* properties: strength, hardness, movement, skill, mind, aura
* drawinfo: x,y,w,h,col
*/
Creature.apply(this, arguments);
this.info["cname"]= info["cname"]+"";
this.info["class"]= info["class"]+"";
this.info["level"]= info["level"]*1;
// Set default battle-propoerties.
this.extern = {"armor":0,"chant":0,"weapon":0};
this.battle["defense"] += this.extern.armor;
this.battle.melee += this.extern.weapon;
this.battle.shoot += this.extern.weapon;
this.battle.chant = this.battle.chant + this.extern.chant - this.extern.armor;
this.battle.shoot_chant = this.battle.chant + this.extern.chant - this.extern.armor;
};
Player.prototype.printoutput = function() {
$('#output').empty();
$('#output').html(this.info.cname+"
"+this.info.pname);
};
function Beast(info,attributes,properties,drawinfo,battle){ // x,y,w,h,col) {
/* info: pname, experience, race, size
* attributes: body, agility, spirit
* properties: strength, hardness, movement, skill, mind, aura
* drawinfo: x,y,w,h,col
* battle: life, defense,ini,walk,melee,shoot,chant,shoot_chant
*/
Creature.apply(this,arguments);
};
Beast.prototype.printoutput = function() {
$('#output').empty();
$('#output').html(this.info.race+"
"+this.info.pname);
};
}