1
0
Fork 1
mirror of https://github.com/webxoss/webxoss-core.git synced 2025-04-05 02:17:18 +02:00

handle coin && rise

This commit is contained in:
WEBXOSS 2017-02-20 23:13:39 +08:00
parent bc5244044b
commit 1d28364349
3 changed files with 138 additions and 23 deletions

79
Card.js
View file

@ -95,6 +95,9 @@ function Card (game,player,zone,pid,side) {
this.sideB = info.sideB? new Card(game,player,zone,info.sideB,this) : null; this.sideB = info.sideB? new Card(game,player,zone,info.sideB,this) : null;
} }
// Lostorage
this.rise = info.rise;
// 杂项 // 杂项
this.effectFilters = []; this.effectFilters = [];
this.registeredEffects = []; this.registeredEffects = [];
@ -106,7 +109,8 @@ function Card (game,player,zone,pid,side) {
// 时点 // 时点
this.onMove = new Timming(game); this.onMove = new Timming(game);
this.onEnterField = new Timming(game); this.onEnterField = new Timming(game);
this.onLeaveField = new Timming(game); this.onLeaveField = new Timming(game); // 常时效果中「离场时」的时点
this.onLeaveField2 = new Timming(game); // 包括被 rise 等而成为卡垫的时点
this.onBurst = new Timming(game); this.onBurst = new Timming(game);
this.onAttack = new Timming(game); this.onAttack = new Timming(game);
this.onStartUp = new Timming(game); this.onStartUp = new Timming(game);
@ -179,7 +183,7 @@ Card.prototype.cookEffect = function (rawEffect,type,offset) {
}; };
Card.prototype.setupConstEffects = function () { Card.prototype.setupConstEffects = function () {
this.constEffects.forEach(function (eff) { this.constEffects.forEach(function (eff,idx) {
var createTimming,destroyTimming,once; var createTimming,destroyTimming,once;
if (eff.duringGame) { if (eff.duringGame) {
createTimming = null; createTimming = null;
@ -191,9 +195,20 @@ Card.prototype.setupConstEffects = function () {
once = eff.once; once = eff.once;
} else { } else {
createTimming = this.onEnterField; createTimming = this.onEnterField;
destroyTimming = this.onLeaveField; destroyTimming = this.onLeaveField2;
once = false; once = false;
} }
var action = eff.action
if (eff.auto) {
action = function (set,add) {
var effect = this.game.newEffect({
source: this,
description: this.cid+'-'+'const-'+idx,
actionAsyn: eff.actionAsyn,
});
add(this,eff.auto,effect);
};
}
this.game.addConstEffect({ this.game.addConstEffect({
source: this, source: this,
createTimming: createTimming, createTimming: createTimming,
@ -202,7 +217,7 @@ Card.prototype.setupConstEffects = function () {
cross: !!eff.cross, cross: !!eff.cross,
fixed: !!eff.fixed, fixed: !!eff.fixed,
condition: eff.condition, condition: eff.condition,
action: eff.action action: action,
},true); },true);
},this); },this);
}; };
@ -312,6 +327,14 @@ Card.prototype.canSummon = function () {
Card.prototype.canSummonWith = function (signis) { Card.prototype.canSummonWith = function (signis) {
// 类型 // 类型
if (this.type !== 'SIGNI') return false; if (this.type !== 'SIGNI') return false;
// rise
var riseTargets = []
if (this.rise) {
riseTargets = signis.filter(function (signi) {
return this.rise(signi)
},this)
if (!riseTargets.length) return false;
}
// <绿罗植 世界树> // <绿罗植 世界树>
if (this.player.canNotUseColorlessSigni) { if (this.player.canNotUseColorlessSigni) {
if (this.hasColor('colorless')) { if (this.hasColor('colorless')) {
@ -328,16 +351,24 @@ Card.prototype.canSummonWith = function (signis) {
// 等级限制 // 等级限制
if (this.level > this.player.lrig.level) return false; if (this.level > this.player.lrig.level) return false;
// SIGNI 数量限制 // SIGNI 数量限制
if (signis.length >= this.player.getSigniAmountLimit()) { var length = signis.length;
if (this.rise) length--;
if (length >= this.player.getSigniAmountLimit()) {
return false; return false;
} }
// 界限限制 // 界限限制
var totalLevel = signis.reduce(function (total,signi) { var totalLevel = signis.reduce(function (total,signi) {
return total + signi.level; return total + signi.level;
},this.level); },this.level);
if (this.rise) {
// rise 减去等级最高的目标即可
totalLevel -= Math.max.apply(Math,riseTargets.map(function (signi) {
return signi.level;
}));
}
if (totalLevel > this.player.lrig.limit) return false; if (totalLevel > this.player.lrig.limit) return false;
// 召唤区限制 // 召唤区限制
var zones = this.player.getSummonZones(signis); var zones = this.player.getSummonZones(signis,this.rise);
if (!zones.length) return false; if (!zones.length) return false;
// 结束 // 结束
return true; return true;
@ -750,6 +781,8 @@ Card.prototype.moveTo = function (zone,arg) {
var leaveFieldEvent = null; var leaveFieldEvent = null;
var lrigChangeEvent = null; var lrigChangeEvent = null;
var charm = null; var charm = null;
/* 处理离开区域逻辑 */
if (card.zone.name === 'HandZone') { if (card.zone.name === 'HandZone') {
// 离开手牌 // 离开手牌
removeFromArr(card,card.player.hands); removeFromArr(card,card.player.hands);
@ -757,6 +790,7 @@ Card.prototype.moveTo = function (zone,arg) {
// 离开 SigniZone // 离开 SigniZone
if (inArr(card,card.player.signis)) { if (inArr(card,card.player.signis)) {
// 是 SIGNI // 是 SIGNI
// 以下代码 rise 里复用了,虽然说 DRY 原则,但这里也不太好抽离,养肥了再抽吧(
leaveFieldEvent = moveEvent; leaveFieldEvent = moveEvent;
card.frozen = false; card.frozen = false;
card.fieldData = {}; card.fieldData = {};
@ -774,15 +808,36 @@ Card.prototype.moveTo = function (zone,arg) {
} }
} }
} }
/* 处理进入区域逻辑 */
if (zone.name === 'HandZone') { if (zone.name === 'HandZone') {
// 进入手牌 // 进入手牌
zone.player.hands.push(card); zone.player.hands.push(card);
} else if (zone.name === 'SigniZone') { } else if (zone.name === 'SigniZone') {
if (card.zone.name !== 'SigniZone' || zone.player !== card.player) { if (card.zone.name !== 'SigniZone' || zone.player !== card.player) {
// 进入 SIGNI 区
if (zone.getActualCards().length) { if (zone.getActualCards().length) {
// 放置到 SIGNI 下面的卡 // rise
if (card.rise) {
// 被 rise 的卡“离场”
signi = zone.getActualCards()[0];
removeFromArr(signi,signi.player.signis);
signi.frozen = false;
signi.fieldData = {};
signi.fieldTurnData = {};
charm = signi.charm;
signi.charm = null;
signi.onLeaveField2.trigger({});
// 出场
arg.bottom = false;
enterFieldEvent = moveEvent;
card.player.signis.push(card);
} else {
// 放置到 SIGNI 下面的卡
// (目前不用处理)
}
} else { } else {
// 进入 SigniZone // 出场
enterFieldEvent = moveEvent; enterFieldEvent = moveEvent;
zone.player.signis.push(card); zone.player.signis.push(card);
} }
@ -882,6 +937,7 @@ Card.prototype.moveTo = function (zone,arg) {
} else if (leaveFieldEvent) { } else if (leaveFieldEvent) {
// card.player.onSignisChange.trigger(); // card.player.onSignisChange.trigger();
card.onLeaveField.trigger(leaveFieldEvent); card.onLeaveField.trigger(leaveFieldEvent);
card.onLeaveField2.trigger(leaveFieldEvent);
card.player.onSigniLeaveField.trigger(leaveFieldEvent); card.player.onSigniLeaveField.trigger(leaveFieldEvent);
// SIGNI 离场时,下面的卡送入废弃区, // SIGNI 离场时,下面的卡送入废弃区,
// 此处理在块结束时执行。 // 此处理在块结束时执行。
@ -896,7 +952,7 @@ Card.prototype.moveTo = function (zone,arg) {
} else if (lrigChangeEvent) { } else if (lrigChangeEvent) {
// card.player.onLrigChange.trigger(lrigChangeEvent); // card.player.onLrigChange.trigger(lrigChangeEvent);
var oldLrig = lrigChangeEvent.oldLrig; var oldLrig = lrigChangeEvent.oldLrig;
if (oldLrig) oldLrig.onLeaveField.trigger(); if (oldLrig) oldLrig.onLeaveField2.trigger();
card.onEnterField.trigger(enterFieldEvent); card.onEnterField.trigger(enterFieldEvent);
if (!(arg.dontTriggerStartUp || card.player.lrigStartUpBanned)) { if (!(arg.dontTriggerStartUp || card.player.lrigStartUpBanned)) {
card.onStartUp.trigger(enterFieldEvent); card.onStartUp.trigger(enterFieldEvent);
@ -1280,10 +1336,7 @@ Card.prototype.banishAsyn = function (arg) {
// }; // };
Card.prototype.summonAsyn = function (optional,dontTriggerStartUp,down) { Card.prototype.summonAsyn = function (optional,dontTriggerStartUp,down) {
var zones = this.player.signiZones.filter(function (zone) { if (!this.canSummon()) return Callback.immediately();
return (zone.getActualCards().length === 0);
},this);
if (!this.canSummon() || !zones.length) return Callback.immediately();
return Callback.immediately().callback(this,function () { return Callback.immediately().callback(this,function () {
if (optional) { if (optional) {
return this.player.selectOptionalAsyn('SUMMON_SIGNI',[this]); return this.player.selectOptionalAsyn('SUMMON_SIGNI',[this]);

View file

@ -58445,7 +58445,7 @@ var CardInfo = {
this.player.signis.forEach(function (signi) { this.player.signis.forEach(function (signi) {
this.game.addConstEffect({ this.game.addConstEffect({
source: signi, source: signi,
destroyTimming: [signi.onLeaveField,this.game.phase.onTurnEnd], destroyTimming: [signi.onLeaveField2,this.game.phase.onTurnEnd],
condition: function () { condition: function () {
var opposingSigni = this.getOpposingSigni(); var opposingSigni = this.getOpposingSigni();
if (!opposingSigni) return false; if (!opposingSigni) return false;
@ -124590,7 +124590,7 @@ var CardInfo = {
"【起】《ターン1回》《赤》《赤》《赤》:ターン終了時まで、あなたの《ライズアイコン》を持つシグニ1体は「このシグニが正面にあるシグニ1体をバニッシュしたとき、このシグニをアップする。」を得る。" "【起】《ターン1回》《赤》《赤》《赤》:ターン終了時まで、あなたの《ライズアイコン》を持つシグニ1体は「このシグニが正面にあるシグニ1体をバニッシュしたとき、このシグニをアップする。」を得る。"
], ],
actionEffectTexts_zh_CN: [ actionEffectTexts_zh_CN: [
"【起】《1回合1次》【红】【红】【红】直到回合结束为止你的1只持有【】的SIGNI获得「这只SIGNI对面的SIGNI被驱逐时将这只SIGNI竖置」。" "【起】《1回合1次》【红】【红】【红】直到回合结束为止你的1只持有【Rise】的SIGNI获得「这只SIGNI对面的SIGNI被驱逐时将这只SIGNI竖置」。"
], ],
actionEffectTexts_en: [ actionEffectTexts_en: [
"[Action] [1/Turn] [Red] [Red] [Red]: Until end of turn, 1 of your SIGNI with Rise gets \"When the SIGNI in front of this SIGNI is banished, up this SIGNI.\"." "[Action] [1/Turn] [Red] [Red] [Red]: Until end of turn, 1 of your SIGNI with Rise gets \"When the SIGNI in front of this SIGNI is banished, up this SIGNI.\"."
@ -124600,7 +124600,7 @@ var CardInfo = {
costRed: 3, costRed: 3,
actionAsyn: function () { actionAsyn: function () {
var filter = function (card) { var filter = function (card) {
return card.hasBurst(); return card.rise;
} }
return this.player.selectSelfSigniAsyn(filter).callback(this,function (card) { return this.player.selectSelfSigniAsyn(filter).callback(this,function (card) {
if (!card) return; if (!card) return;
@ -125548,7 +125548,51 @@ var CardInfo = {
"Banish 1 of your <Valor> SIGNI with Rise. If you do, banish 1 of your opponent's SIGNI with power 12000 or less.", "Banish 1 of your <Valor> SIGNI with Rise. If you do, banish 1 of your opponent's SIGNI with power 12000 or less.",
], ],
spellEffect: [{ spellEffect: [{
// TODO... getTargets: function () {
return this.player.signis.filter(function (signi) {
return !signi.rise && signi.hasClass('武勇');
},this);
},
actionAsyn: function (card) {
return card.banishAsyn().callback(this,function (succ) {
if (!succ) return;
var filter = function (card) {
return card.rise && card.hasClass('武勇');
};
return this.player.seekAsyn(filter,1);
});
}
},{
getTargetAdvancedAsyn: function () {
var targets = [];
var pSignis = this.player.signis.filter(function (signi) {
return signi.rise && signi.hasClass('武勇');
});
var oSignis = this.player.opponent.signis.filter(function (signi) {
return signi.power <= 12000;
},this);
return this.player.selectTargetOptionalAsyn(pSignis).callback(this,function (targetA) {
if (!targetA) return;
targets.push(targetA);
return this.player.selectTargetAsyn(oSignis).callback(this,function (targetB) {
if (!targetB) return;
targets.push(targetB);
});
}).callback(this,function () {
return targets;
});
},
actionAsyn: function (targets) {
var targetA = targets[0];
var targetB = targets[1];
if (!inArr(targetA,this.player.signis)) return;
return targetA.banishAsyn().callback(this,function (succ) {
if (!succ) return;
if (!inArr(targetB,this.player.opponent.signis)) return;
if (targetB.power > 12000) return;
return targetB.banishAsyn();
});
}
}], }],
}, },
"2018": { "2018": {

View file

@ -28,6 +28,7 @@ function Player (game,io,mainDeck,lrigDeck) {
// 然后在调用堆栈的最后将整个队列发送. // 然后在调用堆栈的最后将整个队列发送.
this.messagePacks = []; // 用于保存录像. this.messagePacks = []; // 用于保存录像.
this.rebuildCount = 0; this.rebuildCount = 0;
this.coin = 0;
// 快捷方式 // 快捷方式
this.hands = []; // 手牌 this.hands = []; // 手牌
@ -404,7 +405,7 @@ Player.prototype.summonSigniAsyn = function () {
return Callback.never(); return Callback.never();
} }
return this.selectAsyn('SUMMON_SIGNI',cards).callback(this,function (card) { return this.selectAsyn('SUMMON_SIGNI',cards).callback(this,function (card) {
return this.selectSummonZoneAsyn(true).callback(this,function (zone) { return this.selectSummonZoneAsyn(true,card.rise).callback(this,function (zone) {
if (!zone) return; if (!zone) return;
return this.game.blockAsyn(this,function () { return this.game.blockAsyn(this,function () {
card.moveTo(zone); card.moveTo(zone);
@ -459,8 +460,8 @@ Player.prototype.summonResonaAsyn = function (card) {
}); });
}; };
Player.prototype.selectSummonZoneAsyn = function (optional) { Player.prototype.selectSummonZoneAsyn = function (optional,rise) {
var zones = this.getSummonZones(); var zones = this.getSummonZones(null,rise);
if (!zones.length) { if (!zones.length) {
debugger; debugger;
return Callback.immediately(null); return Callback.immediately(null);
@ -469,13 +470,17 @@ Player.prototype.selectSummonZoneAsyn = function (optional) {
return this.selectAsyn('SUMMON_SIGNI_ZONE',zones); return this.selectAsyn('SUMMON_SIGNI_ZONE',zones);
}; };
Player.prototype.getSummonZones = function (signis) { Player.prototype.getSummonZones = function (signis,rise) {
if (!signis) signis = this.signis; if (!signis) signis = this.signis;
var forcedZones = []; var forcedZones = [];
var zones = this.signiZones.filter(function (zone,idx) { var zones = this.signiZones.filter(function (zone,idx) {
if (zone.disabled) return false; if (zone.disabled) return false;
var signi = zone.getActualCards()[0]; var signi = zone.getActualCards()[0];
if (signi && inArr(signi,signis)) return false; if (rise) {
if (!signi || !rise(signi)) return false;
} else {
if (signi && inArr(signi,signis)) return false;
}
var opposingSigni = this.opponent.signiZones[2-idx].getActualCards()[0]; var opposingSigni = this.opponent.signiZones[2-idx].getActualCards()[0];
if (opposingSigni && opposingSigni.forceSummonZone) { if (opposingSigni && opposingSigni.forceSummonZone) {
forcedZones.push(zone); forcedZones.push(zone);
@ -1385,7 +1390,7 @@ Player.prototype.needEner = function (obj) {
if (obj.costChange) { if (obj.costChange) {
obj = obj.costChange(); obj = obj.costChange();
} }
var costs = [obj.costColorless,obj.costWhite,obj.costBlack,obj.costRed,obj.costBlue,obj.costGreen]; var costs = [obj.costColorless,obj.costWhite,obj.costBlack,obj.costRed,obj.costBlue,obj.costGreen,costCoin];
return costs.some(function (cost) { return costs.some(function (cost) {
return cost > 0; return cost > 0;
}); });
@ -1665,6 +1670,7 @@ Player.prototype.enoughCost = function (obj) {
if (obj.costChange) { if (obj.costChange) {
obj = obj.costChange(); obj = obj.costChange();
} }
if (obj.costCoin && obj.costCoin >= this.coin) return false;
if (!this.enoughEner(obj)) return false; if (!this.enoughEner(obj)) return false;
if (obj.costDown && obj.source && !obj.source.isUp) return false; if (obj.costDown && obj.source && !obj.source.isUp) return false;
if (obj.costCondition && obj.source) { if (obj.costCondition && obj.source) {
@ -1821,6 +1827,11 @@ Player.prototype.payCostAsyn = function (obj,cancelable) {
if (obj.costDown && obj.source) { if (obj.costDown && obj.source) {
obj.source.down(); obj.source.down();
} }
// Coin
if (obj.costCoin) {
this.coin -= obj.costCoin
if (this.coin < 0) this.coin = 0
}
// 其它 // 其它
if (obj.costAsyn) { if (obj.costAsyn) {
if (obj.source) return obj.costAsyn.call(obj.source); if (obj.source) return obj.costAsyn.call(obj.source);
@ -2203,6 +2214,13 @@ Player.prototype.setCrossPair = function () {
pair.crossed = [card,pair]; pair.crossed = [card,pair];
}; };
Player.prototype.gainCoins = function(count) {
this.coin += count;
if (this.coin > 5) {
this.coin = 5;
}
};
// For test: // For test:
Player.prototype.matchCard = function (arg) { Player.prototype.matchCard = function (arg) {