1
0
mirror of https://github.com/exane/not-gwent-online synced 2024-10-31 10:36:53 +00:00
not-gwent-online/server/Battle.js

50 lines
849 B
JavaScript
Raw Normal View History

2015-06-10 16:12:52 +00:00
var Battleside = require("./Battleside");
2015-06-13 19:36:02 +00:00
var io = global.io;
2015-06-10 16:12:52 +00:00
var Battle = (function(){
2015-06-13 19:36:02 +00:00
var Battle = function(id){
2015-06-10 16:12:52 +00:00
if(!(this instanceof Battle)){
2015-06-13 19:36:02 +00:00
return (new Battle(id));
2015-06-10 16:12:52 +00:00
}
/**
* constructor here
*/
2015-06-13 19:36:02 +00:00
this._id = id;
2015-06-10 16:12:52 +00:00
};
var r = Battle.prototype;
/**
* methods && properties here
* r.property = null;
* r.getProperty = function() {...}
*/
2015-06-13 19:36:02 +00:00
r.p1 = null;
r.p2 = null;
r.turn = 0;
2015-06-10 16:12:52 +00:00
2015-06-13 19:36:02 +00:00
r._id = null;
2015-06-10 16:12:52 +00:00
2015-06-13 19:36:02 +00:00
r.init = function(){
this.p1 = Battleside("Player 1", 0, this);
this.p2 = Battleside("Player 2", 1, this);
this.p1.foe = this.p2;
this.p2.foe = this.p1;
this.start();
2015-06-10 16:12:52 +00:00
}
2015-06-13 19:36:02 +00:00
r.start = function() {
this.p1.draw(10);
this.p2.draw(10);
2015-06-10 16:12:52 +00:00
}
2015-06-13 19:36:02 +00:00
r.send = function(event, data) {
io.to(this._id).emit(event, data);
}
2015-06-10 16:12:52 +00:00
return Battle;
})();
module.exports = Battle;