mirror of
https://github.com/exane/not-gwent-online
synced 2025-12-15 02:29:14 +00:00
stuff
This commit is contained in:
@@ -3,14 +3,16 @@ var Battleside = require("./Battleside");
|
||||
var io = global.io;
|
||||
|
||||
var Battle = (function(){
|
||||
var Battle = function(id){
|
||||
var Battle = function(id, p1, p2){
|
||||
if(!(this instanceof Battle)){
|
||||
return (new Battle(id));
|
||||
return (new Battle(id, p1, p2));
|
||||
}
|
||||
/**
|
||||
* constructor here
|
||||
*/
|
||||
this._id = id;
|
||||
this._user1 = p1;
|
||||
this._user2 = p2;
|
||||
};
|
||||
var r = Battle.prototype;
|
||||
/**
|
||||
@@ -21,23 +23,30 @@ var Battle = (function(){
|
||||
|
||||
r.p1 = null;
|
||||
r.p2 = null;
|
||||
r._user1 = null;
|
||||
r._user2 = null;
|
||||
r.turn = 0;
|
||||
|
||||
r._id = null;
|
||||
|
||||
|
||||
r.init = function(){
|
||||
this.p1 = Battleside("Player 1", 0, this);
|
||||
this.p2 = Battleside("Player 2", 1, this);
|
||||
this.p1 = Battleside(this._user1.getName(), 0, this);
|
||||
this.p2 = Battleside(this._user2.getName(), 1, this);
|
||||
this.p1.foe = this.p2;
|
||||
this.p2.foe = this.p1;
|
||||
|
||||
this.p1.send("update:info", {info: this.p1.getInfo()});
|
||||
this.p2.send("update:info", {info: this.p2.getInfo()});
|
||||
|
||||
this.start();
|
||||
}
|
||||
|
||||
r.start = function() {
|
||||
this.p1.draw(10);
|
||||
this.p2.draw(10);
|
||||
|
||||
//this.p2.wait();
|
||||
}
|
||||
|
||||
r.send = function(event, data) {
|
||||
|
||||
@@ -33,6 +33,8 @@ var Battleside = (function(){
|
||||
r._range = null;
|
||||
r._siege = null;
|
||||
r._field = null;
|
||||
r._lives = 2;
|
||||
r._score = 0;
|
||||
|
||||
r.foe = null;
|
||||
r.hand = null;
|
||||
@@ -51,6 +53,19 @@ var Battleside = (function(){
|
||||
this.send("update:hand", {cards: JSON.stringify(this.hand.getCards())});
|
||||
}
|
||||
|
||||
r.getInfo = function() {
|
||||
return {
|
||||
name: this.getName(),
|
||||
lives: this._lives,
|
||||
score: this._score,
|
||||
hand: this.hand.length()
|
||||
}
|
||||
}
|
||||
|
||||
r.getName = function() {
|
||||
return this._name;
|
||||
}
|
||||
|
||||
r.send = function(event, msg) {
|
||||
msg = msg || {};
|
||||
msg._roomSide = this.n;
|
||||
|
||||
@@ -56,9 +56,7 @@ var Room = (function(){
|
||||
r.initBattle = function(){
|
||||
var self = this;
|
||||
var side = 0;
|
||||
this._battle = Battle(this._id);/*
|
||||
this.setReady(this._room[0], false);
|
||||
this.setReady(this._room[1], false);*/
|
||||
this._battle = Battle(this._id, this._room[0], this._room[1]);
|
||||
this._room[0].send("init:battle", {side: "p1"});
|
||||
this._room[1].send("init:battle", {side: "p2"});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user