"use strict"; (function(){ var _status={ paused:false, paused2:false, over:false, clicked:false, auto:false, event:{ finished:true, next:[], }, ai:{}, lastdragchange:[], skillaudio:[], dieClose:[], dragline:[], }; var lib={ configprefix:'noname_0.9_', versionOL:20, sourceURL:'https://rawgit.com/libccy/noname/$version$/', updateURL:'https://raw.githubusercontent.com/libccy/noname/$version$/', assetURL:'', hallURL:'websha.cn', changeLog:[], updates:[], canvasUpdates:[], video:[], _onDB:[], skilllist:[], characterIntro:{}, characterPack:{}, cardPack:{}, onresize:[], onphase:[], onwash:[], onover:[], chatHistory:[], arenaReady:[], inpile:[], extensions:[], extensionPack:{}, cardType:{}, hook:{globaltrigger:{},globalskill:{}}, hookmap:{}, layoutfixed:['chess','stone'], characterDialogGroup:{ '收藏':function(name,capt){ return lib.config.favouriteCharacter.contains(name)?capt:null; }, '最近':function(name,capt){ var list=get.config('recentCharacter')||[]; return list.contains(name)?capt:null; } }, onDB:function(func){ if(lib.db){ func(); } else{ lib._onDB.push(func); } }, listenEnd:function(node){ if(!node._listeningEnd){ node._listeningEnd=true; node.listenTransition(function(){ delete node._listeningEnd; if(node._onEndMoveDelete){ node.moveDelete(node._onEndMoveDelete); } else if(node._onEndDelete){ node.delete(); } node._transitionEnded=true; }); } }, configMenu:{ general:{ name:'通用', config:{ low_performance:{ name:'流畅模式', init:false, intro:'减少部分游戏特效,提高游戏速度', onclick:function(bool){ game.saveConfig('low_performance',bool); if(bool){ ui.arena.classList.add('low_performance'); } else{ ui.arena.classList.remove('low_performance'); } } }, compatiblemode:{ name:'兼容模式', init:false, intro:'提高对旧扩展的兼容性,但可能产生未知结果', onclick:function(bool){ game.saveConfig('compatiblemode',bool); setTimeout(function(){ if(lib.config.compatiblemode){ alert('开启兼容模式可防止扩展使游戏卡死并提高对旧扩展的兼容性,但对游戏速度有一定影响,若无不稳定或不兼容的扩展建议关闭'); } },500); } }, confirm_exit:{ name:'确认退出', init:false, unfrequent:true, intro:'离开游戏前弹出确认对话框', }, auto_confirm:{ name:'自动确认', init:true, unfrequent:true, intro:'当候选目标只有1个时,点击目标后无需再点击确认', }, enable_drag:{ name:'启用拖拽', init:true, intro:'按住卡牌后可将卡牌拖至目标', unfrequent:true, }, enable_dragline:{ name:'拖拽指示线', init:true, unfrequent:true, intro:'拖拽时显示虚线,可能降低游戏速度', }, enable_touchdragline:{ name:'拖拽指示线', init:false, unfrequent:true, intro:'拖拽时显示虚线,可能降低游戏速度', }, wuxie_self:{ name:'不无懈自己', init:true, intro:'自己使用的单目标普通锦囊即将生效时,不询问无懈', }, tao_enemy:{ name:'不对敌方使用桃', init:false, intro:'双方阵营明确的模式中(如对决),敌方角色濒死时不询问出桃', }, touchscreen:{ name:'触屏模式', init:false, restart:true, unfrequent:true, intro:'开启后可使触屏设备反应更快,但无法使用鼠标操作', }, swipe:{ name:'滑动手势', init:true, unfrequent:true, intro:'在非滚动区域向四个方向滑动可执行对应操作', }, swipe_down:{ name:'下划操作', init:'menu', unfrequent:true, intro:'向下滑动时执行的操作', item:{ system:'显示按钮', menu:'打开菜单', pause:'切换暂停', auto:'切换托管', chat:'显示聊天', off:'关闭', } }, swipe_up:{ name:'上划操作', intro:'向上滑动时执行的操作', init:'auto', unfrequent:true, item:{ system:'显示按钮', menu:'打开菜单', pause:'切换暂停', auto:'切换托管', chat:'显示聊天', off:'关闭', } }, swipe_left:{ name:'左划操作', intro:'向左滑动时执行的操作', init:'system', unfrequent:true, item:{ system:'显示按钮', menu:'打开菜单', pause:'切换暂停', auto:'切换托管', chat:'显示聊天', off:'关闭', } }, swipe_right:{ name:'右划操作', intro:'向右滑动时执行的操作', init:'chat', unfrequent:true, item:{ system:'显示按钮', menu:'打开菜单', pause:'切换暂停', auto:'切换托管', chat:'显示聊天', off:'关闭', } }, round_menu_func:{ name:'触屏按钮操作', intro:'点击屏幕中圆形按钮时执行的操作', init:'system', unfrequent:true, item:{ system:'显示按钮', menu:'打开菜单', // pause:'切换暂停', // auto:'切换托管' } }, show_splash:{ name:'显示开始界面', intro:'游戏开始前进入模式选择画面', init:false, }, game_speed:{ name:'游戏速度', init:'mid', item:{ vslow:'慢', slow:'较慢', mid:'中', fast:'较快', vfast:'快', vvfast:'很快', }, intro:'设置不同游戏操作间的时间间隔' }, sync_speed:{ name:'限制结算速度', intro:'在动画结算完成前不执行下一步操作,开启后游戏操作的间隔更长但画面更浏畅,在游戏较卡时建议开启', init:true }, enable_vibrate:{ name:'开启震动', intro:'回合开始时使手机震动', init:false }, right_click:{ name:'右键功能', init:'pause', intro:'在空白区域点击右键时的操作', unfrequent:true, item:{ pause:'暂停', config:'选项', auto:'托管', } }, right_info:{ name:'右键显示信息', init:true, unfrequent:true, restart:true, intro:'右键点击后弹出菜单', }, hover_all:{ name:'悬停显示信息', init:true, unfrequent:true, restart:true, intro:'悬停后弹出菜单', }, hover_handcard:{ name:'悬停手牌显示信息', init:true, unfrequent:true, intro:'悬停手牌后弹出菜单', }, hoveration:{ name:'悬停菜单弹出时间', unfrequent:true, intro:'鼠标移至目标到弹出菜单的时间间隔', init:'1000', item:{ '500':'0.5秒', '700':'0.7秒', '1000':'1秒', '1500':'1.5秒', '2500':'2.5秒', } }, video:{ name:'保存录像', init:'20', intro:'游戏结束后保存录像在最大条数,超过后将从最早的录像开始删除(已收藏的录像不计入条数)', item:{ '0':'关闭', '5':'五局', '10':'十局', '20':'二十局', '50':'五十局', '10000':'无限', }, unfrequent:true, }, mousewheel:{ name:'滚轮控制手牌', init:true, unfrequent:true, intro:'开启后滚轮可使手牌横向滚动,在mac等可横向滚动的设备上建议关闭', 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:'自动检查游戏更新', intro:'进入游戏时检查更新', init:false, unfrequent:true }, dev:{ name:'开发者模式', intro:'开启后可使用浏览器控制台控制游戏,同时可更新到开发版', init:false, onclick:function(bool){ game.saveConfig('dev',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, }, update:function(config,map){ if('ontouchstart' in document){ map.touchscreen.show(); } else{ map.touchscreen.hide(); } 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(!get.is.phoneLayout()){ map.round_menu_func.hide(); } else{ map.round_menu_func.show(); } if(!lib.node&&lib.device!='ios'){ map.confirm_exit.show(); } else{ map.confirm_exit.hide(); } } } }, 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:'默认', long:'新版', long2:'手杀', }, onclick:function(layout){ if(lib.layoutfixed.contains(lib.config.mode)){ game.saveConfig('layout',layout); } else{ lib.init.layout(layout); } } }, fewplayer:{ name:'启用人数', intro:'设置启用新版布局的最小人数(不足时切换至默认布局)', init:'3', // unfrequent:true, item:{ '2':'两人', '3':'三人', '4':'四人', '5':'五人', '6':'六人', '7':'七人', '8':'八人', }, onclick:function(item){ game.saveConfig('fewplayer',item); if(ui.arena) ui.arena.setNumber(ui.arena.dataset.number); } }, player_height:{ name:'角色高度', init:'long', // unfrequent:true, item:{ short:'矮', default:'中', long:'高', }, onclick:function(item){ game.saveConfig('player_height',item); ui.arena.dataset.player_height=item; } }, // 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':zoom=0.8;break; case 'vsmall':zoom=0.9;break; case 'small':zoom=0.95;break; case 'big':zoom=1.05;break; case 'vbig':zoom=1.1;break; case 'ebig':zoom=1.2;break; default:zoom=1; } game.documentZoom=game.deviceZoom*zoom; document.documentElement.style.zoom=game.documentZoom; } }, 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'){ document.documentElement.style.backgroundImage=''; 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=''; } }, }, phonelayout:{ name:'触屏布局', init:false, onclick:function(bool){ game.saveConfig('phonelayout',bool); if(get.is.phoneLayout()){ ui.css.phone.href=lib.assetURL+'layout/default/phone.css'; ui.arena.classList.add('phone'); } else{ ui.css.phone.href=''; ui.arena.classList.remove('phone'); } } }, change_skin:{ name:'开启换肤', init:true, intro:'双点头像或在右键菜单中换肤,皮肤可在选项-文件-图片文件-皮肤图片中添加' }, change_skin_auto:{ name:'自动换肤', init:'off', item:{ 'off':'关闭', '30000':'半分钟', '60000':'一分钟', '120000':'两分钟', '300000':'五分钟', }, intro:'游戏每进行一段时间自动为一个随机角色更换皮肤', onclick:function(item){ game.saveConfig('change_skin_auto',item); clearTimeout(_status.skintimeout); if(item!='off'){ _status.skintimeout=setTimeout(ui.click.autoskin,parseInt(item)); } } }, card_style:{ name:'卡牌样式', init:'default', intro:'设置正面朝上的卡牌的样式', 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:'卡背样式', intro:'设置背面朝上的卡牌的样式', init:'default', item:{ default:'默认', wood:'木纹', music:'音乐', official:'原版', new:'新版', feicheng:'废城', liusha:'流沙', }, 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(game.layout=='default'&&lib.config.hp_style=='official'){ ui.arena.classList.add('hpimage'); } else{ ui.arena.classList.remove('hpimage'); } }, unfrequent:true, }, show_history:{ name:'出牌记录栏', init:'off', intro:'在屏幕左侧或右侧显示出牌记录', unfrequent:true, item:{ off:'关闭', left:'靠左', right:'靠右', }, onclick:function(bool){ if(lib.config.show_history=='right') ui.window.animate('rightbar2'); game.saveConfig('show_history',bool); if(_status.video||!_status.prepareArena) return; if(bool=='left'){ ui.window.classList.add('leftbar'); ui.window.classList.remove('rightbar'); } else if(bool=='right'){ ui.window.classList.remove('leftbar'); ui.window.classList.add('rightbar'); } else{ ui.window.classList.remove('leftbar'); ui.window.classList.remove('rightbar'); } } }, show_log:{ name:'历史记录栏', init:'off', intro:'在屏幕中部显示出牌文字记录', 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=''; } } }, clear_log:{ name:'自动清除历史记录', init:false, unfrequent:true, intro:'开启后将定时清除历史记录栏的条目(而不是等记录栏满后再清除)' }, log_highlight:{ name:'历史记录高亮', init:true, unfrequent:true, intro:'开启后历史记录不同类别的信息将以不同颜色显示', }, glow_phase:{ name:'当前回合角色高亮', unfrequent:true, init:'yellow', intro:'设置当前回合角色的边框颜色', 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'); } } } }, mark_identity_style:{ name:'标记身份操作', unfrequent:true, init:'menu', item:{ menu:'菜单', click:'单击', }, }, player_border:{ name:'边框宽度', init:'normal', intro:'设置角色的边框宽度', unfrequent:true, item:{ slim:'窄', normal:'中', wide:'宽' }, onclick:function(item){ game.saveConfig('player_border',item); if(item!='wide'||game.layout=='long'||game.layout=='long2'){ ui.arena.classList.add('slim_player'); } else{ ui.arena.classList.remove('slim_player'); } if(item=='slim'){ ui.arena.classList.add('uslim_player'); } else{ ui.arena.classList.remove('uslim_player'); } } }, radius_size:{ name:'圆角大小', init:'default', item:{ off:'关闭', reduce:'减小', default:'默认', increase:'增大', }, unfrequent:true, onclick:function(item){ game.saveConfig('radius_size',item); ui.window.dataset.radius_size=item; } }, show_time:{ name:'显示时间', intro:'在屏幕顶部显示当前时间', init:false, unfrequent:true, onclick:function(bool){ game.saveConfig('show_time',bool); if(bool){ ui.time.style.display=''; } else{ ui.time.style.display='none'; } } }, show_time2:{ name:'显示时间', intro:'在触屏按钮处显示当前时间', init:true, unfrequent:true, onclick:function(bool){ game.saveConfig('show_time2',bool); if(bool){ ui.roundmenu.classList.add('clock'); } else{ ui.roundmenu.classList.remove('clock'); } } }, watchface:{ name:'表盘样式', init:'none', unfrequent:true, item:{ none:'默认', simple:'简约', }, onclick:function(item){ game.saveConfig('watchface',item); ui.roundmenu.dataset.watchface=item; } }, show_card_prompt:{ name:'显示出牌信息', intro:'出牌时在使用者上显示卡牌名称', init:true, unfrequent:true, }, hide_card_prompt_basic:{ name:'隐藏基本牌信息', intro:'不显示基本牌名称', init:false, unfrequent:true, }, hide_card_prompt_equip:{ name:'隐藏装备牌信息', intro:'不显示装备牌名称', init:false, unfrequent:true, }, show_phase_prompt:{ name:'显示阶段信息', intro:'在当前回合不同阶段开始时显示阶段名称', init:true, unfrequent:true, }, show_phaseuse_prompt:{ name:'出牌阶段提示', intro:'在你出牌时显示提示文字', init:true, unfrequent:true, }, fold_card:{ name:'折叠手牌', init:true, unfrequent:true, }, fold_mode:{ name:'折叠模式菜单', intro:'关闭后模式菜单中“更多”内的项目将直接展开', init:true, unfrequent:true, }, auto_popped_config:{ name:'自动弹出选项', intro:'鼠标移至选项按钮时弹出模式选择菜单', init:true, unfrequent:true, }, auto_popped_history:{ name:'自动弹出历史', intro:'鼠标移至暂停按钮时弹出历史记录菜单', init:false, unfrequent:true, }, remember_dialog:{ name:'记住对话框位置', intro:'移动对话框后新的对话框也将在移动后的位置显示', 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:'记住按钮位置', intro:'重新开始后触屏按钮将保存的上一局的位置', init:false, unfrequent:true, }, reset_round_button:{ name:'重置按钮位置', clear:true, unfrequent:true, onclick:function(){ ui.click.resetround(); } }, character_dialog_tool:{ name:'自由选将显示', intro:'点击自由选将时默认显示的条目', init:'最近', item:{ '收藏':'收藏', '最近':'最近', 'all':'全部' }, unfrequent:true, }, recent_character_number:{ name:'最近使用武将', intro:'自由选将对话框中最近使用武将的数量', init:'12', item:{ '6':'6', '12':'12', '20':'24', '30':'36', }, unfrequent:true }, filternode_button:{ name:'触屏筛选按钮', intro:'设置自由选将对话框中筛选按钮的样式', init:true, unfrequent:true, }, show_charactercard:{ name:'显示武将资料', intro:'在武将界面单击时弹出武将资料卡', init:true, unfrequent:true }, show_favourite:{ name:'显示添加收藏', intro:'在角色的右键菜单中显示添加收藏', init:true, unfrequent:true }, show_favourite_menu:{ name:'显示收藏菜单', intro:'在选项-武将中显示收藏一栏', init:true, unfrequent:true }, show_ban_menu:{ name:'显示禁将菜单', intro:'在选项-武将中显示禁将一栏', init:true, unfrequent:true }, right_range:{ name:'显示距离信息', intro:'在角色的右键菜单中显示距离等信息', init:true, unfrequent:true }, hide_card_image:{ name:'隐藏卡牌背景', intro:'所有卡牌将使用文字作为背景', 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, }, volumn_audio:{ name:'音效音量', init:8, item:{ '0':'〇', '1':'一', '2':'二', '3':'三', '4':'四', '5':'五', '6':'六', '7':'七', '8':'八', }, onclick:function(volume){ game.saveConfig('volumn_audio',parseInt(volume)); } }, volumn_background:{ name:'音乐音量', init:8, item:{ '0':'〇', '1':'一', '2':'二', '3':'三', '4':'四', '5':'五', '6':'六', '7':'七', '8':'八', }, onclick:function(volume){ game.saveConfig('volumn_background',parseInt(volume)); ui.backgroundMusic.volume=volume/8; } } } }, skill:{ name:'技能', config:{ update:function(config,map){ for(var i in map){ if(map[i]._link.config.type=='autoskill'){ if(!lib.config.autoskilllist.contains(i)){ map[i].classList.add('on'); ui.autoskill[i].lastChild.classList.add('on'); } else{ map[i].classList.remove('on'); ui.autoskill[i].lastChild.classList.remove('on'); } } else if(map[i]._link.config.type=='banskill'){ if(!lib.config.forbidlist.contains(i)){ map[i].classList.add('on'); } else{ map[i].classList.remove('on'); } } } } } }, others:{ name:'其它', config:{ reset_game:{ name:'重置游戏设置', onclick:function(){ var node=this; if(node._clearing){ var noname_inited=localStorage.getItem('noname_inited'); localStorage.clear(); if(noname_inited){ localStorage.setItem('noname_inited',noname_inited); } 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 }, reset_database:{ name:'重置游戏录像', onclick:function(){ var node=this; if(node._clearing){ if(indexedDB) indexedDB.deleteDatabase(lib.configprefix+'data'); 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 }, reset_hiddenpack:{ name:'重置隐藏扩展包', onclick:function(){ if(this.innerHTML!='已重置'){ this.innerHTML='已重置' game.saveConfig('hiddenModePack',[]); game.saveConfig('hiddenCharacterPack',[]); game.saveConfig('hiddenCardPack',[]); game.saveConfig('hiddenPlayPack',[]); var that=this; setTimeout(function(){ that.innerHTML='重置隐藏扩展包'; },500); } }, clear:true }, reset_tutorial:{ name:'重置新手向导', onclick:function(){ if(this.innerHTML!='已重置'){ this.innerHTML='已重置' game.saveConfig('new_tutorial',false); var that=this; setTimeout(function(){ that.innerHTML='重置新手向导'; },500); } }, clear:true }, import_data:{ name:'导入游戏设置', onclick:function(){ ui.import_data_button.classList.toggle('hidden'); }, clear:true }, import_data_button:{ name:'
'+ ''+ '
', clear:true, }, export_data:{ name:'导出游戏设置', onclick:function(){ var data={}; for(var i in localStorage){ if(i.indexOf(lib.configprefix)==0){ 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='已隐藏'; var pack=lib.config.all.cards.slice(0); if(Array.isArray(lib.config.hiddenCardPack)){ for(var i=0;igame.players.length*num&&game.showIdentity){ _status.identityShown=true; game.showIdentity(false); } }, intro:'游戏进行若干轮将自动显示所有角色的身份', }, auto_mark_identity:{ name:'自动标记身份', init:true, intro:'根据角色的出牌行为自动标记可能的身份', }, ban_weak:{ name:'屏蔽弱将', init:true, restart:true, }, ban_strong:{ name:'屏蔽强将', init:false, restart:true, }, enhance_zhu:{ name:'加强主公', init:false, restart:true, intro:'为主公增加一个额外技能' }, 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; } } }, 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(!_status.brawl||!_status.brawl.noAddSetting){ 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&&!_status.brawl){ ui.continue_game=ui.create.control('再战',game.reloadCurrent); } } else if(ui.continue_game){ ui.continue_game.close(); delete ui.continue_game; } }, intro:'游戏结束后可选择用相同的武将再进行一局游戏' }, 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; } } }, ban_identity:{ name:'屏蔽身份', init:'off', item:{ off:'关闭', zhu:'主公', zhong:'忠臣', nei:'内奸', fan:'反贼', }, }, ban_identity2:{ name:'屏蔽身份2', init:'off', item:{ off:'关闭', zhu:'主公', zhong:'忠臣', nei:'内奸', fan:'反贼', }, }, ban_identity3:{ name:'屏蔽身份3', init:'off', item:{ off:'关闭', zhu:'主公', zhong:'忠臣', nei:'内奸', fan:'反贼', }, }, 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:'仇主', }, intro:'设置内奸对主忠反的态度' }, 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:{ update:function(config,map){ if(config.connect_onlyguozhan){ map.connect_junzhu.show(); } else{ map.connect_junzhu.hide(); } }, 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, intro:'第一个明置身份牌的角色可获得摸牌奖励' }, connect_zhulian:{ name:'珠联璧合', init:true, // frequent:true, intro:'主将和副将都明置后,若为特定组合,可摸两张牌或回复一点体力' }, connect_guozhanpile:{ name:'使用国战牌堆', init:true, frequent:true, restart:true, }, connect_onlyguozhan:{ name:'使用国战武将', init:true, frequent:true, restart:true, intro:'开启后将禁用非国战专属武将' }, connect_junzhu:{ name:'替换君主', init:true, // frequent:true, restart:true, intro:'开启后将使用国战君主替换原武将牌' }, connect_ban_weak:{ name:'屏蔽弱将', init:false, restart:true, }, connect_ban_strong:{ name:'屏蔽强将', init:false, restart:true, }, }, config:{ update:function(config,map){ if(config.onlyguozhan){ map.junzhu.show(); } else{ map.junzhu.hide(); } }, 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, intro:'第一个明置身份牌的角色可获得摸牌奖励' }, zhulian:{ name:'珠联璧合', init:true, // frequent:true, intro:'主将和副将都明置后,若为特定组合,可摸两张牌或回复一点体力' }, guozhanpile:{ name:'使用国战牌堆', init:true, frequent:true, restart:true, }, onlyguozhan:{ name:'使用国战武将', init:true, frequent:true, restart:true, intro:'开启后将禁用非国战专属武将' }, junzhu:{ name:'替换君主', init:true, // frequent:true, restart:true, intro:'开启后将使用国战君主替换原武将牌' }, 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; } } }, onlyguozhanexpand:{ name:'默认展开自由选将', init:false, restart:true, intro:'开启后自由选将对话框将默认显示全部武将' }, 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(!_status.brawl||!_status.brawl.noAddSetting){ 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, intro:'游戏结束后可选择用相同的武将再进行一局游戏', onclick:function(bool){ game.saveConfig('continue_game',bool,this._link.config.mode); if(get.config('continue_game')){ if(!ui.continue_game&&_status.over&&!_status.brawl){ 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(); } if(config.connect_versus_mode=='4v4'){ map.connect_four_cross.show(); } else{ map.connect_four_cross.hide(); } }, connect_versus_mode:{ name:'游戏模式', init:'1v1', item:{ '1v1':'1v1', '2v2':'2v2', '3v3':'3v3', '4v4':'4v4', }, frequent:true }, connect_four_cross:{ name:'交叉座位', init:false, frequent:true, restart:true, }, connect_replace_handcard:{ name:'末位可换牌', init:true, frequent:true, intro:'最后行动的角色可在开局时重铸一次手牌' }, 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.ladder.show(); if(config.ladder){ map.ladder_monthly.show(); map.ladder_reset.show(); } else{ map.ladder_monthly.hide(); map.ladder_reset.hide(); } map.enable_all.show(); map.four_assign.show(); map.expand_dialog.show(); } else{ map.change_choice.show(); map.ladder.hide(); map.ladder_monthly.hide(); map.ladder_reset.hide(); map.enable_all.hide(); map.four_assign.hide(); map.expand_dialog.hide(); } if(config.versus_mode=='three'||config.versus_mode=='one'){ map.enable_all_three.show(); map.enable_all_cards.show(); } else{ map.enable_all_three.hide(); map.enable_all_cards.hide(); } if(config.versus_mode=='jiange'||config.versus_mode=='two'||config.versus_mode=='three'||config.versus_mode=='one'){ map.free_choose.show(); } else{ map.free_choose.hide(); } if(config.versus_mode=='jiange'){ map.double_character_jiange.show(); } else{ map.double_character_jiange.hide(); } if(config.versus_mode=='two'){ map.replace_handcard_two.show(); map.replace_character_two.show(); map.change_identity.show(); } else{ map.replace_handcard_two.hide(); map.replace_character_two.hide(); map.change_identity.remove(); } }, versus_mode:{ name:'游戏模式', init:'three', item:{ standard:'自由', three:'统率', jiange:'剑阁', // one:'1v1', two:'2v2', four:'4v4' }, restart:true, frequent:true, }, ladder:{ name:'天梯模式', init:true, frequent:true, restart:true }, ladder_monthly:{ name:'每月重置天梯', init:true, frequent:true, }, enable_all:{ name:'启用全部武将', init:false, frequent:true, restart:true, }, enable_all_three:{ name:'启用全部武将', init:false, frequent:true, restart:true, }, enable_all_cards:{ name:'启用全部卡牌', init:false, frequent:true, restart:true, }, four_assign:{ name:'代替队友选将', init:false, 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_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(!_status.brawl||!_status.brawl.noAddSetting){ 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; } }, frequent:true, }, double_character_jiange:{ name:'双将模式', init:false, frequent:true, }, replace_handcard_two:{ name:'末位可换牌', init:true, frequent:true, intro:'最后行动的角色可在开局时重铸一次手牌' }, replace_character_two:{ name:'替补模式', init:false, frequent:true, intro:'每个额外选择一名武将,死亡后用该武将代替重新上场,替补武将用完时失败' }, expand_dialog:{ name:'默认展开选将框', intro:'选将框打开时直接显示全部武将(可能使游戏在开始时卡顿)', init:false, }, ban_weak:{ name:'屏蔽弱将', init:true, restart:true, }, ban_strong:{ name:'屏蔽强将', init:false, restart:true }, ladder_reset:{ name:'重置天梯数据', onclick:function(){ var node=this; if(node._clearing){ game.save('ladder',{ current:900, top:900, month:(new Date()).getMonth() }); ui.ladder.innerHTML='卫士五'; clearTimeout(node._clearing); node.innerHTML='重置天梯数据'; delete node._clearing; return; } node.innerHTML='单击以确认 (3)'; node._clearing=setTimeout(function(){ node.innerHTML='单击以确认 (2)'; node._clearing=setTimeout(function(){ node.innerHTML='单击以确认 (1)'; node._clearing=setTimeout(function(){ node.innerHTML='重置天梯数据'; delete node._clearing; },1000); },1000); },1000); }, clear: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; } } }, 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=''; } } }, intro:'只控制一名角色,其他角色由AI控制' }, ban_weak:{ name:'屏蔽弱将', init:true, restart:true, }, ban_strong:{ name:'屏蔽强将', init:false, restart:true, }, } }, chess:{ name:'战棋', config:{ chess_mode:{ name:'游戏模式', init:'combat', item:{ combat:'自由', three:'统率', leader:'君主', }, 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!='leader'){ map.ban_weak.show(); map.ban_strong.show(); } else{ map.ban_weak.hide(); map.ban_strong.hide(); } }, 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, }, show_range:{ name:'显示卡牌范围', init:true, }, show_distance:{ name:'显示距离', init:true, }, chess_character:{ name:'战棋武将', init:true, frequent:true, }, chess_card:{ name:'战棋卡牌', init:true, frequent: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; } }, }, 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', intro:'鼠标移至屏幕边缘时自动滚屏', item:{ '0':'不滚动', '10':'10格/秒', '20':'20格/秒', '30':'30格/秒', } }, } }, tafang:{ name:'塔防', config:{ 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':'困难', } }, show_range:{ name:'显示卡牌范围', init:true, }, show_distance:{ name:'显示距离', init:true, }, ban_weak:{ name:'屏蔽弱将', init:true, restart:true, }, ban_strong:{ name:'屏蔽强将', init:false, restart:true, }, chessscroll_speed:{ name:'边缘滚动速度', intro:'鼠标移至屏幕边缘时自动滚屏', init:'20', item:{ '0':'不滚动', '10':'10格/秒', '20':'20格/秒', '30':'30格/秒', } }, } }, brawl:{ name:'乱斗', config:{ duzhansanguo:{ name:'毒战三国', init:true, frequent:true }, daozhiyueying:{ name:'导师月英', init:true, frequent:true }, weiwoduzun:{ name:'唯我独尊', init:true, frequent:true }, tongxingzhizheng:{ name:'同姓之争', init:true, frequent:true }, tongqueduopao:{ name:'铜雀夺袍', init:true, frequent:true }, tongjiangmoshi:{ name:'同将模式', init:true, frequent:true }, scene:{ name:'创建场景', init:true, frequent:true } } }, 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; } }, }, 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, globalId:0, }, help:{ '游戏操作':'', '游戏命令':'
变量名
'+ '
角色属性
'+ '
角色操作
'+ '
游戏操作
', }, 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,paused2){ 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); } if(paused2){ node._paused2=true; } }, placePoppedDialog:function(dialog,e){ if(dialog._place_text){ if(dialog._place_text.firstChild.offsetWidth>=190|| dialog._place_text.firstChild.offsetHeight>=30){ 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.clientX/game.documentZoomui.window.offsetHeight){ idealtop=ui.window.offsetHeight-10-dialog.offsetHeight; } dialog.style.top=idealtop+'px'; }, setHover:function(node,func,hoveration,width){ node._hoverfunc=func; if(typeof hoveration=='number'){ node._hoveration=hoveration; } if(typeof width=='number'){ node._hoverwidth=width } node.addEventListener('mouseenter',ui.click.mouseenter); node.addEventListener('mouseleave',ui.click.mouseleave); node.addEventListener('mousedown',ui.click.mousedown); node.addEventListener('mousemove',ui.click.mousemove); return node; }, 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;i0) top+='+ '+position[1]+'px)'; else top+='- '+Math.abs(position[1])+'px)'; var left='calc('+position[2]+'% '; if(position[3]>0) left+='+ '+position[3]+'px)'; else left+='- '+Math.abs(position[3])+'px)'; this.style.top=top; this.style.left=left; return this; }; HTMLDivElement.prototype.css=function(style){ for(var i in style){ if(i=='innerHTML'){ this.innerHTML=style[i]; } else{ this.style[i]=style[i]; } } return this; }; HTMLDivElement.prototype.transform=function(transform){ var str=''; for(var i in transform){ switch(i){ case 'scale':str+='scale('+transform[i]+') ';break; case 'rotate':str+='rotate('+transform[i]+'deg) ';break; } } if(typeof transform=='object'){ if(transform.left&&transform.top){ str+='translate('+parseInt(transform.left)+'px,'+parseInt(transform.top)+'px) '; } else if(transform.left){ str+='translate('+parseInt(transform.left)+'px) '; } else if(transform.top){ str+='translate(0,'+parseInt(transform.top)+'px) '; } } this.style.transform=str; return this; }; HTMLTableElement.prototype.get=function(row,col){ if(rowthis.length){ num=this.length; } var arr=this.slice(0); var list=[]; for(var i=0;i.dialog.popped:not(.static)'); for(var i=0;i1&&document.documentElement.offsetWidth<900&&!lib.crosswalk){ game.documentZoom=document.documentElement.offsetWidth/960; game.deviceZoom=game.documentZoom; document.documentElement.style.zoom=game.documentZoom; } else{ if(lib.device=='ios'){ if(document.documentElement.offsetWidth<900){ var zoom=Math.round(document.documentElement.offsetWidth/96)/10; var metas=document.head.querySelectorAll('meta'); for(var j=0;j 10 || Math.abs(e.touches[0].clientY/game.documentZoom - 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+')'; 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)'; } }; 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; lib.init.startBefore=lib.init.eval(mode[lib.config.mode].startBefore); if(game.onwash){ lib.onwash.push(game.onwash); delete game.onwash; } if(game.onover){ lib.onover.push(game.onover); delete game.onover; } lib.config.banned=lib.config[lib.config.mode+'_banned']||[]; lib.config.bannedcards=lib.config[lib.config.mode+'_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=='onreinit') continue; if(i=='start') continue; if(i=='startBefore') 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]); } } if(typeof mode[lib.config.mode].init=='function'){ (lib.init.eval(mode[lib.config.mode].init))(); } 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); } 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; }, cfg:function(){ var mode=lib.config.all.mode.slice(0); mode.remove('connect'); mode.remove('brawl'); var banned=['yxs_luzhishen','xuhuang','zhenji','shen_guanyu','zhurong', 'daqiao','lingcao','liuzan','lusu','luxun','yanwen','zhouyu','xiahouyuan', 'zhuzhi','old_caozhen','guojia','simayi','sp_pangde']; var bannedcards=['zengbin','toulianghuanzhu','huoshan','hongshui','guiyoujie']; for(var i=0;i0&&typeof arguments[i]=='number'){ for(var j=0;j=info.usable){ event.finish(); } else{ var hidden=player.hiddenSkills.slice(0); game.expandSkills(hidden); if(hidden.contains(event.skill)){ if(!info.silent&&player.hasSkillTag('nomingzhi',false,null,true)){ event.finish(); } else if(!info.direct){ event.trigger('triggerHidden'); } else{ event.skillHidden=true; } } } "step 1" if(event.cancelled){ event.finish(); } else{ event.trigger('triggerBefore'); } "step 2" var info=get.info(event.skill); if(event.cancelled){ event.finish(); return; } if(!event.revealed&&!info.forced){ var checkFrequent=function(info){ if(typeof info.frequent=='boolean') return info.frequent; if(typeof info.frequent=='function') return info.frequent(trigger,player); if(info.frequent=='check'&&typeof info.check=='function') return info.check(trigger,player); return false; } if(info.direct&&player.isUnderControl()){ game.modeSwapPlayer(player); event._result={bool:true}; } else if(checkFrequent(info)&&!lib.config.autoskilllist.contains(event.skill)){ event._result={bool:true}; } else if(info.direct&&player==game.me&&!_status.auto){ event._result={bool:true}; } else if(info.direct&&player.isOnline()){ event._result={bool:true}; } else{ var str; var check=info.check; if(info.prompt) str=info.prompt; else{ if(typeof info.logTarget=='string'){ str=get.prompt(event.skill,trigger[info.logTarget],player); } else if(typeof info.logTarget=='function'){ str=get.prompt(event.skill,info.logTarget(trigger,player),player); } else{ str=get.prompt(event.skill,null,player); } } 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); if(typeof info.usable=='number'){ player.addSkill('counttrigger'); if(!player.storage.counttrigger){ player.storage.counttrigger={}; } if(!player.storage.counttrigger[event.skill]){ player.storage.counttrigger[event.skill]=1; } else{ player.storage.counttrigger[event.skill]++; } } next.player=player; next._trigger=trigger; next.triggername=event.triggername; next.setContent(info.content); next.skillHidden=event.skillHidden; if(info.popup!=false&&!info.direct){ if(info.popup){ player.popup(info.popup); game.log(player,'发动了','【'+get.skillTranslation(event.skill,player)+'】'); } else{ if(info.logTarget){ if(typeof info.logTarget=='string'){ player.logSkill(event.skill,trigger[info.logTarget]); } else if(typeof info.logTarget=='function'){ player.logSkill(event.skill,info.logTarget(trigger,player)); } } else{ player.logSkill(event.skill); } } } }, playVideoContent:function(){ 'step 0' game.delay(0,500); 'step 1' if(!game.chess){ ui.control.innerHTML=''; var nodes=[]; 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(!game.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); } }, waitForPlayer:function(){ 'step 0' ui.auto.hide(); ui.pause.hide(); game.createServer(); if(!lib.translate.zhu){ lib.translate.zhu='主'; } if(event.func){ event.func(); } if(!lib.configOL.number){ lib.configOL.number=parseInt(lib.configOL.player_number); } if(game.onlineroom){ game.send('server','config',lib.configOL); } ui.create.connectPlayers(game.ip); if(!window.isNonameServer){ var me=game.connectPlayers[0]; me.setIdentity('zhu'); me.initOL(lib.config.connect_nickname,lib.config.connect_avatar); me.playerid='1'; game.onlinezhu='1'; } _status.waitingForPlayer=true; game.pause(); 'step 1' _status.waitingForPlayer=false; lib.configOL.gameStarted=true; if(game.onlineroom){ game.send('server','config',lib.configOL); } for(var i=0;i0){ player.draw(event.num); } } "step 1" if(Array.isArray(result)){ event.cards=result; } }, phaseUse:function(){ "step 0"; var next=player.chooseToUse(); if(!lib.config.show_phaseuse_prompt){ next.set('prompt',false); } next.set('type','phase'); "step 1" if(result.bool&&!event.skipped){ 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')-player.getHandcardLimit(); 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',true); game.expandSkills(skills); for(var i=0;i1&&typeof event.selectCard!='function'){ 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+='牌'; } if(event.prompt2){ str+='

'+event.prompt2; } event.dialog=ui.create.dialog(str); if(Array.isArray(event.selectCard)){ event.dialog.add('0/'+get.numStr(event.selectCard[1])); event.custom.add.card=function(){ _status.event.dialog.content.childNodes[1].innerHTML= ui.selected.cards.length+'/'+get.numStr(_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(); } } if(event.rangecards){ for(var i=0;ievent.num2){ str=get.translation(player.name)+'拼点成功'; player.popup('胜'); target.popup('负'); } else{ str=get.translation(player.name)+'拼点失败'; if(event.num1==event.num2){ player.popup('平'); target.popup('平'); } else{ player.popup('负'); target.popup('胜'); } } game.broadcastAll(function(str){ var dialog=ui.create.dialog(str); dialog.classList.add('center'); setTimeout(function(){ dialog.close(); },1000); },str); game.delay(2); "step 5" if(event.callback){ game.broadcastAll(function(card1,card2){ if(card1.clone) card1.clone.style.opacity=0.5; if(card2.clone) card2.clone.style.opacity=0.5; },event.card1,event.card2); var next=game.createEvent('compareMultiple'); next.player=player; next.target=event.target; next.card1=event.card1; next.card2=event.card2; next.num1=event.num1; next.num2=event.num2; next.setContent(event.callback); } "step 6" game.broadcastAll(ui.clear); event.iwhile++; event.goto(3); }, 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.num1=event.card1.number; event.num2=event.card2.number; event.trigger('compare'); game.delay(0,1500); "step 6" event.result={ player:event.card1, target:event.card2, num1:event.num1, num2:event.num2 } var str; if(event.num1>event.num2){ event.result.bool=true; str=get.translation(player.name)+'拼点成功'; player.popup('胜'); target.popup('负'); } else{ event.result.bool=false; str=get.translation(player.name)+'拼点失败'; if(event.num1==event.num2){ event.result.tie=true; player.popup('平'); target.popup('平'); } else{ player.popup('负'); target.popup('胜'); } } game.broadcastAll(function(str){ var dialog=ui.create.dialog(str); dialog.classList.add('center'); setTimeout(function(){ dialog.close(); },1000); },str); 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; } game.broadcastAll(function(){ ui.arena.classList.remove('thrownhighlight'); }); game.addVideo('thrownhighlight2'); if(event.clear!==false){ game.broadcastAll(ui.clear); } if(typeof event.preserve=='function'){ event.preserve=event.preserve(event.result); } else if(event.preserve=='win'){ event.preserve=event.result.bool; } else if(event.preserve=='lose'){ event.preserve=!event.result.bool; } }, 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); } event.resume(); }, chooseCardOL:function(){ 'step 0' event.targets=event.list.slice(0); if(!_status.connectMode){ event.result=[]; event.goto(7); } else{ for(var i=0;i'+event.controls[i]+'
'); item.firstChild.listen(ui.click.dialogcontrol); item.firstChild.link=event.controls[i]; } event.dialog.forcebutton=true; event.dialog.open(); } else{ if(event.seperate||lib.config.seperate_control){ event.controlbars=[]; for(var i=0;i选项'+ get.cnNumber(i+1,true)+':'+event.choiceList[i]+''); } } else if(event.prompt){ event.dialog=ui.create.dialog(event.prompt); } } game.pause(); game.countChoose(); event.choosing=true; } else if(event.isOnline()){ event.send(); } else{ event.result='ai'; } "step 1" if(event.result=='ai'){ event.result={}; if(event.ai){ var result=event.ai(event.getParent(),player); if(typeof result=='number') event.result.control=event.controls[result]; else event.result.control=result; } else event.result.control=event.controls[event.choice]; } event.result.index=event.controls.indexOf(event.result.control); event.choosing=false; _status.imchoosing=false; if(event.dialog&&event.dialog.close) event.dialog.close(); if(event.controlbar) event.controlbar.close(); if(event.controlbars){ for(var i=0;i=cs.length){ event.result={ bool:true, buttons:event.dialog.buttons, links:cs } } else if(event.forced&&directh&&select[0]==select[1]){ event.result={ bool:true, buttons:event.dialog.buttons.randomGets(select[0]), links:[] } for(var i=0;i=cs.length){ event.result={ bool:true, buttons:event.dialog.buttons, links:cs } } else if(event.forced&&directh&&select[0]==select[1]){ event.result={ bool:true, buttons:event.dialog.buttons.randomGets(select[0]), links:[] } for(var i=0;i=cs.length){ event.result={ bool:true, buttons:event.dialog.buttons, links:cs } } else if(event.forced&&directh&&select[0]==select[1]){ event.result={ bool:true, buttons:event.dialog.buttons.randomGets(select[0]), links:[] } 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.listenTransition(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)){ if(event.addedTarget){ game.log(player,str,card,'(',cards,',指向',event.addedTargets,')'); } else{ game.log(player,str,card,'(',cards,')'); } } else{ if(event.addedTarget){ game.log(player,str,card,'(指向',event.addedTargets,')'); } else{ game.log(player,str,card); } } if(card.name=='wuxie'){ game.logv(player,[card,cards],[event.getTrigger().card]); } else{ game.logv(player,[card,cards],targets); } } 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" var info=get.info(card); if(info.contentBefore){ var next=game.createEvent(card.name+'ContentBefore'); next.setContent(info.contentBefore); next.targets=targets; next.card=card; next.cards=cards; next.player=player; } else if(info.reverseOrder&&get.is.versus()&&targets.length>1){ var next=game.createEvent(card.name+'ContentBefore'); next.setContent('reverseOrder'); 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.setContent(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(event.addedTargets){ next.addedTargets=event.addedTargets; next.addedTarget=event.addedTarget; next._targets=event._targets; } if(info.targetDelay===false){ event.targetDelay=false; } if(num==0&&next.targets.length>1){ if(!info.multitarget){ if(!event.fixedSeat){ get.sortSeat(targets,player); } 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(!info.nodelay&&(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 if(event.targetDelay!==false){ 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){ if(event.visible){ player.gain(cards,'gain2'); game.log(player,'摸了'+get.cnNumber(num)+'张牌(',cards,')'); } else{ player.gain(cards,'draw'); } } else{ player.gain(cards); } event.result=cards; }, discard:function(){ "step 0" 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;i1) 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.pause(); 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(); game.resume(); },get.delayx(500,500)); } else if(event.animate=='gain'){ player.$gain(cards); game.pause(); 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(); game.resume(); },get.delayx(700,700)); } else if(event.animate=='gain2'||event.animate=='draw2'){ var gain2t=300; if(player.$gain2(cards)&&player==game.me){ gain2t=500; } game.pause(); 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(); game.resume(); },get.delayx(gain2t,gain2t)); } 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(); event.finish(); } if(event.log){ game.log(player,'获得了',cards); } "step 4" game.delayx(); }, 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(); } ui.updatej(player); _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); game.broadcastAll(function(player){ if(lib.config.animation&&!lib.config.low_performance){ player.$recover(); } },player); 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(num%2==1){ if(player.singleHp){ player.singleHp=false; player.maxHp-=(num-1)/2; } else{ player.singleHp=true; player.maxHp-=(num+1)/2; event.changed=true; } } else{ player.maxHp-=num/2; } } else{ player.maxHp-=num; } player.update(); "step 1" if(player.maxHp<=0){ player.die(); } "step 2" if(!event.forced&&event.changed&&!player.isUnseen(2)){ player.doubleDraw(); } }, gainMaxHp:function(){ "step 0" game.log(player,'获得了'+get.cnNumber(num)+'点体力上限'); if(!event.forced&&typeof player.singleHp==='boolean'){ if(num%2==1){ if(player.singleHp){ player.singleHp=false; player.maxHp+=(num+1)/2; } else{ player.singleHp=true; player.maxHp+=(num-1)/2; event.changed=true; } } else{ player.maxHp+=num/2; } } else{ player.maxHp+=num; } player.update(); "step 1" if(!event.forced&&event.changed&&!player.isUnseen(2)){ 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.nodying) player.die(event.reason); }, die:function(){ game.logv(player,'die',source); if(source&&source!=player){ 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>1){ player.node.marks.lastChild.remove(); } game.broadcast(function(player){ while(player.node.marks.childNodes.length>1){ player.node.marks.lastChild.remove(); } },player); } for(var i in player.tempSkills){ player.removeSkill(i); } player.removeEquipTrigger(); // for(var i in lib.skill.globalmap){ // if(lib.skill.globalmap[i].contains(player)){ // lib.skill.globalmap[i].remove(player); // if(lib.skill.globalmap[i].length==0&&!lib.skill[i].globalFixed){ // game.removeGlobalSkill(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{ cards[0].classList.remove('fakejudge'); 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'); if(get.is.linked2(player)){ player.classList.toggle('linked2'); } else{ player.classList.toggle('linked'); } ui.updatej(player); ui.updatem(player); game.broadcast(function(player,linked){ player.classList.remove('target'); if(get.is.linked2(player)){ if(linked){ player.classList.add('linked2'); } else{ player.classList.remove('linked2'); } } else{ if(linked){ player.classList.add('linked'); } else{ player.classList.remove('linked'); } } ui.updatej(player); ui.updatem(player); },player,player.isLinked()); game.addVideo('link',player,player.isLinked()); }, }, player:{ init:function(character,character2,skill){ if(!lib.character[character]) return; if(get.is.jun(character2)){ var tmp=character; character=character2; character2=tmp; } 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.clearSkills(true); this.classList.add('fullskin'); if(!game.minskin&&get.is.newLayout()&&!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; this.node.name.dataset.nature=get.groupnature(this.group); 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(this.classList.contains('minskin')&&this.node.name.querySelectorAll('br').length>=4){ this.node.name.classList.add('long'); } 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); // this.node.name2.dataset.nature=get.groupnature(info2[1]); 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)*game.documentZoom, clientY:(ui.arena.offsetTop+this.offsetTop+refnode.offsetTop+refnode.offsetHeight/4)*game.documentZoom }); } else{ lib.placePoppedDialog(dialog,{ clientX:(this.offsetLeft+this.offsetWidth/2)*game.documentZoom, clientY:(this.offsetTop+this.offsetHeight/4)*game.documentZoom }); } 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'), views:[], 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(), } for(var i=0;i=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(game.layout=='default'&&this.maxHp>14){ hp.innerHTML=this.hp+'/'+this.maxHp; hp.classList.add('text'); } else if(get.is.newLayout()&& ( this.maxHp>9|| (this.maxHp>5&&this.classList.contains('minskin'))|| ((game.layout=='mobile'||game.layout=='long')&&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;i1){ this.node.judges.childNodes[j].tempJudge=this.node.judges.childNodes[j].name; this.node.judges.childNodes[j].name=this.node.judges.childNodes[j].viewAs; cards1.push(this.node.judges.childNodes[j]); } } } } } if(arguments.length==1){ return cards; } if(arg2!=undefined){ if(typeof arg3=='function'){ var cards2=cards.slice(0); cards.sort(function(a,b){ return arg3(b,cards2)-arg3(a,cards2); }); } if(typeof arg2=='string'){ for(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.setContent('phase'); }, phaseJudge:function(){ var next=game.createEvent('phaseJudge'); next.player=this; next.setContent('phaseJudge'); }, phaseDraw:function(){ var next=game.createEvent('phaseDraw'); next.player=this; next.num=2; next.setContent('phaseDraw'); }, phaseUse:function(){ var next=game.createEvent('phaseUse'); next.player=this; next.setContent('phaseUse'); }, phaseDiscard:function(){ var next=game.createEvent('phaseDiscard'); next.player=this; next.setContent('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=num; } next.setContent('chooseToDiscard'); next._args=Array.from(arguments); return next; }, chooseToCompare:function(target,check){ var next=game.createEvent('chooseToCompare'); next.player=this; if(Array.isArray(target)){ next.targets=target; if(check) next.ai=check; else next.ai=function(card){ var addi=(ai.get.value(card)>=8&&get.type(card)!='equip')?-10:0; if(card.name=='du') addi+=5; var source=_status.event.source; var player=_status.event.player; if(source&&source!=player&&ai.get.attitude(player,source)>1){ return -get.number(card)-ai.get.value(card)/2+addi; } return get.number(card)-ai.get.value(card)/2+addi; } next.setContent('chooseToCompareMultiple'); } else{ 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(card.name=='du') addi+=5; 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.setContent('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.setContent('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.setContent('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.setContent('gainPlayerCard'); next._args=Array.from(arguments); return next; }, showHandcards:function(str){ var next=game.createEvent('showHandcards'); next.player=this; if(typeof str=='string'){ next.prompt=str; } next.setContent('showHandcards'); next._args=Array.from(arguments); return next; }, showCards:function(cards,str){ var next=game.createEvent('showCards'); next.player=this; next.str=str; if(typeof cards=='string'){ str=cards; cards=next.str; 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.setContent('showCards'); next._args=Array.from(arguments); }, viewCards:function(str,cards){ var next=game.createEvent('viewCards'); next.player=this; next.str=str; next.cards=cards; next.setContent('viewCards'); 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'&&!next.noai){ var postAi=get.info(next.card).postAi; if(postAi&&postAi(next.targets)){ next.postAi=true; } else{ this.logAi(next.targets,next.card); } } next.setContent('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.setContent('useSkill'); return next; }, 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;i0.95){ this.ai.shown=0.95; } } return this; }, equip:function(card){ var next=game.createEvent('equip'); next.card=card; next.player=this; next.setContent(lib.element.content.equip); return next; }, addJudge:function(card,cards){ var next=game.createEvent('addJudge'); next.card=card; next.cards=cards; if(next.cards==undefined) next.cards=[card]; if(get.itemtype(next.cards)=='card') next.cards=[next.cards]; next.player=this; next.setContent('addJudge'); return next; }, judge:function(){ var next=game.createEvent('judge'); 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){ if(storage!=undefined){ 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(); player.marks[name].style.transform+=' scale(0.2)'; delete player.marks[name]; ui.updatem(player); } },this,name); if(this.marks[name]){ this.marks[name].delete(); this.marks[name].style.transform+=' scale(0.2)'; delete this.marks[name]; ui.updatem(this); 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]){ 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.drawinghidden').setBackground(name,'character'); this.node.marks.insertBefore(node,this.node.marks.childNodes[1]); 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; node.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.card); if(!lib.config.touchscreen){ if(lib.config.hover_all){ lib.setHover(node,ui.click.hoverplayer); } if(lib.config.right_info){ node.oncontextmenu=ui.click.rightplayer; } } ui.updatem(this); return node; }, mark:function(name,info,skill){ if(get.itemtype(name)=='cards'){ var marks=[]; for(var i=0;i=3) return target.identity=='fan'; return target.identity=='nei'||target.identity=='fan'; });break; case 'nei':targets=game.filterPlayer(function(target){ if(func&&!func(target)) return false; if(num>=3) return target.identity=='fan'; if(game.players.length==2) return target!=player; return target.identity=='zhong'||target.identity=='mingzhong'||target.identity=='fan'; });break; case 'fan':targets=game.filterPlayer(function(target){ if(func&&!func(target)) return false; return target.identity!='fan'; });break; } } else if(mode=='guozhan'){ if(player.identity=='ye'){ targets=game.filterPlayer(function(target){ if(func&&!func(target)) return false; return true; }); } else{ var group=lib.character[player.name1][1]; targets=game.filterPlayer(function(target){ if(func&&!func(target)) return false; return lib.character[target.name1][1]!=group; }); } } else{ targets=game.filterPlayer(function(target){ if(func&&!func(target)) return false; return target.side!=player.side; }); } targets.remove(player); return targets; }, isEnemyOf:function(){ return !this.isFriendOf.apply(this,arguments); }, isFriendOf:function(player){ if(get.mode()=='guozhan'){ if(this==player) return true; if(this.identity=='unknown'||this.identity=='ye') return false; if(player.identity=='unknown'||player.identity=='ye') return false; return this.identity==player.identity; } if(typeof this.side=='boolean'&&typeof player.side=='boolean'){ return this.side==player.side; } return this==player; }, isAlive:function(){ return this.classList.contains('dead')==false; }, isDead:function(){ return this.classList.contains('dead'); }, isDamaged:function(){ return this.hp=this.hp) return false; } else{ if(game.players[i].hp>this.hp) return false; } } return true; }, isLowestHp:function(equal){ for(var i=0;i=nh) return false; } else{ if(game.players[i].num('h')>nh) return false; } } return true; }, isFewestHandcard:function(equal){ var nh=this.num('h'); for(var i=0;i0){ return true; } } return false; }, hasUnknown:function(num){ var mode=get.mode(); if(typeof num!='number'){ num=0; } if(mode=='identity'||mode=='guozhan'){ 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.listenTransition(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); } } }, $compareMultiple:function(card1,targets,cards){ game.broadcast(function(player,card1,targets,cards){ player.$compareMultiple(card1,targets,cards); },this,card1,targets,cards); game.addVideo('compareMultiple',this,[get.cardInfo(card1),get.targetsInfo(targets),get.cardsInfo(cards)]); var player=this; var node1=player.$throwxy2(card1, 'calc(50% - 52px)','calc(50% + 10px)','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.listenTransition(onEnd); },300); }; node1.listenTransition(onEnd01); setTimeout(function(){ var left0=-targets.length*52-(targets.length-1)*8; 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&&!_status.video){ game.log(player,'从',this,'获得了',card); } if(this.$givemod){ this.$givemod(card,player); } else{ for(var i=0;i=0){ if(log!=false&&!_status.video){ 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&&!_status.video){ 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.listenTransition(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); } var info=get.info(card); if(info.skills){ for(var i=0;i=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&&!_status.video){ game.log(this,'获得了',card); } if(this.$gainmod){ this.$gainmod(card); } else{ for(var i=0;i1){ if(log!=false&&!_status.video){ 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'); return true; } }, $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.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.listenTransition(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(get.is.mobileMe(this)){ if(this.classList.contains('linked')){ 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.classList.contains('linked')&&get.is.newLayout()){ 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(get.is.mobileMe(this)){ if(this.classList.contains('linked')){ 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.classList.contains('linked')&&get.is.newLayout()){ 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(get.is.mobileMe(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(get.is.mobileMe(this)){ this.node.avatar.style.transform=transform; this.node.avatar2.style.transform=transform; this.style.transform=''; } else{ this.node.avatar.style.transform=''; this.node.avatar2.style.transform=''; 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.listenTransition(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'; } } if(!lib.card[card[2]]){ lib.card[card[2]]={}; } var info=lib.card[card[2]]; if(this.name){ this.classList.remove('epic'); this.classList.remove('legend'); var subtype=get.subtype(this); if(subtype){ this.classList.remove(subtype); } } if(info.epic){ this.classList.add('epic'); } else if(info.legend){ this.classList.add('legend'); } var bg=card[2]; if(info.cardimage){ bg=info.cardimage; } var img=lib.card[bg].image; if(img){ if(img.indexOf('db:')==0){ img=img.slice(3); } else if(img.indexOf('ext:')!=0){ img=null; } } if(!lib.config.hide_card_image&&lib.card[bg].fullskin){ this.classList.add('fullskin'); if(img){ if(img.indexOf('ext:')==0){ this.node.image.setBackgroundImage(img.replace(/ext:/,'extension/')); } else{ this.node.image.setBackgroundDB(img); } } else{ if(lib.card[bg].modeimage){ this.node.image.setBackgroundImage('image/mode/'+lib.card[bg].modeimage+'/card/'+bg+'.png'); } else{ this.node.image.setBackgroundImage('image/card/'+bg+'.png'); } } } else if(lib.card[bg].image=='background'){ if(card[3]) this.node.background.setBackground(bg+'_'+card[3],'card'); else this.node.background.setBackground(bg,'card'); } else if(lib.card[bg].fullimage){ if(img){ if(img.indexOf('ext:')==0){ this.setBackgroundImage(img.replace(/ext:/,'extension/')); this.style.backgroundSize='cover'; } else{ this.setBackgroundDB(img); } } else if(lib.card[bg].image){ this.setBackground(lib.card[bg].image); } else{ var cardPack=lib.cardPack['mode_'+get.mode()]; if(Array.isArray(cardPack)&&cardPack.contains(bg)){ this.setBackground('mode/'+get.mode()+'/card/'+bg); } else{ this.setBackground('card/'+bg); } } } else if(lib.card[bg].image=='card'){ if(card[3]) this.setBackground(bg+'_'+card[3],'card'); else this.setBackground(bg,'card'); } else if(typeof lib.card[bg].image=='string'&&!lib.card[bg].fullskin){ if(img){ if(img.indexOf('ext:')==0){ this.setBackgroundImage(img.replace(/ext:/,'extension/')); this.style.backgroundSize='cover'; } else{ this.setBackgroundDB(img); } } else{ this.setBackground(lib.card[bg].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(info.noname&&!this.classList.contains('button')){ this.node.name.style.display='none'; } if(info.color){ this.style.color=info.color; } else if(info.fullimage){ this.style.color='white'; } if(info.textShadow){ this.style.textShadow=info.textShadow; } else if(info.fullimage){ this.style.textShadow='black 0 0 2px'; } if(info.opacity){ this.node.info.style.opacity=info.opacity; this.node.name.style.opacity=info.opacity; } else if(info.fullimage){ this.node.info.style.opacity=1; this.node.name.style.opacity=1; } if(info.modinfo){ this.node.info.innerHTML=info.modinfo; } else{ this.node.info.innerHTML=get.translation(card[0])+' '+card[1]; } if(info.addinfo){ if(!this.node.addinfo){ this.node.addinfo=ui.create.div('.range',this); } this.node.addinfo.innerHTML=info.addinfo; } else if(this.node.addinfo){ this.node.addinfo.remove(); delete this.node.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(name.length>=5){ this.node.name.classList.add('long'); if(name.length>=7){ this.node.name.classList.add('longlong'); } } 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(info.subtype) this.classList.add(info.subtype); if(this.inits){ for(var i=0;i'+str+''); } else{ this.add('
'+str+'
'); } return this; }, addSmall:function(item,noclick){ return this.add(item,noclick,true); }, addAuto:function(content){ if(content&&content.length>4&&!this._hovercustomed){ this.addSmall(content); } else{ this.add(content); } }, open:function(){ if(this.noopen) return; 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(-'+(this.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;i=8){ return true; } } else{ if(lib.config.banned.contains(i)) return true; if(lib.config.replacecharacter[i]&&lib.character[lib.config.replacecharacter[i]]) return true; var double_character=false; if(lib.config.mode=='guozhan'){ double_character=true; } else if(get.config('double_character')&&(lib.config.mode=='identity'||lib.config.mode=='stone')){ double_character=true; } else if(get.config('double_character_jiange')&&(lib.config.mode=='versus'&&_status.mode=='jiange')){ double_character=true; } if(double_character&&lib.config.forbiddouble.contains(i)){ return true; } if(get.config('ban_weak')){ if(lib.config.forbidall.contains(i)) return true; if(!double_character&&get.rank(i,true)<=2){ return true; } } if(get.config('ban_strong')&&get.rank(i,true)>=8){ return true; } } }, cardEnabled:function(card,player,event){ card=get.autoViewAs(card,null,player); if(player==undefined) player=_status.event.player; var filter=get.info(card).enable; if(!filter) return; var mod=game.checkMod(card,player,'unchanged','cardEnabled',player.get('s')); if(mod!='unchanged') return mod; if(typeof filter=='boolean') return filter; if(typeof filter=='function') return filter(card,player); }, cardRespondable:function(card,player){ if(_status.event.name!='chooseToRespond') return true; if(player==undefined) player=_status.event.player; var mod=game.checkMod(card,player,'unchanged','cardRespondable',player.get('s')); if(mod!='unchanged') return mod; return true; }, cardUsable:function(card,player,event){ card=get.autoViewAs(card,null,player); if(player!=_status.event.player) return true; event=event||_status.event; if(event.getParent().name!='phaseUse') return true; if(event.getParent().player!=player) return true; var num=get.info(card).usable; if(typeof num=='function') num=num(card,player); num=game.checkMod(card,player,num,'cardUsable',player.get('s')); if(typeof num!='number') return true; else return(get.cardCount(card,player)0){ var triggerevent=event.getTrigger(); if(triggerevent){ if(ui.tempnowuxie._origin==triggerevent.parent.id){ return true; } } else if(ui.tempnowuxie._origin==_status.event.id2){ return true; } } if(!_status.connectMode&&lib.config.wuxie_self&&event.getParent().state){ var tw=event.getTrigger().parent; if(tw.player.isUnderControl(true)&&tw.targets&&tw.targets.length==1&&!tw.noai){ return true; } } } } }, sort:{ character:function(a,b){ var groupSort=function(name){ if(!lib.character[name]) return 4; if(lib.character[name][1]=='wei') return 0; if(lib.character[name][1]=='shu') return 1; if(lib.character[name][1]=='wu') return 2; if(lib.character[name][1]=='qun') return 3; } var del=groupSort(a)-groupSort(b); if(del!=0) return del; var aa=a,bb=b; if(a.indexOf('_')!=-1){ a=a.slice(a.indexOf('_')+1); } if(b.indexOf('_')!=-1){ b=b.slice(b.indexOf('_')+1); } if(a!=b){ return a>b?1:-1; } return aa>bb?1:-1; }, random:function(){ return (Math.random()-0.5); }, seat:function(a,b){ var player=lib.tempSortSeat||_status.event.player; var delta=get.distance(player,a,'absolute')-get.distance(player,b,'absolute'); if(delta) return delta; delta=parseInt(a.dataset.position)-parseInt(b.dataset.position); if(player.side==game.me.side) return delta; return -delta; }, position:function(a,b){ return parseInt(a.dataset.position)-parseInt(b.dataset.position); }, priority:function(a,b){ var i1=get.info(a[0]),i2=get.info(b[0]); if(i1.priority==undefined) i1.priority=0; if(i2.priority==undefined) i2.priority=0; if(i1.priority==i2.priority){ if(i1.forced==undefined&&i2.forced==undefined) return 0; if(i1.forced&&i2.forced) return 0; if(i1.forced) return 1; if(i2.forced) return -1; } return i2.priority-i1.priority; }, number:function(a,b){ return get.number(a)-get.number(b); }, number2:function(a,b){ return get.number(b)-get.number(a); }, capt:function(a,b){ var aa=a,bb=b; if(aa.indexOf('_')!=-1){ aa=aa.slice(aa.indexOf('_')+1); } if(bb.indexOf('_')!=-1){ bb=bb.slice(bb.indexOf('_')+1); } if(aa!=bb){ return aa>bb?1:-1; } return a>b?1:-1; }, name:function(a,b){ if(a>b) return 1; if(a=player.maxHp; }, content:function(){ trigger.untrigger(); trigger.finish(); }, }, _turnover:{ trigger:{player:'phaseBefore'}, forced:true, priority:20, popup:false, content:function(){ for(var i=0;igame.players.length*num&&game.showIdentity){ if(!_status.video) player.popup('显示身份'); _status.identityShown=true; game.showIdentity(false); } } player.ai.tempIgnore=[]; player.stat.push({card:{},skill:{}}); }, }, _usecard:{ trigger:{global:'useCardAfter'}, forced:true, popup:false, priority:-100, filter:function(event){ return !event._cleared&&event.card.name!='wuxie'; }, content:function(){ game.broadcastAll(function(){ ui.clear(); }); event._cleared=true; } }, _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; if(!event.acted) event.acted=[]; "step 1" if(trigger.player.isDead()){ event.finish(); return; } _status.dying=event.dying; event.acted.push(player); // else if(trigger.source&&trigger.source.isDead()){ // trigger.start=game.findNext(trigger.source); // } // else{ // trigger.start=trigger.source||trigger.player; // } var str=get.translation(trigger.player.name)+'濒死,是否帮助?
当前体力:'+trigger.player.hp+'
'; _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',function(card){ var savable=get.info(card).savable; if(typeof savable=='function') savable=savable(card,player,event.dying); return savable; })){ 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(card){ if(typeof card=='string'){ var info=get.info(card); if(info.ai&&info.ai.order){ if(typeof info.ai.order=='number'){ return info.ai.order; } else if(typeof info.ai.order=='function'){ return info.ai.order(); } } } 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.nodying&&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.acted.contains(event.player.next)){ break; } else{ event.player=event.player.next; if(!event.player.isOut()){ event.goto(1); break; } } } } } }, _ismin:{ mod:{ cardEnabled:function(card,player){ if(player.isMin()){ if(get.type(card)=='equip') return false; } } } }, _chongzhu:{ enable:'phaseUse', logv:false, prompt:'将要重铸的牌置入弃牌堆并摸一张牌', filter:function(event,player){ return (player.num('h',function(card){ var info=get.info(card); if(typeof info.chongzhu=='function'){ return info.chongzhu(event,player); } return info.chongzhu; })>0); }, filterCard:function(card){ var info=get.info(card); if(typeof info.chongzhu=='function'){ return info.chongzhu(event,_status.event.player); } return info.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(var 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]); } } game.finishCards(); _status.event={ finished:true, next:[], }; _status.paused=false; game.createEvent('game',false).setContent(lib.init.startOnline); game.loop(); game.send('inited'); }); } if(_status.event.parent){ 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(var 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]); } } game.finishCards(); if(mode.characterPack){ for(var i in mode.characterPack){ lib.characterPack[i]=mode.characterPack[i]; } } if(mode.onreinit){ (lib.init.eval(mode.onreinit))(); } 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); } if(!lib.configOL.observe_handcard){ ui.arena.classList.add('observe'); } } ui.arena.setNumber(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,'.'); 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 finishLoad=='function'){ finishLoad(); } } else{ game.importExtension.apply(this,[zip.generate({type:'arraybuffer'}),finishLoad]); } } else{ var zip=new JSZip(); zip.load(data); var str=zip.file('extension.js').asText(); try{ _status.importingExtension=true; eval(str); _status.importingExtension=false; if(!game.importedPack) throw('err'); var extname=game.importedPack.name; if(lib.config.all.plays.contains('extname')){ throw('err'); } if(lib.config.extensions.contains(extname)){ game.removeExtension(extname,true); } lib.config.extensions.add(extname); game.saveConfig('extensions',lib.config.extensions); game.saveConfig('extension_'+extname+'_enable',true); for(var i in game.importedPack.config){ if(game.importedPack.config[i]&&game.importedPack.config[i].hasOwnProperty('init')){ game.saveConfig('extension_'+extname+'_'+i,game.importedPack.config[i].init); } } if(game.download){ var filelist=[]; for(var i in zip.files){ if(i[0]!='.'&&i[0]!='_'){ filelist.push(i); } } if(lib.node&&lib.node.fs){ game.ensureDirectory('extension/'+extname,function(){ var writeFile=function(){ if(filelist.length){ var filename=filelist.shift(); lib.node.fs.writeFile(__dirname+'/extension/'+extname+'/'+filename,zip.files[filename].asNodeBuffer(),null,writeFile); } else{ finishLoad(); } } writeFile(); }); } else{ window.resolveLocalFileSystemURL(lib.assetURL,function(entry){ entry.getDirectory('extension/'+extname,{create:true},function(dirEntry){ var writeFile=function(){ if(filelist.length){ var filename=filelist.shift(); dirEntry.getFile(filename,{create:true},function(fileEntry){ fileEntry.createWriter(function(fileWriter){ fileWriter.onwriteend=writeFile; fileWriter.write(zip.files[filename].asArrayBuffer()); }); }); } else{ finishLoad(); } }; writeFile(); }); }); } } else{ localStorage.setItem(lib.configprefix+'extension_'+extname,str); var imglist=[]; for(var i in zip.files){ if(i[0]!='.'&&i[0]!='_'){ if(i.indexOf('.jpg')!=-1||i.indexOf('.png')!=-1){ imglist.push(i); } } } if(imglist.length&&lib.db){ lib.config.extensionInfo[extname]={ image:imglist } game.saveConfig('extensionInfo',lib.config.extensionInfo); for(var i=0;i|\|/g,'.'); if(lib.device){ var directory; if(lib.device=='android'){ directory=cordova.file.externalDataDirectory; } else{ directory=cordova.file.documentsDirectory; } window.resolveLocalFileSystemURL(directory,function(entry){ entry.getFile(fileNameToSaveAs,{create:true},function(fileEntry){ fileEntry.createWriter(function(fileWriter){ fileWriter.onwriteend=function(){ alert('文件已导出至'+directory+fileNameToSaveAs); } fileWriter.write(textFileAsBlob) }); }); }); } else{ var downloadLink = document.createElement("a"); downloadLink.download = fileNameToSaveAs; downloadLink.innerHTML = "Download File"; downloadLink.href = window.URL.createObjectURL(textFileAsBlob); downloadLink.click(); } }, multiDownload:function(list,onsuccess,onerror,onfinish,process,dev){ list=list.slice(0); if(lib.config.dev) game.print(get.url()); var download=function(){ if(list.length){ var current=list.shift(); var current2; if(typeof process=='function'){ current2=process(current); } else{ current2=current; } if(current.indexOf('theme')==0){ game.print(current.slice(6)); } else if(current.indexOf('image/skin')==0){ game.print(current.slice(11)); } else{ game.print(current.slice(current.lastIndexOf('/')+1)); } game.download(current,current2,function(){ if(onsuccess) onsuccess(list.length); download(); },function(){ if(onerror) onerror(list.length); download(); },dev); } else{ if(onfinish) onfinish(); } } download(); }, playVideo:function(time,mode){ if(!_status.replayvideo){ localStorage.setItem(lib.configprefix+'playbackmode',lib.config.mode); } game.saveConfig('mode',mode); localStorage.setItem(lib.configprefix+'playback',time); game.reload(); }, playVideoContent:function(video){ var next=game.createEvent('video',false); next.video=video; ui.system.style.display='none'; ui.system.hide(); ui.arena.style.display='none'; ui.arena.hide(); ui.window.classList.remove('leftbar'); ui.window.classList.remove('rightbar'); ui.historybar.style.display='none'; _status.event=next; _status.paused=false; _status.paused2=false; _status.over=false; _status.video=true; clearTimeout(_status.timeout); for(var i in lib.characterPack){ for(var j in lib.characterPack[i]){ lib.character[j]=lib.character[j]||lib.characterPack[i][j]; } } next.setContent('playVideoContent'); game.loop(); }, videoContent:{ init:function(players){ if(game.chess) return; if(lib.config.mode=='versus'){ players.bool=players.pop(); } ui.arena.setNumber(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.setNumber(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(game.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;i1){ player.node.marks.lastChild.remove(); } player.classList.add('dead'); 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); if(lib.config.mode=='stone'){ setTimeout(function(){ player.delete(); },500); } }, tafangMe:function(player){ if(player){ game.me=player; ui.me.lastChild.show(); ui.create.fakeme(); ui.handcards1=player.node.handcards1.animate('start').fix(); ui.handcards2=player.node.handcards2.animate('start').fix(); ui.handcards1Container.appendChild(ui.handcards1); ui.handcards2Container.appendChild(ui.handcards2); ui.updatehl(); game.setChessInfo(); } }, deleteChessPlayer:function(player){ if(player){ player.delete(); delete game.playerMap[player.dataset.position]; game.players.remove(player); 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.addLink(); } else{ player.removeLink(); } } 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; var drag=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; if(arguments[1]=='drag'){ color=[236, 201, 71]; drag=true; if(arguments[2]){ node=arguments[2] } else{ node=ui.create.div('.linexy.drag'); node.style.left=from[0]+'px'; node.style.top=from[1]+'px'; node.style.background='linear-gradient(transparent,rgba('+color.toString()+','+opacity+'),rgba('+color.toString()+','+opacity+'))'; if(game.chess){ ui.chess.appendChild(node); } else{ ui.arena.appendChild(node); } } } else{ node=ui.create.div('.linexy.hidden'); node.style.left=from[0]+'px'; node.style.top=from[1]+'px'; node.style.background='linear-gradient(transparent,rgba('+color.toString()+','+opacity+'),rgba('+color.toString()+','+opacity+'))'; node.style.transitionDuration=(total/3000)+'s'; } 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; } } if(drag){ node.style.transform='rotate('+(-deg)+'deg)'; node.style.height=get.xyDistance(from,to)+'px'; } else{ 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.listenTransition(function(){ setTimeout(function(){ if(node.classList.contains('removing')) return; node.delete(); },total/3); }); } return node; }, _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.setContent('createTrigger'); }, 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 imgsrc; if(_status.evaluatingExtension){ imgsrc='db:extension-'+extname+':'+name+'.jpg'; } else{ imgsrc='ext:'+extname+'/'+name+'.jpg'; } var character=[info.sex,info.group,info.hp,info.skills||[],[imgsrc]]; 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; }, addCharacterPack:function(pack,packagename){ var extname=_status.extension||'扩展'; packagename=packagename||extname; for(var i in pack){ if(i=='mode'||i=='forbid') continue; for(var j in pack[i]){ if(i=='character'){ if(!pack[i][j][4]){ pack[i][j][4]=[]; } var imgsrc; if(_status.evaluatingExtension){ imgsrc='db:extension-'+extname+':'+j+'.jpg'; } else{ imgsrc='ext:'+extname+'/'+j+'.jpg'; } pack[i][j][4].push(imgsrc); if(pack[i][j][4].contains('boss')|| pack[i][j][4].contains('hiddenboss')){ lib.config.forbidai.add(j); } for(var l=0;lnum){ list.splice(num); } game.saveConfig('recentCharacter',list,true); }, 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'; } var noclick=false; if(suit=='noclick'){ noclick=true; suit=null; } 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); } var card; if(noclick){ card=ui.create.card(ui.special,'noclick',true); } else{ card=ui.create.card(ui.special); } return card.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.setContent('forceOver'); 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.layout=='long2'&&!game.chess){ ui.arena.classList.add('choose-character'); ui.me.hide(); ui.mebg.hide() ui.autonode.hide(); if(lib.config.radius_size!='off'){ ui.historybar.style.borderRadius='0 0 0 4px'; } } if(game.online){ var dialog=ui.create.dialog(); dialog.content.innerHTML=result; dialog.forcebutton=true; 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(ui.auto) ui.auto.hide(); if(ui.wuxie) ui.wuxie.hide(); if(game.getIdentityList){ for(var i=0;i40){ mmr=40; } else if(mmr<10){ mmr=10; } dialog.add(ui.create.div('','获得 '+mmr+' 积分')); } else{ mmr=-30+Math.round(mmr/2); if(mmr>-20){ mmr=-20; } else if(mmr<-35){ mmr=-35; } if(lib.storage.ladder.current<900){ mmr=Math.round(mmr/4); } else if(lib.storage.ladder.current<1400){ mmr=Math.round(mmr/2); } else if(lib.storage.ladder.current<2000){ mmr=Math.round(mmr/1.5); } else if(lib.storage.ladder.current>2500){ mmr=Math.round(mmr*1.5); } dialog.add(ui.create.div('','失去 '+(-mmr)+' 积分')); } if(_status.ladder_tmp){ lib.storage.ladder.current+=40; delete _status.ladder_tmp; } lib.storage.ladder.current+=mmr; if(lib.storage.ladder.top'+get.translation(game.players[i])+''); dialog.addSmall(hs); } } dialog.add(ui.create.div('.placeholder.slim')); var clients=game.players.concat(game.dead); for(var i=0;i=vinum){ var toremove=videos.pop(); lib.videos.remove(toremove); store.delete(toremove.time); } else{ break; } } var me=game.me||game.players[0]; if(!me) return; var newvid={ name:game.getVideoName(), mode:lib.config.mode, video:lib.video, win:result=='战斗胜利', name1:me.name1||me.name, name2:me.name2, time:lib.getUTC(new Date()) }; var modecharacters=lib.characterPack['mode_'+get.mode()]; if(modecharacters){ if(get.mode()=='guozhan'){ if(modecharacters[newvid.name1]){ if(newvid.name1.indexOf('gz_shibing')==0){ newvid.name1=newvid.name1.slice(3,11); } else{ newvid.name1=newvid.name1.slice(3); } } if(modecharacters[newvid.name2]){ if(newvid.name2.indexOf('gz_shibing')==0){ newvid.name2=newvid.name2.slice(3,11); } else{ newvid.name2=newvid.name2.slice(3); } } } else{ if(modecharacters[newvid.name1]){ newvid.name1=get.mode()+'::'+newvid.name1; } if(modecharacters[newvid.name2]){ newvid.name2=get.mode()+'::'+newvid.name2; } } } lib.videos.unshift(newvid); store.put(newvid); ui.create.videoNode(newvid,true); } // _status.auto=false; if(ui.auto){ // ui.auto.classList.remove('glow'); ui.auto.hide(); } if(ui.wuxie) ui.wuxie.hide(); if(lib.config.test_game&&!_status.connectMode){ if(lib.config.test_game!='single'){ 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(!_status.brawl){ 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'||_status.mode=='three'){ ui.create.control('再战',function(){ game.saveConfig('continue_name_versus'+(_status.mode=='three'?'_three':''),{ 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&&!_status.brawl){ 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'){ game.broadcastAll(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.includeOut){ event.finish(); } else{ if(lib.config.compatiblemode||(_status.connectMode&&!lib.config.debug)){ try{ event.content(event,step,source,player,target,targets, card,cards,skill,forced,num,trigger,result, _status,lib,game,ui,get,ai); } catch(e){ game.print('游戏出错:'+event.name); game.print(e.toString()); console.log(e); } } else{ event.content(event,step,source,player,target,targets, card,cards,skill,forced,num,trigger,result, _status,lib,game,ui,get,ai); } } 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||!event._backup)){ if(event.choosing){ _status.imchoosing=true; } return; } if(event.filterButton){ var dialog=event.dialog; range=get.select(event.selectButton); var selectableButtons=false; 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; } else if(game.players[i].isOut()){ nochess=false; } else if(event._targetChoice&&event._targetChoice.has(card)){ var targetChoice=event._targetChoice.get(card); if(!Array.isArray(targetChoice)||!targetChoice.contains(game.players[i])){ nochess=false; } } else if(!event.filterTarget(card,player,game.players[i])){ nochess=false; } if(nochess){ if(ui.selected.targets.length=info.usable) enable=false; if(info.chooseButton&&_status.event.noButton) enable=false; } if(enable){ if(event.isMine()||!event.aiexclude.contains(skills2[i])){ skills.add(skills2[i]); } event._skillChoice.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||(skillinfo&&skillinfo.direct))&&(!_status.mousedragging||!_status.mouseleft)&& !_status.mousedown&&!_status.touchnocheck){ if(ui.confirm){ if(!skillinfo||!skillinfo.preservecancel){ ui.confirm.close(); } } if(skillinfo&&skillinfo.preservecancel&&!ui.confirm){ ui.create.confirm('c'); } 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&&!event.fakeforce&&get.noSelected()) str+='c'; ui.create.confirm(str); } } } if(ui.confirm&&ui.confirm.lastChild.link=='cancel'){ if(_status.event.type=='phase'&&!_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){ if(lib.config.layout!=game.layout&&!lib.layoutfixed.contains(name)){ lib.init.layout(lib.config.layout); } window.mode={}; var script=lib.init.js(lib.assetURL+'mode',name,function(){ script.remove(); var mode=window.mode; delete window.mode; _status.sourcemode=lib.config.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.banned=lib.config[lib.config.mode+'_banned']||[]; lib.config.bannedcards=lib.config[lib.config.mode+'_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(i=='startBefore') 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;i3){ event.side=0; } event.goto(2); } else{ event.promptbar.hide(); event.side++; if(event.side>3){ event.side=0; } if(event.side>=2){ game.delay() } } 'step 4' if(event.checkredo()) return; if(event.replacenode) event.replacenode.delete(); if(event.reselectnode) event.reselectnode.delete(); if(event.freechoosenode) event.freechoosenode.delete(); for(var i=0;ievent.config.width){ event.avatars[i].classList.add('selecting'); } } var rand=[]; for(var 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'){ if(lib.config.log_highlight){ if(arguments[i][0]=='【'&&arguments[i][arguments[i].length-1]=='】'){ str+=''+get.translation(arguments[i])+''; } else if(arguments[i][0]=='#'){ var color=''; switch(arguments[i][1]){ case 'b':color='blue';break; case 'y':color='yellow';break; case 'g':color='green';break; } str+=''+get.translation(arguments[i].slice(2))+''; } else{ 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(!_status.video&&!game.online){ var logvid=_status.event.getLogv(); if(logvid){ game.logv(logvid,'
'+str+'
'); } } if(lib.config.title) document.title=str; if(lib.config.show_log!='off'&&!game.chess){ var nodeentry=node.cloneNode(true); ui.arenalog.insertBefore(nodeentry,ui.arenalog.firstChild); if(!lib.config.clear_log){ while(ui.arenalog.childNodes.length&&ui.arenalog.scrollHeight>ui.arenalog.offsetHeight){ ui.arenalog.lastChild.remove(); } } if(!lib.config.low_performance){ nodeentry.style.transition='all 0s'; nodeentry.style.marginBottom=(-nodeentry.offsetHeight)+'px'; ui.refresh(nodeentry); nodeentry.style.transition=''; nodeentry.style.marginBottom=''; } if(lib.config.clear_log){ nodeentry.timeout=setTimeout(function(){ nodeentry.delete(); },1000); for(var i=0;i0){ try{ config=JSON.parse(localStorage.getItem(lib.configprefix+mode)); if(typeof config!='object') throw 'err'; } catch(err){ config={}; } if(value==undefined){ delete config[key]; if(mode==lib.config.mode) delete lib.storage[key]; } else{ config[key]=value; if(mode==lib.config.mode) lib.storage[key]=value; } } config.version=lib.version; localStorage.setItem(lib.configprefix+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