From 8b55954a6620010026e0d2b9634faaf80f42e6a0 Mon Sep 17 00:00:00 2001 From: WEBXOSS Date: Wed, 7 Jun 2017 17:48:58 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=AB=20implement=20wisdom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Card.js | 1 + CardInfo.js | 1 - ConstEffect.js | 1 + Effect.js | 9 +++++++-- Player.js | 11 +++++++++++ 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Card.js b/Card.js index fc8afed..aef3418 100644 --- a/Card.js +++ b/Card.js @@ -266,6 +266,7 @@ Card.prototype.setupConstEffects = function () { once: once, destroyTimming: destroyTimming, cross: !!eff.cross, + wisdom: eff.wisdom, fixed: !!eff.fixed, condition: eff.condition, action: action, diff --git a/CardInfo.js b/CardInfo.js index a5aa188..f3d386e 100644 --- a/CardInfo.js +++ b/CardInfo.js @@ -116594,7 +116594,6 @@ var CardInfo = { "【常】英知=10:このシグニが正面にアタックする場合、このシグニは正面に加えてその隣のシグニゾーン1つにアタックしてもよい。", ], constEffects: [{ - // TODO: ... wisdom: 7, auto: 'onAttack', effect: { diff --git a/ConstEffect.js b/ConstEffect.js index f4d43bc..adc2953 100644 --- a/ConstEffect.js +++ b/ConstEffect.js @@ -62,6 +62,7 @@ ConstEffect.prototype.compute = function () { if (this.fixed && this.computed) return; this.clear(); if (this.cross && !this.source.crossed) return; + if (this.wisdom && !(this.source.player.getWisdom() >= this.wisdom)) return; if (!this.condition || this.condition.call(this.source)) { var control = { reregister: false diff --git a/Effect.js b/Effect.js index bb3dd3d..8cb988e 100644 --- a/Effect.js +++ b/Effect.js @@ -31,6 +31,7 @@ function Effect (effectManager,cfg) { this.costChange = cfg.costChange; this.condition = cfg.condition; this.actionAsyn = cfg.actionAsyn; + this.wisdom = cfg.wisdom || 0; this.disabled = false; // 失去能力时设置为 true . } @@ -66,10 +67,14 @@ Effect.prototype.triggerAndHandleAsyn = function (event) { Effect.prototype.checkCondition = function () { // "结束这个回合",如<终结之洞> var game = this.effectManager.game; - if (game.getData(game,'endThisTurn')) return; + if (game.getData(game,'endThisTurn')) return false; // "1回合1次" if (this.once && inArr(this.proto,this.effectManager.triggeredEffects)) { - return; + return false; + } + // wisdom + if (this.wisdom && !(this.source.player.getWisdom() > this.wisdom)) { + return false; } // 隐藏规则之"发动和解决的场所必须一致" if (!this.isBurst && this.triggerZone) { // 排除迸发 diff --git a/Player.js b/Player.js index f724afc..d2dce32 100644 --- a/Player.js +++ b/Player.js @@ -848,6 +848,8 @@ Player.prototype.canUseActionEffect = function (effect,arg) { if (!arg.onAttack && effect.onAttack) return false; // cross if (effect.cross && !effect.source.crossed) return false; + // wisdom + if (effect.wisdom && !(effect.source.player.getWisdom() >= effect.wisdom)) return false; // once if (effect.once && inArr(effect,this.usedActionEffects)) return false; // condition @@ -2382,4 +2384,13 @@ Player.prototype.pickCardsFromDeckTopAsyn = function(count,filter,max) { }); }; +Player.prototype.getWisdom = function() { + let wisdom = 0; + this.signis.forEach(function (signi) { + if (!signi.hasClass('英知')) return; + wisdom += signi.level; + },this); + return wisdom; +}; + global.Player = Player; \ No newline at end of file