身份牌实例

This commit is contained in:
Spmario233 2023-10-17 22:34:02 +08:00
parent dad974625e
commit 89186ff31b
9 changed files with 89 additions and 255 deletions

View File

@ -130,6 +130,11 @@ game.import('character',function(lib,game,ui,get,ai,_status){
return '';
}).join('、')}`,
},
$createButton:function(item,type,position,noclick,node){
node=ui.create.identityCard(item,position,null,noclick);
node.link=item;
return node;
},
subSkill:{
show:{
audio:'jxlianpo',
@ -140,66 +145,18 @@ game.import('character',function(lib,game,ui,get,ai,_status){
return list.length;
},
forced:true,
content:function*(event,map){
var player=map.player,trigger=map.trigger;
content:function(){
'step 0'
var list=lib.config.mode_config.identity.identity.lastItem.slice();
list.removeArray(game.filterPlayer().map(i=>i.identity)).unique();
var chooseControl=function(player,list){
var event=_status.event;
player=player||event.player;
var controls=[];
if(!event._result) event._result={};
Promise.all(list.map(identity=>new Promise((resolve,reject)=>{
var imageName=`mougong_${identity}`;
var pth=(`${lib.assetURL}image/card/${imageName}.jpg`);
var image=new Image();
image.onload=()=>resolve(pth);
image.onerror=reject;
image.src=pth;
}))).then(paths=>{
controls.addArray(paths.map(path=>{
return `<img src="${lib.assetURL+path}" width="65" height="93" draggable="false"></img>`;
}));
}).catch(()=>{
controls.addArray(list.map(i=>i+'2'));
}).then(()=>{
var dialog=ui.create.dialog('###炼魄:请选择一个身份###<div class="text center">你选择的身份对应的阵营角色数于本轮内视为+1</div>');
var controlsx=[];
for(var control of controls){
controlsx.push(ui.create.control(control,function(link){
event._result.index=controls.indexOf(link);
dialog.close();
controlsx.forEach(control=>control.close());
_status.imchoosing=false;
game.resume();
}));
}
event.switchToAuto=function(){
event._result={index:get.rand(controls.length)};
dialog.close();
control.close();
_status.imchoosing=false;
game.resume();
};
});
game.pause();
game.countChoose();
}
if(event.isMine()){
chooseControl(player,list);
}
else if(event.isOnline()){
event.player.send(chooseControl,event.player,list);
event.player.wait();
game.pause();
}
else{
event._result={index:get.rand(list.length)};
_status.imchoosing=false;
}
yield null;
var index=event[event.result&&typeof event.result.index=='number'?'result':'_result'].index;
var choice=list[index],mark=`jxlianpo_mark_${choice}`;
player.chooseButton([
'###炼魄:请选择一个身份###<div class="text center">你选择的身份对应的阵营角色数于本轮内视为+1</div>',
[list,function(item,type,position,noclick,node){
return lib.skill.jxlianpo.$createButton(item,type,position,noclick,node);
}],
])
'step 1'
var choice=result.links[0],mark=`jxlianpo_mark_${choice}`;
player.when({global:'roundStart'})
.assign({
firstDo:true,
@ -215,32 +172,18 @@ game.import('character',function(lib,game,ui,get,ai,_status){
player.addMark(mark,1,false);
var videoId=lib.status.videoId++;
var createDialog=function(player,identity,id){
var dialog=ui.create.dialog(`${get.translation(player)}展示了${get.translation(identity+'2')}身份牌<br>`,'forcebutton');
var dialog=ui.create.dialog(`${get.translation(player)}展示了${get.translation(identity+'2')}”的身份牌<br>`,'forcebutton');
dialog.videoId=id;
new Promise((resolve,reject)=>{
var imageName=`mougong_${identity}`;
var pth=(`${lib.assetURL}image/card/${imageName}.jpg`);
var image=new Image();
image.onload=()=>resolve(pth);
image.onerror=reject;
image.src=pth;
}).then(pth=>{
var img=document.createElement('img');
dialog.content.appendChild(img);
img.setAttribute('src',pth);
img.setAttribute('width','130');
img.setAttribute('height','185');
img.setAttribute('draggable',false);
dialog.open();
}).catch(()=>{});
ui.create.spinningIdentityCard(identity,dialog);
};
game.broadcastAll(createDialog,player,choice,videoId);
var color='';
if(choice=='zhong') color='#y';
else if(choice=='fan') color='#g';
else if(choice=='nei') color='#b';
game.log(player,'展示了',`${color}${get.translation(choice+'2')}`,'身份牌');
yield game.delay(2);
game.log(player,'展示了',`${color}${get.translation(choice+'2')}`,'的身份牌');
game.delay(3);
'step 2'
game.broadcastAll('closeDialog',videoId);
}
},
@ -337,6 +280,7 @@ game.import('character',function(lib,game,ui,get,ai,_status){
var bodies=_status.event.player.getStorage('jxzhaoluan_effect').filter(i=>i.isIn());
return `选择一名角色,你令${get.translation(bodies)}${bodies.length>1?'中的一人':''}减1点体力上限然后你对选择的角色造成1点伤害。`;
},
delay:false,
content:function(){
'step 0'
var bodies=player.getStorage('jxzhaoluan_effect').filter(i=>i.isIn());

View File

@ -42556,6 +42556,70 @@
void window.getComputedStyle(node, null).getPropertyValue("opacity");
},
create:{
//创建身份牌实例
identityCard:function(identity,position,info,noclick){
const card=ui.create.card(position,info,noclick);
card._customintro=function(uiintro){
uiintro.add(`${get.translation(item+2)}的身份牌`);
}
const fileName=`image/card/identity_${identity}.jpg`;
new Promise((resolve,reject)=>{
const image=new Image();
image.onload=()=>resolve();
image.onerror=reject;
image.src=`${lib.assetURL}${fileName}`;
}).then(()=>{
card.classList.add('fullskin');
card.node.image.setBackgroundImage(fileName);
}).catch(()=>{
card.node.background.innerHTML=get.translation(identity)[0];
});
return card;
},
//让卡牌旋转
cardSpinning:function(card){
if(lib.config.cardback_style!='default'){
card.style.transitionProperty='none';
ui.refresh(card);
card.classList.add('infohidden');
ui.refresh(card);
card.style.transitionProperty='';
}
else{
card.classList.add('infohidden');
}
card.style.transition='all 0s';
card.style.transform='perspective(600px) rotateY(180deg) translateX(0)';
const onEnd01=function(){
setTimeout(function(){
card.style.transition='all ease-in 0.3s';
card.style.transform='perspective(600px) rotateY(270deg) translateX(52px)';
var onEnd=function(){
card.classList.remove('infohidden');
card.style.transition='all 0s';
ui.refresh(card);
card.style.transform='perspective(600px) rotateY(-90deg) translateX(52px)';
ui.refresh(card);
card.style.transition='';
ui.refresh(card);
card.style.transform='';
}
card.listenTransition(onEnd);
},300);
};
onEnd01();
},
//旋转的身份牌!
spinningIdentityCard:function(identity,dialog){
const card=ui.create.identityCard(identity);
const buttons=ui.create.div('.buttons',dialog.content);
buttons.appendChild(card);
setTimeout(()=>{
buttons.appendChild(card);
dialog.open();
ui.create.cardSpinning(card,time);
},50);
},
/**
* 创建codemirror编辑器
* @param {HTMLDivElement} container

View File

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

View File

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

View File

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

View File

@ -2997,62 +2997,10 @@ game.import('mode',function(lib,game,ui,get,ai,_status){
event.dongcha_result=res;
event.videoId=lib.status.videoId++;
var send=(target,res,id)=>{
var str=get.translation(target)+'是'+get.translation(res+'2')+'<br>';
var dialog=ui.create.dialog(str,'forcebutton');
var card=ui.create.card();
var buttons=ui.create.div('.buttons',dialog.content);
buttons.appendChild(card);
new Promise((resolve)=>{
var imageName=`mougong_${res}`;
resolve(`${lib.assetURL}image/card/${imageName}.jpg`);
}).then(pth=>{
return new Promise((resolve,reject)=>{
var image=new Image();
image.onload=()=>resolve(pth);
image.onerror=reject;
image.src=pth;
}).then(image=>{
card.classList.add('fullskin');
card.node.image.setBackgroundImage(image);
}).catch(()=>{
card.node.background.innerHTML=get.translation(res)[0];
});
}).then(()=>{
if(lib.config.cardback_style!='default'){
card.style.transitionProperty='none';
ui.refresh(card);
card.classList.add('infohidden');
ui.refresh(card);
card.style.transitionProperty='';
}
else{
card.classList.add('infohidden');
}
buttons.appendChild(card);
card.style.transition='all 0s';
card.style.transform='perspective(600px) rotateY(180deg) translateX(0)';
dialog.open();
var onEnd01=function(){
setTimeout(function(){
card.style.transition='all ease-in 0.3s';
card.style.transform='perspective(600px) rotateY(270deg) translateX(52px)';
var onEnd=function(){
card.classList.remove('infohidden');
card.style.transition='all 0s';
ui.refresh(card);
card.style.transform='perspective(600px) rotateY(-90deg) translateX(52px)';
ui.refresh(card);
card.style.transition='';
ui.refresh(card);
card.style.transform='';
}
card.listenTransition(onEnd);
},300);
};
onEnd01();
});
ui.create.spinningIdentityCard(res,dialog);
var control=ui.create.control('ok',()=>{
dialog.close();
control.close();
@ -3104,58 +3052,7 @@ game.import('mode',function(lib,game,ui,get,ai,_status){
var str=get.translation(target)+'是反贼<br>';
event.videoId=lib.status.videoId++;
var dialog=ui.create.dialog(str,'forcebutton');
var card=ui.create.card();
var buttons=ui.create.div('.buttons',dialog.content);
buttons.appendChild(card);
new Promise((resolve)=>{
var imageName=`mougong_fan`;
resolve(`${lib.assetURL}image/card/${imageName}.jpg`);
}).then(pth=>{
return new Promise((resolve,reject)=>{
var image=new Image();
image.onload=()=>resolve(pth);
image.onerror=reject;
image.src=pth;
}).then(image=>{
card.classList.add('fullskin');
card.node.image.setBackgroundImage(image);
}).catch(()=>{
card.node.background.innerHTML='反';
});
}).then(()=>{
if(lib.config.cardback_style!='default'){
card.style.transitionProperty='none';
ui.refresh(card);
card.classList.add('infohidden');
ui.refresh(card);
card.style.transitionProperty='';
}
else{
card.classList.add('infohidden');
}
buttons.appendChild(card);
dialog.open();
card.style.transition='all 0s';
card.style.transform='perspective(600px) rotateY(180deg) translateX(0)';
var onEnd01=function(){
setTimeout(function(){
card.style.transition='all ease-in 0.3s';
card.style.transform='perspective(600px) rotateY(270deg) translateX(52px)';
var onEnd=function(){
card.classList.remove('infohidden');
card.style.transition='all 0s';
ui.refresh(card);
card.style.transform='perspective(600px) rotateY(-90deg) translateX(52px)';
ui.refresh(card);
card.style.transition='';
ui.refresh(card);
card.style.transform='';
}
card.listenTransition(onEnd);
},300);
};
onEnd01();
});
ui.create.spinningIdentityCard('fan',dialog);
dialog.videoId=event.videoId;
game.me.chooseControl('ok').set('dialog',dialog);
}
@ -3176,58 +3073,7 @@ game.import('mode',function(lib,game,ui,get,ai,_status){
if(!game.me.storage.zhibi.contains(target)) game.me.storage.zhibi.push(target);
var str=get.translation(target)+'是反贼<br>';
var dialog=ui.create.dialog(str,'forcebutton');
var card=ui.create.card();
var buttons=ui.create.div('.buttons',dialog.content);
buttons.appendChild(card);
new Promise((resolve)=>{
var imageName=`mougong_fan`;
resolve(`${lib.assetURL}image/card/${imageName}.jpg`);
}).then(pth=>{
return new Promise((resolve,reject)=>{
var image=new Image();
image.onload=()=>resolve(pth);
image.onerror=reject;
image.src=pth;
}).then(image=>{
card.classList.add('fullskin');
card.node.image.setBackgroundImage(image);
}).catch(()=>{
card.node.background.innerHTML='反';
});
}).then(()=>{
if(lib.config.cardback_style!='default'){
card.style.transitionProperty='none';
ui.refresh(card);
card.classList.add('infohidden');
ui.refresh(card);
card.style.transitionProperty='';
}
else{
card.classList.add('infohidden');
}
buttons.appendChild(card);
dialog.open();
card.style.transition='all 0s';
card.style.transform='perspective(600px) rotateY(180deg) translateX(0)';
var onEnd01=function(){
setTimeout(function(){
card.style.transition='all ease-in 0.3s';
card.style.transform='perspective(600px) rotateY(270deg) translateX(52px)';
var onEnd=function(){
card.classList.remove('infohidden');
card.style.transition='all 0s';
ui.refresh(card);
card.style.transform='perspective(600px) rotateY(-90deg) translateX(52px)';
ui.refresh(card);
card.style.transition='';
ui.refresh(card);
card.style.transform='';
}
card.listenTransition(onEnd);
},300);
};
onEnd01();
});
ui.create.spinningIdentityCard('fan',dialog);
dialog.videoId=id;
game.me.chooseControl('ok').set('dialog',dialog);
}
@ -3263,27 +3109,7 @@ game.import('mode',function(lib,game,ui,get,ai,_status){
if(game.me.identity=='nei'){
var str=get.translation(target)+'是反贼<br>';
var dialog=ui.create.dialog(str,'forcebutton');
new Promise((resolve)=>{
var imageName=`mougong_fan`;
resolve(`${lib.assetURL}image/card/${imageName}.jpg`);
}).then(pth=>new Promise((resolve,reject)=>{
var image=new Image();
image.onload=()=>resolve(pth);
image.onerror=reject;
image.src=pth;
})).then(image=>{
var img=document.createElement('img');
dialog.content.appendChild(img);
img.setAttribute('src',image);
img.setAttribute('width','106');
img.setAttribute('height','150');
img.setAttribute('draggable',false);
img.style.transition='all 2s';
setTimeout(function(){
img.style.transform='rotateY(360deg)';
},300);
dialog.open();
}).catch(()=>{});
ui.create.spinningIdentityCard('fan',dialog);
dialog.videoId=event.videoId;
game.me.chooseControl('ok').set('dialog',dialog);
game.me.wait();