"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(bool){ lib.cheat.i(); } else{ delete window.cheat; delete window.game; delete window.ui; delete window.get; delete window.ai; delete window.lib; delete window._status; } }, 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:'切换托管', chat:'显示聊天', off:'关闭', } }, swipe_up:{ name:'上划操作', init:'auto', unfrequent:true, item:{ system:'显示按钮', menu:'打开菜单', pause:'切换暂停', auto:'切换托管', chat:'显示聊天', off:'关闭', } }, swipe_left:{ name:'左划操作', init:'system', unfrequent:true, item:{ system:'显示按钮', menu:'打开菜单', pause:'切换暂停', auto:'切换托管', chat:'显示聊天', off:'关闭', } }, swipe_right:{ name:'右划操作', init:'chat', unfrequent:true, item:{ system:'显示按钮', menu:'打开菜单', pause:'切换暂停', auto:'切换托管', chat:'显示聊天', 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, }, fold_mode:{ 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:{ update:function(config,map){ if(config.connect_identity_mode=='zhong'){ map.connect_player_number.hide(); map.connect_enhance_zhu.hide(); map.connect_double_nei.hide(); } else{ map.connect_player_number.show(); map.connect_enhance_zhu.show(); if(config.connect_player_number!='2'){ map.connect_double_nei.show(); } else{ map.connect_double_nei.hide(); } } }, connect_identity_mode:{ name:'游戏模式', init:'normal', item:{ normal:'普通', zhong:'明忠' }, restart:true, frequent:true, }, connect_player_number:{ name:'游戏人数', init:'8', item:{ '2':'两人', '3':'三人', '4':'四人', '5':'五人', '6':'六人', '7':'七人', '8':'八人' }, frequent:true, restart:true, }, connect_double_nei:{ name:'双内奸', init:false, restart:true, frequent:true, }, connect_double_character:{ name:'双将模式', init:false, frequent:true, restart:true, }, connect_ban_weak:{ name:'屏蔽弱将', init:true, restart:true, }, connect_ban_strong:{ name:'屏蔽强将', init:false, restart:true, }, connect_enhance_zhu:{ name:'加强主公', init:false, restart:true, }, }, config:{ update:function(config,map){ 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, }, player_number:{ name:'游戏人数', init:'8', item:{ '2':'两人', '3':'三人', '4':'四人', '5':'五人', '6':'六人', '7':'七人', '8':'八人' }, frequent:true, restart:true, }, double_nei:{ name:'双内奸', init:false, restart:true, frequent:true, }, double_character:{ name:'双将模式', init:false, frequent:true, restart:true, }, double_hp:{ name:'双将体力上限', init:'pingjun', item:{ hejiansan:'和减三', pingjun:'平均值', zuidazhi:'最大值', zuixiaozhi:'最小值', zonghe:'相加', }, restart: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:true, restart:true, }, ban_strong:{ name:'屏蔽强将', init:false, restart:true, }, enhance_zhu:{ 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: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:'国战', connect:{ connect_player_number:{ name:'游戏人数', init:'8', item:{ '3':'三人', '4':'四人', '5':'五人', '6':'六人', '7':'七人', '8':'八人' }, frequent:true, restart:true, }, connect_initshow_draw:{ name:'首亮摸牌', item:{ '0':'关闭', '1':'一张', '2':'两张', '3':'三张', }, init:'2', frequent:true, }, connect_zhulian:{ name:'珠联璧合', init:true, frequent:true, }, connect_ban_weak:{ name:'屏蔽弱将', init:false, restart:true, }, connect_ban_strong:{ name:'屏蔽强将', init:false, restart:true, }, }, 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:true, 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:'对决', connect:{ update:function(config,map){ if(config.connect_versus_mode=='1v1'){ map.connect_choice_num.show(); map.connect_replace_number.show(); } else{ map.connect_choice_num.hide(); map.connect_replace_number.hide(); } if(config.connect_versus_mode=='2v2'||config.connect_versus_mode=='3v3'){ map.connect_replace_handcard.show(); } else{ map.connect_replace_handcard.hide(); } }, connect_versus_mode:{ name:'游戏模式', init:'1v1', item:{ '1v1':'1v1', '2v2':'2v2', '3v3':'3v3', '4v4':'4v4', }, frequent:true }, connect_replace_handcard:{ name:'末位可换牌', init:true, frequent:true, }, connect_choice_num:{ name:'侯选武将数', init:'20', frequent:true, item:{ '12':'12人', '16':'16人', '20':'20人', '24':'24人', '40':'40人', } }, connect_replace_number:{ name:'替补人数', init:'2', frequent:true, item:{ '0':'无', '1':'1人', '2':'2人', '3':'3人', '4':'4人', '5':'5人', } }, connect_ban_weak:{ name:'屏蔽弱将', init:true, restart:true, }, connect_ban_strong:{ name:'屏蔽强将', init:false, restart:true, }, }, 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:true, restart:true, }, ban_strong:{ name:'屏蔽强将', init:false, restart:true, }, } }, connect:{ name:'联机', config:{ connect_nickname:{ name:'联机昵称', input:true, frequent:true, }, connect_avatar:{ name:'联机头像', init:'caocao', item:{}, frequent:true, onclick:function(item){ game.saveConfig('connect_avatar',item); game.saveConfig('connect_avatar',item,'connect'); } }, hall_ip:{ name:'联机大厅', input:true, frequent:true, }, hall_button:{ name:'联机大厅按钮', init:true, frequent:true, onclick:function(bool){ game.saveConfig('hall_button',bool,'connect'); if(ui.hall_button){ if(bool){ ui.hall_button.style.display=''; } else{ ui.hall_button.style.display='none'; } } } }, } }, 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:true, restart:true, }, ban_strong:{ name:'屏蔽强将', init:false, restart: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); game.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', frequent:true, item:{ '0':'关闭', '0.1':'较少出现', '0.2':'偶尔出现', '0.333':'时常出现', '0.5':'频繁出现', } }, chess_obstacle:{ name:'随机路障', init:'0.2', 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:true, restart:true, }, ban_strong:{ name:'屏蔽强将', init:false, restart:true, }, chessscroll_speed:{ name:'边缘滚动速度', init:'20', item:{ '0':'不滚动', '10':'10格/秒', '20':'20格/秒', '30':'30格/秒', } }, } }, story:{ name:'剧情', config:{ save:{ name:'选择历程', init:'save1', item:{ save1:'一', save2:'二', save3:'三', save4:'四', save5:'五', }, restart:true, frequent:true, }, clear:{ name:'清除进度', onclick:function(){ var node=this; if(node._clearing){ game.save(get.config('save'),null); game.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, }, chessscroll_speed:{ name:'边缘滚动速度', init:'20', item:{ '0':'不滚动', '10':'10格/秒', '20':'20格/秒', '30':'30格/秒', } }, } }, realtime:{ name:'即时', config:{ } }, 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:true, restart:true, }, ban_strong:{ name:'屏蔽强将', init:false, restart:true, }, } }, }, status:{ running:false, canvas:false, time:0, delayed:0, frameId:0, videoId:0, }, help:{ '游戏选项':'
  • 控制台命令
    开启后可用浏览器控制台控制游戏
  • 编辑牌堆
    在卡牌包中修改牌堆后,将自动创建一个临时牌堆,在所有模式中共用,当保存当前牌堆后,临时牌堆被清除。每个模式可设置不同的已保存牌堆,设置的牌堆优先级大于临时牌堆。
  • 自动确认
    开启后当候选目标仅有1个时点击目标无需再点击确定
  • '+ '触屏模式
    可消除iOS等设备上300ms的点击延迟,但开启后无法使用鼠标
  • 滚轮控制手牌
    开启后滚轮可控制手牌的左右滚动,建议Mac等具备横向滚动功能的设备关闭此选项'+ '
  • 游戏玩法
    为游戏增加不同玩法,开启后可在帮助中查看介绍', '游戏操作':'
    • 长按/鼠标悬停/右键单击(需在设置中开启)显示信息
    • 触屏模式中,双指点击切换暂停;下划显示菜单,上划切换托管
    • 键盘快捷键
      '+ '
      a切换托管
      w切换不询问无懈
      暂停', '游戏命令':'
      变量名
      • 场上角色
        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')&&!game.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]); } } var connectCharacterPack=[]; var connectCardPack=[]; for(i in character){ if(character[i].character){ lib.characterPack[i]=character[i].character } for(j in character[i]){ if(j=='mode'||j=='forbid') continue; if(j=='connect'){ connectCharacterPack.push(i); continue; } if(j=='character'&&!lib.config.characters.contains(i)&&lib.config.mode!='connect'){ 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)&&lib.config.mode!='connect'){ 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; } }, cheat:{ i:function(){ window.cheat=lib.cheat; window.game=game; window.ui=ui; window.get=get; window.ai=ai; window.lib=lib; window._status=_status; }, uy:function(me){ if(me){ game.me.useCard({name:'spell_yexinglanghun'},game.me); } else{ var enemy=game.me.getEnemy(); enemy.useCard({name:'spell_yexinglanghun'},enemy); } }, gs:function(name,act){ var card=game.createCard('spell_'+name); game.me.node.handcards1.appendChild(card); if(!act){ game.me.actused=-99; } ui.updatehl(); setTimeout(game.check,300); }, gc:function(name,act){ var card=game.createCard('stone_'+name+'_stonecharacter'); game.me.node.handcards1.appendChild(card); if(!act){ game.me.actused=-99; } ui.updatehl(); setTimeout(game.check,300); }, aa:function(){ game.saveConfig('test_game',!lib.config.test_game); game.reload(); }, a:function(name){ if(lib.storage.test&&!name){ game.save('test',false); if(lib.config.mode=='identity'){ game.saveConfig('double_character',false,true); } } else{ game.save('test',name||true); if(lib.config.mode=='identity'){ game.saveConfig('double_character',true,true); } } game.reload(); }, u:function(){ var card={name:'sha'},source=game.me.next; for(var i=0;i0&&typeof arguments[i]=='number'){ for(var j=0;j0){ 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" var skills=player.get('s'); game.expandSkills(skills); for(var i=0;i0){ 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;}); next.set('selectButton',info.chooseButton.select||1); 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&&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(Array.isArray(event.dialog)){ event.dialog=ui.create.dialog.apply(this,event.dialog); event.dialog.open(); event.dialog.classList.add('noselect'); } else 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&&!game.online){ 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) 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'){ if(event.processAI){ event.result=event.processAI(); } else{ 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' ui.arena.classList.add('markhidden'); 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){ event.discardid=lib.status.videoId++; game.broadcastAll(function(player,cards,id){ player.$throw(cards,null,'nobroadcast'); var cardnodes=[]; cardnodes._discardtime=get.time(); for(var i=0;i1||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,num){ player.directgain(cards); _status.cardPileNum=num; },player,cards,ui.cardPile.childNodes.length); }; 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(); } _status.cardPileNum=num; },player,cards,ui.cardPile.childNodes.length); 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(game.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; } } }, showGiveup:function(){ if(this==game.me){ ui.create.giveup(); } else if(this.isOnline2()){ this.send(ui.create.giveup); } }, applySkills:function(skills){ for(var i in skills){ if(i=='global'){ lib.skill.global=skills[i]; } else if(i=='skillinfo'){ for(var j in skills[i]){ if(!lib.skill[j]){ lib.skill[j]={}; } lib.skill[j].chooseButton=skills[i][j]; } } else if(i=='stat'){ this.stat=[skills.stat]; } else if(lib.playerOL[i]){ for(var j in skills[i]){ lib.playerOL[i][j]=skills[i][j]; } } } }, getState:function(){ var state={ hp:this.hp, maxHp:this.maxHp, nickname:this.nickname, sex:this.sex, name:this.name, name1:this.name1, name2:this.name2, handcards:this.get('h'), equips:this.get('e'), judges:this.get('j'), position:parseInt(this.dataset.position), hujia:this.hujia, side:this.side, 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(), } if(this.getModeState){ state.mode=this.getModeState(); } return state; }, 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&&this.playerid){ 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;i=ui.chessContainer.offsetHeight){ dy=10; } else{ dy=0; } } else if(rect.left+rect.width+80>=ui.chessContainer.offsetWidth){ dx=10; if(rect.top<=80){ dy=-10; } else if(rect.top+rect.height+80>=ui.chessContainer.offsetHeight){ dy=10; } else{ dy=0; } } else if(rect.top<=80){ dx=0; dy=-10; } else if(rect.top+rect.height+80>=ui.chessContainer.offsetHeight){ dx=0; dy=10; } else{ dx=rect.left+this.offsetWidth/2-ui.arena.offsetWidth/2; dy=rect.top+this.offsetHeight/2-ui.arena.offsetHeight/2; } var coeff=240/Math.sqrt(dx*dx+dy*dy); dx*=coeff; dy*=coeff; node.style.left=(this.offsetLeft+this.offsetWidth/2-52-dx)+'px'; node.style.top=(this.offsetTop+this.offsetHeight/2-52-dy)+'px'; this.parentNode.appendChild(node); } else{ this.parentNode.appendChild(node); node.style.left='calc(50% - 52px)'; node.style.top='calc(50% - 52px)'; dx=this.offsetLeft+this.offsetWidth/2-52-node.offsetLeft; dy=this.offsetTop+this.offsetHeight/2-52-node.offsetTop; } node.style.transitionDuration='0.8s'; ui.refresh(node); if(typeof num=='number'&&init!==false){ config={ total:num, current:1 } } if(config&&config.total>1){ 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){ if(init!=='nobroadcast'){ 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(game.chess){ this.chessFocus(); } 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(game.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(game.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(game.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(game.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(game.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(game.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(game.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:{ open:function(){ ui.control.insertBefore(this,_status.createControl||ui.confirm); ui.controls.unshift(this); if(this.childNodes.length){ this.style.transition='opacity 0.5s'; ui.refresh(this); this.style.transform='translateX(-'+(control.offsetWidth/2)+'px)'; this.style.opacity=1; ui.refresh(this); this.style.transition=''; } ui.updatec(); return this; }, 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'); if(typeof node.parentNode._offset=='number'){ node.parentNode.style.transform='translateX('+node.parentNode._offset+'px) scale(0.97)'; } }); node.addEventListener(lib.config.touchscreen?'touchend':'mouseup',function(){ if(typeof node.parentNode._offset=='number'){ node.parentNode.style.transform='translateX('+node.parentNode._offset+'px)'; } node.classList.remove('controlthundertext'); node.parentNode.classList.remove('controlpressdown'); node.parentNode.classList.remove('controlpressdownx'); }); node.addEventListener(lib.config.touchscreen?'touchmove':'mousemove',function(){ if(typeof node.parentNode._offset=='number'){ node.parentNode.style.transform='translateX('+node.parentNode._offset+'px)'; } 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(){ while(ui.dialogs.length){ ui.dialogs[0].close(); } 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); } _status.currentPhase=player; game.syncState(); game.addVideo('phaseChange',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:{}}); }, }, _discard:{ trigger:{global:'discardAfter'}, forced:true, popup:false, priority:-100, filter:function(event){ return ui.todiscard[event.discardid]?true:false; }, content:function(){ game.broadcastAll(function(id){ var todiscard=ui.todiscard[id]; delete ui.todiscard[id]; if(todiscard){ var time=1000; if(typeof todiscard._discardtime=='number'){ time+=todiscard._discardtime-get.time(); } if(time<0){ time=0; } setTimeout(function(){ for(var i=0;i0) 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,event){ event=event||_status.event; var mod=game.checkMod(card,player,'unchanged','cardSavable',player.get('s')); if(mod!='unchanged') return mod; var savable=get.info(card).savable; if(typeof savable=='function') savable=savable(card,player,event.dying); return savable; }, filterTarget:trigger.player, prompt:str, ai1:function(){return 1;}, ai2:ai.get.effect, type:'dying', targetRequired:true, dying:event.dying }); } else{ event._result={bool:false} } "step 2" if(result.bool){ if(trigger.player.hp<=0&&trigger.player.isAlive()&&!trigger.player.isOut()&&!trigger.player.removed) event.goto(0); else trigger.untrigger(); } else{ for(var i=0;i<20;i++){ if(event.player.next!=trigger.start){ event.player=event.player.next; if(!event.player.isOut()){ event.goto(1); break; } } else{ break; } } } } }, _ismin:{ mod:{ cardEnabled:function(card,player){ if(player.isMin()){ if(get.type(card)=='equip') return false; } } } }, _chongzhu:{ enable:'phaseUse', prompt:'将要重铸的牌置于弃牌堆并摸一张牌', filter:function(event,player){ if(player.isMin()&&lib.config.mode=='stone') return false; return (player.get('h',function(card){ return get.info(card).chongzhu; }).length); }, filterCard:function(card){ return get.info(card).chongzhu; }, prepare:function(cards,player){ player.$throw(cards,1000); }, check:function(card){ if(get.type(card)=='stonecharacter'&&_status.event.player.num('h',{type:'stonecharacter'})<=1){ return 0; } return 1; }, discard:false, delay:0.5, content:function(){ "step 0" if(lib.config.mode=='stone'&&_status.mode=='deck'&& !player.isMin()&&get.type(cards[0]).indexOf('stone')==0){ var list=get.stonecard(1,player.career); if(list.length){ player.gain(game.createCard(list.randomGet()),'draw'); } else{ player.draw({drawDeck:1}) } } else{ player.draw(); } "step 1" 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=3){ more_room=true; } ui.rooms[i].initRoom(list[i],list2[i]); } // if(!more_room){ // if(list[0]&&list[1]&&list[2]){ // more_room=true; // } // else if(list[0]=='server'||list[1]=='server'||list2=='server'){ // more_room=true; // } // } if(more_room){ ui.window.classList.add('more_room'); } else{ ui.window.classList.remove('more_room'); } } }, init:function(id,config,ip,servermode,roomId){ game.online=true; game.onlineID=id; game.ip=ip; game.servermode=servermode; game.roomId=roomId; if(game.servermode){ game.saveConfig('reconnect_info',[_status.ip,id,game.roomId]); } else{ game.saveConfig('reconnect_info',[_status.ip,id]); } lib.config.recentIP.remove(_status.ip); lib.config.recentIP.unshift(_status.ip); lib.config.recentIP.splice(5); game.saveConfig('recentIP',lib.config.recentIP); _status.connectMode=true; lib.configOL=config; lib.playerOL={}; lib.cardOL={}; game.clearArena(); game.finishCards(); ui.create.roomInfo(); ui.create.chat(); if(game.servermode){ ui.create.connectPlayers(get.modetrans(config,true)); } else{ ui.create.connectPlayers(ip); } ui.pause.hide(); ui.auto.hide(); game.clearConnect(); clearTimeout(_status.createNodeTimeout); var proceed=function(){ game.loadModeAsync(config.mode,function(mode){ for(var i in mode.ai){ if(typeof mode.ai[i]=='object'){ if(ai[i]==undefined) ai[i]={}; for(j in mode.ai[i]){ ai[i][j]=lib.init.eval(mode.ai[i][j]); } } else{ ai[i]=lib.init.eval(mode.ai[i]); } } for(var i in mode.translate){ lib.translate[i]=mode.translate[i]; } if(mode.game){ game.getIdentityList=lib.init.eval(mode.game.getIdentityList); game.updateState=lib.init.eval(mode.game.updateState); game.getRoomInfo=lib.init.eval(mode.game.getRoomInfo); } if(mode.element&&mode.element.player){ for(var i in mode.element.player){ lib.element.player[i]=lib.init.eval(mode.element.player[i]); } } if(mode.skill){ for(var i in mode.skill){ lib.skill[i]=lib.init.eval(mode.skill[i]); } } _status.event={ finished:true, next:[], }; _status.paused=false; game.createEvent('game',false).content=lib.init.startOnline; game.loop(); game.send('inited'); }); } if(_status.event.getParent()){ game.forceOver('noover',proceed); } else{ proceed(); } for(var i in lib.characterPack){ for(var j in lib.characterPack[i]){ lib.character[j]=lib.character[j]||lib.characterPack[i][j]; } } }, reinit:function(config,state,state2,ip,observe,onreconnect){ ui.auto.show(); ui.pause.show(); game.clearConnect(); clearTimeout(_status.createNodeTimeout); game.online=true; game.ip=ip; game.servermode=state.servermode; game.roomId=state.roomId; if(observe){ game.onlineID=null; game.roomId=null; } if(game.servermode&&!observe){ game.saveConfig('reconnect_info',[_status.ip,game.onlineID,game.roomId]); } else{ game.saveConfig('reconnect_info',[_status.ip,game.onlineID]); } _status.connectMode=true; lib.configOL=config; lib.playerOL={}; lib.cardOL={}; game.loadModeAsync(config.mode,function(mode){ for(var i in mode.ai){ if(typeof mode.ai[i]=='object'){ if(ai[i]==undefined) ai[i]={}; for(j in mode.ai[i]){ ai[i][j]=lib.init.eval(mode.ai[i][j]); } } else{ ai[i]=lib.init.eval(mode.ai[i]); } } for(var i in mode.translate){ lib.translate[i]=mode.translate[i]; } if(mode.game){ game.getIdentityList=lib.init.eval(mode.game.getIdentityList); game.updateState=lib.init.eval(mode.game.updateState); } if(mode.element&&mode.element.player){ for(var i in mode.element.player){ lib.element.player[i]=lib.init.eval(mode.element.player[i]); } } if(mode.skill){ for(var i in mode.skill){ lib.skill[i]=lib.init.eval(mode.skill[i]); } } state=get.parsedResult(state); game.players=[]; game.dead=[]; for(var i in lib.characterPack){ for(var j in lib.characterPack[i]){ lib.character[j]=lib.character[j]||lib.characterPack[i][j]; } } game.clearArena(); game.finishCards(); if(!observe){ ui.create.chat(); if(ui.exitroom){ ui.exitroom.remove(); delete ui.exitroom; } } else{ if(!ui.exitroom){ ui.create.system('退出旁观',function(){ game.saveConfig('reconnect_info'); game.reload(); },true); } } ui.arena.dataset.number=state.number; _status.mode=state.mode; var pos=state.players[observe||game.onlineID].position; for(var i in state.players){ var info=state.players[i]; var player=ui.create.player(ui.arena).animate('start'); player.dataset.position=(info.position|\|/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(game.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]&&game.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)){ if(!get.info(event.skill).direct){ event.trigger('triggerHidden'); } else{ event.skillHidden=true; } } } "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; next.skillHidden=event.skillHidden; 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){ if(_status.over) return; 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('退出联机',ui.click.exit); } if(game.servermode){ ui.exit.firstChild.innerHTML='返回房间'; setTimeout(function(){ ui.exit.firstChild.innerHTML='退出房间'; _status.roomtimeout=true; lib.config.reconnect_info[2]=null; game.saveConfig('reconnect_info',lib.config.reconnect_info); },10000); } if(ui.tempnowuxie){ ui.tempnowuxie.close(); delete ui.tempnowuxie; } if(game.getIdentityList){ 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&&!_status.connectMode){ 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(game.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]); }); }, switchMode:function(name,configx){ window.mode={}; var script=lib.init.js(lib.assetURL+'mode',name,function(){ script.remove(); var mode=window.mode; delete window.mode; lib.config.mode=name; 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]); } 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')||[]; 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]); } } var pilecfg=lib.config.customcardpile[get.config('cardpilename')]; if(pilecfg){ lib.config.bannedpile=pilecfg[0]||{}; lib.config.addedpile=pilecfg[1]||{}; } try{ lib.storage=JSON.parse(localStorage.getItem(lib.configprefix+lib.config.mode)); if(typeof lib.storage!='object') throw('err'); if(lib.storage==null) throw('err'); } catch(err){ lib.storage={}; localStorage.setItem(lib.configprefix+lib.config.mode,"{}"); } _status.event={ finished:true, next:[], }; _status.paused=false; if(_status.connectMode&&lib.mode[name].connect){ game.saveConfig('connect_mode',name); game.clearConnect(); lib.configOL.mode=name; if(configx){ for(var i in configx){ lib.configOL[i]=configx[i]; } } else{ for(var i in lib.mode[name].connect){ if(i=='update') continue; lib.configOL[i.slice(8)]=get.config(i); } lib.configOL.characterPack=lib.connectCharacterPack.slice(0); lib.configOL.cardPack=lib.connectCardPack.slice(0); 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'&&!game.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_update_url',lib.updateURL); } var button1,button2; var span1,includeskin; game.checkForUpdate=function(forcecheck){ if(button1.disabled){ return; } else if(!game.download){ alert('此版本不支持游戏内更新,请手动更新'); 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;iposition2){ position.insertBefore(node,position.childNodes[position2]); } else{ position.appendChild(node); } } return node; }, giveup:function(){ if(ui.giveup) return; ui.giveup=ui.create.system('投降',function(){ var player=game.me; this.remove(); if(game.online){ game.send('giveup',player); } else{ game.log(player,'投降'); player.popup('投降'); setTimeout(function(){ player.die('nosource'); },1000); } if(_status.paused&&_status.imchoosing&&!_status.auto){ ui.click.auto(); } },true); }, groupControl:function(dialog){ return ui.create.control('wei','shu','wu','qun',function(link,node){ if(link=='全部'){ dialog.currentcapt=''; dialog.currentgroup=''; for(var i=0;ib?1:-1; }); if(!thisiscard){ namecapt.remove('自创'); namecapt.push('newline'); for(var i in lib.characterDialogGroup){ namecapt.push(i); } namecapt.push('自创'); } var newlined=false; var clickCapt=function(e){ if(_status.dragged) return; if(this.classList.contains('thundertext')){ dialog.currentcapt=null; dialog.currentcaptnode=null; this.classList.remove('thundertext'); for(var i=0;ib?1:-1; } return aa>bb?1:-1; }); dialog=ui.create.dialog('hidden'); dialog.classList.add('noupdate'); dialog.classList.add('scroll1'); dialog.classList.add('scroll2'); dialog.getCurrentCapt=function(link,capt){ if(lib.characterDialogGroup[this.currentcapt]){ return lib.characterDialogGroup[this.currentcapt](link,capt); } return this.currentcapt; } if(str){ dialog.add(str); } dialog.add(node); if(thisiscard){ if(seperate){ seperate=seperate(list); dialog.seperate=[]; for(var i in seperate){ var link=''; var linkcontent=seperate[i]; if(i.indexOf('_link:')!=-1){ link=i.slice(i.indexOf('_link:')+6); i=i.slice(0,i.indexOf('_link:')); } var nodesep=dialog.add(i); nodesep.link=link; dialog.seperate.push(nodesep); dialog.add([linkcontent,'vcard'],noclick); } } else{ dialog.add([list,'vcard'],noclick); } } else{ dialog.add([list,'character'],noclick); } dialog.add(ui.create.div('.placeholder')); for(i=0;i