▭ | 暂停'
},
setPopped:function(node,func,width,height){
node._poppedfunc=func;
node._poppedwidth=width;
node._poppedheight=height;
node.addEventListener(lib.config.touchscreen?'touchstart':'mouseenter',ui.click.hoverpopped);
},
placePoppedDialog:function(dialog,e){
if(e.touches&&e.touches[0]){
e=e.touches[0];
}
dialog.style.height=Math.min(ui.window.offsetHeight-20,dialog.content.scrollHeight)+'px';
if(e.clientXui.window.offsetHeight){
idealtop=ui.window.offsetHeight-10-dialog.offsetHeight;
}
dialog.style.top=idealtop+'px';
},
setHover:function(node,func,hoveration,width){
node._hoverfunc=func;
if(typeof hoveration=='number'){
node._hoveration=hoveration;
}
if(typeof width=='number'){
node._hoverwidth=width
}
node.addEventListener('mouseenter',ui.click.mouseenter);
node.addEventListener('mouseleave',ui.click.mouseleave);
node.addEventListener('mousedown',ui.click.mousedown);
node.addEventListener('mousemove',ui.click.mousemove);
return node;
},
setLongPress:function(node,func){
node.addEventListener('touchstart',ui.click.longpressdown);
node.addEventListener('touchend',ui.click.longpresscancel);
// node.addEventListener('mouseleave',ui.click.longpresscancel);
node._longpresscallback=func;
return node;
},
updateCanvas:function(time){
if(lib.canvasUpdates.length===0){
lib.status.canvas=false;
return false;
}
ui.canvas.width=ui.arena.offsetWidth;
ui.canvas.height=ui.arena.offsetHeight;
var ctx=ui.ctx;
ctx.shadowBlur=5;
ctx.shadowColor='rgba(0,0,0,0.3)';
ctx.strokeStyle='white';
// ctx.lineCap='round';
ctx.lineWidth=3;
ctx.save();
for(var i=0;i>6, 0x80 | cc&0x3f);
});
strUtf = strUtf.replace(
/[\u0800-\uffff]/g,function(c) {
var cc = c.charCodeAt(0);
return String.fromCharCode(0xe0 | cc>>12, 0x80 | cc>>6&0x3F, 0x80 | cc&0x3f);
});
return btoa(strUtf);
},
decode:function(str){
var strUtf=atob(str);
var strUni = strUtf.replace(
/[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g,function(c) {
var cc = ((c.charCodeAt(0)&0x0f)<<12) | ((c.charCodeAt(1)&0x3f)<<6) | ( c.charCodeAt(2)&0x3f);
return String.fromCharCode(cc);
});
strUni = strUni.replace(
/[\u00c0-\u00df][\u0080-\u00bf]/g,function(c){
var cc = (c.charCodeAt(0)&0x1f)<<6 | c.charCodeAt(1)&0x3f;
return String.fromCharCode(cc);
});
return strUni;
}
},
translate:{
'default':"默认",
zhenfa:'阵法',
heart:"♥︎",
diamond:"♦︎",
spade:"♠︎",
club:"♣︎",
ghujia:'护甲',
ghujia_bg:'甲',
heart2:"红桃",
diamond2:"方片",
spade2:"黑桃",
club2:"梅花",
red:'红色',
black:'黑色',
ok:"确定",
cancel:"取消",
restart:"重新开始",
setting:"设置",
start:"开始",
random:"随机",
_phasebegin:'回合开始',
_out:'无效',
agree:'同意',
refuse:'拒绝',
fire:"火",
thunder:"雷",
poison:"毒",
wei:'魏',
shu:'蜀',
wu:'吴',
qun:'群',
male:'男',
female:'女',
mad:'混乱',
mad_bg:'疯',
draw_card:'摸牌',
discard_card:'弃牌',
reset_character:'重置武将牌',
recover_hp:'回复体力',
lose_hp:'流失体力',
get_damage:'受伤害',
weiColor:"#b0d0e2",
shuColor:"#ffddb9",
wuColor:"#b2d9a9",
qunColor:"#f6f6f6",
basic:'基本',
equip:'装备',
trick:'锦囊',
delay:'延迟锦囊',
character:'角色',
revive:'复活',
equip1:'武器',
equip2:'防具',
equip3:'防御马',
equip4:'攻击马',
equip5:'宝物',
zero:'零',
one:'一',
two:'二',
three:'三',
four:'四',
five:'五',
six:'六',
seven:'七',
eight:'八',
nine:'九',
ten:'十',
},
element:{
playerproto:{
phase:function(){
"step 0"
player.phaseJudge();
"step 1"
player.phaseDraw();
game.delay();
"step 2"
player.phaseUse();
"step 3"
player.phaseDiscard()
game.delay();
},
phaseJudge:function(){
"step 0"
if(player.node.judges.childElementCount){
event.card=player.node.judges.firstChild;
player.lose(event.card);
player.$phaseJudge(event.card);
event.cancelled=false;
event.trigger('phaseJudge');
}
else event.finish();
"step 1"
if(!event.cancelled) player.judge(event.card);
"step 2"
var name=event.card.viewAs||event.card.name;
if(event.cancelled&&!event.direct){
if(lib.card[name].cancel){
var next=game.createEvent(name+'Cancelled');
next.content=lib.card[name].cancel;
next.card=event.card;
next.player=player;
}
}
else{
var next=game.createEvent(name);
next.content=lib.card[name].effect;
next._result=result;
next.card=event.card;
next.player=player;
}
ui.clear();
event.goto(0);
},
phaseDraw:function(){
player.draw(event.num);
},
phaseUse:function(){
"step 0";
player.chooseToUse();
"step 1"
if(result.bool){
event.goto(0);
}
},
phaseDiscard:function(){
"step 0"
event.num=player.num('h')-game.checkMod(player,player.hp,'maxHandcard',player.get('s'));
if(event.num<=0) event.finish();
event.trigger('phaseDiscard');
"step 1"
player.chooseToDiscard(num,true);
"step 2"
event.cards=result.cards;
},
chooseToUse:function(){
"step 0"
var ok=game.check();
if(event.isMine()){
if(!ok||!lib.config.auto_confirm){
game.pause();
}
if(typeof event.prompt=='string'){
if(!ok) event.dialog=ui.create.dialog(event.prompt);
}
else if(event.prompt=='function'){
if(!ok) event.dialog=ui.create.dialog(event.prompt(event));
}
else if(event.prompt==undefined){
var str;
if(typeof event.filterCard=='object'){
str='请使用'+get.cnNumber(event.selectCard[0])+'张'
if(filter.name){
str+=get.translation(filter.name);
}
else{
str+='牌';
}
}
else{
str='请选择要使用的牌';
}
if(!ok){
if(event.openskilldialog){
event.skillDialog=ui.create.dialog(event.openskilldialog);
delete event.openskilldialog;
event.dialog=str;
}
else if(typeof event.skillDialog!='string'){
event.dialog=ui.create.dialog(str);
}
else{
event.dialog=str;
}
}
}
}
else{
if(ok){
ui.click.ok();
}
else if(ai.basic.chooseCard(event.ai1)){
if(ai.basic.chooseTarget(event.ai2)){
ui.click.ok();
_status.event.aiexclude.length=0;
}
else{
if(event.skill){
var skill=event.skill;
ui.click.cancel();
event.aiexclude.add(skill);
}
else{
get.card().aiexclude();
game.uncheck();
}
event.redo();
game.resume();
}
}
else if(event.skill){
var skill=event.skill;
ui.click.cancel();
event.aiexclude.add(skill);
event.redo();
game.resume();
}
else{
ui.click.cancel();
}
}
"step 1"
if(event.skillDialog&&get.objtype(event.skillDialog)=='div'){
event.skillDialog.close();
}
if(event.result.bool){
if(event.result.card||!event.result.skill){
player.useCard(event.result.card,event.result.cards,event.result.targets,event.result.skill);
}
else if(event.result.skill){
player.useSkill(event.result.skill,event.result.cards,event.result.targets);
}
}
if(event.dialog&&typeof event.dialog=='object') event.dialog.close();
},
chooseToRespond:function(){
"step 0"
if(event.responded){
delete event.dialog;
return;
}
if(event.autochoose&&event.autochoose()){
event.result={bool:false};
}
else{
game.check();
if(event.isMine()){
game.pause();
if(event.dialog) event.dialog=ui.create.dialog(event.dialog);
}
else{
if(ai.basic.chooseCard(event.ai)||forced){
ui.click.ok();
}
else if(event.skill){
var skill=event.skill;
ui.click.cancel();
event.aiexclude.add(skill);
event.redo();
game.resume();
}
else{
ui.click.cancel();
}
}
}
"step 1"
if(event.result.bool){
player.respond(event.result.cards,event.result.card,event.animate,event.result.skill,event.source);
}
if(event.dialog&&event.dialog.close) event.dialog.close();
},
chooseToDiscard:function(){
"step 0"
if(event.autochoose()){
event.result={
bool:true,
cards:player.get(event.position||'h')
}
}
else{
var range=get.select(event.selectCard);
game.check();
if(event.isMine()){
game.pause();
if(range[1]>1){
event.promptdiscard=ui.create.control('提示',function(){
ai.basic.chooseCard(event.ai);
if(_status.event.custom.add.card){
_status.event.custom.add.card();
}
});
}
if(event.prompt!=false){
var str;
if(typeof(event.prompt)=='string') str=event.prompt;
else{
str='请弃置';
if(range[0]==range[1]) str+=get.cnNumber(range[0]);
else if(range[1]==Infinity) str+='至少'+get.cnNumber(range[0]);
else str+=get.cnNumber(range[0])+'至'+get.cnNumber(range[1]);
str+='张';
if(event.position=='h'||event.position==undefined) str+='手';
if(event.position=='e') str+='装备';
str+='牌';
}
event.dialog=ui.create.dialog(str);
event.dialog.add('0/'+event.selectCard[1]);
event.custom.add.card=function(){
_status.event.dialog.content.childNodes[1].innerHTML=
ui.selected.cards.length+'/'+_status.event.selectCard[1];
}
}
else if(get.itemtype(event.dialog)=='dialog'){
event.dialog.style.display='';
event.dialog.open();
}
}
else{
if(ai.basic.chooseCard(event.ai)||forced){
ui.click.ok();
}
else if(event.skill){
var skill=event.skill;
ui.click.cancel();
event.aiexclude.add(skill);
event.redo();
game.resume();
}
else{
ui.click.cancel();
}
}
}
"step 1"
if(event.promptdiscard){
event.promptdiscard.close();
}
player.discard(event.result.cards);
if(event.dialog) event.dialog.close();
},
chooseToCompare:function(){
"step 0"
if(player.num('h')==0||target.num('h')==0){
event.result={cancelled:true,bool:false}
event.finish();
return;
}
game.log(get.translation(player)+'对'+get.translation(target)+'发起拼点');
player.chooseCard('请选择拼点牌',true).ai=event.ai;
"step 1"
event.card1=result.cards[0];
target.chooseCard('请选择拼点牌',true).ai=event.ai;
"step 2"
event.card2=result.cards[0];
if(event.card2.number>=10||event.card2.number<=4){
if(target.num('h')>2){
event.addToAI=true;
}
}
player.lose(event.card1);
target.lose(event.card2);
"step 3"
player.$compare(event.card1,target,event.card2);
// player.$throw(event.card1);
// target.$throw(event.card2);
game.log(get.translation(player)+'的拼点牌为'+get.translation(event.card1));
game.log(get.translation(target)+'的拼点牌为'+get.translation(event.card2));
event.result={
player:event.card1,
target:event.card2,
}
if(get.number(event.card1)>get.number(event.card2)){
event.result.bool=true;
setTimeout(function(){
event.dialog=ui.create.dialog(get.translation(player.name)+'拼点成功');
event.dialog.classList.add('center');
player.popup('胜');
target.popup('负');
game.resume();
},1500);
}
else{
event.result.bool=false;
if(get.number(event.card1)>get.number(event.card2)){
event.result.tie=true;
setTimeout(function(){
event.dialog=ui.create.dialog(get.translation(player.name)+'拼点失败');
event.dialog.classList.add('center');
player.popup('平');
target.popup('平');
game.resume();
},1500);
}
else{
setTimeout(function(){
event.dialog=ui.create.dialog(get.translation(player.name)+'拼点失败');
event.dialog.classList.add('center');
player.popup('负');
target.popup('胜');
game.resume();
},1500);
}
}
game.pause();
"step 4"
game.delay(2);
"step 5"
if(typeof event.target.ai.shown=='number'&&event.target.ai.shown<=0.85&&event.addToAI){
event.target.ai.shown+=0.1;
}
if(event.clear!==false) ui.clear();
event.dialog.close();
},
chooseButton:function(){
"step 0"
if(event.dialog==undefined) event.dialog=ui.dialog;
if(event.isMine()){
event.dialog.style.display='';
event.dialog.open();
}
game.check();
if(event.isMine()){
game.pause();
}
else{
if(ai.basic.chooseButton(event.ai)||forced) ui.click.ok();
else ui.click.cancel();
}
"step 1"
if(event.closeDialog){
event.dialog.close();
}
},
chooseCard:function(){
"step 0"
game.check();
if(event.isMine()){
game.pause();
if(event.prompt!=false){
var str;
if(typeof event.prompt=='string') str=event.prompt;
else{
str='请选择'
var range=get.select(event.selectCard);
if(range[0]==range[1]) str+=get.cnNumber(range[0]);
else if(range[1]==Infinity) str+='至少'+get.cnNumber(range[0]);
else str+=get.cnNumber(range[0])+'至'+get.cnNumber(range[1]);
str+='张';
if(event.position=='h'||event.position==undefined) str+='手';
if(event.position=='e') str+='装备';
str+='牌';
}
event.dialog=ui.create.dialog(str);
event.dialog.add('0/'+event.selectCard[1]);
event.custom.add.card=function(){
_status.event.dialog.content.childNodes[1].innerHTML=
ui.selected.cards.length+'/'+_status.event.selectCard[1];
}
}
}
else{
if(ai.basic.chooseCard(event.ai)||forced){
ui.click.ok();
}
else if(event.skill){
var skill=event.skill;
ui.click.cancel();
event.aiexclude.add(skill);
event.redo();
game.resume();
}
else{
ui.click.cancel();
}
}
"step 1"
if(event.dialog) event.dialog.close();
},
chooseTarget:function(){
"step 0"
game.check();
if(event.isMine()){
game.pause();
if(event.prompt!=false){
var str;
if(typeof event.prompt=='string') str=event.prompt;
else{
str='请选择'
var range=get.select(event.selectTarget);
if(range[0]==range[1]) str+=get.cnNumber(range[0]);
else if(range[1]==Infinity) str+='至少'+get.cnNumber(range[0]);
else str+=get.cnNumber(range[0])+'至'+get.cnNumber(range[1]);
str+='个目标';
}
event.dialog=ui.create.dialog(str);
event.dialog.add('0/'+event.selectTarget[1]);
event.custom.add.target=function(){
_status.event.dialog.content.childNodes[1].innerHTML=
ui.selected.targets.length+'/'+_status.event.selectTarget[1];
}
}
else if(get.itemtype(event.dialog)=='dialog'){
event.dialog.open();
}
}
else{
if(ai.basic.chooseTarget(event.ai)||forced){
ui.click.ok();
}
else{
ui.click.cancel();
}
}
"step 1"
if(event.result.bool){
for(var i=0;i1&&!get.info(card).multiline){
player.line2(targets,config);
}
else{
player.line(targets,config);
}
}
player.$throw(cards);
}
event.trigger('useCard');
if(get.type(card)!='equip'){
var str=get.translation(player);
if(targets.length){
str+='对'+(targets[0]==player?'自己':get.translation(targets[0]));
for(var i=1;i1||cards[0]!=card)){
str+='('+get.translation(cards)+')';
}
game.log(str);
}
if(event.addCount!=false){
if(player.stat[player.stat.length-1].card[card.name]==undefined){
player.stat[player.stat.length-1].card[card.name]=1;
}
else{
player.stat[player.stat.length-1].card[card.name]++;
}
if(event.skill){
if(player.stat[player.stat.length-1].skill[event.skill]==undefined){
player.stat[player.stat.length-1].skill[event.skill]=1;
}
else{
player.stat[player.stat.length-1].skill[event.skill]++;
}
}
}
"step 1"
if(get.info(card).contentBefore){
var next=game.createEvent(card.name+'ContentBefore');
next.content=get.info(card).contentBefore;
next.targets=targets;
next.card=card;
next.cards=cards;
next.player=player;
}
"step 2"
if(targets[num]&&targets[num].isDead()) return;
if(targets[num]&&targets[num].isOut()) return;
if(targets[num]&&targets[num].removed) return;
var info=get.info(card);
if(targets.length==0&&!info.notarget) return;
var next=game.createEvent(card.name);
next.content=info.content;
next.targets=targets;
next.card=card;
next.cards=cards;
next.player=player;
next.num=num;
next.type='card';
next.skill=event.skill;
next.multitarget=info.multitarget;
if(num==0&&next.targets.length>1){
if(!info.multitarget){
lib.tempSortSeat=player;
targets.sort(lib.sort.seat);
delete lib.tempSortSeat;
for(var i=0;i1){
// var ttt=next.target;
// setTimeout(function(){ttt.animate('target');},0.5*lib.config.duration);
}
else{
next.target.animate('target');
}
}
if(event.animate!=false||num>0){
if(num==0)game.delay();
else game.delay(0.5);
}
"step 3"
if(!get.info(event.card).multitarget&&num1){
player.line2(targets,config);
}
else{
player.line(targets,config);
}
}
var str=get.translation(player);
if(targets&&targets.length){
str+='对'+(targets[0]==player?'自己':get.translation(targets[0]));
for(var i=1;i1){
if(!info.multitarget){
lib.tempSortSeat=player;
targets.sort(lib.sort.seat);
delete lib.tempSortSeat;
}
for(var i=0;i1){
// var ttt=next.target;
// setTimeout(function(){ttt.animate('target');},0.5*lib.config.duration);
}
else{
next.target.animate('target');
}
}
if(num==0){
if(typeof info.delay=='number') game.delay(info.delay);
else if(info.delay!==false&&info.delay!==0) game.delay();
}
else game.delay(0.5);
if(!info.multitarget&&num1||cards[0].name!=card.name)){
str+='('+get.translation(cards)+')';
}
game.log(str);
for(var i=0;i0) frag1.appendChild(cards[num]);
else frag2.appendChild(cards[num]);
}
if(event.animate=='draw'){
player.$draw(cards.length);
game.delay(1,500);
setTimeout(function(){
player.node.handcards1.insertBefore(frag1,player.node.handcards1.firstChild);
player.node.handcards2.insertBefore(frag2,player.node.handcards2.firstChild);
player.update();
},500);
}
else if(event.animate=='gain'){
player.$gain(cards);
game.delay(1,700);
setTimeout(function(){
player.node.handcards1.insertBefore(frag1,player.node.handcards1.firstChild);
player.node.handcards2.insertBefore(frag2,player.node.handcards2.firstChild);
player.update();
},700);
}
else if(event.animate=='gain2'||event.animate=='draw2'){
player.$gain2(cards);
game.delay(1,500);
setTimeout(function(){
player.node.handcards1.insertBefore(frag1,player.node.handcards1.firstChild);
player.node.handcards2.insertBefore(frag2,player.node.handcards2.firstChild);
player.update();
},500);
}
else{
player.node.handcards1.insertBefore(frag1,player.node.handcards1.firstChild);
player.node.handcards2.insertBefore(frag2,player.node.handcards2.firstChild);
player.update();
}
},
lose:function(){
"step 0"
for(var i=0;i0;i--){
if(player.node.handcards1.childNodes[i].classList.contains('removing')==false){
player.node.handcards1.childNodes[i].animate('last');
break;
}
}
for(var i=player.node.handcards2.childNodes.length-1;i>0;i--){
if(player.node.handcards2.childNodes[i].classList.contains('removing')==false){
player.node.handcards2.childNodes[i].animate('last');
break;
}
}
event.num=0;
"step 1"
if(num0&&player.hujia&&!player.hasSkillTag('nohujia')){
if(num>=player.hujia){
num-=player.hujia;
game.log(get.translation(player)+'的护甲抵挡了'+get.cnNumber(player.hujia)+'点伤害');
player.hujia=0;
}
else{
player.hujia-=num;
game.log(get.translation(player)+'的护甲抵挡了'+get.cnNumber(num)+'点伤害');
num=0;
}
event.hujia=true;
player.update();
}
event.num=num;
if(lib.config.background_audio){
game.playAudio('effect','damage'+(num>1?'2':''));
}
var str=get.translation(player)+'受到了';
if(source) str+='来自'+(source==player?'自己':get.translation(source)+'的');
str+=get.cnNumber(num)+'点';
if(event.nature) str+=get.translation(event.nature)+'属性';
str+='伤害';
game.log(str);
if(player.stat[player.stat.length-1].damaged==undefined){
player.stat[player.stat.length-1].damaged=num;
}
else{
player.stat[player.stat.length-1].damaged+=num;
}
if(source){
if(source.stat[source.stat.length-1].damage==undefined){
source.stat[source.stat.length-1].damage=num;
}
else{
source.stat[source.stat.length-1].damage+=num;
}
}
player.changeHp(-num,false);
player.$damage(source);
player.popup(-num,event.nature);
// if(source){
// if(player._damagetimeout!=source){
// player.$damage(source);
// player._damagetimeout=source;
// setTimeout(function(){
// delete player._damagetimeout;
// },500);
// }
// if(player._damagepopup){
// player._damagepopup-=num;
// player._damagenature=event.nature;
// }
// else{
// player._damagepopup=-num;
// player._damagenature=event.nature;
// setTimeout(function(){
// player.popup(player._damagepopup,player._damagenature);
// delete player._damagepopup;
// delete player._damagenature;
// },300);
// }
// }
// else{
// player.$damage();
// }
event.trigger('damage');
"step 1"
if(player.hp<=0&&player.isAlive()){
game.delay();
player.dying(event);
}
},
recover:function(){
if(lib.config.background_audio){
game.playAudio('effect','recover');
}
if(num>player.maxHp-player.hp) num=player.maxHp-player.hp;
if(num>0){
player.changeHp(num);
game.log(get.translation(player)+'回复了'+get.cnNumber(num)+'点体力')
}
},
loseHp:function(){
"step 0"
if(lib.config.background_audio){
game.playAudio('effect','loseHp');
}
game.log(get.translation(player)+'失去了'+get.cnNumber(num)+'点体力')
player.changeHp(-num);
"step 1"
if(player.hp<=0){
game.delay();
player.dying(event);
}
},
doubleDraw:function(){
"step 0"
player.chooseBool('你的武将牌上有单独的阴阳鱼,是否摸一张牌?');
"step 1"
if(result.bool){
player.draw();
}
},
loseMaxHp:function(){
"step 0"
game.log(get.translation(player)+'失去了'+get.cnNumber(num)+'点体力上限');
if(!event.forced&&typeof player.singleHp==='boolean'){
if(player.singleHp){
player.singleHp=false;
player.maxHp-=num-1;
}
else{
player.singleHp=true;
player.maxHp-=num;
}
}
else{
player.maxHp-=num;
}
player.update();
"step 1"
if(player.maxHp<=0){
player.die();
}
"step 2"
if(!event.forced&&player.singleHp===true&&
!player.classList.contains('unseen')&&!player.classList.contains('unseen2')){
player.doubleDraw();
}
},
gainMaxHp:function(){
"step 0"
game.log(get.translation(player)+'获得了'+get.cnNumber(num)+'点体力上限');
if(typeof player.singleHp==='boolean'){
if(player.singleHp){
player.singleHp=false;
player.maxHp+=num;
}
else{
player.singleHp=true;
player.maxHp+=num-1;
}
}
else{
player.maxHp+=num;
}
player.update();
"step 1"
if(player.singleHp===true&&!player.classList.contains('unseen')&&!player.classList.contains('unseen2')){
player.doubleDraw();
}
},
changeHp:function(){
player.hp+=num;
if(player.hp>player.maxHp) player.hp=player.maxHp;
player.update();
if(event.popup!==false){
player.popup(num);
}
event.trigger('changeHp');
},
dying:function(){
"step 0"
_status.dying=player;
event.trigger('dying');
game.log(get.translation(player)+'濒死')
"step 1"
if(_status.dying==player) delete _status.dying;
if(player.hp<=0) player.die(event.reason);
},
die:function(){
if(source){
game.log(get.translation(player)+'被'+get.translation(source)+'杀害');
if(source.stat[source.stat.length-1].kill==undefined){
source.stat[source.stat.length-1].kill=1;
}
else{
source.stat[source.stat.length-1].kill++;
}
}
else{
game.log(get.translation(player)+'遇难')
}
event.cards=player.get('hej');
event.playerCards=player.get('he');
if(event.cards.length){
for(var i=0;i=equipNum){
player.node.equips.insertBefore(card,player.node.equips.childNodes[i]);
equipped=true;
break;
}
}
if(!equipped){
player.node.equips.appendChild(card);
}
player.node.equips.dataset.number=player.num('e');
game.log(get.translation(player)+'装备了'+get.translation(card))
"step 2"
var info=get.info(card);
if(info.onEquip&&(!info.filterEquip||info.filterEquip(card,player))){
var next=game.createEvent('equip_'+card.name);
next.content=info.onEquip;
next.player=player;
next.card=card;
game.delay();
}
delete player.equiping;
},
addJudge:function(){
"step 0"
if(cards&&get.owner(cards[0])) get.owner(cards[0]).lose(cards);
"step 1"
if(lib.config.background_audio){
game.playAudio('effect','judge');
}
cards[0].fix();
var viewAs=typeof card=='string'?card:card.name;
if(!lib.card[viewAs]||!lib.card[viewAs].effect){
ui.discardPile.appendChild(cards[0]);
}
else{
player.node.judges.insertBefore(cards[0],player.node.judges.firstChild);
player.$gain2(cards);
if(get.itemtype(card)!='card'){
if(typeof card=='string') cards[0].viewAs=card;
else cards[0].viewAs=card.name;
}
else{
delete cards[0].viewAs;
}
if(cards[0].viewAs&&cards[0].viewAs!=cards[0].name){
game.log(get.translation(player)+'被贴上了'+get.translation(cards[0].viewAs)+'('+get.translation(cards)+')');
}
else{
game.log(get.translation(player)+'被贴上了'+get.translation(cards));
}
}
},
judge:function(){
"step 0"
player.judging=get.cards()[0];
event.node=player.judging.copy('thrown','center',ui.arena).animate('start');
event.dialog=ui.create.dialog(get.translation(player)+'的'+event.judgestr+'判定');
event.dialog.classList.add('center');
game.log(get.translation(player)+'进行'+event.judgestr+'判定,亮出的判定牌为'+get.translation(player.judging));
game.delay(2);
event.trigger('judge');
"step 1"
event.result={
card:player.judging,
number:get.number(player.judging),
suit:get.suit(player.judging),
color:get.color(player.judging),
judge:event.judge(player.judging),
node:event.node,
};
if(event.result.judge>0) event.result.bool=true;
if(event.result.judge<0) event.result.bool=false;
delete player.judging;
if(event.result.judge>0){
player.popup('洗具');
}
else if(event.result.judge<0){
player.popup('杯具');
}
if(event.clearArena!=false) ui.clear();
event.dialog.close();
game.log(get.translation(player)+'的判定结果为'+get.translation(event.result.card));
if(!get.owner(event.result.card)) event.position.appendChild(event.result.card);
},
turnOver:function(){
game.log(get.translation(player)+'翻面');
player.classList.toggle('turnedover');
},
link:function(){
if(player.isLinked()){
game.log(get.translation(player)+'解除连环');
}
else{
game.log(get.translation(player)+'被连环');
}
if(lib.config.background_audio){
game.playAudio('effect','link');
}
player.classList.toggle('linked');
},
},
player:{
init:function(character,character2,skill){
if(character2==false){
skill=false;
character2=null;
}
var info=lib.character[character];
var skills=info[3];
this.skills.length=0;
if(!game.minskin&&lib.config.layout=='newlayout'&&info[4].contains('fullskin')){
this.classList.remove('minskin');
this.classList.add('fullskin');
if(lib.fakeavatar&&lib.fakeavatar[character]){
this.node.avatar.setBackground('character/fullskin/'+lib.fakeavatar[character]);
}
else{
this.node.avatar.setBackground('character/fullskin/'+character);
}
}
else{
this.node.avatar.setBackground(character,'character');
this.classList.remove('fullskin');
if(info[4].contains('minskin')){
this.classList.add('minskin');
}
else if(game.minskin){
this.classList.add('minskin');
}
}
this.node.avatar.show();
this.node.count.show();
this.name=character;
this.sex=info[0];
this.group=info[1];
this.hp=info[2];
this.maxHp=info[2];
this.hujia=0;
this.node.intro.innerHTML=lib.config.intro;
if(lib.config.touchscreen){
lib.setLongPress(this,ui.click.intro);
}
if(lib.config.right_info){
this.oncontextmenu=ui.click.rightplayer;
}
if(lib.config.hover_all){
lib.setHover(this,ui.click.hoverplayer);
}
var name=get.translation(character);
this.node.name.innerHTML='';
if(!lib.config.show_name){
this.node.name.style.display='none';
}
for(var i=0;i';
}
if(character2){
var info2=lib.character[character2];
if(lib.config.layout=='newlayout'&&lib.config.only_fullskin){
this.classList.add('fullskin2');
if(lib.fakeavatar&&lib.fakeavatar[character2]){
this.node.avatar2.setBackground('character/fullskin/'+lib.fakeavatar[character2]);
}
else{
this.node.avatar2.setBackground('character/fullskin/'+character2);
}
}
else{
this.node.avatar2.setBackground(character2,'character');
}
this.node.avatar2.show();
this.name2=character2;
var hp1=info[2],hp2=info2[2];
switch(get.config('double_hp')){
case 'pingjun':{
this.maxHp=Math.floor((hp1+hp2)/2);
this.singleHp=((hp1+hp2)%2===1);
break;
}
case 'zuidazhi':this.maxHp=Math.max(hp1,hp2);break;
case 'zuixiaozhi':this.maxHp=Math.min(hp1,hp2);break;
case 'zonghe':this.maxHp=hp1+hp2;break;
default:this.maxHp=hp1+hp2-3;
}
this.hp=this.maxHp;
this.node.count.classList.add('p2');
skills=skills.concat(info2[3]);
}
if(skill!=false){
for(var i=0;i=this.maxHp) this.hp=this.maxHp;
var hp=this.node.hp;
hp.style.transition='none';
if(this.hujia){
this.markSkill('ghujia');
}
else{
this.unmarkSkill('ghujia');
}
if(lib.config.layout=='default'&&this.maxHp>14){
hp.innerHTML=this.hp+'/'+this.maxHp;
hp.classList.add('text');
}
else if(lib.config.layout=='newlayout'&&
(this.maxHp>9||(this.maxHp>5&&this.classList.contains('minskin')))){
hp.innerHTML=this.hp+' / '+this.maxHp;
hp.classList.add('text');
hp.classList.remove('long');
}
else{
hp.innerHTML='';
hp.classList.remove('text');
while(this.maxHp>hp.childNodes.length){
ui.create.div(hp);
}
while(this.maxHpMath.round(this.maxHp/2)||this.hp===this.maxHp){
hp.dataset.condition='high';
}
else if(this.hp>Math.floor(this.maxHp/3)){
hp.dataset.condition='mid';
}
else{
hp.dataset.condition='low';
}
setTimeout(function(){
hp.style.transition='';
});
var numh=this.num('h');
if(numh>=10){
numh=numh.toString();
this.node.count.dataset.condition='low';
this.node.count.innerHTML=numh[0]+' '+numh[1];
}
else{
if(numh>5){
this.node.count.dataset.condition='higher';
}
else if(numh>2){
this.node.count.dataset.condition='high';
}
else if(numh>0){
this.node.count.dataset.condition='mid';
}
else{
this.node.count.dataset.condition='none';
}
this.node.count.innerHTML=numh;
}
this.node.equips.dataset.number=this.num('e');
if(this==game.me){
ui.updateh();
}
if(this.updates){
for(var i=0;i0){
cards.splice(arg2);
}
else if(typeof arg2=='function'){
for(i=0;i0){
game.log(get.translation(this)+'获得了'+get.cnNumber(num)+'点护甲值');
}
if(this.hujia<0){
this.hujia=0;
}
this.update();
},
setIdentity:function(identity){
if(!identity) identity=this.identity;
this.node.identity.firstChild.innerHTML=get.translation(identity);
this.node.identity.dataset.color=identity;
},
phase:function(){
var next=game.createEvent('phase');
next.player=this;
next.content=lib.element.playerproto.phase;
},
phaseJudge:function(){
var next=game.createEvent('phaseJudge');
next.player=this;
next.content=lib.element.playerproto.phaseJudge;
},
phaseDraw:function(){
var next=game.createEvent('phaseDraw');
next.player=this;
next.num=2;
next.content=lib.element.playerproto.phaseDraw;
},
phaseUse:function(){
var next=game.createEvent('phaseUse');
next.player=this;
next.content=lib.element.playerproto.phaseUse;
},
phaseDiscard:function(){
var next=game.createEvent('phaseDiscard');
next.player=this;
next.content=lib.element.playerproto.phaseDiscard;
},
chooseToUse:function(use){
var next=game.createEvent('chooseToUse');
next.player=this;
if(arguments.length==1){
for(var i in use){
next[i]=use[i];
}
}
else{
for(var i=0;i=this.player.num(this.position||'h');
}
next.content=lib.element.playerproto.chooseToDiscard;
return next;
},
chooseToCompare:function(target,check){
var next=game.createEvent('chooseToCompare');
next.player=this;
next.target=target;
if(check) next.ai=check;
else next.ai=function(card){
var player=get.owner(card);
var event=_status.event.parent;
var to=(player==event.player?event.target:event.player);
var addi=(ai.get.value(card)>=8&&get.type(card)!='equip')?-10:0;
if(player==event.player){
if(ai.get.attitude(player,to)>0&&event.small){
return -get.number(card)-ai.get.value(card)/2+addi;
}
return get.number(card)-ai.get.value(card)/2+addi;
}
else{
if(ai.get.attitude(player,to)>0&&!event.small){
return -get.number(card)-ai.get.value(card)/2+addi;
}
return get.number(card)-ai.get.value(card)/2+addi;
}
}
next.content=lib.element.playerproto.chooseToCompare;
return next;
},
chooseCardButton:function(){
var cards,prompt,forced,select;
for(var i=0;i0) return -val;
return val;
};
next.content=lib.element.playerproto.choosePlayerCard;
return next;
},
discardPlayerCard:function(){
var next=game.createEvent('discardPlayerCard');
next.player=this;
for(var i=0;i0) return -val;
return val;
};
next.content=lib.element.playerproto.discardPlayerCard;
return next;
},
gainPlayerCard:function(){
var next=game.createEvent('gainPlayerCard');
next.player=this;
for(var i=0;i0) return -val;
return val;
};
next.content=lib.element.playerproto.gainPlayerCard;
return next;
},
showHandcards:function(){
var next=game.createEvent('showHandcards');
next.player=this;
next.content=lib.element.playerproto.showHandcards;
},
showCards:function(cards,str){
var next=game.createEvent('showCards');
next.player=this;
next.str=str;
if(get.itemtype(cards)=='card') next.cards=[cards];
else if(get.itemtype(cards)=='cards') next.cards=cards;
else _status.event.next.remove(next);
next.content=lib.element.playerproto.showCards;
},
viewHandcards:function(target){
var next=game.createEvent('viewHandcards');
next.player=this;
next.target=target;
next.content=lib.element.playerproto.viewHandcards;
},
useCard:function(){
var next=game.createEvent('useCard');
next.player=this;
next.num=0;
for(var i=0;i=-1&&ai.get.attitude(this,next.targets[i])<0){
if(!this.ai.tempIgnore) this.ai.tempIgnore=[];
this.ai.tempIgnore.add(next.targets[i]);
}
}
if(typeof this.logAi=='function'){
this.logAi(next.targets,next.card);
}
next.content=lib.element.playerproto.useCard;
return next;
},
useSkill:function(){
var next=game.createEvent('useSkill');
next.player=this;
next.num=0;
for(var i=0;i=-1&&ai.get.attitude(this,next.targets[i])<0){
if(!this.ai.tempIgnore) this.ai.tempIgnore=[];
this.ai.tempIgnore.add(next.targets[i]);
}
}
if(typeof this.logAi=='function'){
this.logAi(next.targets,next.skill);
}
}
else{
next.targets=[];
}
next.content=lib.element.playerproto.useSkill;
},
draw:function(){
var next=game.createEvent('draw');
next.player=this;
for(var i=0;i0){
this.node.handcards1.appendChild(cards[i].animate('start'));
}
else{
this.node.handcards2.appendChild(cards[i].animate('start'));
}
}
this.update();
return this;
},
gain:function(){
var next=game.createEvent('gain');
next.player=this;
for(var i=0;i';
}
}
if(className){
node.classList.add(className);
}
},
popup:function(name,className){
var name2=get.translation(name);
var node=ui.create.div('.popup',this.parentNode);
if(!name2){
node.remove();
return node;
}
node.dataset.position=this.dataset.position;
if(this.dataset.position==0||parseInt(this.dataset.position)==parseInt(ui.arena.dataset.number)/2||
typeof name2=='number'||this.classList.contains('minskin')){
node.innerHTML=name2;
}
else{
for(var i=0;i';
}
}
if(className){
node.classList.add(className);
}
this.popups.push(node);
if(this.popups.length>1){
node.hide();
}
else{
var that=this;
setTimeout(function(){that._popup();},1000);
}
return node;
},
_popup:function(){
if(this.popups.length){
this.popups.shift().delete();
if(this.popups.length){
this.popups[0].show();
var that=this;
setTimeout(function(){that._popup();},1000);
}
}
},
markSkill:function(name,info,card){
if(!info){
if(this.marks[name]){
return this;
}
if(lib.skill[name]){
info=lib.skill[name].intro;
}
if(!info){
return this;
}
}
if(this.marks[name]){
this.marks[name].info=info;
}
else{
if(card){
this.marks[name]=this.mark(card,info,name);
}
else{
this.marks[name]=this.mark(name,info);
}
}
return this;
},
unmarkSkill:function(name){
if(this.marks[name]){
this.marks[name].delete();
delete this.marks[name];
var info=lib.skill[name];
if(info&&info.intro&&info.intro.onunmark){
info.intro.onunmark(this.storage[name],this);
}
}
},
markCharacter:function(name,info,learn,learn2){
if(typeof name=='object'){
name=name.name;
}
if(!lib.character[name]) return this;
var node=ui.create.div('.card.mark',this.node.marks).setBackground(name,'character');
node.name=name+'_charactermark';
if(!info){
info={};
}
if(!info.name){
info.name=get.translation(name);
}
if(!info.content){
info.content=get.skillintro(name,learn,learn2)
}
node.info=info;
if(lib.config.touchscreen){
lib.setLongPress(node,ui.click.intro);
}
if(lib.config.right_info){
node.oncontextmenu=ui.click.rightplayer;
}
if(lib.config.hover_all){
lib.setHover(node,ui.click.hoverplayer);
}
return node;
},
mark:function(name,info,skill){
if(get.itemtype(name)=='cards'){
var marks=[];
for(var i=0;i=0){
return true;
}
}
return false;
},
getJudge:function(name){
var judges=this.node.judges.childNodes;
for(var i=0;i1){
setTimeout(function(){
if(cards){
that.$draw(cards)
}
else{
that.$draw(num-1)
}
},200);
}
},
$compare:function(card1,target,card2){
var player=this;
var node1=player.$throwxy(card1,
'calc(50% - 114px)','calc(50% - 52px)'
);
node1.classList.add('infohidden');
node1.style.webkitTransform='perspective(600px) rotateY(180deg) translateX(0)';
setTimeout(function(){
setTimeout(function(){
node1.style.transition='all ease-in 0.3s';
node1.style.webkitTransform='perspective(600px) rotateY(270deg) translateX(52px)';
node1.addEventListener('webkitTransitionEnd',function(){
node1.classList.remove('infohidden');
node1.classList.add('cardflip');
node1.style.webkitTransform='none';
node1.style.transition='';
});
},600);
var node2=target.$throwxy(card2,
'calc(50% + 10px)','calc(50% - 52px)'
);
node2.classList.add('infohidden');
node2.style.webkitTransform='perspective(600px) rotateY(180deg) translateX(0)';
setTimeout(function(){
node2.style.transition='all ease-in 0.3s';
node2.style.webkitTransform='perspective(600px) rotateY(270deg) translateX(52px)';
node2.addEventListener('webkitTransitionEnd',function(){
node2.classList.remove('infohidden');
node2.classList.add('cardflip');
node2.style.webkitTransform='none';
node2.style.transition='';
});
},700);
},200);
},
$throw:function(card,time){
if(get.itemtype(card)=='cards'){
for(var i=0;i=0){
if(log!=false){
game.log(get.translation(player)+'从'+get.translation(this)+'获得了'+get.cnNumber(card)+'张牌');
}
if(this.$givemod){
this.$givemod(card,player);
}
else{
while(card--) this.$give('',player,false);
}
}
else{
if(log!=false){
if(get.itemtype(card)=='card'&&log!=false){
game.log(get.translation(player)+'从'+get.translation(this)+'获得了'+get.translation(card));
}
else{
game.log(get.translation(player)+'从'+get.translation(this)+'获得了一张牌');
}
}
if(this.$givemod){
this.$givemod(card,player);
}
else{
var node;
if(get.itemtype(card)=='card'){
node=card.copy('card','thrown',false);
}
else{
node=ui.create.div('.card.thrown');
}
node.dataset.position=this.dataset.position;
node.fixed=true;
node.hide();
node.style.transitionProperty='left,top,opacity';
node.style.webkitTransform='rotate('+(Math.random()*16-8)+'deg)';
ui.arena.appendChild(node);
ui.refresh(node);
node.show();
node.style.left='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*100+'px)';
node.style.top='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*80+'px)';
setTimeout(function(){
node.removeAttribute('style');
node.dataset.position=player.dataset.position;
node.delete();
},700);
}
}
},
$gain:function(card,log){
if(get.itemtype(card)=='cards'){
if(log!=false){
var str=get.translation(this)+'获得了'+get.translation(card[0]);
for(var i=1;i1){
if(log!=false){
game.log(get.translation(this)+'获得了'+get.cnNumber(card)+'张牌');
}
if(this.$gainmod){
this.$gainmod(card);
}
else{
for(var i=0;i0) left=-left;
if(source.offsetTop-this.offsetTop>0) top=-top;
if(this.isLinked()&&lib.config.layout=='newlayout'){
this.style.webkitTransform='translate('+left+'px,'+top+'px) rotate(-90deg)';
}
else{
this.style.webkitTransform='translate('+left+'px,'+top+'px)';
}
}
else{
if(this.isLinked()&&lib.config.layout=='newlayout'){
this.style.webkitTransform='scale(0.95) rotate(-90deg)';
}
else{
this.style.webkitTransform='scale(0.95)';
}
}
this.queue();
},
$die:function(){
var top0=ui.window.offsetHeight/2;
var left0=ui.window.offsetWidth/2;
var ratio=(left0-this.offsetLeft)/(top0-this.offsetTop);
var left=Math.abs(50*ratio/Math.sqrt(1+ratio*ratio));
var top=Math.abs(50/Math.sqrt(1+ratio*ratio));
if(left0-this.offsetLeft>0) left=-left;
if(top0-this.offsetTop>0) top=-top;
this.style.webkitTransform='translate('+left+'px,'+top+'px) '+
'rotate('+(Math.random()*20-10)+'deg) '+
((Math.random()-0.5<0)?'rotateX(180deg)':'rotateY(180deg)');
this.queue(false);
},
$phaseJudge:function(card){
var clone=card.copy('thrown',ui.arena).animate('judgestart');
var player=this;
clone.style.opacity=0.6;
clone.style.left='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*50+'px)';
clone.style.top='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*40+'px)';
game.delay();
game.linexy([
clone.offsetLeft+clone.offsetWidth/2,
clone.offsetTop+clone.offsetHeight/2,
player.offsetLeft+player.offsetWidth/2,
player.offsetTop+player.offsetHeight/2
],{opacity:0.5,dashed:true});
}
},
card:{
init:function(card){
var bg=card[2];
if(!lib.config.hide_card_image&&lib.card[card[2]].fullskin){
this.classList.add('fullskin');
this.node.image.style.backgroundImage='url("image/card/'+card[2]+'.png")'
}
else if(lib.card[card[2]].image=='background'){
if(card[3]) this.node.background.setBackground(bg+'_'+card[3],'card');
else this.node.background.setBackground(bg,'card');
}
else if(lib.card[card[2]].image=='card'){
if(card[3]) this.setBackground(bg+'_'+card[3],'card');
else this.setBackground(bg,'card');
}
else if(typeof lib.card[card[2]].image=='string'){
this.setBackground(lib.card[card[2]].image);
}
else{
this.node.background.innerHTML=lib.translate[bg+'_bg']||get.translation(bg)[0];
// this.node.background.style.fontFamily=lib.config.card_font;
if(this.node.background.innerHTML.length>1) this.node.background.classList.add('tight');
else this.node.background.classList.remove('tight');
}
if(lib.card[card[2]].color){
this.style.color=lib.card[card[2]].color;
}
if(lib.card[card[2]].textShadow){
this.style.textShadow=lib.card[card[2]].textShadow;
}
if(lib.card[card[2]].opacity){
this.node.info.style.opacity=lib.card[card[2]].opacity;
this.node.name.style.opacity=lib.card[card[2]].opacity;
}
if(lib.card[card[2]].modinfo){
this.node.info.innerHTML=lib.card[card[2]].modinfo;
}
else{
this.node.info.innerHTML=get.translation(card[0])+' '+card[1];
}
if(lib.card[card[2]].addinfo){
this.node.addinfo=ui.create.div('.addinfo',this);
this.node.addinfo.innerHTML=lib.card[card[2]].addinfo;
}
if(card[0]=='heart'||card[0]=='diamond'){
this.node.info.classList.add('red');
}
this.node.name.innerHTML='';
var name=get.translation(card[2]);
if(card[2]=='sha'){
if(card[3]=='fire'){
name='火'+name;
this.node.image.classList.add('fire');
}
else if(card[3]=='thunder'){
name='雷'+name;
this.node.image.classList.add('thunder');
}
}
for(var i=0;i';
}
if(lib.card[card[2]].subtype=='equip3'){
this.node.name.innerHTML+='+';
}
else if(lib.card[card[2]].subtype=='equip4'){
this.node.name.innerHTML+='-';
}
this.node.name2.innerHTML=get.translation(card[0])+card[1]+' '+name;
this.suit=card[0];
this.number=card[1];
this.name=card[2];
this.classList.add('card');
if(card[3]){
if(lib.nature.contains(card[3])) this.nature=card[3];
this.classList.add(card[3]);
}
if(lib.card[card[2]].subtype) this.classList.add(lib.card[card[2]].subtype);
if(this.inits){
for(var i=0;i0){
ui.dialog=ui.dialogs[0];
ui.dialog.show();
ui.dialog.refocus();
ui.update();
}
return this;
},
setCaption:function(str){
this.querySelector('.caption').innerHTML=str;
return this;
}
},
control:{
add:function(item){
var node=document.createElement('div');
this.appendChild(node);
node.link=item;
node.innerHTML=get.translation(item);
node.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.control);
},
close:function(){
ui.controls.remove(this);
this.style.width=0;
this.style.paddingLeft=0;
this.style.paddingRight=0;
this.style.marginLeft=0;
this.style.marginRight=0;
this.delete();
if(ui.confirm==this) delete ui.confirm;
if(ui.skills==this) delete ui.skills;
},
replace:function(){
while(this.childNodes.length) this.firstChild.remove();
var i,controls;
if(get.objtype(arguments[0])=='array') controls=arguments[0];
else controls=arguments;
delete this.custom;
for(i=0;i=player.maxHp;
},
content:function(){
trigger.untrigger();
trigger.finish();
},
},
_turnover:{
trigger:{player:'phaseBefore'},
forced:true,
priority:20,
popup:false,
// filter:function(event,player){
// return player.isTurnedOver();
// },
content:function(){
if(player.isTurnedOver()){
trigger.untrigger();
trigger.finish();
player.turnOver();
player.phaseSkipped=true;
}
else{
player.phaseSkipped=false;
}
},
},
_out:{
trigger:{target:'useCardToBefore',player:['damageBefore','phaseBefore']},
forced:true,
popup:false,
priority:20,
filter:function(event,player){
return player.isOut();
},
content:function(){
trigger.untrigger();
trigger.finish();
},
ai:{
effect:{
target:function(card,player,target){
if(target.isOut()) return 0;
}
},
threaten:function(player,target){
if(target.isOut()) return 0;
}
}
},
_phasebegin:{
trigger:{player:'phaseBegin'},
forced:true,
priority:20,
popup:false,
content:function(){
player.popup('_phasebegin');
_status.currentPhase=player;
game.log();
game.log(get.translation(player)+'的回合开始');
game.phaseNumber++;
var num;
switch(get.config('auto_identity')){
case '一轮':num=1;break;
case '两轮':num=2;break;
case '三轮':num=3;break;
default:num=0;break;
}
if(num&&!_status.identityShown&&game.phaseNumber>game.players.length*num&&game.showIdentity){
player.popup('显示身份');
_status.identityShown=true;
game.showIdentity();
}
player.ai.tempIgnore=[];
player.stat.push({card:{},skill:{}});
},
},
_save:{
trigger:{source:'dying',player:'dying'},
priority:5,
forced:true,
popup:false,
filter:function(event,player){
if(event.player.hp>0) return false;
if(event.source&&event.source!=player) return false;
return true;
},
content:function(){
"step 0"
event.dying=_status.dying;
"step 1"
trigger.start=trigger.source||trigger.player;
var str=get.translation(trigger.player.name)+'濒死,是否帮助?';
_status.dying=event.dying;
if(player.hasSkillTag('save',true)||player.num('h','tao')||
(player==event.dying&&(player.num('h','jiu')||player.num('h','hufu')||player.num('h','tianxianjiu')))){
player.chooseToUse({
filterCard:function(card,player){
var mod=game.checkMod(card,player,'unchanged','cardSavable',player.get('s'));
if(mod!='unchanged') return mod;
var savable=get.info(card).savable;
if(typeof savable=='function') savable=savable(card,player,event.dying);
return savable;
},
filterTarget:trigger.player,
prompt:str,
ai1:function(){return 1;},
ai2:ai.get.effect,
type:'dying',
targetRequired:true,
dying:event.dying
});
}
else{
event._result={bool:false}
}
"step 2"
if(result.bool){
if(trigger.player.hp<=0&&trigger.player.isAlive()&&!trigger.player.isOut()&&!trigger.player.removed) event.goto(0);
else trigger.untrigger();
}
else{
for(var i=0;i<20;i++){
if(event.player.next!=trigger.start){
event.player=event.player.next;
if(!event.player.isOut()){
event.goto(1);
break;
}
}
else{
break;
}
}
}
}
},
_ismin:{
mod:{
cardEnabled:function(card,player){
if(player.isMin()){
if(get.type(card)=='equip') return false;
}
}
}
},
_chongzhu:{
enable:'phaseUse',
prompt:'弃置要重铸的牌并摸一张牌',
filter:function(event,player){
if(player.isMin()&&lib.config.mode=='stone') return false;
return (player.get('h',function(card){
return get.info(card).chongzhu;
}).length);
},
filterCard:function(card){
return get.info(card).chongzhu;
},
prepare:function(cards,player){
player.$throw(cards,1000);
},
discard:false,
delay:0.5,
content:function(){
"step 0"
player.draw();
"step 1"
for(var i=0;itotal/1.5){
ctx.strokeStyle='rgba('+color.toString()+','+opacity*(1-(time-total/1.5)/(total-total/1.5))+')';
}
else{
ctx.strokeStyle='rgba('+color.toString()+','+opacity+')';
}
}
else{
return false;
}
ctx.beginPath();
if(dashed){
ctx.lineCap='butt';
ctx.setLineDash([8,2]);
}
else{
ctx.lineCap='round';
}
ctx.moveTo(from[0],from[1]);
ctx.lineTo(current[0],current[1]);
ctx.stroke();
};
if(arguments[2]&&lib.config.mode=='chess'){
game.draw2(drawfunc);
}
else{
game.draw(drawfunc);
}
},
createEvent:function(name,trigger){
var next={
name:name,
step:0,
finished:false,
next:[],
aiexclude:[],
custom:{
add:{},
replace:{}
},
_result:{}
}
if(trigger!==false) next._triggered=0;
for(var i in lib.element.event){
next[i]=lib.element.event[i];
}
_status.event.next.push(next);
return next;
},
createCard:function(name,suit,number){
if(typeof name!='string'){
name='sha';
}
if(typeof suit!='string'){
suit=['heart','diamond','club','spade'].randomGet();
}
if(typeof number!='number'){
number=Math.ceil(Math.random()*13);
}
return ui.create.card(ui.special).init([suit,number,name]);
},
over:function(result){
var i,j,k,num,table,tr,td,dialog;
_status.over=true;
ui.control.show();
ui.clear();
if(lib.config.background_audio){
if(result===true){
game.playAudio('effect','win');
}
else if(result===false){
game.playAudio('effect','lose');
}
else{
game.playAudio('effect','tie');
}
}
if(result===true) result='战斗胜利';
if(result===false) result='战斗失败';
if(result==undefined) result='战斗结束';
dialog=ui.create.dialog(result);
if(true){
if(game.players.length){
table=document.createElement('table');
tr=document.createElement('tr');
tr.appendChild(document.createElement('td'));
td=document.createElement('td');
td.innerHTML='伤害';
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML='受伤';
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML='摸牌';
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML='出牌';
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML='杀敌';
tr.appendChild(td);
table.appendChild(tr);
for(i=0;i0){
var next=event.next.shift();
if(next.player&&next.player.skipList.contains(next.name)){
next.player.skipList.remove(next.name);
}
else{
next.parent=event;
_status.event=next;
}
}
else if(event.finished){
if(event._triggered==1){
if(event.type=='card') event.trigger('useCardToCancelled');
event.trigger(event.name+'Cancelled');
event._triggered=4;
}
else if(event._triggered==2){
if(event.type=='card') event.trigger('useCardToEnd');
event.trigger(event.name+'End');
event._triggered=3;
}
else if(event._triggered==3){
if(event.type=='card') event.trigger('useCardToAfter');
event.trigger(event.name+'After');
event._triggered++;
}
else{
if(event.parent){
if(event.result){
event.parent._result=event.result;
}
_status.event=event.parent;
}
else{
return;
}
}
}
else{
if(event._triggered==0){
if(event.type=='card') event.trigger('useCardToBefore');
event.trigger(event.name+'Before');
event._triggered++;
}
else if(event._triggered==1){
if(event.type=='card') event.trigger('useCardToBegin');
event.trigger(event.name+'Begin');
event._triggered++;
}
else{
if(player&&player.classList.contains('dead')&&event.name!='phaseLoop'){
event.finish();
}
else if(player&&player.removed&&event.name!='phaseLoop'){
event.finish();
}
else if(player&&player.isOut()&&event.name!='phaseLoop'){
event.finish();
}
else{
eval(lib.init.parse(event.content))();
}
event.step++;
}
}
game.loop();
},
pause:function(){
clearTimeout(_status.timeout);
_status.paused=true;
},
pause2:function(){
_status.paused2=true;
},
resume:function(){
if(_status.paused){
_status.paused=false;
game.loop();
}
},
resume2:function(){
if(_status.paused2){
_status.paused2=false;
game.loop();
}
},
delay:function(time,time2){
if(_status.paused) return;
game.pause();
if(time==undefined) time=1;
if(time2==undefined) time2=0;
time=time*lib.config.duration+time2;
_status.timeout=setTimeout(game.resume,time);
},
check:function(event){
var i,j,range;
if(event==undefined) event=_status.event;
var custom=event.custom||{};
var ok=true,auto=true;
var player=event.player;
if(!event.filterButton&&!event.filterCard&&!event.filterTarget&&!event.skill) return;
if(event.filterButton){
var dialog=event.dialog;
range=get.select(event.selectButton);
if(range[0]!=range[1]||range[0]>1) auto=false;
for(i=0;i1) auto=false;
for(i=0;i1) auto=false;
for(i=0;i7){
nochess=false;
}
}
if(event.filterTarget(card,player,game.players[i])&&
(game.players[i].isOut()==false||event.includeOutTarget)&&nochess){
if(ui.selected.targets.length=info.usable) enable=false;
}
if(enable){
skills.add(skills2[i]);
}
}
if(skills.length){
ui.create.skills(skills);
}
else if(ui.skills){
ui.skills.close();
}
}
else if(ui.skills){
ui.skills.close()
}
_status.multitarget=false;
var skillinfo=get.info(_status.event.skill);
if(_status.event.name=='chooseToUse'){
if(skillinfo&&skillinfo.multitarget&&!skillinfo.multiline){
_status.multitarget=true;
}
if((skillinfo&&skillinfo.viewAs)||!_status.event.skill){
var cardinfo=get.info(get.card());
if(cardinfo&&cardinfo.multitarget&&!cardinfo.multiline){
_status.multitarget=true;
}
}
}
else if(_status.event.multitarget){
_status.multitarget=true;
}
if(event.isMine()){
if(ok&&auto&&lib.config.auto_confirm&&(!_status.mousedragging||!_status.mouseleft)&&!_status.mousedown){
if(ui.confirm){
if(!skillinfo||!skillinfo.preservecancel){
ui.confirm.close();
}
}
if(event.skillDialog==true) event.skillDialog=false;
ui.click.ok();
_status.mousedragging=null;
}
else{
ui.arena.classList.add('selecting');
_status.imchoosing=true;
if(!_status.noconfirm){
if(!_status.mousedown||_status.mouseleft){
var str='';
if(ok) str+='o';
if(!event.forced&&get.noSelected()) str+='c';
ui.create.confirm(str);
}
}
}
}
return ok;
},
uncheck:function(){
var i,j;
if(false){
if(lib.config.mode=='chess'){
var shadows=ui.chessContainer.getElementsByClassName('playergrid temp');
while(shadows.length){
shadows[0].remove();
}
}
}
if(arguments.length==0){
while(document.getElementsByClassName('selectable').length>0){
document.getElementsByClassName('selectable')[0].classList.remove('selectable');
}
while(document.getElementsByClassName('selected').length>0){
document.getElementsByClassName('selected')[0].classList.remove('selected');
}
if(_status.event.player){
var cards=_status.event.player.get('hej');
for(j=0;j=position){
return players[i];
}
}
return players[0];
},
phaseLoop:function(player){
var next=game.createEvent('phaseLoop');
next.player=player;
next.content=function(){
"step 0"
player.phase();
"step 1"
if(!game.players.contains(event.player.next)){
event.player=game.findNext(event.player.next);
}
else{
event.player=event.player.next;
}
event.goto(0);
}
},
gameDraw:function(player,num){
var next=game.createEvent('gameDraw');
next.player=player;
if(num==undefined) next.num=4;
else next.num=num;
next.content=function(){
"step 0"
var end=player;
do{
player.directgain(get.cards(4));
if(player.singleHp===true&&!player.classList.contains('unseen')&&!player.classList.contains('unseen2')){
player.doubleDraw();
}
player=player.next;
}
while(player!=end);
"step 1"
if(get.config('change_card')){
event.dialog=ui.create.dialog('是否使用手气卡?');
ui.create.confirm('oc');
event.custom.replace.confirm=function(bool){
_status.event.bool=bool;
game.resume();
}
}
else{
event.finish();
}
"step 2"
game.pause();
"step 3"
if(event.bool){
game.me.lose(game.me.get('h'))._triggered=null;
}
else{
event.dialog.close();
ui.confirm.close();
event.finish();
}
"step 4"
game.delay();
game.me.gain(get.cards(4))._triggered=null;
"step 5"
event.goto(2);
}
},
asyncDraw:function(players,num){
for(var i=0;ivalue2) return 1;
return -1;
};
}
else if(card.type=='delay'){
if(card.enable==undefined) card.enable=true;
if(card.filterTarget==undefined) card.filterTarget=lib.filter.judge;
if(card.content==undefined) card.content=function(){
target.addJudge(card,cards);
};
}
}
for(i in lib.skill){
if(lib.skill[i].forbid&&lib.skill[i].forbid.contains(lib.config.mode)){
lib.skill[i]={};
if(lib.translate[i+'_info']){
lib.translate[i+'_info']='此模式下不可用';
}
continue;
}
if(lib.skill[i].mode&&lib.skill[i].mode.contains(lib.config.mode)==false){
lib.skill[i]={};
if(lib.translate[i+'_info']){
lib.translate[i+'_info']='此模式下不可用';
}
continue;
}
if(lib.skill[i].viewAs){
if(lib.skill[i].ai==undefined) lib.skill[i].ai={};
var skill=lib.skill[i].ai;
var card=lib.card[lib.skill[i].viewAs.name].ai;
for(j in card){
if(skill[j]==undefined) skill[j]=card[j];
else if(typeof skill[j]=='object'){
for(var k in card[j]){
if(skill[j][k]==undefined) skill[j][k]=card[j][k];
}
}
}
}
if(lib.skill[i].inherit){
var skill=lib.skill[lib.skill[i].inherit];
for(j in skill){
if(lib.skill[i][j]==undefined) lib.skill[i][j]=skill[j];
}
if(lib.translate[i+'_info']==undefined){
lib.translate[i+'_info']=lib.translate[lib.skill[i].inherit+'_info'];
}
}
if(i[0]=='_'){
lib.skill.global.add(i);
}
}
},
checkMod:function(){
var name=arguments[arguments.length-2];
var skills=arguments[arguments.length-1].concat(lib.skill.global);
game.expandSkills(skills);
var arg=[],i,info;
for(i=0;i0){
try{
config=JSON.parse(localStorage.getItem(lib.configprefix+lib.config.mode));
if(typeof config!='object') throw 'err';
}
catch(err){
config={};
}
if(value==undefined){
delete config[key];
delete lib.storage[key];
}
else{
config[key]=value;
lib.storage[key]=value;
}
}
config.version=game.version;
localStorage.setItem(lib.configprefix+lib.config.mode,JSON.stringify(config));
},
updateSave:function(){
if(_status.reloading) return;
localStorage.setItem(lib.configprefix+lib.config.mode,JSON.stringify(lib.storage));
},
saveConfig:function(key,value,local){
if(_status.reloading) return;
var config;
try{
config=JSON.parse(localStorage.getItem(lib.configprefix+'config'));
if(!config||typeof config!='object') throw 'err'
}
catch(err){
config={};
}
if(local){
lib.config.mode_config[lib.config.mode][key]=value;
key+='_mode_config_'+lib.config.mode;
}
else{
lib.config[key]=value;
}
config[key]=value;
localStorage.setItem(lib.configprefix+'config',JSON.stringify(config));
},
addPlayer:function(position,character,character2){
if(position<0||position>game.players.length+game.dead.length||position==undefined){
position=Math.ceil(Math.random()*(game.players.length+game.dead.length));
}
var players=game.players.concat(game.dead);
ui.arena.dataset.number=players.length+1;
for(var i=0;i=position){
players[i].dataset.position=parseInt(players[i].dataset.position)+1;
}
}
var player=ui.create.player(ui.arena).animate('start');
if(character) player.init(character,character2);
game.players.push(player);
player.dataset.position=position;
game.arrangePlayers();
return player;
},
addFellow:function(position,character){
var player=ui.create.player(ui.arena).animate('start');
player.dataset.position=position||game.players.length+game.dead.length;
if(character) player.init(character);
game.players.push(player);game.arrangePlayers();
return player;
},
restorePlayer:function(player){
if(game.players.contains(player)||game.dead.contains(player)) return;
var position=parseInt(player.dataset.position);
if(position<0||position>game.players.length+game.dead.length||position==undefined){
position=Math.ceil(Math.random()*(game.players.length+game.dead.length));
}
var players=game.players.concat(game.dead);
ui.arena.dataset.number=players.length+1;
for(var i=0;i=position){
players[i].dataset.position=parseInt(players[i].dataset.position)+1;
}
}
game.players.push(player);
delete player.removed;
player.removeAttribute('style');
player.animate('start');
ui.arena.appendChild(player);
game.arrangePlayers();
return player;
},
removePlayer:function(player){
var players=game.players.concat(game.dead);
player.style.top=player.offsetTop+'px';
player.style.left=player.offsetLeft+'px';
if(player==undefined) player=game.dead[0]||game.me.next;
var position=parseInt(player.dataset.position);
for(var i=0;iposition){
players[i].dataset.position=parseInt(players[i].dataset.position)-1;
}
}
if(player.isAlive()){
player.next.previous=player.previous;
player.previous.next=player.next;
}
player.nextSeat.previousSeat=player.previousSeat;
player.previousSeat.nextSeat=player.nextSeat;
player.delete();
game.players.remove(player);
game.dead.remove(player);
ui.arena.dataset.number=players.length-1;
player.removed=true;
if(player==game.me){
ui.me.hide();
ui.auto.hide();
ui.wuxie.hide();
}
setTimeout(function(){
player.removeAttribute('style');
},500);
return player;
},
replacePlayer:function(player,character,character2){
player.removed=true;
var position=parseInt(player.dataset.position);
game.players.remove(player);
game.dead.remove(player);
player.delete();
var player2=ui.create.player(ui.arena).animate('start');
if(character) player2.init(character,character2);
game.players.push(player2);
player2.dataset.position=position;
player2.nextSeat=player.nextSeat;
player2.previousSeat=player.previousSeat;
player2.nextSeat.previousSeat=player2;
player2.previousSeat.nextSeat=player2;
var player3=player2.nextSeat;
while(player3.isDead()) player3=player3.nextSeat;
player3.previous=player2;
player2.next=player3;
var player4=player2.previousSeat;
while(player4.isDead()) player4=player4.previousSeat;
player4.next=player2;
player2.previous=player4;
return player2;
},
arrangePlayers:function(){
game.players.sort(lib.sort.position);
var players=game.players.concat(game.dead);
players.sort(lib.sort.position);
for(var i=0;iposition2){
position.insertBefore(node,position.childNodes[position2]);
}
else{
position.appendChild(node);
}
}
if(style) node.css(style);
if(divposition) node.setPosition(divposition);
return node;
},
table:function(){
var str,row,col,position,position2,fixed,style,divposition;
for(var i=0;iposition2){
position.insertBefore(node,position.childNodes[position2]);
}
else{
position.appendChild(node);
}
}
return node;
},
groupControl:function(dialog){
return ui.create.control('wei','shu','wu','qun',function(link,node){
if(link=='全部'){
dialog.currentcapt='';
dialog.currentgroup='';
for(var i=0;ib?1:-1;
});
var clickCapt=function(e){
if(_status.dragged) return;
if(this.classList.contains('thundertext')){
dialog.currentcapt=null;
dialog.currentcaptnode=null;
this.classList.remove('thundertext');
for(var i=0;ib?1:-1;
}
return aa>bb?1:-1;
});
dialog=ui.create.dialog('hidden');
if(str){
dialog.add(str);
}
dialog.add(node);
if(thisiscard){
dialog.add([list,'vcard'],noclick);
}
else{
dialog.add([list,'character'],noclick);
}
dialog.add(ui.create.div('.placeholder'));
for(i=0;i=0;i--){
if(list[i]){
list[i].animate('start');
node.parentNode.parentNode.insertBefore(list[i],node.parentNode.nextSibling);
}
}
node.clicked=true;
setTimeout(function(){
node.clicked=false;
},600);
}
var newgame=[];
newgame._configstr='newgame';
folditems.push(newgame);
ui.config.appendChild(ui.create.line2('新游戏',function(){
if(this.clicked) return;
if(lib.config.newgame){
game.saveConfig('newgame',false);
fold(newgame);
}
else{
game.saveConfig('newgame',true);
unfold(this,newgame);
}
}));
var span1='- ';
var span2='· ';
var clickmode=function(){
game.saveConfig('mode',this.parentNode.link);
game.reload();
};
for(var i=0;i14){
node.node.hp.innerHTML=lib.character[item][2];
node.node.hp.classList.add('text');
}
else{
for(var i =0;i';
}
node.node.intro.innerHTML=lib.config.intro;
if(!noclick){
if(lib.config.touchscreen){
lib.setLongPress(node,ui.click.intro);
}
if(lib.config.right_info){
node.oncontextmenu=ui.click.rightplayer;
}
if(lib.config.hover_all){
lib.setHover(node,ui.click.hoverplayer);
}
}
node.node.group.innerHTML=''+get.translation(lib.character[item][1])+' ';
node.node.group.style.backgroundColor=get.translation(lib.character[item][1]+'Color');
}
else{
if(item.name.indexOf('unknown')==0){
node.setBackground(item.name1,'character');
}
else{
node.setBackground(item.name,'character');
}
}
break;
case 'text':
node=ui.create.div('.button.text',position);
node.innerHTML=lib.get.translate(item);
break;
}
if(!noclick){
node.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
}
else{
node.classList.add('noclick');
if(node.querySelector('.intro')){
node.querySelector('.intro').remove();
}
}
for(var i in lib.element.button){
node[i]=lib.element.button[i];
}
return node;
},
buttons:function(list,type,position,noclick,zoom){
var buttons=[];
for(var i=0;i0){
players[i].previous=players[i-1];
players[i].previousSeat=players[i-1];
}
if(iui.window.offsetWidth-10){
left=ui.window.offsetWidth-width-10;
}
uiintro.style.left=left+'px';
uiintro._poppedorigin=this;
uiintro.addEventListener(lib.config.touchscreen?'touchend':'mouseleave',ui.click.leavehoverpopped);
},
leavehoverpopped:function(){
if(_status.dragged) return;
this.delete();
var button=this._poppedorigin
setTimeout(function(){
delete button._uiintro;
},500);
},
dierevive:function(){
if(game.me.isDead()){
game.me.revive(1);
game.me.draw(2);
}
else{
if(ui.revive){
ui.revive.close();
delete ui.revive;
}
}
},
dieswap:function(){
if(game.me.isDead()){
_status.clicked=true;
var i,translation,intro,str;
if(ui.intro){
ui.intro.close();
if(ui.intro.source=='dieswap'){
delete ui.intro;
ui.control.show();
game.resume2();
return;
}
}
game.pause2();
ui.control.hide();
ui.intro=ui.create.dialog();
ui.intro.source='dieswap';
var players=[];
for(var i=0;i.dialog.popped:not(.static)');
for(var i=0;iitem.offsetLeft&&exitem.offsetTop&&ey.dialog.popped:not(.static)');
for(var i=0;i'+lib.translate[skill+'_info']+' ');
}
}
},
ok:function(node){
var event=_status.event;
if(event.custom.replace.confirm){
event.custom.replace.confirm(true);return;
}
event.result={
buttons:ui.selected.buttons.slice(0),
cards:ui.selected.cards.slice(0),
targets:ui.selected.targets.slice(0),
confirm:'ok',
bool:true,
links:get.links(ui.selected.buttons)
};
if(node){
node.parentNode.close();
}
if(event.skill){
event.result.skill=event.skill;
event.result.card=get.info(event.skill).viewAs;
if(event.result.cards.length==1&&event.result.card){
event.result.card.suit=event.result.cards[0].suit;
}
if(event.skillDialog&&get.objtype(event.skillDialog)=='div'){
event.skillDialog.close();
}
event.restore();
}
if(ui.skills) ui.skills.close();
game.uncheck();
if(event.custom.add.confirm){
event.custom.add.confirm(true);
}
game.resume();
},
cancel:function(node){
var event=_status.event;
if(event.custom.replace.confirm){
event.custom.replace.confirm(false);return;
}
if(event.skill){
if(event.skillDialog&&get.objtype(event.skillDialog)=='div'){
event.skillDialog.close();
}
if(typeof event.dialog=='string'&&event.isMine()){
event.dialog=ui.create.dialog(event.dialog);
}
event.restore();
game.uncheck();
game.check();
return;
}
event.result={
confirm:'cancel',
bool:false
};
if(node){
node.parentNode.close();
}
if(ui.skills) ui.skills.close();
game.uncheck();
if(event.custom.add.confirm){
event.custom.add.confirm(true);
}
game.resume();
},
oldintro:function(e){
if(_status.dragged) return;
_status.clicked=true;
if(this.classList.contains('player')&&!this.name){
return;
}
var i,translation,intro,str;
ui.click.intro2.call(this);
game.pause2();
ui.control.hide();
ui.intro=get.nodeintro(this).open();
ui.intro.source=this;
},
intro:function(e){
if(_status.dragged) return;
_status.clicked=true;
if(this.classList.contains('player')&&!this.name){
return;
}
var uiintro=get.nodeintro(this);
uiintro.classList.add('popped');
uiintro.classList.add('static');
ui.window.appendChild(uiintro);
var layer=ui.create.div('.poplayer',ui.arena);
var clicklayer=function(e){
uiintro.delete();
this.remove();
game.resume2();
e.stopPropagation();
return false;
}
layer.addEventListener(lib.config.touchscreen?'touchend':'click',clicklayer);
layer.oncontextmenu=clicklayer;
lib.placePoppedDialog(uiintro,e);
uiintro.style.zIndex=21;
var clickintro=function(){
layer.remove();
this.delete();
game.resume2();
};
uiintro.addEventListener('mouseleave',clickintro);
uiintro.addEventListener('click',clickintro);
game.pause2();
return uiintro;
},
intro2:function(){
if(ui.intro){
ui.intro.close();
if(ui.intro.source==this){
delete ui.intro;
ui.control.show();
game.resume2();
return;
}
}
},
auto:function(){
if(ui.auto.classList.contains('hidden')) return;
if(!_status.auto){
_status.auto=true;
// ui.auto.innerHTML='手动';
ui.auto.classList.add('glow');
if(ui.confirm) ui.confirm.close();
ui.control.hide();
if(_status.event.switchToAuto){
_status.event.switchToAuto();
}
else{
if(_status.paused&&_status.imchoosing){
game.uncheck();
_status.event.redo();
}
}
game.resume();
}
else{
ui.control.show();
_status.auto=false;
ui.auto.classList.remove('glow');
// ui.auto.innerHTML='托管';
}
},
wuxie:function(){
if(this.classList.contains('hidden')) return;
this.classList.toggle('glow');
if(this.classList.contains('glow')&&
(_status.event.parent.name=='_wuxie1'||_status.event.parent.name=='_wuxie2')&&
_status.event.isMine()&&ui.confirm){
ui.click.cancel(ui.confirm.lastChild);
}
},
pause:function(){
if(_status.paused2) return;
ui.system.hide();
game.pause2();
var node=ui.create.pause().animate('start');
ui.sidebar3.innerHTML='';
if(lib.config.show_discardpile){
for(var i=0;i 0 || evt.wheelDelta < 0){
node.interval=setInterval(function(){
if(num--&&Math.abs(node.scrollLeft+node.clientWidth-node.scrollWidth)>0){
node.scrollLeft +=speed;
}
else{
clearInterval(node.interval);
}
},16);
}
else{
node.interval=setInterval(function(){
if(num--&&node.scrollLeft>0){
node.scrollLeft -=speed;
}
else{
clearInterval(node.interval);
}
},16);
}
},
touchStart:function(e){
this.startX=e.touches[0].clientX;
this.startY=e.touches[0].clientY;
_status.dragged=false;
},
touchScroll:function(e) {
if(!_status.dragged){
if (Math.abs(e.touches[0].clientX - this.startX) > 10 ||
Math.abs(e.touches[0].clientY - this.startY) > 10) {
_status.dragged=true;
}
}
if(this.scrollWidth<=this.offsetWidth&&
this.scrollHeight<=this.offsetHeight){
e.preventDefault();
}
else{
e.stopPropagation();
}
},
sidebar:{
local:function(item){
game.saveConfig(this.name,item,true);
},
local2:function(item){
game.saveConfig(this.name,item,true);
ui.sidebarrestart.classList.add('thundertext');
},
global:function(item){
game.saveConfig(this.name,item);
},
global2:function(item){
game.saveConfig(this.name,item);
ui.sidebarrestart.classList.add('thundertext');
},
background_music:function(item){
game.saveConfig(this.name,item);
game.playBackgroundMusic();
},
cheat:function(bool){
if(lib.config.cheat&&bool==false){
lib.cheat=window.cheat;
delete window.cheat;
delete window.game;
delete window.ui;
delete window.get;
delete window.ai;
delete window.lib;
delete window._status;
}
else if(!lib.config.cheat&&bool){
window.cheat=lib.cheat;
window.cheat.i();
}
game.saveConfig('cheat',bool);
},
free_choose:function(bool){
game.saveConfig('free_choose',bool,true);
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(!ui.cheat2&&get.config('free_choose')) ui.create.cheat2();
else if(ui.cheat2&&!get.config('free_choose')){
ui.cheat2.close();
delete ui.cheat2;
if(ui.cheat2x){
ui.cheat2x.close();
delete ui.cheat2;
}
}
},
change_identity:function(bool){
game.saveConfig('change_identity',bool,true);
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
var dialog;
if(ui.cheat2&&ui.cheat2.backup) dialog=ui.cheat2.backup;
else dialog=_status.event.dialog;
if(!dialog.querySelector('table')&&get.config('change_identity')) _status.event.parent.addSetting(dialog);
else _status.event.parent.removeSetting(dialog);
ui.update();
},
battle_number:function(num){
game.saveConfig('battle_number',num,true);
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(_status.event.parent.changeDialog){
_status.event.parent.changeDialog();
}
},
change_choice:function(bool){
game.saveConfig('change_choice',bool,true);
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(!ui.cheat&&get.config('change_choice')) ui.create.cheat();
else if(ui.cheat&&!get.config('change_choice')){
ui.cheat.close();
delete ui.cheat;
}
},
player_number:function(num){
game.saveConfig('player_number',num,true);
game.reload();
},
auto_identity:function(bool){
game.saveConfig('auto_identity',bool,true);
var num;
switch(bool){
case '一轮':num=1;break;
case '两轮':num=2;break;
case '三轮':num=3;break;
default:num=0;break;
}
if(num&!_status.identityShown&&game.phaseNumber>game.players.length*num&&game.showIdentity){
_status.identityShown=true;
game.showIdentity();
}
},
swap:function(bool){
game.saveConfig('swap',bool,true);
if(get.config('swap')){
if(!ui.swap&&game.me.isDead()){
ui.swap=ui.create.control('换人',ui.click.dieswap);
}
}
else if(ui.swap){
ui.swap.close();
delete ui.swap;
}
},
revive:function(bool){
game.saveConfig('revive',bool,true);
if(get.config('revive')){
if(!ui.revive&&game.me.isDead()){
ui.revive=ui.create.control('revive',ui.click.dierevive);
}
}
else if(ui.revive){
ui.revive.close();
delete ui.revive;
}
},
hover_all:function(bool){
game.saveConfig('hover_all',bool);
if(!lib.config.hover_all) ui.hoverhandcardconfig.classList.add('disabled');
else ui.hoverhandcardconfig.classList.remove('disabled');
ui.sidebarrestart.classList.add('thundertext');
},
theme:function(theme){
game.saveConfig('theme',theme);
ui.arena.hide();
setTimeout(function(){
var theme=ui.css.theme;
ui.css.theme=lib.init.css('theme/'+lib.config.theme,'style');
theme.remove();
setTimeout(function(){ui.arena.show();},100);
},500);
},
layout:function(layout){
game.saveConfig('layout',layout);
if(lib.config.mode!='chess'){
ui.arena.hide();
setTimeout(function(){
var layout=ui.css.layout;
ui.css.layout=lib.init.css('layout/'+lib.config.layout,'layout',layout);
setTimeout(function(){layout.remove();ui.arena.show();},100);
},500);
}
},
image_background:function(background){
var animate=lib.config.image_background=='default';
game.saveConfig('image_background',background);
ui.background.delete();
ui.background=ui.create.div('.background');
switch (lib.config.image_background_filter){
case 'blur':ui.background.style.webkitFilter='blur(8px)';
ui.background.style.webkitTransform='scale(1.05)';break;
case 'gray':ui.background.style.webkitFilter='grayscale(1)';break;
case 'sepia':ui.background.style.webkitFilter='sepia(0.5)';break;
case 'invert':ui.background.style.webkitFilter='invert(1)';break;
case 'saturate':ui.background.style.webkitFilter='saturate(5)';break;
case 'contrast':ui.background.style.webkitFilter='contrast(1.4)';break;
case 'hue':ui.background.style.webkitFilter='hue-rotate(180deg)';break;
case 'brightness':ui.background.style.webkitFilter='brightness(5)';break;
default:ui.background.style.webkitFilter='';
ui.background.style.webkitTransform='';
}
document.body.insertBefore(ui.background,document.body.firstChild);
if(animate) ui.background.animate('start');
if(lib.config.image_background=='default'){
ui.background.style.backgroundImage="none";
}
else{
ui.background.style.backgroundImage="url('image/background/"+lib.config.image_background+".jpg')";
}
ui.background.style.backgroundSize='cover';
},
image_background_filter:function(filter){
game.saveConfig('image_background_filter',filter);
ui.click.sidebar.image_background(lib.config.image_background);
},
ui_zoom:function(zoom){
game.saveConfig('ui_zoom',zoom);
switch(zoom){
case '极小':ui.window.style.zoom=0.8;break;
case '很小':ui.window.style.zoom=0.9;break;
case '较小':ui.window.style.zoom=0.95;break;
case '较大':ui.window.style.zoom=1.05;break;
case '很大':ui.window.style.zoom=1.1;break;
default:ui.window.style.zoom=1;
}
},
show_name:function(bool){
game.saveConfig('show_name',bool);
var players=get.players(false,true);
if(lib.config.show_name){
for(var i=0;i0){
game.me.node.handcards1.appendChild(cards[i]);
}
else{
game.me.node.handcards2.appendChild(cards[i]);
}
}
}
},
reverse_sort:function(bool){
game.saveConfig('reverse_sort',bool,true);
var cards1=[];
var cards2=[];
var i;
for(i=0;i=width){
node.dataset.fold=3;
}
else if(num*93+25>=width){
node.dataset.fold=2;
}
else if(num*112+6>=width){
node.dataset.fold=1;
}
else{
node.dataset.fold=0;
}
},
update:function(){
for(var i=0;i=ui.dialog.content.offsetHeight){
ui.dialog.classList.remove('scroll1');
ui.dialog.classList.remove('scroll2');
return;
}
if(lib.config.touchscreen||lib.config.layout=='newlayout'){
ui.dialog.classList.add('scroll1');
ui.dialog.classList.add('scroll2');
}
if(ui.dialog.contentContainer.scrollTop>0){
ui.dialog.classList.add('scroll1');
}
else{
ui.dialog.classList.remove('scroll1');
}
if(ui.dialog.contentContainer.scrollTop+ui.dialog.contentContainer.offsetHeight>=
ui.dialog.contentContainer.scrollHeight-1){
ui.dialog.classList.remove('scroll2');
}
else{
ui.dialog.classList.add('scroll2');
}
}
},
recycle:function(node,key){
if(!ui._recycle) ui._recycle={};
if(typeof node=='string'){
return ui._recycle[node]
}
ui._recycle[key]=node;
},
};
var get={
config:function(item){
if(!lib.config.mode_config[lib.config.mode]) return;
return lib.config.mode_config[lib.config.mode][item];
},
skillLocked:function(skill){
var info=lib.skill[skill];
if(info.locked==false) return false;
if(info.trigger&&info.forced) return true;
if(info.mod) return true;
if(info.locked) return true;
return false;
},
itemtype:function(obj){
var i,j;
if(typeof obj=='string'){
if(obj.length<=3){
for(i=0;i99) return num;
if(num<=10){
switch(num){
case 0:return '〇';
case 1:return '一';
case 2:return two?'二':'两';
case 3:return '三';
case 4:return '四';
case 5:return '五';
case 6:return '六';
case 7:return '七';
case 8:return '八';
case 9:return '九';
case 10:return '十';
}
}
if(num<20){
return '十'+get.cnNumber(num-10,true);
}
var x=Math.floor(num/10);
return get.cnNumber(x,true)+'十'+(num>10*x?get.cnNumber(num-10*x,true):'');
},
selectableButtons:function(sort){
if(!_status.event.player) return[];
var buttons=_status.event.dialog.buttons;
var selectable=[];
for(var i=0;i【'+get.translation(skills[i]).slice(0,2)+'】'+
lib.translate[skills[i]+'_info']+' ';
}
}
return str;
},
intro:function(name){
var info=lib.character[name];
var str='性别:'+get.translation(info[0])+' ';
str+='势力:'+get.translation(info[1])+' ';
str+='体力:'+get.translation(info[2])+' ';
str+='技能:';
if(info[3].length){
str+=get.translation(info[3][0]);
for(var i=1;i0){
return '共有'+content+'个标记';
}
return false;
}
case 'turn':{
if(content>0){
return '还剩'+content+'个回合';
}
return false;
}
case 'time':{
if(content>0){
return '还剩'+content+'次';
}
return false;
}
case 'limited':{
if(content){
return '已发动';
}
return '未发动';
}
case 'cardCount':{
if(typeof content=='object'&&typeof content.length=='number'){
return '共有'+get.cnNumber(content.length)+'张牌';
}
return false;
}
case 'card':case 'cards':{
if(get.itemtype(content)=='card'){
content=[content];
}
if(dialog&&get.itemtype(content)=='cards'){
if(content.length>6&&!dialog._hovercustomed){
dialog.addSmall(content);
}
else{
dialog.add(content);
}
}
else{
if(content&&content.length){
return get.translation(content);
}
}
return false;
}
case 'player':case 'players':{
if(get.itemtype(content)=='player'){
content=[content];
}
if(dialog&&get.itemtype(content)=='players'){
if(content.length>6&&!dialog._hovercustomed){
dialog.addSmall(content);
}
else{
dialog.add(content);
}
return false;
}
else{
if(content&&content.length){
return get.translation(content);
}
return false;
}
break;
}
default:{
if(typeof type=='string'){
return type.replace(/#/g,content);
}
else if(typeof type=='function'){
return type(content,player);
}
return false;
}
}
},
nodeintro:function(node,simple){
var uiintro=ui.create.dialog('hidden');
if(node.classList.contains('player')&&!node.name){
return uiintro;
}
var i,translation,intro,str;
if(node.classList.contains('player')){
var capt=get.translation(node.name);
if(lib.character[node.name]){
capt+=' '+lib.translate[lib.character[node.name][1]];
}
uiintro.add(capt);
var skills=node.skills;
var skills2=game.filterSkills(node.skills,node);
for(i=0;i【'+translation+'】 '+lib.translate[skills[i]+'_info']+' ');
}
else{
uiintro.add('【'+translation+'】 '+lib.translate[skills[i]+'_info']+' ');
}
}
}
var forbidden=node.forbiddenSkills;
for(i=0;i【'+translation+'】 '+'已禁用'+' ');
}
}
// if(!simple)
if(false){
var storage=node.storage;
for(i in storage){
if(get.info(i)&&get.info(i).intro){
intro=get.info(i).intro;
if(node.get('s').concat(lib.skill.global).contains(i)==false&&!intro.show) continue;
var name=intro.name?intro.name:get.translation(i);
if(typeof name=='function'){
name=name(storage[i],node);
}
translation='『'+name[0]+name[1]+'』 ';
var stint=get.storageintro(intro.content,storage[i],node);
if(stint){
translation+=stint+' ';
uiintro.add(translation);
}
}
}
uiintro.add(ui.create.div('.placeholder'));
var table,tr,td;
table=document.createElement('table');
tr=document.createElement('tr');
table.appendChild(tr);
td=document.createElement('td');
td.innerHTML='攻击范围';
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML='进攻距离';
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML='防御距离';
tr.appendChild(td);
tr=document.createElement('tr');
table.appendChild(tr);
td=document.createElement('td');
td.innerHTML=get.attackRange(node);
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML=get.globalFrom(node);
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML=get.globalTo(node);
tr.appendChild(td);
uiintro.content.appendChild(table);
}
uiintro.add(ui.create.div('.placeholder.slim'));
}
else if(node.classList.contains('mark')&&node.info&&
node.parentNode&&node.parentNode.parentNode&&node.parentNode.parentNode.classList.contains('player')){
var info=node.info;
var player=node.parentNode.parentNode;
if(info.name){
if(typeof info.name=='function'){
var named=info.name(player.storage[node.skill],player);
if(named){
uiintro.add(named);
}
}
else{
uiintro.add(info.name);
}
}
else if(info.name!==false){
uiintro.add(get.translation(node.skill));
}
if(typeof info.mark=='function'){
var stint=info.mark(uiintro,player.storage[node.skill],player);
if(stint){
if(stint.length<=10){
uiintro.add(''+stint+' ');
}
else{
uiintro.add(''+stint+' ');
}
}
}
else{
var stint=get.storageintro(info.content,player.storage[node.skill],player,uiintro);
if(stint){
if(stint[0]=='$'){
uiintro.add(''+stint.slice(1)+' ');
}
else if(stint.length<=10){
uiintro.add(''+stint+' ');
}
else{
uiintro.add(''+stint+' ');
}
}
}
uiintro.add(ui.create.div('.placeholder.slim'));
}
else if(node.classList.contains('card')){
var name=node.name;
if(get.position(node)=='j'&&node.viewAs&&node.viewAs!=name){
uiintro.add(get.translation(node.viewAs)+'('+get.translation(node)+')');
name=node.viewAs;
}
else{
uiintro.add(get.translation(node));
}
if(node.name=='muniu'&&get.position(node)=='e'){
var num=0;
if(node.cards){
num=node.cards.length;
}
if(get.owner(node)==game.me&&num){
uiintro.add(node.cards,true,num>4);
}
else{
uiintro.add(''+'共有'+get.cnNumber(num)+'张牌'+' ');
}
}
else if(node.name=='lianyaohu'&&get.position(node)=='e'){
var num=0;
if(node.storage.shouna){
num=node.storage.shouna.length;
}
if(num){
uiintro.add(node.storage.shouna,true,num>4);
}
else{
uiintro.add('炼妖壶内没有牌 ');
}
}
else if(lib.translate[name+'_info']){
uiintro.add(''+lib.translate[name+'_info']+' ');
}
uiintro.add(ui.create.div('.placeholder.slim'));
}
else if(node.classList.contains('character')){
var character=node.link;
uiintro.add(get.translation(character));
var skills=lib.character[character][3];
for(i=0;i【'+translation+'】 '+lib.translate[skills[i]+'_info']+' ');
}
}
uiintro.add(ui.create.div('.placeholder.slim'));
}
return uiintro;
},
groups:function(){
return ['wei','shu','wu','qun'];
},
types:function(){
var types=[];
for(var i in lib.card){
if(lib.card[i].mode&&lib.card[i].mode.contains(lib.config.mode)==false) continue;
if(lib.card[i].forbid&&lib.card[i].forbid.contains(lib.config.mode)) continue;
if(lib.card[i].type){
if(lib.card[i].type=='delay') types.add('trick');
else types.add(lib.card[i].type);
}
}
return types;
},
links:function(buttons){
var links=[];
for(var i=0;i0);
}
lib.temp={};
buttons=get.selectableButtons();
buttons2=buttons.slice(0);
buttons.sort(function(a,b){
return check(b,buttons2)-check(a,buttons2);
});
if(buttons.length==0){
return ok;
}
if(check(buttons[0])<=0){
if(!forced||ok){
return ok;
}
}
buttons[0].classList.add('selected');
ui.selected.buttons.add(buttons[0]);
game.check();
if(ui.selected.buttons.length>=range[0]){
ok=true;
}
if(ui.selected.buttons.length==range[1]){
return true;
}
}
},
chooseCard:function(check){
var event=_status.event;
if(event.filterCard==undefined) return (check()>0);
var i,j,range,cards,cards2,skills,check,effect;
var ok=false,forced=event.forced;
var iwhile=100;
while(iwhile--){
range=get.select(event.selectCard);
if(ui.selected.cards.length>=range[0]){
ok=true;
}
if(range[1]==-1){
if(ui.selected.cards.length==0) return true;
j=0;
for(i=0;i0);
}
lib.temp={};
cards=get.selectableCards().concat(get.skills());
cards2=cards.slice(0);
cards.sort(function(a,b){
return (check(b,cards2)-check(a,cards2));
});
if(cards.length==0){
return ok;
}
if(check(cards[0])<=0){
if(!forced||ok){
return ok;
}
}
if(typeof cards[0]=='string'){
ui.click.skill(cards[0]);
var info=get.info(event.skill);
if(info.filterCard){
check=info.check||ai.get.unuseful2;
return (ai.basic.chooseCard(check));
}
else{
return true;
}
}
else{
cards[0].classList.add('selected');
ui.selected.cards.add(cards[0]);
game.check();
if(ui.selected.cards.length>=range[0]){
ok=true;
}
if(ui.selected.cards.length==range[1]){
return true;
}
}
}
},
chooseTarget:function(check){
var event=_status.event;
if(event.filterTarget==undefined) return (check()>0);
var i,j,range,targets,targets2,effect;
var ok=false,forced=event.forced;
var iwhile=100;
while(iwhile--){
range=get.select(event.selectTarget);
if(range[1]==-1){
j=0;
for(i=0;i0);
}
else if(range[1]==0){
return check()>0
}
lib.temp={};
targets=get.selectableTargets();
targets2=targets.slice(0);
targets.sort(function(a,b){
return check(b)-check(a);
});
if(targets.length==0){
return ok;
}
if(check(targets[0])<=0){
if(!forced||ok){
return ok;
}
}
targets[0].classList.add('selected');
ui.selected.targets.add(targets[0]);
game.check();
if(ui.selected.targets.length>=range[0]){
ok=true;
}
if(ui.selected.targets.length==range[1]){
return true;
}
}
}
},
get:{
useful:function(card){
if(get.position(card)=='j') return -1;
if(get.position(card)=='e') return ai.get.equipValue(card);
if(lib.temp[card.name]==undefined) lib.temp[card.name]=[card];
else lib.temp[card.name].add(card);
var i=lib.temp[card.name].find(card);
var aii=get.info(card).ai;
var useful;
if(aii&&aii.useful) useful=aii.useful;
else if(aii&&aii.basic) useful=aii.basic.useful;
if(useful==undefined) return -1;
if(typeof useful=='function'){
return useful(card,i);
}
if(typeof useful=='number') return useful;
if(i3) result2*=0.9;
if(target.hp==4) result2*=0.9;
if(target.hp==5) result2*=0.8;
if(target.hp>5) result2*=0.6;
}
else{
result2+=temp02;
result1+=temp01;
}
if(zeroplayer) result1=0;
if(zerotarget) result2=0;
if(player2){
return (result1*ai.get.attitude(player2,player)+(target?result2*ai.get.attitude(player2,target):0));
}
return (result1*ai.get.attitude(player,player)+(target?result2*ai.get.attitude(player,target):0));
},
damageEffect:function(target,player,viewer,nature){
if(!player){
player=target;
}
if(!viewer){
viewer=target;
}
var name='damage';
if(nature=='fire'){
name='firedamage';
}
else if(nature=='thunder'){
name='thunderdamage';
}
return ai.get.effect(target,{name:name},player,viewer);
},
recoverEffect:function(target,player,viewer){
if(target.hp==target.maxHp) return 0;
if(!player){
player=target;
}
if(!viewer){
viewer=target;
}
return ai.get.effect(target,{name:'recover'},player,viewer);
},
buttonValue:function(button){
var card=button.link;
var player=get.owner(card);
if(!player) player=_status.event.player;
if(player.get('j').contains(card)){
var efff=ai.get.effect(player,card,player,player);
if(efff>0) return 0.5;
if(efff==0) return 0;
return -1.5;
}
if(player.get('e').contains(card)){
return ai.get.equipValue(card)/3;
}
var nh=player.num('h');
switch(nh){
case 1:return 2;
case 2:return 1.6;
case 3:return 1;
case 4:return 0.8;
case 5:return 0.6;
default:return 0.4;
}
},
attitude2:function(to){
return ai.get.attitude(_status.event.player,to);
},
players:function(range,sort){
var players=[];
if(range.max==undefined) range.max=Infinity;
if(range.min==undefined) range.min=-Infinity;
if(range.player==undefined) range.player=_status.event.player;
for(var i=0;i=range.min){
players.push(game.players[i]);
}
}
if(sort) players.sort(sort);
return players;
}
},
};
lib.init.init();
HTMLDivElement.prototype.animate=function(name){
this.classList.add(name);
var that=this;
setTimeout(function(){
that.classList.remove(name);
},1000);
return this;
};
HTMLDivElement.prototype.hide=function(){
this.classList.add('hidden');
return this;
};
HTMLDivElement.prototype.unfocus=function(){
this.classList.add('transparent');
return this;
};
HTMLDivElement.prototype.refocus=function(){
this.classList.remove('transparent');
return this;
};
HTMLDivElement.prototype.show=function(){
this.classList.remove('hidden');
return this;
};
HTMLDivElement.prototype.delete=function(time){
if(time==undefined) time=500;
this.classList.add('removing');
var that=this;
this.timeout=setTimeout(function(){
that.remove();
that.classList.remove('removing');
},time);
return this;
};
HTMLDivElement.prototype.goto=function(position,time){
if(time==undefined) time=500;
this.classList.add('removing');
var that=this;
this.timeout=setTimeout(function(){
position.appendChild(that);
that.classList.remove('removing');
delete that.destiny;
},time);
this.destiny=position;
return this;
};
HTMLDivElement.prototype.fix=function(){
clearTimeout(this.timeout);
delete this.destiny;
this.classList.remove('removing');
return this;
};
HTMLDivElement.prototype.setBackground=function(name,type){
var src;
if(type){
src='image/'+type+'/default/'+name+'.jpg';
}
else{
src='image/'+name+'.jpg';
}
this.style.backgroundImage="url('"+src+"')";
this.style.backgroundSize="cover";
return this;
};
HTMLDivElement.prototype.listen=function(func){
this.addEventListener(lib.config.touchscreen?'touchend':'click',function(e){
if(_status.dragged) return;
func.call(this,e);
})
return this;
};
HTMLDivElement.prototype.setPosition=function(){
var position;
if(arguments.length==4){
position=[];
for(var i=0;i0) top+='+ '+position[1]+'px)';
else top+='- '+Math.abs(position[1])+'px)';
var left='calc('+position[2]+'% ';
if(position[3]>0) left+='+ '+position[3]+'px)';
else left+='- '+Math.abs(position[3])+'px)';
this.style.top=top;
this.style.left=left;
return this;
};
HTMLDivElement.prototype.css=function(style){
for(var i in style){
if(i=='innerHTML'){
this.innerHTML=style[i];
}
else{
this.style[i]=style[i];
}
}
return this;
};
HTMLDivElement.prototype.transform=function(transform){
var str='';
for(var i in transform){
switch(i){
case 'scale':str+='scale('+transform[i]+') ';break;
case 'rotate':str+='rotate('+transform[i]+'deg) ';break;
}
}
if(typeof transform=='object'){
if(transform.left&&transform.top){
str+='translate('+parseInt(transform.left)+'px,'+parseInt(transform.top)+'px) ';
}
else if(transform.left){
str+='translate('+parseInt(transform.left)+'px) ';
}
else if(transform.top){
str+='translate(0,'+parseInt(transform.top)+'px) ';
}
}
this.style.webkitTransform=str;
return this;
};
HTMLTableElement.prototype.get=function(row,col){
if(rowthis.length){
num=this.length;
}
var arr=this.slice(0);
var list=[];
for(var i=0;i 10 ||
Math.abs(e.touches[0].clientY - this.startY) > 10) {
_status.dragged=true;
}
});
}
ui.background=document.querySelector('.background.static');
ui.background.classList.remove('static');
ui.dynamicBackground=document.querySelector('.background.dynamic');
var i,j,k;
for(i in mode[lib.config.mode].element){
if(!lib.element[i]) lib.element[i]=[];
for(j in mode[lib.config.mode].element[i]){
if(j=='init'){
if(!lib.element[i].inits) lib.element[i].inits=[];
lib.element[i].inits.push(lib.init.eval(mode[lib.config.mode].element[i][j]));
}
else{
lib.element[i][j]=lib.init.eval(mode[lib.config.mode].element[i][j]);
}
}
}
for(i in mode[lib.config.mode].ai){
if(typeof mode[lib.config.mode].ai[i]=='object'){
if(ai[i]==undefined) ai[i]={};
for(j in mode[lib.config.mode].ai[i]){
ai[i][j]=lib.init.eval(mode[lib.config.mode].ai[i][j]);
}
}
else{
ai[i]=lib.init.eval(mode[lib.config.mode].ai[i]);
}
}
for(i in mode[lib.config.mode].ui){
if(typeof mode[lib.config.mode].ui[i]=='object'){
if(ui[i]==undefined) ui[i]={};
for(j in mode[lib.config.mode].ui[i]){
ui[i][j]=lib.init.eval(mode[lib.config.mode].ui[i][j]);
}
}
else{
ui[i]=lib.init.eval(mode[lib.config.mode].ui[i]);
}
}
for(i in mode[lib.config.mode].game){
game[i]=lib.init.eval(mode[lib.config.mode].game[i]);
}
for(i in mode[lib.config.mode].get){
get[i]=lib.init.eval(mode[lib.config.mode].get[i]);
}
lib.config.current_mode=mode[lib.config.mode].config||[];
lib.config.mode_choice=mode[lib.config.mode].config;
for(i in mode[lib.config.mode]){
if(i=='element') continue;
if(i=='game') continue;
if(i=='ai') continue;
if(i=='ui') continue;
if(i=='get') continue;
if(i=='config') continue;
if(lib[i]==undefined) lib[i]=(get.objtype(mode[lib.config.mode][i])=='array')?[]:{};
for(j in mode[lib.config.mode][i]){
lib[i][j]=lib.init.eval(mode[lib.config.mode][i][j]);
}
}
for(i in character){
if(character[i].forbid&&character[i].forbid.contains(lib.config.mode)) continue;
if(character[i].mode&&character[i].mode.contains(lib.config.mode)==false) continue;
for(j in character[i]){
if(j=='mode'||j=='forbid') continue;
if(j=='character'&&!lib.config.characters.contains(i)) continue;
for(k in character[i][j]){
if(j=='character'){
if(!character[i][j][k][4]){
character[i][j][k][4]=[];
}
if(lib.config.only_fullskin&&lib.config.layout=='newlayout'&&lib.config.mode!='chess'){
if(!character[i][j][k][4].contains('fullskin')&&!character[i][j][k][4].contains('minskin')){
continue;
}
}
}
if(j=='translate'&&k==i){
lib[j][k+'_character_config']=character[i][j][k];
}
else{
if(lib[j][k]==undefined){
lib[j][k]=lib.init.eval(character[i][j][k]);
}
else{
alert('dublicate '+j+' in character '+i+':\n'+k+'\n'+': '+lib[j][k]+'\n'+character[i][j][k]);
}
}
}
}
}
for(i in card){
if(card[i].forbid&&card[i].forbid.contains(lib.config.mode)) continue;
if(card[i].mode&&card[i].mode.contains(lib.config.mode)==false) continue;
for(j in card[i]){
if(j=='mode'||j=='forbid') continue;
if(j=='list'){
if(lib.config.cards.contains(i)){
if(typeof card[i][j]=='function'){
lib.card.list=lib.card.list.concat(lib.init.eval(card[i][j])());
}
else{
lib.card.list=lib.card.list.concat(card[i][j]);
}
}
}
else{
for(k in card[i][j]){
if(j=='translate'&&k==i){
lib[j][k+'_card_config']=card[i][j][k];
}
else{
if(lib[j][k]==undefined) lib[j][k]=lib.init.eval(card[i][j][k]);
else alert('dublicate '+j+' in card '+i+':\n'+k+'\n'+lib[j][k]+'\n'+card[i][j][k]);
}
}
}
}
}
for(i in play){
if(play[i].forbid&&play[i].forbid.contains(lib.config.mode)) continue;
if(play[i].mode&&play[i].mode.contains(lib.config.mode)==false) continue;
for(j in play[i].element){
if(!lib.element[j]) lib.element[j]=[];
for(k in play[i].element[j]){
if(k=='init'){
if(!lib.element[j].inits) lib.element[j].inits=[];
lib.element[j].inits.push(lib.init.eval(play[i].element[j][k]));
}
else{
lib.element[j][k]=lib.init.eval(play[i].element[j][k]);
}
}
}
for(j in play[i].ui){
if(typeof play[i].ui[j]=='object'){
if(ui[j]==undefined) ui[j]={};
for(k in play[i].ui[j]){
ui[j][k]=lib.init.eval(play[i].ui[j][k]);
}
}
else{
ui[j]=lib.init.eval(play[i].ui[j]);
}
}
for(j in play[i].game){
game[j]=lib.init.eval(play[i].game[j]);
}
for(j in play[i].get){
get[j]=lib.init.eval(play[i].get[j]);
}
if(play[i].config){
lib.config.current_mode=lib.config.current_mode.concat(play[i].config);
}
for(j in play[i]){
if(j=='mode'||j=='forbid'||j=='init'||j=='element'||j=='game'||j=='get'||j=='config'||j=='ui') continue;
for(k in play[i][j]){
if(j=='translate'&&k==i){
lib[j][k+'_play_config']=play[i][j][k];
}
else{
if(lib[j][k]!=undefined){
console.log('dublicate '+j+' in play '+i+':\n'+k+'\n'+': '+lib[j][k]+'\n'+play[i][j][k]);
}
lib[j][k]=lib.init.eval(play[i][j][k]);
}
}
}
if(typeof play[i].init=='function') (lib.init.eval(play[i].init))();
}
for(i=0;i |