Reading characters is now complete.
This commit is contained in:
parent
ee680009ef
commit
ce629299bb
3 changed files with 53 additions and 21 deletions
|
@ -11,20 +11,21 @@
|
|||
var cur_sel;
|
||||
|
||||
var player={};
|
||||
player["Gesina"]=(new Player({"pname":"Gesina", "cname":"Aknya", "class":"Zauberin", "level":0, "experience":0,
|
||||
"race":"Mensch", "size":2},
|
||||
player["Gesina"]=new Player({"pname":"Gesina", "cname":"Aknya", "class":"Zauberin", "level":0,
|
||||
"experience":0, "race":"Mensch", "size":2},
|
||||
{"body":6, "agility":6, "spirit":8},
|
||||
{"strength":0,"hardness":2,"movement":0,"skill":3,"mind":3,"aura":3},
|
||||
{"x":40,"y":40,"w":40,"h":40,"col":"blue"}));
|
||||
{"x":40,"y":40,"w":40,"h":40,"col":"blue"});
|
||||
|
||||
// player.push(Crafty.e("Creature").player(40,40,40,40,'red'));
|
||||
|
||||
|
||||
player["HobGob1"]=(new Beast({"pname":"HobGob1", "experience":71, "race":"Hobgoblin", "size":2},
|
||||
{"body":11, "agility":6, "spirit":3},
|
||||
{"strength":2,"hardness":3,"movement":0,"skill":3,"mind":2,"aura":0},
|
||||
{"x":90,"y":90,"w":30,"h":30,"col":"red"}));
|
||||
|
||||
player["Gob1"]=new Beast({"pname":"Gob1", "experience":71, "race":"Goblin", "size":2},
|
||||
{"body":11, "agility":6, "spirit":3},
|
||||
{"strength":2,"hardness":3,"movement":0,"skill":3,"mind":2,"aura":0},
|
||||
{"x":90,"y":90,"w":30,"h":30,"col":"red"},
|
||||
{"life": 8, "defense": 7, "ini":9, "walk":4.5, "melee":7, "shoot":0, "chant":0,
|
||||
"shoot_chant":0});
|
||||
|
||||
/*.push(Crafty.e("Creature").creature("Hobgob1",100,100,30,30,'red'));*/
|
||||
|
||||
|
|
53
src/jsds.js
53
src/jsds.js
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
function Creature(info,attributes,properties,drawinfo){
|
||||
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
|
||||
|
@ -7,18 +7,43 @@
|
|||
*/
|
||||
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};
|
||||
|
||||
this.graphelement = Crafty.e("Creature").creature(this.info["pname"],drawinfo["x"],drawinfo["y"],drawinfo["w"],
|
||||
drawinfo["h"],drawinfo["col"]);
|
||||
|
||||
};
|
||||
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");
|
||||
|
||||
function Player(info,attributes,properties,drawinfo){ // x,y,w,h,col) {
|
||||
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
|
||||
|
@ -29,7 +54,14 @@
|
|||
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() {
|
||||
|
@ -37,11 +69,12 @@
|
|||
$('#output').html(this.info.cname+"<br>"+this.info.pname);
|
||||
};
|
||||
|
||||
function Beast(info,attributes,properties,drawinfo){ // x,y,w,h,col) {
|
||||
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);
|
||||
|
@ -51,6 +84,4 @@
|
|||
$('#output').empty();
|
||||
$('#output').html(this.info.race+"<br>"+this.info.pname);
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -78,8 +78,8 @@
|
|||
this.enableControl();
|
||||
};
|
||||
/* if(e.mouseButton === Crafty.mouseButtons.RIGHT) {
|
||||
cur_sel.attack(player[this.id]);*/
|
||||
};
|
||||
cur_sel.attack(player[this.id]);
|
||||
};*/
|
||||
});
|
||||
|
||||
return this;
|
||||
|
|
Loading…
Reference in a new issue