"use strict"; (function(){ window.resetGameTimeout=setTimeout(function(){ if(window.inSplash) return; if(window.resetExtension){ if(confirm('游戏似乎未正常载入,是否禁用扩展并重新打开?')){ window.resetExtension(); window.location.reload(); } } else{ if(confirm('游戏似乎未正常载入,是否重置游戏?')){ var noname_inited=localStorage.getItem('noname_inited'); localStorage.clear(); if(noname_inited){ localStorage.setItem('noname_inited',noname_inited); } if(indexedDB) indexedDB.deleteDatabase('noname_0.9_data'); window.location.reload(); } } },5000); var links=document.head.querySelectorAll('link'); for(var i=0;iname.indexOf('|')){ lib.translate[name]=name.slice(name.indexOf('|')+1,name.lastIndexOf('|')); } else{ lib.translate[name]=name.slice(name.indexOf('|')+1); } } }, checkCharacterName:function(name){ if(lib.character[name]){ if(!lib.customCharacters.contains(name)) return true; for(var i in lib.config.customCharacterPack){ if(lib.config.customCharacterPack[i].character.contains(name)) return true; } } return false; }, checkSkillName:function(name){ if(lib.skill[name]){ if(!lib.skill[name].createInfo) return true; for(var i in lib.config.customCharacterPack){ if(lib.config.customCharacterPack[i].skill.contains(name)) return true; } } return false; }, listenEnd:function(node){ if(!node._listeningEnd){ node._listeningEnd=true; node.addEventListener('webkitTransitionEnd',function(){ delete node._listeningEnd; if(node._onEndMoveDelete){ node.moveDelete(node._onEndMoveDelete); } else if(node._onEndDelete){ node.delete(); } node._transitionEnded=true; }); } }, configMenu:{ general:{ name:'通用', config:{ cheat:{ name:'控制台命令', init:false, onclick:function(bool){ game.saveConfig('cheat',bool); if(_status.connectMode) return; 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(); } }, unfrequent:true, }, low_performance:{ name:'流畅模式', init:false, onclick:function(bool){ game.saveConfig('low_performance',bool); if(bool){ ui.arena.classList.add('low_performance'); } else{ ui.arena.classList.remove('low_performance'); } } }, confirm_exit:{ name:'确认退出', init:false, unfrequent:true }, auto_confirm:{ name:'自动确认', init:true, unfrequent:true, }, enable_drag:{ name:'启用拖拽', init:true, unfrequent:true, }, enable_dragline:{ name:'拖拽指示线', init:true, unfrequent:true, }, enable_touchdragline:{ name:'拖拽指示线', init:false, unfrequent:true, }, wuxie_self:{ name:'不无懈自己', init:true, }, tao_enemy:{ name:'不对敌将使用桃', init:false, }, touchscreen:{ name:'触屏模式', init:false, restart:true, unfrequent:true, }, change_skin:{ name:'双击换肤', init:true }, swipe:{ name:'滑动手势', init:true, unfrequent:true, }, swipe_down:{ name:'下划操作', init:'menu', unfrequent:true, item:{ system:'显示按钮', menu:'打开菜单', pause:'切换暂停', auto:'切换托管', off:'关闭', } }, swipe_up:{ name:'上划操作', init:'auto', unfrequent:true, item:{ system:'显示按钮', menu:'打开菜单', pause:'切换暂停', auto:'切换托管', off:'关闭', } }, swipe_left:{ name:'左划操作', init:'off', unfrequent:true, item:{ system:'显示按钮', menu:'打开菜单', pause:'切换暂停', auto:'切换托管', off:'关闭', } }, swipe_right:{ name:'右划操作', init:'off', unfrequent:true, item:{ system:'显示按钮', menu:'打开菜单', pause:'切换暂停', auto:'切换托管', off:'关闭', } }, round_menu_func:{ name:'触屏按钮操作', init:'system', unfrequent:true, item:{ system:'显示按钮', menu:'打开菜单', // pause:'切换暂停', // auto:'切换托管' } }, show_splash:{ name:'显示开始界面', init:false, }, game_speed:{ name:'游戏速度', init:'mid', item:{ vslow:'慢', slow:'较慢', mid:'中', fast:'较快', vfast:'快', vvfast:'很快', }, }, sync_speed:{ name:'限制结算速度', init:true }, enable_vibrate:{ name:'开启震动', init:true }, right_click:{ name:'右键功能', init:'pause', unfrequent:true, item:{ pause:'暂停', config:'选项', auto:'托管', } }, right_info:{ name:'右键显示信息', init:true, unfrequent:true, restart:true }, hover_all:{ name:'悬停显示信息', init:true, unfrequent:true, restart:true, }, hover_handcard:{ name:'悬停手牌显示信息', init:true, unfrequent:true, }, hoveration:{ name:'悬停菜单弹出时间', unfrequent:true, init:'1000', item:{ '500':'0.5秒', '700':'0.7秒', '1000':'1秒', '1500':'1.5秒', '2500':'2.5秒', } }, video:{ name:'保存录像', init:'20', item:{ '0':'关闭', '5':'五局', '10':'十局', '20':'二十局', '50':'五十局', '10000':'无限', }, unfrequent:true, }, mousewheel:{ name:'滚轮控制手牌', init:true, unfrequent:true, onclick:function(bool){ game.saveConfig('mousewheel',bool); if(lib.config.touchscreen) return; if(lib.config.mousewheel){ ui.handcards1Container.onmousewheel=ui.click.mousewheel; ui.handcards2Container.onmousewheel=ui.click.mousewheel; } else{ ui.handcards1Container.onmousewheel=null; ui.handcards2Container.onmousewheel=null; } } }, auto_check_update:{ name:'自动检查游戏更新', init:false, unfrequent:true }, update:function(config,map){ if(config.touchscreen){ map.mousewheel.hide(); map.hover_all.hide(); map.hover_handcard.hide(); map.hoveration.hide(); map.right_info.hide(); map.right_click.hide(); map.swipe.show(); if(config.swipe){ map.swipe_up.show(); map.swipe_down.show(); map.swipe_left.show(); map.swipe_right.show(); } else{ map.swipe_up.hide(); map.swipe_down.hide(); map.swipe_left.hide(); map.swipe_right.hide(); } } else{ map.mousewheel.show(); map.hover_all.show(); map.right_info.show(); map.right_click.show(); if(!config.hover_all){ map.hover_handcard.hide(); map.hoveration.hide(); } else{ map.hover_handcard.show(); map.hoveration.show(); } map.swipe.hide(); map.swipe_up.hide(); map.swipe_down.hide(); map.swipe_left.hide(); map.swipe_right.hide(); } if(lib.config.enable_drag){ if(lib.config.touchscreen){ map.enable_dragline.hide(); map.enable_touchdragline.show(); } else{ map.enable_dragline.show(); map.enable_touchdragline.hide(); } } else{ map.enable_dragline.hide(); map.enable_touchdragline.hide(); } if(lib.config.layout!='phone'){ map.round_menu_func.hide(); } else{ map.round_menu_func.show(); } } } }, appearence:{ name:'外观', config:{ theme:{ name:'主题', init:'woodden', item:{}, onclick: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:{ name:'布局', init:'mobile', item:{ default:'旧版', newlayout:'对称', mobile:'默认', phone:'移动' }, onclick:function(layout){ if(lib.config.layoutfixed.contains(lib.config.mode)&&layout=='default'){ game.saveConfig('layout',layout); } else{ lib.init.layout(layout); } } }, // background_color_music:{ // name:'背景色', // init:'black', // item:{ // blue:'蓝色', // black:'黑色', // }, // onclick:function(color){ // game.saveConfig('background_color_music',color); // document.body.dataset.background_color_music=color; // } // }, // background_color_wood:{ // name:'背景色', // init:'blue', // item:{ // blue:'蓝色', // black:'黑色', // }, // onclick:function(color){ // game.saveConfig('background_color_wood',color); // document.body.dataset.background_color_wood=color; // } // }, // theme_color_music:{ // name:'主题色', // init:'black', // item:{ // blue:'蓝色', // black:'黑色', // }, // onclick:function(color){ // game.saveConfig('theme_color_music',color); // document.body.dataset.theme_color_music=color; // } // }, ui_zoom:{ name:'界面缩放', unfrequent:true, init:'normal', item:{ esmall:'80%', vsmall:'90%', small:'95%', normal:'100%', big:'105%', vbig:'110%', ebig:'120%', }, onclick:function(zoom){ game.saveConfig('ui_zoom',zoom); switch(zoom){ case 'esmall':ui.window.style.zoom=0.8;break; case 'vsmall':ui.window.style.zoom=0.9;break; case 'small':ui.window.style.zoom=0.95;break; case 'big':ui.window.style.zoom=1.05;break; case 'vbig':ui.window.style.zoom=1.1;break; case 'ebig':ui.window.style.zoom=1.2;break; default:ui.window.style.zoom=1; } } }, image_background:{ name:'游戏背景', init:'default', item:{ default:'默认', custom:'自定', }, onclick:function(background){ var animate=lib.config.image_background=='default'; game.saveConfig('image_background',background); ui.background.delete(); ui.background=ui.create.div('.background'); if(lib.config.image_background_blur){ ui.background.style.filter='blur(8px)'; ui.background.style.webkitFilter='blur(8px)'; ui.background.style.transform='scale(1.05)'; } else{ 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'; }, }, import_background:{ name:'
'+ ''+ '
', clear:true, }, image_background_blur:{ name:'背景模糊', init:false, onclick:function(bool){ game.saveConfig('image_background_blur',bool); if(lib.config.image_background_blur){ ui.background.style.filter='blur(8px)'; ui.background.style.webkitFilter='blur(8px)'; ui.background.style.transform='scale(1.05)'; } else{ ui.background.style.filter=''; ui.background.style.webkitFilter=''; ui.background.style.transform=''; } }, }, card_style:{ name:'卡牌样式', init:'default', item:{ default:'默认', wood:'木纹', music:'音乐', simple:'原版', new:'新版' }, onclick:function(layout){ game.saveConfig('card_style',layout); var style=ui.css.card_style; ui.css.card_style=lib.init.css(lib.assetURL+'theme/style/card',lib.config.card_style); style.remove(); }, unfrequent:true, }, cardback_style:{ name:'卡背样式', init:'default', item:{ default:'默认', wood:'木纹', music:'音乐', official:'原版', new:'新版', }, onclick:function(layout){ game.saveConfig('cardback_style',layout); var style=ui.css.cardback_style; ui.css.cardback_style=lib.init.css(lib.assetURL+'theme/style/cardback',lib.config.cardback_style); style.remove(); }, unfrequent:true, }, hp_style:{ name:'体力条样式', init:'default', item:{ default:'默认', official:'勾玉', }, onclick:function(layout){ game.saveConfig('hp_style',layout); var style=ui.css.hp_style; ui.css.hp_style=lib.init.css(lib.assetURL+'theme/style/hp',lib.config.hp_style); style.remove(); if(lib.config.layout=='default'&&lib.config.hp_style=='official'){ ui.arena.classList.add('hpimage'); } else{ ui.arena.classList.remove('hpimage'); } }, unfrequent:true, }, show_log:{ name:'显示历史记录', init:'off', unfrequent:true, item:{ off:'关闭', left:'靠左', center:'居中', right:'靠右', }, onclick:function(bool){ game.saveConfig('show_log',bool); if(lib.config.show_log!='off'){ ui.arenalog.style.display=''; ui.arenalog.dataset.position=bool; } else{ ui.arenalog.style.display='none'; ui.arenalog.innerHTML=''; } } }, log_highlight:{ name:'历史记录高亮', init:true, unfrequent:true, }, glow_phase:{ name:'当前回合角色高亮', unfrequent:true, init:'yellow', item:{ none:'无', yellow:'黄色', green:'绿色', purple:'紫色', }, onclick:function(bool){ game.saveConfig('glow_phase',bool); if(_status.currentPhase){ if(lib.config.glow_phase){ _status.currentPhase.classList.add('glow_phase'); ui.arena.dataset.glow_phase=lib.config.glow_phase; } else{ _status.currentPhase.classList.remove('glow_phase'); } } } }, slim_player:{ name:'窄边框', init:true, unfrequent:true, onclick:function(bool){ game.saveConfig('slim_player',bool); if(bool){ ui.arena.classList.add('slim_player'); } else{ ui.arena.classList.remove('slim_player'); } } }, reduce_radius:{ name:'减小圆角', init:false, unfrequent:true, onclick:function(bool){ game.saveConfig('reduce_radius',bool); if(bool){ ui.window.classList.add('reduce_radius'); } else{ ui.window.classList.remove('reduce_radius'); } } }, // popup_style:{ // name:'提示样式', // init:'newstyle', // item:{ // newstyle:'默认', // old:'旧版' // }, // unfrequent:true, // }, show_card_prompt:{ name:'显示出牌提示', init:true, unfrequent:true, }, hide_card_prompt_basic:{ name:'隐藏基本牌提示', init:false, unfrequent:true, }, hide_card_prompt_equip:{ name:'隐藏装备牌提示', init:false, unfrequent:true, }, show_phase_prompt:{ name:'显示阶段提示', init:true, unfrequent:true, }, fold_card:{ name:'折叠手牌', init:true, unfrequent:true, }, auto_popped_config:{ name:'自动弹出选项', init:true, unfrequent:true, }, auto_popped_history:{ name:'自动弹出历史', init:false, unfrequent:true, }, remember_dialog:{ name:'记住对话框位置', init:false, unfrequent:true, }, reset_dialog:{ name:'重置对话框位置', clear:true, unfrequent:true, onclick:function(){ if(ui.dialog){ var dialog=ui.dialog; dialog.style.transform=''; dialog._dragtransform=[0,0]; dialog.style.transition='all 0.3s'; dialog._dragtouches; dialog._dragorigin; dialog._dragorigintransform; setTimeout(function(){ dialog.style.transition=''; },500); } game.saveConfig('dialog_transform',[0,0]); } }, remember_round_button:{ name:'记住按钮位置', init:false, unfrequent:true, }, reset_round_button:{ name:'重置按钮位置', clear:true, unfrequent:true, onclick:function(){ ui.click.resetround(); } }, character_dialog_tool:{ name:'自由选将显示', init:'最近', item:{ '收藏':'收藏', '最近':'最近', '自创':'自创', all:'全部' }, unfrequent:true, }, recent_character_number:{ name:'最近使用武将', init:'12', item:{ '6':'6', '12':'12', '20':'24', '30':'36', }, unfrequent:true }, show_favourite:{ name:'显示添加收藏', init:true, unfrequent:true }, hide_card_image:{ name:'隐藏卡牌背景', init:false, unfrequent:true, restart:true, }, show_name:{ name:'显示武将名', init:false, unfrequent:true, onclick:function(bool){ game.saveConfig('show_name',bool); if(lib.config.show_name){ for(var i=0;i'+ ''+ '', clear:true, }, background_audio:{ name:'游戏音效', init:true, }, background_speak:{ name:'人物配音', init:true, }, background_ogg:{ name:'补全配音', init:true }, volumn_audio:{ name:'音效音量', init:8, item:{ '1':'一', '2':'二', '3':'三', '4':'四', '5':'五', '6':'六', '7':'七', '8':'八', }, onclick:function(volume){ game.saveConfig('volumn_audio',parseInt(volume)); } }, volumn_background:{ name:'音乐音量', init:8, item:{ '1':'一', '2':'二', '3':'三', '4':'四', '5':'五', '6':'六', '7':'七', '8':'八', }, onclick:function(volume){ game.saveConfig('volumn_background',parseInt(volume)); ui.backgroundMusic.volume=volume/8; } } } }, extension:{ name:'扩展', config:{ character:{ name:'技能卡牌', init:false, restart:true, onclick:function(bool){ if(bool){ lib.config.plays.add('character'); } else{ lib.config.plays.remove('character'); } game.saveConfig('plays',lib.config.plays); } }, character_num_playpackconfig:{ name:'卡牌比例', init:'0.05', item:{ '0.02':'2%', '0.05':'5%', '0.1':'10%', '0.2':'20%', } }, character_hide_playpackconfig:{ name:'隐藏此扩展', clear:true, onclick:function(){ lib.config.hiddenPlayPack.add('character'); game.saveConfig('hiddenPlayPack',lib.config.hiddenPlayPack); } }, soldier:{ name:'士兵模式', init:false, restart:true, onclick:function(bool){ if(bool){ lib.config.plays.add('soldier'); } else{ lib.config.plays.remove('soldier'); } game.saveConfig('plays',lib.config.plays); } }, soldier_hide_playpackconfig:{ name:'隐藏此扩展', clear:true, onclick:function(){ lib.config.hiddenPlayPack.add('soldier'); game.saveConfig('hiddenPlayPack',lib.config.hiddenPlayPack); } }, wuxing:{ name:'五行生克', init:false, restart:true, onclick:function(bool){ if(bool){ lib.config.plays.add('wuxing'); } else{ lib.config.plays.remove('wuxing'); } game.saveConfig('plays',lib.config.plays); } }, wuxing_num_playpackconfig:{ name:'带属性卡牌', init:'0.3', item:{ '0.1':'10%', '0.2':'20%', '0.3':'30%', '0.5':'50%', } }, wuxing_hide_playpackconfig:{ name:'隐藏此扩展', clear:true, onclick:function(){ lib.config.hiddenPlayPack.add('wuxing'); game.saveConfig('hiddenPlayPack',lib.config.hiddenPlayPack); } }, weather:{ name:'天气变化', init:false, restart:true, onclick:function(bool){ if(bool){ lib.config.plays.add('weather'); } else{ lib.config.plays.remove('weather'); } game.saveConfig('plays',lib.config.plays); } }, // weather_animation_playpackconfig:{ // name:'天气动画', // init:true // }, weather_noqing_playpackconfig:{ name:'异常天气出现概率', init:'0.5', item:{ '0.1':'10%', '0.3':'30%', '0.5':'50%', '0.7':'70%', '0.9':'90%', } }, weather_chance_playpackconfig:{ name:'天气效果触发概率', init:'0.5', item:{ '0.1':'10%', '0.2':'20%', '0.3':'30%', '0.5':'50%', '0.8':'80%', }, onclick:function(item){ game.saveConfig('weather_chance_playpackconfig',item); _status.weatherchance=parseFloat(lib.config.weather_chance_playpackconfig)||0; } }, weather_duration_playpackconfig:{ name:'异常天气持续时间', init:'[4,4]', item:{ '[2,4]':'1~3回合', '[4,4]':'3~6回合', '[4,7]':'3~9回合', '[7,4]':'6~9回合', '[7,7]':'6~12回合', } }, weather_qingduration_playpackconfig:{ name:'晴朗天气持续时间', init:'[2,4]', item:{ '[2,4]':'1~3回合', '[4,4]':'3~6回合', '[4,7]':'3~9回合', '[7,4]':'6~9回合', '[7,7]':'6~12回合', } }, weather_hide_playpackconfig:{ name:'隐藏此扩展', clear:true, onclick:function(){ lib.config.hiddenPlayPack.add('weather'); game.saveConfig('hiddenPlayPack',lib.config.hiddenPlayPack); } }, coin:{ name:'富甲天下', init:false, restart:true, onclick:function(bool){ if(bool){ lib.config.plays.add('coin'); } else{ lib.config.plays.remove('coin'); } game.saveConfig('plays',lib.config.plays); } }, coin_display_playpackconfig:{ name:'金币显示', init:'text', item:{ symbol:'符号', text:'文字' }, onclick:function(item){ game.saveConfig('coin_display_playpackconfig',item); if(game.changeCoin) game.changeCoin(0); } }, coin_canvas_playpackconfig:{ name:'特效置顶', init:false, onclick:function(bool){ game.saveConfig('coin_canvas_playpackconfig',bool); if(bool){ ui.window.classList.add('canvas_top'); } else{ ui.window.classList.remove('canvas_top'); } } }, coin_hide_playpackconfig:{ name:'隐藏此扩展', clear:true, onclick:function(){ lib.config.hiddenPlayPack.add('coin'); game.saveConfig('hiddenPlayPack',lib.config.hiddenPlayPack); } }, update:function(config,map){ for(var i in map){ if(i.indexOf('extension_')==0) continue; if(i.indexOf('_playpackconfig')!=-1){ var packname=i.slice(0,i.indexOf('_')); map[i].classList.add('indent'); if(!lib.config.hiddenPlayPack.contains(packname)&& lib.config.plays.contains(packname)){ map[i].show(); } else{ map[i].hide(); } } else{ if(lib.config.hiddenPlayPack.contains(i)){ map[i].hide(); } else{ if(lib.config.plays.contains(i)){ map[i].classList.add('on'); } else{ map[i].classList.remove('on'); } } } } for(var i=0;i'+ ''+ '', clear:true, }, export_data:{ name:'导出游戏设置', onclick:function(){ var data={}; for(var i in localStorage){ data[i]=localStorage[i]; } game.export(lib.init.encode(JSON.stringify(data)),'无名杀 - 数据 - '+(new Date()).toLocaleString()); }, clear:true }, trim_game:{ name:'隐藏非官方扩展包', onclick:function(){ if(this.innerHTML!='已隐藏'){ this.innerHTML='已隐藏'; game.saveConfig('hiddenModePack',['stone','chess','boss']); game.saveConfig('hiddenCardPack',['zhenfa','yunchou','swd','shenqi','hearth','compensate']); game.saveConfig('hiddenCharacterPack',['diy','yxs','hearth','swd','gujian','xianjian','xiake','boss']); var that=this; setTimeout(function(){ that.innerHTML='隐藏非官方扩展包'; },500); } }, clear:true } } } }, mode:{ identity:{ name:'身份', connect:true, config:{ update:function(config,map){ if(ui.connectButton.classList.contains('glow')){ for(var i in map){ if(map[i]._link.config.connect){ map[i].style.display=''; } else{ map[i].style.display='none'; } } map.observe.show(); map.choose_timeout.show(); } else{ for(var i in map){ map[i].style.display=''; } map.observe.hide(); map.choose_timeout.hide(); } if(config.identity_mode=='zhong'){ map.player_number.hide(); map.enhance_zhu.hide(); map.double_nei.hide(); map.auto_identity.hide(); map.choice_zhu.hide(); map.choice_zhong.hide(); map.choice_nei.hide(); map.choice_fan.hide(); } else{ map.player_number.show(); map.enhance_zhu.show(); map.auto_identity.show(); if(config.player_number!='2'){ map.double_nei.show(); } else{ map.double_nei.hide(); } map.choice_zhu.show(); map.choice_zhong.show(); map.choice_nei.show(); map.choice_fan.show(); } }, identity_mode:{ name:'游戏模式', init:'normal', item:{ normal:'普通', zhong:'明忠' }, restart:true, frequent:true, connect:true }, choose_timeout:{ name:'出牌时限', init:'30', item:{ '10':'10秒', '15':'15秒', '30':'30秒', '60':'60秒', '90':'90秒', }, connect:true, frequent:true }, player_number:{ name:'游戏人数', init:'8', item:{ '2':'两人', '3':'三人', '4':'四人', '5':'五人', '6':'六人', '7':'七人', '8':'八人' }, frequent:true, restart:true, connect:true }, observe:{ name:'允许旁观', init:false, connect:true }, double_nei:{ name:'双内奸', init:false, restart:true, frequent:true, connect:true }, double_character:{ name:'双将模式', init:false, frequent:true, restart:true, connect:true }, double_hp:{ name:'双将体力上限', init:'pingjun', item:{ hejiansan:'和减三', pingjun:'平均值', zuidazhi:'最大值', zuixiaozhi:'最小值', zonghe:'相加', }, restart:true, connect:true }, auto_identity:{ name:'自动显示身份', item:{ off:'关闭', one:'一轮', two:'两轮', three:'三轮', always:'始终' }, init:'off', onclick:function(bool){ game.saveConfig('auto_identity',bool,this._link.config.mode); if(get.config('identity_mode')=='zhong') return; var num; switch(bool){ case '一轮':num=1;break; case '两轮':num=2;break; case '三轮':num=3;break; default:num=0;break; } if(num&!_status.identityShown&&game.phaseNumber>game.players.length*num&&game.showIdentity){ _status.identityShown=true; game.showIdentity(false); } } }, auto_mark_identity:{ name:'自动标记身份', init:true, }, ban_weak:{ name:'屏蔽弱将', init:false, restart:true, connect:true }, ban_strong:{ name:'屏蔽强将', init:false, restart:true, connect:true }, enhance_zhu:{ name:'加强主公', init:false, restart:true, connect:true }, free_choose:{ name:'自由选将', init:true, onclick:function(bool){ game.saveConfig('free_choose',bool,this._link.config.mode); if(!_status.event.getParent().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:{ name:'自由选择身份和座位', init:true, onclick:function(bool){ game.saveConfig('change_identity',bool,this._link.config.mode); if(!_status.event.getParent().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.getParent().addSetting(dialog); else _status.event.getParent().removeSetting(dialog); ui.update(); } }, change_choice:{ name:'开启换将卡', init:true, onclick:function(bool){ game.saveConfig('change_choice',bool,this._link.config.mode); if(!_status.event.getParent().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; } } }, change_card:{ name:'开启手气卡', init:'disabled', item:{ disabled:'禁用', once:'一次', twice:'两次', unlimited:'无限', }, }, continue_game:{ name:'显示再战', init:false, onclick:function(bool){ game.saveConfig('continue_game',bool,this._link.config.mode); if(get.config('continue_game')){ if(!ui.continue_game&&_status.over){ ui.continue_game=ui.create.control('再战',game.reloadCurrent); } } else if(ui.continue_game){ ui.continue_game.close(); delete ui.continue_game; } } }, dierestart:{ name:'死亡后显示重来', init:true, onclick:function(bool){ game.saveConfig('dierestart',bool,this._link.config.mode); if(get.config('dierestart')){ if(!ui.restart&&game.me.isDead()&&!_status.connectMode){ ui.restart=ui.create.control('restart',game.reload); } } else if(ui.restart){ ui.restart.close(); delete ui.restart; } } }, revive:{ name:'死亡后显示复活', init:false, onclick:function(bool){ game.saveConfig('revive',bool,this._link.config.mode); 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; } } }, ai_strategy:{ name:'内奸策略', init:'ai_strategy_1', item:{ ai_strategy_1:'均衡', ai_strategy_2:'偏反', ai_strategy_3:'偏忠', ai_strategy_4:'酱油', ai_strategy_5:'天使', ai_strategy_6:'仇主', }, }, difficulty:{ name:'AI对人类态度', init:'normal', item:{ easy:'友好', normal:'一般', hard:'仇视', }, }, choice_zhu:{ name:'主公候选武将数', init:'3', restart:true, item:{ '3':'三', '4':'四', '5':'五', '6':'六', '8':'八', '10':'十', }, }, choice_zhong:{ name:'忠臣候选武将数', init:'4', restart:true, item:{ '3':'三', '4':'四', '5':'五', '6':'六', '8':'八', '10':'十', }, }, choice_nei:{ name:'内奸候选武将数', init:'5', restart:true, item:{ '3':'三', '4':'四', '5':'五', '6':'六', '8':'八', '10':'十', }, }, choice_fan:{ name:'反贼候选武将数', init:'3', restart:true, item:{ '3':'三', '4':'四', '5':'五', '6':'六', '8':'八', '10':'十', }, }, } }, guozhan:{ name:'国战', config:{ guozhan_mode:{ name:'游戏模式', init:'normal', item:{ normal:'普通', mingjiang:'明将' }, frequent:true, }, player_number:{ name:'游戏人数', init:'8', item:{ '3':'三人', '4':'四人', '5':'五人', '6':'六人', '7':'七人', '8':'八人' }, frequent:true, restart:true, }, initshow_draw:{ name:'首亮摸牌', item:{ '0':'无', '1':'一张', '2':'两张', '3':'三张', }, init:'2', frequent:true, }, zhulian:{ name:'珠联璧合', init:true, frequent:true, }, double_hp:{ name:'双将体力上限', init:'pingjun', item:{ hejiansan:'和减三', pingjun:'平均值', zuidazhi:'最大值', zuixiaozhi:'最小值', zonghe:'相加', }, restart:true, }, ban_weak:{ name:'屏蔽强将', init:false, restart:true, }, ban_strong:{ name:'屏蔽强将', init:false, restart:true, }, free_choose:{ name:'自由选将', init:true, onclick:function(bool){ game.saveConfig('free_choose',bool,this._link.config.mode); if(!_status.event.getParent().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:{ name:'自由选择座位', init:true, onclick:function(bool){ game.saveConfig('change_identity',bool,this._link.config.mode); if(!_status.event.getParent().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.getParent().addSetting(dialog); else _status.event.getParent().removeSetting(dialog); ui.update(); } }, change_choice:{ name:'开启换将卡', init:true, onclick:function(bool){ game.saveConfig('change_choice',bool,this._link.config.mode); if(!_status.event.getParent().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; } } }, change_card:{ name:'开启手气卡', init:'disabled', item:{ disabled:'禁用', once:'一次', twice:'两次', unlimited:'无限', } }, continue_game:{ name:'显示再战', init:true, onclick:function(bool){ game.saveConfig('continue_game',bool,this._link.config.mode); if(get.config('continue_game')){ if(!ui.continue_game&&_status.over){ ui.continue_game=ui.create.control('再战',game.reloadCurrent); } } else if(ui.continue_game){ ui.continue_game.close(); delete ui.continue_game; } } }, dierestart:{ name:'死亡后显示重来', init:true, onclick:function(bool){ game.saveConfig('dierestart',bool,this._link.config.mode); if(get.config('dierestart')){ if(!ui.restart&&game.me.isDead()&&!_status.connectMode){ ui.restart=ui.create.control('restart',game.reload); } } else if(ui.restart){ ui.restart.close(); delete ui.restart; } } }, revive:{ name:'死亡后显示复活', init:false, onclick:function(bool){ game.saveConfig('revive',bool,this._link.config.mode); 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; } } }, difficulty:{ name:'AI对人类态度', init:'normal', item:{ easy:'友好', normal:'一般', hard:'仇视', } }, choice_num:{ name:'候选武将数', init:'7', restart:true, item:{ '5':'五', '6':'六', '7':'七', '8':'八', '9':'九', '10':'十', } }, } }, versus:{ name:'对决', config:{ update:function(config,map){ if(config.versus_mode=='four'){ map.change_choice.hide(); map.enable_all.show(); map.four_assign.show(); } else{ map.change_choice.show(); map.enable_all.hide(); map.four_assign.hide(); } if(config.versus_mode=='jiange'){ map.free_choose.show(); map.double_character_jiange.show(); } else{ map.free_choose.hide(); map.double_character_jiange.hide(); } }, versus_mode:{ name:'游戏模式', init:'standard', item:{ standard:'标准', jiange:'剑阁', four:'4v4' }, restart:true, frequent:true, }, enable_all:{ name:'启用全部武将', init:false, frequent:true, restart:true, }, four_assign:{ name:'代替队友选将', init:true, frequent:true, restart:true, }, free_choose:{ name:'自由选将', init:true, frequent:true, onclick:function(bool){ game.saveConfig('free_choose',bool,this._link.config.mode); if(!ui.create.cheat2) return; if(!_status.event.getParent().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; } } }, change_choice:{ name:'开启换将卡', init:true, onclick:function(bool){ game.saveConfig('change_choice',bool,this._link.config.mode); if(!_status.event.getParent().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; } }, frequent:true, }, double_character_jiange:{ name:'双将模式', init:false, frequent:true, }, ban_weak:{ name:'屏蔽弱将', init:false, restart:true, // frequent:true, }, ban_strong:{ name:'屏蔽强将', init:false, restart:true, // frequent:true, }, } }, boss:{ name:'挑战', config:{ free_choose:{ name:'自由选将', init:true, frequent:true, onclick:function(bool){ game.saveConfig('free_choose',bool,this._link.config.mode); if(!_status.event.getParent().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_choice:{ name:'开启换将卡', init:true, onclick:function(bool){ game.saveConfig('change_choice',bool,this._link.config.mode); if(!_status.event.getParent().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; } }, frequent:true, }, single_control:{ name:'单人控制', init:true, frequent:true, onclick:function(bool){ game.saveConfig('single_control',bool,this._link.config.mode); if(ui.single_swap&&game.me!=game.boss){ if(bool){ ui.single_swap.style.display='none'; } else{ ui.single_swap.style.display=''; } } }, }, ban_weak:{ name:'屏蔽弱将', init:false, restart:true, frequent:true, }, ban_strong:{ name:'屏蔽强将', init:false, restart:true, frequent:true, }, } }, chess:{ name:'战棋', config:{ chess_mode:{ name:'游戏模式', init:'combat', item:{ combat:'对战', leader:'君主', tafang:'塔防' }, restart:true, frequent:true, }, update:function(config,map){ if(config.chess_mode=='leader'){ map.chess_leader_save.show(); map.chess_leader_clear.show(); map.chess_character.hide(); } else{ map.chess_leader_save.hide(); map.chess_leader_clear.hide(); map.chess_character.show(); } if(config.chess_mode=='combat'){ // map.battle_number.show(); // map.chess_ordered.show(); map.free_choose.show(); map.change_choice.show(); } else{ // map.battle_number.hide(); // map.chess_ordered.hide(); map.free_choose.hide(); map.change_choice.hide(); } if(config.chess_mode=='tafang'){ map.chess_treasure.hide(); map.chess_obstacle.hide(); map.tafang_size.show(); map.tafang_turn.show(); map.tafang_difficulty.show(); } else{ map.chess_treasure.show(); map.chess_obstacle.show(); map.tafang_size.hide(); map.tafang_turn.hide(); map.tafang_difficulty.hide(); } if(config.chess_mode!='leader'){ map.ban_weak.show(); map.ban_strong.show(); } else{ map.ban_weak.hide(); map.ban_strong.hide(); } }, tafang_turn:{ name:'游戏胜利', init:'20', frequent:true, item:{ '10':'十回合', '20':'二十回合', '30':'三十回合', '1000':'无限', } }, tafang_size:{ name:'战场大小', init:'9', frequent:true, item:{ '6':'小', '9':'中', '12':'大', } }, tafang_difficulty:{ name:'战斗难度', init:'2', frequent:true, item:{ '1':'简单', '2':'普通', '3':'困难', } }, chess_leader_save:{ name:'选择历程', init:'save1', item:{ save1:'一', save2:'二', save3:'三', save4:'四', save5:'五', }, restart:true, frequent:true, }, chess_leader_clear:{ name:'清除进度', onclick:function(){ var node=this; if(node._clearing){ game.save(get.config('chess_leader_save'),null); window.location.reload(); return; } node._clearing=true; node.innerHTML='单击以确认 (3)'; setTimeout(function(){ node.innerHTML='单击以确认 (2)'; setTimeout(function(){ node.innerHTML='单击以确认 (1)'; setTimeout(function(){ node.innerHTML='清除进度'; delete node._clearing; },1000); },1000); },1000); }, clear:true, frequent:true, }, chess_treasure:{ name:'战场机关', init:'0.2', frequent:true, item:{ '0':'关闭', '0.1':'较少出现', '0.2':'偶尔出现', '0.333':'时常出现', '0.5':'频繁出现', } }, chess_obstacle:{ name:'随机路障', init:'0', item:{ '0':'关闭', '0.2':'少量', '0.333':'中量', '0.5':'大量', }, frequent:true, }, attack_move:{ name:'击退效果', init:true, }, show_range:{ name:'显示卡牌范围', init:true, }, show_distance:{ name:'显示距离', init:true, }, chess_character:{ name:'战棋武将', init:true, }, // chess_jiange:{ // name:'守卫剑阁', // init:true, // }, chess_card:{ name:'战棋卡牌', init:true, }, free_choose:{ name:'自由选将', init:true, onclick:function(bool){ game.saveConfig('free_choose',bool,this._link.config.mode); if(!_status.event.getParent().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_choice:{ name:'开启换将卡', init:true, onclick:function(bool){ game.saveConfig('change_choice',bool,this._link.config.mode); if(!_status.event.getParent().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; } }, }, ban_weak:{ name:'屏蔽弱将', init:false, restart:true, }, ban_strong:{ name:'屏蔽强将', init:false, restart:true, }, chessscroll_speed:{ name:'边缘滚动速度', init:'20', item:{ '0':'不滚动', '10':'10格/秒', '20':'20格/秒', '30':'30格/秒', } }, } }, stone:{ name:'炉石', config:{ update:function(config,map){ if(config.stone_mode=='deck'){ // map.deck_length.show(); // map.deck_repeat.show(); map.random_length.hide(); map.skill_bar.show(); } else{ // map.deck_length.hide(); // map.deck_repeat.hide(); map.random_length.show(); map.skill_bar.hide(); } }, stone_mode:{ name:'游戏模式', init:'deck', item:{ deck:'构筑', random:'随机' }, restart:true, frequent:true, }, // deck_length:{ // name:'卡组长度', // init:'30', // item:{ // '30':'30张', // '50':'50张', // '80':'80张', // }, // frequent:true, // }, // deck_repeat:{ // name:'重复卡牌', // init:'2', // item:{ // '2':'2张', // '3':'3张', // '5':'5张', // '80':'无限', // }, // frequent:true, // }, random_length:{ name:'随从牌数量', init:'1/80', item:{ '1/120':'少', '1/80':'中', '1/50':'多', }, frequent:true, }, battle_number:{ name:'出场人数', init:'1', frequent:true, item:{ '1':'一人', '2':'两人', '3':'三人', '4':'四人', '6':'六人', '8':'八人', '10':'十人', }, onclick:function(num){ game.saveConfig('battle_number',num,this._link.config.mode); if(!_status.event.getParent().showConfig&&!_status.event.showConfig) return; if(_status.event.getParent().changeDialog){ _status.event.getParent().changeDialog(); } }, }, mana_mode:{ name:'行动值变化', init:'inc', item:{ inf:'涨落', inc:'递增' }, frequent:true }, skill_bar:{ name:'怒气值', init:true, frequent:true, restart:true, }, double_character:{ name:'双将模式', init:false, frequent:true, restart:function(){ return _status.event.getParent().name!='chooseCharacter'||_status.event.name!='chooseButton'; } }, free_choose:{ name:'自由选将', init:true, onclick:function(bool){ game.saveConfig('free_choose',bool,this._link.config.mode); if(!_status.event.getParent().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_choice:{ name:'开启换将卡', init:true, onclick:function(bool){ game.saveConfig('change_choice',bool,this._link.config.mode); if(!_status.event.getParent().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; } }, }, ban_weak:{ name:'屏蔽弱将', init:false, restart:true, }, ban_strong:{ name:'屏蔽强将', init:false, restart:true, }, } }, connect:{ name:'联机', config:{ connect_nickname:{ name:'联机昵称', input:true, frequent:true, init:'无名玩家' }, connect_avatar:{ name:'联机头像', init:'caocao', item:{}, frequent:true, onclick:function(item){ game.saveConfig('connect_avatar',item); game.saveConfig('connect_avatar',item,'connect'); } }, connect_start:{ name:'启动服务器', clear:true, frequent:true, onclick:function(){ game.saveConfig('connectMode',true); game.saveConfig('mode','identity'); localStorage.setItem(lib.configprefix+'directstart',true); game.reload(); } }, update:function(config,map){ if(lib.node){ map.connect_start.show(); } else{ map.connect_start.hide(); } } } } }, status:{ running:false, canvas:false, time:0, delayed:0, frameId:0, videoId:0, }, help:{ '游戏选项':'
  • 控制台命令
    开启后可用浏览器控制台控制游戏
  • 编辑牌堆
    在卡牌包中修改牌堆后,将自动创建一个临时牌堆,在所有模式中共用,当保存当前牌堆后,临时牌堆被清除。每个模式可设置不同的已保存牌堆,设置的牌堆优先级大于临时牌堆。
  • 自动确认
    开启后当候选目标仅有1个时点击目标无需再点击确定
  • '+ '触屏模式
    可消除iOS等设备上300ms的点击延迟,但开启后无法使用鼠标
  • 滚轮控制手牌
    开启后滚轮可控制手牌的左右滚动,建议Mac等具备横向滚动功能的设备关闭此选项'+ '
  • 游戏玩法
    为游戏增加不同玩法,开启后可在帮助中查看介绍', '游戏操作':'
    • 长按/鼠标悬停/右键单击(需在设置中开启)显示信息
    • 触屏模式中,双指点击切换暂停;下划显示菜单,上划切换托管
    • 键盘快捷键
      '+ '
      a切换托管
      c打开设置
      w切换不询问无懈
      i显示身份
      暂停', '游戏命令':'
      变量名
      • 场上角色
        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)
      • 清除命令框中的内容
        cls
      • 游戏结束
        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,forceclick){ node._poppedfunc=func; node._poppedwidth=width; node._poppedheight=height; if(forceclick){ node.forceclick=true; } if(lib.config.touchscreen||forceclick){ node.listen(ui.click.hoverpopped); } else{ node.addEventListener('mouseenter',ui.click.hoverpopped); // node.addEventListener('mouseleave',ui.click.hoverpopped_leave); } }, placePoppedDialog:function(dialog,e){ if(dialog._place_text){ if(dialog._place_text.firstChild.offsetWidth>=190){ dialog._place_text.style.textAlign='left'; dialog._place_text.style.marginLeft='14px'; } } if(e.touches&&e.touches[0]){ e=e.touches[0]; } var height=Math.min(ui.window.offsetHeight-20,dialog.content.scrollHeight); if(dialog._mod_height){ height+=dialog._mod_height; } dialog.style.height=height+'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 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>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" player.phaseJudge(); "step 1" player.phaseDraw(); if(!player.noPhaseDelay){ if(player==game.me){ game.delay(); } else{ game.delayx(); } } "step 2" player.phaseUse(); "step 3" game.broadcastAll(function(){ 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); } game.broadcastAll(function(){ 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" _status.noclearcountdown=true; if(event.isMine()){ if(event.type=='wuxie'){ if(ui.wuxie&&ui.wuxie.classList.contains('glow')){ event.result={ bool:false } return; } if(ui.tempnowuxie&&ui.tempnowuxie.classList.contains('glow')){ event.result={ bool:false } return; } if(!_status.connectMode&&lib.config.wuxie_self&&event.getParent().state){ var tw=event.getParent()._trigger.parent; if(tw.player==player&&tw.targets&&tw.targets.length==1){ event.result={ bool:false } return; } } } var ok=game.check(); 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(event.isOnline()){ event.send(); } else{ event.result='ai'; } "step 1" if(event.result=='ai'){ var ok=game.check(); 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); var info=get.info(skill); if(info.sourceSkill){ event.aiexclude.add(info.sourceSkill); } } 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 2" if(event.result){ if(event.result.skill){ var info=get.info(event.result.skill); if(info&&info.chooseButton){ if(event.dialog&&typeof event.dialog=='object') event.dialog.close(); var dialog=info.chooseButton.dialog(event,player); var next=player.chooseButton(dialog); next.set('ai',info.chooseButton.check||function(){return 1;}); next.set('filterButton',info.chooseButton.filter||function(){return true;}); event.buttoned=event.result.skill; } } } "step 3" if(event.buttoned){ if(result.bool){ var info=get.info(event.buttoned).chooseButton; lib.skill[event.buttoned+'_backup']=info.backup(result.links,player); lib.skill[event.buttoned+'_backup'].sourceSkill=event.buttoned; if(game.online){ event._sendskill=[event.buttoned+'_backup',lib.skill[event.buttoned+'_backup']]; } event.backup(event.buttoned+'_backup'); if(info.prompt){ event.openskilldialog=info.prompt(result.links,player); } } else{ event.aiexclude.add(event.buttoned); } event.goto(0); delete event.buttoned; } "step 4" delete _status.noclearcountdown; if(event.skillDialog&&get.objtype(event.skillDialog)=='div'){ event.skillDialog.close(); } if(event.result.bool&&!game.online&&!event.nouse){ player.useResult(event.result,event); } else if(event._sendskill){ event.result._sendskill=event._sendskill; } if(event.dialog&&typeof event.dialog=='object') event.dialog.close(); if(!_status.noclearcountdown){ game.stopCountChoose(); } "step 5" if(event._result&&event.result){ event.result.result=event._result; } }, chooseToRespond:function(){ "step 0" if(event.responded){ delete event.dialog; return; } if(!_status.connectMode&&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(event.isOnline()){ event.send(); } else{ event.result='ai'; } } "step 1" if(event.result=='ai'){ game.check(); 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 2" if(event.result.bool&&!game.online){ 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(event.isOnline()){ event.send(); } else{ event.result='ai'; } } "step 1" if(event.result=='ai'){ game.check(); 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 2" 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); } } if(!game.online) 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,'发起拼点'); "step 1" var sendback=function(){ if(_status.event!=event){ return function(){ event.resultOL=_status.event.resultOL; }; } }; if(player.isOnline()){ player.wait(sendback); event.ol=true; player.send(function(ai){ game.me.chooseCard('请选择拼点牌',true).set('glow_result',true).ai=ai; game.resume(); },event.ai); } else{ event.localPlayer=true; player.chooseCard('请选择拼点牌',true).set('glow_result',true).ai=event.ai; } if(target.isOnline()){ target.wait(sendback); event.ol=true; target.send(function(ai){ game.me.chooseCard('请选择拼点牌',true).set('glow_result',true).ai=ai; game.resume(); },event.ai); } else{ event.localTarget=true; } "step 2" if(event.localPlayer){ event.card1=result.cards[0]; } if(event.localTarget){ target.chooseCard('请选择拼点牌',true).set('glow_result',true).ai=event.ai; } "step 3" if(event.localTarget){ event.card2=result.cards[0]; } if(!event.resultOL&&event.ol){ game.pause(); } "step 4" try{ if(!event.card1) event.card1=event.resultOL[player.playerid].cards[0]; if(!event.card2) event.card2=event.resultOL[target.playerid].cards[0]; if(!event.card1||!event.card2){ throw('err'); } } catch(e){ console.log(e); event.finish(); return; } 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 5" game.broadcast(function(){ ui.arena.classList.add('thrownhighlight'); }); 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, } event.dialogid=lib.status.videoId++; if(get.number(event.card1)>get.number(event.card2)){ event.result.bool=true; setTimeout(function(){ var str=get.translation(player.name)+'拼点成功'; game.broadcast(function(str,id){ var dialog=ui.create.dialog(str); dialog.videoId=id; dialog.classList.add('center'); },str,event.dialogid); event.dialog=ui.create.dialog(str); 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(){ var str=get.translation(player.name)+'拼点失败'; game.broadcast(function(str,id){ var dialog=ui.create.dialog(str); dialog.videoId=id; dialog.classList.add('center'); },str,event.dialogid); event.dialog=ui.create.dialog(str); 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 6" game.delay(2); "step 7" 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.broadcast(function(id){ var dialog=get.idDialog(id); if(dialog){ dialog.close(); } ui.arena.classList.remove('thrownhighlight'); },event.dialogid); game.addVideo('thrownhighlight2'); if(event.clear!==false){ game.broadcastAll(ui.clear); } event.dialog.close(); }, chooseButton:function(){ "step 0" if(typeof event.dialog=='number'){ event.dialog=get.idDialog(event.dialog); } if(event.createDialog&&!event.dialog){ if(Array.isArray(event.createDialog)){ event.createDialog.add('hidden'); event.dialog=ui.create.dialog.apply(this,event.createDialog); } event.closeDialog=true; } if(event.dialog==undefined) event.dialog=ui.dialog; if(event.isMine()||event.dialogdisplay){ event.dialog.style.display=''; event.dialog.open(); } game.check(); if(event.isMine()){ game.pause(); } else if(event.isOnline()){ event.send(); delete event.callback; } else{ event.result='ai'; } "step 1" if(event.result=='ai'){ game.check(); if(ai.basic.chooseButton(event.ai)||forced) ui.click.ok(); else ui.click.cancel(); } if(event.closeDialog){ event.dialog.close(); } if(event.callback){ event.callback(event.player,event.result); } }, chooseButtonOL:function(){ 'step 0' 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(); game.pause(); } else if(event.isOnline()){ event.send(); } else{ event.result='ai'; } } "step 1" if(event.result=='ai'){ game.check(); if(ai.basic.chooseButton(event.ai)||forced) ui.click.ok(); else ui.click.cancel(); } 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(); game.pause(); } else if(event.isOnline()){ event.send(); } else{ event.result='ai'; } } "step 1" if(event.result=='ai'){ game.check(); if(ai.basic.chooseButton(event.ai)||forced) ui.click.ok(); else ui.click.cancel(); } event.dialog.close(); "step 2" if(event.result.bool&&event.result.buttons&&!game.online){ 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(); game.pause(); } else if(event.isOnline()){ event.send(); } else{ event.result='ai'; } } "step 1" if(event.result=='ai'){ game.check(); if(ai.basic.chooseButton(event.ai)||forced) ui.click.ok(); else ui.click.cancel(); } event.dialog.close(); "step 2" if(game.online){ event.finish(); } "step 3" 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.id=get.id(); event.trigger('useCard'); event._oncancel=function(){ game.broadcastAll(function(id){ if(ui.tempnowuxie&&ui.tempnowuxie._origin==id){ ui.tempnowuxie.close(); delete ui.tempnowuxie; } },event.id); }; if(get.type(card)!='equip'){ var str=''; if(targets.length){ str+='对'+(targets[0]==player?'自己':get.translation(targets[0])); for(var i=1;i1||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]++; } var sourceSkill=get.info(event.skill).sourceSkill; if(sourceSkill){ if(player.stat[player.stat.length-1].skill[sourceSkill]==undefined){ player.stat[player.stat.length-1].skill[sourceSkill]=1; } else{ player.stat[player.stat.length-1].skill[sourceSkill]++; } } } } "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;i1){ if(!info.multitarget){ lib.tempSortSeat=player; targets.sort(lib.sort.seat); delete lib.tempSortSeat; } for(var i=0;i1){ // var ttt=next.target; // setTimeout(function(){ttt.animate('target');},0.5*lib.config.duration); } else{ next.target.animate('target'); } } if(num==0){ if(typeof info.delay=='number') game.delay(info.delay); else if(info.delay!==false&&info.delay!==0){ 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'); } game.broadcast(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.broadcast(function(){ 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.getParent().discardTransition){ delete event.getParent().discardTransition; var waitingForTransition=get.time(); event.getParent().waitingForTransition=waitingForTransition; cards[0].clone.addEventListener('webkitTransitionEnd',function(){ if(_status.waitingForTransition==waitingForTransition&&_status.paused){ game.resume(); } delete event.getParent().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.getParent(3).name=='useCard'){ game.broadcastAll(function(player,card){ 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'); } } },player,card); } 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)]); } }; var broadcast=function(){ game.broadcast(function(player,cards){ player.directgain(cards); },player,cards); }; 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(); broadcast(); },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(); broadcast(); },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(); broadcast(); },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(); broadcast(); } }, 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; } } ui.updatehl(); } },player,cards); game.addVideo('lose',player,[get.cardsInfo(hs),get.cardsInfo(es),get.cardsInfo(js)]); player.update(); game.addVideo('loseAfter',player); for(var i=player.node.handcards1.childNodes.length-1;i>0;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':'')); } game.broadcast(function(num){ if(lib.config.background_audio){ game.playAudio('effect','damage'+(num>1?'2':'')); } },num); 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); game.broadcastAll(function(nature,player){ if(lib.config.animation&&!lib.config.low_performance){ if(nature=='fire'){ player.$fire(); } else if(nature=='thunder'){ player.$thunder(); } } },event.nature,player); 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'); } game.broadcast(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.broadcast(function(){ 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){ player.$throw(event.cards,1000); game.log(player,'弃置了',event.cards); } if(!game.reserveDead){ for(var mark in player.marks){ player.unmarkSkill(mark); } while(player.node.marks.childNodes.length){ player.node.marks.firstChild.remove(); } game.broadcast(function(player){ while(player.node.marks.childNodes.length){ player.node.marks.firstChild.remove(); } },player); } for(var i in player.tempSkills){ player.skills.remove(i); delete player.tempSkills[i]; } game.broadcastAll(function(player,cards){ player.classList.add('dead'); // player.classList.remove('linked'); player.classList.remove('turnedover'); player.classList.remove('out'); player.node.count.innerHTML='0'; player.node.hp.hide(); player.node.equips.hide(); player.node.count.hide(); player.previous.next=player.next; player.next.previous=player.previous; game.players.remove(player); game.dead.push(player); 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]); game.broadcastAll(function(player,card,str,id,cardid){ var event; if(game.online){ event={}; } else{ event=_status.event; } if(lib.config.mode=='chess'){ event.node=card.copy('thrown','center',ui.arena).animate('start'); } else{ event.node=player.$throwordered(card.copy(),true); } if(lib.cardOL) lib.cardOL[cardid]=event.node; event.node.cardid=cardid; event.node.classList.add('thrownhighlight'); ui.arena.classList.add('thrownhighlight'); event.dialog=ui.create.dialog(str); event.dialog.classList.add('center'); event.dialog.videoId=id; },player,player.judging[0],judgestr,event.videoId,get.id()); 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){ game.broadcastAll(ui.clear); } game.broadcast(function(id){ var dialog=get.idDialog(id); if(dialog){ dialog.close(); } ui.arena.classList.remove('thrownhighlight'); },event.videoId); 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.broadcast(function(player){ player.classList.toggle('turnedover'); },player); 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'); } game.broadcast(function(){ if(lib.config.background_audio){ game.playAudio('effect','link'); } }); player.classList.remove('target'); player.classList.toggle('linked'); game.broadcast(function(player){ player.classList.remove('target'); player.classList.toggle('linked'); },player); 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]; if(!info){ info=['','',1,[],[]]; } if(!info[4]){ info[4]=[]; } 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]; if(!info2){ info2=['','',1,[],[]]; } if(!info2[4]){ info2[4]=[]; } 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'+str+''); dialog.classList.add('popped'); ui.window.appendChild(dialog); var width=dialog.content.firstChild.firstChild.offsetWidth; if(width<190){ dialog._mod_height=-16; } else{ dialog.content.firstChild.style.textAlign='left'; } dialog.style.width=(width+16)+'px'; var refnode; if(this.node&&this.node.avatar&&this.parentNode==ui.arena){ refnode=this.node.avatar; } if(refnode){ lib.placePoppedDialog(dialog,{ clientX:ui.arena.offsetLeft+this.offsetLeft+refnode.offsetLeft+refnode.offsetWidth/2, clientY:ui.arena.offsetTop+this.offsetTop+refnode.offsetTop+refnode.offsetHeight/4 }); } else{ lib.placePoppedDialog(dialog,{ clientX:this.offsetLeft+this.offsetWidth/2, clientY:this.offsetTop+this.offsetHeight/4 }); } if(dialog._mod_height){ dialog.content.firstChild.style.padding=0; } setTimeout(function(){ dialog.delete(); },2000); var info=[get.translation(this.name)||this.nickname,str]; lib.chatHistory.push(info); if(_status.addChatEntry){ if(_status.addChatEntry._origin.parentNode){ _status.addChatEntry(info,false); } else{ delete _status.addChatEntry; } } }, getState:function(){ return { hp:this.hp, maxHp:this.maxHp, nickname:this.nickname, name:this.name, name2:this.name2, handcards:this.get('h'), equips:this.get('e'), judges:this.get('j'), position:parseInt(this.dataset.position), hujia:this.hujia, identityShown:this.identityShown, identityNode:[this.node.identity.innerHTML,this.node.identity.dataset.color], identity:this.identity, dead:this.isDead(), linked:this.isLinked(), turnedover:this.isTurnedOver(), } }, setNickname:function(str){ this.node.nameol.innerHTML=str||this.nickname||''; return this; }, update:function(){ if(_status.video&&arguments.length==0) return; if(this.hp>=this.maxHp) this.hp=this.maxHp; var hp=this.node.hp; hp.style.transition='none'; game.broadcast(function(player,hp,maxHp,hujia){ player.hp=hp; player.maxHp=maxHp; player.hujia=hujia; player.update(); },this,this.hp,this.maxHp,this.hujia); 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&&get.objtype(arguments[0])=='object'){ 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; next._args=Array.from(arguments); 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.getParent(); 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; next._args=Array.from(arguments); return next; }, chooseCardButton:function(){ var cards,prompt,forced,select; for(var i=0;i0) return -val; return val; }; next.content=lib.element.playerproto.choosePlayerCard; next._args=Array.from(arguments); 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; next._args=Array.from(arguments); 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; next._args=Array.from(arguments); return next; }, showHandcards:function(){ var next=game.createEvent('showHandcards'); next.player=this; next.content=lib.element.playerproto.showHandcards; next._args=Array.from(arguments); return next; }, 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; next._args=Array.from(arguments); }, viewHandcards:function(target){ var next=game.createEvent('viewHandcards'); next.player=this; next.target=target; next.content=lib.element.playerproto.viewHandcards; next._args=Array.from(arguments); return next; }, useResult:function(result,event){ event=event||_status.event; if(result._sendskill){ lib.skill[result._sendskill[0]]=result._sendskill[1]; } if(event.onresult){ event.onresult(result); } if(result.skill){ var info=get.info(result.skill); if(info.onuse){ info.onuse(result,this); } if(info.direct){ _status.noclearcountdown=true; } } if(event.logSkill){ if(typeof event.logSkill=='string'){ this.logSkill(event.logSkill); } else if(Array.isArray(event.logSkill)){ this.logSkill.apply(this,event.logSkill); } } if(result.card||!result.skill){ this.useCard(result.card,result.cards,result.targets,result.skill); } else if(result.skill){ this.useSkill(result.skill,result.cards,result.targets); } }, 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(); } game.broadcast(function(player,cards){ player.directgain(cards); },this,cards); 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); } } }, showTimer:function(time){ if(!time&&lib.configOL){ time=parseInt(lib.configOL.choose_timeout)*1000; } if(_status.connectMode&&!game.online){ game.broadcast(function(player,time){ player.showTimer(time); },this,time); } if(this==game.me){ return; } if(this.node.timer){ this.node.timer.remove(); } var timer=ui.create.div('.timerbar',this); this.node.timer=timer; ui.create.div(this.node.timer); var bar=ui.create.div(this.node.timer); ui.refresh(bar); bar.style.transitionDuration=(time/1000)+'s'; bar.style.width=0; }, hideTimer:function(){ if(_status.connectMode&&!game.online){ game.broadcast(function(player){ player.hideTimer(); },this); } if(this.node.timer){ this.node.timer.delete(); delete this.node.timer; } }, markSkill:function(name,info,card){ if(get.itemtype(card)=='card'){ game.addVideo('markSkill',this,[name,get.cardInfo(card)]); } else{ game.addVideo('markSkill',this,[name]); } game.broadcastAll(function(storage,player,name,info,card){ player.storage[name]=storage; if(!info){ if(player.marks[name]){ player.updateMarks(); return; } if(lib.skill[name]){ info=lib.skill[name].intro; } if(!info){ return; } } if(player.marks[name]){ player.marks[name].info=info; } else{ if(card){ player.marks[name]=player.mark(card,info,name); } else{ player.marks[name]=player.mark(name,info); } } player.updateMarks(); },this.storage[name],this,name,info,card); return this; }, unmarkSkill:function(name){ game.addVideo('unmarkSkill',this,name); game.broadcast(function(player,name){ if(player.marks[name]){ player.marks[name].delete(); delete player.marks[name]; } },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(id,target,name,content){ if(typeof target=='object'){ target=target.name; } game.broadcastAll(function(player,target,name,content,id){ if(player.marks[id]){ if(player.marks[id]._name==target){ return player; } player.marks[id].name=name+'_charactermark'; player.marks[id]._name=target; player.marks[id].info={ name:name, content:content }; player.marks[id].setBackground(target,'character'); game.addVideo('changeMarkCharacter',player,{ id:id, name:name, content:content, target:target }); } else{ player.marks[id]=player.markCharacter(target,{ name:name, content:content }); player.marks[id]._name=target; game.addVideo('markCharacter',player,{ name:name, content:content, id:id, target:target }); } },this,target,name,content,id); 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; }, hasWuxie:function(){ if(this.num('h','wuxie')) return true; var skills=this.get('s',true).concat(lib.skill.global); game.expandSkills(skills); 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.broadcast(function(player,target,card1,card2){ player.$compare(card1,target,card2); },this,target,card1,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){ game.broadcast(function(player,card,time,init){ player.$throw(card,time,init); },this,card,time,init); 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){ game.broadcast(function(player,card){ player.$equip(card); },this,card); card.fix(); card.style.transform=''; card.classList.remove('drawinghidden'); 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){ game.broadcast(function(player,card,init){ player.$gain(card,false,init); },this,card,init); 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,'nobroadcast'); }, $skill:function(name,type,color){ if(typeof type!='string') type='legend'; game.delay(2); this.playerfocus(1500); var that=this; setTimeout(function(){ game.broadcastAll(function(that,type,name,color){ 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); } },that,type,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.broadcast(function(player){ if(!lib.config.low_performance){ player.$coin(); } },this); 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.broadcast(function(player){ if(!lib.config.low_performance){ player.$dust(); } },this); 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.broadcast(function(player){ if(!lib.config.low_performance){ player.$recover(); } },this); 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'); }, $fullscreenpop:function(str,nature){ game.broadcast(function(player,str,nature){ player.$fullscreenpop(str,nature); },this,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]); game.broadcast(function(player,num,nature,font){ player.$damagepop(num,nature,font); },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); } game.broadcast(function(player,source){ player.$damage(source); },this,source); 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); game.broadcast(function(player){ player.$die(); },this); if(lib.config.die_flip){ this.$dieflip(); } if(lib.element.player.$dieAfter){ lib.element.player.$dieAfter.call(this); } }, $dieflip:function(){ var top0=ui.window.offsetHeight/2; var left0=ui.window.offsetWidth/2; var ratio=(left0-this.offsetLeft)/(top0-this.offsetTop); var left=Math.abs(50*ratio/Math.sqrt(1+ratio*ratio)); var top=Math.abs(50/Math.sqrt(1+ratio*ratio)); if(left0-this.offsetLeft>0) left=-left; if(top0-this.offsetTop>0) top=-top; 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 nocard=false; if(!lib.card[card[2]]){ nocard=true; lib.card[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;ibb?1:-1; } return a>b?1:-1; } }, skill:{ global:[], storage:{}, unequip:{}, mad:{ mark:true, intro:{ content:'已进入混乱状态', name:'混乱' } }, ghujia:{ intro:{ content:function(content,player){ return '已有'+get.cnNumber(player.hujia)+'点护甲值'; } } }, _recoverCheck:{ trigger:{player:'recoverBefore'}, forced:true, priority:20, popup:false, filter:function(event,player){ return player.hp>=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'); game.broadcast(function(player){ player.classList.remove('glow_phase'); },_status.currentPhase); } player.classList.add('glow_phase'); game.broadcast(function(player){ player.classList.add('glow_phase'); },player); } game.syncState(); game.addVideo('phaseChange',player); _status.currentPhase=player; game.log(); game.log(player,'的回合开始'); game.phaseNumber++; player._noVibrate=true; if(get.config('identity_mode')!='zhong'&&!_status.connectMode){ 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.isOnline()||(_status.connectMode&&player==game.me)||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,_status.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=parseInt(lib.configOL.number)){ this.send('denied','number'); lib.node.clients.remove(this); this.closed=true; } else{ if(config){ this.avatar=config.avatar; this.nickname=config.nickname; } 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){ 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 if(get.info(event.skill).direct&&player.isOnline()){ 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:{}, _set:[], } if(trigger!==false&&!game.online) 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;inum){ lib.config.recentCharacter.splice(num); } game.saveConfig('recentCharacter',lib.config.recentCharacter); }, createCard:function(name,suit,number,nature){ if(typeof name=='object'){ nature=name.nature; number=name.number; suit=name.suit; name=name.name; } if(typeof name!='string'){ name='sha'; } if(typeof suit!='string'){ suit=['heart','diamond','club','spade'].randomGet(); } else if(suit=='black'){ suit=Math.random()<0.5?'club':'spade'; } else if(suit=='red'){ suit=Math.random()<0.5?'diamond':'heart'; } if(typeof number!='number'){ number=Math.ceil(Math.random()*13); } return ui.create.card(ui.special).init([suit,number,name,nature]); }, forceOver:function(bool,callback){ _status.event.next.length=0; var next=game.createEvent('finish_game'); next.bool=bool; next.callback=callback; next.content=function(){ 'step 0' while(ui.controls.length){ ui.controls[0].close(); } while(ui.dialogs.length){ ui.dialogs[0].close(); } 'step 1' if(event.bool!='noover'){ game.over(event.bool); } if(event.callback){ event.callback(); } }; if(_status.paused){ game.uncheck(); game.resume(); } }, over:function(result){ var i,j,k,num,table,tr,td,dialog; _status.over=true; ui.control.show(); ui.clear(); game.stopCountChoose(); if(game.online){ var dialog=ui.create.dialog(); dialog.content.innerHTML=result; var result2=arguments[1]; if(result2==true){ dialog.content.firstChild.innerHTML='战斗胜利'; } else if(result2==false){ dialog.content.firstChild.innerHTML='战斗失败'; } ui.update(); if(lib.config.background_audio){ if(result2===true){ game.playAudio('effect','win'); } else if(result2===false){ game.playAudio('effect','lose'); } else{ game.playAudio('effect','tie'); } } if(!ui.exit){ ui.exit=ui.create.control('退出联机',function(){ game.saveConfig('reconnect_info'); game.reload(); }); } if(ui.tempnowuxie){ ui.tempnowuxie.close(); delete ui.tempnowuxie; } 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(!_status.connectMode&&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(); } game.broadcast(function(){ while(_status.dieClose.length){ _status.dieClose.shift().close(); } }); if(event._oncancel){ event._oncancel(); } 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(){ if(_status.connectMode) return; _status.paused2=true; }, resume:function(){ if(_status.paused){ if(!_status.noclearcountdown){ game.stopCountChoose(); } _status.paused=false; delete _status.waitingForTransition; game.loop(); } }, resume2:function(){ if(_status.connectMode) return; 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'); game.countChoose(); 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.getParent().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]; }, loadModeAsync:function(name,callback){ window.mode={}; var script=lib.init.js(lib.assetURL+'mode',name,function(){ script.remove(); var mode=window.mode; delete window.mode; callback(mode[name]); }); }, 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'; } 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); game.broadcast(function(str){ game.log(str); },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;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||'无')+'

      '; li3.innerHTML='更新源

      '; li3.querySelector('button').onclick=function(){ lib.updateURL=this.previousSibling.value; localStorage.setItem('noname_download_source',lib.updateURL); } 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; 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;i=lib.configOL.number){ player.classList.add('unselectable2'); } } var bar=ui.create.div(ui.window); bar.style.height='20px'; bar.style.width='80%'; bar.style.left='10%'; bar.style.top='calc(200% / 7 - 120px + 5px)'; bar.style.textAlign='center'; var ipbar=ui.create.div('.shadowed',ip,bar); ipbar.style.padding='4px'; ipbar.style.borderRadius='2px'; ipbar.style.position='relative'; var button=ui.create.div('.menubutton.large.highlight.connectbutton',game.online?'退出联机':'开始游戏',ui.window,function(){ if(button.clicked) return; if(game.online){ game.saveConfig('reconnect_info'); game.reload(); } else{ game.resume(); } button.delete(); bar.delete(); delete ui.connectStartButton; delete ui.connectStartBar; button.clicked=true; }); ui.connectStartButton=button; ui.connectStartBar=bar; }, players:function(num){ if(num===0){ return; } if(num==undefined) num=lib.configOL.number; if(num==undefined) num=lib.config.mode_config[lib.config.mode].player_number; if(typeof num=='string'){ num=parseInt(num); } if(!num) num=5; 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; }, chat:function(){ var uiintro=ui.create.dialog('hidden'); uiintro.listen(function(e){ e.stopPropagation(); }); // uiintro.add('
      对话记录
      '); // uiintro.add(ui.create.div('.placeholder.slim')); // uiintro.classList.add('noleave'); var list=ui.create.div('.caption'); list.style.maxHeight='350px'; list.style.overflow='scroll'; uiintro.contentContainer.style.overflow='hidden'; var input; var addEntry=function(info,clear){ if(list._chatempty){ list.innerHTML=''; delete list._chatempty; } var node=ui.create.div('.text.chat'); node.innerHTML=info[0]+': '+info[1]; list.appendChild(node); list.scrollTop=list.scrollHeight; uiintro.style.height=uiintro.content.scrollHeight+'px'; } _status.addChatEntry=addEntry; _status.addChatEntry._origin=uiintro; if(lib.chatHistory.length){ for(var i=0;i'); node.style.paddingTop=0; node.style.marginBottom='16px'; input=node.firstChild; input.style.width='calc(100% - 20px)'; input.onkeydown=function(e){ if(e.keyCode==13&&input.value){ var player=game.me; var str=input.value; if(!player){ if(game.connectPlayers){ if(game.online){ for(var i=0;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); } if(uiintro._onopen){ uiintro._onopen(); } }, 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.classList.add('glow'); if(_status.imchoosing&&_status.paused){ 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(); } if(game.online){ game.send('auto'); } } else{ ui.control.show(); _status.auto=false; ui.auto.classList.remove('glow'); if(game.online){ game.send('unauto'); } } }, wuxie:function(){ if(this.classList.contains('hidden')) return; this.classList.toggle('glow'); if(this.classList.contains('glow')&&_status.event.type=='wuxie'&& _status.event.isMine()&&ui.confirm&&_status.imchoosing){ 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.type=='wuxie'&& _status.event.isMine()&&ui.confirm&&_status.imchoosing){ 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(); } }, autoskill:function(bool,node){ var list=lib.config.autoskilllist; if(bool){ list.remove(node.link); } else{ list.add(node.link); } game.saveConfig('autoskilllist',list); }, rightplayer:function(e){ if(this._nopup) return false; if(_status.clickedplayer){ return false; } // if(this._mouseentercreated){ // this._mouseentercreated=false; // ui.click.window(); // } // else{ // ui.click.intro.call(this,e); // } if(this._mouseenterdialog&&this._mouseenterdialog.parentNode){ this._mouseenterdialog.delete(); } else{ ui.click.intro.call(this,e); } _status.clickedplayer=true; _status.clicked=false; ui.click.longpresscancel.call(this); return false; }, right:function(){ if(window.inSplash) return false; if(lib.config.touchscreen) return; if(_status.noright){ _status.noright=false; return false; } if(_status.clickedplayer){ _status.clickedplayer=false; return; } if(ui.currentpopped){ if(ui.currentpopped._uiintro){ ui.currentpopped._uiintro.delete(); delete ui.currentpopped._uiintro; } delete ui.currentpopped; } switch(lib.config.right_click){ case 'pause':ui.click.pause();break; case 'auto':ui.click.auto();break; case 'config':ui.click.config();break; } return false; } }, selected:{ buttons:[],cards:[],targets:[] }, clear:function(){ game.addVideo('uiClear'); var thrown=document.getElementsByClassName('thrown'); var nodes=[]; 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={ mode:function(){ if(_status.connectMode){ return lib.configOL.mode; } else{ return lib.config.mode; } }, idDialog:function(id){ for(var 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(lib.config.show_favourite&&lib.character[node.name]){ var addFavourite=ui.create.div('.text.center'); addFavourite.link=node.link; if(lib.config.favouriteCharacter.contains(node.name)){ addFavourite.innerHTML='移除收藏'; } else{ addFavourite.innerHTML='添加收藏'; } addFavourite.listen(ui.click.favouriteCharacter) uiintro.add(addFavourite); } 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+'
      '); } uiintro._place_text=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']+'
      '); } } if((node.parentNode.classList.contains('menu-buttons')||lib.config.show_favourite)&&lib.character[node.link]){ var addFavourite=ui.create.div('.text.center'); addFavourite.link=node.link; addFavourite.style.marginBottom='15px'; if(lib.config.favouriteCharacter.contains(node.link)){ addFavourite.innerHTML='移除收藏'; } else{ addFavourite.innerHTML='添加收藏'; } addFavourite.listen(ui.click.favouriteCharacter) uiintro.add(addFavourite); } else{ 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