"use strict";
(function(){
if(!localStorage.getItem('gplv3_noname_alerted')){
if(confirm('①无名杀是一款基于GPLv3协议的开源软件!\n你可以在遵守GPLv3协议的基础上任意使用,修改并转发《无名杀》,以及所有基于《无名杀》开发的拓展。\n点击“确定”即代表您认可并接受GPLv3协议↓️\nhttps://www.gnu.org/licenses/gpl-3.0.html\n②无名杀官方发布地址仅有GitHub仓库!\n其他所有的所谓“无名杀”社群(包括但不限于绝大多数“官方”QQ群、QQ频道等)均为玩家自发组织,与无名杀官方无关!')){
localStorage.setItem('gplv3_noname_alerted',true);
}
else{
var ua=navigator.userAgent.toLowerCase();
var ios=ua.indexOf('iphone')!=-1||ua.indexOf('ipad')!=-1||ua.indexOf('macintosh')!=-1;
//electron
if(typeof window.process=='object'&&typeof window.require=='function'){
var versions=window.process.versions;
var electronVersion=parseFloat(versions.electron);
var remote;
if(electronVersion>=14){
remote=require('@electron/remote');
}else{
remote=require('electron').remote;
}
var thisWindow=remote.getCurrentWindow();
thisWindow.destroy();
window.process.exit();
}
//android-cordova环境
//ios-cordova环境或ios浏览器环境
//非ios的网页版
else if(!ios){
window.close();
}
}
}
var _status={
paused:false,
paused2:false,
paused3:false,
over:false,
clicked:false,
auto:false,
event:{
finished:true,
next:[],
after:[]
},
ai:{},
lastdragchange:[],
skillaudio:[],
dieClose:[],
dragline:[],
dying:[],
globalHistory:[{
cardMove:[],
custom:[],
useCard:[],
changeHp:[],
everything:[],
}],
cardtag:{
yingbian_zhuzhan:[],
yingbian_kongchao:[],
yingbian_fujia:[],
yingbian_canqu:[],
},
renku:[],
prehidden_skills:[],
postReconnect:{},
};
var lib={
configprefix:'noname_0.9_',
versionOL:27,
updateURLS:{
coding:'https://ghproxy.com/https://raw.githubusercontent.com/libccy/noname',
github:'https://raw.githubusercontent.com/libccy/noname',
},
updateURL:'https://raw.githubusercontent.com/libccy/noname',
mirrorURL:'https://nakamurayuri.coding.net/p/noname/d/noname/git/raw',
hallURL:'47.99.105.222',
assetURL:'',
changeLog:[],
updates:[],
canvasUpdates:[],
video:[],
skilllist:[],
connectBanned:[],
characterIntro:{},
characterTitle:{},
characterPack:{},
characterFilter:{},
characterSort:{},
characterReplace:{},
dynamicTranslate:{},
cardPack:{},
skin:{},
onresize:[],
onphase:[],
onwash:[],
onover:[],
ondb:[],
ondb2:[],
chatHistory:[],
emotionList:{
xiaowu_emotion:14,
shibing_emotion:15,
guojia_emotion:20,
zhenji_emotion:20,
xiaosha_emotion:20,
xiaotao_emotion:20,
xiaojiu_emotion:20,
},
animate:{
skill:{},
card:{},
},
arenaReady:[],
onfree:[],
inpile:[],
inpile_nature:[],
extensions:[],
extensionPack:{},
cardType:{},
hook:{globaltrigger:{},globalskill:{}},
hookmap:{},
imported:{},
layoutfixed:['chess','tafang','stone'],
pinyins:{
metadata:{
shengmu:['zh','ch','sh','b','p','m','f','d','t','l','n','g','k','h','j','q','x','r','z','c','s','y','w'],
special_shengmu:['j','q','x','y'],
feijiemu:{
i:['ing','iu','ie','in'],
u:['ui','un'],
ü:['üe','ün'],
},
zhengtirendu:['zhi','chi','shi','ri','zi','ci','si'],
yunjiao:{
'一麻':['a','ia','ua'],
'二波':['o','e','uo'],
'三皆':['ie','üe'],
'四开':['ai','uai'],
'五微':['ei','ui'],
'六豪':['ao','iao'],
'七尤':['ou','iu'],
'八寒':['an','ian','uan','üan'],
'九文':['en','in','un','ün'],
'十唐':['ang','iang','uang'],
'十一庚':['eng','ing','ong','ung'],
'十二齐':['i','er','ü'],
'十三支':['-i'],
'十四姑':['u'],
},
}
},
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;
}
},
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.window.classList.add('low_performance');
}
else{
ui.window.classList.remove('low_performance');
}
}
},
compatiblemode:{
name:'兼容模式',
init:false,
intro:'开启兼容模式可防止扩展使游戏卡死并提高对旧扩展的兼容性,但对游戏速度有一定影响,若无不稳定或不兼容的扩展建议关闭',
onclick:function(bool){
game.saveConfig('compatiblemode',bool);
if(bool){
ui.window.classList.add('compatiblemode');
}
else{
ui.window.classList.remove('compatiblemode');
}
}
},
confirm_exit:{
name:'确认退出',
init:false,
unfrequent:true,
intro:'离开游戏前弹出确认对话框',
},
keep_awake:{
name:'屏幕常亮',
init:false,
unfrequent:true,
intro:'防止屏幕自动关闭
注:旧版本通过NoSleep.js实现的屏幕常亮可能会影响外置音频的音量',
onclick:function(bool){
game.saveConfig('keep_awake',bool);
if(bool){
if(window.plugins&&window.plugins.insomnia) window.plugins.insomnia.keepAwake();
else if(window.noSleep){
document.addEventListener(lib.config.touchscreen?'touchend':'click', function enableNoSleepX() {
document.removeEventListener(lib.config.touchscreen?'touchend':'click', enableNoSleepX, false);
window.noSleep.enable();
}, false);
}
}
else{
if(window.plugins&&window.plugins.insomnia) window.plugins.insomnia.allowSleepAgain();
else if(window.noSleep) window.noSleep.disable();
}
}
},
auto_confirm:{
name:'自动确认',
init:true,
unfrequent:true,
intro:'当候选目标只有1个时,点击目标后无需再点击确认',
},
skip_shan:{
name:'无闪自动取消',
init:false,
unfrequent:true,
intro:'当自己需要使用或打出【闪】时,若自己没有【闪】,则跳过该步骤',
},
unauto_choose:{
name:'拆顺手牌选择',
init:false,
unfrequent:true,
intro:'拆牌或者顺牌时,就算只能选择对方的手牌依然手动选择',
},
wuxie_self:{
name:'不无懈自己',
init:true,
unfrequent:true,
intro:'自己使用的单目标普通锦囊即将生效时,不询问无懈',
},
tao_enemy:{
name:'不对敌方出桃',
init:false,
intro:'双方阵营明确的模式中(如对决),敌方角色濒死时不询问出桃',
unfrequent:true,
},
enable_drag:{
name:'启用拖拽',
init:true,
intro:'按住卡牌后可将卡牌拖至目标',
unfrequent:true,
},
enable_dragline:{
name:'拖拽指示线',
init:true,
unfrequent:true,
intro:'拖拽时显示虚线,可能降低游戏速度',
},
enable_touchdragline:{
name:'拖拽指示线',
init:false,
unfrequent:true,
intro:'拖拽时显示虚线,可能降低游戏速度',
},
// enable_pressure:{
// name:'启用压感',
// init:false,
// intro:'开启后可通过按压执行操作',
// unfrequent:true,
// },
// pressure_taptic:{
// name:'触觉反馈',
// init:false,
// intro:'开启后按压操作执行时将产生震动',
// unfrequent:true,
// },
// pressure_click:{
// name:'按压操作',
// init:'pause',
// intro:'在空白区域按压时的操作',
// unfrequent:true,
// item:{
// pause:'暂停',
// config:'选项',
// auto:'托管',
// }
// },
touchscreen:{
name:'触屏模式',
init:false,
restart:true,
unfrequent:true,
intro:'开启后可使触屏设备反应更快,但无法使用鼠标操作',
onclick:function(bool){
if(get.is.nomenu('touchscreen',bool)) return false;
game.saveConfig('touchscreen',bool);
}
},
swipe:{
name:'滑动手势',
init:true,
unfrequent:true,
intro:'在非滚动区域向四个方向滑动可执行对应操作',
},
swipe_down:{
name:'下划操作',
init:'menu',
unfrequent:true,
intro:'向下滑动时执行的操作',
item:{
system:'显示按钮',
menu:'打开菜单',
pause:'切换暂停',
auto:'切换托管',
chat:'显示聊天',
off:'关闭',
},
onclick:function(item){
if(get.is.nomenu('swipe_down',item)) return false;
game.saveConfig('swipe_down',item);
}
},
swipe_up:{
name:'上划操作',
intro:'向上滑动时执行的操作',
init:'auto',
unfrequent:true,
item:{
system:'显示按钮',
menu:'打开菜单',
pause:'切换暂停',
auto:'切换托管',
chat:'显示聊天',
off:'关闭',
},
onclick:function(item){
if(get.is.nomenu('swipe_up',item)) return false;
game.saveConfig('swipe_up',item);
}
},
swipe_left:{
name:'左划操作',
intro:'向左滑动时执行的操作',
init:'system',
unfrequent:true,
item:{
system:'显示按钮',
menu:'打开菜单',
pause:'切换暂停',
auto:'切换托管',
chat:'显示聊天',
off:'关闭',
},
onclick:function(item){
if(get.is.nomenu('swipe_left',item)) return false;
game.saveConfig('swipe_left',item);
}
},
swipe_right:{
name:'右划操作',
intro:'向右滑动时执行的操作',
init:'system',
unfrequent:true,
item:{
system:'显示按钮',
menu:'打开菜单',
pause:'切换暂停',
auto:'切换托管',
chat:'显示聊天',
off:'关闭',
},
onclick:function(item){
if(get.is.nomenu('swipe_right',item)) return false;
game.saveConfig('swipe_right',item);
}
},
round_menu_func:{
name:'触屏按钮操作',
intro:'点击屏幕中圆形按钮时执行的操作',
init:'system',
unfrequent:true,
item:{
system:'显示按钮',
menu:'打开菜单',
pause:'切换暂停',
auto:'切换托管'
},
onclick:function(item){
if(get.is.nomenu('round_menu_func',item)) return false;
game.saveConfig('round_menu_func',item);
},
},
show_splash:{
name:'显示开始界面',
intro:'游戏开始前进入模式选择画面',
init:'init',
item:{
off:'关闭',
init:'首次启动',
always:'保持开启',
}
},
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:'暂停',
shortcut:'工具',
config:'选项',
auto:'托管',
},
onclick:function(item){
if(get.is.nomenu('right_click',item)) return false;
game.saveConfig('right_click',item);
}
},
longpress_info:{
name:'长按显示信息',
init:true,
unfrequent:true,
restart:true,
intro:'长按后弹出菜单',
},
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秒',
}
},
doubleclick_intro:{
name:'双击显示武将资料',
init:true,
unfrequent:true,
intro:'双击武将头像后显示其资料卡',
},
video:{
name:'保存录像',
init:'20',
intro:'游戏结束后保存录像在最大条数,超过后将从最早的录像开始删除(已收藏的录像不计入条数)',
item:{
'0':'关闭',
'5':'五局',
'10':'十局',
'20':'二十局',
'50':'五十局',
'10000':'无限',
},
unfrequent:true,
},
max_loadtime:{
name:'最长载入时间',
intro:'设置游戏从启动到完成载入所需的最长时间,超过此时间未完成载入会报错,若设备较慢或安装了较多扩展可适当延长此时间',
init:'5000',
unfrequent:true,
item:{
5000:'5秒',
10000:'10秒',
20000:'20秒',
60000:'60秒'
},
onclick:function(item){
game.saveConfig('max_loadtime',item);
if(item=='5000'){
localStorage.removeItem(lib.configprefix+'loadtime');
}
else{
localStorage.setItem(lib.configprefix+'loadtime',item);
}
}
},
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
},
lucky_star:{
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,
},
fuck_sojson:{
name:'检测加密扩展',
init:false,
},
errstop:{
name:'出错时停止游戏',
init:false,
unfrequent:true
},
update_link:{
name:'更新地址',
init:'coding',
unfrequent:true,
item:{
coding:'Github Proxy',
github:'GitHub',
},
onclick:function(item){
game.saveConfig('update_link',item);
lib.updateURL=lib.updateURLS[item]||lib.updateURLS.coding;
},
},
extension_source:{
name:'获取扩展地址',
init:'Coding',
unfrequent:true,
item:{},
intro:function(){
return '获取在线扩展时的地址。当前地址:
'+lib.config.extension_sources[lib.config.extension_source];
},
onclick:function(item){
game.saveConfig('extension_source',item);
},
},
extension_create:{
name:'添加获取扩展地址',
clear:true,
unfrequent:true,
onclick:function(){
game.prompt('请输入地址名称',function(str){
if(str){
var map=lib.config.extension_sources;
game.prompt('请输入'+str+'的地址',function(str2){
if(str2){
delete map[str];
map[str]=str2;
game.saveConfig('extension_sources',map);
game.saveConfig('extension_source',str);
var nodexx=ui.extension_source;
nodexx.updateInner();
var nodeyy=nodexx._link.menu;
var nodezz=nodexx._link.config;
for(var i=0;i');
}
},
onclick:function(theme){
game.saveConfig('theme',theme);
ui.arena.hide();
lib.init.background();
if(lib.config.autostyle){
if(theme=='simple'){
lib.configMenu.appearence.config.player_border.onclick('slim');
}
else{
lib.configMenu.appearence.config.player_border.onclick('normal');
}
}
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:'手杀',
nova:'新版'
},
visualMenu:function(node,link){
node.className='button character themebutton '+lib.config.theme;
if(!node.created){
node.created=true;
node.style.overflow='hidden';
node.firstChild.style.display='none';
// node.firstChild.classList.add('shadowed');
// node.firstChild.style.width='16px';
// node.firstChild.style.height='auto';
// node.firstChild.style.padding='2px';
// node.firstChild.style.textAlign='center';
var me=ui.create.div(node);
me.style.top='auto';
if(link=='default'||link=='newlayout'){
me.style.width='calc(100% - 6px)';
me.style.left='3px';
me.style.bottom='3px';
me.style.height='25px';
if(link=='newlayout'){
me.style.height='23px';
me.style.bottom='4px';
}
}
else if(link=='long2'||link=='nova'){
me.style.display='none';
}
else{
me.style.width='120%';
me.style.left='-10%';
me.style.bottom='0';
me.style.height='22px';
}
me.style.borderRadius='2px';
var list=['re_caocao','re_liubei','sp_zhangjiao','sunquan'];
for(var i=0;i<4;i++){
var player=ui.create.div('.fakeplayer',node);
ui.create.div('.avatar',player).setBackground(list.randomRemove(),'character');
player.style.borderRadius='2px';
if(i!=3){
player.style.top='auto';
}
if(link=='default'){
player.style.height='19px';
player.style.width='38px';
player.classList.add('oldlayout')
}
else if(link=='mobile'||link=='newlayout'){
player.style.width='24px';
player.style.height='29px';
}
else if(link=='nova') {
player.style.width='20px';
player.style.height='24px';
}
else{
player.style.width='20px';
player.style.height='34px';
}
if(i==1){
player.style.left='3px';
}
if(i==2){
player.style.left='auto';
player.style.right='3px';
}
if(i==3){
player.style.top='3px';
}
if(link=='default'){
if(i==0){
player.style.bottom='6px';
}
if(i==0||i==3){
player.style.left='calc(50% - 18px)';
}
if(i==1||i==2){
player.style.bottom='36px';
}
}
else if(link=='newlayout'){
if(i==0){
player.style.bottom='1px';
}
if(i==0||i==3){
player.style.left='calc(50% - 12px)';
}
if(i==1||i==2){
player.style.bottom='32px';
}
}
else if(link=='mobile'){
if(i==0||i==3){
player.style.left='calc(50% - 12px)';
}
if(i==1||i==2){
player.style.bottom='30px';
}
}
else if(link=='long'){
if(i==0||i==3){
player.style.left='calc(50% - 10px)';
}
if(i==1||i==2){
player.style.bottom='45px';
}
}
else if(link=='long2'){
if(i==0){
player.style.bottom='2px';
player.style.left='3px';
}
if(i==3){
player.style.left='calc(50% - 10px)';
}
if(i==1||i==2){
player.style.bottom='45px';
}
}
else if(link=='nova'){
if(i==0){
player.style.bottom='2px';
player.style.left='3px';
}
if(i==3){
player.style.left='calc(50% - 10px)';
}
if(i==1||i==2){
player.style.left='3px';
player.style.bottom=(i*30)+'px';
}
}
if(i==0&&(link=='mobile'||link=='long')){
player.classList.add('me');
player.style.borderRadius='0px';
player.style.width='25px';
player.style.height='25px';
player.style.bottom='-3px';
player.style.left='-3px';
}
}
}
},
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;
}
},
player_height_nova:{
name:'角色高度',
init:'short',
item:{
// auto:'自动',
short:'矮',
default:'中',
long:'高',
},
onclick:function(item){
game.saveConfig('player_height_nova',item);
// if(item=='auto'){
// if(parseInt(ui.arena.dataset.number)>=7){
// ui.arena.dataset.player_height_nova='short';
// }
// else{
// ui.arena.dataset.player_height_nova='default';
// }
// }
// else{
ui.arena.dataset.player_height_nova=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%',
eebig:'150%',
eeebig:'180%',
eeeebig:'200%',
},
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.93;break;
case 'big':zoom=1.05;break;
case 'vbig':zoom=1.1;break;
case 'ebig':zoom=1.2;break;
case 'eebig':zoom=1.5;break;
case 'eeebig':zoom=1.8;break;
case 'eeeebig':zoom=2;break;
default:zoom=1;
}
game.documentZoom=game.deviceZoom*zoom;
ui.updatez();
if (Array.isArray(lib.onresize)) {
lib.onresize.forEach(fun => {
if (typeof fun == 'function') fun();
});
}
}
},
image_background:{
name:'游戏背景',
init:'default',
item:{},
visualBar:function(node,item,create){
if(node.created){
node.lastChild.classList.remove('active');
return;
}
node.created=true;
ui.create.filediv('.menubutton','添加背景',node,function(file){
if(file){
var name=file.name;
if(name.indexOf('.')!=-1){
name=name.slice(0,name.indexOf('.'));
}
var link=(game.writeFile?'cdv_':'custom_')+name;
if(item[link]){
for(var i=1;i<1000;i++){
if(!item[link+'_'+i]){
link=link+'_'+i;break;
}
}
}
item[link]=name;
var callback=function(){
create(link,node.parentNode.defaultNode);
node.parentNode.updateBr();
lib.config.customBackgroundPack.add(link);
game.saveConfig('customBackgroundPack',lib.config.customBackgroundPack);
};
if(game.writeFile){
game.writeFile(file,'image/background',link+'.jpg',callback);
}
else{
game.putDB('image',link,file,callback);
}
if(node.lastChild.classList.contains('active')){
editbg.call(node.lastChild);
}
}
}).inputNode.accept='image/*';
var editbg=function(){
this.classList.toggle('active');
var page=this.parentNode.parentNode;
for(var i=0;i4){
node.classList.add('hideadd');
button.classList.remove('transparent');
delete node.currentDB;
}
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
});
}
}).inputNode.accept='image/*';
deletepic=ui.create.div('.menubutton.deletebutton','删除图片',node,function(){
if(confirm('确定删除自定义图片?(此操作不可撤销)')){
game.deleteDB('image','hp_style1');
game.deleteDB('image','hp_style2');
game.deleteDB('image','hp_style3');
game.deleteDB('image','hp_style4');
for(var i=0;idiv:not(.lost){background-image:url('+fileLoadedEvent.target.result+')}');
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
game.getDB('image','hp_style2',function(fileToLoad){
if(!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent){
if(ui.css.hp_stylesheet2){
ui.css.hp_stylesheet2.remove();
}
ui.css.hp_stylesheet2=lib.init.sheet('.hp:not(.text):not(.actcount)[data-condition="mid"]>div:not(.lost){background-image:url('+fileLoadedEvent.target.result+')}');
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
game.getDB('image','hp_style3',function(fileToLoad){
if(!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent){
if(ui.css.hp_stylesheet3){
ui.css.hp_stylesheet3.remove();
}
ui.css.hp_stylesheet3=lib.init.sheet('.hp:not(.text):not(.actcount)[data-condition="low"]>div:not(.lost){background-image:url('+fileLoadedEvent.target.result+')}');
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
game.getDB('image','hp_style4',function(fileToLoad){
if(!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent){
if(ui.css.hp_stylesheet4){
ui.css.hp_stylesheet4.remove();
}
ui.css.hp_stylesheet4=lib.init.sheet('.hp:not(.text):not(.actcount)>.lost{background-image:url('+fileLoadedEvent.target.result+')}');
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
},
unfrequent:true,
},
player_style:{
name:'角色背景',
init:'default',
intro:'设置角色的背景图片',
item:{
wood:'木纹',
music:'音乐',
simple:'简约',
custom:'自定',
default:'默认',
},
visualBar:function(node,item,create,switcher){
if(node.created){
return;
}
var button;
for(var i=0;i.framebg{display:block;background-image:url("'+fileLoadedEvent.target.result+'")}',0);
ui.css.border_stylesheet.sheet.insertRule('.player>.count{z-index: 3 !important;border-radius: 2px !important;text-align: center !important;}',0);
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
else if(layout!='default'&&layout!='auto'){
ui.css.border_stylesheet=lib.init.sheet();
if(layout.indexOf('dragon_')==0){
layout=layout.slice(7);
ui.arena.dataset.framedecoration=layout;
}
else{
ui.arena.dataset.framedecoration='';
}
ui.css.border_stylesheet.sheet.insertRule('#window .player>.framebg,#window #arena.long.mobile:not(.fewplayer) .player[data-position="0"]>.framebg{display:block;background-image:url("'+lib.assetURL+'theme/style/player/'+layout+'1.png")}',0);
ui.css.border_stylesheet.sheet.insertRule('#window #arena.long:not(.fewplayer) .player>.framebg, #arena.oldlayout .player>.framebg{background-image:url("'+lib.assetURL+'theme/style/player/'+layout+'3.png")}',0);
ui.css.border_stylesheet.sheet.insertRule('.player>.count{z-index: 3 !important;border-radius: 2px !important;text-align: center !important;}',0);
}
},
unfrequent:true,
},
autoborder_count:{
name:'边框升级方式',
intro:'击杀 每击杀一人,边框提升两级
伤害 每造成两点伤害,边框提升一级
混合 击杀量决定边框颜色,伤害量决定边框装饰',
init:'kill',
item:{
kill:'击杀',
damage:'伤害',
mix:'混合',
},
unfrequent:true,
},
autoborder_start:{
name:'基础边框颜色',
init:'bronze',
item:{
bronze:'铜',
silver:'银',
gold:'金'
},
unfrequent:true
},
player_border:{
name:'边框宽度',
init:'normal',
intro:'设置角色的边框宽度',
unfrequent:true,
item:{
slim:'细',
narrow:'窄',
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');
}
if(item=='narrow'){
ui.arena.classList.add('mslim_player');
}
else{
ui.arena.classList.remove('mslim_player');
}
if(item=='normal'&&lib.config.mode!='brawl'&&(game.layout=='long'||game.layout=='long2')){
ui.arena.classList.add('lslim_player');
}
else{
ui.arena.classList.remove('lslim_player');
}
ui.window.dataset.player_border=item;
}
},
menu_style:{
name:'菜单背景',
init:'default',
item:{
wood:'木纹',
music:'音乐',
simple:'简约',
custom:'自定',
default:'默认',
},
visualBar:function(node,item,create,switcher){
if(node.created){
return;
}
var button;
for(var i=0;i.dialog.popped,html .menu,html .menubg{background-image:url("'+fileLoadedEvent.target.result+'");background-size:cover}');
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
else if(layout!='default'){
var str='';
switch(layout){
case 'wood':str='url("'+lib.assetURL+'theme/woodden/wood2.png")';break;
case 'music':str='linear-gradient(#4b4b4b, #464646);color:white;text-shadow:black 0 0 2px';break;
case 'simple':str='linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4));color:white;text-shadow:black 0 0 2px';break;
}
ui.css.menu_stylesheet=lib.init.sheet('html #window>.dialog.popped,html .menu,html .menubg{background-image:'+str+'}');
}
},
unfrequent:true,
},
control_style:{
name:'按钮背景',
init:'default',
item:{
wood:'木纹',
music:'音乐',
simple:'简约',
custom:'自定',
default:'默认',
},
visualBar:function(node,item,create,switcher){
if(node.created){
return;
}
var button;
for(var i=0;idiv>div{background-image:url("'+fileLoadedEvent.target.result+'")}');
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
else if(layout!='default'){
var str='';
switch(layout){
case 'wood':str='url("'+lib.assetURL+'theme/woodden/wood.jpg")';break;
case 'music':str='linear-gradient(#4b4b4b, #464646);color:white;text-shadow:black 0 0 2px';break;
case 'simple':str='linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4));color:white;text-shadow:black 0 0 2px';break;
}
if(layout=='wood'){
ui.css.control_stylesheet=lib.init.sheet('#window .control,#window .menubutton,#window #system>div>div,#window #system>div>.pressdown2{background-image:'+str+'}');
}
else{
ui.css.control_stylesheet=lib.init.sheet('#window .control,.menubutton:not(.active):not(.highlight):not(.red):not(.blue),#window #system>div>div{background-image:'+str+'}');
}
}
},
unfrequent:true,
},
custom_button:{
name:'自定义按钮高度',
init:false,
unfrequent:true,
onclick:function(bool){
if(bool!=='skip'){
game.saveConfig('custom_button',bool);
}
if(ui.css.buttonsheet){
ui.css.buttonsheet.remove();
}
if(lib.config.custom_button){
var cbnum1=6+(parseInt(lib.config.custom_button_system_top)||0);
var cbnum2=6+(parseInt(lib.config.custom_button_system_bottom)||0);
var cbnum3=3+(parseInt(lib.config.custom_button_control_top)||0);
var cbnum4=3+(parseInt(lib.config.custom_button_control_bottom)||0);
var cbnum5=2;
var cbnum6=2;
if(cbnum3<0){
cbnum5+=cbnum3;
cbnum3=0;
}
if(cbnum4<0){
cbnum6+=cbnum4;
cbnum4=0;
}
ui.css.buttonsheet=lib.init.sheet(
'#system>div>div, .caption>div>.tdnode{padding-top:'+cbnum1+'px !important;padding-bottom:'+cbnum2+'px !important}',
'#control>.control>div{padding-top:'+cbnum3+'px;padding-bottom:'+cbnum4+'px}',
'#control>.control{padding-top:'+cbnum5+'px;padding-bottom:'+cbnum6+'px}'
);
}
}
},
custom_button_system_top:{
name:'菜单上部高度',
init:'0x',
item:{
'-5x':'-5px',
'-4x':'-4px',
'-3x':'-3px',
'-2x':'-2px',
'-1x':'-1px',
'0x':'默认',
'1x':'1px',
'2x':'2px',
'3x':'3px',
'4x':'4px',
'5x':'5px',
},
unfrequent:true,
onclick:function(item){
game.saveConfig('custom_button_system_top',item);
lib.configMenu.appearence.config.custom_button.onclick('skip');
}
},
custom_button_system_bottom:{
name:'菜单下部高度',
init:'0x',
item:{
'-5x':'-5px',
'-4x':'-4px',
'-3x':'-3px',
'-2x':'-2px',
'-1x':'-1px',
'0x':'默认',
'1x':'1px',
'2x':'2px',
'3x':'3px',
'4x':'4px',
'5x':'5px',
},
unfrequent:true,
onclick:function(item){
game.saveConfig('custom_button_system_bottom',item);
lib.configMenu.appearence.config.custom_button.onclick('skip');
}
},
custom_button_control_top:{
name:'技能上部高度',
init:'0x',
item:{
'-5x':'-5px',
'-4x':'-4px',
'-3x':'-3px',
'-2x':'-2px',
'-1x':'-1px',
'0x':'默认',
'1x':'1px',
'2x':'2px',
'3x':'3px',
'4x':'4px',
'5x':'5px',
},
unfrequent:true,
onclick:function(item){
game.saveConfig('custom_button_control_top',item);
lib.configMenu.appearence.config.custom_button.onclick('skip');
}
},
custom_button_control_bottom:{
name:'技能下部高度',
init:'0x',
item:{
'-5x':'-5px',
'-4x':'-4px',
'-3x':'-3px',
'-2x':'-2px',
'-1x':'-1px',
'0x':'默认',
'1x':'1px',
'2x':'2px',
'3x':'3px',
'4x':'4px',
'5x':'5px',
},
unfrequent:true,
onclick:function(item){
game.saveConfig('custom_button_control_bottom',item);
lib.configMenu.appearence.config.custom_button.onclick('skip');
}
},
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;
}
},
glow_phase:{
name:'当前回合角色高亮',
unfrequent:true,
init:'yellow',
intro:'设置当前回合角色的边框颜色',
item:{
none:'无',
yellow:'黄色',
green:'绿色',
purple:'紫色',
},
onclick:function(bool){
game.saveConfig('glow_phase',bool);
lib.init.cssstyles();
}
},
fold_card:{
name:'折叠手牌',
init:true,
unfrequent:true,
},
fold_mode:{
name:'折叠模式菜单',
intro:'关闭后模式菜单中“更多”内的项目将直接展开',
init:true,
unfrequent:true,
},
seperate_control:{
name:'分离选项条',
init:true,
unfrequent:true,
intro:'开启后玩家在进行选择时不同的选项将分开,而不是连在一起',
},
blur_ui:{
name:'模糊效果',
intro:'在暂停或打开菜单时开启模糊效果',
init:false,
unfrequent:true,
onclick:function(bool){
game.saveConfig('blur_ui',bool);
if(bool){
ui.window.classList.add('blur_ui');
}
else{
ui.window.classList.remove('blur_ui');
}
}
},
glass_ui:{
name:'玻璃主题',
intro:'为游戏主题打开玻璃效果(手机暂不支持)',
init:false,
unfrequent:true,
onclick:function(bool){
game.saveConfig('glass_ui',bool);
if(bool){
ui.window.classList.add('glass_ui');
}
else{
ui.window.classList.remove('glass_ui');
}
}
},
damage_shake:{
name:'伤害抖动',
intro:'角色受到伤害时的抖动效果',
init:true,
unfrequent:true,
},
button_press:{
name:'按钮效果',
intro:'选项条被按下时将有按下效果',
init:true,
unfrequent:true,
},
jiu_effect:{
name:'喝酒效果',
init:true,
unfrequent:true,
},
animation:{
name:'游戏特效',
intro:'开启后出现属性伤害、回复体力等情况时会显示动画',
init:false,
unfrequent:true,
},
skill_animation_type:{
name:'技能特效',
intro:'开启后觉醒技、限定技将显示全屏文字',
init:'default',
unfrequent:true,
item:{
default:'默认',
old:'旧版',
off:'关闭'
}
},
die_move:{
name:'阵亡效果',
intro:'阵亡后武将的显示效果',
init:'flip',
unfrequent:true,
item:{
off:'关闭',
move:'移动',
flip:'翻面',
}
},
target_shake:{
name:'目标效果',
intro:'一名玩家成为卡牌或技能的目标时的显示效果',
init:'off',
item:{
off:'关闭',
zoom:'缩放',
shake:'抖动',
},
unfrequent:true,
onclick:function(bool){
game.saveConfig('target_shake',bool);
ui.arena.dataset.target_shake=bool;
}
},
turned_style:{
name:'翻面文字',
intro:'角色被翻面时显示“翻面”',
init:true,
unfrequent:true,
onclick:function(bool){
game.saveConfig('turned_style',bool);
if(bool){
ui.arena.classList.remove('hide_turned');
}
else{
ui.arena.classList.add('hide_turned');
}
}
},
link_style2:{
name:'横置样式',
intro:'设置角色被横置时的样式',
init:'chain',
unfrequent:true,
item:{
chain:'铁索',
rotate:'横置',
mark:'标记'
},
onclick:function(style){
var list=[];
for(var i=0;i'+
''+
'',
clear:true,
},
background_audio:{
name:'游戏音效',
init:true,
},
background_speak:{
name:'人物配音',
init:true,
},
equip_audio:{
name:'装备配音',
init:false,
},
repeat_audio:{
name:'播放重复语音',
init:false,
},
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;
}
},
clear_background_music:{
name:'清除自定义背景音乐',
clear:true,
onclick:function(){
if(confirm('是否清除已导入的所有自定义背景音乐?(该操作不可撤销!)')){
for(var i in lib.config.customBackgroundMusic){
lib.config.all.background_music.remove(i);
if(i.indexOf('cdv_')==0){
game.removeFile('audio/background/'+i+'.mp3');
}
else{
game.deleteDB('audio',i);
}
}
lib.config.customBackgroundMusic=null;
game.saveConfig('customBackgroundMusic',null);
game.saveConfig('background_music','music_off');
if(!_status._aozhan) game.playBackgroundMusic();
}
},
},
}
},
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');
}
else{
map[i].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_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_game:{
name:'重置游戏设置',
onclick:function(){
var node=this;
if(node._clearing){
var noname_inited=localStorage.getItem('noname_inited');
var onlineKey=localStorage.getItem(lib.configprefix+'key');
localStorage.clear();
if(noname_inited){
localStorage.setItem('noname_inited',noname_inited);
}
if(onlineKey){
localStorage.setItem(lib.configprefix+'key',onlineKey);
}
game.deleteDB('config');
game.deleteDB('data');
game.reload();
return;
}
node._clearing=true;
node.firstChild.innerHTML='单击以确认 (3)';
setTimeout(function(){
node.firstChild.innerHTML='单击以确认 (2)';
setTimeout(function(){
node.firstChild.innerHTML='单击以确认 (1)';
setTimeout(function(){
node.firstChild.innerHTML='重置游戏设置';
delete node._clearing;
},1000);
},1000);
},1000);
},
clear:true
},
reset_hiddenpack:{
name:'重置隐藏内容',
onclick:function(){
if(this.firstChild.innerHTML!='已重置'){
this.firstChild.innerHTML='已重置'
game.saveConfig('hiddenModePack',[]);
game.saveConfig('hiddenCharacterPack',[]);
game.saveConfig('hiddenCardPack',[]);
game.saveConfig('hiddenPlayPack',[]);
game.saveConfig('hiddenBackgroundPack',[]);
var that=this;
setTimeout(function(){
that.firstChild.innerHTML='重置隐藏内容';
setTimeout(function(){
if(confirm('是否重新启动使改变生效?')){
game.reload();
}
});
},500);
}
},
clear:true
},
reset_tutorial:{
name:'重置新手向导',
onclick:function(){
if(this.firstChild.innerHTML!='已重置'){
this.firstChild.innerHTML='已重置'
game.saveConfig('new_tutorial',false);
game.saveConfig('prompt_hidebg');
game.saveConfig('prompt_hidepack');
var that=this;
setTimeout(function(){
that.firstChild.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;
var export_data=function(data){
game.export(lib.init.encode(JSON.stringify(data)),'无名杀 - 数据 - '+(new Date()).toLocaleString());
}
if(!lib.db){
data={};
for(var i in localStorage){
if(i.indexOf(lib.configprefix)==0){
data[i]=localStorage[i];
}
}
export_data(data);
}
else{
game.getDB('config',null,function(data1){
game.getDB('data',null,function(data2){
export_data({
config:data1,
data:data2
});
});
});
}
},
clear:true
},
redownload_game:{
name:'重新下载游戏',
onclick:function(){
var node=this;
if(node._clearing){
localStorage.removeItem('noname_inited');
game.reload();
return;
}
node._clearing=true;
node.firstChild.innerHTML='单击以确认 (3)';
setTimeout(function(){
node.firstChild.innerHTML='单击以确认 (2)';
setTimeout(function(){
node.firstChild.innerHTML='单击以确认 (1)';
setTimeout(function(){
node.firstChild.innerHTML='重新下载游戏';
delete node._clearing;
},1000);
},1000);
},1000);
},
clear:true
},
update:function(config,map){
if(lib.device||lib.node){
map.redownload_game.show();
}
else{
map.redownload_game.hide();
}
}
// 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(get.mode()!='identity'||!_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(get.mode()!='identity'||!_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')&&get.mode()=='identity'){
if(!ui.continue_game&&_status.over&&!_status.brawl&&!game.no_continue_game){
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')&&get.mode()=='identity'){
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')&&get.mode()=='identity'){
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':'十',
},
},
limit_zhu:{
name:'常备主候选武将数',
init:'group',
restart:true,
item:{
off:'不限制',
group:'按势力筛选',
'4':'四',
'6':'六',
'8':'八',
},
},
choice_zhong:{
name:'忠臣候选武将数',
init:'4',
restart:true,
item:{
'3':'三',
'4':'四',
'5':'五',
'6':'六',
'8':'八',
'10':'十',
},
},
choice_nei:{
name:'内奸候选武将数',
init:'5',
restart:true,
item:{
'3':'三',
'4':'四',
'5':'五',
'6':'六',
'8':'八',
'10':'十',
},
},
choice_fan:{
name:'反贼候选武将数',
init:'3',
restart:true,
item:{
'3':'三',
'4':'四',
'5':'五',
'6':'六',
'8':'八',
'10':'十',
},
},
}
},
guozhan:{
name:'国战',
connect:{
connect_guozhan_mode:{
name:'游戏模式',
init:'normal',
item:{
normal:'势备',
yingbian:'应变',
old:'怀旧',
},
frequent:true,
restart:true,
intro:'势备:默认模式,使用线下《君临天下·势备篇》的牌堆进行游戏。
应变:使用OL的应变国战牌堆进行游戏。
怀旧:使用传统国战的牌堆进行游戏。',
},
connect_player_number:{
name:'游戏人数',
init:'8',
item:{
'3':'三人',
'4':'四人',
'5':'五人',
'6':'六人',
'7':'七人',
'8':'八人'
},
frequent:true,
restart:true,
},
connect_initshow_draw:{
name:'首亮奖励',
item:{
'off':'关闭',
'draw':'摸牌',
'mark':'标记',
},
init:'mark',
frequent:true,
intro:'第一个明置武将牌的角色可获得首亮奖励'
},
connect_aozhan:{
name:'鏖战模式',
init:true,
intro:'若开启此选项,则将在游戏中引入“鏖战模式”的规则:
当游戏中仅剩四名或更少角色时(七人以下游戏时改为三名或更少),若此时全场没有超过一名势力相同的角色,则从一个新的回合开始,游戏进入鏖战模式直至游戏结束。
◇在鏖战模式下,【桃】只能当做【杀】或【闪】使用或打出,不能用来回复体力。
注:进入鏖战模式后,即使之后有两名或者更多势力相同的角色出现,仍然不会取消鏖战模式。',
frequent:true,
restart:true,
},
connect_viewnext:{
name:'观看下家副将',
init:false,
intro:'若开启此选项,所有的玩家将在挑选武将后,分发起始手牌之前,分别观看自己下家的副将。',
},
connect_zhulian:{
name:'珠联璧合',
init:true,
// frequent:true,
intro:'主将和副将都明置后,若为特定组合,可获得【珠联璧合】标记'
},
connect_junzhu:{
name:'替换君主',
init:true,
// frequent:true,
restart:true,
intro:'若开启此选项,玩家的第一个回合开始时,若其主武将牌有对应的君主武将牌,则其可以将此武将牌替换为对应的君主武将牌,然后重新调整体力上限。若玩家的体力上限因此增大,则玩家回复等量的体力。'
},
connect_change_card:{
name:'启用手气卡',
init:false,
frequent:true,
restart:true,
},
// 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();
}
ui.aozhan_bgm=map.aozhan_bgm;
map.aozhan_bgm._link.config.updatex.call(map.aozhan_bgm,[]);
},
guozhan_mode:{
name:'游戏模式',
init:'normal',
item:{
normal:'势备',
yingbian:'应变',
old:'怀旧',
free:'自由',
},
frequent:true,
restart:true,
intro:'势备:默认模式,使用线下《君临天下·势备篇》的牌堆进行游戏。
应变:使用OL的应变国战牌堆进行游戏。
怀旧:使用传统国战的牌堆进行游戏。
自由:使用玩家的自定义牌堆进行游戏。',
},
player_number:{
name:'游戏人数',
init:'8',
item:{
'3':'三人',
'4':'四人',
'5':'五人',
'6':'六人',
'7':'七人',
'8':'八人'
},
frequent:true,
restart:true,
},
initshow_draw:{
name:'首亮奖励',
item:{
'off':'关闭',
'draw':'摸牌',
'mark':'标记',
},
init:'mark',
frequent:true,
intro:'第一个明置身份牌的角色可获得摸牌奖励'
},
aozhan:{
name:'鏖战模式',
init:true,
frequent:true,
restart:true,
intro:'若开启此选项,则将在游戏中引入“鏖战模式”的规则:
当游戏中仅剩四名或更少角色时(七人以下游戏时改为三名或更少),若此时全场没有超过一名势力相同的角色,则从一个新的回合开始,游戏进入鏖战模式直至游戏结束。
◇在鏖战模式下,【桃】只能当做【杀】或【闪】使用或打出,不能用来回复体力。
注:进入鏖战模式后,即使之后有两名或者更多势力相同的角色出现,仍然不会取消鏖战模式。',
},
viewnext:{
name:'观看下家副将',
init:false,
intro:'若开启此选项,所有的玩家将在挑选武将后,分发起始手牌之前,分别观看自己下家的副将。',
},
aozhan_bgm:{
updatex:function(){
this.lastChild.innerHTML=this._link.config.item[lib.config.mode_config.guozhan.aozhan_bgm];
if(!Array.isArray(_status.aozhanBGMToRemove)) return;
const menu=this._link.menu;
for(let i=0;i1v1',
},
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_cards_four:{
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,
restart:true,
},
four_phaseswap:{
name:'代替队友行动',
init:false,
restart:true,
},
two_assign:{
name:'代替队友选将',
init:false,
restart:true,
},
two_phaseswap:{
name:'代替队友行动',
init:false,
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;
}
}
},
fouralign:{
name:'自由选择阵型',
init:false
},
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;
if(_status.mode=='four'){
if(get.config('four_assign')||get.config('four_phaseswap')) return;
if(bool){
if(_status.event.parent.addSetting){
_status.event.parent.addSetting();
}
}
else{
var seats=_status.event.parent.seatsbutton;
if(seats){
while(seats.length){
seats.shift().remove();
}
delete _status.event.parent.seatsbutton;
}
}
}
else{
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:'最后行动的角色起始手牌+1'
},
replace_character_two:{
name:'替补模式',
init:false,
frequent:true,
intro:'每个额外选择一名武将,死亡后用该武将代替重新上场,替补武将用完时失败'
},
expand_dialog:{
name:'默认展开选将框',
intro:'选将框打开时直接显示全部武将(可能使游戏在开始时卡顿)',
init:false,
},
siguo_character:{
name:'专属武将出场率',
init:'increase',
item:{
increase:'大概率',
normal:'默认概率',
off:'不出现',
},
frequent:true
},
// 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.firstChild.innerHTML='重置天梯数据';
delete node._clearing;
return;
}
node.firstChild.innerHTML='单击以确认 (3)';
node._clearing=setTimeout(function(){
node.firstChild.innerHTML='单击以确认 (2)';
node._clearing=setTimeout(function(){
node.firstChild.innerHTML='单击以确认 (1)';
node._clearing=setTimeout(function(){
node.firstChild.innerHTML='重置天梯数据';
delete node._clearing;
},1000);
},1000);
},1000);
},
clear:true,
},
edit_character_three:{
name:'编辑统率将池',
clear:true,
onclick:function(){
if(get.mode()!='versus'){
alert('请进入对决模式,然后再编辑将池');
return;
}
var container=ui.create.div('.popup-container.editor');
var editorpage=ui.create.div(container);
var discardConfig=ui.create.div('.editbutton','取消',editorpage,function(){
ui.window.classList.remove('shortcutpaused');
ui.window.classList.remove('systempaused');
container.delete(null);
delete window.saveNonameInput;
});
var node=container;
var map=get.config('character_three')||lib.choiceThree;
var str='character=[\n ';
for(var i=0;i请不要轻易勾选此项!',
},
}
},
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,
// },
}
},
doudizhu:{
name:'斗地主',
connect:{
update:function(config,map){
if(config.connect_doudizhu_mode=='online'){
map.connect_change_card.hide();
}
else{
map.connect_change_card.show();
}
if(config.connect_doudizhu_mode!='normal'){
map.connect_double_character.hide();
}
else{
map.connect_double_character.show();
}
},
connect_doudizhu_mode:{
name:'游戏模式',
init:'normal',
item:{
normal:'休闲',
kaihei:'开黑',
huanle:'欢乐',
binglin:'兵临',
online:'智斗',
},
restart:true,
frequent:true,
},
connect_double_character:{
name:'双将模式',
init:false,
frequent:true,
restart:true,
},
connect_change_card:{
name:'启用手气卡',
init:false,
frequent:true,
restart:true,
},
},
config:{
update:function(config,map){
if(config.doudizhu_mode=='online'){
map.change_card.hide();
map.edit_character.show();
map.reset_character.show();
}
else{
map.change_card.show();
map.edit_character.hide();
map.reset_character.hide();
}
if(config.doudizhu_mode!='normal'){
map.double_character.hide();
map.free_choose.hide();
map.change_identity.hide();
map.change_choice.hide();
map.continue_game.hide();
map.dierestart.hide();
map.choice_zhu.hide();
map.choice_fan.hide();
map.revive.hide();
}
else{
map.double_character.show();
map.free_choose.show();
map.change_identity.show();
map.change_choice.show();
map.continue_game.show();
map.dierestart.show();
map.choice_zhu.show();
map.choice_fan.show();
map.revive.show();
}
if(config.double_character&&config.doudizhu_mode=='normal'){
map.double_hp.show();
}
else{
map.double_hp.hide();
}
},
doudizhu_mode:{
name:'游戏模式',
init:'normal',
item:{
normal:'休闲',
kaihei:'开黑',
huanle:'欢乐',
binglin:'兵临',
online:'智斗',
},
restart:true,
frequent:true,
},
double_character:{
name:'双将模式',
init:false,
frequent:true,
restart:true,
},
double_hp:{
name:'双将体力上限',
init:'pingjun',
item:{
hejiansan:'和减三',
pingjun:'平均值',
zuidazhi:'最大值',
zuixiaozhi:'最小值',
zonghe:'相加',
},
restart:true,
},
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&&!game.no_continue_game){
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;
}
}
},
choice_zhu:{
name:'地主候选武将数',
init:'3',
restart:true,
item:{
'3':'三',
'4':'四',
'5':'五',
'6':'六',
'8':'八',
'10':'十',
},
},
choice_fan:{
name:'农民候选武将数',
init:'3',
restart:true,
item:{
'3':'三',
'4':'四',
'5':'五',
'6':'六',
'8':'八',
'10':'十',
},
},
edit_character:{
name:'编辑将池',
clear:true,
onclick:function(){
if(get.mode()!='doudizhu'){
alert('请进入斗地主模式,然后再编辑将池');
return;
}
var container=ui.create.div('.popup-container.editor');
var editorpage=ui.create.div(container);
var discardConfig=ui.create.div('.editbutton','取消',editorpage,function(){
ui.window.classList.remove('shortcutpaused');
ui.window.classList.remove('systempaused');
container.delete(null);
delete window.saveNonameInput;
});
var node=container;
var map=get.config('character_online')||lib.characterOnline;
node.code='character='+get.stringify(map)+'\n/*\n 这里是智斗三国模式的武将将池。\n 您可以在这里编辑对武将将池进行编辑,然后点击“保存”按钮即可保存。\n 将池中的Key势力武将,仅同时在没有被禁用的情况下,才会出现在选将框中。\n 而非Key势力的武将,只要所在的武将包没有被隐藏,即可出现在选将框中。\n 该将池为单机模式/联机模式通用将池。在这里编辑后,即使进入联机模式,也依然会生效。\n 但联机模式本身禁用的武将(如神貂蝉)不会出现在联机模式的选将框中。\n*/';
ui.window.classList.add('shortcutpaused');
ui.window.classList.add('systempaused');
var saveInput=function(){
var code;
if(container.editor){
code=container.editor.getValue();
}
else if(container.textarea){
code=container.textarea.value;
}
try{
var character=null;
eval(code);
if(!get.is.object(character)){
throw('err');
}
var groups=[];
for(var i in character){
if(!Array.isArray(character[i])) throw('type');
if(character[i].length>=3) groups.push(i);
}
if(groups.length<3) throw('enough');
}
catch(e){
if(e=='type'){
alert('请严格按照格式填写,不要写入不为数组的数据');
}
else if(e=='enough'){
alert('请保证至少写入了3个势力,且每个势力至少有3个武将');
}
else if(e=='err'){
alert('代码格式有错误,请对比示例代码仔细检查');
}
else{
alert('代码语法有错误,请仔细检查('+e+')')
}
return;
}
game.saveConfig('character_online',character,'doudizhu');
ui.window.classList.remove('shortcutpaused');
ui.window.classList.remove('systempaused');
container.delete();
container.code=code;
delete window.saveNonameInput;
};
window.saveNonameInput=saveInput;
var saveConfig=ui.create.div('.editbutton','保存',editorpage,saveInput);
var editor=ui.create.div(editorpage);
if(node.aced){
ui.window.appendChild(node);
node.editor.setValue(node.code,1);
}
else if(lib.device=='ios'){
ui.window.appendChild(node);
if(!node.textarea){
var textarea=document.createElement('textarea');
editor.appendChild(textarea);
node.textarea=textarea;
lib.setScroll(textarea);
}
node.textarea.value=node.code;
}
else{
var aceReady=function(){
ui.window.appendChild(node);
var mirror = window.CodeMirror(editor, {
value:node.code,
mode:"javascript",
lineWrapping:!lib.config.touchscreen&&lib.config.mousewheel,
lineNumbers:true,
indentUnit:4,
autoCloseBrackets:true,
theme:'mdn-like'
});
lib.setScroll(editor.querySelector('.CodeMirror-scroll'));
node.aced=true;
node.editor=mirror;
}
if(!window.ace){
lib.init.js(lib.assetURL+'game','codemirror',aceReady);
lib.init.css(lib.assetURL+'layout/default','codemirror');
}
else{
aceReady();
}
};
},
},
reset_character:{
name:'重置将池',
intro:'将智斗三国模式下的将池重置为默认将池',
clear:true,
onclick:function(){
if(confirm('该操作不可撤销!是否清除智斗三国模式的自定义将池,并将其重置为默认将池?')){
game.saveConfig('character_online',null,'doudizhu');
alert('将池已重置');
}
},
},
}
},
single:{
name:'单挑',
connect:{
connect_single_mode:{
name:'游戏模式',
init:'normal',
item:{
normal:'新1v1',
dianjiang:'点将单挑',
changban:'血战长坂坡',
},
restart:true,
frequent:true,
},
connect_enable_jin:{
name:'启用晋势力武将',
init:false,
restart:true,
frequent:true,
},
update:function(config,map){
if(config.connect_single_mode!='normal'){
map.connect_enable_jin.hide();
}
else{
map.connect_enable_jin.show();
}
},
},
config:{
single_mode:{
name:'游戏模式',
init:'normal',
item:{
normal:'新1v1',
dianjiang:'点将单挑',
changban:'血战长坂坡',
},
restart:true,
frequent:true,
},
enable_jin:{
name:'启用晋势力武将',
init:false,
restart:true,
frequent:true,
},
update:function(config,map){
if(config.single_mode!='normal'){
map.enable_jin.hide();
}
else{
map.enable_jin.show();
}
},
}
},
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_leader_allcharacter.show();
map.chess_character.hide();
}
else{
map.chess_leader_save.hide();
map.chess_leader_clear.hide();
map.chess_leader_allcharacter.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_allcharacter:{
name:'启用全部角色',
init:true,
onclick:function(bool){
if(confirm('调整该设置将清除所有进度,是否继续?')){
for(var i=1;i<6;i++) game.save('save'+i,null,'chess');
game.saveConfig('chess_leader_allcharacter',bool,'chess')
if(get.mode()=='chess') game.reload();
return;
}
else this.classList.toggle('on');
},
},
chess_leader_clear:{
name:'清除进度',
onclick:function(){
var node=this;
if(node._clearing){
for(var i=1;i<6;i++) game.save('save'+i,null,'chess');
game.reload();
return;
}
node._clearing=true;
node.firstChild.innerHTML='单击以确认 (3)';
setTimeout(function(){
node.firstChild.innerHTML='单击以确认 (2)';
setTimeout(function(){
node.firstChild.innerHTML='单击以确认 (1)';
setTimeout(function(){
node.firstChild.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:'10',
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:{
huanhuazhizhan:{
name:'幻化之战',
init:true,
frequent:true
},
qunxionggeju:{
name:'群雄割据',
init:true,
frequent:true
},
duzhansanguo:{
name:'毒战三国',
init:true,
frequent:true
},
daozhiyueying:{
name:'导师月英',
init:true,
frequent:true
},
weiwoduzun:{
name:'唯我独尊',
init:true,
frequent:true
},
tongxingzhizheng:{
name:'同姓之争',
init:true,
frequent:true
},
jiazuzhizheng:{
name:'家族之争',
init:true,
frequent:true
},
tongqueduopao:{
name:'铜雀夺袍',
init:true,
frequent:true
},
tongjiangmoshi:{
name:'同将模式',
init:true,
frequent:true
},
baiyidujiang:{
name:'白衣渡江',
init:true,
frequent:true
},
qianlidanji:{
name:'千里单骑',
init:true,
frequent:true
},
liangjunduilei:{
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.connectMode) return;
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.connectMode) return;
if(!_status.event.getParent().showConfig&&!_status.event.showConfig) return;
if(!ui.cheat2&&get.config('free_choose')) ui.create.cheat2();
else if(ui.cheat2&&!get.config('free_choose')){
ui.cheat2.close();
delete ui.cheat2;
}
},
},
change_choice:{
name:'开启换将卡',
init:true,
onclick:function(bool){
game.saveConfig('change_choice',bool,this._link.config.mode);
if(_status.connectMode) return;
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,
reload:0,
delayed:0,
frameId:0,
videoId:0,
globalId:0,
},
help:{
'关于游戏':'关于无名杀
- 无名杀官方发布地址仅有GitHub仓库!
点击前往Github仓库
- 无名杀基于GPLv3开源协议。
点击查看GPLv3协议
- 其他所有的所谓“无名杀”社群(包括但不限于绝大多数“官方”QQ群、QQ频道等)均为玩家自发组织,与无名杀官方无关!',
'游戏操作':'
- 长按/鼠标悬停/右键单击显示信息。
- 触屏模式中,双指点击切换暂停;下划显示菜单,上划切换托管。
- 键盘快捷键
'+
' - 编辑牌堆
在卡牌包中修改牌堆后,将自动创建一个临时牌堆,在所有模式中共用,当保存当前牌堆后,临时牌堆被清除。每个模式可设置不同的已保存牌堆,设置的牌堆优先级大于临时牌堆。
',
'游戏命令':'变量名
- 场上角色
game.players - 阵亡角色
game.dead'+
' - 玩家
game.me - 玩家的上/下家
game.me.previous/next'+
' - 玩家的上/下家(含阵亡)
game.me.previousSeat/
nextSeat'+
' - 牌堆
ui.cardPile - 弃牌堆
ui.discardPile
'+
'角色属性
- 体力值
player.hp'+
' - 体力上限
player.maxHp - 身份
player.identity - 手牌
player.getCards("h") - 装备牌
player.getCards("e") - 判定牌
player.getCards("j")'+
' - 是否存活/横置/翻面
player.isAlive()/
isLinked()/
isTurnedOver()
'+
'角色操作
- 受到伤害
player.damage(source,
num)'+
' - 回复体力
player.recover(num) - 摸牌
player.draw(num) - 获得牌
player.gain(cards) - 弃牌
player.discard(cards)'+
' - 使用卡牌
player.useCard(card,
targets) - 死亡
player.die() - 复活
player.revive(hp)
'+
'游戏操作
- 在命令框中输出结果
game.print(str) - 清除命令框中的内容
cls - 上一条/下一条输入的内容
up/down - 游戏结束
game.over(bool)'+
' - 角色资料
lib.character - 卡牌资料
lib.card
',
'游戏名词':'- 智囊:无名杀默认为过河拆桥/无懈可击/无中生有/洞烛先机。牌堆中没有的智囊牌会被过滤。可在卡牌设置中自行增减。若没有可用的智囊,则改为随机选取的三种锦囊牌的牌名。'+
'
- 仁库:部分武将使用的游戏外共通区域。至多包含六张牌。当有新牌注入后,若牌数超过上限,则将最早进入仁库的溢出牌置入弃牌堆。'+
'
- 护甲:和体力类似,每点护甲可抵挡一点伤害,但不影响手牌上限。'+
'
- 随从:通过技能获得,拥有独立的技能、手牌区和装备区(共享判定区),出场时替代主武将的位置;随从死亡时自动切换回主武将。'+
'
- 发现:从三张随机亮出的牌中选择一张,若无特殊说明,则获得此牌。'+
'
- 蓄能技:发动时可以增大黄色的数字。若如此做,红色数字于技能的结算过程中改为原来的两倍。'+
'
- 施法:若技能的拥有者未拥有等待执行的同名“施法”效果,则其可以发动“施法”技能。其须选择声明一个数字X(X∈[1, 3]),在此之后的第X个回合结束时,其执行“施法”效果,且效果中的数字X视为与技能发动者声明的X相同。'+
'
- 共同拼点:一种特殊的拼点结算。发起者与被指定的拼点目标同时亮出拼点牌,进行一次决算:其中拼点牌点数唯一最大的角色赢,其他角色均没赢;若没有点数唯一最大的拼点牌,则所有角色拼点均没赢。'+
'
- 强令:若一名角色拥有带有“强令”的技能,则该技能的发动时机为“出牌阶段开始时”。若技能拥有者发动该技能,其须发布“强令”给一名其他角色,并在对应技能的时间节点加以判断目标角色是否成功完成该强令所要求的任务条件。成功或失败则会根据技能效果执行不同结算流程。'+
'
- 摧坚:若一名角色拥有带有“摧坚”的技能,则该技能的发动时机为“当你使用伤害牌指定第一个目标后”。你可以对其中一个目标发动“摧坚”技能,然后执行后续效果。其中,后续效果里的X等于该目标的非charlotte技能的数量。'+
'
- 妄行:一种特殊的选项。若一名角色拥有带有“妄行”的技能,则该技能触发时,你须选择声明一个数字X(X∈{1,2,3,4}),技能后续中的X即为你选择的数字。选择完毕后,你获得如下效果:回合结束时,你选择一项:1.弃置X张牌;2.减1点体力上限。'+
'
- 搏击:若一名角色拥有带有“搏击”的技能,则当该搏击技能触发时,若本次技能的目标角色在你攻击范围内,且你在其攻击范围内,则你执行技能主体效果时,同时额外执行“搏击”后的额外效果。'+
'
- 游击:若一名角色拥有带有“游击”的技能,则当该游击技能执行至“游击”处时,若本次技能的目标角色在你的攻击范围内,且你不在其攻击范围内,则你可以执行“游击”后的额外效果。'+
''
},
setIntro:function(node,func,left){
if(lib.config.touchscreen){
if(left){
node.listen(ui.click.touchintro);
}
else{
lib.setLongPress(node,ui.click.intro);
}
}
else{
if(left){
node.listen(ui.click.intro);
}
if(lib.config.hover_all){
lib.setHover(node,ui.click.hoverplayer);
}
if(lib.config.right_info){
node.oncontextmenu=ui.click.rightplayer;
}
}
// if(!left){
// lib.setPressure(node,ui.click.rightpressure);
// }
if(func){
node._customintro=func;
}
},
// setPressure:function(node,func){
// if(window.Pressure){
// window.Pressure.set(node,{change: func}, {polyfill: false});
// }
// },
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.marginLeft='14px';
dialog._place_text.style.marginRight='14px';
dialog._place_text.style.textAlign='left';
dialog._place_text.style.width='calc(100% - 28px)';
}
}
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;
},
setMousewheel:function(node){
if(lib.config.mousewheel) node.onmousewheel=ui.click.mousewheel;
},
setLongPress:function(node,func){
node.addEventListener('touchstart',ui.click.longpressdown);
node.addEventListener('touchend',ui.click.longpresscancel);
node._longpresscallback=func;
return node;
},
updateCanvas:function(time){
if(lib.canvasUpdates.length===0){
lib.status.canvas=false;
return false;
}
ui.canvas.width=ui.arena.offsetWidth;
ui.canvas.height=ui.arena.offsetHeight;
var ctx=ui.ctx;
ctx.shadowBlur=5;
ctx.shadowColor='rgba(0,0,0,0.3)';
ctx.strokeStyle='white';
// ctx.lineCap='round';
ctx.lineWidth=3;
ctx.save();
for(var i=0;i Object.keys(lib.characterPack[pack]).contains(name));
if(pack) nameinfo=lib.characterPack[pack][name];
}
else if(name.indexOf('::')!=-1){
name=name.split('::');
modeimage=name[0];
name=name[1];
}
}
if(!modeimage&&nameinfo&&nameinfo[4]){
for(var i=0;i0) top+='+ '+position[1]+'px)';
else top+='- '+Math.abs(position[1])+'px)';
var left='calc('+position[2]+'% ';
if(position[3]>0) left+='+ '+position[3]+'px)';
else left+='- '+Math.abs(position[3])+'px)';
this.style.top=top;
this.style.left=left;
return this;
};
HTMLDivElement.prototype.css=function(style){
for(var i in style){
if(i=='innerHTML'){
this.innerHTML=style[i];
}
else{
this.style[i]=style[i];
}
}
return this;
};
HTMLTableElement.prototype.get=function(row,col){
if(rowthis.length){
num=this.length;
}
var arr=this.slice(0);
var list=[];
for(var i=0;i>> 0;
if (len === 0) {
return false;
}
var n = fromIndex | 0;
var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
function sameValueZero(x, y) {
return x === y || (typeof x === 'number' && typeof y === 'number' && isNaN(x) && isNaN(y));
}
while (k < len) {
if (sameValueZero(o[k], searchElement)) {
return true;
}
k++;
}
return false;
}
});
}
if(!('flat' in Array.prototype)){
Object.defineProperty(Array.prototype, "flat", {
configurable:true,
enumerable:false,
writable:true,
value:function(depth){
if(typeof depth!='number') depth=1;
const arr=[];
for(let i=0;i0&&Array.isArray(obj)){
obj.flat(depth-1).forEach(function(item){
arr.push(item)
});
}
else{
arr.push(obj);
}
}
return arr;
}
});
}
if(!Array.from){
Object.defineProperty(Array, "from", {
configurable:true,
enumerable:false,
writable:true,
value:function(args){
const list=[];
if(args&&args.length){
for(let i=0;i.dialog.popped:not(.static)');
for(var i=0;i{
const font=pack.font[value];
appearenceConfig.name_font.item[value]=font;
appearenceConfig.identity_font.item[value]=font;
appearenceConfig.cardtext_font.item[value]=font;
appearenceConfig.global_font.item[value]=font;
fontSheet.insertRule(`@font-face {font-family: '${value}'; src: local('${font}'), url('${lib.assetURL}font/${value}.ttf');}`,0);
if(suitsFont) fontSheet.insertRule(`@font-face {font-family: '${value}'; src: local('${font}'), url('${lib.assetURL}font/suits.ttf');}`,0);
});
if(suitsFont) fontSheet.insertRule(`@font-face {font-family: 'Suits'; src: local('Noname Suit'), url('${lib.assetURL}font/suits.ttf');}`,0);
appearenceConfig.cardtext_font.item.default='默认';
appearenceConfig.global_font.item.default='默认';
}
var ua=navigator.userAgent.toLowerCase();
if('ontouchstart' in document){
if(!lib.config.totouched){
game.saveConfig('totouched',true);
if(lib.device){
game.saveConfig('low_performance',true);
game.saveConfig('confirm_exit',true);
game.saveConfig('touchscreen',true);
game.saveConfig('fold_mode',false);
if(ua.indexOf('ipad')==-1){
game.saveConfig('phonelayout',true);
}
else if(lib.device=='ios'){
game.saveConfig('show_statusbar_ios','overlay');
}
}
else if(confirm('是否切换到触屏模式?(触屏模式可提高触屏设备的响应速度,但无法使用鼠标)')){
game.saveConfig('touchscreen',true);
if(ua.indexOf('iphone')!=-1||ua.indexOf('android')!=-1){
game.saveConfig('phonelayout',true);
}
game.reload();
}
}
}
else if(lib.config.touchscreen){
game.saveConfig('touchscreen',false);
}
if(!lib.config.toscrolled&&ua.indexOf('macintosh')!=-1){
game.saveConfig('toscrolled',true);
game.saveConfig('mousewheel',false);
}
var show_splash=lib.config.show_splash;
if(show_splash=='off'){
show_splash=false;
}
else if(show_splash=='init'){
if(localStorage.getItem('show_splash_off')){
show_splash=false;
}
}
localStorage.removeItem('show_splash_off');
var extensionlist=[];
if(!localStorage.getItem(lib.configprefix+'disable_extension')){
if(lib.config.extensions&&lib.config.extensions.length){
window.resetExtension=function(){
for(var i=0;i.framebg,#window #arena.long.mobile:not(.fewplayer) .player[data-position="0"]>.framebg{display:block;background-image:url("'+lib.assetURL+'theme/style/player/'+bstyle+'1.png")}',0);
ui.css.border_stylesheet.sheet.insertRule('#window #arena.long:not(.fewplayer) .player>.framebg, #arena.oldlayout .player>.framebg{background-image:url("'+lib.assetURL+'theme/style/player/'+bstyle+'3.png")}',0);
ui.css.border_stylesheet.sheet.insertRule('.player>.count{z-index: 3 !important;border-radius: 2px !important;text-align: center !important;}',0);
}
if(lib.config.control_style&&lib.config.control_style!='default'&&lib.config.control_style!='custom'){
var str='';
switch(lib.config.control_style){
case 'wood':str='url("'+lib.assetURL+'theme/woodden/wood.jpg")';break;
case 'music':str='linear-gradient(#4b4b4b, #464646);color:white;text-shadow:black 0 0 2px';break;
case 'simple':str='linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4));color:white;text-shadow:black 0 0 2px';break;
}
if(lib.config.control_style=='wood'){
ui.css.control_stylesheet=lib.init.sheet('#window .control,#window .menubutton,#window #system>div>div,#window #system>div>.pressdown2{background-image:'+str+'}');
}
else{
ui.css.control_stylesheet=lib.init.sheet('#window .control,.menubutton:not(.active):not(.highlight):not(.red):not(.blue),#window #system>div>div{background-image:'+str+'}');
}
}
if(lib.config.menu_style&&lib.config.menu_style!='default'&&lib.config.menu_style!='custom'){
var str='';
switch(lib.config.menu_style){
case 'wood':str='url("'+lib.assetURL+'theme/woodden/wood2.png")';break;
case 'music':str='linear-gradient(#4b4b4b, #464646);color:white;text-shadow:black 0 0 2px';break;
case 'simple':str='linear-gradient(rgba(0,0,0,0.4), rgba(0,0,0,0.4));color:white;text-shadow:black 0 0 2px';break;
}
ui.css.menu_stylesheet=lib.init.sheet('html #window>.dialog.popped,html .menu,html .menubg{background-image:'+str+'}');
}
lib.config.duration=500;
if(!lib.config.touchscreen){
document.addEventListener('mousewheel',ui.click.windowmousewheel,{passive:true});
document.addEventListener('mousemove',ui.click.windowmousemove);
document.addEventListener('mousedown',ui.click.windowmousedown);
document.addEventListener('mouseup',ui.click.windowmouseup);
document.addEventListener('contextmenu',ui.click.right);
}
else{
document.addEventListener('touchstart',ui.click.touchconfirm);
document.addEventListener('touchstart',ui.click.windowtouchstart);
document.addEventListener('touchend',ui.click.windowtouchend);
document.addEventListener('touchmove',ui.click.windowtouchmove);
}
};
var proceed2=function(){
if(config3){
proceed(config3);
}
else{
config3=true;
}
};
ui.css={menu:lib.init.css(lib.assetURL+'layout/default','menu',function(){
ui.css.default=lib.init.css(lib.assetURL+'layout/default','layout');
proceed2();
})};
if(lib.device){
lib.init.cordovaReady=function(){
if(lib.device=='android'){
document.addEventListener("pause", function(){
if(!_status.paused2&&(typeof _status.event.isMine=='function'&&!_status.event.isMine())){
ui.click.pause();
}
if(ui.backgroundMusic){
ui.backgroundMusic.pause();
}
});
document.addEventListener("resume", ()=>{
if(ui.backgroundMusic) Promise.resolve(ui.backgroundMusic.play()).catch(()=>void 0);
});
document.addEventListener("backbutton", function(){
if(ui.arena&&ui.arena.classList.contains('menupaused')){
if(window.saveNonameInput){
window.saveNonameInput();
}
else{
ui.click.configMenu();
}
}
else if(lib.config.confirm_exit){
navigator.notification.confirm(
'是否退出游戏?',
function(index){
switch(index){
case 2:game.saveConfig('null');game.reload();break;
case 3:navigator.app.exitApp();break;
}
},
'确认退出',
['取消','重新开始','退出']
);
}
else{
navigator.app.exitApp();
}
});
}
game.download=function(url,folder,onsuccess,onerror,dev,onprogress){
if(url.indexOf('http')!=0){
url=get.url(dev)+url;
}
var fileTransfer = new FileTransfer();
folder=lib.assetURL+folder;
if(onprogress){
fileTransfer.onprogress=function(progressEvent){
onprogress(progressEvent.loaded,progressEvent.total);
};
}
lib.config.brokenFile.add(folder);
game.saveConfigValue('brokenFile');
fileTransfer.download(encodeURI(url),encodeURI(folder),function(){
lib.config.brokenFile.remove(folder);
game.saveConfigValue('brokenFile');
if(onsuccess){
onsuccess();
}
},onerror);
};
game.readFile=function(filename,callback,onerror){
window.resolveLocalFileSystemURL(lib.assetURL,function(entry){
entry.getFile(filename,{},function(fileEntry){
fileEntry.file(function(fileToLoad){
var fileReader = new FileReader();
fileReader.onload = function(e){
callback(e.target.result);
};
fileReader.readAsArrayBuffer(fileToLoad, "UTF-8");
},onerror);
},onerror);
},onerror);
};
game.readFileAsText=function(filename,callback,onerror){
window.resolveLocalFileSystemURL(lib.assetURL,function(entry){
entry.getFile(filename,{},function(fileEntry){
fileEntry.file(function(fileToLoad){
var fileReader = new FileReader();
fileReader.onload = function(e){
callback(e.target.result);
};
fileReader.readAsText(fileToLoad, "UTF-8");
},onerror);
},onerror);
},onerror);
};
game.writeFile=function(data,path,name,callback){
game.ensureDirectory(path,function(){
if(Object.prototype.toString.call(data)=='[object File]'){
var fileReader = new FileReader();
fileReader.onload = function(e){
game.writeFile(e.target.result,path,name,callback);
};
fileReader.readAsArrayBuffer(data, "UTF-8");
}
else{
window.resolveLocalFileSystemURL(lib.assetURL+path,function(entry){
entry.getFile(name,{create:true},function(fileEntry){
fileEntry.createWriter(function(fileWriter){
fileWriter.onwriteend=callback;
fileWriter.write(data);
});
});
});
}
});
};
game.removeFile=function(dir,callback){
window.resolveLocalFileSystemURL(lib.assetURL,function(entry){
entry.getFile(dir,{},function(fileEntry){
fileEntry.remove();
if(callback){
callback();
}
});
});
};
game.getFileList=function(dir,callback){
var files=[],folders=[];
window.resolveLocalFileSystemURL(lib.assetURL+dir,function(entry){
var dirReader=entry.createReader();
var entries=[];
var readEntries=function(){
dirReader.readEntries(function(results){
if(!results.length){
entries.sort();
for(var i=0;i 10 ||
Math.abs(e.touches[0].clientY/game.documentZoom - this.startY) > 10) {
_status.dragged=true;
}
});
}
if(lib.config.image_background.indexOf('custom_')==0){
ui.background.style.backgroundImage="none";
game.getDB('image',lib.config.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");
});
}
if(lib.config.card_style=='custom'){
game.getDB('image','card_style',function(fileToLoad){
if(!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent){
if(ui.css.card_stylesheet){
ui.css.card_stylesheet.remove();
}
ui.css.card_stylesheet=lib.init.sheet('.card:not(*:empty){background-image:url('+fileLoadedEvent.target.result+')}');
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
if(lib.config.cardback_style=='custom'){
game.getDB('image','cardback_style',function(fileToLoad){
if(!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent){
if(ui.css.cardback_stylesheet){
ui.css.cardback_stylesheet.remove();
}
ui.css.cardback_stylesheet=lib.init.sheet('.card:empty,.card.infohidden{background-image:url('+fileLoadedEvent.target.result+')}');
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
game.getDB('image','cardback_style2',function(fileToLoad){
if(!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent){
if(ui.css.cardback_stylesheet2){
ui.css.cardback_stylesheet2.remove();
}
ui.css.cardback_stylesheet2=lib.init.sheet('.card.infohidden:not(.infoflip){background-image:url('+fileLoadedEvent.target.result+')}');
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
if(lib.config.hp_style=='custom'){
game.getDB('image','hp_style1',function(fileToLoad){
if(!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent){
if(ui.css.hp_stylesheet1){
ui.css.hp_stylesheet1.remove();
}
ui.css.hp_stylesheet1=lib.init.sheet('.hp:not(.text):not(.actcount)[data-condition="high"]>div:not(.lost){background-image:url('+fileLoadedEvent.target.result+')}');
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
game.getDB('image','hp_style2',function(fileToLoad){
if(!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent){
if(ui.css.hp_stylesheet2){
ui.css.hp_stylesheet2.remove();
}
ui.css.hp_stylesheet2=lib.init.sheet('.hp:not(.text):not(.actcount)[data-condition="mid"]>div:not(.lost){background-image:url('+fileLoadedEvent.target.result+')}');
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
game.getDB('image','hp_style3',function(fileToLoad){
if(!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent){
if(ui.css.hp_stylesheet3){
ui.css.hp_stylesheet3.remove();
}
ui.css.hp_stylesheet3=lib.init.sheet('.hp:not(.text):not(.actcount)[data-condition="low"]>div:not(.lost){background-image:url('+fileLoadedEvent.target.result+')}');
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
game.getDB('image','hp_style4',function(fileToLoad){
if(!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent){
if(ui.css.hp_stylesheet4){
ui.css.hp_stylesheet4.remove();
}
ui.css.hp_stylesheet4=lib.init.sheet('.hp:not(.text):not(.actcount)>.lost{background-image:url('+fileLoadedEvent.target.result+')}');
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
if(lib.config.player_style=='custom'){
ui.css.player_stylesheet=lib.init.sheet('#window .player{background-image:none;background-size:100% 100%;}');
game.getDB('image','player_style',function(fileToLoad){
if(!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent){
if(ui.css.player_stylesheet){
ui.css.player_stylesheet.remove();
}
ui.css.player_stylesheet=lib.init.sheet('#window .player{background-image:url("'+fileLoadedEvent.target.result+'");background-size:100% 100%;}');
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
if(lib.config.border_style=='custom'){
game.getDB('image','border_style',function(fileToLoad){
if(!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent){
if(ui.css.border_stylesheet){
ui.css.border_stylesheet.remove();
}
ui.css.border_stylesheet=lib.init.sheet();
ui.css.border_stylesheet.sheet.insertRule('#window .player>.framebg{display:block;background-image:url("'+fileLoadedEvent.target.result+'")}',0);
ui.css.border_stylesheet.sheet.insertRule('.player>.count{z-index: 3 !important;border-radius: 2px !important;text-align: center !important;}',0);
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
if(lib.config.control_style=='custom'){
game.getDB('image','control_style',function(fileToLoad){
if(!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent){
if(ui.css.control_stylesheet){
ui.css.control_stylesheet.remove();
}
ui.css.control_stylesheet=lib.init.sheet('#window .control,.menubutton:not(.active):not(.highlight):not(.red):not(.blue),#window #system>div>div{background-image:url("'+fileLoadedEvent.target.result+'")}');
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
if(lib.config.menu_style=='custom'){
game.getDB('image','menu_style',function(fileToLoad){
if(!fileToLoad) return;
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent){
if(ui.css.menu_stylesheet){
ui.css.menu_stylesheet.remove();
}
ui.css.menu_stylesheet=lib.init.sheet('html #window>.dialog.popped,html .menu,html .menubg{background-image:url("'+fileLoadedEvent.target.result+'");background-size:cover}');
};
fileReader.readAsDataURL(fileToLoad, "UTF-8");
});
}
var proceed2=function(){
var mode=lib.imported.mode;
var card=lib.imported.card;
var character=lib.imported.character;
var play=lib.imported.play;
delete window.game;
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(mode[lib.config.mode].element[i][j]);
}
else{
lib.element[i][j]=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]=mode[lib.config.mode].ai[i][j];
}
}
else{
ai[i]=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]=mode[lib.config.mode].ui[i][j];
}
}
else{
ui[i]=mode[lib.config.mode].ui[i];
}
}
for(i in mode[lib.config.mode].game){
game[i]=mode[lib.config.mode].game[i];
}
for(i in mode[lib.config.mode].get){
get[i]=mode[lib.config.mode].get[i];
}
lib.init.start=mode[lib.config.mode].start;
lib.init.startBefore=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.noname_character_rank;
delete window.noname_character_rank;
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]=(Array.isArray(mode[lib.config.mode][i]))?[]:{};
for(j in mode[lib.config.mode][i]){
lib[i][j]=mode[lib.config.mode][i][j];
}
}
if(typeof mode[lib.config.mode].init=='function'){
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'&&get.config('chess_leader_allcharacter')){
for(k in character[i][j]){
lib.hiddenCharacters.push(k);
}
}
else if(lib.config.mode!='boss'||i!='boss'){
continue;
}
}
if(Array.isArray(lib[j])&&Array.isArray(character[i][j])){
lib[j].addArray(character[i][j]);
continue;
}
for(k in character[i][j]){
if(j=='character'){
if(!character[i][j][k][4]){
character[i][j][k][4]=[];
}
if(character[i][j][k][4].contains('boss')||
character[i][j][k][4].contains('hiddenboss')){
lib.config.forbidai.add(k);
}
if(lib.config.forbidai_user&&lib.config.forbidai_user.contains(k)){
lib.config.forbidai.add(k);
}
for(var l=0;l.name,#arena .button.character>.name {font-family: '+(lib.config.name_font||'xinwei')+',xinwei}',0);
ui.css.styles.sheet.insertRule('#arena .player .identity>div {font-family: '+(lib.config.identity_font||'huangcao')+',xinwei}',0);
ui.css.styles.sheet.insertRule('.button.character.newstyle>.identity {font-family: '+(lib.config.identity_font||'huangcao')+',xinwei}',0);
if(lib.config.cardtext_font&&lib.config.cardtext_font!='default'){
ui.css.styles.sheet.insertRule('.card div:not(.info):not(.background) {font-family: '+lib.config.cardtext_font+';}',0);
}
if(lib.config.global_font&&lib.config.global_font!='default'){
ui.css.styles.sheet.insertRule('#window {font-family: '+lib.config.global_font+',xinwei}',0);
ui.css.styles.sheet.insertRule('#window #control{font-family: STHeiti,SimHei,Microsoft JhengHei,Microsoft YaHei,WenQuanYi Micro Hei,Suits,Helvetica,Arial,sans-serif}',0);
}
switch(lib.config.glow_phase){
case 'yellow':ui.css.styles.sheet.insertRule('#arena .player:not(.selectable):not(.selected).glow_phase {box-shadow: rgba(0, 0, 0, 0.3) 0 0 0 1px, rgb(217, 152, 62) 0 0 15px, rgb(217, 152, 62) 0 0 15px !important;}',0);break;
case 'green':ui.css.styles.sheet.insertRule('#arena .player:not(.selectable):not(.selected).glow_phase {box-shadow: rgba(0, 0, 0, 0.3) 0 0 0 1px, rgba(10, 155, 67, 1) 0 0 15px, rgba(10, 155, 67, 1) 0 0 15px !important;}',0);break;
case 'purple':ui.css.styles.sheet.insertRule('#arena .player:not(.selectable):not(.selected).glow_phase {box-shadow: rgba(0, 0, 0, 0.3) 0 0 0 1px, rgb(189, 62, 170) 0 0 15px, rgb(189, 62, 170) 0 0 15px !important;}',0);break;
}
},
layout:function(layout,nosave){
if(layout=='default') layout='mobile';
if(!nosave) game.saveConfig('layout',layout);
game.layout=layout;
ui.arena.hide();
setTimeout(function(){
if(game.layout=='default'){
ui.css.layout.href='';
}
else{
ui.css.layout.href=lib.assetURL+'layout/'+game.layout+'/layout.css';
}
if(game.layout=='mobile'||game.layout=='long'){
ui.arena.classList.add('mobile');
}
else{
ui.arena.classList.remove('mobile');
}
if(game.layout=='mobile'||game.layout=='long'||game.layout=='long2'||game.layout=='nova'){
if(game.me&&game.me.node.handcards2.childNodes.length){
while(game.me.node.handcards2.childNodes.length){
game.me.node.handcards1.appendChild(game.me.node.handcards2.firstChild);
}
}
}
if(game.layout=='default'){
ui.arena.classList.add('oldlayout');
}
else{
ui.arena.classList.remove('oldlayout');
}
if(lib.config.cardshape=='oblong'&&(game.layout=='long'||game.layout=='mobile'||game.layout=='long2'||game.layout=='nova')){
ui.arena.classList.add('oblongcard');
ui.window.classList.add('oblongcard');
}
else{
ui.arena.classList.remove('oblongcard');
ui.window.classList.remove('oblongcard');
}
//if(lib.config.textequip=='text'&&(game.layout=='long'||game.layout=='mobile')){
if(game.layout=='long'||game.layout=='mobile'){
ui.arena.classList.add('textequip');
}
else{
ui.arena.classList.remove('textequip');
}
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');
}
for(var i=0;i>6, 0x80 | cc&0x3f);
});
strUtf = strUtf.replace(
/[\u0800-\uffff]/g,function(c) {
var cc = c.charCodeAt(0);
return String.fromCharCode(0xe0 | cc>>12, 0x80 | cc>>6&0x3F, 0x80 | cc&0x3f);
});
return btoa(strUtf);
},
decode:function(str){
var strUtf=atob(str);
var strUni = strUtf.replace(
/[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g,function(c) {
var cc = ((c.charCodeAt(0)&0x0f)<<12) | ((c.charCodeAt(1)&0x3f)<<6) | ( c.charCodeAt(2)&0x3f);
return String.fromCharCode(cc);
});
strUni = strUni.replace(
/[\u00c0-\u00df][\u0080-\u00bf]/g,function(c){
var cc = (c.charCodeAt(0)&0x1f)<<6 | c.charCodeAt(1)&0x3f;
return String.fromCharCode(cc);
});
return strUni;
},
stringify:function(obj){
var str='{'
for(var i in obj){
str+='"'+i+'":'
if(Object.prototype.toString.call(obj[i])=='[object Object]'){
str+=lib.init.stringify(obj[i]);
}
else if(typeof obj[i]=='function'){
str+=obj[i].toString();
}
else{
str+=JSON.stringify(obj[i]);
}
str+=','
}
str+='}';
return str;
},
stringifySkill:function(obj){
var str='';
for(var i in obj){
str+=i+':'
if(Object.prototype.toString.call(obj[i])=='[object Object]'){
str+='{\n'+lib.init.stringifySkill(obj[i])+'}';
}
else if(typeof obj[i]=='function'){
str+=obj[i].toString().replace(/\t/g,'');
}
else{
str+=JSON.stringify(obj[i]);
}
str+=',\n'
}
return str;
}
},
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;
},
dy:function(){
var next=game.me.next;
for(var i=0;i<10;i++){
if(next.identity!='zhu'){
break;
}
next=next.next;
}
next.die();
},
x:function(){
var gl=function(dir,callback){
var files=[],folders=[];
dir='/Users/widget/Documents/extension/'+dir;
lib.node.fs.readdir(dir,function(err,filelist){
for(var i=0;i1){
for(var i=0;i0&&typeof arguments[i]=='number'){
for(var j=0;j{
'step 0'
game.log(player,'重铸了',cards);
if(typeof event.recastingLose=='function') event.recastingLostCards=event.recastingLose(player,cards);
'step 1'
event.trigger('recast');
'step 2'
if(typeof event.recastingGain!='function') return;
event.recastingGainedCards=event.recastingGain(player,cards);
if(get.itemtype(event.recastingGainedCards)=='card') event.recastingGainedCards=[event.recastingGainedCards];
'step 3'
event.result=[];
if(get.itemtype(event.recastingGainedCards)=='cards') event.result.addArray(event.recastingGainedCards);
if(get.itemtype(result.cards)=='card') event.result.push(result.cards);
else if(get.itemtype(result.cards)=='cards') event.result.addArray(result.cards);
if(get.itemtype(result)=='card') event.result.push(result);
else if(get.itemtype(result)=='cards') event.result.addArray(result);
},
//装备栏相关
disableEquip:function(){
'step 0'
event.cards=[];
event.num=0;
event.slotsx=[...new Set(event.slots)].sort();
if(!event.slots.length) event.finish();
'step 1'
var slot=event.slotsx[event.num];
var left=player.countEnabledSlot(slot),lose=Math.min(left,get.numOf(event.slots,slot));
if(lose<=0) event.goto(3);
else{
game.log(player,'废除了'+get.cnNumber(lose)+'个','#g'+get.translation(slot)+'栏');
if(!player.disabledSlots) player.disabledSlots={};
if(!player.disabledSlots[slot]) player.disabledSlots[slot]=0;
player.disabledSlots[slot]+=lose;
var cards=player.getEquips(slot).filter(card=>!event.cards.contains(card));
if(cards.length>0){
if(lose>=left){
event._result={bool:true,links:cards};
}
else if(cards.length>(left-lose)){
var source=event.source,num=(cards.length-(left-lose));
if(!source||!source.isIn()) source=player;
source.chooseButton([
'选择'+(player==source?'你':get.translation(player))+'的'+get.cnNumber(num)+'张'+get.translation(slot)+'牌置入弃牌堆',
cards,
],true,[1,num]).set('filterOk',function(){
var evt=_status.event;
return ui.selected.buttons.reduce(function(num,button){
return num+get.numOf(get.subtypes(button.link,false),evt.slot)
},0)==evt.required;
}).set('required',num).set('slot',slot)
}
else event.goto(3);
}
else event.goto(3)
}
'step 2'
if(result.bool) event.cards.addArray(result.links);
'step 3'
event.num++;
if(event.num0) player.loseToDiscardpile(cards);
}
},
enableEquip:function(){
if(!event.slots.length) return;
var slotsx=[...new Set(event.slots)].sort();
for(var slot of slotsx){
var lost=player.countDisabledSlot(slot),gain=Math.min(lost,get.numOf(event.slots,slot));
if(lost<=0) continue;
else{
game.log(player,'恢复了'+get.cnNumber(gain)+'个','#g'+get.translation(slot)+'栏');
if(!player.disabledSlots) player.disabledSlots={};
if(!player.disabledSlots[slot]) player.disabledSlots[slot]=0;
player.disabledSlots[slot]-=gain;
}
}
player.$syncDisable();
},
expandEquip:function(){
if(!event.slots.length) return;
var slotsx=[...new Set(event.slots)].sort();
for(var slot of slotsx){
var expand=get.numOf(event.slots,slot);
game.log(player,'获得了'+get.cnNumber(expand)+'个额外的','#g'+get.translation(slot)+'栏');
if(!player.expandedSlots) player.expandedSlots={};
if(!player.expandedSlots[slot]) player.expandedSlots[slot]=0;
player.expandedSlots[slot]+=expand;
}
player.$syncExpand();
},
//选择顶装备要顶的牌
replaceEquip:function(){
'step 0'
event.cards=[];
var types=get.subtypes(card,false);
if(types.length){
var info=get.info(card,false);
if(info.customSwap){
event.cards.addArray(player.getCards('e',function(card){
return info.customSwap(card);
}));
event.goto(4);
}
else{
event.num=0;
event.slots=types;
event.slotsx=[...new Set(event.slots)].sort();
}
}
else event.goto(4);
'step 1'
var slot=event.slotsx[event.num];
var left=player.countEquipableSlot(slot),lose=Math.min(left,get.numOf(event.slots,slot));
if(lose<=0) event.goto(3);
else{
var cards=player.getEquips(slot).filter(card=>{
return !event.cards.contains(card)&&lib.filter.canBeReplaced(card,player);
});
if(cards.length>0){
if(lose>=left){
event._result={bool:true,links:cards};
}
else if(cards.length>(left-lose)){
var source=event.source,num=(cards.length-(left-lose));
if(!source||!source.isIn()) source=player;
source.chooseButton([
'选择替换掉'+get.cnNumber(num)+'张'+get.translation(slot)+'牌',
cards,
],true,[1,num]).set('filterOk',function(){
var evt=_status.event;
return ui.selected.buttons.reduce(function(num,button){
return num+get.numOf(get.subtypes(button.link,false),evt.slot)
},0)==evt.required;
}).set('required',num).set('slot',slot)
}
else event.goto(3);
}
else event.goto(3)
}
'step 2'
if(result.bool) event.cards.addArray(result.links);
'step 3'
event.num++;
if(event.num0;
});
if(!event.targets.length) event.result={bool:false};
else{
var next=player.chooseCardOL(event.targets,get.translation(player)+'发起了议事,请选择展示的手牌',true).set('type','debate').set('source',player).set('ai',event.ai||function(card){
return Math.random();
}).set('aiCard',event.aiCard||function(target){
var hs=target.getCards('h');
return {bool:true,cards:[hs.randomGet()]};
});
next._args.remove('glow_result');
}
'step 1'
var red=[],black=[];
event.videoId=lib.status.videoId++;
for(var i=0;i红色,展示了',red.map(function(i){
return i[1];
}));
}
else game.log('#b无人','意见为红色');
if(black.length){
game.log(black.map(function(i){
return i[0];
}),'意见为','#g黑色',',展示了',black.map(function(i){
return i[1];
}));
}
else game.log('#b无人','意见为','#g黑色');
game.broadcastAll(function(name,id,redArgs,blackArgs){
var dialog=ui.create.dialog(name+'发起了议事','hidden','forcebutton');
dialog.videoId=id;
dialog.classList.add('scroll1');
dialog.classList.add('scroll2');
dialog.classList.add('fullwidth');
dialog.classList.add('fullheight');
dialog.buttonss=[];
var list=['意见为红色的角色','意见为黑色的角色']
for(var i=0;i'+list[i]+'');
var buttons=ui.create.div('.buttons',dialog.content);
dialog.buttonss.push(buttons);
buttons.classList.add('popup');
buttons.classList.add('guanxing');
}
var func=function(target){
if(target._tempTranslate) return target._tempTranslate;
var name=target.name;
if(lib.translate[name+'_ab']) return lib.translate[name+'_ab'];
return get.translation(name);
};
for(var i=0;ievent.black.length) opinion='red';
else if(event.red.length红色':'#g黑色');
else game.log(player,'本次发起的议事无结果');
event.result={
bool:true,
opinion:opinion,
red:event.red,
black:event.black,
targets:event.targets
}
'step 3'
if(event.callback){
var next=game.createEvent('debateCallback',false);
next.player=player;
next.debateResult=get.copy(event.result);
next.setContent(event.callback);
}
},
delay:function(){
game[event.name].apply(game,event._args)
},
chooseCooperationFor:function(){
'step 0'
var next=player.chooseButton([
'选择和'+get.translation(target)+'的协力方式',
[event.cardlist,'vcard'],
],true);
next.set('ai',event.ai||function(){
return Math.random();
});
'step 1'
if(result.bool){
player.cooperationWith(target,result.links[0][2].slice(12),event.reason);
}
},
chooseToPlayBeatmap:function(){
'step 0'
if(game.online) return;
if(_status.connectMode) event.time=lib.configOL.choose_timeout;
event.videoId=lib.status.videoId++;
//给其他角色看的演奏框
game.broadcastAll(function(player,id,beatmap){
if(_status.connectMode) lib.configOL.choose_timeout=(Math.ceil((beatmap.timeleap[beatmap.timeleap.length-1]+beatmap.speed*100+(beatmap.current||0))/1000)+5).toString();
if(player==game.me) return;
var str=get.translation(player)+'正在演奏《'+beatmap.name+'》...';
if(!_status.connectMode) str+='
(点击屏幕可以跳过等待AI操作)';
ui.create.dialog(str).videoId=id;
if(ui.backgroundMusic) ui.backgroundMusic.pause();
if(lib.config.background_audio){
if(beatmap.filename.indexOf('ext:')==0) game.playAudio('..','extension',beatmap.filename.slice(4),beatmap.name);
else game.playAudio('effect',beatmap.filename);
}
},player,event.videoId,event.beatmap);
'step 1'
var beatmap=event.beatmap;
if(event.isMine()){
var timeleap=beatmap.timeleap.slice(0);
var current=beatmap.current;
//获取两个音符的时间间隔
var getTimeout=function(){
var time=timeleap.shift();
var out=time-current;
current=time;
return out;
};
//初始化一堆变量
var score=0;
var added=timeleap.length;
var number_of_tracks=beatmap.number_of_tracks||6;
var custom_mapping=Array.isArray(beatmap.mapping);
var mapping=custom_mapping?beatmap.mapping.slice():beatmap.mapping;
var hitsound=beatmap.hitsound||'hitsound.wav';
if(hitsound.indexOf('ext:')==0) hitsound=lib.assetURL+'extension/'+hitsound.slice(4);
else hitsound=lib.assetURL+'audio/effect/'+hitsound;
var hitsound_audio=new Audio(hitsound);
hitsound_audio.volume=0.25;
var abs=1;
var node_pos=0;
if(custom_mapping){
node_pos=mapping.shift();
}
else if(mapping=='random'){
abs=get.rand(number_of_tracks);
node_pos=abs;
}
var combo=0;
var max_combo=0;
var nodes=[];
var roundmenu=false;
//隐藏菜单按钮
if(ui.roundmenu&&ui.roundmenu.display!='none'){
roundmenu=true;
ui.roundmenu.style.display='none';
}
if(ui.backgroundMusic) ui.backgroundMusic.pause();
var event=_status.event;
event.settleed=false;
//建个框框
var dialog=ui.create.dialog('forcebutton','hidden');
event.dialog=dialog;
event.dialog.textPrompt=event.dialog.add(''+(beatmap.prompt||'在音符滑条和底部判定区重合时点击屏幕!')+'
');
event.switchToAuto=function(){};
event.dialog.classList.add('fixed');
event.dialog.classList.add('scroll1');
event.dialog.classList.add('scroll2');
event.dialog.classList.add('fullwidth');
event.dialog.classList.add('fullheight');
event.dialog.classList.add('noupdate');
event.dialog.style.overflow='hidden';
//结束后操作
event.settle=function(){
if(event.settleed) return;
event.settleed=true;
//评分
var acc=Math.floor(score/(added*5)*100);
if(!Array.isArray(lib.config.choose_to_play_beatmap_accuracies)) lib.config.choose_to_play_beatmap_accuracies=[];
lib.config.choose_to_play_beatmap_accuracies.push(acc);
if(lib.config.choose_to_play_beatmap_accuracies.length>5) lib.config.choose_to_play_beatmap_accuracies.shift();
game.saveConfigValue("choose_to_play_beatmap_accuracies");
var rank;
if(acc==100) rank=['SS','metal'];
else if(acc>=94) rank=['S','orange'];
else if(acc>=87) rank=['A','wood'];
else if(acc>=80) rank=['B','water'];
else if(acc>=65) rank=['C','thunder'];
else rank=['D','fire'];
event.dialog.textPrompt.innerHTML='演奏结束!
最大连击数:'+max_combo+' 精准度:'+acc+'%
';
game.me.$fullscreenpop('演奏评级:'+rank[0]+'',null,null,false);
//返回结果并继续游戏
setTimeout(function(){
event._result={
bool:true,
accuracy:acc,
rank:rank,
};
event.dialog.close();
game.resume();
_status.imchoosing=false;
if(roundmenu) ui.roundmenu.style.display='';
if(ui.backgroundMusic) Promise.resolve(ui.backgroundMusic.play()).catch(()=>void 0);
hitsound_audio.remove();
},1000);
};
event.dialog.open();
//操作容差
var height=event.dialog.offsetHeight;
var width=event.dialog.offsetWidth;
var range1=(beatmap.range1||[90,110]);
var range2=(beatmap.range2||[93,107]);
var range3=(beatmap.range3||[96,104]);
var speed=(beatmap.speed||25);
//初始化底部的条子
var judger=ui.create.div('');
judger.style["background-image"]=(beatmap.judgebar_color||'linear-gradient(rgba(240, 235, 3, 1), rgba(230, 225, 5, 1))');
judger.style["border-radius"]='3px';
judger.style.position='absolute';
judger.style.opacity='0.3';
var heightj=Math.ceil(height*(beatmap.judgebar_height||0.1));
judger.style.height=heightj+'px';
judger.style.width=width+'px';
judger.style.left='0px';
judger.style.top=(height-heightj)+'px';
event.dialog.appendChild(judger);
//生成每个音符
var addNode=function(){
var node=ui.create.div('');
nodes.push(node);
node.style["background-image"]=(beatmap.node_color||'linear-gradient(rgba(120, 120, 240, 1), rgba(100, 100, 230, 1))');
node.style["border-radius"]='3px';
node.style.position='absolute';
node.style.height=Math.ceil(height/10)+'px';
node.style.width=Math.ceil(width/number_of_tracks)-10+'px';
node._position=get.utc();
event.dialog.appendChild(node);
node.style.left=Math.ceil(width*node_pos/number_of_tracks+5)+'px';
node.style.top='-'+(Math.ceil(height/10))+'px';
ui.refresh(node);
node.style.transition='all '+speed*110+'ms linear';
node.style.transform='translateY('+Math.ceil(height*1.1)+'px)';
node.timeout=setTimeout(function(){
if(nodes.contains(node)){
nodes.remove(node);
player.popup('Miss','fire',false);
if(player.damagepopups.length) player.$damagepop();
combo=0;
}
},speed*110);
if(custom_mapping){
node_pos=mapping.shift();
}
else if(mapping=='random'){
while(node_pos==abs){
node_pos=get.rand(number_of_tracks);
}
abs=node_pos;
}
else{
node_pos+=abs;
if(node_pos>number_of_tracks-1){
abs=-1;
node_pos=number_of_tracks-2;
}
else if(node_pos<0){
abs=1;
node_pos=1;
}
}
if(timeleap.length){
setTimeout(function(){
addNode();
},getTimeout());
}
else{
setTimeout(function(){
event.settle();
},speed*110+100)
}
}
//点击时的判断操作
var click=function(){
if(!nodes.length) return;
for(var node of nodes){
//用生成到点击的时间差来判断距离
var time=get.utc();
var top=(time-node._position)/speed;
if(top>range1[1]) continue;
else if(top=range3[0]&&top=range2[0]&&topvoid 0);
break;
}
};
document.addEventListener(lib.config.touchscreen?'touchstart':'mousedown',click);
game.pause();
game.countChoose();
setTimeout(function(){
if(lib.config.background_audio){
if(beatmap.filename.indexOf('ext:')==0) game.playAudio('..','extension',beatmap.filename.slice(4),beatmap.name);
else game.playAudio('effect',beatmap.filename);
}
},Math.floor(speed*100*(0.9+beatmap.judgebar_height))+beatmap.current);
setTimeout(function(){
addNode();
},getTimeout());
}
else if(event.isOnline()){
event.send();
}
else{
game.pause();
game.countChoose();
var settle=function(){
_status.imchoosing=false;
//Algorithm: Generate the random number range using the mean and the half standard deviation of accuracies of the player's last 5 plays
//算法:用玩家的上5次游玩的准确率的平均数和半标准差生成随机数范围
var choose_to_play_beatmap_accuracies=(lib.config.choose_to_play_beatmap_accuracies||[]).concat(Array.from({
length:6-(lib.config.choose_to_play_beatmap_accuracies||[]).length
},()=>get.rand(70,100)));
var mean=Math.round(choose_to_play_beatmap_accuracies.reduce((previousValue,currentValue)=>previousValue+currentValue)/choose_to_play_beatmap_accuracies.length);
var half_standard_deviation=Math.round(Math.sqrt(choose_to_play_beatmap_accuracies.reduce((previousValue,currentValue)=>previousValue+Math.pow(currentValue-mean,2),0))/2);
var acc=Math.min(Math.max(get.rand.apply(get,beatmap.aiAcc||[mean-half_standard_deviation-get.rand(0,half_standard_deviation),mean+half_standard_deviation+get.rand(0,half_standard_deviation)]),0),100);
var rank;
if(acc==100) rank=['SS','metal'];
else if(acc>=94) rank=['S','orange'];
else if(acc>=87) rank=['A','green'];
else if(acc>=80) rank=['B','water'];
else if(acc>=65) rank=['C','thunder'];
else rank=['D','fire'];
event._result={
bool:true,
accuracy:acc,
rank:rank,
};
if(event.dialog) event.dialog.close();
if(event.control) event.control.close();
game.resume();
};
var song_duration=beatmap.timeleap[beatmap.timeleap.length-1]+beatmap.speed*100+1000+(beatmap.current||0);
var settle_timeout=setTimeout(settle,song_duration);
if(!_status.connectMode) {
var skip_timeout;
var skip=()=>{
settle();
Array.from(ui.window.getElementsByTagName('audio')).forEach(value=>{
if(value.currentSrc.indexOf(beatmap.filename.indexOf('ext:')==0?beatmap.name:beatmap.filename)>-1) value.remove();
});
document.removeEventListener(lib.config.touchscreen?'touchend':'click',skip);
clearTimeout(settle_timeout);
clearTimeout(skip_timeout);
};
document.addEventListener(lib.config.touchscreen?'touchend':'click',skip);
skip_timeout=setTimeout(()=>document.removeEventListener(lib.config.touchscreen?'touchend':'click',skip),song_duration);
}
}
'step 2'
game.broadcastAll(function(id,time){
if(_status.connectMode) lib.configOL.choose_timeout=time;
var dialog=get.idDialog(id);
if(dialog){
dialog.close();
}
if(ui.backgroundMusic) Promise.resolve(ui.backgroundMusic.play()).catch(()=>void 0);
},event.videoId,event.time);
var result=event.result||result;
event.result=result;
},
chooseToMove:function(){
'step 0'
if(event.chooseTime&&_status.connectMode&&!game.online){
event.time=lib.configOL.choose_timeout;
game.broadcastAll(function(time){
lib.configOL.choose_timeout=time;
},event.chooseTime);
}
if(event.isMine()){
delete ui.selected.guanxing_button;
var list=event.list,filterMove=event.filterMove,filterOk=event.filterOk;
_status.imchoosing=true;
var event=_status.event;
event.settleed=false;
event.dialog=ui.create.dialog(event.prompt||'请选择要操作的牌','hidden','forcebutton');
event.switchToAuto=function(){
if(!filterOk(event.moved)){
if(!event.forced) event._result={bool:false};
else event._result='ai';
}
else{
event._result={
bool:true,
moved:event.moved,
};
}
event.dialog.close();
if(ui.confirm) ui.confirm.close();
game.resume();
_status.imchoosing=false;
setTimeout(function(){
ui.arena.classList.remove('choose-to-move');
},500);
};
event.dialog.classList.add('scroll1');
event.dialog.classList.add('scroll2');
event.dialog.classList.add('fullwidth');
if(list.length>1){
ui.arena.classList.add('choose-to-move');
event.dialog.classList.add('fullheight');
}
event.moved=[];
var buttonss=[];
event.buttonss=buttonss;
var updateButtons=function(){
for(var i of buttonss){
event.moved[i._link]=get.links(Array.from(i.childNodes));
if(i.textPrompt) i.previousSibling.innerHTML=(''+i.textPrompt(event.moved[i._link])+'
');
}
if(filterOk(event.moved)){
ui.create.confirm('o');
}
else{
if(!event.forced) ui.create.confirm('c');
else if(ui.confirm) ui.confirm.close();
}
};
var clickButtons=function(){
if(!ui.selected.guanxing_button) return;
if(ui.selected.guanxing_button.parentNode==this) return;
if(!filterMove(ui.selected.guanxing_button,this._link,event.moved)) return;
ui.selected.guanxing_button.classList.remove('glow2');
this.appendChild(ui.selected.guanxing_button);
delete ui.selected.guanxing_button;
updateButtons();
};
for(var i=0;i'+list[i][0]+'');
tex.classList.add('choosetomove');
var buttons=ui.create.div('.buttons',event.dialog.content,clickButtons);
buttonss.push(buttons);
buttons.classList.add('popup');
buttons.classList.add('guanxing');
buttons._link=i;
if(list[i][1]){
if(get.itemtype(list[i][1])=='cards'){
var cardsb=ui.create.buttons(list[i][1],'card',buttons);
if(list[i][2]&&typeof list[i][2]=='string'){
for(var ij of cardsb) ij.node.gaintag.innerHTML=get.translation(list[i][2]);
}
}
else if(list[i][1].length==2){
ui.create.buttons(list[i][1][0],list[i][1][1],buttons);
}
}
if(list[i][2]&&typeof list[i][2]=='function') buttons.textPrompt=list[i][2];
}
var tex=event.dialog.add('点击两张牌以交换位置;点击一张牌并点击其他区域以移动卡牌
');
tex.classList.add('choosetomove');
event.dialog.open();
updateButtons();
event.custom.replace.button=function(button){
var node=button.parentNode;
if(!buttonss.contains(node)) return;
if(!ui.selected.guanxing_button){
ui.selected.guanxing_button=button;
button.classList.add('glow2');
return;
}
if(ui.selected.guanxing_button==button){
button.classList.remove('glow2');
delete ui.selected.guanxing_button;
return;
}
if(!filterMove(button,ui.selected.guanxing_button,event.moved)) return;
var par1=ui.selected.guanxing_button.parentNode,ind1=ui.selected.guanxing_button.nextSibling,par2=button.parentNode,ind2=button.nextSibling;
ui.selected.guanxing_button.classList.remove('glow2');
par1.insertBefore(button,ind1);
par2.insertBefore(ui.selected.guanxing_button,ind2);
delete ui.selected.guanxing_button;
updateButtons();
}
event.custom.replace.confirm=function(bool){
if(bool) event._result={
bool:true,
moved:event.moved,
};
else event._result={bool:false};
event.dialog.close();
if(ui.confirm) ui.confirm.close();
game.resume();
_status.imchoosing=false;
setTimeout(function(){
ui.arena.classList.remove('choose-to-move');
},500);
};
game.pause();
game.countChoose();
event.choosing=true;
}
else if(event.isOnline()){
event.send();
}
else{
event.result='ai';
}
"step 1"
if(event.time) game.broadcastAll(function(time){
lib.configOL.choose_timeout=time;
},event.time);
var result=event.result||result;
if((!result||result=='ai'||(event.forced&&!result.bool))&&event.processAI){
var moved=event.processAI(event.list);
if(moved) result={
bool:true,
moved:moved,
}
else result={bool:false};
}
event.result=result;
},
showCharacter:function(){
'step 0'
event.trigger('showCharacterEnd');
'step 1'
event.trigger('showCharacterAfter');
if(get.mode()=='identity'&&player.isZhu) event.trigger('zhuUpdate');
},
removeCharacter:function(){
player.$removeCharacter(event.num);
},
chooseUseTarget:function(){
'step 0'
if(get.is.object(card)&&!event.viewAs) card.isCard=true;
if(cards&&get.itemtype(card)!='card'){
card=get.copy(card);
card.cards=cards.slice(0);
event.card=card;
}
if(!lib.filter.cardEnabled(card,player)||(event.addCount!==false&&!lib.filter.cardUsable(card,player))){
event.result={bool:false};
event.finish();
return;
}
var info=get.info(card);
var range;
if(!info.notarget){
var select=get.copy(info.selectTarget);
if(select==undefined){
range=[1,1];
}
else if(typeof select=='number') range=[select,select];
else if(get.itemtype(select)=='select') range=select;
else if(typeof select=='function') range=select(card,player);
game.checkMod(card,player,range,'selectTarget',player);
}
if(info.notarget||range[1]<=-1){
if(!info.notarget&&range[1]<=-1){
for(var i=0;i0;
};
}
}
else{
if(event.filterTarget){
var targets=game.filterPlayer(function(current){
return event.filterTarget(card,player,current);
});
if(targets.length6){
var cards=_status.renku.splice(0,_status.renku.length-6);
game.log(cards,'从仁库进入了弃牌堆');
game.cardsDiscard(cards).set('outRange',true).fromRenku=true;
}
game.updateRenku();
}
},
chooseToEnable:function(){
'step 0'
var list=[];
for(var i=1;i<=5;i++){
if(player.hasDisabledSlot(i)) list.push('equip'+i);
}
if(!list.length) event.finish();
else if(list.length==1){
event.list=list;
event._result={control:list[0]};
}
else{
var next=player.chooseControl(list);
next.set('prompt','请选择恢复一个装备栏');
if(!event.ai) event.ai=function(event,player,list){
return list.randomGet();
}
event.ai=event.ai(event.getParent(),player,list);
next.ai=function(){
return event.ai;
};
}
'step 1'
event.result={control:result.control};
player.enableEquip(result.control);
},
chooseToDisable:function(){
'step 0'
var list=[];
for(var i=1;i<=5;i++){
if(player.hasEnabledSlot(i)) list.push('equip'+i);
}
if(event.horse){
if(list.contains('equip3')&&list.contains('equip4')) list.push('equip3_4');
list.remove('equip3');
list.remove('equip4');
}
if(!list.length) event.finish();
else if(list.length==1){
event.list=list;
event._result={control:list[0]};
}
else{
list.sort();
event.list=list;
var next=player.chooseControl(list);
next.set('prompt','请选择废除一个装备栏');
if(!event.ai) event.ai=function(event,player,list){
return list.randomGet();
}
event.ai=event.ai(event.getParent(),player,list);
next.ai=function(){
return event.ai;
};
}
'step 1'
event.result={control:result.control};
if(result.control=='equip3_4'){
player.disableEquip(3,4);
}
else player.disableEquip(result.control);
},
swapEquip:function(){
"step 0"
game.log(player,'和',target,'交换了装备区中的牌')
event.cards=[player.getCards('e'),target.getCards('e')];
game.loseAsync({
player:player,
target:target,
cards1:event.cards[0],
cards2:event.cards[1],
}).setContent('swapHandcardsx');
"step 1"
for(var i=0;igame.players.length*num&&game.showIdentity){
if(!_status.video) player.popup('显示身份');
_status.identityShown=true;
game.showIdentity(false);
}
}
player.ai.tempIgnore=[];
if(ui.land&&ui.land.player==player){
game.addVideo('destroyLand');
ui.land.destroy();
}
'step 1'
event.trigger('phaseBeginStart');
},
toggleSubPlayer:function(){
'step 0'
var list=event.list||player.storage.subplayer.skills.slice(0);
list.remove(player.storage.subplayer.name2);
event.list=list;
if(!event.directresult){
if(list.length>1){
var dialog=ui.create.dialog('更换一个随从','hidden');
dialog.add([list,'character']);
player.chooseButton(dialog,true);
}
else if(list.length==1){
event.directresult=list[0];
}
else{
event.finish();
}
}
else{
if(!list.contains(event.directresult)){
event.finish();
}
}
'step 1'
if(!event.directresult){
if(result&&result.bool&&result.links[0]){
event.directresult=result.links[0];
}
else{
event.finish();
return;
}
}
if(player.storage.subplayer){
var current=player.storage.subplayer.name2;
if(event.directresult==current){
event.finish();
return;
}
player.storage[current].hp=player.hp;
player.storage[current].maxHp=player.maxHp;
player.storage[current].hs=player.getCards('h');
player.storage[current].es=player.getCards('e');
player.lose(player.getCards('he'),ui.special)._triggered=null;
var cfg=player.storage[event.directresult];
player.storage.subplayer.name2=event.directresult;
player.reinit(current,event.directresult,[
cfg.hp,
cfg.maxHp
]);
if(cfg.hs.length) player.directgain(cfg.hs);
if(cfg.es.length) player.directequip(cfg.es);
}
},
exitSubPlayer:function(){
'step 0'
if(player.storage.subplayer){
var current=player.storage.subplayer.name2;
if(event.remove){
player.lose(player.getCards('he'),ui.discardPile)._triggered=null;
}
else{
player.storage[current].hp=player.hp;
player.storage[current].maxHp=player.maxHp;
player.storage[current].hs=player.getCards('h');
player.storage[current].es=player.getCards('e');
player.lose(player.getCards('he'),ui.special)._triggered=null;
}
player.reinit(current,player.storage.subplayer.name,[
player.storage.subplayer.hp,
player.storage.subplayer.maxHp
]);
player.update();
if(event.remove){
if(player.storage[current].onremove){
player.storage[current].onremove(player);
}
delete player.storage[current];
player.storage.subplayer.skills.remove(current);
game.log(player,'牺牲了随从','#g'+current);
}
else{
game.log(player,'收回了随从','#g'+current);
}
player.addSkill(player.storage.subplayer.skills);
}
'step 1'
if(player.storage.subplayer){
player.directgain(player.storage.subplayer.hs);
player.directequip(player.storage.subplayer.es);
}
player.removeSkill('subplayer');
'step 2'
if(event.remove){
event.trigger('subPlayerDie');
}
},
callSubPlayer:function(){
'step 0'
var list=player.getSubPlayers(event.tag);
event.list=list;
if(!event.directresult){
if(list.length>1){
var dialog=ui.create.dialog('调遣一个随从','hidden');
dialog.add([list,'character']);
player.chooseButton(dialog,true);
}
else if(list.length==1){
event.directresult=list[0];
}
else{
event.finish();
}
}
else{
if(!list.contains(event.directresult)){
event.finish();
}
}
'step 1'
if(!event.directresult){
if(result&&result.bool&&result.links[0]){
event.directresult=result.links[0];
}
else{
event.finish();
return;
}
}
if(event.directresult){
var cfg=player.storage[event.directresult];
var source=cfg.source||player.name;
var name=event.directresult;
game.log(player,'调遣了随从','#g'+name);
player.storage.subplayer={
name:source,
name2:event.directresult,
hp:player.hp,
maxHp:player.maxHp,
skills:event.list.slice(0),
hs:player.getCards('h'),
es:player.getCards('e'),
intro2:cfg.intro2
}
player.removeSkill(event.list);
player.reinit(source,name,[cfg.hp,cfg.maxHp]);
player.addSkill('subplayer');
player.lose(player.getCards('he'),ui.special)._triggered=null;
if(cfg.hs.length) player.directgain(cfg.hs);
if(cfg.es.length) player.directequip(cfg.es);
}
'step 2'
game.delay();
},
addExtraTarget:function(){
"step 0"
event.num=0;
"step 1"
var target=targets[num],info=get.info(card);
if(target==event.target&&event.addedTarget){
event.addedTargets[num]=event.addedTarget;
event._result={bool:false};
}
else if(game.hasPlayer(function(current){
return info.filterAddedTarget(card,player,current,target)
})){
var next=player.chooseTarget(get.translation(event.card)+':选择'+get.translation(targets[num])+'对应的指向目标',function(card,player,target){
var card=get.card(),info=get.info(card);
return info.filterAddedTarget(card,player,target,_status.event.preTarget)
},true);
next.set('_get_card',card);
next.set('preTarget',targets[num]);
}
else{
event.addedTargets[num]=false;
event._result={bool:false};
}
"step 2"
if(result.bool){
event.addedTargets[num]=result.targets[0];
player.line2([targets[num],result.targets[0]]);
}
event.num++;
if(event.numpriority){
event.doing.list.splice(i--,1);
event.num--;
}
}
event.choice=[];
if(event.num'+trigger.skillwarn+'。'+next.prompt2);
}
else{
next.set('prompt2',trigger.skillwarn);
}
}
}
}
"step 2"
var info=get.info(event.skill);
if(result&&result.bool!=false){
var autodelay=info.autodelay;
if(typeof autodelay=='function'){
autodelay=autodelay(trigger,player);
}
if(autodelay&&(info.forced||!event.isMine())){
if(typeof autodelay=='number'){
game.delayx(autodelay);
}
else{
game.delayx();
}
}
}
"step 3"
var info=get.info(event.skill);
if(result&&result.bool==false){
if(info.oncancel) info.oncancel(trigger,player);
event.finish();
return;
}
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&&info.logLine!==false){
if(typeof info.logTarget=='string'){
player.logSkill(event.skill,trigger[info.logTarget],info.line);
}
else if(typeof info.logTarget=='function'){
player.logSkill(event.skill,info.logTarget(trigger,player),info.line);
}
}
else{
player.logSkill(event.skill,false,info.line);
}
}
}
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.forceDie) next.forceDie=true;
if(info.forceOut||event.skill=='_turnover') next.includeOut=true;
"step 4"
if(player._hookTrigger){
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(get.connectNickname(),lib.config.connect_avatar);
me.playerid='1';
game.onlinezhu='1';
}
_status.waitingForPlayer=true;
if(window.isNonameServer){
document.querySelector('#server_status').innerHTML='等待中';
}
game.pause();
'step 1'
_status.waitingForPlayer=false;
lib.configOL.gameStarted=true;
if(window.isNonameServer){
document.querySelector('#server_status').innerHTML='游戏中';
}
if(game.onlineroom){
game.send('server','config',lib.configOL);
}
for(var i=0;i0){
var num=event.num;
if(event.attachDraw){
for(var i=0;i1&&typeof event.selectCard!='function'){
event.promptdiscard=ui.create.control('AI代选',function(){
ai.basic.chooseCard(event.ai);
if(_status.event.custom&&_status.event.custom.add.card){
_status.event.custom.add.card();
}
for(var i=0;i{
return !cards.contains(card)||!player.getCards('hejsx').contains(card);
})
}
if(i[1].length>0) i[0].$draw(i[1].length);
}
break;
case 'gain':
game.delay(0,get.delayx(700,700));
for(var i of event.gain_list){
if(get.itemtype(i[1])=='card') i[1]=[i[1]];
if(event._lose){
i[1]=i[1].filter(card=>{
return !cards.contains(card)||!player.getCards('hejsx').contains(card);
})
}
if(i[1].length>0) i[0].$gain(i[1].length);
}
break;
case 'gain2': case 'draw2':
game.delay(0,get.delayx(500,500));
for(var i of event.gain_list){
if(get.itemtype(i[1])=='card') i[1]=[i[1]];
if(event._lose){
i[1]=i[1].filter(card=>{
return !cards.contains(card)||!player.getCards('hejsx').contains(card);
})
}
if(i[1].length>0) i[0].$gain2(i[1]);
}
break;
case 'give': case 'giveAuto':
if(!player) break;
var evt=event.getl(player);
game.delay(0,get.delayx(500,500));
for(var i of event.gain_list){
if(get.itemtype(i[1])=='card') i[1]=[i[1]];
if(event._lose){
i[1]=i[1].filter(card=>{
return !cards.contains(card)||!player.getCards('hejsx').contains(card);
})
}
var shown=i[1].slice(0),hidden=[];
if(event.animate=='giveAuto'){
for(var card of i[1]){
if(evt.hs.contains(card)){
shown.remove(card);
hidden.push(card);
}
}
}
if(shown.length>0) player.$give(shown,i[0]);
if(hidden.length>0) player.$giveAuto(hidden,i[0]);
}
break;
default:
event.finish();
}
for(var i of event.gain_list){
if(i[1].length>0){
var next=i[0].gain(i[1]);
next.getlx=false;
if(event.visible) next.visible=true;
if(event.giver) next.giver=event.giver;
if(event.gaintag) next.gaintag.addArray(event.gaintag);
}
}
'step 2'
game.delayx();
},
discardMultiple:function(){
'step 0'
event.type='discard';
event.visible=true;
if(!event.position) event.position=ui.discardPile;
var cards=[];
event.cards=cards;
for(var i=0;ievent.num2){
str=get.translation(player)+'拼点成功';
player.popup('胜');
target.popup('负');
}
else{
str=get.translation(player)+'拼点失败';
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);
event.compareMultiple=true;
}
"step 6"
game.broadcastAll(ui.clear);
event.iwhile++;
event.goto(3);
"step 7"
event.cards.add(event.card1);
},
chooseToCompare:function(){
"step 0"
if(((!event.fixedResult||!event.fixedResult[player.playerid])&&player.countCards('h')==0)||((!event.fixedResult||!event.fixedResult[target.playerid])&&target.countCards('h')==0)){
event.result={cancelled:true,bool:false}
event.finish();
return;
}
game.log(player,'对',target,'发起拼点');
event.lose_list=[];
"step 1"
var sendback=function(){
if(_status.event!=event){
return function(){
event.resultOL=_status.event.resultOL;
};
}
};
if(event.fixedResult&&event.fixedResult[player.playerid]){
event.card1=event.fixedResult[player.playerid];
event.lose_list.push([player,event.card1]);
}
else if(player.isOnline()){
player.wait(sendback);
event.ol=true;
player.send(function(ai){
game.me.chooseCard('请选择拼点牌',true).set('type','compare').set('glow_result',true).ai=ai;
game.resume();
},event.ai);
}
else{
event.localPlayer=true;
player.chooseCard('请选择拼点牌',true).set('type','compare').set('glow_result',true).ai=event.ai;
}
if(event.fixedResult&&event.fixedResult[target.playerid]){
event.card2=event.fixedResult[target.playerid];
event.lose_list.push([target,event.card2]);
}
else if(target.isOnline()){
target.wait(sendback);
event.ol=true;
target.send(function(ai){
game.me.chooseCard('请选择拼点牌',true).set('type','compare').set('glow_result',true).ai=ai;
game.resume();
},event.ai);
}
else{
event.localTarget=true;
}
"step 2"
if(event.localPlayer){
if(result.skill&&lib.skill[result.skill]&&lib.skill[result.skill].onCompare){
result.cards=lib.skill[result.skill].onCompare(player);
player.logSkill(result.skill);
}
else event.lose_list.push([player,result.cards[0]]);
event.card1=result.cards[0];
}
if(event.localTarget){
target.chooseCard('请选择拼点牌',true).set('type','compare').set('glow_result',true).ai=event.ai;
}
"step 3"
if(event.localTarget){
if(result.skill&&lib.skill[result.skill]&&lib.skill[result.skill].onCompare){
target.logSkill(result.skill);
result.cards=lib.skill[result.skill].onCompare(target);
}
else event.lose_list.push([target,result.cards[0]]);
event.card2=result.cards[0];
}
if(!event.resultOL&&event.ol){
game.pause();
}
"step 4"
try{
if(!event.card1){
if(event.resultOL[player.playerid].skill&&lib.skill[event.resultOL[player.playerid].skill]&&lib.skill[event.resultOL[player.playerid].skill].onCompare){
player.logSkill(event.resultOL[player.playerid].skill);
event.resultOL[player.playerid].cards=lib.skill[event.resultOL[player.playerid].skill].onCompare(player);
}
else event.lose_list.push([player,event.resultOL[player.playerid].cards[0]]);
event.card1=event.resultOL[player.playerid].cards[0];
};
if(!event.card2){
if(event.resultOL[target.playerid].skill&&lib.skill[event.resultOL[target.playerid].skill]&&lib.skill[event.resultOL[target.playerid].skill].onCompare){
target.logSkill(event.resultOL[target.playerid].skill);
event.resultOL[target.playerid].cards=lib.skill[event.resultOL[target.playerid].skill].onCompare(player);
}
else event.lose_list.push([target,event.resultOL[target.playerid].cards[0]]);
event.card2=event.resultOL[target.playerid].cards[0];
}
if(!event.card1||!event.card2){
throw('err');
}
}
catch(e){
console.log(e);
game.print(e);
event.finish();
return;
}
if(event.card2.number>=10||event.card2.number<=4){
if(target.countCards('h')>2){
event.addToAI=true;
}
}
if(event.lose_list.length){
game.loseAsync({
lose_list:event.lose_list,
}).setContent('chooseToCompareLose');
}
"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);
var getNum=function(card){
for(var i of event.lose_list){
if(i[1]==card) return get.number(card,i[0]);
}
return get.number(card,false);
}
event.num1=getNum(event.card1);
event.num2=getNum(event.card2);
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;
event.result.winner=player;
str=get.translation(player)+'拼点成功';
player.popup('胜');
target.popup('负');
}
else{
event.result.bool=false;
str=get.translation(player)+'拼点失败';
if(event.num1==event.num2){
event.result.tie=true;
player.popup('平');
target.popup('平');
}
else{
event.result.winner=target;
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;
}
},
chooseSkill:function(){
'step 0'
var list;
if(typeof event.target=='string'){
list=get.gainableSkillsName(event.target,event.func);
}
else{
list=event.target.getGainableSkills(event.func);
}
if(!list.length){
event.finish();
event.result={bool:false};
return;
}
event.skillai=function(list){
return get.max(list,get.skillRank,'item');
};
if(event.isMine()){
var dialog=ui.create.dialog('forcebutton');
dialog.add(event.prompt||'选择获得一项技能');
_status.event.list=list;
var clickItem=function(){
_status.event._result=this.link;
game.resume();
};
for(i=0;i
"\n}\n帮助内容将显示在菜单-选项-帮助中\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/';
}
};
var dashes={};
var createCode=function(str1,str2,sub,func,link,str){
var dash=ui.create.div('.menubutton.large.dashboard');
dashes[link]=dash;
sub.appendChild(dash);
dash.listen(func);
dash.link=link;
ui.create.div('',str1,dash);
ui.create.div('',str2,dash);
var container=ui.create.div('.popup-container.editor');
var editorpage=ui.create.div(container);
var discardConfig=ui.create.div('.editbutton','取消',editorpage,function(){
ui.window.classList.remove('shortcutpaused');
ui.window.classList.remove('systempaused');
container.delete(null);
delete window.saveNonameInput;
});
var saveInput=function(){
var code;
if(container.editor){
code=container.editor.getValue();
}
else if(container.textarea){
code=container.textarea.value;
}
try{
if(link=='content'||link=='precontent'){
var func=null;
eval('func='+code);
if(typeof func!='function'){
throw('err');
}
}
else if(link=='config'){
var config=null;
eval(code);
if(config==null||typeof config!='object'){
throw('err');
}
}
else if(link=='help'){
var help=null;
eval(code);
if(help==null||typeof help!='object'){
throw('err');
}
}
}
catch(e){
if(e=='err'){
alert('代码格式有错误,请对比示例代码仔细检查');
}
else{
alert('代码语法有错误,请仔细检查('+e+')')
}
return;
}
dash4.link.classList.add('active');
ui.window.classList.remove('shortcutpaused');
ui.window.classList.remove('systempaused');
container.delete();
container.code=code;
page.content[link]=code;
delete window.saveNonameInput;
};
var saveConfig=ui.create.div('.editbutton','保存',editorpage,saveInput);
var editor=ui.create.div(editorpage);
container.code=str;
dash.editor=editor;
dash.node=container;
dash.saveInput=saveInput;
page.content[link]=str;
};
var clickCode=function(){
var node=this.node;
ui.window.classList.add('shortcutpaused');
ui.window.classList.add('systempaused');
window.saveNonameInput=this.saveInput;
if(node.aced){
ui.window.appendChild(node);
node.editor.setValue(node.code,1);
}
else if(lib.device=='ios'){
ui.window.appendChild(node);
if(!node.textarea){
var textarea=document.createElement('textarea');
this.editor.appendChild(textarea);
node.textarea=textarea;
lib.setScroll(textarea);
}
node.textarea.value=node.code;
}
else{
var editor=this.editor;
var aceReady=function(){
ui.window.appendChild(node);
var mirror = window.CodeMirror(editor, {
value:node.code,
mode:"javascript",
lineWrapping:!lib.config.touchscreen&&lib.config.mousewheel,
lineNumbers:true,
indentUnit:4,
autoCloseBrackets:true,
theme:'mdn-like'
});
lib.setScroll(editor.querySelector('.CodeMirror-scroll'));
node.aced=true;
node.editor=mirror;
}
if(!window.ace){
lib.init.js(lib.assetURL+'game','codemirror',aceReady);
lib.init.css(lib.assetURL+'layout/default','codemirror');
}
else{
aceReady();
}
}
};
page.content={}
createCode('主','主代码',page,clickCode,'content','function(config,pack){\n \n}\n\n\/*\n函数执行时机为游戏数据加载之后、界面加载之前\n参数1扩展选项(见选项代码);参数2为扩展定义的武将、卡牌和技能等(可在此函数中修改)\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/');
createCode('启','启动代码',page,clickCode,'precontent','function(){\n \n}\n\n\/*\n函数执行时机为游戏数据加载之前,且不受禁用扩展的限制\n除添加模式外请慎用\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/');
createCode('选','选项代码',page,clickCode,'config','config={\n \n}\n\n\/*\n示例:\nconfig={\n switcher_example:{\n name:"示例列表选项",\n init:"3",\n item:{"1":"一","2":"二","3":"三"}\n },\n toggle_example:{\n name:"示例开关选项",\n init:true\n }\n}\n此例中传入的主代码函数的默认参数为{switcher_example:"3",toggle_example:true}\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/');
createCode('帮','帮助代码',page,clickCode,'help','help={\n \n}\n\n\/*\n示例:\nhelp={\n "帮助条目":"- 列表2-条目1
- 列表2-条目2
"\n}\n帮助内容将显示在菜单-选项-帮助中\n导出时本段代码中的换行、缩进以及注释将被清除\n*\/');
return page;
}());
createDash('将','编辑武将',dash1);
createDash('卡','编辑卡牌',dash2);
createDash('技','编辑技能',dash3);
createDash('码','编辑代码',dash4);
};
}());
(function(){
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','获取扩展',start.firstChild,clickMode);
node.mode='get';
var _thisUpdate=false;
node.update=function(){
_thisUpdate=true;
};
node._initLink=function(){
node.link=page;
page.listen(function(){
if(!page.currenttimeout){
var active=page.querySelector('.videonode.current');
if(active){
active.classList.remove('current');
}
}
});
var importextensionexpanded=false;
page.style.paddingBottom='10px';
var importExtension;
var extensionnode=ui.create.div('.config.more','导入扩展 >
',page,function(){
if(importextensionexpanded){
this.classList.remove('on');
importExtension.style.display='none';
}
else{
this.classList.add('on');
importExtension.style.display='';
}
importextensionexpanded=!importextensionexpanded;
});
importExtension=ui.create.div('.new_character.export.import',page);
importExtension.style.marginLeft='5px';
importExtension.style.marginTop='5px';
importExtension.style.marginBottom='5px';
importExtension.style.display='none';
importExtension.style.width='100%';
importExtension.style.textAlign='left';
ui.create.div('','',importExtension);
ui.create.div('.config','修改下载地址',page,function(){
alert('您可以在“设置→通用→获取扩展地址”中,修改下载扩展时所采用的地址。')
})
var extensionURL;
var source=lib.config.extension_sources,index=lib.config.extension_source;
if(source&&source[index]) extensionURL=source[index];
else extensionURL=lib.updateURL.replace(/noname/g,'noname-extension')+'/master/';
var reloadnode=ui.create.div('.config.toggle.pointerdiv','重新启动',page,game.reload);
reloadnode.style.display='none';
var placeholder=ui.create.div('.config.toggle',page);
placeholder.style.height=0;
placeholder.style.marginTop='5px';
importExtension.firstChild.lastChild.onclick=function(){
var fileToLoad=this.previousSibling.files[0];
if(fileToLoad){
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent)
{
var finishLoad=function(){
extensionnode.innerHTML='导入成功,3秒后将重启';
setTimeout(function(){
extensionnode.innerHTML='导入成功,2秒后将重启';
setTimeout(function(){
extensionnode.innerHTML='导入成功,1秒后将重启';
setTimeout(game.reload,1000);
},1000);
},1000);
};
var data = fileLoadedEvent.target.result;
if(game.importExtension(data,finishLoad)!==false){
importExtension.style.display='none';
}
};
fileReader.readAsArrayBuffer(fileToLoad, "UTF-8");
}
}
var clickExtension=function(){
var active=this.parentNode.querySelector('.videonode.current');
if(active&&active!=this){
active.classList.remove('current');
}
this.classList.add('current');
clearTimeout(page.currenttimeout);
page.currenttimeout=setTimeout(function(){
delete page.currenttimeout;
},200);
};
var downloadExtension=function(e){
if((this.innerHTML!='下载扩展'&&this.innerHTML!='更新扩展')||!window.JSZip) return;
this.classList.remove('update');
if(e){
e.stopPropagation();
}
node.updated=true;
var that=this;
var list=[];
var size=parseFloat(this.info.size)||0;
if(size){
if(this.info.size.indexOf('MB')!=-1){
size*=1024*1024;
}
else if(this.info.size.indexOf('KB')!=-1){
size*=1024;
}
}
this.innerHTML='正在下载正在下载
';
this.classList.add('nopointer');
this.classList.add('button-downloading');
var progress=ui.create.div('.button-progress',this);
ui.create.div(progress);
var url=extensionURL+this.info.name+'.zip';
var onprogress=function(byte,total){
if(total){
size=total;
}
if(byte==-1){
byte=size;
}
progress.firstChild.style.width=Math.round(100*byte/size)+'%';
};
var files=this.info.files||[];
for(var i=0;i('+list[i].size+')',node);
ui.create.div('.text',list[i].intro,node);
var download=ui.create.div('.menubutton.text.active','下载扩展',node.firstChild);
if(game.download){
if(list[i].netdisk){
var linknode=ui.create.div('.text',node);
ui.create.node('span.hrefnode','网盘链接',function(){
game.open(this.link);
},linknode).link=list[i].netdisk;
if(list[i].forum){
ui.create.node('span',linknode).style.marginRight='10px';
ui.create.node('span.hrefnode','参与讨论',function(){
game.open(this.link);
},linknode).link=list[i].forum;
}
}
else if(list[i].forum){
var linknode=ui.create.div('.text',node);
ui.create.node('span.hrefnode','参与讨论',function(){
game.open(this.link);
},linknode).link=list[i].forum;
}
download.listen(downloadExtension);
if(lib.config.extensions.contains(list[i].name)){
download.classList.remove('active');
if(lib.extensionPack[list[i].name]&&lib.extensionPack[list[i].name].version==list[i].version){
download.classList.add('transparent2');
download.classList.remove('active');
download.innerHTML='已安装';
}
else if(lib.config['extension_'+list[i].name+'_version']!=list[i].version){
download.innerHTML='更新扩展';
download.classList.add('highlight');
download.classList.add('update');
}
else{
download.classList.add('transparent2');
download.classList.remove('active');
download.innerHTML='已安装';
}
}
download.info=list[i];
}
else{
if(list[i].forum){
var linknode=ui.create.div('.text',node);
ui.create.node('span',linknode);
ui.create.node('span.hrefnode','参与讨论',function(){
game.open(this.link);
},linknode).link=list[i].forum;
}
download.listen(function(){
game.open(this.link);
});
download.link=list[i].netdisk;
}
}
};
window.extension={};
if(game.download){
lib.init.req(extensionURL+'catalog.js',function(){
try{
eval(this.responseText);
// if(!window.noname_extension_list){
// throw('err');
// }
}
catch(e){
delete window.extension;
loading.innerHTML='连接失败';
return;
}
loaded();
},function(){
delete window.extension;
loading.innerHTML='连接失败';
});
}
else{
lib.init.req(extensionURL.replace(/raw\.githubusercontent\.com/,'rawgit.com')+'catalog.js',function(){
try{
eval(this.responseText);
}
catch(e){
delete window.extension;
loading.innerHTML='连接失败';
return;
}
loaded();
},function(){
delete window.extension;
loading.innerHTML='连接失败';
});
}
};
if(_thisUpdate) node.update();
};
}());
var active=start.firstChild.querySelector('.active');
if(!active){
active=start.firstChild.firstChild;
active.classList.add('active');
}
if(!active.link) active._initLink();
rightPane.appendChild(active.link);
updateNodes();
}());
(function(){
if(connectMenu) return;
var start=menuxpages.shift();
var rightPane=start.lastChild;
var cheatButton=ui.create.div('.menubutton.round.highlight','作',start);
cheatButton.style.display='none';
var runButton=ui.create.div('.menubutton.round.highlight','执',start);
runButton.style.display='none';
var clearButton=ui.create.div('.menubutton.round.highlight','清',start);
clearButton.style.display='none';
clearButton.style.left='275px';
var playButton=ui.create.div('.menubutton.round.highlight.hidden','播',start);
playButton.style.display='none';
playButton.style.left='215px';
playButton.style.transition='opacity 0.3s';
var deleteButton=ui.create.div('.menubutton.round.highlight.hidden','删',start);
deleteButton.style.display='none';
deleteButton.style.left='275px';
deleteButton.style.transition='opacity 0.3s';
var saveButton=ui.create.div('.menubutton.round.highlight.hidden','存',start);
saveButton.style.display='none';
saveButton.style.transition='opacity 0.3s';
var clickMode=function(){
if(this.classList.contains('off')) return;
var active=this.parentNode.querySelector('.active');
if(active===this){
return;
}
if(active){
active.classList.remove('active');
active.link.remove();
}
active=this;
this.classList.add('active');
if(this.link) rightPane.appendChild(this.link);
else{
this._initLink();
rightPane.appendChild(this.link);
}
if(this.type=='cheat'){
cheatButton.style.display='';
}
else{
cheatButton.style.display='none';
}
if(this.type=='cmd'){
runButton.style.display='';
clearButton.style.display='';
}
else{
runButton.style.display='none';
clearButton.style.display='none';
}
if(this.type=='video'){
playButton.style.display='';
saveButton.style.display='';
deleteButton.style.display='';
}
else{
playButton.style.display='none';
saveButton.style.display='none';
deleteButton.style.display='none';
}
};
ui.click.consoleMenu=function(){
ui.click.menuTab('其它');
clickMode.call(ui.commandnode);
};
//更新菜单有本体函数赋值,就不要懒加载了
(function(){
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','更新',start.firstChild,clickMode);
node.link=page;
page.classList.add('menu-help');
var ul=document.createElement('ul');
var li1=document.createElement('li');
var li2=document.createElement('li');
var li3=document.createElement('li');
var trimurl=function(str){
if(str==lib.updateURLS.github){
return 'GitHub';
}
if(str==lib.updateURLS.coding){
return 'Coding';
}
var index;
index=str.indexOf('://');
if(index!=-1){
str=str.slice(index+3);
}
index=str.indexOf('/');
if(index!=-1){
str=str.slice(0,index);
}
if(str.length>15){
var list=str.split('.');
if(list.length>1){
list.shift();
}
str=list[0];
for(var i=1;i15){
var list=str.split('.');
if(list.length>1){
list.pop();
}
str=list[0];
for(var i=1;i
';
li2.innerHTML='素材版本:'+(lib.config.asset_version||'无')+'';
li3.innerHTML='更新地址:'+trimurl(lib.config.updateURL||lib.updateURL)+'';
li3.style.whiteSpace='nowrap';
li3.style.display='none';// coding
var button1,button2,button3,button4,button5;
game.checkForUpdate=function(forcecheck,dev){
if(!dev&&button1.disabled){
return;
}
else if(dev&&button3.disabled){
return;
}
else if(!game.download){
alert('此版本不支持游戏内更新,请手动更新');
return;
}
else{
if(dev){
button3.innerHTML='正在检查更新';
}
else{
button1.innerHTML='正在检查更新';
}
button3.disabled=true;
button1.disabled=true;
var goupdate=function(files,update){
lib.version=update.version;
if(update.dev&&!lib.config.debug){
dev='nodev';
}
lib.init.req('game/source.js',function(){
try{
eval(this.responseText);
if(!window.noname_source_list){
throw('err');
}
}
catch(e){
alert('更新地址有误');
console.log(e);
return;
}
var updates=window.noname_source_list;
delete window.noname_source_list;
if(Array.isArray(files)){
files.add('game/update.js');
var files2=[];
for(var i=0;iversion1[i]){
files=false;break;
}
else if(version1[i]>version2[i]){
files=update.files.slice(0);break;
}
}
if(files===null){
if(version1.length>=version2.length){
files=update.files.slice(0);
}
}
}
var str;
if(dev){
str='开发版仅供测试使用,可能存在风险,是否确定更新?'
}
else{
str='有新版本'+update.version+'可用,是否下载?';
}
if(navigator.notification&&navigator.notification.confirm){
var str2;
if(dev){
str2=str;
str='更新到开发版';
}
else{
str2=update.changeLog[0];
for(var i=1;i>');
span1.style.fontSize='small';
span1.style.display='inline';
span1.toggle=function(){
if(!this.classList.toggle('on')){
game.saveConfig('asset_toggle_off',true);
span2.style.display='none';
span2_br.style.display='none';
span2_check.style.display='none';
span3.style.display='none';
span3_br.style.display='none';
span3_check.style.display='none';
span4.style.display='none';
span4_br.style.display='none';
span4_check.style.display='none';
span5.style.display='none';
span5_br.style.display='none';
span5_check.style.display='none';
span6.style.display='none';
span6_br.style.display='none';
span6_check.style.display='none';
}
else{
game.saveConfig('asset_toggle_off');
span2.style.display='';
span2_br.style.display='';
span2_check.style.display='';
span3.style.display='';
span3_br.style.display='';
span3_check.style.display='';
span4.style.display='';
span4_br.style.display='';
span4_check.style.display='';
span5.style.display='';
span5_br.style.display='';
span5_check.style.display='';
span6.style.display='';
span6_br.style.display='';
span6_check.style.display='';
}
};
span1.listen(span1.toggle);
li2.lastChild.appendChild(span1);
var span6_br=ui.create.node('br');
li2.lastChild.appendChild(span6_br);
var span5=ui.create.div('','图片素材(精简,126MB)');
span5.style.fontSize='small';
span5.style.lineHeight='16px';
var span5_check=document.createElement('input');
span5_check.type='checkbox';
span5_check.style.marginLeft='5px';
if(lib.config.asset_image){
span5_check.checked=true;
}
span5_check.onchange=function(){
game.saveConfig('asset_image',this.checked);
}
var span2_br=ui.create.node('br');
var span4=ui.create.div('','字体素材(48MB)');
span4.style.fontSize='small';
span4.style.lineHeight='16px';
li2.lastChild.appendChild(span4);
var span4_check=document.createElement('input');
span4_check.type='checkbox';
span4_check.style.marginLeft='5px';
if(lib.config.asset_font){
span4_check.checked=true;
}
span4_check.onchange=function(){
game.saveConfig('asset_font',this.checked);
}
li2.lastChild.appendChild(span4_check);
var span3_br=ui.create.node('br');
li2.lastChild.appendChild(span3_br);
var span3=ui.create.div('','音效素材(125MB)');
span3.style.fontSize='small';
span3.style.lineHeight='16px';
li2.lastChild.appendChild(span3);
var span3_check=document.createElement('input');
span3_check.type='checkbox';
span3_check.style.marginLeft='5px';
if(lib.config.asset_audio){
span3_check.checked=true;
}
span3_check.onchange=function(){
game.saveConfig('asset_audio',this.checked);
}
li2.lastChild.appendChild(span3_check);
var span4_br=ui.create.node('br');
li2.lastChild.appendChild(span4_br);
var span2=ui.create.div('','皮肤素材(351MB)');
span2.style.fontSize='small';
span2.style.lineHeight='16px';
li2.lastChild.appendChild(span2);
var span2_check=document.createElement('input');
span2_check.type='checkbox';
span2_check.style.marginLeft='5px';
if(lib.config.asset_skin){
span2_check.checked=true;
}
span2_check.onchange=function(){
game.saveConfig('asset_skin',this.checked);
}
li2.lastChild.appendChild(span2_check);
var span5_br=ui.create.node('br');
li2.lastChild.appendChild(span5_br);
li2.lastChild.appendChild(span5);
li2.lastChild.appendChild(span5_check);
li2.lastChild.appendChild(span2_br);
var span6=ui.create.div('','图片素材(完整,203MB)');
span6.style.fontSize='small';
span6.style.lineHeight='16px';
li2.lastChild.appendChild(span6);
var span6_check=document.createElement('input');
span6_check.type='checkbox';
span6_check.style.marginLeft='5px';
if(lib.config.asset_full){
span6_check.checked=true;
}
span6_check.onchange=function(){
game.saveConfig('asset_full',this.checked);
}
li2.lastChild.appendChild(span6_check);
span2.style.display='none';
span2_br.style.display='none';
span2_check.style.display='none';
span3.style.display='none';
span3_br.style.display='none';
span3_check.style.display='none';
span4.style.display='none';
span4_br.style.display='none';
span4_check.style.display='none';
span5.style.display='none';
span5_br.style.display='none';
span5_check.style.display='none';
span6.style.display='none';
span6_br.style.display='none';
span6_check.style.display='none';
ul.appendChild(li1);
ul.appendChild(li2);
ul.appendChild(li3);
page.appendChild(ul);
if(!lib.config.asset_toggle_off){
span1.toggle();
}
}());
(function(){
var norow2=function(){
var node=currentrow1;
if(!node) return false;
return node.innerHTML=='横置'||node.innerHTML=='翻面'||node.innerHTML=='换人'||node.innerHTML=='复活';
};
var checkCheat=function(){
if(norow2()){
for(var i=0;i=0){
logindex--;
if(logindex<0){
text2.value='';
}
else{
text2.value=logs[logindex];
}
}
else{
text2.value='';
}
}
else if(text2.value.indexOf('无天使')!=-1&&(text2.value.indexOf('无神佛')!=-1||text2.value.indexOf('无神')!=-1&&text2.value.indexOf('无佛')!=-1)){
game.print('密码正确!欢迎来到死后世界战线!');
_status.keyVerified=true;
text2.value='';
}
else{
if(!game.observe&&!game.online){
try{
var value=text2.value.trim();
if(value.endsWith(";")) value=value.slice(0,-1).trim();
var result=fun(reg,value,_status,lib,game,ui,get,ai);
game.print(result);
}
catch(e){
game.print(e);
}
}
text2.value='';
}
}
text2.addEventListener('keydown',function(e){
if(e.keyCode==13){
runCommand();
}
else if(e.keyCode==38){
if(logindex+1=0){
logindex--;
if(logindex<0){
text2.value='';
}
else{
text2.value=logs[logindex];
}
}
}
});
page.appendChild(text2);
game.print=function(){
var args=[].slice.call(arguments);
var printResult=args.map(arg=>{
if(get.is.object(arg)||typeof arg=='function'){
var argi=get.stringify(arg);
if(argi/*&&argi.length<5000*/){
return argi.replace(/&/g, '&')
.replace(//g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
}
else return arg.toString();
}else{
var str=String(arg);
if (!/<[a-zA-Z]+[^>]*?\/?>.*?(?=<\/[a-zA-Z]+[^>]*?>|$)/.exec(str)) return String(arg)
.replace(/&/g, '&')
.replace(//g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
else return str;
}
}).join(' ');
pre.innerHTML+=printResult+'
';
text.scrollTop=text.scrollHeight;
}
if(_status.toprint){
for(var i=0;i<_status.toprint.length;i++){
game.print.apply(this,_status.toprint[i]);
}
delete _status.toprint;
}
runButton.listen(runCommand);
clearButton.listen(function(){
pre.innerHTML='';
});
};
}());
(function(){
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','战绩',start.firstChild,clickMode);
node.type='rec';
node._initLink=function(){
node.link=page;
page.style.paddingBottom='10px';
var reset=function(){
if(this.innerHTML=='重置'){
this.innerHTML='确定';
var that=this;
setTimeout(function(){
that.innerHTML='重置';
},1000);
}
else{
this.parentNode.previousSibling.remove();
this.parentNode.remove();
lib.config.gameRecord[this.parentNode.link]={data:{}};
game.saveConfig('gameRecord',lib.config.gameRecord);
}
}
for(var i=0;i重置',page);
item.style.height='auto';
item.lastChild.addEventListener('click',reset);
item.lastChild.classList.add('pointerdiv');
item.link=lib.config.all.mode[i];
}
}
};
}());
(function(){
if(!window.indexedDB||window.nodb) return;
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','录像',start.firstChild,clickMode);
node.type='video';
lib.videos=[];
ui.create.videoNode=(video,before)=>lib.videos[before===true?'unshift':'push'](video);
node._initLink=function(){
node.link=page;
var store=lib.db.transaction(['video'],'readwrite').objectStore('video');
store.openCursor().onsuccess=function(e){
var cursor=e.target.result;
if(cursor){
lib.videos.push(cursor.value);
cursor.continue();
}
else{
lib.videos.sort(function(a,b){
return parseInt(b.time)-parseInt(a.time);
});
var clickcapt=function(){
var current=this.parentNode.querySelector('.videonode.active');
if(current&¤t!=this){
current.classList.remove('active');
}
if(this.classList.toggle('active')){
playButton.show();
deleteButton.show();
saveButton.show();
}
else{
playButton.hide();
deleteButton.hide();
saveButton.hide();
}
};
var staritem=function(){
this.parentNode.classList.toggle('starred');
var store=lib.db.transaction(['video'],'readwrite').objectStore('video');
if(this.parentNode.classList.contains('starred')){
this.parentNode.link.starred=true;
}
else{
this.parentNode.link.starred=false;
}
store.put(this.parentNode.link);
}
var createNode=function(video,before){
var node=ui.create.div('.videonode.menubutton.large',clickcapt);
node.link=video;
var nodename1=ui.create.div('.menubutton.videoavatar',node);
nodename1.setBackground(video.name1,'character');
if(video.name2){
var nodename2=ui.create.div('.menubutton.videoavatar2',node);
nodename2.setBackground(video.name2,'character');
}
var date=new Date(video.time);
var str=date.getFullYear()+'.'+(date.getMonth()+1)+'.'+(date.getDate())+' '+
date.getHours()+':';
var minutes=date.getMinutes();
if(minutes<10){
str+='0';
}
str+=minutes;
ui.create.div('.caption',video.name[0],node);
ui.create.div('.text',str+'
'+video.name[1],node);
if(video.win){
ui.create.div('.victory','胜',node);
}
if(before){
page.insertBefore(node,page.firstChild);
}
else{
page.appendChild(node);
}
ui.create.div('.video_star','★',node,staritem);
if(video.starred){
node.classList.add('starred');
}
}
for(var i=0;i导入录像...',function(){
this.nextSibling.classList.toggle('hidden');
},page);
importVideoNode.style.marginLeft='12px';
importVideoNode.style.marginTop='3px';
var importVideo=ui.create.div('.config.hidden',page);
importVideo.style.whiteSpace='nowrap';
importVideo.style.marginBottom='80px';
importVideo.style.marginLeft='13px';
importVideo.style.width='calc(100% - 30px)';
importVideo.innerHTML=''+
'';
importVideo.lastChild.onclick=function(){
var fileToLoad = importVideo.firstChild.files[0];
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent)
{
var data = fileLoadedEvent.target.result;
if(!data) return;
try{
data=JSON.parse(lib.init.decode(data));
}
catch(e){
console.log(e);
alert('导入失败');
return;
}
var store=lib.db.transaction(['video'],'readwrite').objectStore('video');
var videos=lib.videos.slice(0);
for(var i=0;i=parseInt(lib.config.video)&&videos.length){
var toremove=videos.pop();
lib.videos.remove(toremove);
store.delete(toremove.time);
for(var i=0;iposition2){
position.insertBefore(node,position.childNodes[position2]);
}
else{
position.appendChild(node);
}
}
return node;
},
giveup:function(){
if(ui.giveup) return;
if(!lib.config.show_giveup) return;
ui.giveup=ui.create.system('投降',function(){
var player=game.me;
this.remove();
if(game.online){
game.send('giveup',player);
}
else{
_status.event.next.length=0;
game.createEvent('giveup',false).set('includeOut',true).setContent(function(){
game.log(player,'投降');
player.popup('投降');
player.die('nosource').includeOut=true;
}).player=player;
}
if(_status.paused&&_status.imchoosing&&!_status.auto){
ui.click.auto();
}
},true,true);
},
groupControl:function(dialog){
return ui.create.control('wei','shu','wu','qun','jin','western','key',function(link,node){
if(link=='全部'){
dialog.currentcapt='';
dialog.currentgroup='';
for(var i=0;ib?1:-1;
});
if(!thisiscard){
namecapt.remove('自定义');
namecapt.push('newline');
for(var i in lib.characterDialogGroup){
namecapt.push(i);
}
}
var newlined=false;
var newlined2;
var packsource;
var clickCapt=function(e){
if(_status.dragged) return;
if(dialog.currentcapt2=='最近'&&dialog.currentcaptnode2!=this&&!dialog.currentcaptnode2.inited){
dialog.currentcapt2=null;
dialog.currentcaptnode2.classList.remove('thundertext');
dialog.currentcaptnode2.inited=true;
dialog.currentcaptnode2=null;
}
if(this.alphabet){
if(this.classList.contains('thundertext')){
dialog.currentcapt=null;
dialog.currentcaptnode=null;
this.classList.remove('thundertext');
if(this.touchlink){
this.touchlink.classList.remove('active');
}
for(var i=0;i0){
filternode.firstChild.style.top=(dh/2)+'px';
}
else{
filternode.firstChild.style.top='';
}
}
else{
if(newlined2.style.display=='none'){
newlined2.style.display='block';
}
else{
newlined2.style.display='none';
}
}
});
var packlist=[];
for(var i=0;ib?1:-1;
}
return aa>bb?1:-1;
});
dialog=ui.create.dialog('hidden');
dialog.classList.add('noupdate');
dialog.classList.add('scroll1');
dialog.classList.add('scroll2');
dialog.classList.add('scroll3');
dialog.addEventListener(lib.config.touchscreen?'touchend':'mouseup',function(){
_status.clicked2=true;
});
if(heightset){
dialog.style.height=((game.layout=='long2'||game.layout=='nova')?380:350)+'px';
dialog._scrollset=true;
}
dialog.getCurrentCapt=function(link,capt,noalph){
var currentcapt=noalph?this.currentcapt2:this.currentcapt;
if(this.seperatelist&&noalph){
if(this.seperatelist[currentcapt].contains(link)) return capt;
return null;
}
if(lib.characterDialogGroup[currentcapt]){
return lib.characterDialogGroup[currentcapt](link,capt);
}
if(lib.characterPack[currentcapt]){
if(lib.characterPack[currentcapt][link]){
return capt;
}
return null;
}
return this.currentcapt;
}
if(str){
dialog.add(str);
}
dialog.add(node);
if(thisiscard){
if(seperate){
seperate=seperate(list);
dialog.seperate=[];
dialog.seperatelist=seperate.list;
if(dialog.seperatelist){
newlined=document.createElement('div');
newlined.style.marginTop='5px';
newlined.style.display='block';
newlined.style.fontFamily='xinwei';
if(get.is.phoneLayout()){
newlined.style.fontSize='32px';
}
else{
newlined.style.fontSize='22px';
}
newlined.style.textAlign='center';
node.appendChild(newlined);
for(var i in dialog.seperatelist){
var span=document.createElement('span');
span.style.margin='3px';
span.innerHTML=i;
span.link=i;
span.seperate=true;
span.addEventListener(lib.config.touchscreen?'touchend':'click',clickCapt);
newlined.appendChild(span);
}
}
for(var i in seperate){
if(i=='list') continue;
var link='';
var linkcontent=seperate[i];
if(i.indexOf('_link:')!=-1){
link=i.slice(i.indexOf('_link:')+6);
i=i.slice(0,i.indexOf('_link:'));
}
var nodesep=dialog.add(i);
nodesep.link=link;
dialog.seperate.push(nodesep);
dialog.add([linkcontent,'vcard'],noclick);
}
}
else{
dialog.add([list,'vcard'],noclick);
}
}
else{
if(precharacter){
dialog.add([list,'precharacter'],noclick);
}
else if(characterx){
dialog.add([list,'characterx'],noclick);
}
else{
dialog.add([list,'character'],noclick);
}
}
dialog.add(ui.create.div('.placeholder'));
for(i=0;ivoid 0);
}, false);
if(lib.config.cursor_style=='pointer'){
ui.window.classList.add('nopointer');
}
if(lib.config.turned_style==false){
ui.arena.classList.add('hide_turned');
}
if(lib.config.link_style2!='chain'){
ui.arena.classList.add('nolink');
}
if(lib.config.show_name==false){
ui.arena.classList.add('hide_name');
}
if(lib.config.change_skin_auto!='off'){
_status.skintimeout=setTimeout(ui.click.autoskin,parseInt(lib.config.change_skin_auto));
}
if(lib.config.border_style&&lib.config.border_style.indexOf('dragon_')==0){
ui.arena.dataset.framedecoration=lib.config.border_style.slice(7);
}
ui.gameinfo=ui.create.div('#time',ui.window);
ui.arenalog=ui.create.div('#arenalog',ui.arena);
if(lib.config.show_log=='off'){
ui.arenalog.style.display='none';
}
else{
ui.arenalog.dataset.position=lib.config.show_log;
}
ui.historybar=ui.create.div('#historybar.shadowed',ui.window);
lib.setScroll(ui.historybar);
ui.roundmenu=ui.create.div('#roundmenu.roundarenabutton.menubutton.round',ui.arena);
ui.roundmenu._position=[180,210];
ui.create.div(ui.roundmenu);
ui.create.div(ui.roundmenu);
ui.create.div(ui.roundmenu);
ui.create.div(ui.roundmenu);
ui.create.div(ui.roundmenu);
ui.create.div(ui.roundmenu);
ui.create.div(ui.roundmenu);
ui.create.div(ui.roundmenu);
ui.create.div(ui.roundmenu);
ui.create.div(ui.roundmenu);
ui.create.div(ui.roundmenu);
ui.create.div(ui.roundmenu);
ui.create.div(ui.roundmenu);
ui.create.div(ui.roundmenu);
ui.create.div(ui.roundmenu);
if(lib.config.show_time2){
ui.roundmenu.classList.add('clock');
}
ui.roundmenu.dataset.watchface=lib.config.watchface||'none';
if(get.is.phoneLayout()){
if(lib.config.show_time3){
ui.time3=ui.create.div('.touchinfo.left',ui.window);
}
ui.cardPileNumber=ui.create.div('.touchinfo.right',ui.window);
}
else{
if(lib.config.show_time3){
ui.time3=ui.create.div(ui.gameinfo);
}
ui.cardPileNumber=ui.create.div(ui.gameinfo);
}
if(!lib.config.show_cardpile_number){
ui.cardPileNumber.style.display='none';
}
if(ui.time3){
ui.time3.starttime=get.utc();
ui.time3.interval=setInterval(function(){
var num=Math.round((get.utc()-ui.time3.starttime)/1000);
if(num>=3600){
var num1=Math.floor(num/3600);
var num2=Math.floor((num-num1*3600)/60);
if(num2<10){
num2='0'+num2.toString();
}
var num3=num-num1*3600-parseInt(num2)*60;
if(num3<10){
num3='0'+num3.toString();
}
ui.time3.innerHTML=num1+':'+num2+':'+num3;
}
else{
var num1=Math.floor(num/60);
var num2=num-num1*60;
if(num2<10){
num2='0'+num2.toString();
}
ui.time3.innerHTML=num1+':'+num2;
}
},1000);
}
if(get.is.nomenu()){
if(!['menu','system'].contains(lib.config.round_menu_func)){
lib.config.round_menu_func='system';
}
}
else if(!lib.config.show_round_menu){
ui.roundmenu.style.display='none';
}
var resetround=function(e){
_status.draggingroundmenu=false;
ui.roundmenu.style.transform='';
ui.roundmenu._dragtransform=[0,0];
ui.roundmenu.style.transition='all 0.3s';
delete ui.roundmenu._dragtouches;
delete ui.roundmenu._dragorigin;
delete ui.roundmenu._dragorigintransform;
setTimeout(function(){
ui.roundmenu.style.transition='';
},500);
game.saveConfig('roundmenu_transform',[0,0]);
if(e) e.stopPropagation();
return false;
};
ui.click.resetround=resetround;
if(lib.config.touchscreen){
ui.roundmenu.addEventListener('touchstart',function(e){
_status.draggingroundmenu=true;
ui.roundmenu._dragorigin={
clientX:e.touches[0].clientX,
clientY:e.touches[0].clientY,
};
if(!ui.roundmenu._dragtransform){
ui.roundmenu._dragtransform=[0,0];
}
ui.roundmenu._dragorigintransform=ui.roundmenu._dragtransform.slice(0);
ui.roundmenu._resetTimeout=setTimeout(function(){
resetround();
delete ui.roundmenu._resetTimeout;
},1000);
});
}
else{
ui.roundmenu.oncontextmenu=resetround;
}
if(!lib.config.remember_round_button){
game.saveConfig('roundmenu_transform');
}
if(lib.config.roundmenu_transform){
var translate=lib.config.roundmenu_transform;
ui.roundmenu._dragtransform=translate;
ui.roundmenu.style.transform='translate('+translate[0]+'px,'+translate[1]+'px)';
ui.click.checkroundtranslate();
}
if(get.is.phoneLayout()){
ui.arena.classList.add('phone');
}
ui.sidebar=ui.create.div('#sidebar');
ui.sidebar3=ui.create.div('#sidebar3');
ui.canvas=document.createElement('canvas');
ui.arena.appendChild(ui.canvas);
ui.canvas.id='canvas';
ui.ctx=ui.canvas.getContext('2d');
ui.sidebar.ontouchstart=ui.click.touchStart;
ui.sidebar.ontouchmove = ui.click.touchScroll;
ui.sidebar.style.WebkitOverflowScrolling='touch';
var zoom;
switch(lib.config.ui_zoom){
case 'esmall':zoom=0.8;break;
case 'vsmall':zoom=0.9;break;
case 'small':zoom=0.93;break;
case 'big':zoom=1.05;break;
case 'vbig':zoom=1.1;break;
case 'ebig':zoom=1.2;break;
case 'eebig':zoom=1.5;break;
case 'eeebig':zoom=1.8;break;
case 'eeeebig':zoom=2;break;
default:zoom=1;
}
game.documentZoom=game.deviceZoom*zoom;
if(zoom!=1){
ui.updatez();
}
ui.system1=ui.create.div('#system1',ui.system);
ui.system2=ui.create.div('#system2',ui.system);
ui.replay=ui.create.system('重来',game.reload,true);
ui.replay.id='restartbutton';
ui.config2=ui.create.system('选项',ui.click.config);
ui.pause=ui.create.system('暂停',ui.click.pause);
ui.pause.id='pausebutton';
if(!_status.video){
ui.pause.hide();
}
if(!lib.config.touchscreen){
lib.setPopped(ui.pause,ui.click.pausehistory,220,400,null,true);
}
if(!lib.config.show_pause){
ui.pause.style.display='none';
}
ui.cardPileButton=ui.create.system('牌堆',null,true);
ui.cardPileButton.style.display='none';
lib.setPopped(ui.cardPileButton,ui.click.cardPileButton,220);
ui.wuxie=ui.create.system('不询问无懈',ui.click.wuxie,true);
if(!lib.config.touchscreen){
lib.setPopped(ui.config2,ui.click.pauseconfig,170);
}
ui.auto=ui.create.system('托管',ui.click.auto);
if(!game.syncMenu){
ui.config2.classList.add('hidden');
ui.config2.style.transition='all 0.5s';
ui.roundmenu.classList.add('transparent2');
ui.auto.style.opacity=0.5;
ui.auto.style.transition='all 0.5s';
lib.onfree.push(function(){
ui.auto.style.opacity='';
setTimeout(function(){
ui.auto.style.transition='';
},500);
});
}
ui.auto.id='autobutton';
ui.autonode=ui.create.div('#autonode','托管中...
',ui.arena);
ui.autonode.listen(ui.click.auto);
if(lib.config.mode=='connect'){
ui.auto.hide();
ui.pause.hide();
}
if(lib.forcehide){
if(lib.forcehide.contains('replay')) ui.replay.classList.add('forcehide');
if(lib.forcehide.contains('auto')) ui.auto.classList.add('forcehide');
if(lib.forcehide.contains('pause')) ui.pause.classList.add('forcehide');
if(lib.forcehide.contains('wuxie')) ui.wuxie.classList.add('forcehide');
if(lib.forcehide.contains('cardPileButton')) ui.cardPileButton.classList.add('forcehide');
}
ui.volumn=ui.create.system('♫');
lib.setPopped(ui.volumn,ui.click.volumn,200);
// if(lib.config.show_pause) ui.auto.style.marginLeft='10px';
if(!lib.config.show_volumn){
ui.volumn.style.display='none';
}
if(!lib.config.show_auto){
ui.auto.style.display='none';
}
if(!lib.config.show_wuxie){
ui.wuxie.style.display='none';
}
// if(!lib.config.show_cardpile||_status.connectMode){
// ui.cardPileButton.style.display='none';
// }
ui.sortCard=ui.create.system('整理手牌',function(){
if(!game.me) return;
var hs=game.me.getCards('h');
if(!hs.length) return;
game.addVideo('lose',game.me,[get.cardsInfo(hs),[],[],[]]);
for(var i=0;i(getn(b)-getn(a)));
}
else hs.sort(function(b,a){
if(a.name!=b.name) return lib.sort.card(a.name,b.name);
else if(a.suit!=b.suit) return lib.suit.indexOf(a)-lib.suit.indexOf(b);
else return a.number-b.number;
});
game.me.directgain(hs,false);
});
if(!lib.config.show_sortcard){
ui.sortCard.style.display='none';
}
ui.playerids=ui.create.system('显示身份',function(){
if(game.showIdentity){
game.showIdentity();
_status.identityShown=true;
}
},true);
if(!lib.config.show_playerids||!game.showIdentity){
ui.playerids.style.display='none';
}
if(!lib.config.show_replay){
ui.replay.style.display='none';
}
ui.control=ui.create.div('#control',ui.arena).animate('nozoom');
ui.cardPile=ui.create.div('#cardPile');
ui.discardPile=ui.create.div('#discardPile');
ui.special=ui.create.div('#special');
ui.ordering=ui.create.div('#ordering');
ui.dialogs=[];
ui.controls=[];
ui.style={};
ui.time=ui.create.div(ui.gameinfo);
var timeInterval=function(){
var date=new Date();
var hours=date.getHours();
var minutes=date.getMinutes();
if(lib.config.watchface=='simple'){
ui.roundmenu.childNodes[13].style.transform='rotate('+get.round((hours+9)*30,2)+'deg)';
}
else{
ui.roundmenu.childNodes[13].style.transform='rotate('+get.round((hours+minutes/60+9)*30,2)+'deg)';
}
ui.roundmenu.childNodes[12].style.transform='rotate('+(minutes+45)*6+'deg)';
if(minutes<10){
minutes='0'+minutes.toString();
}
ui.time.innerHTML=hours+':'+minutes;
};
_status.timeInterval=setInterval(timeInterval,30000);
timeInterval();
if(!lib.config.show_time){
ui.time.style.display='none';
}
ui.timer=ui.create.div('.skillbar.shadowed.playerbg.hidden');
ui.timer.id='timer';
ui.create.div('.skillbarshadow',ui.timer);
ui.create.div('.skillbarfill',ui.timer);
ui.timer.fillnode=ui.create.div(ui.timer.lastChild);
ui.timer.popnode=ui.create.div('.skillbartext',ui.timer);
ui.timer.popnode.style.opacity=1;
ui.timer.position=4;
ui.timer.style.zIndex=5;
ui.timer.set=function(text,percentage){
if(typeof text=='string'||typeof text=='number'){
ui.timer.popnode.innerHTML=text;
}
ui.timer.fillnode.style.top=((1-percentage)*100)+'%';
}
var setTimerPosition=function(e){
this.position++;
if(this.position>4){
this.position=1;
}
var left1='180px';
var left2='calc(100% - 245px)';
var top1='210px';
var top2='calc(100% - 245px)';
if(game.layout=='default'){
left1='265px';
top1='160px';
left2='calc(100% - 330px)';
top2='calc(100% - 235px)';
}
if(this.position==1||this.position==2){
this.style.top=top2;
}
else{
this.style.top=top1;
}
if(this.position==1||this.position==4){
this.style.left=left2;
}
else{
this.style.left=left1;
}
}
ui.timer.listen(setTimerPosition);
ui.shortcut=ui.create.div('#shortcut.hidden',ui.window);
ui.shortcut.listen(ui.click.shortcut);
ui.create.div(ui.shortcut,function(e){e.stopPropagation()});
ui.create.div('.menubutton.round','重来',ui.shortcut,game.reload).dataset.position=1;
ui.create.div('.menubutton.round','退出',ui.shortcut,game.exit).dataset.position=3;
ui.create.div('.menubutton.round','记录',ui.shortcut,ui.click.pause).dataset.position=4;
ui.shortcut.autobutton=ui.create.div('.menubutton.round','托管',ui.shortcut,ui.click.auto);
ui.shortcut.autobutton.dataset.position=2;
ui.favmodelist=ui.create.div('.favmodelist',ui.shortcut);
ui.favmodelist.update=function(){
this.innerHTML='';
var num=Math.min(6,lib.config.favouriteMode.length);
for(var i=0;i菜单',ui.shortcut,ui.click.config).dataset.position=5;
if(_status.connectMode){
ui.playerids.remove();
ui.pause.innerHTML='记录';
}
setTimerPosition.call(ui.timer);
ui.arena.appendChild(ui.timer);
if(!game.syncMenu){
lib.onfree.push(function(){
ui.create.menu();
ui.config2.classList.remove('hidden');
ui.roundmenu.classList.remove('transparent2');
setTimeout(function(){
ui.config2.style.transition='';
},500);
});
}
else{
ui.create.menu();
}
lib.status.date=new Date();
lib.status.dateDelayed=0;
while(lib.arenaReady.length){
(lib.arenaReady.shift())();
}
delete lib.arenaReady;
if(lib.config.auto_check_update){
setTimeout(function(){
game.checkForUpdate(false);
},3000);
}
if(!lib.config.asset_version){
lib.onfree.push(function(){
setTimeout(function(){
if(!game.download){
game.saveConfig('asset_version','无');
}
else{
var func=function(){
if(confirm('是否下载图片和字体素材?(约175MB)')){
if(!ui.arena.classList.contains('menupaused')){
ui.click.configMenu();
ui.click.menuTab('其它');
}
setTimeout(game.checkForAssetUpdate,500);
}
else{
game.saveConfig('asset_version','无');
}
}
if(_status.new_tutorial){
_status.new_tutorial=func;
}
else{
func();
}
}
},3000);
});
}
if(localStorage.getItem(lib.configprefix+'playback')){
setTimeout(lib.init.onfree);
}
if(lib.config.test_game){
ui.window.classList.add('testing');
lib.config.game_speed='vfast';
lib.config.low_performance=true;
lib.config.animation=false;
_status.auto=true;
ui.auto.classList.add('glow');
setTimeout(function(){
var node=ui.create.pause().animate('start');
node.appendChild(ui.sidebar);
node.firstChild.innerHTML='正在测试';
node.removeEventListener('click',ui.click.resume);
},500);
}
},
system:function(str,func,right,before){
var parent=right?ui.system2:ui.system1;
var node=ui.create.div();
if(before){
parent.insertBefore(node,parent.firstChild);
}
else{
parent.appendChild(node);
}
node.innerHTML=str;
if(func){
node.listen(func);
}
if(lib.config.button_press){
node.addEventListener(lib.config.touchscreen?'touchstart':'mousedown',function(e){
if(!node.classList.contains('hidden')) node.classList.add('pressdown');
});
node.addEventListener(lib.config.touchscreen?'touchend':'mouseup',function(e){
node.classList.remove('pressdown');
});
node.addEventListener(lib.config.touchscreen?'touchmove':'mousemove',function(e){
node.classList.remove('pressdown');
});
}
return node;
},
pause:function(){
if(_status.pausing) return;
ui.click.shortcut(false);
var node=ui.create.div(".pausedbg",ui.window);
_status.pausing=true;
setTimeout(function(){
_status.pausing=false;
},500);
if(lib.config.touchscreen){
setTimeout(function(){
node.addEventListener('touchend',ui.click.resume);
},500);
}
else{
node.addEventListener('click',ui.click.resume);
}
if(!lib.config.touchscreen){
node.oncontextmenu=ui.click.resume;
}
var node2=ui.create.div(node);
if(_status.connectMode){
node2.innerHTML='';
}
else{
node2.innerHTML='已暂停';
}
// node2.listen(function(){
// _status.clicked=true;
// if(ui.sidebar.classList.contains('hidden')){
// ui.sidebar.show();
// ui.sidebar3.show();
// }
// else{
// ui.sidebar.hide();
// ui.sidebar3.hide();
// }
// });
return node;
},
prebutton:function(item,type,position,noclick){
var node=ui.create.div(position);
node.style.display='none';
node.link=item;
node.activate=function(){
ui.create.button(item,type,position,noclick,node);
delete node.activate;
}
_status.prebutton.push(node);
return node;
},
button:function(item,type,position,noclick,node){
switch(type){
case 'tdnodes':
node=ui.create.div('.shadowed.reduce_radius.pointerdiv.tdnode.tdnodes',position);
if(Array.isArray(item)){
node.innerHTML=''+(item[1])+'';
node.link=item[0];
}
else{
node.innerHTML=''+(item)+'';
node.link=item;
}
break;
case 'blank':
node=ui.create.div('.button.card',position);
node.link=item;
break;
case 'card':
if(typeof item.copy=='function'){
node=item.copy(false);
}
else{
node=item.cloneNode(true);
}
node.classList.add('button');
if(position) position.appendChild(node);
node.link=item;
if(item.style.backgroundImage){
node.style.backgroundImage=item.style.backgroundImage;
node.style.backgroundSize='cover';
}
if(item.style.color){
node.style.color=item.style.color;
}
if(item.nature){
node.classList.add(item.nature);
}
if(!noclick){
lib.setIntro(node);
}
if(get.position(item)=='j'&&item.viewAs&&item.viewAs!=item.name&&lib.config.cardtempname!='off'){
node._tempName=ui.create.div('.tempname',node);
var tempname=get.translation(item.viewAs);
node._tempName.dataset.nature='wood';
node._tempName.innerHTML=lib.config.cardtempname=='default'?get.verticalStr(tempname):tempname;
node._tempName.tempname=tempname;
}
break;
case 'vcard':
if(typeof item=='string'){
item=[get.type(item),'',item];
}
node=ui.create.card(position,'noclick',noclick);
node.classList.add('button');
node.init(item);
node.link=item;
break;
case 'character':case 'player':case 'characterx':
if(node){
node.classList.add('button');
node.classList.add('character');
node.style.display='';
}
else{
node=ui.create.div('.button.character',position);
}
node._link=item;
if(_status.noReplaceCharacter&&type=='characterx') type='character';
if(type=='characterx'){
if(lib.characterReplace[item]&&lib.characterReplace[item].length) item=lib.characterReplace[item].randomGet();
}
node.link=item;
if(type=='character'||type=='characterx'){
var double=get.is.double(node._link,true);
if(double) node._changeGroup=true;
if(type=='characterx'&&lib.characterReplace[node._link]&&lib.characterReplace[node._link].length>1) node._replaceButton=true;
var func=function(node,item){
node.setBackground(item,'character');
if(node.node){
node.node.name.remove();
node.node.hp.remove();
node.node.group.remove();
node.node.intro.remove();
if(node.node.replaceButton) node.node.replaceButton.remove();
}
node.node={
name:ui.create.div('.name',node),
hp:ui.create.div('.hp',node),
group:ui.create.div('.identity',node),
intro:ui.create.div('.intro',node),
};
var infoitem=lib.character[item];
if(!infoitem){
for(var itemx in lib.characterPack){
if(lib.characterPack[itemx][item]){
infoitem=lib.characterPack[itemx][item];break;
}
}
}
node.node.name.innerHTML=get.slimName(item);
if(lib.config.buttoncharacter_style=='default'||lib.config.buttoncharacter_style=='simple'){
if(lib.config.buttoncharacter_style=='simple'){
node.node.group.style.display='none';
}
node.classList.add('newstyle');
if(double&&double.length){
node.node.name.dataset.nature=get.groupnature(double[0]);
node.node.group.dataset.nature=get.groupnature(double[double.length==2?1:0]);
}
else{
node.node.name.dataset.nature=get.groupnature(get.bordergroup(infoitem));
node.node.group.dataset.nature=get.groupnature(get.bordergroup(infoitem),'raw');
}
ui.create.div(node.node.hp);
var hp=get.infoHp(infoitem[2]),maxHp=get.infoMaxHp(infoitem[2]),hujia=get.infoHujia(infoitem[2]);
var str=get.numStr(hp);
if(hp!=maxHp){
str+='/';
str+=get.numStr(maxHp);
}
var textnode=ui.create.div('.text',str,node.node.hp);
if(infoitem[2]==0){
node.node.hp.hide();
}
else if(get.infoHp(infoitem[2])<=3){
node.node.hp.dataset.condition='mid';
}
else{
node.node.hp.dataset.condition='high';
}
if(hujia>0){
ui.create.div(node.node.hp,'.shield');
ui.create.div('.text',get.numStr(hujia),node.node.hp);
}
}
else{
var hp=get.infoHp(infoitem[2]);
var maxHp=get.infoMaxHp(infoitem[2]);
var shield=get.infoHujia(infoitem[2]);
if(maxHp>14){
if(typeof infoitem[2]=='string') node.node.hp.innerHTML=infoitem[2];
else node.node.hp.innerHTML=get.numStr(infoitem[2]);
node.node.hp.classList.add('text');
}
else{
for(var i=0;i=hp) next.classList.add('exclude');
}
for(var i=0;i=4){
node.node.name.classList.add('long');
if(lib.config.buttoncharacter_style=='old'){
node.addEventListener('mouseenter',ui.click.buttonnameenter);
node.addEventListener('mouseleave',ui.click.buttonnameleave);
}
}
node.node.intro.innerHTML=lib.config.intro;
if(!noclick){
lib.setIntro(node);
}
if(infoitem[1]){
if(double){
var str='';
if(double.length==2){
for(var i of double){
str+=get.translation(i);
}
}
else str+=get.translation(double[0]);
str+='
';
node.node.group.innerHTML=str;
}
else node.node.group.innerHTML=''+get.translation(infoitem[1])+'
';
node.node.group.style.backgroundColor=get.translation(get.bordergroup(infoitem)+'Color');
}
else{
node.node.group.style.display='none';
}
if(node._replaceButton){
var intro=ui.create.div('.button.replaceButton',node);
node.node.replaceButton=intro;
intro.innerHTML='切换';
intro._node=node;
intro.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
_status.tempNoButton=true;
var node=this._node;
var list=lib.characterReplace[node._link];
var link=node.link;
var index=list.indexOf(link);
if(index==list.length-1) index=0;
else index++;
link=list[index];
node.link=link;
node.refresh(node,link);
setTimeout(function(){
delete _status.tempNoButton;
},200);
});
}
};
node.refresh=func;
node.refresh(node,item);
}
else{
node.node={
name:ui.create.div('.name',node),
intro:ui.create.div('.intro',node)
}
if(item.name&&item.name.indexOf('unknown')==0){
if(item.node&&item.node.name_seat){
node.classList.add('cardbg');
ui.create.div('.avatar_name',node,get.translation(item.name));
}
else{
node.setBackground(item.name1,'character');
}
}
else{
node.setBackground(item.name,'character');
}
}
break;
}
if(!noclick){
node.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
}
else{
node.classList.add('noclick');
if(node.querySelector('.intro')){
node.querySelector('.intro').remove();
}
}
for(var i in lib.element.button){
node[i]=lib.element.button[i];
}
return node;
},
buttons:function(list,type,position,noclick,zoom){
var buttons=[];
var pre=(type.slice(0,3)=='pre');
if(pre){
if(!_status.prebutton){
_status.prebutton=[];
lib.onfree.push(function(){
for(var i=0;i<_status.prebutton.length;i++){
if(_status.prebutton[i].activate){
_status.prebutton[i].activate();
}
}
delete _status.prebutton;
});
}
}
for(var i=0;i';
var next=dialog.add(str);
if(!noclick) next.firstChild.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
next.firstChild.link=link;
for(var j in lib.element.button){
next[j]=lib.element.button[j];
}
dialog.buttons.add(next.firstChild)
}
},
player:function(position,noclick){
var node=ui.create.div('.player',position);
node.node={
avatar:ui.create.div('.avatar',node,ui.click.avatar).hide(),
avatar2:ui.create.div('.avatar2',node,ui.click.avatar2).hide(),
turnedover:ui.create.div('.turned',''+get.verticalStr('翻面')+'
',node),
framebg:ui.create.div('.framebg',node),
intro:ui.create.div('.intro',node),
identity:ui.create.div('.identity',node),
hp:ui.create.div('.hp',node),
name:ui.create.div('.name',node),
name2:ui.create.div('.name.name2',node),
nameol:ui.create.div('.nameol',node),
count:ui.create.div('.count',node).hide(),
equips:ui.create.div('.equips',node).hide(),
judges:ui.create.div('.judges',node),
marks:ui.create.div('.marks',node),
chain:ui.create.div('.chain','
',node),
handcards1:ui.create.div('.handcards'),
handcards2:ui.create.div('.handcards'),
expansions:ui.create.div('.expansions'),
};
node.node.expansions.display='none';
var chainlength=game.layout=='default'?64:40;
for(var i=0;i
=lib.configOL.number){
player.classList.add('unselectable2');
}
}
var bar=ui.create.div(ui.window);
bar.style.height='20px';
bar.style.width='80%';
bar.style.left='10%';
bar.style.top='calc(200% / 7 - 120px + 5px)';
bar.style.textAlign='center';
var ipbar=ui.create.div('.shadowed',ip,bar);
ipbar.style.padding='4px';
ipbar.style.borderRadius='2px';
ipbar.style.position='relative';
var button=ui.create.div('.menubutton.large.highlight.connectbutton.pointerdiv',game.online?'退出联机':'开始游戏',ui.window,function(){
if(button.clicked) return;
if(game.online){
if(game.onlinezhu){
game.send('startGame');
}
else{
game.saveConfig('tmp_owner_roomId');
game.saveConfig('tmp_user_roomId');
game.saveConfig('reconnect_info');
game.reload();
}
}
else{
var num=0;
for(var i of game.connectPlayers){
if(!i.nickname&&!i.classList.contains('unselectable2')) num++;
}
if(num>=lib.configOL.number-1){
alert('至少要有两名玩家才能开始游戏!');
return;
}
game.resume();
}
button.delete();
bar.delete();
delete ui.connectStartButton;
delete ui.connectStartBar;
button.clicked=true;
});
ui.connectStartButton=button;
ui.connectStartBar=bar;
},
players:function(num){
if(num===0){
return;
}
if(num==undefined) num=lib.configOL.number;
if(num==undefined) num=get.playerNumber();
if(typeof num=='string'){
num=parseInt(num);
}
if(!num) num=5;
for(var i=0;i0){
players[i].previous=players[i-1];
players[i].previousSeat=players[i-1];
}
if(i');
uiintro.content.lastChild.style.paddingTop=0;
button.input=uiintro.content.lastChild.lastChild;
button.input.onfocus=function(){
button.focused=true;
}
button.input.onblur=function(){
delete button.focused;
}
if(button.interval){
button.input.disabled=true;
button.input.style.opacity=0.6;
if(button.intervaltext){
button.textnode.innerHTML=button.intervaltext;
}
}
var datenode=ui.create.div(uiintro.content);
datenode.style.marginTop=0;
datenode.style.whiteSpace='nowrap';
var date=new Date();
var days=[];
var currentDay=date.getDay();
if(currentDay==0) currentDay=7;
for(var i=1;i<=7;i++){
if(i7){
initday-=7;
}
var daysselect=ui.create.selectlist(days,initday.toString(),datenode);
daysselect.style.width='55px';
var hours=[];
for(var i=0;i<24;i++){
hours.push([i.toString(),i.toString()+'点']);
}
var hoursselect=ui.create.selectlist(hours,date.getHours().toString(),datenode);
hoursselect.style.marginLeft='5px';
hoursselect.style.width='55px';
var timeconfirm=ui.create.node('button','确定',datenode);
timeconfirm.style.marginLeft='5px';
timeconfirm.onclick=function(){
if(!button.input.value){
alert('请填写约战标题');
return;
}
var date2=new Date();
date2.setHours(parseInt(hoursselect.value));
date2.setMinutes(0);
date2.setSeconds(0);
var deltaday=parseInt(daysselect.value)-currentDay;
if(deltaday<0){
deltaday+=7;
}
var utc=date2.getTime()+deltaday*24*3600000;
if(utcID:'+button.info[i].creator,eventnode);
ui.create.div('','已有'+(button.info[i].members.length)+'人加入',eventnode);
ui.create.div('','时间:'+str,eventnode);
if(button.info[i].members.contains(game.onlineKey)){
eventnode.classList.add('active');
}
}
else{
ui.create.div('.title',button.info[i].title,eventnode);
ui.create.div('',button.info[i].content,eventnode);
ui.create.div('','创建者:'+(button.info[i].nickname),eventnode);
}
}
if(num>=3){
button.input.disabled=true;
button.input.style.opacity=0.6;
hoursselect.disabled=true;
daysselect.disabled=true;
timeconfirm.disabled=true;
}
}
uiintro.refresh();
ui.window.appendChild(uiintro);
_status.connectEventsCallback=function(){
if(uiintro.parentNode==ui.window){
uiintro.refresh();
}
};
}
},
connectClients:function(){
if(this.info){
var button=this;
var layer=ui.create.div('.poplayer',ui.window);
var uiintro=ui.create.dialog('hidden','notouchscroll');
this.classList.add('active');
if(lib.config.touchscreen){
lib.setScroll(uiintro.contentContainer);
}
layer.listen(function(){
if(this.clicked){
this.clicked=false;
return;
}
button.classList.remove('active');
uiintro.delete();
this.delete();
});
uiintro.listen(function(){
_status.clicked=true;
});
uiintro.style.zIndex=21;
uiintro.classList.add('popped');
uiintro.classList.add('static');
uiintro.classList.add('onlineclient');
uiintro.style.width='180px';
uiintro.style.height='300px';
uiintro.style.left='auto';
uiintro.style.right='20px';
uiintro.style.top='auto';
uiintro.style.bottom='75px';
uiintro.refresh=function(){
if(button.focused) return;
uiintro.content.innerHTML='';
uiintro.addText('发状态');
button.textnode=uiintro.content.lastChild.lastChild;
uiintro.add('');
uiintro.content.lastChild.style.paddingTop=0;
button.input=uiintro.content.lastChild.lastChild;
button.input.onfocus=function(){
button.focused=true;
}
button.input.onblur=function(){
delete button.focused;
}
if(button.interval){
button.input.disabled=true;
button.input.style.opacity=0.6;
if(button.intervaltext){
button.textnode.innerHTML=button.intervaltext;
}
}
button.input.onkeydown=function(e){
if(e.keyCode==13&&!this.disabled){
game.send('server','status',this.value);
this.blur();
this.disabled=true;
this.style.opacity=0.6;
button.textnode.innerHTML='发状态(10)';
button.intervaltext=button.textnode.innerHTML;
var num=10;
var that=this;
button.input.disabled=true;
button.input.style.opacity=0.6;
this.value='';
button.interval=setInterval(function(){
num--;
if(num>0){
button.textnode.innerHTML='发状态('+num+')';
button.intervaltext=button.textnode.innerHTML;
}
else{
button.textnode.innerHTML='发状态';
button.input.disabled=false;
button.input.style.opacity='';
clearInterval(button.interval);
delete button.interval;
delete button.intervaltext;
}
},1000);
}
}
for(var i=0;i'+(button.info[i][0]||'无名玩家'),node);node.isme=true;
}
else if(button.info[i][2]){
ui.create.div('.name',(button.info[i][0]||'无名玩家'),node);
}
else{
ui.create.div('.name',''+(button.info[i][0]||'无名玩家'),node);
}
//show ID
//ui.create.div('.videostatus',node,button.info[i][5]);
//node.classList.add('videonodestatus');
if(button.info[i][3]){
ui.create.div('.videostatus',node,button.info[i][3].slice(0,80));
node.classList.add('videonodestatus')
}
}
};
uiintro.refresh();
ui.window.appendChild(uiintro);
_status.connectClientsCallback=function(){
if(uiintro.parentNode==ui.window){
uiintro.refresh();
}
};
}
},
autoskin:function(){
if(!lib.config.change_skin) return;
var players=game.filterPlayer();
var change=function(player,num,callback){
if(num=='1'){
ui.click.skin(player.node.avatar,player.name,callback);
}
else{
ui.click.skin(player.node.avatar2,player.name2,callback);
}
};
var finish=function(){
if(lib.config.change_skin_auto!='off'){
_status.skintimeout=setTimeout(ui.click.autoskin,parseInt(lib.config.change_skin_auto));
}
};
var autoskin=function(){
if(players.length){
var player=players.randomRemove();
var list=[];
if(player.name&&!player.isUnseen(0)){
list.push('1');
}
if(player.name2&&!player.isUnseen(1)){
list.push('2');
}
if(list.length){
change(player,list.randomRemove(),function(bool){
if(bool){
finish();
}
else if(list.length){
change(player,list[0],function(bool){
if(bool){
finish();
}
else{
autoskin();
}
});
}
else{
autoskin();
}
});
}
else{
autoskin();
}
}
}
autoskin();
},
skin:function(avatar,name,callback){
var num=1;
if(name.indexOf('gz_')==0){
name=name.slice(3);
}
if(lib.config.skin[name]){
num=lib.config.skin[name]+1;
}
var fakeavatar=avatar.cloneNode(true);
var finish=function(bool){
var player=avatar.parentNode;
if(bool){
fakeavatar.style.boxShadow='none';
player.insertBefore(fakeavatar,avatar.nextSibling);
setTimeout(function(){
fakeavatar.delete();
},100);
}
if(bool&&lib.config.animation&&!lib.config.low_performance){
player.$rare();
}
if(callback){
callback(bool);
}
}
var img=new Image();
img.onload=function(){
lib.config.skin[name]=num;
game.saveConfig('skin',lib.config.skin);
avatar.style.backgroundImage='url("'+img.src+'")';
finish(true);
}
img.onerror=function(){
if(lib.config.skin[name]){
finish(true);
}
else{
finish(false);
}
delete lib.config.skin[name];
game.saveConfig('skin',lib.config.skin);
avatar.setBackground(name,'character');
}
img.src=lib.assetURL+'image/skin/'+name+'/'+num+'.jpg';
},
touchpop:function(forced){
if(lib.config.touchscreen||forced){
_status.touchpopping=true;
clearTimeout(_status.touchpoppingtimeout);
_status.touchpoppingtimeout=setTimeout(function(){
_status.touchpopping=false;
},600);
}
},
exit:function(){
if(game.servermode&&lib.config.reconnect_info&&_status.over){
if(!_status.roomtimeout){
lib.config.reconnect_info[2]=game.roomId;
game.saveConfig('reconnect_info',lib.config.reconnect_info);
}
game.reload();
return;
}
else{
if(typeof game.roomId!='string'){
game.saveConfig('reconnect_info');
}
}
if(!ui.exit||!ui.exit.stay){
if(lib.config.reconnect_info){
lib.config.reconnect_info.length=1;
game.saveConfig('reconnect_info',lib.config.reconnect_info);
}
game.saveConfig('tmp_user_roomId',undefined,false,function(){
game.reload();
});
}
else{
game.reload();
}
},
shortcut:function(show){
if(show===false){
ui.shortcut.classList.add('hidden');
}
else{
ui.shortcut.classList.toggle('hidden');
}
if(ui.shortcut.classList.contains('hidden')){
ui.favmode.style.display='none';
if(window.StatusBar&&lib.config.show_statusbar_ios=='auto'){
document.body.classList.remove('statusbar');
window.StatusBar.hide();
}
ui.window.classList.remove('shortcutpaused');
}
else{
if(lib.config.show_favmode){
ui.favmode.style.display='';
}
if(window.StatusBar&&lib.config.show_statusbar_ios=='auto'){
document.body.classList.add('statusbar');
window.StatusBar.overlaysWebView(true);
window.StatusBar.backgroundColorByName('black');
window.StatusBar.show();
}
if(_status.auto){
ui.shortcut.autobutton.classList.add('active');
}
else{
ui.shortcut.autobutton.classList.remove('active');
}
ui.window.classList.add('shortcutpaused');
}
},
favouriteCharacter:function(e){
if(typeof this.link=='string'){
if(this.innerHTML=='添加收藏'){
this.innerHTML='移除收藏';
lib.config.favouriteCharacter.add(this.link);
}
else{
this.innerHTML='添加收藏';
lib.config.favouriteCharacter.remove(this.link);
}
if(ui.favouriteCharacter){
if(lib.config.favouriteCharacter.contains(this.link)){
for(var i=0;i=node.scrollHeight){
clearInterval(that.buttonscrollinterval);
delete that.buttonscrollinterval;
}
else{
if(num>0){
num--;
}
else{
node.scrollTop+=2;
}
}
},16);
}
},
buttonnameleave:function(){
if(this.buttonscrollinterval){
clearInterval(this.buttonscrollinterval);
}
var node=this.node.name;
if(node.offsetHeight1&&
!this.classList.contains('popped')&&
!this.classList.contains('fixed')){
_status.draggingtouchdialog=this;
this._dragorigin={
clientX:e.touches[0].clientX,
clientY:e.touches[0].clientY,
};
if(!this._dragtransform){
this._dragtransform=[0,0];
}
this._dragorigintransform=this._dragtransform.slice(0);
e.preventDefault();
e.stopPropagation();
}
},
identity:function(e){
if(_status.dragged) return;
_status.clicked=true;
if(!game.getIdentityList) return;
if(_status.video) return;
if(this.parentNode.forceShown) return;
if(_status.clickingidentity){
for(var i=0;i<_status.clickingidentity[1].length;i++){
_status.clickingidentity[1][i].delete();
_status.clickingidentity[1][i].style.transform='';
}
if(_status.clickingidentity[0]==this.parentNode){
delete _status.clickingidentity;
return;
}
}
var list=game.getIdentityList(this.parentNode);
if(!list) return;
if(lib.config.mark_identity_style=='click'){
var list2=[];
for(var i in list){
list2.push(i);
}
list2.push(list2[0]);
for(var i=0;i'+num);
if(_status.connectMode) return uiintro;
uiintro.add('轮数 '+game.roundNumber+' 洗牌 '+game.shuffleNumber+'
');
uiintro.add('弃牌堆
');
if(ui.discardPile.childNodes.length){
var list=[];
for(var i=0;i无');
}
return uiintro;
},
chat:function(){
ui.system1.classList.add('shown');
ui.system2.classList.add('shown');
var uiintro=ui.create.dialog('hidden');
uiintro.listen(function(e){
e.stopPropagation();
});
var list=ui.create.div('.caption');
if(get.is.phoneLayout()){
list.style.maxHeight='110px';
}
else{
list.style.maxHeight='220px';
}
list.style.overflow='scroll';
lib.setScroll(list);
uiintro.contentContainer.style.overflow='hidden';
var input;
var addEntry=function(info,clear){
if(list._chatempty){
list.innerHTML='';
delete list._chatempty;
}
var node=ui.create.div('.text.chat');
node.innerHTML=info[0]+': '+info[1];
list.appendChild(node);
list.scrollTop=list.scrollHeight;
uiintro.style.height=uiintro.content.scrollHeight+'px';
}
_status.addChatEntry=addEntry;
_status.addChatEntry._origin=uiintro;
if(lib.chatHistory.length){
for(var i=0;i
');
node.style.paddingTop=0;
node.style.marginBottom='16px';
input=node.firstChild;
input.style.width='calc(100% - 20px)';
input.onchange=function(){
_status.chatValue=input.value;
}
input.onkeydown=function(e){
if(e.keyCode==13&&input.value){
var player=game.me;
var str=input.value;
if(!player){
if(game.connectPlayers){
if(game.online){
for(var i=0;i',function(){
emotionTitle.innerHTML=get.translation(this.pack);
for(var j=1;j<=lib.emotionList[this.pack];j++){
var emotionButton=ui.create.div('.card.fullskin','',function(){
var player=game.me;
if(!player){
if(game.connectPlayers){
if(game.online){
for(var i=0;iui.window.offsetWidth-10){
left=ui.window.offsetWidth-width-10;
}
uiintro.style.left=left+'px';
uiintro._poppedorigin=this;
if(!lib.config.touchscreen){
uiintro.addEventListener('mouseleave',ui.click.leavehoverpopped);
}
ui.click.shortcut(false);
if(uiintro._onopen){
uiintro._onopen();
}
if(this._paused2&&!lib.config.touchscreen){
game.pause2();
uiintro.classList.add('static');
var layer=ui.create.div('.poplayer',ui.window);
var clicklayer=function(e){
uiintro.delete();
layer.remove();
game.resume2();
e.stopPropagation();
return false;
}
uiintro.style.zIndex=21;
layer.onclick=clicklayer;
layer.oncontextmenu=clicklayer;
uiintro.addEventListener('mouseleave',clicklayer);
uiintro.addEventListener('click',clicklayer);
}
},
hoverpopped_leave:function(){
this._poppedalready=false;
},
leavehoverpopped:function(){
if(_status.dragged) return;
if(this.classList.contains('noleave')) return;
this.delete();
var button=this._poppedorigin;
var uiintro=this;
setTimeout(function(){
if(button._uiintro==uiintro){
delete button._uiintro;
}
},500);
},
dierevive:function(){
if(game.me.isDead()){
game.me.revive(Math.max(1,game.me.maxHp));
game.me.draw(2);
}
else{
if(ui.revive){
ui.revive.close();
delete ui.revive;
}
}
},
dieswap:function(){
if(game.me.isDead()){
_status.clicked=true;
var i,translation,intro,str;
if(ui.intro){
ui.intro.close();
if(ui.intro.source=='dieswap'){
delete ui.intro;
ui.control.show();
game.resume2();
return;
}
}
game.pause2();
ui.control.hide();
ui.intro=ui.create.dialog();
ui.intro.source='dieswap';
var players=[];
for(var i=0;i100){
if(ui.roundmenu._resetTimeout){
clearTimeout(ui.roundmenu._resetTimeout);
delete ui.roundmenu._resetTimeout;
}
}
ui.roundmenu._dragtouches=e.touches[0];
ui.click.checkroundtranslate(translate);
}
_status.clicked=true;
}
else if(_status.draggingtouchdialog){
delete _status._swipeorigin;
if(_status.draggingtouchdialog._dragorigin&&_status.draggingtouchdialog._dragtransform&&e.touches.length){
var translate=_status.draggingtouchdialog._dragtransform.slice(0);
var dx=e.touches[0].clientX/game.documentZoom-_status.draggingtouchdialog._dragorigin.clientX/game.documentZoom;
var dy=e.touches[0].clientY/game.documentZoom-_status.draggingtouchdialog._dragorigin.clientY/game.documentZoom;
translate[0]+=dx;
translate[1]+=dy;
_status.draggingtouchdialog._dragtouches=e.touches[0];
ui.click.checkdialogtranslate(translate,_status.draggingtouchdialog);
}
_status.clicked=true;
}
else if(_status._swipeorigin&&e.touches[0]){
_status._swipeorigin.touches=e.touches[0];
}
if(_status.mousedragging&&e.touches.length){
e.preventDefault();
var item=document.elementFromPoint(e.touches[0].clientX,e.touches[0].clientY);
if(game.chess&&ui.selected.cards.length){
var itemtype=get.itemtype(item);
if(itemtype!='card'&&itemtype!='button'){
var ex=e.touches[0].clientX/game.documentZoom-ui.arena.offsetLeft;
var ey=e.touches[0].clientY/game.documentZoom-ui.arena.offsetTop;
for(var i=0;ileft&&extop&&eyitem.offsetLeft&&exitem.offsetTop&&ey=0){
if(dy<=0){
deg+=90;
}
else{
deg=90-deg;
}
}
else{
if(dy<=0){
deg=270-deg;
}
else{
deg+=270;
}
}
node.style.transform='rotate('+(-deg)+'deg) scaleY(0)';
node.style.height=get.xyDistance(from,to)+'px';
if(game.chess){
ui.chess.appendChild(node);
}
else{
ui.arena.appendChild(node);
}
ui.refresh(node);
node.show();
node.style.transform='rotate('+(-deg)+'deg) scaleY(1)';
ui.touchlines.push(node);
node._origin=item;
}
}
}
else{
_status.lastdragchange.remove(item);
for(var i=0;i200){
goswipe(lib.config.swipe_down);
}
}
else if(Math.abs(dy)<100){
if(dx<-200){
goswipe(lib.config.swipe_left);
}
else if(dx>200){
goswipe(lib.config.swipe_right);
}
}
}
}
var tmpflag=false;
_status.mousedown=false;
_status.clicked=false;
if(_status.mousedragging&&_status.mouseleft){
if(game.check()){
if(ui.confirm){
ui.confirm.close();
}
var event=_status.event;
if(!event.filterOk||event.filterOk()) ui.click.ok();
ui.canvas.width=ui.arena.offsetWidth;
ui.canvas.height=ui.arena.offsetHeight;
}
else{
game.uncheck();
game.check();
}
}
else if(_status.mousedragging&&_status.mousedragorigin){
tmpflag=_status.mousedragorigin;
}
_status.lastdragchange.length=0;
_status.mousedragging=null;
_status.mouseleft=false;
_status.mousedragorigin=null;
_status.dragstatuschanged=false;
while(ui.touchlines.length){
ui.touchlines.shift().delete();
}
if(tmpflag){
game.check();
}
_status.dragged=false;
_status.clicked=false;
},
checkroundtranslate:function(translate){
var translate=translate||ui.roundmenu._dragtransform;
if(translate[1]+ui.roundmenu._position[1]+50+ui.arena.offsetTop>ui.window.offsetHeight){
translate[1]=ui.window.offsetHeight-(ui.roundmenu._position[1]+50)-ui.arena.offsetTop;
}
else if(translate[1]+ui.roundmenu._position[1]+ui.arena.offsetTop<0){
translate[1]=-ui.roundmenu._position[1]-ui.arena.offsetTop;
}
if(translate[0]+ui.roundmenu._position[0]+50+ui.arena.offsetLeft>ui.window.offsetWidth){
translate[0]=ui.window.offsetWidth-(ui.roundmenu._position[0]+50)-ui.arena.offsetLeft;
}
else if(translate[0]+ui.roundmenu._position[0]+ui.arena.offsetLeft<0){
translate[0]=-ui.roundmenu._position[0]-ui.arena.offsetLeft;
}
ui.roundmenu.style.transform='translate('+translate[0]+'px,'+translate[1]+'px)';
},
checkdialogtranslate:function(translate,dialog){
var translate=translate||dialog._dragtransform;
if(Math.sqrt(translate[0]*translate[0]+translate[1]*translate[1])<10){
translate[0]=0;
translate[1]=0;
}
dialog.style.transform='translate('+translate[0]+'px,'+translate[1]+'px)';
},
windowmousewheel:function(e){
_status.tempunpopup=e;
},
windowmousemove:function(e){
if(window.inSplash) return;
if(_status.tempunpopup){
if(get.evtDistance(_status.tempunpopup,e)>5){
delete _status.tempunpopup;
}
}
if(e.button==2) return;
var dialogs=document.querySelectorAll('#window>.dialog.popped:not(.static)');
for(var i=0;ileft&&extop&&eyitem.offsetLeft&&exitem.offsetTop&&ey.dialog.popped:not(.static)');
for(var i=0;ilib.versionOL){
alert('加入失败:你的游戏版本过低');
}
else{
alert('加入失败:房主的游戏版本过低');
}
}
else{
if(!_status.enteringroom){
_status.enteringroom=true;
_status.enteringroomserver=this.serving;
game.send('server','enter',this.key,get.connectNickname(),lib.config.connect_avatar);
}
}
},
player:function(){
return ui.click.target.apply(this,arguments);
},
target:function(e){
if(_status.dragged) return;
if(_status.clicked) return;
if(ui.intro) return;
if(this.classList.contains('connect')){
if(game.online){
if(game.onlinezhu){
if(!this.playerid&&game.connectPlayers){
if(lib.configOL.mode=='versus'||lib.configOL.mode=='doudizhu') return;
if(lib.configOL.mode=='identity'&&lib.configOL.identity_mode=='zhong') return;
if(!this.classList.contains('unselectable2')&&lib.configOL.number<=2) return;
this.classList.toggle('unselectable2')
if(this.classList.contains('unselectable2')){
lib.configOL.number--;
}
else{
lib.configOL.number++;
}
game.send('changeNumConfig',lib.configOL.number,
game.connectPlayers.indexOf(this),this.classList.contains('unselectable2'));
}
}
return;
}
if(this.playerid){
if(this.ws){
if(confirm('是否踢出'+this.nickname+'?')){
var id=get.id();
this.ws.send(function(id){
if(game.ws){
game.ws.close();
game.saveConfig('reconnect_info');
game.saveConfig('banned_info',id);
}
},id);
lib.node.banned.push(id);
}
}
}
else{
if(lib.configOL.mode=='versus'||lib.configOL.mode=='doudizhu'||lib.configOL.mode=='single') return;
if(lib.configOL.mode=='identity'&&(lib.configOL.identity_mode=='zhong'||lib.configOL.identity_mode=='purple')) return;
if(!this.classList.contains('unselectable2')&&lib.configOL.number<=2) return;
this.classList.toggle('unselectable2')
if(this.classList.contains('unselectable2')){
lib.configOL.number--;
}
else{
lib.configOL.number++;
}
game.send('server','config',lib.configOL);
game.updateWaiting();
}
return;
}
_status.clicked=true;
var custom=_status.event.custom;
if(custom&&custom.replace.target){
custom.replace.target(this,e);
return;
}
if(this.classList.contains('selectable')==false) return;
this.unprompt();
if(this.classList.contains('selected')){
ui.selected.targets.remove(this);
if(_status.multitarget||_status.event.complexSelect){
game.uncheck();
game.check();
}
else{
this.classList.remove('selected');
}
}
else{
ui.selected.targets.add(this);
if(_status.event.name=='chooseTarget'||_status.event.name=='chooseToUse'||_status.event.name=='chooseCardTarget'){
var targetprompt=null;
if(_status.event.targetprompt){
targetprompt=_status.event.targetprompt;
}
else if(_status.event.skill&&!get.info(_status.event.skill).viewAs){
targetprompt=get.info(_status.event.skill).targetprompt;
}
else if(_status.event.name=='chooseToUse'){
var currentcard=get.card();
if(currentcard){
targetprompt=get.info(currentcard).targetprompt;
}
}
if(targetprompt){
if(Array.isArray(targetprompt)){
targetprompt=targetprompt[Math.min(targetprompt.length-1,ui.selected.targets.indexOf(this))];
}
else if(typeof targetprompt=='function'){
targetprompt=targetprompt(this);
}
if(targetprompt&&typeof targetprompt=='string'){
this.prompt(targetprompt);
}
}
}
this.classList.add('selected');
}
if(custom.add.target){
custom.add.target();
}
game.check();
},
control2:function(){
if(this.childNodes.length==1&&!this._doubleclick){
ui.click.control.call(this.firstChild);
}
},
control:function(){
if(_status.dragged) return;
if(ui.control.classList.contains('hidden')) return;
var node=this.parentNode;
if(node){
if(node._doubleclick){
return;
}
else{
node._doubleclick=true;
setTimeout(function(){
node._doubleclick=false;
},500);
}
if(node.classList.contains('hidden')) return;
if(node.classList.contains('removing')) return;
if(node.classList.contains('disabled')) return;
}
if(ui.intro){
ui.intro.close();
delete ui.intro;
}
_status.clicked=true;
if(this.parentNode.custom){
this.parentNode.custom(this.link,this);
return;
}
if(this.link=='ok'){
ui.click.ok(this);
}
else if(this.link=='cancel'){
ui.click.cancel(this);
}
else{
_status.event.result={
buttons:ui.selected.buttons.slice(0),
cards:ui.selected.cards.slice(0),
targets:ui.selected.targets.slice(0),
control:this.link,
links:get.links(ui.selected.buttons)
};
if(this.parentNode.close!=false){
game.uncheck();
this.parentNode.close();
}
game.resume();
}
},
dialogcontrol:function(){
_status.event.result={
buttons:ui.selected.buttons.slice(0),
cards:ui.selected.cards.slice(0),
targets:ui.selected.targets.slice(0),
control:this.link,
links:get.links(ui.selected.buttons)
};
game.resume();
},
skill:function(skill){
var info=get.info(skill);
var event=_status.event;
event.backup(skill);
if(info.filterCard&&info.discard!=false&&info.lose!=false&&!info.viewAs){
var cards=event.player.getCards(event.position);
for(var i=0;i'+str2+'
');
if(info.longprompt){
event.skillDialog.forcebutton=true;
ui.update();
}
}
else if(info.promptfunc){
event.skillDialog=ui.create.dialog(str,''+info.promptfunc(event,event.player)+'
');
}
else if(lib.dynamicTranslate[skill]){
event.skillDialog=ui.create.dialog(str,''+lib.dynamicTranslate[skill](event.player,skill)+'
');
}
else if(lib.translate[skill+'_info']){
event.skillDialog=ui.create.dialog(str,''+lib.translate[skill+'_info']+'
');
}
}
},
ok:function(node){
var event=_status.event;
if(event.custom&&event.custom.replace.confirm){
event.custom.replace.confirm(true);return;
}
event.result={
buttons:ui.selected.buttons.slice(0),
cards:ui.selected.cards.slice(0),
targets:ui.selected.targets.slice(0),
confirm:'ok',
bool:true,
links:get.links(ui.selected.buttons)
};
if(node){
node.parentNode.close();
}
if(event.skill){
event.result.skill=event.skill;
if(typeof get.info(event.skill).viewAs=='function') event.result.card=get.info(event.skill).viewAs(event.result.cards,event.player);
else event.result.card=get.copy(get.info(event.skill).viewAs);
if(event.result.cards.length==1&&event.result.card){
if(!event.result.card.suit) event.result.card.suit=get.suit(event.result.cards[0]);
if(!event.result.card.number) event.result.card.number=get.number(event.result.cards[0]);
}
if(event.skillDialog&&get.objtype(event.skillDialog)=='div'){
event.skillDialog.close();
}
var cards=event.player.getCards('hej');
for(var i=0;i=4){
avatars.classList.add('scroll');
if(lib.config.touchscreen){
lib.setScroll(avatars);
}
}
for(var i=0;i<=num;i++){
var button=ui.create.div(avatars,function(){
playerbg.classList.remove('scroll');
if(this._link){
lib.config.skin[nameskin]=this._link;
bg.style.backgroundImage=this.style.backgroundImage;
if(sourcenode) sourcenode.style.backgroundImage=this.style.backgroundImage;
if(avatar) avatar.style.backgroundImage=this.style.backgroundImage;
game.saveConfig('skin',lib.config.skin);
}
else{
delete lib.config.skin[nameskin];
if(gzbool&&lib.character[nameskin2][4].contains('gzskin')&&lib.config.mode_config.guozhan.guozhanSkin){
bg.setBackground(nameskin2,'character');
if(sourcenode) sourcenode.setBackground(nameskin2,'character');
if(avatar) avatar.setBackground(nameskin2,'character');
}
else{
bg.setBackground(nameskin,'character');
if(sourcenode) sourcenode.setBackground(nameskin,'character');
if(avatar) avatar.setBackground(nameskin,'character');
}
game.saveConfig('skin',lib.config.skin);
}
});
button._link=i;
if(i){
button.setBackgroundImage('image/skin/'+nameskin+'/'+i+'.jpg');
}
else{
if(gzbool&&lib.character[nameskin2][4].contains('gzskin')&&lib.config.mode_config.guozhan.guozhanSkin) button.setBackground(nameskin2,'character','noskin');
else button.setBackground(nameskin,'character','noskin');
}
}
};
var num=1;
var loadImage=function(){
var img=new Image();
img.onload=function(){
num++;
loadImage();
}
img.onerror=function(){
num--;
createButtons(num);
}
img.src=lib.assetURL+'image/skin/'+nameskin+'/'+num+'.jpg';
}
if(lib.config.change_skin){
loadImage();
}
else{
createButtons(lib.skin[nameskin]);
}
};
};
if(lib.config.change_skin){
var img=new Image();
img.onload=changeskin;
img.src=lib.assetURL+'image/skin/'+nameskin+'/1.jpg';
}
else if(lib.config.debug&&lib.skin[nameskin]){
changeskin();
}
var ban=ui.create.div('.menubutton.large.ban.character',uiintro,'禁用',function(e){
if(this.classList.contains('unselectable')) return;
if(typeof noedit=='string'){
this.classList.toggle('active');
var bannedname=noedit+'_banned';
if(!lib.config[bannedname]){
lib.config[bannedname]=[];
}
if(this.classList.contains('active')){
lib.config[bannedname].add(name);
}
else{
lib.config[bannedname].remove(name);
}
game.saveConfig(bannedname,lib.config[bannedname]);
ban.updateBanned();
}
else{
ui.click.touchpop();
ui.click.intro.call(this,e);
_status.clicked=true;
}
});
ban.link=name;
ban._banning='offline';
ban.updateBanned=function(){
if(noedit===true) return;
if(lib.config[get.mode()+'_banned']&&lib.config[get.mode()+'_banned'].contains(name)){
ban.classList.add('active');
}
else{
ban.classList.remove('active');
}
if(sourcenode&&sourcenode.updateBanned){
sourcenode.updateBanned();
}
};
ban.updateBanned();
var fav=ui.create.div('.menubutton.large.fav',uiintro,'收藏',function(){
if(this.classList.contains('unselectable')) return;
this.classList.toggle('active');
if(this.classList.contains('active')){
lib.config.favouriteCharacter.add(name);
}
else{
lib.config.favouriteCharacter.remove(name);
}
game.saveConfig('favouriteCharacter',lib.config.favouriteCharacter);
});
if(noedit===true){
fav.classList.add('unselectable');
ban.classList.add('unselectable');
}
else if(lib.config.favouriteCharacter.contains(name)){
fav.classList.add('active');
}
var intro=ui.create.div('.characterintro',get.characterIntro(name),uiintro);
var intro2=ui.create.div('.characterintro.intro2',uiintro);
var list=get.character(name,3)||[];
var skills=ui.create.div('.characterskill',uiintro);
if(lib.config.touchscreen){
lib.setScroll(intro);
lib.setScroll(intro2);
lib.setScroll(skills);
}
if(lib.config.mousewheel){
skills.onmousewheel=ui.click.mousewheel;
}
var clickSkill=function(e){
var current=this.parentNode.querySelector('.active');
if(current){
current.classList.remove('active');
}
this.classList.add('active');
intro2.innerHTML=''+get.translation(this.link)+''+get.skillInfoTranslation(this.link);
var info=get.info(this.link);
var skill=this.link;
var playername=this.linkname;
var skillnode=this;
if(info.derivation){
var derivation=info.derivation;
if(typeof derivation=='string'){
derivation=[derivation];
}
for(var i=0;i
'+get.translation(derivation[i])+''+get.skillInfoTranslation(derivation[i]);
}
}
if(info.alter){
intro2.innerHTML+='
';
var skillversionnode=intro2.querySelector('.hrefnode.skillversion');
if(lib.config.vintageSkills.contains(skill)){
skillversionnode.innerHTML='切换至新版';
}
else{
skillversionnode.innerHTML='切换至旧版';
}
skillversionnode.listen(function(){
if(lib.config.vintageSkills.contains(skill)){
lib.config.vintageSkills.remove(skill);
lib.translate[skill+'_info']=lib.translate[skill+'_info_alter'];
}
else{
lib.config.vintageSkills.push(skill);
lib.translate[skill+'_info']=lib.translate[skill+'_info_origin'];
}
game.saveConfig('vintageSkills',lib.config.vintageSkills);
clickSkill.call(skillnode,'init');
});
}
if(lib.config.background_speak&&e!=='init'){
var audioname=this.link;
if(info.audioname2&&info.audioname2[playername]){
audioname=info.audioname2[playername];
info=lib.skill[audioname];
}
var audioinfo=info.audio;
var that=this;
var getIndex=function(i){
if(typeof that.audioindex!='number'){
that.audioindex=i;
}
that.audioindex++;
if(that.audioindex>i){
that.audioindex=1;
}
return that.audioindex;
};
if(typeof audioinfo=='string'){
if(audioinfo.indexOf('ext:')==0){
audioinfo=audioinfo.split(':');
if(audioinfo.length==3){
if(audioinfo[2]=='true'){
game.playAudio('..','extension',audioinfo[1],audioname);
}
else{
audioinfo[2]=parseInt(audioinfo[2]);
if(audioinfo[2]){
game.playAudio('..','extension',audioinfo[1],audioname+getIndex(audioinfo[2]));
}
}
}
return;
}
else{
audioname=audioinfo;
if(lib.skill[audioinfo]){
audioinfo=lib.skill[audioinfo].audio;
}
}
}
else if(Array.isArray(audioinfo)){
audioname=audioinfo[0];
audioinfo=audioinfo[1];
}
if(typeof audioinfo=='number'){
if(Array.isArray(info.audioname)&&info.audioname.contains(playername)) audioname=audioname+'_'+playername;
game.playAudio('skill',audioname+getIndex(audioinfo));
}
else if(audioinfo){
if(Array.isArray(info.audioname)&&info.audioname.contains(playername)) audioname=audioname+'_'+playername;
game.playAudio('skill',audioname);
}
else if(true&&info.audio!==false){
if(Array.isArray(info.audioname)&&info.audioname.contains(playername)) audioname=audioname+'_'+playername;
game.playSkillAudio(audioname,getIndex(2));
}
}
}
var initskill=false;
for(var i=0;i 0 || evt.wheelDelta < 0){
node.interval=setInterval(function(){
if(num--&&Math.abs(node.scrollLeft+node.clientWidth-node.scrollWidth)>0){
node.scrollLeft +=speed;
}
else{
clearInterval(node.interval);
}
},16);
}
else{
node.interval=setInterval(function(){
if(num--&&node.scrollLeft>0){
node.scrollLeft -=speed;
}
else{
clearInterval(node.interval);
}
},16);
}
},
touchStart:function(e){
this.startX=e.touches[0].clientX/game.documentZoom;
this.startY=e.touches[0].clientY/game.documentZoom;
_status.dragged=false;
},
dialogtouchStart:function(e){
ui.click.touchStart.call(this,e);
_status.dialogtouched=true;
},
touchScroll:function(e) {
if(_status.mousedragging) return;
if(_status.draggingtouchdialog) return;
if(!_status.dragged){
if (Math.abs(e.touches[0].clientX/game.documentZoom - this.startX) > 10 ||
Math.abs(e.touches[0].clientY/game.documentZoom - this.startY) > 10) {
_status.dragged=true;
}
}
if((this==ui.handcards1Container||this==ui.handcards2Container)&&!this.classList.contains('scrollh')){
e.preventDefault();
}
else if(lib.device=='ios'&&this.scrollHeight<=this.offsetHeight+5&&this.scrollWidth<=this.offsetWidth+5){
e.preventDefault();
}
else{
delete _status._swipeorigin;
e.stopPropagation();
}
},
autoskill:function(bool,node){
var list=lib.config.autoskilllist;
if(bool){
list.remove(node.link);
}
else{
list.add(node.link);
}
game.saveConfig('autoskilllist',list);
},
skillbutton:function(){
this.func(this.link);
},
autoskill2:function(e){
this.classList.toggle('on');
var list=[];
if(lib.skill[this.link].frequent){
list.push(this.link);
}
if(lib.skill[this.link].subfrequent){
for(var i=0;i 0.2){
// _status.force=true;
// var taptic=false;
// if(_status.longpressing){
// delete _status.longpressing._waitingfordrag;
// ui.click.touchpop();
// ui.click.longpresscallback.call(_status.longpressing);
// taptic=true;
// }
// else if(!_status.forceright){
// _status.forceright=true;
// setTimeout(function(){
// _status.forceright=false;
// },600);
// if(_status.mousedragging){
// _status.mousedragging=null;
// _status.mouseleft=false;
// _status.mousedragorigin=null;
// _status.dragstatuschanged=false;
// game.uncheck();
// game.check();
// }
// switch(lib.config.pressure_click){
// case 'pause':ui.click.pause();break;
// case 'auto':ui.click.auto();break;
// case 'config':ui.click.config();break;
// }
// taptic=true;
// }
// if(taptic&&lib.config.pressure_taptic){
// if(window.TapticEngine){
// window.TapticEngine.generateTapticFeedback();
// }
// else{
// game.vibrate(50);
// }
// }
// }
// }
// });
// },
// pressurepause:function(force,event){
// if(!_status.force&&!_status.mousedragging&&force>=0.5&&!_status.forceright){
// _status.force=true;
// _status.forceright=true;
// setTimeout(function(){
// _status.forceright=false;
// },600);
// switch(lib.config.pressure_click){
// case 'pause':ui.click.pause();break;
// case 'auto':ui.click.auto();break;
// case 'config':ui.click.config();break;
// }
// }
// },
// rightpressure:function(force, event){
// if(force>0){
// _status.force=true;
// }
// if(force>=0.5){
// if(_status.mousedragging){
// _status.mousedragging=null;
// _status.mouseleft=false;
// _status.mousedragorigin=null;
// _status.dragstatuschanged=false;
// game.uncheck();
// game.check();
// }
// ui.click.rightplayer.call(this,event);
// _status.clickedplayer=false;
// }
// },
rightplayer:function(e){
if(this._nopup) return false;
if(_status.clickedplayer){
return false;
}
if(this._mouseenterdialog&&this._mouseenterdialog.parentNode){
this._mouseenterdialog.delete();
}
else{
ui.click.intro.call(this,e);
}
_status.clickedplayer=true;
_status.clicked=false;
ui.click.longpresscancel.call(this);
return false;
},
right:function(e){
if(window.inSplash) return false;
if(lib.config.touchscreen) return;
if(_status.noright){
_status.noright=false;
return false;
}
if(_status.clickedplayer){
_status.clickedplayer=false;
return;
}
game.closePopped();
switch(lib.config.right_click){
case 'shortcut':ui.click.shortcut();break;
case 'pause':ui.click.pause();break;
case 'auto':ui.click.auto();break;
case 'config':ui.click.config();break;
}
e.preventDefault();
return false;
}
},
selected:{
buttons:[],cards:[],targets:[]
},
clear:function(){
game.addVideo('uiClear');
var thrown=document.getElementsByClassName('thrown');
var nodes=[];
var i;
for(i=0;ioffset) offset=minoffset;
var control=controls.shift();
if(control._offset!=offset){
control.animate('controlpressdownx',500);
control.style.transform='translateX('+offset+'px)';
control._offset=offset;
}
while(controls.length){
var control=controls.shift();
var width=widths.shift();
offset+=width+6;
if(get.is.phoneLayout()){
offset+=6;
}
if(control._offset!=offset){
control.animate('controlpressdownx',500);
control.style.transform='translateX('+offset+'px)';
control._offset=offset;
}
}
},
updatex:function(){
ui.update.apply(this,arguments);
ui.updatehl();
for(var i=0;i1&&offset1<32){
offset1=32;
ui.handcards1Container.classList.add('scrollh');
}
else{
ui.handcards1Container.classList.remove('scrollh');
}
}
if(offset1<100){
offset12=100-offset1;
}
for(var i=0;i40){
offset12=90-hs1[i].node.info.offsetWidth;
hs1[i].node.info.querySelector('span').style.display='none';
if(hs1[i].node.name.classList.contains('long')){
hs1[i].node.name.style.transform='translateY(16px) scale(0.85)';
hs1[i].node.name.style.transformOrigin='top left';
}
else{
hs1[i].node.name.style.transform='translateY(16px)';
}
hs1[i].node.info.style.transform='translateX(-'+offset12+'px) translateY(-3px)';
}
else{
hs1[i].node.info.querySelector('span').style.display='';
hs1[i].node.name.style.transform='';
hs1[i].node.name.style.transformOrigin='';
hs1[i].node.info.style.transform='translateX(-'+offset12+'px)';
}
}
ui.handcards1Container.firstChild.style.width=(offset1*(hs1.length-1)+118)+'px';
var offset2,offset22=0;
if(!lib.config.fold_card){
offset2=112;
ui.handcards2Container.classList.add('scrollh');
}
else{
offset2=Math.min(112,(ui.handcards2Container.offsetWidth-128)/(hs2.length-1));
if(hs2.length>1&&offset2<32){
offset2=32;
ui.handcards2Container.classList.add('scrollh');
}
else{
ui.handcards2Container.classList.remove('scrollh');
}
}
if(offset2<100){
offset22=100-offset2;
}
for(var i=0;i40){
offset22=90-hs2[i].node.info.offsetWidth;
hs2[i].node.info.querySelector('span').style.display='none';
if(hs2[i].node.name.classList.contains('long')){
hs2[i].node.name.style.transform='translateY(16px) scale(0.85)';
hs2[i].node.name.style.transformOrigin='top left';
}
else{
hs2[i].node.name.style.transform='translateY(16px)';
}
hs2[i].node.info.style.transform='translateX(-'+offset22+'px) translateY(-3px)';
}
else{
hs2[i].node.info.querySelector('span').style.display='';
hs2[i].node.name.style.transform='';
hs2[i].node.name.style.transformOrigin='';
hs2[i].node.info.style.transform='translateX(-'+offset22+'px)';
}
}
ui.handcards2Container.firstChild.style.width=(offset2*(hs2.length-1)+118)+'px';
},
updateh:function(compute){
if(!game.me) return;
if(!ui.handcards1Container) return;
if(lib.config.low_performance){
if(compute){
ui.updatehl();
setTimeout(ui.updatehl,1000);
}
return;
}
if(compute){
ui.handcards1Container._handcardsWidth=ui.handcards1Container.offsetWidth;
ui.handcards2Container._handcardsWidth=ui.handcards2Container.offsetWidth;
}
ui.updatehx(game.me.node.handcards1);
ui.updatehx(game.me.node.handcards2);
},
updatehx:function(node){
var width=node.parentNode._handcardsWidth;
var num=node.childElementCount-node.getElementsByClassName('removing').length;
node.classList.remove('fold0');
node.classList.remove('fold1');
node.classList.remove('fold2');
node.classList.remove('fold3');
if(num*78+40>=width){
// node.dataset.fold=3;
node.classList.add('fold3');
}
else if(num*93+25>=width){
// node.dataset.fold=2;
node.classList.add('fold2');
}
else if(num*112+6>=width){
// node.dataset.fold=1;
node.classList.add('fold1');
}
else{
// node.dataset.fold=0;
node.classList.add('fold0');
}
},
updated:function(){
if (document.documentElement.offsetWidth<900 || document.documentElement.offsetHeight < 500) {
game.deviceZoom=Math.min(
Math.round(document.documentElement.offsetWidth/98)/10,
Math.round(document.documentElement.offsetHeight/50)/10
);
}
else {
game.deviceZoom=1;
}
},
updatez:function(){
var width=document.documentElement.offsetWidth;
var height=document.documentElement.offsetHeight;
var zoom=game.documentZoom;
if(zoom!=1){
document.body.style.width=Math.round(width/zoom)+'px';
document.body.style.height=Math.round(height/zoom)+'px';
document.body.style.transform='scale('+(Math.floor(zoom*100)/100)+')';
}
else{
document.body.style.width=width+'px';
document.body.style.height=height+'px';
document.body.style.transform='';
}
},
update:function(){
for(var i=0;i=height1&&height2>=210))){
ui.dialog.classList.remove('scroll1');
ui.dialog.classList.remove('scroll2');
}
else{
ui.dialog.classList.add('scroll1');
ui.dialog.classList.add('scroll2');
if(game.layout!='default'){
ui.dialog.style.height=Math.min(height1,((game.layout=='long2'||game.layout=='nova')&&ui.arena.classList.contains('choose-character'))?380:350)+'px';
ui.dialog._scrollset=true;
}
}
if(game.layout=='long2'||game.layout=='nova'){
if(height1+240>=ui.arena.offsetHeight){
ui.dialog.classList.add('scroll3');
}
else{
ui.dialog.classList.remove('scroll3');
}
}
}
}
},
recycle:function(node,key){
if(!ui._recycle) ui._recycle={};
if(typeof node=='string'){
return ui._recycle[node]
}
ui._recycle[key]=node;
},
};
var get={
//优先度判断
priority:function(skill){
var info=get.info(skill),priority=0;
if(!info) return 0;
if(info.priority){
priority=info.priority*100;
}
if(info.silent){
priority++;
}
if(info.equipSkill) priority-=25;
if(info.cardSkill) priority-=50;
if(info.ruleSkill) priority-=75;
return priority;
},
//新装备栏相关
//获取一张装备牌实际占用的装备栏(君曹操六龙)
//用法同get.subtype,返回数组
subtypes:function(obj,player){
if(typeof obj=='string') obj={name:obj};
if(typeof obj!='object') return;
var name=get.name(obj,player);
if(!lib.card[name]) return [];
if(lib.card[name].subtypes) return get.copy(lib.card[name].subtypes);
else if(lib.card[name].subtype) return [lib.card[name].subtype];
return [];
},
//装备栏 END
pinyin:function(chinese,withtone){
const util=window.pinyinUtilx;
if(!window.pinyinUtilx) return [];
if(lib.pinyins.metadata&&lib.pinyins.metadata[chinese]){
const str=lib.pinyins.metadata[chinese];
if(withtone===false){
for(let i=0;i0){
for(let i in lib.pinyins.metadata.feijiemu){
if(str[0]==i){
let goon=false;
for(let j of lib.pinyins.metadata.feijiemu[i]){
if(str.indexOf(j)==0) goon=true;
}
if(!goon) str=str.slice(1);
break;
}
}
}
return str;
},
yunjiao:function(str){
const util=window.pinyinUtilx;
if(util) str=util.removeTone(str)
if(lib.pinyins.metadata.zhengtirendu.contains(str)){
str=('-'+str[str.length-1]);
}
else{
for(let i of lib.pinyins.metadata.shengmu){
if(str.indexOf(i)==0){
str=str.slice(i.length);
if(str[0]=='u'&&lib.pinyins.metadata.special_shengmu.contains(i)) str='ü'+str.slice(1);
break;
}
}
}
for(let i in lib.pinyins.metadata.yunjiao){
if(lib.pinyins.metadata.yunjiao[i].contains(str)) return i;
}
return null;
},
skillCategoriesOf:function(skill,player){
var list=[],info=get.info(skill);
if(!info) return list;
if(get.is.locked(skill,player)) list.add('锁定技');
if(info.zhuSkill) list.add('主公技');
if(info.limited) list.add('限定技');
if(info.juexingji||info.limited) list.add('觉醒技');
if(info.limited) list.add('限定技');
if(info.zhuanhuanji) list.add('转换技');
if(info.hiddenSkill) list.add('隐匿技');
if(info.clanSkill) list.add('宗族技');
if(info.groupSkill) list.add('势力技');
if(info.dutySkill) list.add('使命技');
if(info.chargeSkill) list.add('蓄力技');
if(info.zhenfa) list.add('阵法技');
if(info.mainSkill) list.add('主将技');
if(info.viceSkill) list.add('副将技');
if(info.lordSkill) list.add('君主技');
if(info.chargingSkill) list.add('蓄能技');
if(info.charlotte) list.add('Charlotte');
if(info.categories) list.addArray(info.categories(skill,player));
return list;
},
numOf:function(obj,item){
var num=0;
for(var i=0;i2) return parseInt(splited[2]);
}
return 0;
},
is:{
yayun:function(str1,str2){
if(str1==str2) return true;
var pinyin1=get.pinyin(str1,false),pinyin2=get.pinyin(str2,false);
if(!pinyin1.length||!pinyin2.length) return false;
var pron1=pinyin1[pinyin1.length-1],pron2=pinyin2[pinyin2.length-1];
if(pron1==pron2) return true;
return get.yunjiao(pron1)==get.yunjiao(pron2);
},
blocked:function(skill,player){
if(!player.storage.skill_blocker||!player.storage.skill_blocker.length) return false;
for(var i of player.storage.skill_blocker){
if(lib.skill[i]&&lib.skill[i].skillBlocker&&lib.skill[i].skillBlocker(skill,player)) return true;
}
return false;
},
double:function(name,array){
if(!lib.character[name]||!lib.character[name][4]) return false;
for(var i of lib.character[name][4]){
if(i.indexOf('doublegroup:')==0){
if(!array) return true;
return i.split(':').slice(1);
}
}
return false;
},
yingbian:function(node){
return get.cardtag(node,'yingbian_zhuzhan')||get.cardtag(node,'yingbian_fujia')||get.cardtag(node,'yingbian_canqu')||get.cardtag(node,'yingbian_kongchao');
},
emoji:function(substring){
if(substring){
var reg=new RegExp("[~#^$@%&!?%*]",'g');
if(substring.match(reg)){
return true;
}
for(var i=0;i1){
var ls=substring.charCodeAt(i+1);
var uc=((hs-0xd800)*0x400)+(ls-0xdc00)+0x10000;
if(0x1d000<=uc&&uc<=0x1f77f){
return true;
}
}
}
else if(substring.length>1){
var ls=substring.charCodeAt(i+1);
if(ls==0x20e3){
return true;
}
}
else{
if(0x2100<=hs&&hs<=0x27ff){
return true;
}
else if(0x2B05<=hs&&hs<=0x2b07){
return true;
}
else if(0x2934<=hs&&hs<=0x2935){
return true;
}
else if(0x3297<=hs&&hs<=0x3299){
return true;
}
else if(hs==0xa9||hs==0xae||hs==0x303d||hs==0x3030
||hs==0x2b55||hs==0x2b1c||hs==0x2b1b
||hs==0x2b50){
return true;
}
}
}
}
return false;
},
banWords:function(str){
if(get.is.emoji(str)) return true;
for(var i of window.bannedKeyWords){
if(str.indexOf(i)!=-1) return true;
}
return false;
},
converted:function(event){
return !(event.card&&event.card.isCard);
},
safari:function(){
var ua=navigator.userAgent.toLowerCase();
return ua.indexOf('safari'!=-1)&&ua.indexOf('chrome')==-1;
},
freePosition:function(cards){
for(var i=0;i'+str.slice(2)+'';
}
return str;
},
evtprompt:function(next,str){
if(next.prompt){
next.set('prompt2',str);
}
else{
if(str.indexOf('###')==0){
var prompts=str.slice(3).split('###');
if(prompts[0]) next.set('prompt',prompts[0]);
if(prompts[1]) next.set('prompt2',prompts[1]);
}
else{
next.set('prompt',str);
}
}
},
autoViewAs:function(card,cards){
var info=get.info(card);
if(info.autoViewAs){
if(cards===false){
return {
name:info.autoViewAs,
};
}
else if(Array.isArray(cards)){
return {
name:info.autoViewAs,
cards:cards.slice(0),
};
}
else if(get.itemtype(card)=='card'){
return {
name:info.autoViewAs,
cards:[card],
};
}
else{
return {
name:info.autoViewAs,
suit:card.suit,
number:card.number,
nature:card.nature,
};
}
}
else{
if(card.isCard||get.itemtype(card)=='card'){
var next={
name:get.name(card),
suit:get.suit(card),
number:get.number(card),
nature:get.nature(card),
isCard:true,
cardid:card.cardid,
wunature:card.wunature,
storage:get.copy(card.storage),
cards:get.copy(card.cards),
};
if(get.itemtype(cards)=='cards'&&!card.cards) next.cards=cards.slice(0);
else if(get.itemtype(card)=='card') next.cards=[card];
return next;
}
else if(get.is.object(card)&&get.itemtype(cards)=='cards'&&!card.cards){
card=get.copy(card);
card.cards=cards.slice(0);
}
return card;
}
},
max:function(list,func,type){
list=list.slice(0);
if(typeof func=='string'){
var key=func;
func=function(item){
return item[key];
}
}
list.sort(function(a,b){
return func(b)-func(a);
});
if(type=='list'){
var list2=[];
for(var i=0;i0) return 1;
if(num<0) return -1;
return 0;
},
rand:function(num,num2){
if(typeof num2=='number'){
return num+Math.floor(Math.random()*(num2-num+1));
}
else{
return Math.floor(Math.random()*num);
}
},
sort:function(arr,method){
switch(method){
case 'seat':{
lib.tempSortSeat=arguments[2];
arr.sort(lib.sort.seat);
delete lib.tempSortSeat;
return arr;
}
}
},
sortSeat:function(arr,target){
lib.tempSortSeat=target;
arr.sort(lib.sort.seat);
delete lib.tempSortSeat;
return arr;
},
zip:function(callback){
if(!window.JSZip){
lib.init.js(lib.assetURL+'game','jszip',function(){
callback(new JSZip());
});
}
else{
callback(new JSZip());
}
},
delayx:function(num,max){
if(typeof num!='number') num=1;
if(typeof max!='number') max=Infinity;
switch(lib.config.game_speed){
case 'vslow':return Math.min(max,2.5*num);
case 'slow':return Math.min(max,1.5*num);
case 'fast':return Math.min(max,0.7*num);
case 'vfast':return Math.min(max,0.4*num);
case 'vvfast':return Math.min(max,0.2*num);
default:return Math.min(max,num);
}
},
prompt:function(skill,target,player){
player=player||_status.event.player;
if(target){
var str=get.translation(target);
if(target==player){
str+='(你)'
}
return '是否对'+str+'发动【'+get.skillTranslation(skill,player)+'】?';
}
else{
return '是否发动【'+get.skillTranslation(skill,player)+'】?';
}
},
prompt2:function(skill,target,player){
var str=get.prompt.apply(this,arguments);
if(!lib.translate[skill+'_info']) return str;
return '###'+str+'###'+lib.translate[skill+'_info'];
},
url:function(master){
var url=lib.config.updateURL||lib.updateURL;
if(url[url.length-1]!='/'){
url+='/';
}
if(master!='nodev'){
return url+'master/';
}
else{
return url+'v'+lib.version+'/';
}
},
round:function(num,f){
var round=1;
for(var i=0;i1&&threaten>1){
num+=Math.sqrt(threaten)-1;
}
}
if(type.indexOf('out')!=-1){
if(threaten<1){
num*=1/Math.sqrt(threaten);
}
if(info.trigger){
if(info.trigger.global){
var list=Array.isArray(info.trigger.global)?info.trigger.global:[info.trigger.global];
num+=Math.min(3,list.length)/10;
for(var i of list){
if(i.indexOf('lose')==0||i.indexOf('use')==0) num+=0.3;
if(i.indexOf('cardsDiscard')==0) num+=0.4;
}
}
if(info.trigger.target||(typeof info.trigger.player=='string'&&
(info.trigger.player.indexOf('damage')==0||info.trigger.player.indexOf('lose')==0))) num+=0.1;
}
if(info.ai){
if(info.ai.maixie||info.ai.maixie_hp||info.ai.maixie_defend){
num+=0.5;
}
if(info.ai.nolose||info.ai.noh||info.ai.noe||info.ai.nodiscard){
num+=0.3;
}
}
}
if(!grouped){
var groups=game.expandSkills([skill]);
groups.remove(skill);
var ggt=[];
for(var i=0;i1){
ggt.push(gi);
}
}
if(ggt.length){
num+=Math.max.apply(this,ggt)-1+ggt.length/20;
}
}
return num;
},
targetsInfo:function(targets){
var info=[];
for(var i=0;ivalue!='`').join('');
},
numStr:function(num,method){
if(num==Infinity){
if(method=='card') return get.selectableCards().length+ui.selected.cards.length;
if(method=='target') return get.selectableTargets().length+ui.selected.targets.length;
return '∞';
}
return num.toString();
},
rawName:function(str){
if(lib.translate[str+'_ab']) return lib.translate[str+'_ab'];
var str2=lib.translate[str];
if(!str2) return '';
if(str2.indexOf('SP')==0){
str2=str2.slice(2);
}
else if(str2.indexOf('TW')==0){
str2=str2.slice(2);
}
else if(str2.indexOf('OL')==0){
str2=str2.slice(2);
}
else if(str2.indexOf('JSP')==0){
str2=str2.slice(3);
}
else if(str2.indexOf('☆SP')==0){
str2=str2.slice(3);
}
else if(str2.indexOf('手杀')==0){
str2=str2.slice(2);
}
else if(str2.indexOf('新杀')==0){
str2=str2.slice(2);
}
else if(str2.indexOf('界')==0&&lib.characterPack.refresh&&lib.characterPack.refresh[str]){
str2=str2.slice(1);
}
else if(str2.indexOf('旧')==0&&(lib.characterPack.old||lib.characterPack.mobile)&&(lib.characterPack.old[str]||lib.characterPack.mobile[str])){
str2=str2.slice(1);
}
else if(str2.indexOf('新')==0&&(str.indexOf('re_')==0||str.indexOf('new_')==0)){
str2=str2.slice(1);
}
return str2;
},
rawName2:function(str){
if(lib.translate[str+'_ab']) return lib.translate[str+'_ab'];
var str2=lib.translate[str];
if(!str2) return '';
if(str2.indexOf('SP')==0){
str2=str2.slice(2);
}
else if(str2.indexOf('TW')==0){
str2=str2.slice(2);
}
else if(str2.indexOf('OL')==0){
str2=str2.slice(2);
}
else if(str2.indexOf('JSP')==0){
str2=str2.slice(3);
}
else if(str2.indexOf('☆SP')==0){
str2=str2.slice(3);
}
else if(str2.indexOf('手杀')==0){
str2=str2.slice(2);
}
else if(str2.indexOf('新杀')==0){
str2=str2.slice(2);
}
return str2;
},
slimName:function(str){
var str2=lib.translate[str];
if(lib.translate[str+'_ab']) str2=lib.translate[str+'_ab'];
if(!str2) return '';
if(str2.indexOf('SP')==0){
str2=str2.slice(2);
}
else if(str2.indexOf('TW')==0){
str2=str2.slice(2);
}
else if(str2.indexOf('OL')==0){
str2=str2.slice(2);
}
else if(str2.indexOf('JSP')==0){
str2=str2.slice(3);
}
else if(str2.indexOf('☆SP')==0){
str2=str2.slice(3);
}
else if(str2.indexOf('手杀')==0){
str2=str2.slice(2);
}
else if(str2.indexOf('新杀')==0){
str2=str2.slice(2);
}
return get.verticalStr(str2,true);
},
time:function(){
if(lib.status.dateDelaying){
return lib.getUTC(lib.status.dateDelaying)-lib.getUTC(lib.status.date)-lib.status.dateDelayed;
}
else{
return lib.getUTC(new Date())-lib.getUTC(lib.status.date)-lib.status.dateDelayed;
}
},
utc:function(){
return (new Date()).getTime();
},
evtDistance:function(e1,e2){
var dx=(e1.clientX-e2.clientX)/game.documentZoom;
var dy=(e1.clientY-e2.clientY)/game.documentZoom;
return Math.sqrt(dx*dx+dy*dy);
},
xyDistance:function(from,to){
return Math.sqrt((from[0]-to[0])*(from[0]-to[0])+(from[1]-to[1])*(from[1]-to[1]));
},
itemtype:function(obj){
var i,j;
if(typeof obj=='string'){
if(obj.length<=5){
var bool=true;
for(i=0;i锁定技').
// replace(/限定技/g,'限定技').
// replace(/觉醒技/g,'觉醒技').
// replace(/主将技/g,'主将技').
// replace(/副将技/g,'副将技').
// replace(/阵法技/g,'阵法技').
// replace(/主公技/g,'主公技');
},
translation:function(str,arg){
if(str&&typeof str=='object'&&(str.name||str._tempTranslate)){
if(str._tempTranslate) return str._tempTranslate;
var str2;
if(arg=='viewAs'&&str.viewAs){
str2=get.translation(str.viewAs);
}
else{
str2=get.translation(str.name);
}
if(str2=='杀'){
if(str.nature=='fire'){
str2='火'+str2;
}
else if(str.nature=='thunder'){
str2='雷'+str2;
}
else if(str.nature=='kami'){
str2='神'+str2;
}
else if(str.nature=='ice'){
str2='冰'+str2;
}
else if(str.nature=='stab'){
str2='刺'+str2;
}
}
if(get.itemtype(str)=='card'||str.isCard){
if(_status.cardtag&&str.cardid){
var tagstr='';
for(var i in _status.cardtag){
if(_status.cardtag[i].contains(str.cardid)){
tagstr+=lib.translate[i+'_tag'];
}
}
if(tagstr){
str2+='·'+tagstr;
}
}
if(str.suit&&str.number){
var cardnum=str.number||'';
if([1,11,12,13].contains(cardnum)){
cardnum={'1':'A','11':'J','12':'Q','13':'K'}[cardnum]
}
if(arg=='viewAs'&&str.viewAs!=str.name&&str.viewAs){
str2+='('+get.translation(str)+')';
}
else{
str2+='【'+get.translation(str.suit)+cardnum+'】';
// var len=str2.length-1;
// str2=str2.slice(0,len)+''+str2[len]+'·'+get.translation(str.suit)+str.number;
}
}
}
return str2;
}
if(Array.isArray(str)){
var str2=get.translation(str[0],arg);
for(var i=1;i0){
str2=str.slice(0,str.lastIndexOf('_'));
if(lib.translate[str2+'_info']) return lib.translate[str2+'_info'];
}
str2=str.slice(0,str.length-2);
if(lib.translate[str2+'_info']) return lib.translate[str2+'_info'];
if(lib.skill[str]&&lib.skill[str].prompt) return lib.skill[str].prompt;
}
if(lib.translate[str]){
return lib.translate[str];
}
if(typeof str=='string'){
return str;
}
if(typeof str=='number'||typeof str=='boolean'){
return str.toString();
}
if(str&&str.toString){
return str.toString();
}
return '';
},
strNumber:function(num){
switch(num){
case 1:return 'A';
case 11:return 'J';
case 12:return 'Q';
case 13:return 'K';
default:return num.toString();
}
},
cnNumber:function(num,two){
if(num==Infinity) return '∞';
if(isNaN(num)) return '';
if(typeof num!='number') return num;
if(num<0||num>99) return num;
if(num<=10){
switch(num){
case 0:return '〇';
case 1:return '一';
case 2:return two?'二':'两';
case 3:return '三';
case 4:return '四';
case 5:return '五';
case 6:return '六';
case 7:return '七';
case 8:return '八';
case 9:return '九';
case 10:return '十';
}
}
if(num<20){
return '十'+get.cnNumber(num-10,true);
}
var x=Math.floor(num/10);
return get.cnNumber(x,true)+'十'+(num>10*x?get.cnNumber(num-10*x,true):'');
},
selectableButtons:function(sort){
if(!_status.event.player) return[];
var buttons=_status.event.dialog.buttons;
var selectable=[];
for(var i=0;i=ui.cardPile.childNodes.length) j-=ui.cardPile.childNodes.length;
if(filter(ui.cardPile.childNodes[j])){
return ui.cardPile.childNodes[j];
}
}
}
if(create!='cardPile'){
for(var i=0;i=ui.discardPile.childNodes.length) j-=ui.discardPile.childNodes.length;
if(filter(ui.discardPile.childNodes[j])){
return ui.discardPile.childNodes[j];
}
}
}
if(create=='field'){
var found=null;
game.findPlayer(function(current){
var ej=current.getCards('ej');
for(var i=0;i【'+skilltrans+'】'+
get.skillInfoTranslation(skills[i])+'
';
}
}
return str;
},
intro:function(name){
var info=lib.character[name];
var str='性别:'+get.translation(info[0])+'
';
str+='势力:'+get.translation(info[1])+'
';
str+='体力:'+get.translation(info[2])+'
';
str+='技能:';
if(info[3].length){
str+=get.translation(info[3][0]);
for(var i=1;i0){
return '共有'+content+'个标记';
}
return false;
}
case 'turn':{
if(content>0){
return '剩余'+content+'个回合';
}
return false;
}
case 'time':{
if(content>0){
return '剩余'+content+'次';
}
return false;
}
case 'limited':{
if(content){
return '已发动';
}
return '未发动';
}
case 'info':{
return lib.translate[skill+'_info'];
}
case 'cardCount':{
if(Array.isArray(content)){
return '共有'+get.cnNumber(content.length)+'张牌';
}
return false;
}
case 'expansion':{
content=player.getCards('x',function(card){
return card.hasGaintag(skill);
});
if(dialog&&content.length){
dialog.addAuto(content);
}
else{
return '没有卡牌';
}
return false;
}
case 'card':case 'cards':{
if(get.itemtype(content)=='card'){
content=[content];
}
if(dialog&&get.itemtype(content)=='cards'){
dialog.addAuto(content);
}
else{
if(content&&content.length){
return get.translation(content);
}
}
if(Array.isArray(content)&&!content.length){
return '没有卡牌';
}
return false;
}
case 'player':case 'players':{
if(get.itemtype(content)=='player'){
content=[content];
}
if(dialog&&get.itemtype(content)=='players'){
dialog.addAuto(content);
return false;
}
else{
if(content&&content.length){
return get.translation(content);
}
return false;
}
}
case 'character':case 'characters':{
if(typeof content=='string'){
content=[content];
}
if(dialog&&Array.isArray(content)){
dialog.addAuto([content,'character']);
return false;
}
else{
if(content&&content.length){
return get.translation(content);
}
return false;
}
}
default:{
if(typeof type=='string'){
type=type.replace(/#/g,content);
type=type.replace(/&/g,get.cnNumber(content));
type=type.replace(/\$/g,get.translation(content));
return type;
}
else if(typeof type=='function'){
return type(content,player,skill);
}
return false;
}
}
},
nodeintro:function(node,simple,evt){
var uiintro=ui.create.dialog('hidden','notouchscroll');
if(node.classList.contains('player')&&!node.name){
return uiintro;
}
var i,translation,intro,str;
if(node._nointro) return;
if(typeof node._customintro=='function'){
if(node._customintro(uiintro,evt)===false) return;
}
else if(Array.isArray(node._customintro)){
var caption=node._customintro[0];
var content=node._customintro[1];
if(typeof caption=='function'){
caption=caption(node);
}
if(typeof content=='function'){
content=content(node);
}
uiintro.add(caption);
uiintro.add(''+content+'
');
}
else if(node.classList.contains('player')||node.linkplayer){
if(node.linkplayer){
node=node.link;
}
var capt=get.translation(node.name);
if((lib.character[node.name]&&lib.character[node.name][1])||lib.group.contains(node.group)){
capt+=' '+(lib.group.contains(node.group)?get.translation(node.group):lib.translate[lib.character[node.name][1]]);
}
uiintro.add(capt);
if(lib.characterTitle[node.name]){
uiintro.addText(get.colorspan(lib.characterTitle[node.name]));
}
if(!node.noclick&&(node.isUnderControl()||(!game.observe&&game.me&&game.me.hasSkillTag('viewHandcard',null,node,true)))){
var hs=node.getCards('h');
if(hs.length){
uiintro.add('手牌
');
uiintro.addSmall(node.getCards('h'));
}
}
var skills=node.getSkills(null,false,false).slice(0);
var skills2=game.filterSkills(skills,node);
if(node==game.me&&node.hiddenSkills.length){
skills.addArray(node.hiddenSkills);
}
for(var i in node.disabledSkills){
if(node.disabledSkills[i].length==1&&
node.disabledSkills[i][0]==i+'_awake'&&
!node.hiddenSkills.contains(i)){
skills.add(i);
}
}
for(i=0;i';
if(node.forbiddenSkills[skills[i]].length){
forbidstr+='(与'+get.translation(node.forbiddenSkills[skills[i]])+'冲突)
';
}
else{
forbidstr+='(双将禁用)
';
}
forbidstr+=get.skillInfoTranslation(skills[i],node)+'
'
uiintro.add(forbidstr);
}
else if(!skills2.contains(skills[i])){
if(lib.skill[skills[i]].preHidden&&get.mode()=='guozhan'){
uiintro.add('【'+translation+'】
'+get.skillInfoTranslation(skills[i],node)+'预亮技能
');
var underlinenode=uiintro.content.lastChild.querySelector('.underlinenode');
if(_status.prehidden_skills.contains(skills[i])){
underlinenode.classList.remove('on');
}
underlinenode.link=skills[i];
underlinenode.listen(ui.click.hiddenskill);
}
else uiintro.add('【'+translation+'】
'+get.skillInfoTranslation(skills[i],node)+'
');
}
else if(lib.skill[skills[i]].temp||!node.skills.contains(skills[i])||lib.skill[skills[i]].thundertext){
if(lib.skill[skills[i]].frequent||lib.skill[skills[i]].subfrequent){
uiintro.add('【'+translation+'】
'+get.skillInfoTranslation(skills[i],node)+'
自动发动
');
var underlinenode=uiintro.content.lastChild.querySelector('.underlinenode');
if(lib.skill[skills[i]].frequent){
if(lib.config.autoskilllist.contains(skills[i])){
underlinenode.classList.remove('on');
}
}
if(lib.skill[skills[i]].subfrequent){
for(var j=0;j【'+translation+'】
'+get.skillInfoTranslation(skills[i],node)+'
');
}
}
else if(lib.skill[skills[i]].frequent||lib.skill[skills[i]].subfrequent){
uiintro.add('【'+translation+'】
'+get.skillInfoTranslation(skills[i],node)+'
自动发动
');
var underlinenode=uiintro.content.lastChild.querySelector('.underlinenode');
if(lib.skill[skills[i]].frequent){
if(lib.config.autoskilllist.contains(skills[i])){
underlinenode.classList.remove('on');
}
}
if(lib.skill[skills[i]].subfrequent){
for(var j=0;j【'+translation+'】
'+get.skillInfoTranslation(skills[i],node)+'
').querySelector('.skillbutton');
if(!_status.gameStarted||(lib.skill[skills[i]].clickableFilter&&!lib.skill[skills[i]].clickableFilter(node))){
intronode.classList.add('disabled');
intronode.style.opacity=0.5;
}
else{
intronode.link=node;
intronode.func=lib.skill[skills[i]].clickable;
intronode.classList.add('pointerdiv');
intronode.listen(ui.click.skillbutton);
}
}
else if(lib.skill[skills[i]].nobracket){
uiintro.add(''+get.translation(skills[i])+'
'+get.skillInfoTranslation(skills[i],node)+'
');
}
else{
uiintro.add('【'+translation+'】
'+get.skillInfoTranslation(skills[i],node)+'
');
}
if(lib.translate[skills[i]+'_append']){
uiintro._place_text=uiintro.add(''+lib.translate[skills[i]+'_append']+'
')
}
}
}
// if(get.is.phoneLayout()){
// var storage=node.storage;
// for(i in storage){
// if(get.info(i)&&get.info(i).intro){
// intro=get.info(i).intro;
// if(node.getSkills().concat(lib.skill.global).contains(i)==false&&!intro.show) continue;
// var name=intro.name?intro.name:get.translation(i);
// if(typeof name=='function'){
// name=name(storage[i],node);
// }
// translation='『'+name.slice(0,2)+'』
';
// var stint=get.storageintro(intro.content,storage[i],node,null,i);
// if(stint){
// translation+=stint+'
';
// uiintro.add(translation);
// }
// }
// }
// }
if(lib.config.right_range&&_status.gameStarted){
uiintro.add(ui.create.div('.placeholder'));
var table,tr,td;
table=document.createElement('table');
tr=document.createElement('tr');
table.appendChild(tr);
td=document.createElement('td');
td.innerHTML='距离';
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML='手牌';
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML='行动';
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML='伤害';
tr.appendChild(td);
tr=document.createElement('tr');
table.appendChild(tr);
td=document.createElement('td');
if(node==game.me||!game.me||!game.me.isIn()){
td.innerHTML='-';
}
else{
var dist1=get.numStr(Math.max(1,game.me.distanceTo(node)));
var dist2=get.numStr(Math.max(1,node.distanceTo(game.me)));
if(dist1==dist2){
td.innerHTML=dist1;
}
else{
td.innerHTML=dist1+'/'+dist2;
}
}
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML=node.countCards('h');
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML=node.phaseNumber;
tr.appendChild(td);
td=document.createElement('td');
(function(){
num=0;
for(var j=0;j'+es[i].outerHTML+'
'+cardinfo.cardPrompt(es[i])+'
');
else uiintro.add(''+es[i].outerHTML+'
'+lib.translate[es[i].name+'_info']+'
');
uiintro.content.lastChild.querySelector('.skill>.card').style.transform='';
}
var js=node.getCards('j');
for(var i=0;i'+js[i].outerHTML+'
'+lib.translate[js[i].viewAs]+':'+lib.translate[js[i].viewAs+'_info']+'
');
}
else{
uiintro.add(''+js[i].outerHTML+'
'+lib.translate[js[i].name+'_info']+'
');
}
uiintro.content.lastChild.querySelector('.skill>.card').style.transform='';
}
if(get.is.phoneLayout()){
var markCoutainer=ui.create.div('.mark-container.marks');
for(var i in node.marks){
var nodemark=node.marks[i].cloneNode(true);
nodemark.classList.add('pointerdiv');
nodemark.link=node.marks[i];
nodemark.style.transform='';
markCoutainer.appendChild(nodemark);
nodemark.listen(function(){
uiintro.noresume=true;
var rect=this.link.getBoundingClientRect();
ui.click.intro.call(this.link,{
clientX:rect.left+rect.width,
clientY:rect.top+rect.height/2,
});
if(lib.config.touchscreen){
uiintro._close();
}
});
}
if(markCoutainer.childElementCount){
uiintro.addText('标记');
uiintro.add(markCoutainer);
}
}
}
if(!game.observe&&_status.gameStarted&&game.me&&node!=game.me){
ui.throwEmotion=[];
uiintro.addText('发送交互表情');
var click=function(){
if(_status.dragged) return;
if(_status.justdragged) return;
if(_status.throwEmotionWait) return;
var emotion=this.link;
if(game.online){
game.send('throwEmotion',node,emotion);
}
else game.me.throwEmotion(node,emotion);
uiintro._close();
_status.throwEmotionWait=true;
setTimeout(function(){
_status.throwEmotionWait=false;
if(ui.throwEmotion){
for(var i of ui.throwEmotion) i.classList.remove('exclude');
}
},(emotion=='flower'||emotion=='egg')?500:5000)
};
var td;
var table=document.createElement('div');
table.classList.add('add-setting');
table.style.margin='0';
table.style.width='100%';
table.style.position='relative';
var listi=['flower','egg'];
for(var i=0;i';
td.addEventListener(lib.config.touchscreen?'touchend':'click',click);
}
uiintro.content.appendChild(table);
table=document.createElement('div');
table.classList.add('add-setting');
table.style.margin='0';
table.style.width='100%';
table.style.position='relative';
var listi=['wine','shoe'];
if(game.me.storage.zhuSkill_shanli) listi=['yuxisx','jiasuo'];
for(var i=0;i';
td.addEventListener(lib.config.touchscreen?'touchend':'click',click);
}
uiintro.content.appendChild(table);
}
var modepack=lib.characterPack['mode_'+get.mode()];
if(lib.config.show_favourite&&lib.character[node.name]&&game.players.contains(node)&&
(!modepack||!modepack[node.name])&&(!simple||get.is.phoneLayout())){
var addFavourite=ui.create.div('.text.center.pointerdiv');
addFavourite.link=node.name;
if(lib.config.favouriteCharacter.contains(node.name)){
addFavourite.innerHTML='移除收藏';
}
else{
addFavourite.innerHTML='添加收藏';
}
addFavourite.listen(ui.click.favouriteCharacter)
uiintro.add(addFavourite);
}
if(!simple||get.is.phoneLayout()){
if((lib.config.change_skin||lib.skin)&&!node.isUnseen()){
var num=1;
var introadded=false;
var createButtons=function(num,avatar2){
if(!introadded){
introadded=true;
uiintro.add('更改皮肤
');
}
var buttons=ui.create.div('.buttons.smallzoom.scrollbuttons');
lib.setMousewheel(buttons);
var nameskin=(avatar2?node.name2:node.name1);
var nameskin2=nameskin;
var gzbool=false;
if(nameskin.indexOf('gz_shibing')==0){
nameskin=nameskin.slice(3,11);
}
else if(nameskin.indexOf('gz_')==0){
nameskin=nameskin.slice(3);
gzbool=true;
}
for(var i=0;i<=num;i++){
var button=ui.create.div('.button.character.pointerdiv',buttons,function(){
if(this._link){
if(avatar2){
lib.config.skin[nameskin]=this._link;
node.node.avatar2.style.backgroundImage=this.style.backgroundImage;
}
else{
lib.config.skin[nameskin]=this._link;
node.node.avatar.style.backgroundImage=this.style.backgroundImage;
}
}
else{
delete lib.config.skin[nameskin];
if(avatar2){
if(gzbool&&lib.character[nameskin2][4].contains('gzskin')&&lib.config.mode_config.guozhan.guozhanSkin) node.node.avatar2.setBackground(nameskin2,'character');
else node.node.avatar2.setBackground(nameskin,'character');
}
else{
if(gzbool&&lib.character[nameskin2][4].contains('gzskin')&&lib.config.mode_config.guozhan.guozhanSkin) node.node.avatar.setBackground(nameskin2,'character');
else node.node.avatar.setBackground(nameskin,'character');
}
}
game.saveConfig('skin',lib.config.skin);
});
button._link=i;
if(i){
button.setBackgroundImage('image/skin/'+nameskin+'/'+i+'.jpg');
}
else{
if(gzbool&&lib.character[nameskin2][4].contains('gzskin')&&lib.config.mode_config.guozhan.guozhanSkin) button.setBackground(nameskin2,'character','noskin');
else button.setBackground(nameskin,'character','noskin');
}
}
uiintro.add(buttons);
};
var loadImage=function(avatar2){
var img=new Image();
img.onload=function(){
num++;
loadImage(avatar2);
}
img.onerror=function(){
num--;
if(num){
createButtons(num,avatar2);
}
if(!avatar2){
if(!node.classList.contains('unseen2')&&node.name2){
num=1;
loadImage(true);
}
}
}
var nameskin=(avatar2?node.name2:node.name1);
var nameskin2=nameskin;
var gzbool=false;
if(nameskin.indexOf('gz_shibing')==0){
nameskin=nameskin.slice(3,11);
}
else if(nameskin.indexOf('gz_')==0){
nameskin=nameskin.slice(3);
gzbool=true;
}
img.src=lib.assetURL+'image/skin/'+nameskin+'/'+num+'.jpg';
}
if(lib.config.change_skin){
if(!node.isUnseen(0)){
loadImage();
}
else if(node.name2){
loadImage(true);
}
}
else{
setTimeout(function(){
var nameskin1=node.name1;
var nameskin2=node.name2;
if(nameskin1&&nameskin1.indexOf('gz_')==0){
nameskin1=nameskin1.slice(3);
}
if(nameskin2&&nameskin2.indexOf('gz_')==0){
nameskin2=nameskin2.slice(3);
}
if(!node.isUnseen(0)&&lib.skin[nameskin1]){
createButtons(lib.skin[nameskin1]);
}
if(!node.isUnseen(1)&&lib.skin[nameskin2]){
createButtons(lib.skin[nameskin2],true);
}
});
}
}
}
uiintro.add(ui.create.div('.placeholder.slim'));
}
else if(node.classList.contains('mark')&&node.info&&
node.parentNode&&node.parentNode.parentNode&&node.parentNode.parentNode.classList.contains('player')){
var info=node.info;
var player=node.parentNode.parentNode;
if(info.name){
if(typeof info.name=='function'){
var named=info.name(player.storage[node.skill],player);
if(named){
uiintro.add(named);
}
}
else{
uiintro.add(info.name);
}
}
else if(info.name!==false){
uiintro.add(get.translation(node.skill));
}
if(typeof info.id=='string'&&info.id.indexOf('subplayer')==0&&
player.isUnderControl(true)&&player.storage[info.id]&&!_status.video){
var storage=player.storage[info.id];
uiintro.addText('当前体力:'+storage.hp+'/'+storage.maxHp);
if(storage.hs.length){
uiintro.addText('手牌区');
uiintro.addSmall(storage.hs);
}
if(storage.es.length){
uiintro.addText('装备区');
uiintro.addSmall(storage.es);
}
}
if(typeof info.mark=='function'){
var stint=info.mark(uiintro,player.storage[node.skill],player);
if(stint){
var placetext=uiintro.add(''+stint+'
');
if(stint.indexOf(''+stint+'
');
// }
// else{
// uiintro.add(''+stint+'
');
// }
}
}
else{
var stint=get.storageintro(info.content,player.storage[node.skill],player,uiintro,node.skill);
if(stint){
if(stint[0]=='@'){
uiintro.add(''+stint.slice(1)+'
');
}
else{
var placetext=uiintro.add(''+stint+'
');
if(stint.indexOf(''+stint+'
');
// }
// else{
// uiintro.add(''+stint+'
');
// }
}
}
uiintro.add(ui.create.div('.placeholder.slim'));
}
else if(node.classList.contains('card')){
//卡牌长按介绍
if(ui.arena.classList.contains('observe')&&node.parentNode.classList.contains('handcards')){
return;
}
var name=node.name;
if(node.parentNode.cardMod){
var moded=false;
for(var i in node.parentNode.cardMod){
var item=node.parentNode.cardMod[i](node);
if(Array.isArray(item)){
moded=true;
uiintro.add(item[0]);
uiintro._place_text=uiintro.add(''+item[1]+'
');
}
}
if(moded) return uiintro;
}
if(node.link&&node.link.name&&lib.card[node.link.name]){
name=node.link.name;
}
if(get.position(node)=='j'&&node.viewAs&&node.viewAs!=name){
uiintro.add(get.translation(node.viewAs));
uiintro.add('('+get.translation(get.translation(node))+')
');
// uiintro.add(get.translation(node.viewAs)+'
('+get.translation(node)+')
');
uiintro.nosub=true;
name=node.viewAs;
}
else{
uiintro.add(get.translation(node));
}
if(node._banning){
var clickBanned=function(){
var banned=lib.config[this.bannedname]||[];
if(banned.contains(name)){
banned.remove(name);
}
else{
banned.push(name);
}
game.saveConfig(this.bannedname,banned);
this.classList.toggle('on');
if(node.updateBanned){
node.updateBanned();
}
};
var modeorder=lib.config.modeorder||[];
for(var i in lib.mode){
modeorder.add(i);
}
var list=[];
uiintro.contentContainer.listen(function(e){
ui.click.touchpop();
e.stopPropagation();
});
for(var i=0;i攻击范围:'+(-dist.attackFrom+1)+'');
}
}
if(!added){
uiintro.add('攻击范围:1
');
}
}
else if(get.subtype(name)){
uiintro.add(''+get.translation(get.subtype(name))+'
');
}
else if(lib.card[name]&&lib.card[name].addinfomenu){
uiintro.add(''+lib.card[name].addinfomenu+'
');
}
else if(lib.card[name]&&lib.card[name].derivation){
if(typeof lib.card[name].derivation=='string'){
uiintro.add('来源:'+get.translation(lib.card[name].derivation)+'
');
}
else if(lib.card[name].derivationpack){
uiintro.add('来源:'+get.translation(lib.card[name].derivationpack+'_card_config')+'包
');
}
}
else{
if(lib.card[name].unique){
uiintro.add('特殊'+get.translation(lib.card[name].type)+'牌
');
}
else{
if(lib.card[name].type&&lib.translate[lib.card[name].type]) uiintro.add(''+get.translation(lib.card[name].type)+'牌
');
}
}
if(lib.card[name].unique&&lib.card[name].type=='equip'){
if(lib.cardPile.guozhan&&lib.cardPack.guozhan.contains(name)){
uiintro.add('专属装备
').style.marginTop='-5px';
}
else{
uiintro.add('特殊装备
').style.marginTop='-5px';
}
}
}
if(lib.card[name].cardPrompt){
var str=lib.card[name].cardPrompt(node.link||node),placetext=uiintro.add(''+str+'
');
if(str.indexOf(''+lib.translate[name+'_info']+'
');
if(lib.translate[name+'_info'].indexOf('应变:'+lib.card[name].yingbian_prompt(node.link||node)+'
');
else uiintro.add('应变:'+lib.card[name].yingbian_prompt+'
');
}
if(lib.translate[name+'_append']){
uiintro.add(''+lib.translate[name+'_append']+'
');
}
}
uiintro.add(ui.create.div('.placeholder.slim'));
}
}
else if(node.classList.contains('character')){
var character=node.link;
if(lib.character[node.link]&&lib.character[node.link][1]){
var group=get.is.double(node.link,true);
if(group){
var str=get.translation(character)+' ';
for(var i=0;i'+get.translation(skills[i])+'
'+get.skillInfoTranslation(skills[i])+'
');
}
else{
uiintro.add('【'+translation+'】
'+get.skillInfoTranslation(skills[i])+'
');
}
if(lib.translate[skills[i]+'_append']){
uiintro._place_text=uiintro.add(''+lib.translate[skills[i]+'_append']+'
')
}
}
}
var modepack=lib.characterPack['mode_'+get.mode()];
if(lib.config.show_favourite&&
lib.character[node.link]&&(!modepack||!modepack[node.link])&&(!simple||get.is.phoneLayout())){
var addFavourite=ui.create.div('.text.center.pointerdiv');
addFavourite.link=node.link;
addFavourite.style.marginBottom='15px';
if(lib.config.favouriteCharacter.contains(node.link)){
addFavourite.innerHTML='移除收藏';
}
else{
addFavourite.innerHTML='添加收藏';
}
addFavourite.listen(ui.click.favouriteCharacter)
uiintro.add(addFavourite);
}
else{
uiintro.add(ui.create.div('.placeholder.slim'));
}
var addskin=false;
if(node.parentNode.classList.contains('menu-buttons')){
addskin=!lib.config.show_charactercard;
}
else{
addskin=lib.config.change_skin||lib.skin;
}
if(addskin&&(!simple||get.is.phoneLayout())){
var num=1;
var introadded=false;
var nameskin=node.link;
var nameskin2=nameskin;
var gzbool=false;
if(nameskin.indexOf('gz_shibing')==0){
nameskin=nameskin.slice(3,11);
}
else if(nameskin.indexOf('gz_')==0){
nameskin=nameskin.slice(3);
gzbool=true;
}
var createButtons=function(num){
if(!num) return;
if(!introadded){
introadded=true;
uiintro.add('更改皮肤
');
}
var buttons=ui.create.div('.buttons.smallzoom.scrollbuttons');
lib.setMousewheel(buttons);
for(var i=0;i<=num;i++){
var button=ui.create.div('.button.character.pointerdiv',buttons,function(){
if(this._link){
lib.config.skin[nameskin]=this._link;
node.style.backgroundImage=this.style.backgroundImage;
game.saveConfig('skin',lib.config.skin);
}
else{
delete lib.config.skin[nameskin];
if(gzbool&&lib.character[nameskin2][4].contains('gzskin')&&lib.config.mode_config.guozhan.guozhanSkin) node.setBackground(nameskin2,'character');
else node.setBackground(nameskin,'character');
game.saveConfig('skin',lib.config.skin);
}
});
button._link=i;
if(i){
button.setBackgroundImage('image/skin/'+nameskin+'/'+i+'.jpg');
}
else{
if(gzbool&&lib.character[nameskin2][4].contains('gzskin')&&lib.config.mode_config.guozhan.guozhanSkin) button.setBackground(nameskin2,'character','noskin');
else button.setBackground(nameskin,'character','noskin');
}
}
uiintro.add(buttons);
};
var loadImage=function(){
var img=new Image();
img.onload=function(){
num++;
loadImage();
}
img.onerror=function(){
num--;
createButtons(num);
}
img.src=lib.assetURL+'image/skin/'+nameskin+'/'+num+'.jpg';
}
if(lib.config.change_skin){
loadImage();
}
else{
setTimeout(function(){
createButtons(lib.skin[nameskin]);
});
}
}
}
}
else if(node.classList.contains('equips')&&ui.arena.classList.contains('selecting')){
(function(){
uiintro.add('选择装备');
uiintro.addSmall(Array.from(node.childNodes),true);
uiintro.clickintro=true;
ui.control.hide();
uiintro._onclose=function(){
ui.control.show();
}
var confirmbutton;
for(var i=0;i'+lib.translate['_'+career+'_skill_info']+'');
}
else if(node.classList.contains('skillbar')){
if(node==ui.friendBar){
uiintro.add('友方怒气值');
uiintro.add(''+_status.friendRage+'/100
');
}
else if(node==ui.enemyBar){
uiintro.add('敌方怒气值');
uiintro.add(''+_status.enemyRage+'/100
');
}
}
else if(node.parentNode==ui.historybar){
if(node.dead){
if(!node.source||node.source==node.player){
uiintro.add(''+get.translation(node.player)+'阵亡
');
uiintro.addSmall([node.player]);
}
else{
uiintro.add(''+get.translation(node.player)+'被'+get.translation(node.source)+'杀害
');
uiintro.addSmall([node.source]);
}
}
if(node.skill){
uiintro.add(''+get.translation(node.skill,'skill')+'
');
uiintro._place_text=uiintro.add(''+get.translation(node.skill,'info')+'
');
}
if(node.targets&&get.itemtype(node.targets)=='players'){
uiintro.add('目标
');
uiintro.addSmall(node.targets);
}
if(node.players&&node.players.length>1){
uiintro.add('使用者
');
uiintro.addSmall(node.players);
}
if(node.cards&&node.cards.length){
uiintro.add('卡牌
');
uiintro.addSmall(node.cards);
}
for(var i=0;i已横置');
var list=[];
for(var i=0;i4){
num=4+Math.sqrt(num-4);
}
else{
if(player.isHealthy()){
if(player.hp==3){
num+=0.5;
}
else if(player.hp<3){
num++;
}
}
}
num+=player.countCards('h')/2;
var es=player.getCards('e');
for(var i=0;i=7) num+=0.8;
if(val>=5) num+=0.5;
if(val>=3) num+=0.2;
}
return num;
},
attitude:function(from,to){
if(!from||!to) return 0;
from=from._trueMe||from;
arguments[0]=from;
var att=get.rawAttitude.apply(this,arguments);
if(from.isMad()) att=-att;
if(to.isMad()&&att>0){
if(to.identity=='zhu'){
att=1;
}
else{
att=0;
}
}
if(!_status.tempnofake){
_status.tempnofake=true;
if(from.ai.modAttitudeFrom){
att=from.ai.modAttitudeFrom(from,to,att);
}
if(to.ai.modAttitudeTo){
att=to.ai.modAttitudeTo(from,to,att);
}
delete _status.tempnofake;
}
return att;
},
sgnAttitude:function(){
return get.sgn(get.attitude.apply(this,arguments));
},
useful:function(card,player){
if(get.position(card)=='j') return -1;
if(get.position(card)=='e') return get.equipValue(card);
if(card._modUseful){
return card._modUseful();
}
var i=0;
if(!player) player=_status.event.player;
if(player){
i=player.getCards('h',card.name).indexOf(card);
if(i<0) i=0;
}
var aii=get.info(card).ai;
var useful;
if(aii&&aii.useful) useful=aii.useful;
else if(aii&&aii.basic) useful=aii.basic.useful;
var result;
if(useful==undefined) result=-1;
else if(typeof useful=='function'){
result=useful(card,i);
}
else if(typeof useful=='number') result=useful;
else if(i0&&!target.needsToDiscard()&&!get.tag(card,'valueswap')){
return 0;
}
}
}
return Math.max(0,value1-value2)/5;
},
equipValue:function(card,player){
if(player==undefined||get.itemtype(player)!='player') player=get.owner(card);
if(player==undefined||get.itemtype(player)!='player') player=_status.event.player;
var info=get.info(card);
if(!info.ai) return 0;
var value=info.ai.equipValue;
if(value==undefined){
if(info.ai.basic&&info.ai.basic.equipValue!=undefined){
value=info.ai.basic.equipValue;
}
else return 0;
}
if(typeof value=='number') return value;
if(typeof value=='function') return value(card,player,null,'raw2');
return 0;
},
equipValueNumber:function(card){
var info=get.info(card);
if(info.ai){
if(typeof info.ai.equipValue=='number') return info.ai.equipValue;
if(info.ai.basic&&typeof info.ai.basic.equipValue=='number') return info.ai.basic.equipValue;
}
return 0;
},
disvalue:function(card,player){
return -get.value(card,player);
},
disvalue2:function(card,player){
return -get.value(card,player,'raw');
},
skillthreaten:function(skill,player,target){
if(!lib.skill[skill]) return 1;
if(!lib.skill[skill].ai) return 1;
var threaten=lib.skill[skill].ai.threaten;
if(typeof threaten=='number') return threaten;
if(typeof threaten=='function'){
player=player||_status.event.player;
target=target||player;
return threaten(player,target);
}
return 1;
},
order:function(item){
var info=get.info(item);
if(!info) return -1;
var aii=info.ai;
var order;
if(aii&&aii.order) order=aii.order;
else if(aii&&aii.basic) order=aii.basic.order;
if(order==undefined) return -1;
var num=order;
if(typeof(order)=='function'){
num=order(item,_status.event.player);
}
if(typeof item=='object'&&_status.event.player){
var player=_status.event.player;
num=game.checkMod(player,item,num,'aiOrder',player);
}
return num;
},
result:function(item,skill){
var result;
var info=get.info(item);
if(info.ai) result=get.copy(info.ai.result);
if(typeof(result)=='function') result=result(item);
if(!result) result={};
if(skill){
var info2=get.info(skill);
if(info2.ai){
info2=info2.ai.result;
for(var i in info2){
result[i]=info2[i];
}
}
}
return result;
},
effect_use:function(target,card,player,player2,isLink){
var event=_status.event;
var eventskill=null;
if(player==undefined) player=_status.event.player;
if(typeof card!='string'&&(typeof card!='object'||!card.name)){
var skillinfo=get.info(event.skill);
if(event.skill&&skillinfo.viewAs==undefined) card=_status.event.skill;
else{
card=get.card();
if(skillinfo&&skillinfo.viewAs&&card.name===skillinfo.viewAs.name){
eventskill=event.skill;
}
}
}
var info=get.info(card);
if(typeof card=='object'&&info&&info.changeTarget){
var targets=[target];
info.changeTarget(player,targets);
var eff=0;
for(var i of targets){
eff+=get.effect(i,card,player,player2,isLink);
}
return eff;
}
var result=get.result(card,eventskill);
var result1=result.player_use||result.player,result2=result.target_use||result.target;
if(typeof result1=='function') result1=result1(player,target,card,isLink);
if(typeof result2=='function') result2=result2(player,target,card,isLink);
if(typeof result1!='number') result1=0;
if(typeof result2!='number') result2=0;
var temp1,temp2,temp3,temp01=0,temp02=0,threaten=1;
var skills1=player.getSkills().concat(lib.skill.global);
game.expandSkills(skills1);
var zerotarget=false,zeroplayer=false;
for(var i=0;i3) result2*=0.5;
if(target.hp==4) result2*=0.9;
if(target.hp==5) result2*=0.8;
if(target.hp>5) result2*=0.6;
}
}
else{
result2+=temp02;
result1+=temp01;
}
if(zeroplayer) result1=0;
if(zerotarget) result2=0;
var final=0;
if(player2){
final=(result1*get.attitude(player2,player)+(target?result2*get.attitude(player2,target):0));
}
else final=(result1*get.attitude(player,player)+(target?result2*get.attitude(player,target):0));
if(!isLink&&get.tag(card,'natureDamage')&&!zerotarget){
var info=get.info(card);
if(!info||!info.ai||!info.ai.canLink){
if(target.isLinked()) game.countPlayer(function(current){
if(current!=target&¤t.isLinked()) final+=get.effect(current,card,player,player2,true);
});
}
else if(info.ai.canLink(player,target,card)){
game.countPlayer(function(current){
if(current!=target&¤t.isLinked()) final+=get.effect(current,card,player,player2,true);
});
}
}
return final;
},
effect:function(target,card,player,player2,isLink){
var event=_status.event;
var eventskill=null;
if(player==undefined) player=_status.event.player;
if(typeof card!='string'&&(typeof card!='object'||!card.name)){
var skillinfo=get.info(event.skill);
if(event.skill&&skillinfo.viewAs==undefined) card=_status.event.skill;
else{
card=get.card();
if(skillinfo&&skillinfo.viewAs&&card.name===skillinfo.viewAs.name){
eventskill=event.skill;
}
}
}
var result=get.result(card,eventskill);
var result1=result.player,result2=result.target;
if(typeof result1=='function') result1=result1(player,target,card,isLink);
if(typeof result2=='function') result2=result2(player,target,card,isLink);
if(typeof result1!='number') result1=0;
if(typeof result2!='number') result2=0;
var temp1,temp2,temp3,temp01=0,temp02=0,threaten=1;
var skills1=player.getSkills().concat(lib.skill.global);
game.expandSkills(skills1);
var zerotarget=false,zeroplayer=false;
for(var i=0;i3) result2*=0.5;
if(target.hp==4) result2*=0.9;
if(target.hp==5) result2*=0.8;
if(target.hp>5) result2*=0.6;
}
}
else{
result2+=temp02;
result1+=temp01;
}
if(zeroplayer) result1=0;
if(zerotarget) result2=0;
var final=0;
if(player2){
final=(result1*get.attitude(player2,player)+(target?result2*get.attitude(player2,target):0));
}
else final=(result1*get.attitude(player,player)+(target?result2*get.attitude(player,target):0));
if(!isLink&&get.tag(card,'natureDamage')&&!zerotarget){
var info=get.info(card);
if(!info||!info.ai||!info.ai.canLink){
if(target.isLinked()) game.countPlayer(function(current){
if(current!=target&¤t.isLinked()) final+=get.effect(current,card,player,player2,true);
});
}
else if(info.ai.canLink(player,target,card)){
game.countPlayer(function(current){
if(current!=target&¤t.isLinked()) final+=get.effect(current,card,player,player2,true);
});
}
}
return final;
},
damageEffect:function(target,player,viewer,nature){
if(!player){
player=target;
}
if(!viewer){
viewer=target;
}
var name='damage';
if(nature=='fire'){
name='firedamage';
}
else if(nature=='thunder'){
name='thunderdamage';
}
else if(nature=='ice'){
name='icedamage';
}
var eff=get.effect(target,{name:name},player,viewer);
if(eff>0&&target.hujia>0) return eff/1.3;
return eff;
},
recoverEffect:function(target,player,viewer){
if(target.hp==target.maxHp) return 0;
if(!player){
player=target;
}
if(!viewer){
viewer=target;
}
return get.effect(target,{name:'recover'},player,viewer);
},
buttonValue:function(button){
var card=button.link;
var player=get.owner(card);
if(!player) player=_status.event.player;
if(player.getCards('j').contains(card)){
var efff=get.effect(player,{
name:card.viewAs||card.name,
cards:[card],
},player,player);
if(efff>0) return 0.5;
if(efff==0) return 0;
return -1.5;
}
if(player.getCards('e').contains(card)){
var evalue=get.value(card,player);
if(player.hasSkillTag('noe')){
if(evalue>=7){
return evalue/6;
}
return evalue/10;
}
return evalue/3;
}
if(player.hasSkillTag('noh')) return 0.1;
var nh=player.countCards('h');
switch(nh){
case 1:return 2;
case 2:return 1.6;
case 3:return 1;
case 4:return 0.8;
case 5:return 0.6;
default:return 0.4;
}
},
attitude2:function(to){
return get.attitude(_status.event.player,to);
},
};
var ai={
basic:{
chooseButton:function(check){
var event=_status.event;
var i,j,range,buttons,buttons2;
var ok=false,forced=event.forced;
var iwhile=100;
while(iwhile--){
range=get.select(event.selectButton);
if(ui.selected.buttons.length>=range[0]){
ok=true;
}
if(range[1]<=-1){
j=0;
for(i=0;i0);
}
buttons=get.selectableButtons();
if(buttons.length==0){
return ok;
}
buttons2=buttons.slice(0);
var ix=0;
var checkix=check(buttons[0],buttons2);
for(i=1;icheckix){
ix=i;
checkix=checkixtmp;
}
}
// buttons.sort(function(a,b){
// return check(b,buttons2)-check(a,buttons2);
// });
if(check(buttons[ix])<=0){
if(!forced||ok){
return ok;
}
}
buttons[ix].classList.add('selected');
ui.selected.buttons.add(buttons[ix]);
game.check();
if(ui.selected.buttons.length>=range[0]){
ok=true;
}
if(ui.selected.buttons.length==range[1]){
return true;
}
}
},
chooseCard:function(check){
var event=_status.event;
if(event.filterCard==undefined) return (check()>0);
var i,j,range,cards,cards2,skills,check,effect;
var ok=false,forced=event.forced;
var iwhile=100;
while(iwhile--){
range=get.select(event.selectCard);
if(ui.selected.cards.length>=range[0]){
ok=true;
}
if(range[1]<=-1){
if(ui.selected.cards.length==0) return true;
j=0;
for(i=0;i0);
}
cards=get.selectableCards();
if(!_status.event.player._noSkill){
cards=cards.concat(get.skills());
}
if(cards.length==0){
return ok;
}
cards2=cards.slice(0);
// cards.sort(function(a,b){
// return (check(b,cards2)-check(a,cards2));
// });
var ix=0;
var checkix=check(cards[0],cards2);
for(i=1;icheckix){
ix=i;
checkix=checkixtmp;
}
}
if(check(cards[ix])<=0){
if(!forced||ok){
return ok;
}
}
if(typeof cards[ix]=='string'){
ui.click.skill(cards[ix]);
var info=get.info(event.skill);
if(info.filterCard){
check=info.check||get.unuseful2;
return (ai.basic.chooseCard(check));
}
else{
return true;
}
}
else{
cards[ix].classList.add('selected');
ui.selected.cards.add(cards[ix]);
game.check();
if(ui.selected.cards.length>=range[0]){
ok=true;
}
if(ui.selected.cards.length==range[1]){
return true;
}
}
}
},
chooseTarget:function(check){
var event=_status.event;
if(event.filterTarget==undefined) return (check()>0);
var i,j,range,targets,targets2,effect;
var ok=false,forced=event.forced;
var iwhile=100;
while(iwhile--){
range=get.select(event.selectTarget);
if(range[1]<=-1){
j=0;
for(i=0;i0);
}
else if(range[1]==0){
return check()>0
}
targets=get.selectableTargets();
if(targets.length==0){
return range[0]==0||ok;
}
targets2=targets.slice(0);
// targets.sort(function(a,b){
// return check(b)-check(a);
// });
var ix=0;
var checkix=check(targets[0],targets2);
for(i=1;icheckix){
ix=i;
checkix=checkixtmp;
}
}
if(check(targets[ix])<=0){
if(!forced||ok){
return ok;
}
}
targets[ix].classList.add('selected');
ui.selected.targets.add(targets[ix]);
game.check();
if(ui.selected.targets.length>=range[0]){
ok=true;
}
if(ui.selected.targets.length==range[1]){
return true;
}
}
}
},
get:get
};
lib.init.init();
}());