diff --git a/Card.js b/Card.js index 8dcf361..1d5fdb9 100644 --- a/Card.js +++ b/Card.js @@ -103,6 +103,7 @@ function Card (game,player,zone,pid,side) { this.rise = info.rise; this.acce = !!info.acce; this.acceingCard = null; + this.trap = info.trap || null; // 杂项 this.effectFilters = []; @@ -731,6 +732,8 @@ Card.prototype.moveTo = function (zone,arg) { if (arg.faceup === undefined) arg.faceup = zone.faceup; if (arg.bottom === undefined) arg.bottom = zone.bottom; + if (arg.isSummon) arg.bottom = false; + var card = this; // 效果过滤 (不会受到XXX的效果影响) @@ -824,7 +827,7 @@ Card.prototype.moveTo = function (zone,arg) { } else { // 是 SIGNI 下方的卡,比如魅饰卡 // 处理魅饰卡 - var signi = card.zone.getActualCards()[0]; + var signi = card.zone.getSigni(); if (signi && card === signi.charm) { moveEvent.isCharm = true; signi.charm = null; @@ -843,11 +846,10 @@ Card.prototype.moveTo = function (zone,arg) { } else if (zone.name === 'SigniZone') { if (card.zone.name !== 'SigniZone' || zone.player !== card.player) { // 进入 SIGNI 区 - if (zone.getActualCards().length) { - // rise - if (!arg.bottom && card.rise) { + if (arg.isSummon) { + if (card.rise) { // 被 rise 的卡“离场” - signi = zone.getActualCards()[0]; + signi = zone.getSigni(); removeFromArr(signi,signi.player.signis); signi.frozen = false; signi.fieldData = {}; @@ -855,19 +857,14 @@ Card.prototype.moveTo = function (zone,arg) { charm = signi.charm; signi.charm = null; signi.onLeaveField2.trigger({}); - // 出场 - arg.bottom = false; - enterFieldEvent = moveEvent; - enterFieldEvent.riseTarget = signi; - card.player.signis.push(card); - } else { - // 放置到 SIGNI 下面的卡 - // (目前不用处理) + moveEvent.riseTarget = signi; } - } else { // 出场 enterFieldEvent = moveEvent; zone.player.signis.push(card); + } else { + // 放置到 SIGNI 下方的卡 + // 目前不需要处理 } } } else if ((zone.name === 'LrigZone') && !arg.bottom) { @@ -912,15 +909,15 @@ Card.prototype.moveTo = function (zone,arg) { // 手牌中非公开的卡,在游戏逻辑中是"背面朝上"的,即: // 对方不能查看;己方能查看(这是因为手牌区是 checkable 的). // 但在客户端中,手牌里的卡即使逻辑上是背面朝上的,仍显示为正面朝上. - // PS: 增加了陷阱,陷阱和手牌一样,是仅己方玩家可见的。 + // PS: 增加了陷阱,陷阱是 chekcable 的,背面朝上,但己方玩家可见的。 card.player.output({ type: 'MOVE_CARD', content: { card: card, - pid: (card.isFaceup || zone.checkable)? card.pid : 0, + pid: (card.isFaceup || arg.isTrap || zone.checkable)? card.pid : 0, zone: zone, up: arg.up, - faceup: (arg.isTrap || zone.inhand)? true : arg.faceup, + faceup: zone.inhand? true : arg.faceup, bottom: arg.bottom, isSide: arg.isSide } @@ -1146,7 +1143,7 @@ Card.prototype.attackAsyn = function () { if (!zones.length) return attackedZone = opposingZone; return this.player.selectAsyn('TARGET',zones).callback(this,function (zone) { attackedZone = zone - var card = zone.getActualCards()[0]; + var card = zone.getSigni(); if (card) card.beSelectedAsTarget(); }); }).callback(this,function () { @@ -1202,19 +1199,16 @@ Card.prototype.attackAsyn = function () { var trap = opposingZone.trap return Callback.immediately().callback(this,function () { if (opposingSigni || !trap) return; - return this.player.selectOptionalAsyn('LAUNCH',[trap]).callback(this,function (card) { + return this.player.opponent.selectOptionalAsyn('LAUNCH',[trap]).callback(this,function (card) { if (!card) return; - card.beSelectedAsTarget(); - return card.trap.actionAsyn.call(card).callback(this,function () { - card.trash(); - }); + return card.handleTrapAsyn(); }); }).callback(this,function () { // 攻击被无效,结束处理 if (event.prevented) return; // 若攻击的目标存在,进行战斗; // (暗杀的情况下,目标为正对面的 SIGNI 时,不战斗) - var target = attackedZone.getActualCards()[0] || null; + var target = attackedZone.getSigni() || null; var battle = true; if (!target) battle = false; if (card.assassin && (target === opposingSigni)) return false; @@ -1425,6 +1419,7 @@ Card.prototype.summonAsyn = function (optional,dontTriggerStartUp,down) { if (!card) return; return this.player.selectSummonZoneAsyn(false,this.rise).callback(this,function (zone) { card.moveTo(zone,{ + isSummon: true, dontTriggerStartUp: dontTriggerStartUp, up: !down }); @@ -1534,7 +1529,7 @@ Card.prototype.getTotalEnerCost = function (original) { Card.prototype.getOpposingSigni = function () { if (!inArr(this,this.player.signis)) return null; var idx = 2 - this.player.signiZones.indexOf(this.zone); - return this.player.opponent.signiZones[idx].getActualCards()[0] || null; + return this.player.opponent.signiZones[idx].getSigni() || null; }; Card.prototype.charmTo = function (signi) { @@ -1553,7 +1548,6 @@ Card.prototype.trapTo = function(zone) { zone.trap = this; this.moveTo(zone,{ faceup: false, - up: signi.isUp, isTrap: true, }); }; @@ -1665,4 +1659,19 @@ Card.prototype.isInfected = function() { return this.zone.virus; }; +Card.prototype.handleTrapAsyn = function() { + return Callback.immediately().callback(this,function () { + if (this.zone.cards.indexOf(this) === 0) { + this.faceup(); + } else { + return this.player.opponent.showCardsAsyn([this]); + } + }).callback(this,function () { + if (!this.trap) return; + return this.trap.actionAsyn.call(this); + }).callback(this,function () { + this.trash(); + }); +}; + global.Card = Card; \ No newline at end of file diff --git a/CardInfo.js b/CardInfo.js index 203aba5..3fdeb10 100644 --- a/CardInfo.js +++ b/CardInfo.js @@ -25883,7 +25883,7 @@ var CardInfo = { if (!inArr(card,card.player.signis)) return; var idx = 2 - card.player.signiZones.indexOf(card.zone); var zone = this.player.signiZones[idx]; - var opposingSigni = zone.getActualCards()[0]; + var opposingSigni = zone.getSigni(); var opposingSigni = card.getOpposingSigni(); if (opposingSigni) return; if (zone.disabled) return; @@ -27223,8 +27223,8 @@ var CardInfo = { },this); var zones = this.player.opponent.signiZones.filter(function (zone) { if (zone.disabled) return false; - var cards = zone.getActualCards(); - return (!cards.length) || (!cards[0].isEffectFiltered()); + var signi = zone.getSigni(); + return !card || !card.isEffectFiltered(); },this); return Callback.loop(this,2,function () { if (done) return; @@ -28304,8 +28304,8 @@ var CardInfo = { },this); var zones = this.player.signiZones.filter(function (zone) { if (zone.disabled) return false; - var cards = zone.getActualCards(); - return (!cards.length) || (!cards[0].isEffectFiltered()); + var signi = zone.getSigni(); + return !card || !card.isEffectFiltered(); },this); return Callback.loop(this,2,function () { if (done) return; @@ -38881,7 +38881,7 @@ var CardInfo = { source: this, destroyTimming: this.game.phase.onTurnEnd, action: function (set,add) { - var card = this.player.signiZones[1].getActualCards()[0]; + var card = this.player.signiZones[1].getSigni(); if (card) { set(card,'doubleCrash',true); } @@ -38893,7 +38893,7 @@ var CardInfo = { once: true, destroyTimming: this.game.phase.onTurnEnd, action: function (set,add) { - var card = this.player.signiZones[1].getActualCards()[0]; + var card = this.player.signiZones[1].getSigni(); if (card) { set(card,'doubleCrash',true); } @@ -64100,7 +64100,7 @@ var CardInfo = { destroyTimming: [this.game.phase.onTurnEnd], action: function (set,add) { set(zone,'powerDown',true); - var card = zone.getActualCards()[0]; + var card = zone.getSigni(); if (!card) return; add(card,'power',-7000); } @@ -64113,7 +64113,7 @@ var CardInfo = { destroyTimming: [this.game.phase.onTurnEnd], action: function (set,add) { set(zone,'powerDown',true); - var card = zone.getActualCards()[0]; + var card = zone.getSigni(); if (!card) return; add(card,'power',-7000); } @@ -79269,7 +79269,7 @@ var CardInfo = { },this); return this.player.selectAsyn('TRASH_CHARM',zones).callback(this,function (zone) { if (!zone) return; - var card = zone.getActualCards()[0].charm; + var card = zone.getSigni().charm; card.trash(); }); }); @@ -82803,7 +82803,7 @@ var CardInfo = { destroyTimming: this.game.phase.onTurnEnd, action: function (set,add) { var zone = this.player.signiZones[1]; - var card = zone.getActualCards()[0]; + var card = zone.getSigni(); if (!inArr(card,this.player.signis)) return; var opposingSigni = card.getOpposingSigni(); if (!opposingSigni || !opposingSigni.charm) return; @@ -87968,7 +87968,7 @@ var CardInfo = { destroyTimming: this.game.phase.onTurnEnd, action: function (set,add) { var zone = this.player.signiZones[1]; - var card = zone.getActualCards()[0]; + var card = zone.getSigni(); if (!inArr(card,this.player.signis)) return; add(card,'power',5000); set(card,'lancer',true); @@ -104711,7 +104711,7 @@ var CardInfo = { destroyTimming: this.game.phase.onTurnEnd, action: function (set,add) { var zone = this.player.signiZones[1]; - var card = zone.getActualCards()[0]; + var card = zone.getSigni(); if (!inArr(card,this.player.signis)) return; if (!card.hasClass('龍獣')) return; set(card,'doubleCrash',true); @@ -119414,7 +119414,7 @@ var CardInfo = { }, actionAsyn: function (event) { var zones = this.player.signiZones.filter(function (zone) { - return !zone.disabled && (zone !== event.card.zone) && !zone.getActualCards().length; + return !zone.disabled && (zone !== event.card.zone) && !zone.getSigni(); },this); if (!zones.length) return; return this.player.selectAsyn('RESET_SIGNI_ZONE',zones).callback(this,function (zone) { @@ -119502,7 +119502,7 @@ var CardInfo = { }, actionAsyn: function (event) { var zones = this.player.signiZones.filter(function (zone) { - return !zone.disabled && (zone !== event.card.zone) && !zone.getActualCards().length; + return !zone.disabled && (zone !== event.card.zone) && !zone.getSigni(); },this); if (!zones.length) return; return this.player.selectAsyn('RESET_SIGNI_ZONE',zones).callback(this,function (zone) { @@ -119590,7 +119590,7 @@ var CardInfo = { }, actionAsyn: function (event) { var zones = this.player.signiZones.filter(function (zone) { - return !zone.disabled && (zone !== event.card.zone) && !zone.getActualCards().length; + return !zone.disabled && (zone !== event.card.zone) && !zone.getSigni(); },this); if (!zones.length) return; return this.player.selectAsyn('RESET_SIGNI_ZONE',zones).callback(this,function (zone) { @@ -127048,7 +127048,7 @@ var CardInfo = { if (!zone) return; zone.trap.moveTo(this.player.handZone); }); - }); + }); } }] }, @@ -127311,7 +127311,7 @@ var CardInfo = { var source = this.game.getEffectSource(); if (source && source.player === this.player) return false; return true; - } + }, actionAsyn: function () { return this.player.draw(1); } @@ -127328,7 +127328,7 @@ var CardInfo = { var source = this.game.getEffectSource(); if (source && source.player === this.player) return false; return true; - } + }, actionAsyn: function () { return this.player.revealAsyn(3).callback(this,function (cards) { var targets = cards.filter(function (card) { @@ -127725,12 +127725,7 @@ var CardInfo = { },this); return this.player.selectAsyn('LAUNCH',zones).callback(this,function (zone) { if (!zone) return; - var card = zone.trap; - return this.player.opponent.showCardsAsyn([card]).callback(this,function () { - return card.trap.actionAsyn.call(card); - }).callback(this,function () { - card.trash(); - }); + return zone.trap.handleTrapAsyn(); }); } } @@ -128292,7 +128287,7 @@ var CardInfo = { startUpEffects: [{ actionAsyn: function () { if (this.player.opponent.lifeClothZone.cards.length <= this.player.lifeClothZone.cards.length) return; - var signi = this.player.opponent.signiZones[1].getActualCards()[0]; + var signi = this.player.opponent.signiZones[1].getSigni(); if (!signi) return; return signi.banishAsyn(); } @@ -128392,11 +128387,7 @@ var CardInfo = { actionAsyn: function () { var card = this.zone.trap; if (!card) return; - return this.player.opponent.showCardsAsyn([card]).callback(this,function () { - return card.trap.actionAsyn.call(card); - }).callback(this,function () { - card.trash(); - }); + return card.handleTrapAsyn(); }, }], // ====================== @@ -128916,7 +128907,6 @@ var CardInfo = { "costGreen": 0, "costColorless": 0, "guardFlag": false, - ], "multiEner": false, cardText: "苦しめよ。 ~オイゴナ~", cardText_zh_CN: "", @@ -132503,7 +132493,7 @@ var CardInfo = { }); }, }); - add(this.opponent,'onAttack',effect); + add(this.player.opponent,'onAttack',effect); } }); } @@ -132578,7 +132568,6 @@ var CardInfo = { "costGreen": 0, "costColorless": 0, "guardFlag": false, - ], "multiEner": false, cardText: "ドキドキさせられちゃいますわ♥ ~ナナシ~", cardText_zh_CN: "", @@ -132595,7 +132584,7 @@ var CardInfo = { "【自】:あなたのメインフェイズ開始時、対戦相手のシグニゾーン1つに【ウィルス】1つを置く。", ], constEffectTexts_en: [ - "[Constant]: All of your opponent's infected SIGNI get −1000 power." + "[Constant]: All of your opponent's infected SIGNI get −1000 power.", "[Auto]: When your main phase starts, put 1 [Virus] on 1 of your opponent's SIGNI Zones.", ], constEffects: [{ @@ -133635,7 +133624,7 @@ var CardInfo = { actionAsyn: function () { if (this.player.hands.length <= 2) { this.player.draw(1); - }, + } }, }], // ====================== @@ -133711,7 +133700,7 @@ var CardInfo = { actionAsyn: function () { if (this.player.getTraps().length) { this.player.draw(1); - }, + } }, }], }, @@ -134197,7 +134186,7 @@ var CardInfo = { this.player.enerCharge(1); } }); - }, + } }, }, }, @@ -134530,7 +134519,7 @@ var CardInfo = { return this.player.signis.some(function (signi) { return signi.rise; },this); - } + }, actionAsyn: function () { return this.banishSigniAsyn(12000); } @@ -134717,7 +134706,7 @@ var CardInfo = { return this.player.signis.some(function (signi) { return signi.rise; },this); - } + }, actionAsyn: function () { return this.banishSigniAsyn(5000); } @@ -134834,7 +134823,7 @@ var CardInfo = { return this.player.signis.some(function (signi) { return signi.rise; },this); - } + }, actionAsyn: function () { return this.banishSigniAsyn(2000); } diff --git a/Player.js b/Player.js index 4a693f7..9639943 100644 --- a/Player.js +++ b/Player.js @@ -400,17 +400,14 @@ Player.prototype.summonSigniAsyn = function () { var cards = this.hands.filter(function (card) { return card.canSummon() && (!this.summonPowerLimit || (card.power < this.summonPowerLimit)); },this); - var zones = this.signiZones.filter(function (zone) { - return (zone.getActualCards().length === 0); - },this); - if (!cards.length || !zones.length) { + if (!cards.length) { return Callback.never(); } return this.selectAsyn('SUMMON_SIGNI',cards).callback(this,function (card) { return this.selectSummonZoneAsyn(true,card.rise).callback(this,function (zone) { if (!zone) return; return this.game.blockAsyn(this,function () { - card.moveTo(zone); + card.moveTo(zone,{isSummon: true}); this.game.handleFrameEnd(); // 增加一个空帧,以进行两次常计算 }); }); @@ -455,7 +452,7 @@ Player.prototype.summonResonaAsyn = function (card) { return this.selectSummonZoneAsyn(false).callback(this,function (zone) { if (!zone) return; return this.game.blockAsyn(this,function () { - card.moveTo(zone,{resonaArg: resonaArg}); + card.moveTo(zone,{isSummon: true, resonaArg: resonaArg}); this.game.handleFrameEnd(); // 增加一个空帧,以进行两次常计算 }); }); @@ -477,13 +474,13 @@ Player.prototype.getSummonZones = function (signis,rise) { var forcedZones = []; var zones = this.signiZones.filter(function (zone,idx) { if (zone.disabled) return false; - var signi = zone.getActualCards()[0]; + var signi = zone.getSigni(); 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].getSigni(); if (opposingSigni && opposingSigni.forceSummonZone) { forcedZones.push(zone); } @@ -2228,7 +2225,7 @@ Player.prototype.setCrossPair = function () { if (!card.crossLeft && !card.crossRight) return; function checkMatch (zone,cross) { if (!zone) return null; - var card = zone.getActualCards()[0]; + var card = zone.getSigni(); if (!card) return null; var cids = concat(cross); var matched = cids.some(function (cid) { diff --git a/Zone.js b/Zone.js index bd77d0b..d14e229 100644 --- a/Zone.js +++ b/Zone.js @@ -59,6 +59,12 @@ Zone.prototype.getActualCards = function () { },this); }; +Zone.prototype.getSigni = function() { + return this.player.signis.filter(function (signi) { + return signi.zone === this; + },this)[0] || null; +}; + Zone.prototype.moveCardsToTop = function (cards) { cards = cards.filter(function (card) { return inArr(card,this.cards);