forked from mirrors/webxoss-core
Improve player.getCard()
This commit is contained in:
parent
86e7897f62
commit
890a54d1ad
1 changed files with 24 additions and 29 deletions
41
Player.js
41
Player.js
|
@ -2162,48 +2162,43 @@ Player.prototype.setCrossPair = function () {
|
|||
|
||||
|
||||
// For test:
|
||||
Player.prototype.getCard = function (cid) {
|
||||
if (isStr(cid)) {
|
||||
Player.prototype.matchCard = function (arg) {
|
||||
var cid = 0;
|
||||
for (var i = 0; i < this.game.cards.length; i++) {
|
||||
var card = this.game.cards[i];
|
||||
if (CardInfo[card.cid].name_zh_CN === cid) {
|
||||
var info = CardInfo[card.cid];
|
||||
var matched = info.name === arg ||
|
||||
info.name_zh_CN === arg ||
|
||||
info.cid === arg ||
|
||||
info.wxid === arg;
|
||||
if (matched) {
|
||||
cid = card.cid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isStr(cid)) return null;
|
||||
}
|
||||
if (!cid) return null;
|
||||
var cards = concat(this.mainDeck.cards,this.trashZone.cards,this.enerZone.cards,this.lifeClothZone.cards);
|
||||
for (var i = 0; i < cards.length; i++) {
|
||||
var card = cards[i];
|
||||
if (card.cid === cid) {
|
||||
card.moveTo(this.handZone);
|
||||
return card;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
Player.prototype.getCard = function (arg) {
|
||||
var card = this.matchCard(arg);
|
||||
if (!card) return null;
|
||||
card.moveTo(this.handZone);
|
||||
return card;
|
||||
};
|
||||
|
||||
Player.prototype.putCardToLifeCloth = function (cid) {
|
||||
if (isStr(cid)) {
|
||||
for (var i = 0; i < this.game.cards.length; i++) {
|
||||
var card = this.game.cards[i];
|
||||
if (CardInfo[card.cid].name_zh_CN === cid) {
|
||||
cid = card.cid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isStr(cid)) return null;
|
||||
}
|
||||
var cards = concat(this.mainDeck.cards,this.trashZone.cards,this.enerZone.cards,this.hands,this.signis);
|
||||
for (var i = 0; i < cards.length; i++) {
|
||||
var card = cards[i];
|
||||
if (card.cid === cid) {
|
||||
var card = this.matchCard(arg);
|
||||
if (!card) return null;
|
||||
card.moveTo(this.lifeClothZone);
|
||||
return card;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
global.Player = Player;
|
Loading…
Reference in a new issue