添加知情牌机制,辅助AI
This commit is contained in:
parent
bbcc7233a2
commit
f6b6f0f26c
|
@ -242,6 +242,17 @@ game.import('card',function(lib,game,ui,get,ai,_status){
|
||||||
target:function(player,target){
|
target:function(player,target){
|
||||||
if(target.hasSkill('huogong2')||target.countCards('h')==0) return 0;
|
if(target.hasSkill('huogong2')||target.countCards('h')==0) return 0;
|
||||||
if(player.countCards('h')<=1) return 0;
|
if(player.countCards('h')<=1) return 0;
|
||||||
|
if(_status.event.player == player){
|
||||||
|
if(target.isAllCardsKnown(player)){
|
||||||
|
if(!target.countCards('h',card=>{
|
||||||
|
return player.countCards('h',card2=>{
|
||||||
|
return get.suit(card2) == get.suit(card);
|
||||||
|
});
|
||||||
|
})){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if(target==player){
|
if(target==player){
|
||||||
if(typeof _status.event.filterCard=='function'&&
|
if(typeof _status.event.filterCard=='function'&&
|
||||||
_status.event.filterCard({name:'huogong'},player,_status.event)){
|
_status.event.filterCard({name:'huogong'},player,_status.event)){
|
||||||
|
|
108
game/game.js
108
game/game.js
|
@ -17968,10 +17968,12 @@
|
||||||
if(!event.chooseonly){
|
if(!event.chooseonly){
|
||||||
if(event.delay!==false){
|
if(event.delay!==false){
|
||||||
var next=player.gain(event.cards,target,event.visibleMove?'give':'giveAuto','bySelf');
|
var next=player.gain(event.cards,target,event.visibleMove?'give':'giveAuto','bySelf');
|
||||||
|
next.set('cardKnower',event.visibleMove?['everyone']:[target]);
|
||||||
event.done=next;
|
event.done=next;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
var next=player.gain(event.cards,target,'bySelf');
|
var next=player.gain(event.cards,target,'bySelf');
|
||||||
|
next.set('cardKnower',event.visibleMove?['everyone']:[target]);
|
||||||
event.done=next;
|
event.done=next;
|
||||||
target[event.visibleMove?'$give':'$giveAuto'](cards,player);
|
target[event.visibleMove?'$give':'$giveAuto'](cards,player);
|
||||||
if(event.visibleMove) next.visible=true;
|
if(event.visibleMove) next.visible=true;
|
||||||
|
@ -18048,6 +18050,7 @@
|
||||||
else{
|
else{
|
||||||
game.log(player,'展示了',cards);
|
game.log(player,'展示了',cards);
|
||||||
}
|
}
|
||||||
|
game.addCardKnowner(cards,'everyone');
|
||||||
game.delayx(event.delay_time||2.5);
|
game.delayx(event.delay_time||2.5);
|
||||||
game.addVideo('showCards',player,[event.str,get.cardsInfo(cards)]);
|
game.addVideo('showCards',player,[event.str,get.cardsInfo(cards)]);
|
||||||
"step 1"
|
"step 1"
|
||||||
|
@ -18056,6 +18059,7 @@
|
||||||
},
|
},
|
||||||
viewCards:function(){
|
viewCards:function(){
|
||||||
"step 0"
|
"step 0"
|
||||||
|
game.addCardKnowner(event.cards,player);
|
||||||
if(player==game.me){
|
if(player==game.me){
|
||||||
event.dialog=ui.create.dialog(event.str,event.cards);
|
event.dialog=ui.create.dialog(event.str,event.cards);
|
||||||
if(event.isMine()){
|
if(event.isMine()){
|
||||||
|
@ -19254,7 +19258,13 @@
|
||||||
for(var i in map){
|
for(var i in map){
|
||||||
var owner=(_status.connectMode?lib.playerOL:game.playerMap)[i];
|
var owner=(_status.connectMode?lib.playerOL:game.playerMap)[i];
|
||||||
var next=owner.lose(map[i][0],ui.special).set('type','gain').set('forceDie',true).set('getlx',false);
|
var next=owner.lose(map[i][0],ui.special).set('type','gain').set('forceDie',true).set('getlx',false);
|
||||||
if(event.visible==true) next.visible=true;
|
if(event.visible==true){
|
||||||
|
next.visible=true;
|
||||||
|
game.addCardKnowner(map[i][0],'everyone');
|
||||||
|
}else{
|
||||||
|
game.addCardKnowner(map[i][1],owner);
|
||||||
|
game.addCardKnowner(map[i][2],'everyone');
|
||||||
|
}
|
||||||
event.relatedLose=next;
|
event.relatedLose=next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19765,6 +19775,7 @@
|
||||||
event.js=js;
|
event.js=js;
|
||||||
event.ss=ss;
|
event.ss=ss;
|
||||||
event.xs=xs;
|
event.xs=xs;
|
||||||
|
game.clearCardKnowers(hs);
|
||||||
"step 2"
|
"step 2"
|
||||||
if(num<cards.length){
|
if(num<cards.length){
|
||||||
if(event.es.contains(cards[num])){
|
if(event.es.contains(cards[num])){
|
||||||
|
@ -20606,6 +20617,8 @@
|
||||||
for(i=0;i<bottom.length;i++){
|
for(i=0;i<bottom.length;i++){
|
||||||
ui.cardPile.appendChild(bottom[i]);
|
ui.cardPile.appendChild(bottom[i]);
|
||||||
}
|
}
|
||||||
|
game.addCardKnowner(top,player);
|
||||||
|
game.addCardKnowner(bottom,player);
|
||||||
player.popup(get.cnNumber(top.length)+'上'+get.cnNumber(bottom.length)+'下');
|
player.popup(get.cnNumber(top.length)+'上'+get.cnNumber(bottom.length)+'下');
|
||||||
game.log(player,'将'+get.cnNumber(top.length)+'张牌置于牌堆顶');
|
game.log(player,'将'+get.cnNumber(top.length)+'张牌置于牌堆顶');
|
||||||
game.updateRoundNumber();
|
game.updateRoundNumber();
|
||||||
|
@ -20969,6 +20982,32 @@
|
||||||
return get.is.shownCard(card);
|
return get.is.shownCard(card);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
//获取该角色被other所知的牌。
|
||||||
|
getKnownCards(other,filter){
|
||||||
|
if(!other)other = _status.event.player;
|
||||||
|
if(!other)other = this;
|
||||||
|
if(!filter)filter = (card)=>{return true};
|
||||||
|
return this.getCards('h',function(card){
|
||||||
|
return card.isKnownBy(other) && filter(card);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//判断此角色的手牌是否已经被看光了。
|
||||||
|
isAllCardsKnown(other){
|
||||||
|
if(!other)other = _status.event.player;
|
||||||
|
if(!other)other = this;
|
||||||
|
return this.countCards('h',function(card){
|
||||||
|
return !card.isKnownBy(other);
|
||||||
|
}) == 0;
|
||||||
|
}
|
||||||
|
//判断此角色是否有被知的牌。
|
||||||
|
hasKnownCards(other,filter){
|
||||||
|
if(!other)other = _status.event.player;
|
||||||
|
if(!other)other = this;
|
||||||
|
if(!filter)filter = (card)=>{return true};
|
||||||
|
return this.countCards('h',function(card){
|
||||||
|
return card.isKnownBy(other) && filter(card);
|
||||||
|
}) > 0;
|
||||||
|
}
|
||||||
//Execute the delay card effect
|
//Execute the delay card effect
|
||||||
//执行延时锦囊牌效果
|
//执行延时锦囊牌效果
|
||||||
executeDelayCardEffect(card,target,judge,judge2){
|
executeDelayCardEffect(card,target,judge,judge2){
|
||||||
|
@ -28286,8 +28325,13 @@
|
||||||
let cards,selected=get.copy(ui.selected.cards);
|
let cards,selected=get.copy(ui.selected.cards);
|
||||||
if(get.itemtype(ignore)==='cards') selected.addArray(ignore);
|
if(get.itemtype(ignore)==='cards') selected.addArray(ignore);
|
||||||
else if(get.itemtype(ignore)==='card') selected.add(ignore);
|
else if(get.itemtype(ignore)==='card') selected.add(ignore);
|
||||||
if(this===viewer||get.itemtype(viewer)==='player'&&viewer.hasSkillTag('viewHandcard',null,this,true)) cards=this.getCards('h');
|
/*if(this===viewer||get.itemtype(viewer)==='player'&&viewer.hasSkillTag('viewHandcard',null,this,true)) cards=this.getCards('h');
|
||||||
else cards=this.getShownCards();
|
else cards=this.getShownCards();*/
|
||||||
|
if(this === viewer || get.itemtype(viewer) == 'player'){
|
||||||
|
cards = this.getKnownCards(viewer);
|
||||||
|
}else{
|
||||||
|
cards = this.getShownCards();
|
||||||
|
}
|
||||||
if(cards.some(card=>{
|
if(cards.some(card=>{
|
||||||
if(selected.includes(card)) return false;
|
if(selected.includes(card)) return false;
|
||||||
let name=get.name(card,this);
|
let name=get.name(card,this);
|
||||||
|
@ -28308,8 +28352,13 @@
|
||||||
let cards,selected=get.copy(ui.selected.cards);
|
let cards,selected=get.copy(ui.selected.cards);
|
||||||
if(get.itemtype(ignore)==='cards') selected.addArray(ignore);
|
if(get.itemtype(ignore)==='cards') selected.addArray(ignore);
|
||||||
else if(get.itemtype(ignore)==='card') selected.add(ignore);
|
else if(get.itemtype(ignore)==='card') selected.add(ignore);
|
||||||
if(this===viewer||get.itemtype(viewer)==='player'&&viewer.hasSkillTag('viewHandcard',null,this,true)) cards=this.getCards('h');
|
/*if(this===viewer||get.itemtype(viewer)==='player'&&viewer.hasSkillTag('viewHandcard',null,this,true)) cards=this.getCards('h');
|
||||||
else cards=this.getShownCards();
|
else cards=this.getShownCards();*/
|
||||||
|
if(this === viewer || get.itemtype(viewer) == 'player'){
|
||||||
|
cards = this.getKnownCards(viewer);
|
||||||
|
}else{
|
||||||
|
cards = this.getShownCards();
|
||||||
|
}
|
||||||
if(cards.some(card=>{
|
if(cards.some(card=>{
|
||||||
if(selected.includes(card)) return false;
|
if(selected.includes(card)) return false;
|
||||||
let name=get.name(card,this);
|
let name=get.name(card,this);
|
||||||
|
@ -30432,6 +30481,41 @@
|
||||||
aiexclude(){
|
aiexclude(){
|
||||||
_status.event._aiexclude.add(this);
|
_status.event._aiexclude.add(this);
|
||||||
}
|
}
|
||||||
|
//为此牌添加知情者。参数可为数组,若参数为字符串'everyone',则所有玩家均为知情者。
|
||||||
|
addKnowner(player){
|
||||||
|
if(!this._knowers){
|
||||||
|
this._knowers = [];
|
||||||
|
}
|
||||||
|
if(typeof player == 'string'){
|
||||||
|
this._knowers.add(player);
|
||||||
|
}else{
|
||||||
|
let type = get.itemtype(player);
|
||||||
|
if(type == 'player'){
|
||||||
|
this._knowers.add(player.playerid);
|
||||||
|
}else if(type == 'players'){
|
||||||
|
player.forEach(p=>this._knowers.add(p.playerid));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//清除此牌的知情者。
|
||||||
|
clearKnowers(){
|
||||||
|
if(this._knowers)delete this._knowers;
|
||||||
|
}
|
||||||
|
//判断玩家对此牌是否知情。
|
||||||
|
isKnownBy(player){
|
||||||
|
if(['e','j'].includes(get.position(this)))return true;//装备区或者判定区的牌,必知情。
|
||||||
|
let owner = get.owner(this);
|
||||||
|
if(owner){
|
||||||
|
if(owner == player)return true;//是牌主,必知情。
|
||||||
|
if(player.hasSkillTag('viewHandcard',null,owner,true))return true;//有viewHandcard标签,必知情。
|
||||||
|
if(owner.isUnderControl(true,player))return true;//被操控,必知情。
|
||||||
|
}
|
||||||
|
if(get.is.shownCard(this))return true;//此牌是明置牌,必知情。
|
||||||
|
if(this._knowers){
|
||||||
|
return this._knowers.includes('everyone') || this._knowers.includes(player.playerid);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
getSource(name){
|
getSource(name){
|
||||||
if(this.name==name) return true;
|
if(this.name==name) return true;
|
||||||
var info=lib.card[this.name];
|
var info=lib.card[this.name];
|
||||||
|
@ -36059,6 +36143,20 @@
|
||||||
if(i.storage.renku) i.markSkill('renku');
|
if(i.storage.renku) i.markSkill('renku');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
//为牌添加知情者。
|
||||||
|
addCardKnowner:function(cards,players){
|
||||||
|
if(get.itemtype(cards) == 'card'){
|
||||||
|
cards = [cards];
|
||||||
|
}
|
||||||
|
cards.forEach(card=>card.addKnowner(players));
|
||||||
|
},
|
||||||
|
//移除牌的所有知情者。
|
||||||
|
clearCardKnowers:function(cards){
|
||||||
|
if(get.itemtype(cards) == 'card'){
|
||||||
|
cards = [cards];
|
||||||
|
}
|
||||||
|
cards.forEach(card=>card.clearKnowers());
|
||||||
|
},
|
||||||
loseAsync:function(arg){
|
loseAsync:function(arg){
|
||||||
var next=game.createEvent('loseAsync');
|
var next=game.createEvent('loseAsync');
|
||||||
next.forceDie=true;
|
next.forceDie=true;
|
||||||
|
|
Loading…
Reference in New Issue