mirror of
https://github.com/exane/not-gwent-online
synced 2025-08-10 04:57:29 +00:00
more convenient build process
This commit is contained in:
README.mdgulpfile.jspackage.json
server
site
client
app.blade.phpgulpfile.jspackage.json
app
assets
sass
public
server
.env.exampleartisan
app
Console
Events
Exceptions
Http
Jobs
Listeners
Providers
User.phpbootstrap
composer.jsonconfig
app.phpauth.phpbroadcasting.phpcache.phpcompile.phpdatabase.phpfilesystems.phpmail.phpqueue.phpservices.phpsession.phpview.php
database
phpspec.ymlphpunit.xmlserver.phpstorage
tests
@@ -3,7 +3,7 @@ var Card = require("./Card");
|
||||
var Deck = require("./Deck");
|
||||
var shortid = require("shortid");
|
||||
var Promise = require("jquery-deferred");
|
||||
var CardManager = require("./CardManager")
|
||||
var CardManager = require("./CardManager");
|
||||
|
||||
|
||||
var Battle = (function(){
|
||||
|
@@ -8,9 +8,9 @@ var Promise = require("jquery-deferred");
|
||||
|
||||
|
||||
var Battleside;
|
||||
Battleside = (function(){
|
||||
var Battleside = function(user, n, battle){
|
||||
if(!(this instanceof Battleside)){
|
||||
Battleside = (function() {
|
||||
var Battleside = function(user, n, battle) {
|
||||
if(!(this instanceof Battleside)) {
|
||||
return (new Battleside(user, n, battle));
|
||||
}
|
||||
/**
|
||||
@@ -42,9 +42,7 @@ Battleside = (function(){
|
||||
this.off = this.battle.off.bind(this.battle);
|
||||
|
||||
|
||||
|
||||
|
||||
this.receive("activate:leader", function(){
|
||||
this.receive("activate:leader", function() {
|
||||
if(self._isWaiting) return;
|
||||
if(self.isPassing()) return;
|
||||
|
||||
@@ -60,13 +58,13 @@ Battleside = (function(){
|
||||
leaderCard.setDisabled(true);
|
||||
self.battle.sendNotification(self.getName() + " activated " + leaderCard.getName() + "! (leadercard)");
|
||||
self.update();
|
||||
if(ability.waitResponse){
|
||||
if(ability.waitResponse) {
|
||||
return;
|
||||
}
|
||||
//self.runEvent("NextTurn", null, [self.foe]);
|
||||
self.endTurn();
|
||||
})
|
||||
this.receive("play:cardFromHand", function(data){
|
||||
this.receive("play:cardFromHand", function(data) {
|
||||
if(self._isWaiting) return;
|
||||
if(self.isPassing()) return;
|
||||
var cardID = data.id;
|
||||
@@ -74,7 +72,7 @@ Battleside = (function(){
|
||||
|
||||
self.playCard(card);
|
||||
})
|
||||
this.receive("decoy:replaceWith", function(data){
|
||||
this.receive("decoy:replaceWith", function(data) {
|
||||
if(self._isWaiting) return;
|
||||
var card = self.findCardOnFieldByID(data.cardID);
|
||||
/*if(card === -1) throw new Error("decoy:replace | unknown card");*/
|
||||
@@ -86,10 +84,10 @@ Battleside = (function(){
|
||||
}
|
||||
self.runEvent("Decoy:replaceWith", self, [card]);
|
||||
})
|
||||
this.receive("cancel:decoy", function(){
|
||||
this.receive("cancel:decoy", function() {
|
||||
self.off("Decoy:replaceWith");
|
||||
})
|
||||
this.receive("set:passing", function(){
|
||||
this.receive("set:passing", function() {
|
||||
self.setPassing(true);
|
||||
self.update();
|
||||
|
||||
@@ -97,8 +95,8 @@ Battleside = (function(){
|
||||
//self.runEvent("NextTurn", null, [self.foe]);
|
||||
self.endTurn();
|
||||
})
|
||||
this.receive("medic:chooseCardFromDiscard", function(data){
|
||||
if(!data){
|
||||
this.receive("medic:chooseCardFromDiscard", function(data) {
|
||||
if(!data) {
|
||||
//self.runEvent("NextTurn", null, [self.foe]);
|
||||
|
||||
self.endTurn();
|
||||
@@ -117,8 +115,8 @@ Battleside = (function(){
|
||||
|
||||
self.playCard(card);
|
||||
})
|
||||
this.receive("emreis_leader4:chooseCardFromDiscard", function(data){
|
||||
if(!data){
|
||||
this.receive("emreis_leader4:chooseCardFromDiscard", function(data) {
|
||||
if(!data) {
|
||||
self.endTurn();
|
||||
self.sendNotificationTo(self.foe, self.getName() + " takes no card from your discard pile (or there wasn't any card to choose)");
|
||||
//self.runEvent("NextTurn", null, [self.foe]);
|
||||
@@ -142,7 +140,7 @@ Battleside = (function(){
|
||||
self.endTurn();
|
||||
// self.runEvent("NextTurn", null, [self.foe]);
|
||||
})
|
||||
this.receive("agile:field", function(data){
|
||||
this.receive("agile:field", function(data) {
|
||||
var fieldType = data.field;
|
||||
if(!(fieldType in [0, 1])) throw new Error("set field agile: false fieldtype " + fieldType);
|
||||
self.runEvent("agile:setField", null, [fieldType]);
|
||||
@@ -150,10 +148,10 @@ Battleside = (function(){
|
||||
self.endTurn();
|
||||
//self.runEvent("NextTurn", null, [self.foe]);
|
||||
})
|
||||
this.receive("cancel:agile", function(){
|
||||
this.receive("cancel:agile", function() {
|
||||
self.off("agile:setField");
|
||||
})
|
||||
this.receive("horn:field", function(data){
|
||||
this.receive("horn:field", function(data) {
|
||||
var fieldType = data.field;
|
||||
if(!(fieldType in [0, 1, 2])) throw new Error("set field horn: false fieldtype " + fieldType);
|
||||
self.runEvent("horn:setField", null, [fieldType]);
|
||||
@@ -161,7 +159,7 @@ Battleside = (function(){
|
||||
self.endTurn();
|
||||
//self.runEvent("NextTurn", null, [self.foe]);
|
||||
})
|
||||
this.receive("cancel:horn", function(){
|
||||
this.receive("cancel:horn", function() {
|
||||
self.off("horn:setField");
|
||||
})
|
||||
|
||||
@@ -194,23 +192,23 @@ Battleside = (function(){
|
||||
r.battle = null;
|
||||
r.deck = null;
|
||||
|
||||
r.createCard = function(key){
|
||||
r.createCard = function(key) {
|
||||
return this.cm.create(key, this.n);
|
||||
}
|
||||
|
||||
r.isPassing = function(){
|
||||
r.isPassing = function() {
|
||||
return this._passing;
|
||||
}
|
||||
|
||||
r.isWaiting = function(){
|
||||
r.isWaiting = function() {
|
||||
return this._isWaiting;
|
||||
}
|
||||
|
||||
r.setUpWeatherFieldWith = function(p2){
|
||||
r.setUpWeatherFieldWith = function(p2) {
|
||||
this.field[Card.TYPE.WEATHER] = p2.field[Card.TYPE.WEATHER] = Field(this);
|
||||
}
|
||||
|
||||
r.findCardOnFieldByID = function(id){
|
||||
r.findCardOnFieldByID = function(id) {
|
||||
for(var key in this.field) {
|
||||
var field = this.field[key];
|
||||
var card = field.getCard(id);
|
||||
@@ -224,7 +222,7 @@ Battleside = (function(){
|
||||
return -1;
|
||||
}
|
||||
|
||||
r.getRandomCardOnField = function(){
|
||||
r.getRandomCardOnField = function() {
|
||||
var allCards = this.getFieldCards();
|
||||
var rnd = (Math.random() * allCards.length) | 0;
|
||||
|
||||
@@ -232,7 +230,7 @@ Battleside = (function(){
|
||||
return allCards[rnd];
|
||||
}
|
||||
|
||||
r.getCardFromDiscard = function(id){
|
||||
r.getCardFromDiscard = function(id) {
|
||||
for(var i = 0; i < this._discard.length; i++) {
|
||||
var c = this._discard[i];
|
||||
if(c.getID() === id) return c;
|
||||
@@ -240,7 +238,7 @@ Battleside = (function(){
|
||||
return -1;
|
||||
}
|
||||
|
||||
r.getFieldCards = function(){
|
||||
r.getFieldCards = function() {
|
||||
var close, range, siege;
|
||||
|
||||
close = this.field[Card.TYPE.CLOSE_COMBAT].get();
|
||||
@@ -250,22 +248,22 @@ Battleside = (function(){
|
||||
return close.concat(range.concat(siege));
|
||||
}
|
||||
|
||||
r.setPassing = function(b){
|
||||
r.setPassing = function(b) {
|
||||
this._passing = b;
|
||||
this.send("set:passing", {passing: this._passing}, true);
|
||||
}
|
||||
|
||||
r.wait = function(){
|
||||
r.wait = function() {
|
||||
this._isWaiting = true;
|
||||
this.send("set:waiting", {waiting: this._isWaiting}, true);
|
||||
}
|
||||
|
||||
r.turn = function(){
|
||||
r.turn = function() {
|
||||
this._isWaiting = false;
|
||||
this.send("set:waiting", {waiting: this._isWaiting}, true);
|
||||
}
|
||||
|
||||
r.setLeadercard = function(){
|
||||
r.setLeadercard = function() {
|
||||
var leaderCard = this.deck.find("type", Card.TYPE.LEADER);
|
||||
this.deck.removeFromDeck(leaderCard[0]);
|
||||
/*
|
||||
@@ -273,22 +271,22 @@ Battleside = (function(){
|
||||
this.field[Card.TYPE.LEADER].add(leaderCard[0]);
|
||||
}
|
||||
|
||||
r.getLeader = function(){
|
||||
r.getLeader = function() {
|
||||
return this.field[Card.TYPE.LEADER].get()[0];
|
||||
}
|
||||
|
||||
r.getID = function(){
|
||||
r.getID = function() {
|
||||
return this.n;
|
||||
}
|
||||
|
||||
r.draw = function(times){
|
||||
r.draw = function(times) {
|
||||
while(times--) {
|
||||
var card = this.deck.draw();
|
||||
this.hand.add(card);
|
||||
}
|
||||
}
|
||||
|
||||
r.calcScore = function(){
|
||||
r.calcScore = function() {
|
||||
var score = 0;
|
||||
for(var key in this.field) {
|
||||
score += +this.field[key].getScore();
|
||||
@@ -296,7 +294,7 @@ Battleside = (function(){
|
||||
return this._score = score;
|
||||
}
|
||||
|
||||
r.getInfo = function(){
|
||||
r.getInfo = function() {
|
||||
return {
|
||||
name: this.getName(),
|
||||
lives: this._rubies,
|
||||
@@ -308,43 +306,43 @@ Battleside = (function(){
|
||||
}
|
||||
}
|
||||
|
||||
r.getRubies = function(){
|
||||
r.getRubies = function() {
|
||||
return this._rubies;
|
||||
}
|
||||
|
||||
r.getScore = function(){
|
||||
r.getScore = function() {
|
||||
return +this.calcScore();
|
||||
}
|
||||
|
||||
r.removeRuby = function(){
|
||||
r.removeRuby = function() {
|
||||
this._rubies--;
|
||||
}
|
||||
|
||||
r.getName = function(){
|
||||
r.getName = function() {
|
||||
return this._name;
|
||||
}
|
||||
|
||||
r.send = function(event, msg, isPrivate){
|
||||
r.send = function(event, msg, isPrivate) {
|
||||
msg = msg || {};
|
||||
isPrivate = typeof isPrivate === "undefined" ? false : isPrivate;
|
||||
msg._roomSide = this.n;
|
||||
|
||||
if(isPrivate){
|
||||
if(isPrivate) {
|
||||
return this.socket.emit(event, msg);
|
||||
}
|
||||
this.battle.send(event, msg);
|
||||
}
|
||||
|
||||
r.receive = function(event, cb){
|
||||
r.receive = function(event, cb) {
|
||||
this.socket.on(event, cb);
|
||||
}
|
||||
|
||||
r.update = function(self){
|
||||
r.update = function(self) {
|
||||
self = self || false;
|
||||
this.runEvent("Update", null, [self]);
|
||||
}
|
||||
|
||||
r.onTurnStart = function(){
|
||||
r.onTurnStart = function() {
|
||||
this.foe.wait();
|
||||
this.turn();
|
||||
|
||||
@@ -353,7 +351,7 @@ Battleside = (function(){
|
||||
|
||||
};
|
||||
|
||||
r.playCard = function(card){
|
||||
r.playCard = function(card) {
|
||||
if(card === null || card === -1) return;
|
||||
if(this.isWaiting()) return;
|
||||
if(this.isPassing()) return;
|
||||
@@ -369,27 +367,27 @@ Battleside = (function(){
|
||||
this.endTurn();
|
||||
}
|
||||
|
||||
r.endTurn = function(){
|
||||
r.endTurn = function() {
|
||||
this.update();
|
||||
|
||||
this.runEvent("NextTurn", null, [this.foe]);
|
||||
}
|
||||
|
||||
r.placeCard = function(card, obj){
|
||||
r.placeCard = function(card, obj) {
|
||||
obj = _.extend({}, obj);
|
||||
|
||||
if(typeof card === "string"){
|
||||
if(typeof card === "string") {
|
||||
//card = Card(card);
|
||||
card = this.createCard(card);
|
||||
}
|
||||
|
||||
this.checkAbilities(card, obj);
|
||||
if(obj._cancelPlacement && !obj.forceField){
|
||||
if(obj._cancelPlacement && !obj.forceField) {
|
||||
|
||||
//this.battle.sendNotification(this.getName() + " played " + card.getName() + "!");
|
||||
return 0;
|
||||
}
|
||||
if(obj._nextTurn && !obj.forceField){
|
||||
if(obj._nextTurn && !obj.forceField) {
|
||||
this.update();
|
||||
//this.runEvent("NextTurn", null, [this.foe]);
|
||||
this.endTurn();
|
||||
@@ -398,14 +396,14 @@ Battleside = (function(){
|
||||
|
||||
|
||||
var field = obj.forceField || null;
|
||||
if(typeof obj.isHorn !== "undefined"){
|
||||
if(!field){
|
||||
if(typeof obj.isHorn !== "undefined") {
|
||||
if(!field) {
|
||||
field = obj.targetSide.field[obj.isHorn];
|
||||
}
|
||||
field.add(card, true);
|
||||
}
|
||||
else {
|
||||
if(!field){
|
||||
if(!field) {
|
||||
field = obj.targetSide.field[card.getType()];
|
||||
}
|
||||
|
||||
@@ -418,7 +416,7 @@ Battleside = (function(){
|
||||
this.checkAbilityOnAfterPlace(card, obj);
|
||||
|
||||
|
||||
if(obj._waitResponse){
|
||||
if(obj._waitResponse) {
|
||||
this.hand.remove(card);
|
||||
this.update();
|
||||
return 0;
|
||||
@@ -429,17 +427,17 @@ Battleside = (function(){
|
||||
return 1;
|
||||
}
|
||||
|
||||
r.setHorn = function(card, field){
|
||||
r.setHorn = function(card, field) {
|
||||
var self = this;
|
||||
field = typeof field === "undefined" ? null : field;
|
||||
|
||||
if(typeof card === "string"){
|
||||
if(typeof card === "string") {
|
||||
//card = Card(card);
|
||||
//card = this.cm.create(card);
|
||||
card = this.createCard(card);
|
||||
}
|
||||
|
||||
if(typeof field === "number"){
|
||||
if(typeof field === "number") {
|
||||
card.changeType(field);
|
||||
this.placeCard(card, {
|
||||
isHorn: field,
|
||||
@@ -450,7 +448,7 @@ Battleside = (function(){
|
||||
}
|
||||
|
||||
this.send("played:horn", {cardID: card.getID()}, true)
|
||||
this.on("horn:setField", function(type){
|
||||
this.on("horn:setField", function(type) {
|
||||
self.off("horn:setField");
|
||||
card.changeType(type);
|
||||
self.placeCard(card, {
|
||||
@@ -463,17 +461,17 @@ Battleside = (function(){
|
||||
})
|
||||
}
|
||||
|
||||
r.commanderHornAbility = function(card){
|
||||
r.commanderHornAbility = function(card) {
|
||||
var field = this.field[card.getType()];
|
||||
var id = "commanders_horn";
|
||||
|
||||
if(typeof field === "undefined"){
|
||||
if(typeof field === "undefined") {
|
||||
//console.log("field unknown | %s", card.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
if(!field.isOnField(card)){
|
||||
field.get().forEach(function(_card){
|
||||
if(!field.isOnField(card)) {
|
||||
field.get().forEach(function(_card) {
|
||||
if(_card.getID() === id) return;
|
||||
if(_card.getID() === card.getID()) return;
|
||||
if(_card.getType() !== card.getType()) return;
|
||||
@@ -484,7 +482,7 @@ Battleside = (function(){
|
||||
return;
|
||||
}
|
||||
|
||||
field.get().forEach(function(_card){
|
||||
field.get().forEach(function(_card) {
|
||||
if(_card.getID() === id) return;
|
||||
if(_card.getID() === card.getID()) return;
|
||||
if(_card.getType() != card.getType()) return;
|
||||
@@ -494,9 +492,10 @@ Battleside = (function(){
|
||||
})
|
||||
}
|
||||
|
||||
r.setTightBond = function(card){
|
||||
var field = this.field[card.getType()];/*
|
||||
var pos = field.getPosition(card);*/
|
||||
r.setTightBond = function(card) {
|
||||
var field = this.field[card.getType()];
|
||||
/*
|
||||
var pos = field.getPosition(card);*/
|
||||
var cards = field.get();
|
||||
|
||||
card.resetTightBond();
|
||||
@@ -504,7 +503,7 @@ Battleside = (function(){
|
||||
cards.forEach(function(c) {
|
||||
if(c.getID() === card.getID()) return;
|
||||
if(c.getName() !== card.getName()) return;
|
||||
card.setBoost(card.getID() + "|tight_bond|"+c.getID(), "tight_bond");
|
||||
card.setBoost(card.getID() + "|tight_bond|" + c.getID(), "tight_bond");
|
||||
});
|
||||
|
||||
/*if(pos < 0) return;
|
||||
@@ -523,13 +522,13 @@ Battleside = (function(){
|
||||
}*/
|
||||
}
|
||||
|
||||
r.checkAbilities = function(card, obj, __flag){
|
||||
r.checkAbilities = function(card, obj, __flag) {
|
||||
var self = this;
|
||||
obj.targetSide = this;
|
||||
if(obj.disabled) return;
|
||||
var ability = Array.isArray(__flag) ? __flag : card.getAbility();
|
||||
|
||||
if(Array.isArray(ability) && ability.length){
|
||||
if(Array.isArray(ability) && ability.length) {
|
||||
var ret = ability.slice();
|
||||
ret.splice(0, 1);
|
||||
this.checkAbilities(card, obj, ret);
|
||||
@@ -540,56 +539,56 @@ Battleside = (function(){
|
||||
//this.update();
|
||||
}*/
|
||||
|
||||
if(ability && !Array.isArray(ability)){
|
||||
if(ability && !Array.isArray(ability)) {
|
||||
|
||||
if(ability.onBeforePlace){
|
||||
if(ability.onBeforePlace) {
|
||||
ability.onBeforePlace.apply(this, [card]);
|
||||
}
|
||||
if(ability.isCommandersHornCard && typeof obj.isHorn === "undefined"){
|
||||
if(ability.isCommandersHornCard && typeof obj.isHorn === "undefined") {
|
||||
this.setHorn(card);
|
||||
}
|
||||
if(ability.commandersHorn){
|
||||
if(ability.commandersHorn) {
|
||||
ability.onEachCardPlace = this.commanderHornAbility;
|
||||
ability.onWeatherChange = this.commanderHornAbility;
|
||||
}
|
||||
if(ability.cancelPlacement && !obj.forcePlace){
|
||||
if(ability.cancelPlacement && !obj.forcePlace) {
|
||||
obj._cancelPlacement = true;
|
||||
}
|
||||
if(ability.nextTurn){
|
||||
if(ability.nextTurn) {
|
||||
obj._nextTurn = ability.nextTurn;
|
||||
}
|
||||
if(ability.tightBond){
|
||||
if(ability.tightBond) {
|
||||
//this.setTightBond(card);
|
||||
ability.onAfterPlace = this.setTightBond;
|
||||
ability.onEachCardPlace = this.setTightBond;
|
||||
//ability.onWeatherChange = this.setTightBond;
|
||||
}
|
||||
if(ability.scorch){
|
||||
if(ability.scorch) {
|
||||
this.scorch(card);
|
||||
}
|
||||
if(ability.scorchMelee){
|
||||
if(ability.scorchMelee) {
|
||||
this.scorchMelee(card);
|
||||
}
|
||||
if(ability.removeImmediately){
|
||||
if(ability.removeImmediately) {
|
||||
this.hand.remove(card);
|
||||
this.addToDiscard(card);
|
||||
}
|
||||
if(ability.waitResponse && !obj.forcePlace){
|
||||
if(ability.waitResponse && !obj.forcePlace) {
|
||||
obj._waitResponse = true;
|
||||
}
|
||||
if(ability.changeSide){
|
||||
if(ability.changeSide) {
|
||||
obj.targetSide = this.foe;
|
||||
}
|
||||
if(typeof ability.weather !== "undefined"){
|
||||
if(typeof ability.weather !== "undefined") {
|
||||
ability.onEachTurn = this.setWeather.bind(this, ability.weather);
|
||||
ability.onEachCardPlace = this.setWeather.bind(this, ability.weather);
|
||||
}
|
||||
if(ability.replaceWith && !obj.forcePlace){
|
||||
if(ability.replaceWith && !obj.forcePlace) {
|
||||
obj._cancelPlacement = true;
|
||||
this.on("Decoy:replaceWith", function(replaceCard){
|
||||
this.on("Decoy:replaceWith", function(replaceCard) {
|
||||
if(replaceCard.getType() == Card.TYPE.LEADER ||
|
||||
replaceCard.getType() == Card.TYPE.WEATHER ||
|
||||
replaceCard.getType() == Card.TYPE.SPECIAL){
|
||||
replaceCard.getType() == Card.TYPE.WEATHER ||
|
||||
replaceCard.getType() == Card.TYPE.SPECIAL) {
|
||||
return;
|
||||
}
|
||||
if(replaceCard.getName() === card.getName()) return;
|
||||
@@ -610,15 +609,15 @@ Battleside = (function(){
|
||||
self.battle.sendNotification(self.getName() + " played Decoy!");
|
||||
})
|
||||
}
|
||||
if(ability.onEachTurn){
|
||||
if(ability.onEachTurn) {
|
||||
var uid = this.on("EachTurn", ability.onEachTurn, this, [card])
|
||||
card._uidEvents["EachTurn"] = uid;
|
||||
}
|
||||
if(ability.onEachCardPlace){
|
||||
if(ability.onEachCardPlace) {
|
||||
var uid = this.on("EachCardPlace", ability.onEachCardPlace, this, [card]);
|
||||
card._uidEvents["EachCardPlace"] = uid;
|
||||
}
|
||||
if(ability.onWeatherChange){
|
||||
if(ability.onWeatherChange) {
|
||||
var uid = this.on("WeatherChange", ability.onWeatherChange, this, [card]);
|
||||
card._uidEvents["WeatherChange"] = uid;
|
||||
}
|
||||
@@ -628,29 +627,29 @@ Battleside = (function(){
|
||||
}
|
||||
}
|
||||
|
||||
r.checkAbilityOnAfterPlace = function(card, obj, __flag){
|
||||
r.checkAbilityOnAfterPlace = function(card, obj, __flag) {
|
||||
//var ability = card.getAbility();
|
||||
var ability = Array.isArray(__flag) ? __flag : card.getAbility();
|
||||
|
||||
if(Array.isArray(ability) && ability.length){
|
||||
if(Array.isArray(ability) && ability.length) {
|
||||
var ret = ability.slice();
|
||||
ret.splice(0, 1);
|
||||
this.checkAbilityOnAfterPlace(card, obj, ret);
|
||||
ability = ability[0];
|
||||
}
|
||||
|
||||
if(ability && !Array.isArray(ability)){
|
||||
if(ability.name && ability.name === obj.suppress){
|
||||
if(ability && !Array.isArray(ability)) {
|
||||
if(ability.name && ability.name === obj.suppress) {
|
||||
//this.update();
|
||||
return;
|
||||
}
|
||||
if(ability.onAfterPlace){
|
||||
if(ability.onAfterPlace) {
|
||||
ability.onAfterPlace.call(this, card)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
r.setWeather = function(weather, opt){
|
||||
r.setWeather = function(weather, opt) {
|
||||
var targetRow = weather;
|
||||
var field;
|
||||
if(typeof targetRow === "undefined") {
|
||||
@@ -662,8 +661,8 @@ Battleside = (function(){
|
||||
var onRoundEnd = opt.onTurnEnd || false;
|
||||
|
||||
|
||||
if(targetRow === Card.TYPE.WEATHER){
|
||||
if(!onRoundEnd){
|
||||
if(targetRow === Card.TYPE.WEATHER) {
|
||||
if(!onRoundEnd) {
|
||||
this.battle.sendNotification(this.getName() + " played Clear Weather!");
|
||||
}
|
||||
field = this.field[targetRow];
|
||||
@@ -675,7 +674,7 @@ Battleside = (function(){
|
||||
_field2 = this.foe.field[i].get();
|
||||
_field = _field1.concat(_field2);
|
||||
|
||||
_field.forEach(function(_card){
|
||||
_field.forEach(function(_card) {
|
||||
if(_card.hasAbility("hero")) return;
|
||||
_card.setForcedPower(-1);
|
||||
});
|
||||
@@ -685,7 +684,7 @@ Battleside = (function(){
|
||||
}
|
||||
var forcedPower = 1;
|
||||
|
||||
if(typeof targetRow === "undefined"){
|
||||
if(typeof targetRow === "undefined") {
|
||||
console.trace(this);
|
||||
}
|
||||
var field1 = this.field[targetRow].get();
|
||||
@@ -693,20 +692,20 @@ Battleside = (function(){
|
||||
|
||||
field = field1.concat(field2);
|
||||
|
||||
field.forEach(function(_card){
|
||||
field.forEach(function(_card) {
|
||||
if(_card.hasAbility("hero")) return;
|
||||
_card.setForcedPower(forcedPower);
|
||||
});
|
||||
this.runEvent("WeatherChange");
|
||||
}
|
||||
|
||||
r.scorchMelee = function(card){
|
||||
r.scorchMelee = function(card) {
|
||||
var side = this.foe;
|
||||
var field = side.field[Card.TYPE.CLOSE_COMBAT];
|
||||
|
||||
this.battle.sendNotification(this.getName() + " played " + card.getName());
|
||||
|
||||
if(field.getScore() < 10){
|
||||
if(field.getScore() < 10) {
|
||||
this.battle.sendNotification("Scorch: Score is under 10! Nothing happens.");
|
||||
return;
|
||||
}
|
||||
@@ -726,7 +725,7 @@ Battleside = (function(){
|
||||
side.addToDiscard(removeCards);
|
||||
}
|
||||
|
||||
r.scorch = function(card){/*
|
||||
r.scorch = function(card) {/*
|
||||
var side = this.foe;
|
||||
var field = side.field[Card.TYPE.CLOSE_COMBAT];
|
||||
var cards = field.getHighestCards(true);
|
||||
@@ -740,19 +739,19 @@ Battleside = (function(){
|
||||
|
||||
this.battle.sendNotification(this.getName() + " played " + card.getName());
|
||||
|
||||
cards.forEach(function(card){
|
||||
cards.forEach(function(card) {
|
||||
if(noHeroes && card.hasAbility("hero")) return;
|
||||
highest = card.getPower() > highest ? card.getPower() : highest;
|
||||
})
|
||||
|
||||
cards.forEach(function(card){
|
||||
cards.forEach(function(card) {
|
||||
if(noHeroes && card.hasAbility("hero")) return;
|
||||
if(card.getPower() === highest) res.push(card);
|
||||
});
|
||||
|
||||
res.forEach(function(card){
|
||||
res.forEach(function(card) {
|
||||
var side = self;
|
||||
if(self.foe.field[card.getType()].isOnField(card)){
|
||||
if(self.foe.field[card.getType()].isOnField(card)) {
|
||||
side = self.foe;
|
||||
}
|
||||
var removed = side.field[card.getType()].removeCard(card);
|
||||
@@ -768,11 +767,11 @@ Battleside = (function(){
|
||||
this.battle.sendNotification(txt);
|
||||
}
|
||||
|
||||
r.clearMainFields = function(){
|
||||
r.clearMainFields = function() {
|
||||
var rndCard = null;
|
||||
if(this.deck.getFaction() === Deck.FACTION.MONSTERS){
|
||||
if(this.deck.getFaction() === Deck.FACTION.MONSTERS) {
|
||||
rndCard = this.getRandomCardOnField();
|
||||
if(rndCard){
|
||||
if(rndCard) {
|
||||
rndCard.__lock = true;
|
||||
this.sendNotification(this.getName() + ": Monsters faction ability triggered! " + rndCard.getName());
|
||||
}
|
||||
@@ -789,13 +788,13 @@ Battleside = (function(){
|
||||
this.addToDiscard(cards);
|
||||
}
|
||||
|
||||
r.addToDiscard = function(cards){
|
||||
r.addToDiscard = function(cards) {
|
||||
var self = this;
|
||||
if(!Array.isArray(cards)){
|
||||
if(!Array.isArray(cards)) {
|
||||
cards = [cards];
|
||||
}
|
||||
cards.forEach(function(_card){
|
||||
if(_card.__lock){
|
||||
cards.forEach(function(_card) {
|
||||
if(_card.__lock) {
|
||||
delete _card.__lock;
|
||||
return;
|
||||
}
|
||||
@@ -803,10 +802,10 @@ Battleside = (function(){
|
||||
});
|
||||
}
|
||||
|
||||
r.removeFromDiscard = function(card){
|
||||
r.removeFromDiscard = function(card) {
|
||||
for(var i = 0; i < this._discard.length; i++) {
|
||||
var c = this._discard[i];
|
||||
if(c.getID() === card.getID()){
|
||||
if(c.getID() === card.getID()) {
|
||||
|
||||
this._discard.splice(i, 1);
|
||||
return
|
||||
@@ -814,14 +813,14 @@ Battleside = (function(){
|
||||
}
|
||||
}
|
||||
|
||||
r.getDiscard = function(json){
|
||||
if(json){
|
||||
r.getDiscard = function(json) {
|
||||
if(json) {
|
||||
return JSON.stringify(this._discard);
|
||||
}
|
||||
return this._discard;
|
||||
}
|
||||
|
||||
r.resetNewRound = function(){
|
||||
r.resetNewRound = function() {
|
||||
this.clearMainFields();
|
||||
this.setWeather(5, {
|
||||
onTurnEnd: true
|
||||
@@ -829,7 +828,7 @@ Battleside = (function(){
|
||||
this.setPassing(false);
|
||||
}
|
||||
|
||||
r.filter = function(arrCards, opt){
|
||||
r.filter = function(arrCards, opt) {
|
||||
var arr = arrCards.slice();
|
||||
|
||||
for(var key in opt) {
|
||||
@@ -837,33 +836,33 @@ Battleside = (function(){
|
||||
var prop = key, val = opt[key];
|
||||
|
||||
|
||||
arrCards.forEach(function(card){
|
||||
arrCards.forEach(function(card) {
|
||||
var property = card.getProperty(prop);
|
||||
if(_.isArray(property)){
|
||||
if(_.isArray(property)) {
|
||||
var _f = false;
|
||||
for(var i = 0; i < property.length; i++) {
|
||||
if(property[i] === val){
|
||||
if(property[i] === val) {
|
||||
_f = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!_f){
|
||||
if(!_f) {
|
||||
res.push(card);
|
||||
}
|
||||
}
|
||||
else if(_.isArray(val)){
|
||||
else if(_.isArray(val)) {
|
||||
var _f = false;
|
||||
for(var i = 0; i < val.length; i++) {
|
||||
if(property === val[i]){
|
||||
if(property === val[i]) {
|
||||
_f = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!_f){
|
||||
if(!_f) {
|
||||
res.push(card);
|
||||
}
|
||||
}
|
||||
else if(card.getProperty(prop) !== val){
|
||||
else if(card.getProperty(prop) !== val) {
|
||||
res.push(card);
|
||||
}
|
||||
})
|
||||
@@ -873,7 +872,7 @@ Battleside = (function(){
|
||||
return arr;
|
||||
}
|
||||
|
||||
r.reDraw = function(n){
|
||||
r.reDraw = function(n) {
|
||||
//var hand = this.hand.getCards();
|
||||
var self = this;
|
||||
var left = n;
|
||||
@@ -881,7 +880,7 @@ Battleside = (function(){
|
||||
|
||||
this.send("redraw:cards", null, true);
|
||||
|
||||
this.receive("redraw:reDrawCard", function(data){
|
||||
this.receive("redraw:reDrawCard", function(data) {
|
||||
var id = data.cardID;
|
||||
if(!left) return;
|
||||
left--;
|
||||
@@ -891,7 +890,7 @@ Battleside = (function(){
|
||||
self.deck.shuffle();
|
||||
self.draw(1);
|
||||
|
||||
if(!left){
|
||||
if(!left) {
|
||||
self.send("redraw:close", null, true);
|
||||
|
||||
self.wait();
|
||||
@@ -903,7 +902,7 @@ Battleside = (function(){
|
||||
self.battle.updateSelf(self);
|
||||
})
|
||||
|
||||
this.receive("redraw:close_client", function(){
|
||||
this.receive("redraw:close_client", function() {
|
||||
|
||||
self.wait();
|
||||
deferred.resolve("done");
|
||||
@@ -914,10 +913,10 @@ Battleside = (function(){
|
||||
|
||||
}
|
||||
|
||||
r.sendNotificationTo = function(side, msg){
|
||||
r.sendNotificationTo = function(side, msg) {
|
||||
this.battle.sendNotificationTo(side, msg);
|
||||
}
|
||||
r.sendNotification = function(msg){
|
||||
r.sendNotification = function(msg) {
|
||||
this.battle.sendNotification(msg);
|
||||
}
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
var _ = require("underscore");
|
||||
|
||||
var Field = (function(){
|
||||
var Field = function(side, hasHornField){
|
||||
if(!(this instanceof Field)){
|
||||
var Field = (function() {
|
||||
var Field = function(side, hasHornField) {
|
||||
if(!(this instanceof Field)) {
|
||||
return (new Field(side, hasHornField));
|
||||
}
|
||||
/**
|
||||
@@ -26,12 +26,12 @@ var Field = (function(){
|
||||
r._hornCard = null;
|
||||
r.side = null;
|
||||
|
||||
r.add = function(card, isHorn){
|
||||
r.add = function(card, isHorn) {
|
||||
/*if(card.hasAbility("commanders_horn")) {
|
||||
this.setHorn(card);
|
||||
return;
|
||||
}*/
|
||||
if(isHorn && this._hasHornField){
|
||||
if(isHorn && this._hasHornField) {
|
||||
this.setHorn(card);
|
||||
return;
|
||||
}
|
||||
@@ -39,16 +39,16 @@ var Field = (function(){
|
||||
this.updateScore();
|
||||
}
|
||||
|
||||
r.get = function(){
|
||||
r.get = function() {
|
||||
return this._cards;
|
||||
}
|
||||
|
||||
r.getScore = function(){
|
||||
r.getScore = function() {
|
||||
this.updateScore();
|
||||
return this._score;
|
||||
}
|
||||
|
||||
r.updateScore = function(){
|
||||
r.updateScore = function() {
|
||||
this._score = 0;
|
||||
for(var i = 0; i < this._cards.length; i++) {
|
||||
var card = this._cards[i];
|
||||
@@ -56,33 +56,33 @@ var Field = (function(){
|
||||
}
|
||||
}
|
||||
|
||||
r.getPosition = function(card){
|
||||
r.getPosition = function(card) {
|
||||
for(var i = 0; i < this._cards.length; i++) {
|
||||
if(this._cards[i].getID() === card.getID()) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
r.isOnField = function(card){
|
||||
if(this._hasHornField && this.getHorn() && card.getID() === this.getHorn().getID()){
|
||||
r.isOnField = function(card) {
|
||||
if(this._hasHornField && this.getHorn() && card.getID() === this.getHorn().getID()) {
|
||||
return true;
|
||||
}
|
||||
return this.getPosition(card) >= 0;
|
||||
}
|
||||
|
||||
r.replaceWith = function(oldCard, newCard){
|
||||
r.replaceWith = function(oldCard, newCard) {
|
||||
var index = this.getPosition(oldCard);
|
||||
this._cards[index] = newCard;
|
||||
oldCard.reset();
|
||||
for(var event in oldCard._uidEvents) {
|
||||
if(this.side && this.side.off){
|
||||
if(this.side && this.side.off) {
|
||||
this.side.off(event, oldCard.getUidEvents(event));
|
||||
}
|
||||
}
|
||||
return oldCard;
|
||||
}
|
||||
|
||||
r.getCard = function(id){
|
||||
r.getCard = function(id) {
|
||||
for(var i = 0; i < this._cards.length; i++) {
|
||||
var card = this._cards[i];
|
||||
if(card.getID() == id) return card;
|
||||
@@ -90,7 +90,7 @@ var Field = (function(){
|
||||
return -1;
|
||||
}
|
||||
|
||||
r.removeAll = function(){
|
||||
r.removeAll = function() {
|
||||
var tmp = this._cards.slice();
|
||||
var self = this;
|
||||
/*for(var i = 0; i < tmp.length; i++) {
|
||||
@@ -104,13 +104,13 @@ var Field = (function(){
|
||||
}
|
||||
this._cards[i] = null;
|
||||
}*/
|
||||
tmp.forEach(function(card, i){
|
||||
tmp.forEach(function(card, i) {
|
||||
card.reset();
|
||||
if(card.__lock){
|
||||
if(card.__lock) {
|
||||
return;
|
||||
}
|
||||
for(var event in card._uidEvents) {
|
||||
if(this.side && this.side.off){
|
||||
if(this.side && this.side.off) {
|
||||
this.side.off(event, card.getUidEvents(event));
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ var Field = (function(){
|
||||
|
||||
this._cards = _.without(this._cards, null);
|
||||
|
||||
if(this.getHorn()){
|
||||
if(this.getHorn()) {
|
||||
var card = this.getHorn();
|
||||
card.reset();
|
||||
this.setHorn(null);
|
||||
@@ -131,17 +131,17 @@ var Field = (function(){
|
||||
return tmp;
|
||||
}
|
||||
|
||||
r.removeCard = function(cards){
|
||||
r.removeCard = function(cards) {
|
||||
var res = [];
|
||||
var _cards = this.get();
|
||||
if(!Array.isArray(cards)){
|
||||
if(!Array.isArray(cards)) {
|
||||
cards = [cards];
|
||||
}
|
||||
var self = this;
|
||||
cards.forEach(function(card){
|
||||
cards.forEach(function(card) {
|
||||
card.reset();
|
||||
for(var event in card._uidEvents) {
|
||||
if(this.side && this.side.off){
|
||||
if(this.side && this.side.off) {
|
||||
this.side.off(event, card.getUidEvents(event));
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ var Field = (function(){
|
||||
return res;
|
||||
}
|
||||
|
||||
r.getInfo = function(){
|
||||
r.getInfo = function() {
|
||||
var self = this;
|
||||
return {
|
||||
cards: self._cards,
|
||||
@@ -160,27 +160,27 @@ var Field = (function(){
|
||||
}
|
||||
}
|
||||
|
||||
r.getHorn = function(){
|
||||
r.getHorn = function() {
|
||||
if(!this._hasHornField) return null;
|
||||
return this._hornCard;
|
||||
}
|
||||
|
||||
r.setHorn = function(card){
|
||||
r.setHorn = function(card) {
|
||||
if(!this._hasHornField) return null;
|
||||
this._hornCard = card;
|
||||
}
|
||||
|
||||
r.getHighestCards = function(noHeroes){
|
||||
r.getHighestCards = function(noHeroes) {
|
||||
noHeroes = noHeroes || false;
|
||||
var res = [];
|
||||
var highest = 0;
|
||||
|
||||
this.get().forEach(function(card){
|
||||
this.get().forEach(function(card) {
|
||||
if(noHeroes && card.hasAbility("hero")) return;
|
||||
highest = card.getPower() > highest ? card.getPower() : highest;
|
||||
})
|
||||
|
||||
this.get().forEach(function(card){
|
||||
this.get().forEach(function(card) {
|
||||
if(noHeroes && card.hasAbility("hero")) return;
|
||||
if(card.getPower() === highest) res.push(card);
|
||||
});
|
||||
|
Reference in New Issue
Block a user