1
0
Fork 0

💩 add WX16 cards (before pid 2400)

This commit is contained in:
WEBXOSS 2017-05-30 16:12:04 +08:00
parent 2cc031f0a0
commit 334a5c0020
3 changed files with 1931 additions and 1401 deletions

50
Card.js
View file

@ -63,8 +63,8 @@ function Card (game,player,zone,pid,side) {
this.beforeUseAsyn = info.beforeUseAsyn || null; this.beforeUseAsyn = info.beforeUseAsyn || null;
// 生命迸发效果 // 生命迸发效果
this.burstEffects = this.cookEffect(info.burstEffect,'burst'); this.burstEffects = this.cookEffect(info.burstEffect,'burst');
// 常时效果 // 常时效果(因为内容会被修改,这里用 slice 创建不同的引用)
this.constEffects = info.constEffects || []; this.constEffects = info.constEffects.slice() || [];
// 出场效果 // 出场效果
this.startUpEffects = this.cookEffect(info.startUpEffects,'startup'); this.startUpEffects = this.cookEffect(info.startUpEffects,'startup');
// 起动效果 // 起动效果
@ -188,18 +188,43 @@ Card.abilityProps = [
'trap', 'trap',
]; ];
var mixins = {
acce: {
activatedInEnerZone: true,
useCondition: function () {
return this.player.signis.some(function (signi) {
return signi.canBeAcced();
},this);
},
actionAsyn: function () {
var signis = this.player.signis.filter(function (signi) {
return signi.canBeAcced();
},this);
return this.player.selectTargetOptionalAsyn(signis).callback(this,function (signi) {
if (!signi) return;
this.acceTo(signi);
});
},
},
};
Card.prototype.cookEffect = function (rawEffect,type,offset) { Card.prototype.cookEffect = function (rawEffect,type,offset) {
if (!offset) offset = 0; if (!offset) offset = 0;
return concat(rawEffect || []).map(function (eff,idx) { return concat(rawEffect || []).map(function (eff,idx) {
var effect = Object.create(eff); var effect = Object.create(eff);
effect.source = this; effect.source = this;
effect.description = [this.cid,type,idx+offset].join('-'); effect.description = [this.cid,type,idx+offset].join('-');
if (eff.mixin) {
var mixin = mixins[eff.mixin];
for(var porp in mixin) {
effect[prop] = mixin[prop];
}
}
return effect; return effect;
},this); },this);
}; };
Card.prototype.setupConstEffects = function () { Card.prototype.setupConstEffects = function () {
this.constEffects.forEach(function (eff,idx) { this.constEffects.forEach(function (eff,idx,constEffects) {
var createTimming,destroyTimming,once; var createTimming,destroyTimming,once;
if (eff.duringGame) { if (eff.duringGame) {
createTimming = null; createTimming = null;
@ -216,14 +241,22 @@ Card.prototype.setupConstEffects = function () {
} }
var action = eff.action var action = eff.action
if (eff.auto) { if (eff.auto) {
// 对于【自】效果,自动添加效果源和效果描述。
// 暴露在 card.constEffects[i].effect 上,供<験英の応援 #ゴウカク#>之类的效果获取。
var options = Object.create(eff.effect);
if (!options.source) options.source = this;
if (!options.description) options.description = this.cid+'-'+'const-'+idx;
var effect = this.game.newEffect(options);
constEffects[idx].effect = effect;
if (isStr(eff.auto)) {
action = function (set,add) { action = function (set,add) {
var effect = this.game.newEffect({
source: this,
description: this.cid+'-'+'const-'+idx,
actionAsyn: eff.actionAsyn,
});
add(this,eff.auto,effect); add(this,eff.auto,effect);
}; };
} else {
action = function (set,add) {
eff.auto.call(this,add,effect);
};
}
} }
this.game.addConstEffect({ this.game.addConstEffect({
source: this, source: this,
@ -1683,6 +1716,7 @@ Card.prototype.handleTrapAsyn = function(event) {
}).callback(this,function () { }).callback(this,function () {
if (!this.trap) return; if (!this.trap) return;
return this.game.blockAsyn(this,function () { return this.game.blockAsyn(this,function () {
this.player.onTrapTriggered.trigger();
return this.trap.actionAsyn.call(this,event); return this.trap.actionAsyn.call(this,event);
}) })
}).callback(this,function () { }).callback(this,function () {

File diff suppressed because it is too large Load diff

View file

@ -78,6 +78,7 @@ function Player (game,io,mainDeck,lrigDeck) {
this.onDoubleCrashed = new Timming(game); this.onDoubleCrashed = new Timming(game);
this.onDraw = new Timming(game); this.onDraw = new Timming(game);
this.onRemoveVirus = new Timming(game); this.onRemoveVirus = new Timming(game);
this.onTrapTriggered = new Timming(game);
// 附加属性 // 附加属性
this.skipGrowPhase = false; this.skipGrowPhase = false;
@ -2309,14 +2310,14 @@ Player.prototype.infectZoneAsyn = function() {
}); });
}; };
Player.prototype.setTrapFromDeckTopAsyn = function(count,max) { Player.prototype.setTrapFromDeckTopAsyn = function(count,max,forced) {
if (!isNum(max)) max = 1; if (!isNum(max)) max = 1;
var cards = this.mainDeck.getTopCards(count); var cards = this.mainDeck.getTopCards(count);
this.informCards(cards); this.informCards(cards);
var done = false; var done = false;
return Callback.loop(this,max,function () { return Callback.loop(this,max,function () {
if (done) return; if (done) return;
return this.selectOptionalAsyn('TARGET',cards).callback(this,function (card) { return this.selectAsyn('TARGET',cards,!forced).callback(this,function (card) {
if (!card) return done = true; if (!card) return done = true;
removeFromArr(card,cards); removeFromArr(card,cards);
return this.selectAsyn('TARGET',this.signiZones).callback(this,function (zone) { return this.selectAsyn('TARGET',this.signiZones).callback(this,function (zone) {
@ -2340,12 +2341,43 @@ Player.prototype.getTraps = function() {
}); });
}; };
Player.prototype.handleWisdomAuto = function(effect) { Player.prototype.handleEffectAsyn = function(effect) {
if (!effect.checkCondition()) return Callback.immediately();
var card = effect.source; var card = effect.source;
card.beSelectedAsTarget(); card.beSelectedAsTarget();
return card.player.opponent.showEffectsAsyn([effect]).callback(this,function () { return card.player.opponent.showEffectsAsyn([effect]).callback(this,function () {
return this.game.blockAsyn(card,function () { return this.game.blockAsyn(card,function () {
return effect.actionAsyn.call(effect.source); return effect.handleAsyn(false);
});
});
};
Player.prototype.addLifeCloth = function(count) {
if (!isNum(count)) count = 1;
var cards = this.mainDeck.getTopCards(count);
return this.game.moveCards(cards,this.lifeClothZone);
};
Player.prototype.pickCardsFromDeckTopAsyn = function(count,filter,max) {
if (!isNum(max)) max = 1;
var cards = this.mainDeck.getTopCards(count);
if (!cards.length) return;
var targets = cards.filter(filter);
return Callback.immediately().callback(this,function () {
if (!targets.length) return;
return this.selectSomeAsyn('ADD_TO_HAND',targets,0,max,false,cards).callback(this,function (targets) {
return this.opponent.showCardsAsyn(targets).callback(this,function () {
this.game.moveCards(targets,this.handZone);
cards = cards.filter(function (card) {
return !inArr(card,targets);
},this);
});
});
}).callback(this,function () {
var len = cards.length;
if (!len) return;
return this.selectSomeAsyn('SET_ORDER',cards,len,len,true).callback(this,function (cards) {
this.mainDeck.moveCardsToBottom(cards);
}); });
}); });
}; };