▭ | 暂停',
'游戏命令':' 变量名 - 场上角色
game.players - 阵亡角色
game.dead'+
' - 玩家
game.me - 玩家的上/下家
game.me.previous/next'+
' - 玩家的上/下家(含阵亡)
game.me.previousSeat/ nextSeat'+
' - 牌堆
ui.cardPile - 弃牌堆
ui.discardPile '+
'角色属性 - 体力值
player.hp'+
' - 体力上限
player.maxHp - 身份
player.identity - 手牌
player.get("h") - 装备牌
player.get("e") - 判定牌
player.get("j")'+
' - 是否存活/横置/翻面
player.isAlive()/ isLinked()/ isTurnedOver() '+
'角色操作 - 受到伤害
player.damage(source, num)'+
' - 回复体力
player.recover(num) - 摸牌
player.draw(num) - 获得牌
player.gain(cards) - 弃牌
player.discard(cards)'+
' - 使用卡牌
player.useCard(card, targets) - 死亡
player.die() - 复活
player.revive(hp) '+
'游戏操作 - 在命令输入框中输出结果
game.print(str) - 游戏结束
game.over(bool)'+
' - 角色资料
lib.character - 卡牌资料
lib.card ',
},
setIntro:function(node,func){
if(lib.config.touchscreen){
lib.setLongPress(node,ui.click.intro);
}
else{
if(lib.config.hover_all){
lib.setHover(node,ui.click.hoverplayer);
}
if(lib.config.right_info){
node.oncontextmenu=ui.click.rightplayer;
}
}
node._customintro=func;
},
setPopped:function(node,func,width,height){
node._poppedfunc=func;
node._poppedwidth=width;
node._poppedheight=height;
if(lib.config.touchscreen){
node.listen(ui.click.hoverpopped);
}
else{
node.addEventListener('mouseenter',ui.click.hoverpopped);
// node.addEventListener('mouseleave',ui.click.hoverpopped_leave);
}
},
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';
},
isMobileMe:function(player){
return (lib.config.layout=='mobile'||lib.config.layout=='phone')&&lib.config.mode!='chess'&&player.dataset.position==0;
},
isNewLayout:function(){
if(lib.config.layout!='default') return true;
if(lib.config.layoutfixed.contains(lib.config.mode)) return true;
return false;
},
isSingleHandcard:function(){
if(game.singleHandcard||lib.config.layout=='mobile'||lib.config.layout=='phone'){
return true;
}
if(lib.config.layout=='default'&&lib.config.layoutfixed.contains(lib.config.mode)){
return true;
}
return false;
},
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;
},
setScroll:function(node){
node.ontouchstart=ui.click.touchStart;
node.ontouchmove = ui.click.touchScroll;
node.style.WebkitOverflowScrolling='touch';
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;
},
stringify:function(obj){
var str='{'
for(var i in obj){
str+='"'+i+'":'
if(Object.prototype.toString.call(obj[i])=='[object Object]'){
str+=lib.init.stringify(obj[i]);
}
else if(typeof obj[i]=='function'){
str+=obj[i].toString();
}
else{
str+=JSON.stringify(obj[i]);
}
str+=','
}
str+='}';
return str;
},
stringifySkill:function(obj){
var str='';
for(var i in obj){
str+=i+':'
if(Object.prototype.toString.call(obj[i])=='[object Object]'){
str+='{\n'+lib.init.stringifySkill(obj[i])+'}';
}
else if(typeof obj[i]=='function'){
str+=obj[i].toString().replace(/\t/g,'');
}
else{
str+=JSON.stringify(obj[i]);
}
str+=',\n'
}
return str;
}
},
translate:{
'default':"默认",
zhenfa:'阵法',
mode_derivation_card_config:'衍生',
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"
// if(player.node.judges.childElementCount){
// player.popup('判定阶段');
// }
player.phaseJudge();
"step 1"
player.phaseDraw();
if(!player.noPhaseDelay){
if(player==game.me){
game.delay();
}
else{
game.delayx();
}
}
"step 2"
// if(!player.skipList.contains('phaseUse')) player.popup('出牌阶段');
player.phaseUse();
"step 3"
if(ui.tempnowuxie){
ui.tempnowuxie.close();
delete ui.tempnowuxie;
}
player.phaseDiscard()
if(!player.noPhaseDelay) game.delayx();
delete player.using;
delete player._noSkill;
},
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');
player.popup(event.card.viewAs||event.card.name,'thunder');
}
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(){
if(game.modPhaseDraw){
game.modPhaseDraw(player,event.num);
}
else{
if(get.config('first_less')&&game.phaseNumber==1&&_status.first_less){
event.num--;
}
if(event.num>0){
player.draw(event.num);
}
}
},
phaseUse:function(){
"step 0";
player.chooseToUse();
"step 1"
if(result.bool){
event.goto(0);
}
if(ui.tempnowuxie){
ui.tempnowuxie.close();
delete ui.tempnowuxie;
}
delete player.using;
},
phaseDiscard:function(){
"step 0"
event.num=player.num('h')-game.checkMod(player,player.hp,'maxHandcard',player.get('s'));
if(event.num<=0) event.finish();
else{
if(lib.config.show_phase_prompt){
player.popup('弃牌阶段');
}
}
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(lib.config.enable_vibrate&&player._noVibrate){
delete player._noVibrate;
game.vibrate();
}
}
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'){
var filter=event.filterCard;
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.norestore){
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{
ui.click.cancel();
}
}
}
else if(event.skill&&!event.norestore){
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.logSkill){
if(typeof event.logSkill=='string'){
player.logSkill(event.logSkill);
}
else if(Array.isArray(event.logSkill)){
player.logSkill.apply(player,event.logSkill);
}
}
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();
}
if(event.logSkill&&event.result.bool){
if(typeof event.logSkill=='string'){
player.logSkill(event.logSkill);
}
else if(Array.isArray(event.logSkill)){
player.logSkill.apply(player,event.logSkill);
}
}
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(player,'对',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"
ui.arena.classList.add('thrownhighlight');
game.addVideo('thrownhighlight1');
player.$compare(event.card1,target,event.card2);
game.log(player,'的拼点牌为',event.card1);
game.log(target,'的拼点牌为',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;
}
ui.arena.classList.remove('thrownhighlight');
game.addVideo('thrownhighlight2');
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;i=cs.length){
event.result={
bool:true,
buttons:event.dialog.buttons,
links:cs
}
}
else{
if(event.isMine()){
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"
event.dialog.close();
},
discardPlayerCard:function(){
"step 0"
if(!event.dialog) event.dialog=ui.create.dialog('hidden');
else if(!event.isMine){
event.dialog.style.display='none';
}
if(event.prompt==undefined){
var str='弃置'+get.translation(target);
var range=get.select(event.selectButton);
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.prompt=str;
}
if(event.prompt){
event.dialog.add(event.prompt);
}
for(var i=0;i=cs.length){
event.result={
bool:true,
buttons:event.dialog.buttons,
links:cs
}
}
else{
if(event.isMine()){
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"
event.dialog.close();
"step 2"
if(event.result.bool&&event.result.buttons){
if(event.logSkill){
if(typeof event.logSkill=='string'){
player.logSkill(event.logSkill);
}
else if(Array.isArray(event.logSkill)){
player.logSkill.apply(player,event.logSkill);
}
}
var cards=[];
for(var i=0;i=cs.length){
event.result={
bool:true,
buttons:event.dialog.buttons,
links:cs
}
}
else{
if(event.isMine()){
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"
event.dialog.close();
"step 2"
var cards=[];
for(var i=0;i1&&!get.info(card).multiline){
player.line2(targets,config);
}
else{
player.line(targets,config);
}
}
player.$throw(cards);
if(lib.config.sync_speed&&cards[0]&&cards[0].clone){
var waitingForTransition=get.time();
event.waitingForTransition=waitingForTransition;
cards[0].clone.addEventListener('webkitTransitionEnd',function(){
if(_status.waitingForTransition==waitingForTransition&&_status.paused){
game.resume();
}
delete event.waitingForTransition;
});
}
}
event.trigger('useCard');
if(get.type(card)!='equip'){
var str='';
if(targets.length){
str+='对'+(targets[0]==player?'自己':get.translation(targets[0]));
for(var i=1;i'
}
str+='使用了';
if(cards.length&&(cards.length>1||cards[0]!=card)){
game.log(player,str,card,'(',cards,')');
}
else{
game.log(player,str,card);
}
}
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;
next.preResult=event.preResult;
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){
if(event.delayx!==false){
if(event.waitingForTransition){
_status.waitingForTransition=event.waitingForTransition;
game.pause();
}
else{
game.delayx();
}
}
}
else game.delayx(0.5);
}
"step 3"
if(!get.info(event.card).multitarget&&num1){
player.line2(targets,config);
}
else{
player.line(targets,config);
}
}
var str='';
if(targets&&targets.length&&info.log!='notarget'){
str+='对'+(targets[0]==player?'自己':get.translation(targets[0]));
for(var i=1;i'
}
str+='发动了';
if(!info.direct){
game.log(player,str,'【'+get.translation(skill)+'】');
if(lib.config.skill_animation&&lib.skill[skill]&&lib.skill[skill].skillAnimation){
player.$skill(lib.skill[skill].animationStr||lib.translate[skill],lib.skill[skill].skillAnimation,lib.skill[skill].animationColor);
}
else{
player.popup(skill);
}
}
if(event.addCount!=false){
if(player.stat[player.stat.length-1].skill[skill]==undefined){
player.stat[player.stat.length-1].skill[skill]=1;
}
else{
player.stat[player.stat.length-1].skill[skill]++;
}
}
if(player.stat[player.stat.length-1].allSkills==undefined){
player.stat[player.stat.length-1].allSkills=1;
}
else{
player.stat[player.stat.length-1].allSkills++;
}
"step 1"
if(!event.skill){
console.log('error: no skill',get.translation(event.player),event.player.get('s'));
if(event._skill){
event.skill=event._skill;
console.log(event._skill);
}
else{
event.finish();
return;
}
}
var info=get.info(event.skill);
if(targets[num]&&targets[num].isDead()||
targets[num]&&targets[num].isOut()||
targets[num]&&targets[num].removed){
if(!info.multitarget&&num1){
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){
if(event.waitingForTransition){
_status.waitingForTransition=event.waitingForTransition;
game.pause();
}
else{
game.delayx()
}
}
}
else game.delayx(0.5);
if(!info.multitarget&&num200){
player._noSkill=true;
console.log(player.name,event.skill);
}
if(document.getElementsByClassName('thrown').length){
if(event.skill&&get.info(event.skill).delay!==0) game.delayx();
}
else{
event.finish();
}
"step 3"
ui.clear();
},
draw:function(){
if(lib.config.background_audio){
game.playAudio('effect','draw');
}
if(event.drawDeck){
if(event.drawDeck>num){
event.drawDeck=num;
}
num-=event.drawDeck;
}
if(event.log!=false){
if(num>0){
game.log(player,'摸了'+get.cnNumber(num)+'张牌');
}
if(event.drawDeck){
game.log(player,'从牌库中获得了'+get.cnNumber(event.drawDeck)+'张牌');
}
}
var cards;
if(num>0){
cards=get.cards(num);
}
else{
cards=[];
}
if(event.drawDeck){
cards=cards.concat(player.getDeckCards(event.drawDeck));
}
if(event.animate!=false){
player.gain(cards,'draw');
}
else{
player.gain(cards);
}
event.result=cards;
},
discard:function(){
"step 0"
if(lib.config.background_audio){
game.playAudio('effect','discard');
}
game.log(player,'弃置了',cards);
player.lose(cards);
if(event.animate!=false){
player.$throw(cards,1000);
if(lib.config.sync_speed&&cards[0]&&cards[0].clone){
if(event.delay!=false){
var waitingForTransition=get.time();
event.waitingForTransition=waitingForTransition;
cards[0].clone.addEventListener('webkitTransitionEnd',function(){
if(_status.waitingForTransition==waitingForTransition&&_status.paused){
game.resume();
}
delete event.waitingForTransition;
});
}
else if(event.parent.discardTransition){
delete event.parent.discardTransition;
var waitingForTransition=get.time();
event.parent.waitingForTransition=waitingForTransition;
cards[0].clone.addEventListener('webkitTransitionEnd',function(){
if(_status.waitingForTransition==waitingForTransition&&_status.paused){
game.resume();
}
delete event.parent.waitingForTransition;
});
}
}
}
event.trigger('discard');
"step 1"
if(event.delay!=false){
if(event.waitingForTransition){
_status.waitingForTransition=event.waitingForTransition;
game.pause();
}
else{
game.delayx();
}
}
},
respond:function(){
var cardaudio=true;
if(event.skill){
if(lib.skill[event.skill].audio){
cardaudio=false;
}
player.logSkill(event.skill);
if(player.checkShow){
player.checkShow(event.skill);
}
}
else if(lib.config.show_card_prompt&&!lib.config.hide_card_prompt_basic){
player.popup(card.name,'wood');
}
if(cardaudio&&event.parent.parent.parent.name=='useCard'){
if(lib.config.background_audio){
var sex=player.sex=='female'?'female':'male';
if(lib.card[card.name].audio||lib.config.background_ogg){
game.playAudio('card',sex,card.name);
}
else{
game.playAudio('card/default');
}
}
}
if(cards.length&&(cards.length>1||cards[0].name!=card.name)){
game.log(player,'打出了',card,'(',cards,')');
}
else{
game.log(player,'打出了',card);
}
for(var i=0;i0) frag1.appendChild(cards[num]);
else frag2.appendChild(cards[num]);
}
var addv=function(){
if(player==game.me){
game.addVideo('gain12',player,[get.cardsInfo(frag1.childNodes),get.cardsInfo(frag2.childNodes)]);
}
};
if(event.animate=='draw'){
player.$draw(cards.length);
game.delayx(1,500);
setTimeout(function(){
addv();
player.node.handcards1.insertBefore(frag1,player.node.handcards1.firstChild);
player.node.handcards2.insertBefore(frag2,player.node.handcards2.firstChild);
player.update();
if(player==game.me) ui.updatehl();
},500);
}
else if(event.animate=='gain'){
player.$gain(cards);
game.delayx(1,700);
setTimeout(function(){
addv();
player.node.handcards1.insertBefore(frag1,player.node.handcards1.firstChild);
player.node.handcards2.insertBefore(frag2,player.node.handcards2.firstChild);
player.update();
if(player==game.me) ui.updatehl();
},700);
}
else if(event.animate=='gain2'||event.animate=='draw2'){
player.$gain2(cards);
game.delayx(1,500);
setTimeout(function(){
addv();
player.node.handcards1.insertBefore(frag1,player.node.handcards1.firstChild);
player.node.handcards2.insertBefore(frag2,player.node.handcards2.firstChild);
player.update();
if(player==game.me) ui.updatehl();
},500);
}
else{
addv();
player.node.handcards1.insertBefore(frag1,player.node.handcards1.firstChild);
player.node.handcards2.insertBefore(frag2,player.node.handcards2.firstChild);
player.update();
if(player==game.me) ui.updatehl();
}
},
lose:function(){
"step 0"
var hs=[],es=[],js=[];
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(player,'的护甲抵挡了'+get.cnNumber(player.hujia)+'点伤害');
player.hujia=0;
}
else{
player.hujia-=num;
game.log(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='受到了';
if(source) str+='来自'+(source==player?'自己':get.translation(source))+'的';
str+=get.cnNumber(num)+'点';
if(event.nature) str+=get.translation(event.nature)+'属性';
str+='伤害';
game.log(player,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);
if(event.animate!==false){
player.$damage(source);
if(lib.config.animation&&!lib.config.low_performance){
if(event.nature=='fire'){
player.$fire();
}
else if(event.nature=='thunder'){
player.$thunder();
}
}
player.$damagepop(-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.delayx();
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,false);
if(lib.config.animation&&!lib.config.low_performance){
player.$recover();
}
player.$damagepop(num,'wood');
game.log(player,'回复了'+get.cnNumber(num)+'点体力')
}
},
loseHp:function(){
"step 0"
if(lib.config.background_audio){
game.playAudio('effect','loseHp');
}
game.log(player,'失去了'+get.cnNumber(num)+'点体力')
player.changeHp(-num);
"step 1"
if(player.hp<=0){
game.delayx();
player.dying(event);
}
},
doubleDraw:function(){
"step 0"
player.chooseBool('你的武将牌上有单独的阴阳鱼,是否摸一张牌?');
"step 1"
if(result.bool){
player.draw();
}
},
loseMaxHp:function(){
"step 0"
game.log(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(player,'获得了'+get.cnNumber(num)+'点体力上限');
if(!event.forced&&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.$damagepop(num,'water');
}
event.trigger('changeHp');
},
dying:function(){
"step 0"
_status.dying=player;
event.trigger('dying');
game.log(player,'濒死')
"step 1"
if(_status.dying==player) delete _status.dying;
if(player.hp<=0) player.die(event.reason);
},
die:function(){
if(source){
game.log(player,'被',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(player,'遇难')
}
event.cards=player.get('hej');
event.playerCards=player.get('he');
if(event.cards.length){
for(var i=0;i'+get.translation(cards[0].viewAs)+'(',cards,')');
}
else{
game.log(player,'被贴上了',cards);
}
game.addVideo('addJudge',player,[get.cardInfo(cards[0]),cards[0].viewAs]);
}
},
judge:function(){
"step 0"
var judgestr=get.translation(player)+'的'+event.judgestr+'判定';
event.videoId=lib.status.videoId++;
player.judging.unshift(get.cards()[0]);
game.addVideo('judge1',player,[get.cardInfo(player.judging[0]),judgestr,event.videoId]);
if(lib.config.mode=='chess'){
event.node=player.judging[0].copy('thrown','center',ui.arena).animate('start');
}
else{
event.node=player.$throwordered(player.judging[0].copy(),true);
}
event.node.classList.add('thrownhighlight');
ui.arena.classList.add('thrownhighlight');
event.dialog=ui.create.dialog(judgestr);
event.dialog.classList.add('center');
game.log(player,'进行'+event.judgestr+'判定,亮出的判定牌为',player.judging[0]);
game.delay(2);
event.trigger('judge');
"step 1"
event.result={
card:player.judging[0],
number:get.number(player.judging[0]),
suit:get.suit(player.judging[0]),
color:get.color(player.judging[0]),
judge:event.judge(player.judging[0]),
node:event.node,
};
if(event.result.judge>0) event.result.bool=true;
if(event.result.judge<0) event.result.bool=false;
player.judging.shift();
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.addVideo('judge2',null,event.videoId);
ui.arena.classList.remove('thrownhighlight');
game.log(player,'的判定结果为',event.result.card);
if(!get.owner(event.result.card)) event.position.appendChild(event.result.card);
},
turnOver:function(){
game.log(player,'翻面');
player.classList.toggle('turnedover');
game.addVideo('turnOver',player,player.classList.contains('turnedover'));
},
link:function(){
if(player.isLinked()){
game.log(player,'解除连环');
}
else{
game.log(player,'被连环');
}
if(lib.config.background_audio){
game.playAudio('effect','link');
}
player.classList.remove('target');
player.classList.toggle('linked');
game.addVideo('link',player,player.classList.contains('linked'));
},
},
player:{
init:function(character,character2,skill){
if(!lib.character[character]) return;
if(character2==false){
skill=false;
character2=null;
}
var info=lib.character[character];
var skills=info[3];
this.skills.length=0;
this.classList.add('fullskin');
if(!game.minskin&&lib.isNewLayout()&&!info[4].contains('minskin')){
this.classList.remove('minskin');
this.node.avatar.setBackground(character,'character');
}
else{
this.node.avatar.setBackground(character,'character');
if(info[4].contains('minskin')){
this.classList.add('minskin');
}
else if(game.minskin){
this.classList.add('minskin');
}
else{
this.classList.remove('minskin');
}
}
this.node.avatar.show();
this.node.count.show();
this.node.equips.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;
switch(this.group){
case 'wei':this.node.name.dataset.nature='watermm';break;
case 'shu':this.node.name.dataset.nature='soilmm';break;
case 'wu':this.node.name.dataset.nature='woodmm';break;
case 'qun':this.node.name.dataset.nature='metalmm';break;
}
if(lib.config.touchscreen){
lib.setLongPress(this,ui.click.intro);
}
else{
if(lib.config.hover_all){
lib.setHover(this,ui.click.hoverplayer);
}
if(lib.config.right_info){
this.oncontextmenu=ui.click.rightplayer;
}
}
// var name=get.translation(character);
this.node.name.innerHTML=get.slimName(character);
if(!lib.config.show_name){
this.node.name.style.display='none';
}
// for(var i=0;i';
// }
if(character2&&lib.character[character2]){
var info2=lib.character[character2];
this.classList.add('fullskin2');
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]);
// var name=get.translation(character2);
this.node.name2.innerHTML=get.slimName(character2);
if(!lib.config.show_name){
this.node.name2.style.display='none';
}
// for(var i=0;i';
// }
}
if(skill!=false){
for(var i=0;i=this.maxHp) this.hp=this.maxHp;
var hp=this.node.hp;
hp.style.transition='none';
if(!_status.video){
if(this.hujia){
this.markSkill('ghujia');
}
else{
this.unmarkSkill('ghujia');
}
}
if(this.maxHp==Infinity){
hp.innerHTML='∞';
}
else if(lib.config.layout=='default'&&this.maxHp>14){
hp.innerHTML=this.hp+'/'+this.maxHp;
hp.classList.add('text');
}
else if(lib.isNewLayout()&&
(
this.maxHp>9||
(this.maxHp>5&&this.classList.contains('minskin'))||
((lib.config.layout=='mobile'||lib.config.layout=='phone')&&this.dataset.position==0&&this.maxHp>7)
)){
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(_status.video){
numh=arguments[0];
}
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;
}
if(this.updates){
for(var i=0;i0){
cards.splice(arg2);
}
else if(typeof arg2=='function'){
for(i=0;i0){
game.log(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;i1){
next.drawDeck=1;
}
return next;
},
discard:function(){
var next=game.createEvent('discard');
next.player=this;
next.num=0;
for(var i=0;i0){
this.node.handcards1.insertBefore(cards[i],this.node.handcards1.firstChild);
}
else{
this.node.handcards2.insertBefore(cards[i],this.node.handcards2.firstChild);
}
}
if(this==game.me||_status.video) ui.updatehl();
if(!_status.video){
game.addVideo('directgain',this,get.cardsInfo(cards));
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);
if(!name2) return;
this.$damagepop(name2,className||'water',true);
},
popup_old:function(name,className){
var name2=get.translation(name);
var node=ui.create.div('.popup',this.parentNode);
if(!name2){
node.remove();
return node;
}
game.addVideo('popup',this,[name,className]);
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(get.itemtype(card)=='card'){
game.addVideo('markSkill',this,[name,get.cardInfo(card)]);
}
else{
game.addVideo('markSkill',this,[name]);
}
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);
}
}
this.updateMarks();
return this;
},
unmarkSkill:function(name){
game.addVideo('unmarkSkill',this,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){
if(info.intro.onunmark=='throw'){
if(get.itemtype(this.storage[name])=='cards'){
this.$throw(this.storage[name]);
while(this.storage[name].length){
ui.discardPile.appendChild(this.storage[name].shift());
}
}
}
else if(typeof info.intro.onunmark=='function'){
info.intro.onunmark(this.storage[name],this);
}
}
}
},
markSkillCharacter:function(target,name,content,id){
if(typeof target=='object'){
target=target.name;
}
if(this.marks[id]){
if(this.marks[id]._name==target){
return this;
}
this.marks[id].name=name+'_charactermark';
this.marks[id]._name=target;
this.marks[id].info={
name:name,
content:content
};
this.marks[id].setBackground(target,'character');
game.addVideo('changeMarkCharacter',this,{
id:id,
name:name,
content:content,
target:target
});
}
else{
this.marks[id]=this.markCharacter(target,{
name:name,
content:content
});
this.marks[id]._name=target;
game.addVideo('markCharacter',this,{
name:name,
content:content,
id:id,
target:target
});
}
return 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);
}
else{
if(lib.config.hover_all){
lib.setHover(node,ui.click.hoverplayer);
}
if(lib.config.right_info){
node.oncontextmenu=ui.click.rightplayer;
}
}
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){
var total=config.total,current=config.current;
var dxtotal;
if(total<=5){
dxtotal=Math.min(80,(total-1)*20);
dx+=-dxtotal+2*dxtotal*(current-1)/(total-1)
}
else{
var total2=Math.floor(total/2);
if(current<=total2){
total=total2;
dy-=20;
}
else{
current-=total2;
total-=total2;
dy+=20;
}
dxtotal=Math.min(80,(total-1)*20);
dx+=-dxtotal+2*dxtotal*(current-1)/(total-1)
}
config.current++;
}
if(node.style.transform&&node.style.transform!='none'&&node.style.transform.indexOf('translate')==-1){
node.style.transform+=' translate('+dx+'px,'+dy+'px)';
}
else{
node.style.transform='translate('+dx+'px,'+dy+'px)';
}
node.show();
node.addEventListener('webkitTransitionEnd',function(){
node.style.transitionDuration='0.5s';
ui.refresh(node);
node.delete();
});
var that=this;
if(num&&num>1){
if(config&&config.total>1){
setTimeout(function(){
if(cards){
that.$draw(cards,false,config)
}
else{
that.$draw(num-1,false,config)
}
},50)
}
else{
setTimeout(function(){
if(cards){
that.$draw(cards,false,config)
}
else{
that.$draw(num-1,false,config)
}
},200);
}
}
},
$compare:function(card1,target,card2){
game.addVideo('compare',this,[get.cardInfo(card1),target.dataset.position,get.cardInfo(card2)]);
var player=this;
var node1=player.$throwxy2(card1,
'calc(50% - 114px)','calc(50% - 52px)','perspective(600px) rotateY(180deg)',true
);
if(lib.config.cardback_style!='default'){
node1.style.transitionProperty='none';
ui.refresh(node1);
node1.classList.add('infohidden');
ui.refresh(node1);
node1.style.transitionProperty='';
}
else{
node1.classList.add('infohidden');
}
node1.style.transform='perspective(600px) rotateY(180deg) translateX(0)';
var onEnd01=function(){
node1.removeEventListener('webkitTransitionEnd',onEnd01);
setTimeout(function(){
node1.style.transition='all ease-in 0.3s';
node1.style.transform='perspective(600px) rotateY(270deg) translateX(52px)';
var onEnd=function(){
node1.classList.remove('infohidden');
node1.style.transition='all 0s';
ui.refresh(node1);
node1.style.transform='perspective(600px) rotateY(-90deg) translateX(52px)';
ui.refresh(node1);
node1.style.transition='';
ui.refresh(node1);
node1.style.transform='';
node1.removeEventListener('webkitTransitionEnd',onEnd);
}
node1.addEventListener('webkitTransitionEnd',onEnd);
},300);
};
node1.addEventListener('webkitTransitionEnd',onEnd01);
setTimeout(function(){
var node2=target.$throwxy2(card2,
'calc(50% + 10px)','calc(50% - 52px)','perspective(600px) rotateY(180deg)',true
);
if(lib.config.cardback_style!='default'){
node2.style.transitionProperty='none';
ui.refresh(node2);
node2.classList.add('infohidden');
ui.refresh(node2);
node2.style.transitionProperty='';
}
else{
node2.classList.add('infohidden');
}
node2.style.transform='perspective(600px) rotateY(180deg) translateX(0)';
var onEnd02=function(){
node2.removeEventListener('webkitTransitionEnd',onEnd02);
setTimeout(function(){
node2.style.transition='all ease-in 0.3s';
node2.style.transform='perspective(600px) rotateY(270deg) translateX(52px)';
var onEnd=function(){
node2.classList.remove('infohidden');
node2.style.transition='all 0s';
ui.refresh(node2);
node2.style.transform='perspective(600px) rotateY(-90deg) translateX(52px)';
ui.refresh(node2);
node2.style.transition='';
ui.refresh(node2);
node2.style.transform='';
node2.removeEventListener('webkitTransitionEnd',onEnd);
}
node2.addEventListener('webkitTransitionEnd',onEnd);
},200);
};
node2.addEventListener('webkitTransitionEnd',onEnd02);
},200);
},
$throw:function(card,time,init){
if(init!==false){
if(get.itemtype(card)!='cards'){
if(get.itemtype(card)=='card'){
card=[card];
}
else{
return;
}
}
game.addVideo('throw',this,[get.cardsInfo(card),time]);
}
if(get.itemtype(card)=='cards'){
var node;
for(var i=0;i=0){
game.addVideo('give',this,[card,player.dataset.position]);
}
else{
if(get.itemtype(card)=='card'){
card=[card];
}
if(get.itemtype(card)=='cards'){
game.addVideo('giveCard',this,[get.cardsInfo(card),player.dataset.position]);
}
}
}
if(get.itemtype(card)=='cards'){
if(log!=false){
game.log(player,'从',this,'获得了',card);
}
if(this.$givemod){
this.$givemod(card,player);
}
else{
for(var i=0;i=0){
if(log!=false){
game.log(player,'从',this,'获得了'+get.cnNumber(card)+'张牌');
}
if(this.$givemod){
this.$givemod(card,player);
}
else{
while(card--) this.$give('',player,false,false);
}
}
else{
if(log!=false){
if(get.itemtype(card)=='card'&&log!=false){
game.log(player,'从',this,'获得了',card);
}
else{
game.log(player,'从',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;
this.$throwordered(node);
// lib.listenEnd(node);
// node.hide();
// node.style.transitionProperty='left,top,opacity';
//
// node.style.transform='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)';
node.addEventListener('webkitTransitionEnd',function(){
var dx=player.offsetLeft+player.offsetWidth/2-52-node.offsetLeft;
var dy=player.offsetTop+player.offsetHeight/2-52-node.offsetTop;
if(node.style.transform&&node.style.transform!='none'&&node.style.transform.indexOf('translate')==-1){
node.style.transform+=' translate('+dx+'px,'+dy+'px)';
}
else{
node.style.transform='translate('+dx+'px,'+dy+'px)';
}
node.delete();
});
// setTimeout(function(){
// // node.removeAttribute('style');
// // node.dataset.position=player.dataset.position;
// var dx=player.offsetLeft+player.offsetWidth/2-52-node.offsetLeft;
// var dy=player.offsetTop+player.offsetHeight/2-52-node.offsetTop;
// if(node.style.transform&&node.style.transform!='none'&&node.style.transform.indexOf('translate')==-1){
// node.style.transform+=' translate('+dx+'px,'+dy+'px)';
// }
// else{
// node.style.transform='translate('+dx+'px,'+dy+'px)';
// }
//
// node.delete();
// },700);
}
}
},
$equip:function(card){
card.style.transform='';
var player=this;
var equipNum=get.equipNum(card);
var equipped=false;
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);
}
return player;
},
$gain:function(card,log,init){
if(init!==false){
if(typeof card=='number'&&card>=0){
game.addVideo('gain',this,card);
}
else{
if(get.itemtype(card)=='card'){
card=[card];
}
if(get.itemtype(card)=='cards'){
game.addVideo('gainCard',this,get.cardsInfo(card));
}
else{
game.addVideo('gain',this,1);
}
}
}
if(get.itemtype(card)=='cards'){
if(log!=false){
game.log(this,'获得了',card);
}
if(this.$gainmod){
this.$gainmod(card);
}
else{
for(var i=0;i1){
if(log!=false){
game.log(this,'获得了'+get.cnNumber(card)+'张牌');
}
if(this.$gainmod){
this.$gainmod(card);
}
else{
for(var i=0;i0.3){
cards[i].clone.moveDelete(this);
list2.push(cards[i].clone);
}
else{
list.push(cards[i]);
}
}
if(list2.length){
game.addVideo('gain2',this,get.cardsInfo(list2));
}
if(list.length) this.$draw(list);
},
$skill:function(name,type,color){
if(typeof type!='string') type='legend';
game.delay(2);
this.playerfocus(1500);
var that=this;
setTimeout(function(){
if(lib.config.animation&&!lib.config.low_performance){
if(lib.config.mode=='chess'){
that['$'+type+'2'](1200);
}
else{
that['$'+type](1200);
}
}
if(name){
that.$fullscreenpop(name,color);
}
},300);
},
$fire:function(){
game.addVideo('flame',this,'fire');
var left,top;
if(lib.config.mode=='chess'){
var rect=this.getBoundingClientRect();
left=rect.left;
top=rect.top;
}
else{
left=this.offsetLeft;
top=this.offsetTop;
}
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-20,700,'fire');
},
$thunder:function(){
game.addVideo('flame',this,'thunder');
var left,top;
if(lib.config.mode=='chess'){
var rect=this.getBoundingClientRect();
left=rect.left;
top=rect.top;
}
else{
left=this.offsetLeft;
top=this.offsetTop;
}
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,700,'thunder');
},
$rare2:function(){
game.addVideo('flame',this,'rare2');
var rect=this.getBoundingClientRect();
var left=rect.left;
var top=rect.top+15;
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,700,'rare');
},
$epic2:function(){
game.addVideo('flame',this,'epic2');
var rect=this.getBoundingClientRect();
var left=rect.left;
var top=rect.top+15;
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,700,'epic');
},
$legend2:function(){
game.addVideo('flame',this,'legend2');
var rect=this.getBoundingClientRect();
var left=rect.left;
var top=rect.top+15;
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,700,'legend');
},
$rare:function(time){
time=time||700;
game.addVideo('flame',this,'rare');
var left,top;
if(lib.config.mode=='chess'){
left=this.offsetLeft-ui.arena.offsetLeft;
top=this.offsetTop-ui.arena.offsetTop;
}
else{
left=this.offsetLeft;
top=this.offsetTop;
}
if(this.classList.contains('minskin')){
top+=15;
}
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,time,'rare');
},
$epic:function(time){
time=time||700;
game.addVideo('flame',this,'epic');
var left,top;
if(lib.config.mode=='chess'){
left=this.offsetLeft-ui.arena.offsetLeft;
top=this.offsetTop-ui.arena.offsetTop;
}
else{
left=this.offsetLeft;
top=this.offsetTop;
}
if(this.classList.contains('minskin')){
top+=15;
}
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,time,'epic');
},
$legend:function(time){
time=time||700;
game.addVideo('flame',this,'legend');
var left,top;
if(lib.config.mode=='chess'){
left=this.offsetLeft-ui.arena.offsetLeft;
top=this.offsetTop-ui.arena.offsetTop;
}
else{
left=this.offsetLeft;
top=this.offsetTop;
}
if(this.classList.contains('minskin')){
top+=15;
}
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,time,'legend');
},
$coin:function(){
game.addVideo('flame',this,'coin');
var left=this.offsetLeft-ui.arena.offsetLeft;
var top=this.offsetTop-ui.arena.offsetTop;
if(this.classList.contains('minskin')){
top+=15;
}
top-=25;
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,700,'coin');
},
$dust:function(){
game.addVideo('flame',this,'dust');
var left=this.offsetLeft-ui.arena.offsetLeft;
var top=this.offsetTop-ui.arena.offsetTop;
if(this.classList.contains('minskin')){
top+=15;
}
top-=25;
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,700,'dust');
},
$recover:function(){
game.addVideo('flame',this,'recover');
var left,top;
if(lib.config.mode=='chess'){
var rect=this.getBoundingClientRect();
left=rect.left;
top=rect.top;
}
else{
left=this.offsetLeft;
top=this.offsetTop;
}
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,700,'recover');
},
$sha:function(nature){
if(this._shaing){
return;
}
this._shaing=true;
var player=this;
setTimeout(function(){
player._shaing=false;
},1000);
var node=ui.create.div('.cardeffect',this);
node.innerHTML='殺';
node.dataset.nature=nature||'black';
return node;
},
$fullscreenpop:function(str,nature){
game.addVideo('fullscreenpop',this,[str,nature]);
var node=ui.create.div('.damage',ui.window);
node.innerHTML=str;
node.dataset.nature=nature||'soil';
ui.refresh(node);
node.classList.add('damageadded');
setTimeout(function(){
node.delete();
},1000);
},
$damagepop:function(num,nature,font){
if(typeof num=='number'||typeof num=='string'){
game.addVideo('damagepop',this,[num,nature,font]);
var node=ui.create.div('.damage');
if(font){
node.classList.add('normal-font');
}
if(typeof num=='number'&&num>0){
num='+'+num;
}
node.innerHTML=num;
this.damagepopups.push(node);
node.dataset.nature=nature||'soil';
if(this.damagepopups.length==1){
this.$damagepop();
}
}
else if(this.damagepopups.length){
var node=this.damagepopups[0];
this.appendChild(node);
ui.refresh(node);
node.classList.add('damageadded');
node.addEventListener('webkitTransitionEnd',function(){
setTimeout(function(){
node.delete();
},200);
});
// setTimeout(function(){
// node.delete();
// },500);
var that=this;
setTimeout(function(){
that.damagepopups.shift();
that.$damagepop();
},500);
}
},
$damage:function(source){
if(get.itemtype(source)=='player'){
game.addVideo('damage',this,source.dataset.position);
}
else{
game.addVideo('damage',this);
}
if(source&&source!=this&&lib.config.damage_shake){
var left,top;
if(source.offsetTop==this.offsetTop){
left=20;
top=0;
}
else{
var ratio=(source.offsetLeft-this.offsetLeft)/(source.offsetTop-this.offsetTop);
left=Math.abs(20*ratio/Math.sqrt(1+ratio*ratio));
top=Math.abs(20/Math.sqrt(1+ratio*ratio));
}
if(source.offsetLeft-this.offsetLeft>0) left=-left;
if(source.offsetTop-this.offsetTop>0) top=-top;
if(lib.isMobileMe(this)){
if(this.isLinked()){
this.node.avatar.style.transform='translate('+left+'px,'+top+'px) rotate(-90deg)';
this.node.avatar2.style.transform='translate('+left+'px,'+top+'px) rotate(-90deg)';
}
else{
this.node.avatar.style.transform='translate('+left+'px,'+top+'px)';
this.node.avatar2.style.transform='translate('+left+'px,'+top+'px)';
}
}
else if(this.isLinked()&&lib.isNewLayout()){
this.style.transform='translate('+left+'px,'+top+'px) rotate(-90deg)';
}
else{
this.style.transform='translate('+left+'px,'+top+'px)';
}
}
else{
var zoom1=0.9,zoom2=0.95;
if(arguments[1]=='phase'){
zoom1=1.05;
zoom2=1.05;
}
if(lib.isMobileMe(this)){
if(this.isLinked()){
this.node.avatar.style.transform='scale('+zoom1+') rotate(-90deg)';
this.node.avatar2.style.transform='scale('+zoom1+') rotate(-90deg)';
}
else{
this.node.avatar.style.transform='scale('+zoom1+')';
this.node.avatar2.style.transform='scale('+zoom1+')';
}
}
else if(this.isLinked()&&lib.isNewLayout()){
this.style.transform='scale('+zoom2+') rotate(-90deg)';
}
else{
this.style.transform='scale('+zoom2+')';
}
}
this.queue();
},
$die:function(){
game.addVideo('die',this);
if(lib.config.die_flip){
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;
if(lib.isMobileMe(this)){
left=-Math.random()*5-10;
top=Math.random()*5+10;
}
var transform='translate('+left+'px,'+top+'px) '+
'rotate('+(Math.random()*20-10)+'deg) '+
((Math.random()-0.5<0)?'rotateX(180deg)':'rotateY(180deg)');
if(lib.isMobileMe(this)){
this.node.avatar.style.transform=transform;
this.node.avatar2.style.transform=transform;
}
else{
this.style.transform=transform;
}
this.queue(false);
}
},
$phaseJudge:function(card){
game.addVideo('phaseJudge',this,get.cardInfo(card));
var player=this;
var clone=player.$throw(card);
if(lib.config.low_performance&&card&&card.clone){
var waitingForTransition=get.time();
_status.waitingForTransition=waitingForTransition;
card.clone.addEventListener('webkitTransitionEnd',function(){
if(_status.waitingForTransition==waitingForTransition&&_status.paused){
game.resume();
}
});
game.pause();
}
else{
game.delay();
}
}
},
card:{
init:function(card){
if(Array.isArray(card)){
if(card[2]=='huosha'){
card[2]='sha';
card[3]='fire';
}
if(card[2]=='leisha'){
card[2]='sha';
card[3]='thunder';
}
}
var bg=card[2];
var img=lib.card[card[2]].image;
if(img&&img.indexOf('db:')==0){
img=img.slice(3);
}
else{
img=null;
}
if(!lib.config.hide_card_image&&lib.card[card[2]].fullskin){
this.classList.add('fullskin');
if(img){
this.node.image.setBackgroundDB(img);
}
else{
this.node.image.setBackgroundImage('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]].fullimage){
if(img){
this.setBackgroundDB(img);
}
else{
this.setBackground('card/'+bg);
}
}
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'&&!lib.card[card[2]].fullskin){
if(img){
this.setBackgroundDB(img);
}
else{
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]].noname){
this.node.name.style.display='none';
}
if(lib.card[card[2]].color){
this.style.color=lib.card[card[2]].color;
}
else if(lib.card[card[2]].fullimage){
this.style.color='white';
}
if(lib.card[card[2]].textShadow){
this.style.textShadow=lib.card[card[2]].textShadow;
}
else if(lib.card[card[2]].fullimage){
this.style.textShadow='black 0 0 2px';
}
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;
}
else if(lib.card[card[2]].fullimage){
this.node.info.style.opacity=1;
this.node.name.style.opacity=1;
}
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('.range',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='';
this.node.image.className='image';
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]);
}
else if(this.nature){
this.classList.remove(this.nature);
delete this.nature;
}
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();
}
// if(ui.arenalog){
// ui.arenalog.classList.remove('withdialog');
// }
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);
if(lib.config.button_press){
node.addEventListener(lib.config.touchscreen?'touchstart':'mousedown',function(){
node.classList.add('controlthundertext');
node.parentNode.classList.add('controlpressdown');
node.parentNode.classList.add('controlpressdownx');
});
node.addEventListener(lib.config.touchscreen?'touchend':'mouseup',function(){
node.classList.remove('controlthundertext');
node.parentNode.classList.remove('controlpressdown');
node.parentNode.classList.remove('controlpressdownx');
// setTimeout(function(){
// if(node.parentNode)
// },200);
});
node.addEventListener(lib.config.touchscreen?'touchmove':'mousemove',function(){
node.classList.remove('controlthundertext');
node.parentNode.classList.remove('controlpressdown');
node.parentNode.classList.remove('controlpressdownx');
});
}
},
close:function(){
ui.controls.remove(this);
this.delete();
setTimeout(ui.updatec,100);
if(ui.confirm==this) delete ui.confirm;
if(ui.skills==this) delete ui.skills;
if(ui.skills2==this) delete ui.skills2;
if(ui.skills3==this) delete ui.skills3;
},
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(){
if(!player.noPhaseDelay&&lib.config.show_phase_prompt){
player.popup('回合开始');
}
if(lib.config.glow_phase){
if(_status.currentPhase){
_status.currentPhase.classList.remove('glow_phase');
}
player.classList.add('glow_phase');
// player.dataset.glow_phase=lib.config.glow_phase;
// player.animate('playerbright',500);
}
// player.$damage(null,'phase')
game.addVideo('phaseChange',player);
_status.currentPhase=player;
game.log();
game.log(player,'的回合开始');
game.phaseNumber++;
player._noVibrate=true;
if(get.config('identity_mode')!='zhong'){
var num;
switch(get.config('auto_identity')){
case 'one':num=1;break;
case 'two':num=2;break;
case 'three':num=3;break;
case 'always':num=-1;break;
default:num=0;break;
}
if(num&&!_status.identityShown&&game.phaseNumber>game.players.length*num&&game.showIdentity){
if(!_status.video) player.popup('显示身份');
_status.identityShown=true;
game.showIdentity(false);
}
}
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(lib.config.tao_enemy&&event.dying.side!=player.side&&lib.config.mode!='identity'&&lib.config.mode!='guozhan'){
event._result={bool:false}
}
else if(player.hasSkillTag('save',true)||player.num('h','tao')||player.num('h','spell_zhiliaoshui')||
(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);
},
check:function(card){
if(get.type(card)=='stonecharacter'&&_status.event.player.num('h',{type:'stonecharacter'})<=1){
return 0;
}
return 1;
},
discard:false,
delay:0.5,
content:function(){
"step 0"
if(lib.config.mode=='stone'&&_status.mode=='deck'&&
!player.isMin()&&get.type(cards[0]).indexOf('stone')==0){
var list=[];
for(var i=0;i|\|/g,'.');
if(lib.device){
var directory;
if(lib.device=='android'){
directory=cordova.file.externalDataDirectory;
}
else{
directory=cordova.file.documentsDirectory;
}
window.resolveLocalFileSystemURL(directory,function(entry){
entry.getFile(fileNameToSaveAs,{create:true},function(fileEntry){
fileEntry.createWriter(function(fileWriter){
fileWriter.onwriteend=function(){
alert('文件已导出至'+directory+fileNameToSaveAs);
}
fileWriter.write(textFileAsBlob)
});
});
});
}
else{
var downloadLink = document.createElement("a");
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = "Download File";
downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
downloadLink.click();
}
},
exportCharacters:function(packname,list,callback){
var zipReady=function(){
var zip=new JSZip();
var imageLoaded=0;
var character={
name:packname||'noname',
character:{},
skill:{},
};
var load=function(img){
var blob = zip.generate({type:"blob"});
var fileNameToSaveAs = packname||'noname';
fileNameToSaveAs=fileNameToSaveAs.replace(/\\|\/|\:|\?|\"|\*|\<|\>|\|/g,'.');
fileNameToSaveAs+='.zip';
if(lib.device){
var directory;
if(lib.device=='android'){
directory=cordova.file.externalDataDirectory;
}
else{
directory=cordova.file.documentsDirectory;
}
window.resolveLocalFileSystemURL(directory,function(entry){
entry.getFile(fileNameToSaveAs,{create:true},function(fileEntry){
fileEntry.createWriter(function(fileWriter){
fileWriter.onwriteend=function(){
alert('文件已导出至'+directory+fileNameToSaveAs);
}
fileWriter.write(blob)
});
});
});
}
else{
var downloadLink = document.createElement("a");
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = "Download File";
downloadLink.href = window.URL.createObjectURL(blob);
downloadLink.click();
}
if(typeof callback=='function'){
callback(character);
}
};
for(var i=0;i1){
slow.classList.add('glow');
}
else{
slow.classList.remove('glow');
}
if(_status.videoDuration<1){
fast.classList.add('glow');
}
else{
fast.classList.remove('glow');
}
}
ui.system.style.display='';
ui.refresh(ui.system);
ui.system.show();
ui.window.show();
if(lib.config.mode!='versus'&&lib.config.mode!='boss'){
ui.arena.style.display='';
ui.refresh(ui.arena);
ui.arena.show();
}
if(lib.config.mode!='chess'){
game.playerMap={};
}
game.finishCards();
'step 2'
if(event.video.length){
var content=event.video.shift();
// console.log(content);
if(content.type=='delay'){
game.delay(content.content);
}
else if(content.type=='play'){
window.play={};
if(!event.playtoload){
event.playtoload=1;
}
else{
event.playtoload++;
}
var script=lib.init.js(lib.assetURL+'play',content.name);
script.addEventListener('load',function(){
var play=window.play[content.name]
if(play&&play.video){
play.video(content.init);
}
event.playtoload--;
if(event.playtoload==0){
delete window.play;
}
});
}
else if(typeof content.player=='string'&&game.playerMap[content.player]&&
game.playerMap[content.player].classList&&
!game.playerMap[content.player].classList.contains('obstacle')){
game.videoContent[content.type](game.playerMap[content.player],content.content);
}
else{
game.videoContent[content.type](content.content);
}
if(event.video.length){
game.delay(0,_status.videoDuration*Math.min(2000,event.video[0].delay));
}
event.redo();
}
else{
_status.over=true;
ui.system.lastChild.hide();
setTimeout(function(){
ui.system.lastChild.innerHTML='';
},500);
}
}
game.loop();
},
videoContent:{
init:function(players){
if(lib.config.mode=='chess') return;
if(lib.config.mode=='versus'){
players.bool=players.pop();
}
ui.arena.dataset.number=players.length;
ui.arena.classList.add('video');
game.players.length=0;
game.dead.length=0;
ui.create.players(players.length);
game.me=game.players[0];
ui.handcards1=game.me.node.handcards1;
ui.handcards2=game.me.node.handcards2;
ui.handcards1Container.appendChild(ui.handcards1);
ui.handcards2Container.appendChild(ui.handcards2);
if(lib.config.mode=='versus'){
if(players.bool){
ui.arena.dataset.number=parseInt(ui.arena.dataset.number)+1;
for(var i=0;i.card,#chess>.card');
var nodes=[];
for(var i=0;i.card,#chess>.card');
var nodes=[];
for(var i=0;i.card,#chess>.card');
var nodes=[];
for(var i=0;i=0;j--){
if(card[2]==nodes[j].name&&card[0]==nodes[j].suit&&card[1]==nodes[j].number){
nodes[j].classList.add('thrownhighlight');
break;
}
}
}
else{
console.log(player,cards);
}
},
uiClear:function(){
ui.clear();
},
judge1:function(player,content){
if(player&&content){
var judging=get.infoCard(content[0]);
if(lib.config.mode=='chess'){
judging.copy('thrown','center','thrownhighlight',ui.arena).animate('start');
}
else{
player.$throwordered(judging.copy('thrownhighlight'),true);
}
ui.create.dialog(content[1]).videoId=content[2];
ui.arena.classList.add('thrownhighlight');
}
else{
console.log(player);
}
},
centernode:function(content){
get.infoCard(content).copy('thrown','center','thrownhighlight',ui.arena).animate('start');
},
judge2:function(videoId){
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;
}
}
},
link:function(player,bool){
if(player&&player.classList){
if(bool){
player.classList.add('linked');
}
else{
player.classList.remove('linked');
}
}
else{
console.log(player);
}
},
turnOver:function(player,bool){
if(player&&player.classList){
if(bool){
player.classList.add('turnedover');
}
else{
player.classList.remove('turnedover');
}
}
else{
console.log(player);
}
},
showCards:function(player,info){
if(info){
var dialog=ui.create.dialog(info[0],get.infoCards(info[1]));
setTimeout(function(){
dialog.close();
},1000);
}
else{
console.log(player);
}
},
cardDialog:function(content){
if(Array.isArray(content)){
ui.create.dialog(content[0],get.infoCards(content[1])).videoId=content[2];
}
else if(typeof content=='number'){
for(var i=0;ix){
this.speed.x=Math.abs(this.speed.x);
}
this.life*=1.3;
this.death*=1.3;
break;
}
case 'dust':{
this.r = Math.round(Math.random()*55)+105;
this.g = Math.round(Math.random()*55)+150;
this.b = 255;
this.location.x+=Math.round(Math.random()*60)-30;
this.location.y+=Math.round(Math.random()*40)-20;
if(this.location.xx){
this.speed.x=Math.abs(this.speed.x);
}
this.life*=1.3;
this.death*=1.3;
break;
}
case 'legend':{
this.r = 255;
this.g = Math.round(Math.random()*100+155);
this.b = Math.round(Math.random()*100+50);
this.location.x+=Math.round(Math.random()*60)-30;
this.location.y+=Math.round(Math.random()*40)-20;
if(this.location.xx){
this.speed.x=Math.abs(this.speed.x);
}
this.speed.x/=2;
this.speed.y/=2;
this.life*=2;
this.death*=2;
break;
}
case 'epic':{
this.r = Math.round(Math.random()*55)+200;
this.g = Math.round(Math.random()*100)+55;
this.b = 255;
this.location.x+=Math.round(Math.random()*60)-30;
this.location.y+=Math.round(Math.random()*40)-20;
if(this.location.xx){
this.speed.x=Math.abs(this.speed.x);
}
this.speed.x/=2;
this.speed.y/=2;
this.life*=2;
this.death*=2;
break;
}
case 'rare':{
this.r = Math.round(Math.random()*55)+105;
this.g = Math.round(Math.random()*55)+150;
this.b = 255;
this.location.x+=Math.round(Math.random()*60)-30;
this.location.y+=Math.round(Math.random()*40)-20;
if(this.location.xx){
this.speed.x=Math.abs(this.speed.x);
}
this.speed.x/=2;
this.speed.y/=2;
this.life*=2;
this.death*=2;
break;
}
case 'recover':{
this.g = 255;
this.r = Math.round(Math.random()*200+55);
this.b = Math.round(Math.random()*155+55);
this.location.x+=Math.round(Math.random()*60)-30;
this.location.y+=Math.round(Math.random()*40)-20;
if(this.location.xx){
this.speed.x=Math.abs(this.speed.x);
}
this.speed.x/=2;
this.speed.y/=2;
this.life*=2;
this.death*=2;
break;
}
default:{
this.r = 255;
this.g = Math.round(Math.random()*155);
this.b = 0;
}
}
}
game.draw(function(time,surface){
surface.globalCompositeOperation = "source-over";
surface.globalCompositeOperation = "lighter";
for(var i = 0; i < particles.length; i++)
{
var p = particles[i];
surface.beginPath();
var middle=0.5;
var radius=p.radius;
if(type=='recover'||type=='legend'||type=='rare'||
type=='epic'||type=='coin'||type=='dust'){
middle=0.7;
radius/=3;
}
p.opacity = Math.round(p.death/p.life*100)/100
var gradient = surface.createRadialGradient(p.location.x, p.location.y, 0, p.location.x, p.location.y, p.radius);
gradient.addColorStop(0, "rgba("+p.r+", "+p.g+", "+p.b+", "+p.opacity+")");
gradient.addColorStop(middle, "rgba("+p.r+", "+p.g+", "+p.b+", "+p.opacity+")");
gradient.addColorStop(1, "rgba("+p.r+", "+p.g+", "+p.b+", 0)");
surface.fillStyle = gradient;
surface.arc(p.location.x, p.location.y, radius, Math.PI*2, false);
surface.fill();
p.death--;
if(type=='recover'){
p.radius+=0.5;
}
else if(type=='coin'||type=='dust'){
p.radius+=0.7;
}
else if(type=='legend'||type=='rare'||type=='epic'){
p.radius+=0.5;
}
else {
p.radius++;
}
p.location.x += (p.speed.x);
p.location.y += (p.speed.y);
if(p.death < 0 || p.radius < 0){
if(typeof duration=='number'&&time+500>=duration){
particles.splice(i--,1);
}
else{
particles[i] = new particle();
}
}
}
if(particles.length==0){
return false;
}
});
}
},
linexy:function(path){
// if(lib.config.mode=='chess'){
// return game._linexy.apply(this,arguments);
// }
var from=[path[0],path[1]];
var to=[path[2],path[3]];
var total=typeof arguments[1]==='number'?arguments[1]:lib.config.duration*2;
var opacity=1;
var color=[255,255,255];
var dashed=false;
if(typeof arguments[1]=='object'){
for(var i in arguments[1]){
switch(i){
case 'opacity':opacity=arguments[1][i];break;
case 'color':color=arguments[1][i];break;
case 'dashed':dashed=arguments[1][i];break;
case 'duration':total=arguments[1][i];break;
}
}
}
else if(arguments[1]=='fire'||arguments[1]=='thunder'||arguments[1]=='green'){
color=arguments[1];
}
if(color=='fire'){
color=[255, 146, 68];
}
else if(color=='thunder'){
color=[141, 216, 255];
}
else if(color=='green'){
color=[141, 255, 216];
}
var node=ui.create.div('.linexy.hidden');
node.style.transitionDuration=(total/3000)+'s';
node.style.left=from[0]+'px';
node.style.top=from[1]+'px';
node.style.backgroundColor='rgba('+color.toString()+','+opacity+')';
var dy=to[1]-from[1];
var dx=to[0]-from[0];
var deg=Math.atan(Math.abs(dy)/Math.abs(dx))/Math.PI*180;
if(dx>=0){
if(dy<=0){
deg+=90;
}
else{
deg=90-deg;
}
}
else{
if(dy<=0){
deg=270-deg;
}
else{
deg+=270;
}
}
node.style.transform='rotate('+(-deg)+'deg) scaleY(0)';
node.style.height=get.xyDistance(from,to)+'px';
if(lib.config.mode=='chess'){
ui.chess.appendChild(node);
}
else{
ui.arena.appendChild(node);
}
ui.refresh(node);
node.show();
node.style.transform='rotate('+(-deg)+'deg) scaleY(1)';
node.addEventListener('webkitTransitionEnd',function(){
setTimeout(function(){
node.delete();
},total/3);
});
},
_linexy:function(path){
var from=[path[0],path[1]];
var to=[path[2],path[3]];
var total=typeof arguments[1]==='number'?arguments[1]:lib.config.duration*2;
var opacity=1;
var color=[255,255,255];
var dashed=false;
if(typeof arguments[1]=='object'){
for(var i in arguments[1]){
switch(i){
case 'opacity':opacity=arguments[1][i];break;
case 'color':color=arguments[1][i];break;
case 'dashed':dashed=arguments[1][i];break;
case 'duration':total=arguments[1][i];break;
}
}
}
else if(arguments[1]=='fire'||arguments[1]=='thunder'||arguments[1]=='green'){
color=arguments[1];
}
if(color=='fire'){
color=[255, 146, 68];
}
else if(color=='thunder'){
color=[141, 216, 255];
}
else if(color=='green'){
color=[141, 255, 216];
}
var drawfunc=function(time,ctx){
var current;
if(timetotal/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);
}
},
createTrigger:function(name,skill,player,event){
if(player.isOut()||player.isDead()||player.removed) return;
var next=game.createEvent('trigger',false,event);
next.skill=skill;
next.player=player;
next.triggername=name;
next._trigger=event;
next.content=function(){
"step 0"
var info=get.info(event.skill);
if(info.filter&&!info.filter(trigger,player,event.triggername)){
event.finish();
}
else if(event._trigger.notrigger.contains(player)&&!lib.skill.global.contains(event.skill)){
event.finish();
}
else{
var hidden=player.hiddenSkills.slice(0);
game.expandSkills(hidden);
if(hidden.contains(event.skill)&&!get.info(event.skill).direct){
event.trigger('triggerHidden');
}
}
"step 1"
if(event.cancelled){
event.finish();
}
else{
event.trigger('triggerBefore');
}
"step 2"
if(event.cancelled){
event.finish();
return;
}
if(!event.revealed&&!get.info(event.skill).forced){
if(get.info(event.skill).direct&&player.isUnderControl()){
game.modeSwapPlayer(player);
event._result={bool:true};
}
else if(get.info(event.skill).frequent&&!lib.config.autoskilllist.contains(event.skill)){
event._result={bool:true};
}
else if(get.info(event.skill).direct&&player==game.me&&!_status.auto){
event._result={bool:true};
}
else{
var str;
var check=get.info(event.skill).check;
if(get.info(event.skill).prompt) str=get.info(event.skill).prompt;
else str='是否发动【'+get.translation(event.skill)+'】?';
if(typeof str=='function'){str=str(trigger,player)}
player.chooseBool(str).ai=function(){
return !check||check(trigger,player);
};
}
}
"step 3"
if(result&&result.bool==false) return;
var info=get.info(event.skill);
var next=game.createEvent(event.skill);
next.player=player;
next._trigger=trigger;
next.triggername=event.triggername;
next.content=info.content;
if(info.popup!=false&&!info.direct){
if(info.popup){
player.popup(info.popup);
game.log(player,'发动了','【'+get.translation(event.skill)+'】');
}
else{
player.logSkill(event.skill);
}
}
}
},
createEvent:function(name,trigger,triggerevent){
var next={
name:name,
step:0,
finished:false,
next:[],
aiexclude:[],
notrigger:[],
custom:{
add:{},
replace:{}
},
_result:{}
}
if(trigger!==false) next._triggered=0;
for(var i in lib.element.event){
next[i]=lib.element.event[i];
}
(triggerevent||_status.event).next.push(next);
return next;
},
addCharacter:function(name,info){
var extname=(_status.extension||info.extension);
var character=[info.sex,info.group,info.hp,info.skills||[],['db:extension-'+extname+':'+name+'.jpg']];
if(info.tags){
character[4]=character[4].concat(info.tags);
}
lib.character[name]=character;
var packname='mode_extension_'+extname;
if(!lib.characterPack[packname]){
lib.characterPack[packname]={};
}
lib.translate[name]=info.translate;
lib.characterPack[packname][name]=character;
lib.translate[packname+'_character_config']=extname;
},
addCard:function(name,info,info2){
var extname=(_status.extension||info2.extension);
if(info.fullskin){
info.image='db:extension-'+extname+':'+name+'.png';
}
else if(info.fullimage){
info.image='db:extension-'+extname+':'+name+'.jpg';
}
lib.card[name]=info;
lib.translate[name]=info2.translate;
lib.translate[name+'_info']=info2.description;
if(typeof info2.number=='number'){
var suits=['heart','spade','diamond','club'];
if(info2.color=='red'){
suits=['heart','diamond'];
}
else if(info2.color=='black'){
suits=['club','spade'];
}
for(var i=0;i=vinum){
var toremove=videos.pop();
lib.videos.remove(toremove);
store.delete(toremove.time);
}
else{
break;
}
}
var newvid={
name:game.getVideoName(),
mode:lib.config.mode,
video:lib.video,
win:result=='战斗胜利',
name1:game.me.name1||game.me.name,
name2:game.me.name2,
time:lib.getUTC(new Date())
};
lib.videos.unshift(newvid);
store.put(newvid);
lib.createVideoNode(newvid,true);
}
// _status.auto=false;
if(ui.auto){
// ui.auto.classList.remove('glow');
ui.auto.hide();
}
if(ui.wuxie) ui.wuxie.hide();
if(lib.storage.test){
if(lib.config.test_game){
switch(lib.config.mode){
case 'identity':game.saveConfig('mode','guozhan');break;
case 'guozhan':game.saveConfig('mode','versus');break;
case 'versus':game.saveConfig('mode','boss');break;
case 'boss':game.saveConfig('mode','chess');break;
case 'chess':game.saveConfig('mode','stone');break;
case 'stone':game.saveConfig('mode','identity');break;
}
}
setTimeout(game.reload,500);
}
if(game.controlOver){
game.controlOver();return;
}
if(lib.config.mode=='boss'){
ui.create.control('再战',function(){
var pointer=game.boss;
var map={boss:game.me==game.boss,links:[]};
for(var iwhile=0;iwhile<10;iwhile++){
pointer=pointer.nextSeat;
if(pointer==game.boss){
break;
}
map.links.push(pointer.name);
}
game.saveConfig('continue_name_boss',map);
game.saveConfig('mode',lib.config.mode);
localStorage.setItem(lib.configprefix+'directstart',true);
game.reload();
});
}
else if(lib.config.mode=='versus'){
if(_status.mode=='standard'){
ui.create.control('再战',function(){
game.saveConfig('continue_name_versus',{
friend:_status.friendBackup,
enemy:_status.enemyBackup,
color:_status.color
});
game.saveConfig('mode',lib.config.mode);
localStorage.setItem(lib.configprefix+'directstart',true);
game.reload();
});
}
}
else if(get.config('continue_game')){
ui.continue_game=ui.create.control('再战',game.reloadCurrent);
}
if(!ui.restart){
ui.restart=ui.create.control('restart',game.reload);
}
if(ui.tempnowuxie){
ui.tempnowuxie.close();
delete ui.tempnowuxie;
}
if(ui.revive){
ui.revive.close();
delete ui.revive;
}
if(ui.swap){
ui.swap.close();
delete ui.swap;
}
for(var 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.forceDie&&event.name!='phaseLoop'){
while(_status.dieClose.length){
_status.dieClose.shift().close();
}
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;
delete _status.waitingForTransition;
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;
if(lib.config.speed=='vvfast') time/=3;
_status.timeout=setTimeout(game.resume,time);
},
delayx:function(time,time2){
if(typeof time!='number') time=1;
switch(lib.config.game_speed){
case 'vslow':time*=2.5;break;
case 'slow':time*=1.5;break;
case 'fast':time*=0.7;break;
case 'vfast':time*=0.4;break;
case 'vvfast':time*=0.2;break;
}
return game.delay(time,time2);
},
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].forceout&&
(game.players[i].isOut()==false||event.includeOutTarget)&&nochess){
if(ui.selected.targets.length=info.usable) enable=false;
}
if(enable){
skills.add(skills2[i]);
}
}
var globalskills=[];
var globallist=lib.skill.global.slice(0);
game.expandSkills(globallist);
for(var i=0;i7){
game.players[i].node.action.classList.add('thunder');
}
else{
game.players[i].node.action.classList.remove('thunder');
}
}
}
}
if(ok&&auto&&lib.config.auto_confirm&&(!_status.mousedragging||!_status.mouseleft)&&
!_status.mousedown&&!_status.touchnocheck){
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&&!_status.event.noconfirm){
if(!_status.mousedown||_status.mouseleft){
var str='';
if(ok) str+='o';
if(!event.forced&&get.noSelected()) str+='c';
ui.create.confirm(str);
}
}
}
if(ui.confirm&&ui.confirm.lastChild.link=='cancel'){
if(_status.event.parent.name=='phaseUse'&&!_status.event.skill){
ui.confirm.lastChild.innerHTML='结束';
}
else{
ui.confirm.lastChild.innerHTML='取消';
}
}
}
return ok;
},
uncheck:function(){
var i,j;
if(true){
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];
},
loadMode:function(mode){
var next=game.createEvent('loadMode');
next.mode=mode;
next.content=function(){
'step 0'
window.mode={};
lib.init.js(lib.assetURL+'mode',event.mode,game.resume);
game.pause();
'step 1'
event.result=window.mode[event.mode];
delete window.mode;
}
},
loadPackage:function(){
var next=game.createEvent('loadPackage');
next.packages=[];
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(typeof lib.skill[i].viewAs=='string'){
lib.skill[i].viewAs={name:lib.skill[i].viewAs};
}
if(lib.skill[i].ai==undefined) lib.skill[i].ai={};
var skill=lib.skill[i].ai;
if(!lib.card[lib.skill[i].viewAs.name]){
lib.skill[i]={};
lib.translate[i+'_info']='技能不可用';
continue;
}
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(lib.skill[i].subSkill){
for(var j in lib.skill[i].subSkill){
lib.skill[i+'_'+j]=lib.skill[i].subSkill[j];
if(lib.skill[i].subSkill[j].name){
lib.translate[i+'_'+j]=lib.skill[i].subSkill[j].name;
}
else{
lib.translate[i+'_'+j]=lib.translate[i];
}
if(lib.skill[i].subSkill[j].description){
lib.translate[i+'_'+j+'_info']=lib.skill[i].subSkill[j].description;
}
if(lib.skill[i].subSkill[j].marktext){
lib.translate[i+'_'+j+'_bg']=lib.skill[i].subSkill[j].marktext;
}
}
}
if(lib.skill[i].marktext){
lib.translate[i+'_bg']=lib.skill[i].marktext;
}
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;i'+get.translation(arguments[i])+'';
}
else{
str+=get.translation(arguments[i]);
}
}
else if(itemtype=='cards'||itemtype=='card'||(typeof arguments[i]=='object'&&arguments[i].name)){
if(lib.config.log_highlight){
str+=''+get.translation(arguments[i])+'';
}
else{
str+=get.translation(arguments[i]);
}
}
else if(typeof arguments[i]=='object'){
str+=get.translation(arguments[i]);
}
else if(typeof arguments[i]=='string'&&arguments[i][0]=='【'&&arguments[i][arguments[i].length-1]=='】'){
if(lib.config.log_highlight){
str+=''+get.translation(arguments[i])+'';
}
else{
str+=get.translation(arguments[i]);
}
}
else{
str+=arguments[i];
}
}
var node=ui.create.div();
node.innerHTML=str;
ui.sidebar.insertBefore(node,ui.sidebar.firstChild);
game.addVideo('log',null,str);
if(lib.config.title) document.title=str;
if(lib.config.show_log!='off'&&lib.config.mode!='chess'){
ui.arenalog.insertBefore(node.cloneNode(true),ui.arenalog.firstChild);
while(ui.arenalog.childNodes.length&&ui.arenalog.scrollHeight>ui.arenalog.offsetHeight){
ui.arenalog.lastChild.remove();
}
}
},
putDB:function(type,id,item,callback){
if(!lib.db) return item;
var put=lib.db.transaction([type],'readwrite').objectStore(type).put(item,id);
if(callback){
put.onsuccess=callback;
}
},
getDB:function(type,id,callback){
if(!lib.db){
callback(null);
return;
}
if(!callback) return;
var store=lib.db.transaction([type],'readwrite').objectStore(type);
if(id){
store.get(id).onsuccess=function(e){
callback(e.target.result);
};
}
else{
var obj={};
store.openCursor().onsuccess=function(e){
var cursor=e.target.result;
if(cursor){
obj[cursor.key]=cursor.value;
cursor.continue();
}
else{
callback(obj);
}
}
}
},
deleteDB:function(type,id,callback){
if(!lib.db){
callback(false);
return;
}
var store=lib.db.transaction([type],'readwrite').objectStore(type);
store.delete(id).onsuccess=callback;
},
save:function(key,value){
if(_status.reloading) return;
var config={};
if(arguments.length>0){
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=lib.version;
localStorage.setItem(lib.configprefix+lib.config.mode,JSON.stringify(config));
},
showChangeLog:function(){
if(lib.version!=lib.config.version){
game.saveConfig('version',lib.version);
var ul=document.createElement('ul');
ul.style.textAlign='left';
for(var i=0;igame.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,animation){
game.addVideo('addFellow',null,[position,character]);
var player=ui.create.player(ui.arena).animate(animation||'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(){
if(lib.config.mode=='chess'&&game.me){
var friendCount=0;
var enemyCount=0;
var rand=Math.random()<0.5;
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);
if(innerHTML) node.innerHTML=innerHTML;
if(listen) node.listen(listen);
return node;
},
selectlist:function(list,init,position){
var select=document.createElement('select');
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){
if(seperate){
seperate=seperate(list);
dialog.seperate=[];
for(var i in seperate){
var link='';
var linkcontent=seperate[i];
if(i.indexOf('_link:')!=-1){
link=i.slice(i.indexOf('_link:')+6);
i=i.slice(0,i.indexOf('_link:'));
}
var nodesep=dialog.add(i);
nodesep.link=link;
dialog.seperate.push(nodesep);
dialog.add([linkcontent,'vcard'],noclick);
}
}
else{
dialog.add([list,'vcard'],noclick);
}
}
else{
dialog.add([list,'character'],noclick);
}
dialog.add(ui.create.div('.placeholder'));
for(i=0;i>',page,function(){
if(expanded){
this.classList.remove('on');
this.parentNode.classList.remove('expanded');
}
else{
this.classList.add('on');
this.parentNode.classList.add('expanded');
}
expanded=!expanded;
});
for(var k=0;k>',page,function(){
if(importextensionexpanded){
this.classList.remove('on');
importExtension.style.display='none';
}
else{
this.classList.add('on');
importExtension.style.display='';
}
importextensionexpanded=!importextensionexpanded;
});
importExtension=ui.create.div('.new_character.export.import',page);
importExtension.style.marginLeft='5px';
importExtension.style.marginTop='5px';
importExtension.style.display='none';
ui.create.div('','',importExtension);
importExtension.firstChild.lastChild.onclick=function(){
var fileToLoad=this.previousSibling.files[0];
if(fileToLoad){
var zipReady=function(){
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent)
{
var data = fileLoadedEvent.target.result;
var zip=new JSZip();
zip.load(data);
var str=zip.file('extension.js').asText();
try{
eval(str);
if(!game.importedPack) throw('err');
var extname=game.importedPack.name;
localStorage.setItem(lib.configprefix+'extension_'+extname,str);
lib.config.extensions.add(extname);
game.saveConfig('extensions',lib.config.extensions);
game.saveConfig('extension_'+extname,true);
for(var i in game.importedPack.config){
if(game.importedPack.config[i]&&game.importedPack.config[i].hasOwnProperty('init')){
game.saveConfig('extension_'+extname+'_'+i,game.importedPack.config[i].init);
}
}
if(game.importedPack.image&&lib.db){
for(var i=0;i>',page,function(){
if(autoskillexpanded){
this.classList.remove('on');
for(var k=0;k>',page,function(){
if(banskillexpanded){
this.classList.remove('on');
for(var k=0;kbb?1:-1;
}
return a>b?1:-1;
});
var list2=[];
var skills=lib.character[list[0][0]][3];
for(var i=0;i>',page,function(){
// if(expanded){
// this.classList.remove('on');
// this.parentNode.classList.remove('expanded');
// }
// else{
// this.classList.add('on');
// this.parentNode.classList.add('expanded');
// }
// expanded=!expanded;
// });
page.classList.add('morenodes');
for(var k=0;k>',page,function(){
this.classList.toggle('on');
if(this.classList.contains('on')){
importCharacter.style.display='';
resetEditor();
resetExport();
currentEditing=null;
}
else{
importCharacter.style.display='none';
}
});
var resetImport=function(){
importCharacter.style.display='none';
toggle3.classList.remove('on')
}
importCharacter=ui.create.div('.new_character.export.import',page);
importCharacter.style.display='none';
ui.create.div('','',importCharacter);
importCharacter.firstChild.lastChild.onclick=function(){
var fileToLoad=this.previousSibling.files[0];
if(fileToLoad){
var zipReady=function(){
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent)
{
var data = fileLoadedEvent.target.result;
var zip=new JSZip();
zip.load(data);
var str=zip.file('pack.js').asText();
try{
eval(str);
if(!game.importedPack) throw('err');
for(var i in game.importedPack.character){
var buttons=page.querySelectorAll('.button.character');
for(var j=0;j>',page,function(){
this.classList.toggle('on');
if(this.classList.contains('on')){
exportCharacter.style.display='';
resetEditor();
resetImport();
currentEditing=null;
packExporting=true;
}
else{
resetExport();
}
});
var resetExport=function(){
packExporting=false;
exportCharacter.style.display='none';
toggle2.classList.remove('on');
var selected=page.querySelectorAll('.button.character.selected');
var list=[];
for(var i=0;i',exportCharacter);
exportCharacter.firstChild.lastChild.onclick=function(){
var name=this.previousSibling.value;
var selected=page.querySelectorAll('.button.character.selected');
var list=[];
var list2=[];
for(var i=0;i>',page,function(){
this.classList.toggle('on');
if(this.classList.contains('on')){
newCharacter.style.display='';
resetExport();
resetImport();
}
else{
newCharacter.style.display='none';
}
});
var resetEditor=function(){
toggle.classList.remove('on');
newCharacter.style.display='none';
fakeme.classList.remove('inited');
delete fakeme.image;
fakeme.style.backgroundImage='';
var inputs=newCharacter.querySelectorAll('input');
for(var i=0;i',newCharacter).style.paddingTop='10px';
ui.create.div('.indent','体力:',newCharacter).style.paddingTop='10px';
var sexes=ui.create.selectlist([
['male','男'],
['female','女'],
['none','无'],
],null,ui.create.div('.indent','性别:',newCharacter));
var groups=ui.create.selectlist([
['wei','魏'],
['shu','蜀'],
['wu','吴'],
['qun','群'],
],null,ui.create.div('.indent','势力:',newCharacter));
var options=ui.create.div('.add_skill.options','主公BOSSAI禁选 ',newCharacter);
var addSkill=ui.create.div('.add_skill','添加技能 ',newCharacter);
var list=[];
for(var i in lib.character){
if(!lib.customCharacters.contains(i)&&lib.character[i][3].length)
list.push([i,lib.translate[i]]);
}
list.sort(function(a,b){
a=a[0];b=b[0];
var aa=a,bb=b;
if(aa.indexOf('_')!=-1){
aa=aa.slice(aa.indexOf('_')+1);
}
if(bb.indexOf('_')!=-1){
bb=bb.slice(bb.indexOf('_')+1);
}
if(aa!=bb){
return aa>bb?1:-1;
}
return a>b?1:-1;
});
var list2=[];
var skills=lib.character[list[0][0]][3];
for(var i=0;i创建技能... ',newCharacter);
createSkill.firstChild.listen(function(){
createSkill.lastChild.classList.toggle('hidden');
if(createSkill.lastChild.classList.contains('hidden')){
this.innerHTML='创建技能...';
skillList.style.top='';
}
else{
this.innerHTML='创建技能';
skillList.style.top='435px';
}
});
var newSkill=document.createElement('textarea');
createSkill.lastChild.appendChild(newSkill);
createSkill.lastChild.innerHTML+=' ';
ui.create.div('','技能名称:',createSkill.lastChild);
createSkill.lastChild.innerHTML+=' ';
ui.create.div('','技能描述: ',createSkill.lastChild);
createSkill.lastChild.lastChild.lastChild.previousSibling.style.marginTop='5px';
createSkill.lastChild.lastChild.lastChild.previousSibling.style.marginRight='3px';
createSkill.lastChild.lastChild.lastChild.previousSibling.onclick=function(){
var node;
var name=createSkill.lastChild.querySelector('.skillname').value;
var description=createSkill.lastChild.querySelector('.skilldescription').value;
var content=createSkill.lastChild.querySelector('textarea').value;
if(!name||!description) return;
if(lib.checkSkillName(name)){
alert('技能名重复');
return;
}
for(var i=0;iname2.indexOf('|')){
name2=name2.slice(name2.indexOf('|')+1,name2.lastIndexOf('|'));
}
else{
name2=name2.slice(name2.indexOf('|')+1);
}
}
ui.create.div('',name2,node,editnode);
ui.create.div('','×',node,deletenode);
}
node.createInfo={
name:name,
description:description,
content:content
}
createSkill.lastChild.querySelector('.skillname').value='';
createSkill.lastChild.querySelector('.skilldescription').value='';
createSkill.lastChild.querySelector('textarea').value='';
createSkill.lastChild.classList.add('hidden');
createSkill.firstChild.innerHTML='创建技能...';
skillList.style.top='';
}
createSkill.lastChild.lastChild.lastChild.onclick=function(){
createSkill.lastChild.querySelector('.skillname').value='';
createSkill.lastChild.querySelector('.skilldescription').value='';
createSkill.lastChild.querySelector('textarea').value='';
createSkill.lastChild.classList.add('hidden');
createSkill.firstChild.innerHTML='创建技能...';
skillList.style.top='';
};
var skillList=ui.create.div('.skill_list',newCharacter);
ui.create.div(skillList);
ui.create.div('.menubutton.large','创建武将',ui.create.div(skillList),function(){
var image=fakeme.image;if(!image&&this.innerHTML!='编辑武将') return;
var name=newCharacter.querySelector('.new_name').value;if(!name) return;
if(lib.checkCharacterName(name)){
alert('武将名重复');return;
}
var hp=newCharacter.querySelector('.new_hp').value;
hp=parseInt(hp);
if(!hp) hp=1;
var skills=[];
var dontcreate=false;
if(this.innerHTML=='编辑武将'&&this._origin&&this._origin.link!=name){
dontcreate=true;
var origin=this._origin;
game.getDB('image','character:'+this._origin.link,function(data){
if(data){
game.putDB('image','character:'+name,data);
origin.remove();
lib.customCharacters.remove(origin.link);
game.deleteDB('character',origin.link);
game.deleteDB('image','character:'+origin.link);
if(lib.character[origin.link]){
var skills=lib.character[origin.link][3];
delete lib.character[origin.link];
for(var i=0;i>',page,function(){
if(cardpileexpanded){
this.classList.remove('on');
for(var k=0;k>',page,function(){
this.classList.toggle('on');
if(this.classList.contains('on')){
exportCardPile.classList.remove('hidden');
}
else{
exportCardPile.classList.add('hidden');
}
});
exportCardPile=ui.create.div('.config.cardpileadd.indent',page);
exportCardPile.classList.add('hidden');
ui.create.div('','名称:',exportCardPile);
var input=exportCardPile.firstChild.lastChild.previousSibling;
input.value='自定义牌堆';
input.style.marginRight='3px';
input.style.width='120px';
exportCardPile.firstChild.lastChild.onclick=function(){
var name=input.value;
var ok=true;
if(lib.config.customcardpile[name]){
for(var i=1;i<=1000;i++){
if(!lib.config.customcardpile[name+'('+i+')']){
name=name+'('+i+')';
break;
}
}
}
lib.config.customcardpile[name]=[lib.config.bannedpile,lib.config.addedpile];
game.saveConfig('cardpilename',name,true);
game.saveConfig('customcardpile',lib.config.customcardpile);
game.saveConfig('bannedpile');
game.saveConfig('addedpile');
createPileNode(name);
updatePileConfig();
};
}());
var node1=ui.create.div('.lefttext','全部开启',start.firstChild,function(){
game.saveConfig('cards',lib.config.all.cards);
updateNodes();
});
var node2=ui.create.div('.lefttext','恢复默认',start.firstChild,function(){
game.saveConfig('cards',lib.config.defaultcards);
updateNodes();
});
node1.style.marginTop='12px';
node2.style.marginTop='7px';
updateNodes();
}());
(function(){
var start=menux.pages[4];
var rightPane=start.lastChild;
var cheatButton=ui.create.div('.menubutton.round.highlight','作',start);
var runButton=ui.create.div('.menubutton.round.highlight','执',start);
runButton.style.display='none';
var playButton=ui.create.div('.menubutton.round.highlight','播',start);
playButton.style.display='none';
playButton.style.left='215px';
var deleteButton=ui.create.div('.menubutton.round.highlight','删',start);
deleteButton.style.display='none';
deleteButton.style.left='275px';
var saveButton=ui.create.div('.menubutton.round.highlight','存',start);
saveButton.style.display='none';
var clickMode=function(){
if(this.classList.contains('off')) return;
var active=this.parentNode.querySelector('.active');
if(active===this){
return;
}
active.classList.remove('active');
active.link.remove();
active=this;
this.classList.add('active');
rightPane.appendChild(this.link);
if(this.type=='cheat'){
cheatButton.style.display='';
}
else{
cheatButton.style.display='none';
}
if(this.type=='cmd'){
runButton.style.display='';
}
else{
runButton.style.display='none';
}
if(this.type=='video'){
playButton.style.display='';
saveButton.style.display='';
deleteButton.style.display='';
}
else{
playButton.style.display='none';
saveButton.style.display='none';
deleteButton.style.display='none';
}
};
(function(){
var checkCheat=function(){
if(currentrow1&¤trow2&&row3.querySelector('.glow')){
cheatButton.classList.add('glowing');
return true;
}
else{
cheatButton.classList.remove('glowing');
return false;
}
}
cheatButton.listen(function(){
if(checkCheat()){
var num;
switch(currentrow2.innerHTML){
case '一':num=1;break;
case '二':num=2;break;
case '三':num=3;break;
case '四':num=4;break;
case '五':num=5;break;
}
var targets=[];
var buttons=row3.querySelectorAll('.glow');
for(var i=0;i重置',page);
item.style.height='auto';
item.lastChild.addEventListener('click',reset);
item.link=lib.config.all.mode[i];
}
}
}());
(function(){
if(!window.indexedDB) return;
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','录像',start.firstChild,clickMode);
node.type='video';
node.link=page;
lib.onDB(function(){
var store=lib.db.transaction(['video'],'readwrite').objectStore('video');
lib.videos=[];
store.openCursor().onsuccess=function(e){
var cursor=e.target.result;
if(cursor){
lib.videos.push(cursor.value);
cursor.continue();
}
else{
lib.videos.sort(function(a,b){
return parseInt(b.time)-parseInt(a.time);
});
var clickcapt=function(){
var current=this.parentNode.querySelector('.videonode.active');
if(current&¤t!=this){
current.classList.remove('active');
}
this.classList.toggle('active');
};
var staritem=function(){
this.parentNode.classList.toggle('starred');
var store=lib.db.transaction(['video'],'readwrite').objectStore('video');
if(this.parentNode.classList.contains('starred')){
this.parentNode.link.starred=true;
}
else{
this.parentNode.link.starred=false;
}
store.put(this.parentNode.link);
}
var createNode=function(video,before){
var node=ui.create.div('.videonode.menubutton.large',clickcapt);
node.link=video;
ui.create.div('.menubutton.videoavatar',node).setBackground(video.name1,'character');
if(video.name2){
ui.create.div('.menubutton.videoavatar2',node).setBackground(video.name2,'character');
}
var date=new Date(video.time);
var str=date.getFullYear()+'.'+(date.getMonth()+2)+'.'+(date.getDay()+1)+' '+
date.getHours()+':';
var minutes=date.getMinutes();
if(minutes<10){
str+='0';
}
str+=minutes;
ui.create.div('.caption',video.name[0],node);
ui.create.div('.text',str+' '+video.name[1],node);
if(video.win){
ui.create.div('.victory','胜',node);
}
if(before){
page.insertBefore(node,page.firstChild);
}
else{
page.appendChild(node);
}
ui.create.div('.video_star','★',node,staritem);
if(video.starred){
node.classList.add('starred');
}
}
for(var i=0;i导入录像...',function(){
this.nextSibling.classList.toggle('hidden');
},page);
importVideoNode.style.marginLeft='12px';
importVideoNode.style.marginTop='3px';
var importVideo=ui.create.div('.config.hidden',page);
importVideo.style.whiteSpace='nowrap';
importVideo.style.marginBottom='80px';
importVideo.style.marginLeft='13px';
importVideo.style.width='calc(100% - 30px)';
importVideo.innerHTML=''+
'';
importVideo.lastChild.onclick=function(){
var fileToLoad = importVideo.firstChild.files[0];
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent)
{
var data = fileLoadedEvent.target.result;
if(!data) return;
try{
data=JSON.parse(lib.init.decode(data));
}
catch(e){
console.log(e);
alert('导入失败');
return;
}
var store=lib.db.transaction(['video'],'readwrite').objectStore('video');
var videos=lib.videos.slice(0);
for(var i=0;i=parseInt(lib.config.video)&&videos.length){
var toremove=videos.pop();
lib.videos.remove(toremove);
store.delete(toremove.time);
for(var i=0;i';
li2.innerHTML='素材版本:'+(lib.config.asset_version||'无')+'';
var button1,button2;
game.checkForUpdate=function(forcecheck){
if(button1.disabled){
return;
}
else{
button1.innerHTML='正在检查更新';
button1.disabled=true;
var goupdate=function(){
if(game.download){
var script=lib.init.js(lib.updateURL,'game/source',function(){
script.remove();
var updates=window.noname_source_list;
delete window.noname_source_list;
if(!ui.arena.classList.contains('menupaused')){
ui.click.configMenu();
ui.click.menuTab('帮助');
}
var p=button1.parentNode;
button1.remove();
var span=document.createElement('span');
var n1=0;
var n2=updates.length;
var n=n2;
span.innerHTML='正在下载文件('+n1+'/'+n2+')';
p.appendChild(span);
var finish=function(){
span.innerHTML='游戏更新完毕('+n1+'/'+n2+')';
p.appendChild(document.createElement('br'));
var button=document.createElement('button');
button.innerHTML='重新启动';
button.onclick=game.reload;
p.appendChild(button);
}
for(var i=0;i14){
node.node.hp.innerHTML=infoitem[2];
if(infoitem[2]==Infinity){
node.node.hp.innerHTML='∞';
}
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);
}
else{
if(lib.config.hover_all){
lib.setHover(node,ui.click.hoverplayer);
}
if(lib.config.right_info){
node.oncontextmenu=ui.click.rightplayer;
}
}
}
if(infoitem[1]){
node.node.group.innerHTML=''+get.translation(infoitem[1])+' ';
node.node.group.style.backgroundColor=get.translation(infoitem[1]+'Color');
}
else{
node.node.group.style.display='none';
}
}
else{
node.node={
name:ui.create.div('.name',node),
intro:ui.create.div('.intro',node)
}
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(i1&&
!this.classList.contains('popped')&&
!this.classList.contains('fixed')){
_status.draggingtouchdialog=this;
this._dragorigin={
clientX:e.touches[0].clientX,
clientY:e.touches[0].clientY,
};
if(!this._dragtransform){
this._dragtransform=[0,0];
}
this._dragorigintransform=this._dragtransform.slice(0);
e.preventDefault();
e.stopPropagation();
}
},
identity:function(){
if(_status.dragged) return;
_status.clicked=true;
if(!game.getIdentityList) return;
if(_status.video) return;
if(_status.clickingidentity){
for(var i=0;i<_status.clickingidentity[1].length;i++){
_status.clickingidentity[1][i].delete();
_status.clickingidentity[1][i].style.transform='';
}
if(_status.clickingidentity[0]==this.parentNode){
delete _status.clickingidentity;
return;
}
}
var list=game.getIdentityList(this.parentNode);
if(!list) return;
var nodes=[];
_status.clickingidentity=[this.parentNode,nodes];
var num=1;
for(var i in list){
if(this.firstChild.innerHTML!=list[i]){
var node=ui.create.div('.identity.hidden',this.parentNode,ui.click.identity2);
ui.create.div(node).innerHTML=list[i];
node.dataset.color=i;
ui.refresh(node);
node.show();
var transstr='translateY('+((num++)*30)+'px)';
if(lib.config.layout=='phone'){
transstr+=' scale(1.3)';
}
if(lib.isNewLayout()&&this.parentNode.isLinked()){
transstr+=' rotate(90deg)';
}
node.style.transform=transstr;
nodes.push(node);
}
}
},
identity2:function(){
if(_status.clickingidentity){
_status.clicked=true;
var player=_status.clickingidentity[0];
var nodes=_status.clickingidentity[1];
player.node.identity.dataset.color=this.dataset.color;
player.node.identity.firstChild.innerHTML=this.firstChild.innerHTML;
for(var i=0;i'+ui.cardPile.childNodes.length);
uiintro.add('弃牌堆 ');
if(ui.discardPile.childNodes.length){
var list=[];
for(var i=0;i无');
}
return uiintro;
},
volumn:function(){
var uiintro=ui.create.dialog('hidden');
uiintro.listen(function(e){
e.stopPropagation();
});
uiintro.add('背景音乐');
var vol1=ui.create.div('.volumn');
uiintro.add(vol1);
for(var i=0;i<8;i++){
var span=document.createElement('span');
span.link=i+1;
span.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.volumn_background);
if(iui.window.offsetWidth-10){
left=ui.window.offsetWidth-width-10;
}
uiintro.style.left=left+'px';
uiintro._poppedorigin=this;
if(!lib.config.touchscreen){
uiintro.addEventListener('mouseleave',ui.click.leavehoverpopped);
}
},
hoverpopped_leave:function(){
this._poppedalready=false;
},
leavehoverpopped:function(){
if(_status.dragged) return;
if(this.classList.contains('noleave')) return;
this.delete();
var button=this._poppedorigin;
var uiintro=this;
setTimeout(function(){
if(button._uiintro==uiintro){
delete button._uiintro;
}
},500);
},
dierevive:function(){
if(game.me.isDead()){
game.me.revive(Math.max(1,game.me.maxHp));
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;i100){
if(ui.roundmenu._resetTimeout){
clearTimeout(ui.roundmenu._resetTimeout);
delete ui.roundmenu._resetTimeout;
}
}
ui.roundmenu._dragtouches=e.touches[0];
ui.click.checkroundtranslate(translate);
}
_status.clicked=true;
}
else if(_status.draggingtouchdialog){
delete _status._swipeorigin;
if(_status.draggingtouchdialog._dragorigin&&_status.draggingtouchdialog._dragtransform&&e.touches.length){
var translate=_status.draggingtouchdialog._dragtransform.slice(0);
var dx=e.touches[0].clientX-_status.draggingtouchdialog._dragorigin.clientX;
var dy=e.touches[0].clientY-_status.draggingtouchdialog._dragorigin.clientY;
translate[0]+=dx;
translate[1]+=dy;
_status.draggingtouchdialog._dragtouches=e.touches[0];
ui.click.checkdialogtranslate(translate,_status.draggingtouchdialog);
}
_status.clicked=true;
}
else if(_status._swipeorigin&&e.touches[0]){
_status._swipeorigin.touches=e.touches[0];
}
if(_status.mousedragging&&e.touches.length){
e.preventDefault();
var item=document.elementFromPoint(e.touches[0].clientX,e.touches[0].clientY);
while(item){
if(lib.config.enable_touchdragline&&_status.mouseleft&&lib.config.mode!='chess'){
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.lineWidth=3;
ctx.setLineDash([8,2]);
ctx.beginPath();
ctx.moveTo(_status.mousedragging.clientX-ui.arena.offsetLeft,_status.mousedragging.clientY-ui.arena.offsetTop);
if(_status.multitarget){
for(var i=0;i<_status.lastdragchange.length;i++){
var exy=_status.lastdragchange[i]._lastdragchange;
ctx.lineTo(exy[0],exy[1]);
}
}
if(!_status.selectionfull){
ctx.lineTo(e.touches[0].clientX-ui.arena.offsetLeft,e.touches[0].clientY-ui.arena.offsetTop);
}
ctx.stroke();
if(!_status.multitarget){
for(var i=0;i<_status.lastdragchange.length;i++){
ctx.moveTo(_status.mousedragging.clientX-ui.arena.offsetLeft,_status.mousedragging.clientY-ui.arena.offsetTop);
var exy=_status.lastdragchange[i]._lastdragchange;
ctx.lineTo(exy[0],exy[1]);
ctx.stroke();
}
}
}
if(item==_status.mousedragorigin){
if(_status.mouseleft){
_status.mousedragging=null;
_status.mousedragorigin=null;
_status.clicked=false;
game.uncheck();
game.check();
ui.canvas.width=ui.arena.offsetWidth;
ui.canvas.height=ui.arena.offsetHeight;
_status.clicked=true;
}
return;
}
var itemtype=get.itemtype(item);
if(itemtype=='card'||itemtype=='button'||itemtype=='player'){
_status.mouseleft=true;
var ex=e.touches[0].clientX-ui.arena.offsetLeft;
var ey=e.touches[0].clientY-ui.arena.offsetTop;
var exx=ex,eyy=ey;
if(lib.config.mode=='chess'){
ex-=-ui.chessContainer.scrollLeft+ui.chess.offsetLeft;
ey-=-ui.chessContainer.scrollTop+ui.chess.offsetTop;
}
if(itemtype!='player'||(ex>item.offsetLeft&&exitem.offsetTop&&ey=0){
if(dy<=0){
deg+=90;
}
else{
deg=90-deg;
}
}
else{
if(dy<=0){
deg=270-deg;
}
else{
deg+=270;
}
}
node.style.transform='rotate('+(-deg)+'deg) scaleY(0)';
node.style.height=get.xyDistance(from,to)+'px';
if(lib.config.mode=='chess'){
ui.chess.appendChild(node);
}
else{
ui.arena.appendChild(node);
}
ui.refresh(node);
node.show();
node.style.transform='rotate('+(-deg)+'deg) scaleY(1)';
ui.touchlines.push(node);
node._origin=item;
}
}
}
else{
_status.lastdragchange.remove(item);
for(var i=0;i200){
goswipe(lib.config.swipe_down);
}
}
else if(Math.abs(dy)<100){
if(dx<-200){
goswipe(lib.config.swipe_left);
}
else if(dx>200){
goswipe(lib.config.swipe_right);
}
}
}
}
var tmpflag=false;
_status.mousedown=false;
_status.clicked=false;
if(_status.mousedragging&&_status.mouseleft){
if(game.check()){
if(ui.confirm){
ui.confirm.close();
}
ui.click.ok();
}
else{
game.uncheck();
game.check();
}
}
else if(_status.mousedragging&&_status.mousedragorigin){
tmpflag=_status.mousedragorigin;
}
_status.lastdragchange.length=0;
_status.mousedragging=null;
_status.mouseleft=false;
_status.mousedragorigin=null;
_status.dragstatuschanged=false;
while(ui.touchlines.length){
ui.touchlines.shift().delete();
}
ui.canvas.width=ui.arena.offsetWidth;
ui.canvas.height=ui.arena.offsetHeight;
if(tmpflag){
game.check();
}
_status.dragged=false;
_status.clicked=false;
},
checkroundtranslate:function(translate){
var translate=translate||ui.roundmenu._dragtransform;
if(translate[1]+ui.roundmenu._position[1]+50+ui.arena.offsetTop>ui.window.offsetHeight){
translate[1]=ui.window.offsetHeight-(ui.roundmenu._position[1]+50)-ui.arena.offsetTop;
}
else if(translate[1]+ui.roundmenu._position[1]+ui.arena.offsetTop<0){
translate[1]=-ui.roundmenu._position[1]-ui.arena.offsetTop;
}
if(translate[0]+ui.roundmenu._position[0]+50+ui.arena.offsetLeft>ui.window.offsetWidth){
translate[0]=ui.window.offsetWidth-(ui.roundmenu._position[0]+50)-ui.arena.offsetLeft;
}
else if(translate[0]+ui.roundmenu._position[0]+ui.arena.offsetLeft<0){
translate[0]=-ui.roundmenu._position[0]-ui.arena.offsetLeft;
}
ui.roundmenu.style.transform='translate('+translate[0]+'px,'+translate[1]+'px)';
},
checkdialogtranslate:function(translate,dialog){
var translate=translate||dialog._dragtransform;
dialog.style.transform='translate('+translate[0]+'px,'+translate[1]+'px)';
},
windowmousewheel:function(e){
_status.tempunpopup=e;
},
windowmousemove:function(e){
if(window.inSplash) return;
if(_status.tempunpopup){
if(get.evtDistance(_status.tempunpopup,e)>5){
delete _status.tempunpopup;
}
}
if(e.button==2) return;
if(!Array.isArray(e.path)) return;
var dialogs=document.querySelectorAll('#window>.dialog.popped:not(.static)');
for(var i=0;iitem.offsetLeft&&exitem.offsetTop&&ey.dialog.popped:not(.static)');
for(var i=0;i'+info.promptfunc(event,event.player)+' ');
}
else if(lib.translate[skill+'_info']){
event.skillDialog=ui.create.dialog(str,''+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();
if(ui.skills2) ui.skills2.close();
if(ui.skills3) ui.skills3.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&&!event.norestore){
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();
if(ui.skills2) ui.skills2.close();
if(ui.skills3) ui.skills3.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.window);
var clicklayer=function(e){
uiintro.delete();
this.remove();
if(!ui.arena.classList.contains('menupaused')) game.resume2();
e.stopPropagation();
return false;
}
layer.addEventListener(lib.config.touchscreen?'touchend':'click',clicklayer);
if(!lib.config.touchscreen) layer.oncontextmenu=clicklayer;
lib.placePoppedDialog(uiintro,e);
uiintro.style.zIndex=21;
var clickintro=function(){
layer.remove();
this.delete();
if(!ui.arena.classList.contains('menupaused')) 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.paused2) 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);
}
},
tempnowuxie: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;
if(_status.nopause) return;
if(ui.pause.classList.contains('hidden')) 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;
},
dialogtouchStart:function(e){
this.startX=e.touches[0].clientX;
this.startY=e.touches[0].clientY;
_status.dragged=false;
_status.dialogtouched=true;
},
touchScroll:function(e) {
if(_status.mousedragging) return;
if(_status.draggingtouchdialog) return;
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+5&&
this.scrollHeight<=this.offsetHeight+5){
e.preventDefault();
}
else{
delete _status._swipeorigin;
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');
},
wuxie_self:function(item){
ui.wuxie_self.lastChild.click();
},
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(item){
game.saveConfig('auto_identity',item,true);
var num;
switch(item){
case 'one':num=1;break;
case 'two':num=2;break;
case 'three':num=3;break;
case 'always':num=-1;break;
default:num=0;break;
}
if(num&!_status.identityShown&&game.phaseNumber>game.players.length*num&&game.showIdentity){
_status.identityShown=true;
game.showIdentity(false);
}
},
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(lib.assetURL+'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(lib.assetURL+'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.filter='blur(8px)';
ui.background.style.webkitFilter='blur(8px)';
ui.background.style.transform='scale(1.05)';break;
case 'gray':
ui.background.style.filter='grayscale(1)';
ui.background.style.webkitFilter='grayscale(1)';
break;
case 'sepia':
ui.background.style.filter='sepia(0.5)';
ui.background.style.webkitFilter='sepia(0.5)';
break;
case 'invert':
ui.background.style.filter='invert(1)';
ui.background.style.webkitFilter='invert(1)';
break;
case 'saturate':
ui.background.style.filter='saturate(5)';
ui.background.style.webkitFilter='saturate(5)';
break;
case 'contrast':
ui.background.style.filter='contrast(1.4)';
ui.background.style.webkitFilter='contrast(1.4)';
break;
case 'hue':
ui.background.style.filter='hue-rotate(180deg)';
ui.background.style.webkitFilter='hue-rotate(180deg)';
break;
case 'brightness':
ui.background.style.filter='brightness(5)';
ui.background.style.webkitFilter='brightness(5)';
break;
default:
ui.background.style.filter='';
ui.background.style.webkitFilter='';
ui.background.style.transform='';
}
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 if(lib.config.image_background=='custom'){
ui.background.style.backgroundImage="none";
game.getDB('image','background',function(fileToLoad){
if(!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent)
{
var data = fileLoadedEvent.target.result;
ui.background.style.backgroundImage='url('+data+')';
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
else{
ui.background.setBackgroundImage("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;i0){
if(lib.config.layout=='phone'){
width+=12;
}
else{
width+=6;
}
}
}
if(!controls.length) return;
var offset=-length/2;
var control=controls.shift();
control.style.transform='translateX('+offset+'px)';
while(controls.length){
var control=controls.shift();
var width=widths.shift();
offset+=width+6;
if(lib.config.layout=='phone'){
offset+=6;
}
control.style.transform='translateX('+offset+'px)';
}
},
updatex:function(){
ui.update.apply(this,arguments);
ui.updatehl();
for(var i=0;i40){
offset12=90-hs1[i].node.info.offsetWidth;
hs1[i].node.info.querySelector('span').style.display='none';
hs1[i].node.name.style.transform='translateY(16px)';
hs1[i].node.info.style.transform='translateX(-'+offset12+'px) translateY(-3px)';
}
else{
hs1[i].node.info.querySelector('span').style.display='';
hs1[i].node.name.style.transform='';
hs1[i].node.info.style.transform='translateX(-'+offset12+'px)';
}
}
ui.handcards1Container.firstChild.style.width=(offset1*(hs1.length-1)+118)+'px';
var offset2,offset22=0;
if(!lib.config.fold_card){
offset2=112;
ui.handcards2Container.classList.add('scrollh');
}
else{
offset2=Math.min(112,(ui.handcards2Container.offsetWidth-128)/(hs2.length-1));
if(offset2<32){
offset2=32;
ui.handcards2Container.classList.add('scrollh');
}
else{
ui.handcards2Container.classList.remove('scrollh');
}
}
if(offset2<100){
offset22=100-offset2;
}
for(var i=0;i40){
offset22=90-hs2[i].node.info.offsetWidth;
hs2[i].node.info.querySelector('span').style.display='none';
hs2[i].node.name.style.transform='translateY(16px)';
hs2[i].node.info.style.transform='translateX(-'+offset22+'px) translateY(-3px)';
}
else{
hs2[i].node.info.querySelector('span').style.display='';
hs2[i].node.name.style.transform='';
hs2[i].node.info.style.transform='translateX(-'+offset22+'px)';
}
}
ui.handcards2Container.firstChild.style.width=(offset2*(hs2.length-1)+118)+'px';
},
updateh:function(compute){
if(!game.me) return;
if(!ui.handcards1Container) return;
if(lib.config.low_performance){
if(compute){
ui.updatehl();
setTimeout(ui.updatehl,1000);
}
return;
}
if(compute){
ui.handcards1Container._handcardsWidth=ui.handcards1Container.offsetWidth;
ui.handcards2Container._handcardsWidth=ui.handcards2Container.offsetWidth;
}
ui.updatehx(game.me.node.handcards1);
ui.updatehx(game.me.node.handcards2);
},
updatehx:function(node){
var width=node.parentNode._handcardsWidth;
var num=node.childElementCount-node.getElementsByClassName('removing').length;
node.classList.remove('fold0');
node.classList.remove('fold1');
node.classList.remove('fold2');
node.classList.remove('fold3');
if(num*78+40>=width){
// node.dataset.fold=3;
node.classList.add('fold3');
}
else if(num*93+25>=width){
// node.dataset.fold=2;
node.classList.add('fold2');
}
else if(num*112+6>=width){
// node.dataset.fold=1;
node.classList.add('fold1');
}
else{
// node.dataset.fold=0;
node.classList.add('fold0');
}
},
update:function(){
for(var i=0;i=ui.dialog.content.offsetHeight){
ui.dialog.style.height=ui.dialog.content.offsetHeight+'px';
}
else{
ui.dialog.style.height='';
}
if(ui.dialog.content.offsetHeight<240){
ui.dialog.classList.add('slim');
ui.dialog.classList.remove('scroll1');
ui.dialog.classList.remove('scroll2');
}
else{
ui.dialog.classList.remove('slim');
ui.dialog.classList.add('scroll1');
ui.dialog.classList.add('scroll2');
}
}
else{
if(ui.dialog.content.offsetHeight<=240||
ui.dialog.contentContainer.offsetHeight>=ui.dialog.content.offsetHeight){
ui.dialog.classList.remove('scroll1');
ui.dialog.classList.remove('scroll2');
}
else{
ui.dialog.classList.add('scroll1');
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={
zhu:function(player,skill){
if(typeof player=='string'){
skill=player;
player=null;
}
if(lib.config.mode=='identity'){
if(skill&&!game.zhu.get('s').contains(skill)) return null;
if(game.zhu.isZhu) return game.zhu;
}
else if(lib.config.mode=='versus'&&_status.mode=='four'){
for(var i=0;i';
}
}
return str2;
},
slimName:function(str){
var str2=lib.translate[str];
if(!str2) return '';
if(str2.indexOf('sp')==0){
str2=str2.slice(2);
}
else if(str2.indexOf('界sp')==0){
str2=str2.slice(3);
}
return get.verticalStr(str2,true);
},
time:function(){
if(lib.status.dateDelaying){
return lib.getUTC(lib.status.dateDelaying)-lib.getUTC(lib.status.date)-lib.status.dateDelayed;
}
else{
return lib.getUTC(new Date())-lib.getUTC(lib.status.date)-lib.status.dateDelayed;
}
},
currentTime:function(){
return lib.getUTC(new Date());
},
evtDistance:function(e1,e2){
return Math.sqrt((e1.x-e2.x)*(e1.x-e2.x)+(e1.y-e2.y)*(e1.y-e2.y));
},
xyDistance:function(from,to){
return Math.sqrt((from[0]-to[0])*(from[0]-to[0])+(from[1]-to[1])*(from[1]-to[1]));
},
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【'+skilltrans+'】'+
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(typeof node._customintro=='function'){
node._customintro(uiintro);
}
else if(Array.isArray(node._customintro)){
var caption=node._customintro[0];
var content=node._customintro[1];
if(typeof caption=='function'){
caption=caption(node);
}
if(typeof content=='function'){
content=content(node);
}
uiintro.add(caption);
uiintro.add(''+content+' ');
}
else if(node.classList.contains('player')){
var capt=get.translation(node.name);
if(lib.character[node.name]&&lib.character[node.name][1]){
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||lib.config.touchscreen){
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);
}
}
}
var js=node.get('j');
for(var i=0;i'+
lib.translate[(js[i].viewAs||js[i].name)+'_info']+' ';
uiintro.add(translation);
}
if(lib.falseitem){
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);
}
if(lib.config.change_skin&&(
!node.classList.contains('unseen')||!node.classList.contains('unseen2')
)){
var num=1;
var introadded=false;
var loadImage=function(avatar2){
var img=new Image();
img.onload=function(){
num++;
loadImage(avatar2);
}
img.onerror=function(){
num--;
if(num){
if(!introadded){
introadded=true;
uiintro.add('更改皮肤 ');
}
var buttons=ui.create.div('.buttons.smallzoom');
for(var i=0;i<=num;i++){
var button=ui.create.div('.button.character',buttons,function(){
if(this._link){
if(avatar2){
lib.config.skin[node.name2]=this._link;
node.node.avatar2.style.backgroundImage=this.style.backgroundImage;
}
else{
lib.config.skin[node.name]=this._link;
node.node.avatar.style.backgroundImage=this.style.backgroundImage;
}
game.saveConfig('skin',lib.config.skin);
}
else{
if(avatar2){
delete lib.config.skin[node.name2];
node.node.avatar2.setBackground(node.name2,'character');
}
else{
delete lib.config.skin[node.name];
node.node.avatar.setBackground(node.name,'character');
}
game.saveConfig('skin',lib.config.skin);
}
});
button._link=i;
if(i){
button.setBackgroundImage('image/skin/'+(avatar2?node.name2:node.name)+'/'+i+'.jpg');
}
else{
button.setBackgroundImage('image/character/'+(avatar2?node.name2:node.name)+'.jpg');
}
}
uiintro.add(buttons);
}
if(!avatar2){
if(!node.classList.contains('unseen2')&&node.name2){
num=1;
loadImage(true);
}
}
}
img.src=lib.assetURL+'image/skin/'+(avatar2?node.name2:node.name)+'/'+num+'.jpg';
}
if(!node.classList.contains('unseen')){
loadImage();
}
}
}
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<=100){
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<=100){
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']){
if(get.subtype(node)=='equip1'){
var added=false;
if(lib.card[node.name]&&lib.card[node.name].distance){
var dist=lib.card[node.name].distance;
if(dist.attackFrom){
added=true;
uiintro.add('攻击范围:'+(-dist.attackFrom+1)+' ');
}
}
if(!added){
uiintro.add('攻击范围:1 ');
}
}
else if(lib.card[name]&&lib.card[name].addinfomenu){
uiintro.add(''+lib.card[name].addinfomenu+' ');
}
if(lib.translate[name+'_info'].length<=100){
uiintro.add(''+lib.translate[name+'_info']+' ');
}
else{
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 infoitem=lib.character[character];
if(!infoitem){
for(var itemx in lib.characterPack){
if(lib.characterPack[itemx][character]){
infoitem=lib.characterPack[itemx][character];break;
}
}
}
var skills=infoitem[3];
for(i=0;i【'+translation+'】 '+lib.translate[skills[i]+'_info']+' ');
}
}
uiintro.add(ui.create.div('.placeholder.slim'));
}
else if(node.classList.contains('identity')&&node.dataset.career){
var career=node.dataset.career;
uiintro.add(get.translation(career));
uiintro.add(''+lib.translate['_'+career+'_skill_info']+' ');
}
else if(node.classList.contains('skillbar')){
if(node==ui.friendBar){
uiintro.add('友方怒气值');
uiintro.add(''+_status.friendRage+'/100 ');
}
else if(node==ui.enemyBar){
uiintro.add('敌方怒气值');
uiintro.add(''+_status.enemyRage+'/100 ');
}
}
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();
if(buttons.length==0){
return ok;
}
buttons2=buttons.slice(0);
var ix=0;
var checkix=check(buttons[0],buttons2);
for(i=1;icheckix){
ix=i;
checkix=checkixtmp;
}
}
// buttons.sort(function(a,b){
// return check(b,buttons2)-check(a,buttons2);
// });
if(check(buttons[ix])<=0){
if(!forced||ok){
return ok;
}
}
buttons[ix].classList.add('selected');
ui.selected.buttons.add(buttons[ix]);
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();
if(!_status.event.player._noSkill){
cards=cards.concat(get.skills());
}
if(cards.length==0){
return ok;
}
cards2=cards.slice(0);
// cards.sort(function(a,b){
// return (check(b,cards2)-check(a,cards2));
// });
var ix=0;
var checkix=check(cards[0],cards2);
for(i=1;icheckix){
ix=i;
checkix=checkixtmp;
}
}
if(check(cards[ix])<=0){
if(!forced||ok){
return ok;
}
}
if(typeof cards[ix]=='string'){
ui.click.skill(cards[ix]);
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[ix].classList.add('selected');
ui.selected.cards.add(cards[ix]);
game.check();
if(ui.selected.cards.length>=range[ix]){
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();
if(targets.length==0){
return ok;
}
targets2=targets.slice(0);
// targets.sort(function(a,b){
// return check(b)-check(a);
// });
var ix=0;
var checkix=check(targets[0],targets2);
for(i=1;icheckix){
ix=i;
checkix=checkixtmp;
}
}
if(check(targets[ix])<=0){
if(!forced||ok){
return ok;
}
}
targets[ix].classList.add('selected');
ui.selected.targets.add(targets[ix]);
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,time){
this.classList.add(name);
var that=this;
setTimeout(function(){
that.classList.remove(name);
},time||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(this.timeout){
clearTimeout(this.timeout);
delete this.timeout;
}
if(!this._listeningEnd||this._transitionEnded){
if(typeof time!='number') time=500;
this.classList.add('removing');
var that=this;
this.timeout=setTimeout(function(){
that.remove();
that.classList.remove('removing');
},time);
}
else{
this._onEndDelete=true;
}
return this;
};
HTMLDivElement.prototype.goto=function(position,time){
if(this.timeout){
clearTimeout(this.timeout);
delete this.timeout;
}
if(typeof time!='number') 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.timeout;
delete this.destiny;
this.classList.remove('removing');
return this;
};
HTMLDivElement.prototype.setBackground=function(name,type,ext,subfolder){
var src;
ext=ext||'.jpg';
subfolder=subfolder||'default'
if(type){
var dbimage=null;
if(type=='character'&&lib.character[name]&&lib.character[name][4]){
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.transform=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;i0&&typeof arguments[i]=='number'){
for(var j=0;j.dialog.popped:not(.static)');
for(var i=0;i 10 ||
Math.abs(e.touches[0].clientY - this.startY) > 10) {
_status.dragged=true;
}
});
}
lib.onDB(function(){
if(lib.config.image_background=='custom'){
ui.background.style.backgroundImage="none";
game.getDB('image','background',function(fileToLoad){
if(!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent)
{
var data = fileLoadedEvent.target.result;
ui.background.style.backgroundImage='url('+data+')';
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
});
var proceed=function(){
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.init.start=mode[lib.config.mode].start;
if(game.onwash){
lib.onwash.push(game.onwash);
delete game.onwash;
}
if(game.onover){
lib.onover.push(game.onover);
delete game.onover;
}
lib.config.current_mode=mode[lib.config.mode].config||[];
lib.config.banned=get.config('banned')||[];
lib.config.bannedcards=get.config('bannedcards')||[];
lib.rank=window.characterRank;
delete window.characterRank;
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(i=='start') 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].character){
lib.characterPack[i]=character[i].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)){
if(lib.config.mode=='chess'&&get.config('chess_mode')=='leader'){
for(k in character[i][j]){
lib.hiddenCharacters.push(k);
}
}
else if(lib.config.mode!='boss'||i!='boss'){
continue;
}
}
for(k in character[i][j]){
if(j=='character'){
if(!character[i][j][k][4]){
character[i][j][k][4]=[];
}
if(character[i][j][k][4].contains('boss')||
character[i][j][k][4].contains('hiddenboss')){
lib.config.forbidai.add(k);
}
if(lib.config.banned.contains(k)){
if(lib.config.mode=='chess'&&get.config('chess_mode')=='leader'){
lib.hiddenCharacters.push(k);
}
else{
continue;
}
}
for(var l=0;l |