noname/game/game.js

17219 lines
507 KiB
JavaScript
Raw Normal View History

2015-04-29 03:25:17 +00:00
"use strict";
(function(){
var _status={
paused:false,
paused2:false,
over:false,
clicked:false,
auto:false,
event:{
finished:true,
next:[],
},
ai:{},
2015-11-01 07:54:42 +00:00
lastdragchange:[],
skillaudio:[],
2015-11-09 03:15:16 +00:00
dieClose:[]
2015-04-29 03:25:17 +00:00
};
var lib={
configprefix:'noname_0.9_',
updates:[],
canvasUpdates:[],
2015-11-04 01:59:00 +00:00
video:[],
2015-11-09 09:05:28 +00:00
arenaReady:[],
2015-11-04 01:59:00 +00:00
_onDB:[],
onDB:function(func){
if(lib.db){
func();
}
else{
lib._onDB.push(func);
}
},
2015-10-29 17:36:14 +00:00
configMenu:{
general:{
name:'通用',
config:{
cheat:{
name:'控制台命令',
init:false,
onclick:function(bool){
if(lib.config.cheat&&bool==false){
lib.cheat=window.cheat;
delete window.cheat;
delete window.game;
delete window.ui;
delete window.get;
delete window.ai;
delete window.lib;
delete window._status;
}
else if(!lib.config.cheat&&bool){
window.cheat=lib.cheat;
window.cheat.i();
}
game.saveConfig('cheat',bool);
},
unfrequent:true,
},
auto_confirm:{
name:'自动确认',
init:true,
},
enable_drag:{
name:'启用拖拽',
init:true,
},
wuxie_self:{
name:'不无懈自己',
init:true,
2015-10-30 09:13:19 +00:00
},
2015-11-05 02:34:35 +00:00
touchscreen:{
name:'触屏模式',
init:false,
restart:true
},
2015-10-30 09:13:19 +00:00
game_speed:{
name:'游戏速度',
init:'mid',
item:{
vslow:'慢',
slow:'较慢',
mid:'中',
fast:'较快',
vfast:'快',
},
},
right_click:{
name:'右键功能',
init:'pause',
unfrequent:true,
item:{
pause:'暂停',
config:'选项',
auto:'托管',
}
},
right_info:{
name:'右键显示信息',
init:true,
unfrequent:true,
restart:true
},
hover_all:{
name:'悬停显示信息',
init:true,
unfrequent:true,
restart:true,
},
hover_handcard:{
name:'悬停手牌显示信息',
init:true,
unfrequent:true,
},
hoveration:{
name:'悬停菜单弹出时间',
unfrequent:true,
init:'1000',
item:{
'500':'0.5秒',
'700':'0.7秒',
'1000':'1秒',
'1500':'1.5秒',
'2500':'2.5秒',
}
},
mousewheel:{
name:'滚轮控制手牌',
init:true,
unfrequent:true,
onclick:function(bool){
game.saveConfig('mousewheel',bool);
if(lib.config.touchscreen) return;
if(lib.config.mousewheel){
game.me.node.handcards1.onmousewheel=ui.click.mousewheel;
game.me.node.handcards2.onmousewheel=ui.click.mousewheel;
}
else{
game.me.node.handcards1.onmousewheel=null;
game.me.node.handcards2.onmousewheel=null;
}
}
},
2015-11-04 01:59:00 +00:00
video:{
name:'保存录像',
init:'20',
item:{
'0':'关闭',
'5':'五局',
'10':'十局',
'20':'二十局',
'50':'五十局',
'10000':'无限',
},
unfrequent:true,
},
2015-10-30 09:13:19 +00:00
update:function(config,map){
if(!config.hover_all){
map.hover_handcard.hide();
map.hoveration.hide();
}
else{
map.hover_handcard.show();
map.hoveration.show();
}
if(config.touchscreen){
map.mousewheel.hide();
2015-11-09 17:04:18 +00:00
map.hover_all.hide();
map.hover_handcard.hide();
map.hoveration.hide();
2015-10-30 09:13:19 +00:00
}
else{
map.mousewheel.show();
2015-11-09 17:04:18 +00:00
map.hover_all.show();
map.hover_handcard.show();
map.hoveration.show();
2015-10-30 09:13:19 +00:00
}
2015-10-29 17:36:14 +00:00
}
}
},
appearence:{
name:'外观',
config:{
theme:{
name:'主题',
init:'woodden',
item:{
woodden:'木纹',
music:'音乐',
simple:'简约',
},
onclick:function(theme){
game.saveConfig('theme',theme);
ui.arena.hide();
setTimeout(function(){
var theme=ui.css.theme;
ui.css.theme=lib.init.css('theme/'+lib.config.theme,'style');
theme.remove();
setTimeout(function(){ui.arena.show();},100);
},500);
}
2015-10-30 09:13:19 +00:00
},
layout:{
name:'布局',
2015-11-05 02:34:35 +00:00
init:'mobile',
2015-10-30 09:13:19 +00:00
item:{
2015-10-31 10:14:14 +00:00
default:'旧版',
2015-11-05 02:34:35 +00:00
newlayout:'对称',
mobile:'默认',
2015-10-31 16:18:20 +00:00
phone:'移动'
2015-10-30 09:13:19 +00:00
},
onclick:function(layout){
game.saveConfig('layout',layout);
2015-10-31 10:14:14 +00:00
if(lib.config.layoutfixed.contains(lib.config.mode)&&layout=='default'){
return;
2015-10-30 09:13:19 +00:00
}
2015-10-31 10:14:14 +00:00
setTimeout(function(){
var layout=ui.css.layout;
ui.css.layout=lib.init.css('layout/'+lib.config.layout,'layout',layout);
2015-10-31 16:18:20 +00:00
if(lib.config.layout=='mobile'||lib.config.layout=='phone'){
2015-10-31 10:14:14 +00:00
ui.arena.classList.add('mobile');
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);
}
}
}
else{
ui.arena.classList.remove('mobile');
}
setTimeout(function(){
layout.remove();
ui.arena.show();
2015-11-09 17:04:18 +00:00
if(game.me) game.me.update();
2015-10-31 10:14:14 +00:00
setTimeout(function(){
ui.updatex();
},500);
},100);
},500);
2015-10-30 09:13:19 +00:00
}
},
ui_zoom:{
name:'界面缩放',
unfrequent:true,
init:'normal',
item:{
2015-11-05 02:34:35 +00:00
esmall:'80%',
vsmall:'90%',
small:'95%',
normal:'100%',
big:'105%',
vbig:'110%',
ebig:'120%',
2015-10-30 09:13:19 +00:00
},
onclick:function(zoom){
game.saveConfig('ui_zoom',zoom);
switch(zoom){
case 'esmall':ui.window.style.zoom=0.8;break;
case 'vsmall':ui.window.style.zoom=0.9;break;
case 'small':ui.window.style.zoom=0.95;break;
case 'big':ui.window.style.zoom=1.05;break;
case 'vbig':ui.window.style.zoom=1.1;break;
2015-11-05 02:34:35 +00:00
case 'ebig':ui.window.style.zoom=1.2;break;
2015-10-30 09:13:19 +00:00
default:ui.window.style.zoom=1;
}
}
},
image_background:{
name:'游戏背景',
init:'default',
item:{
default:'默认',
huangyueying_bg:'逐墨',
zhulian_bg:'璧合',
september_bg:'九月',
xueji_bg:'雪霁',
yinxiang_bg:'印象',
chunhui_bg:'春晖',
grass_bg:'芳草',
huangtian_bg:'黄天',
},
onclick:function(background){
var animate=lib.config.image_background=='default';
game.saveConfig('image_background',background);
ui.background.delete();
ui.background=ui.create.div('.background');
switch (lib.config.image_background_filter){
2015-11-05 02:34:35 +00:00
case 'blur':
ui.background.style.filter='blur(8px)';
ui.background.style.webkitFilter='blur(8px)';
ui.background.style.transform='scale(1.05)';
break;
case 'gray':
ui.background.style.filter='grayscale(1)';
ui.background.style.webkitFilter='grayscale(1)';
break;
case 'sepia':
ui.background.style.filter='sepia(0.5)';
ui.background.style.webkitFilter='sepia(0.5)';
break;
case 'invert':
ui.background.style.filter='invert(1)';
ui.background.style.webkitFilter='invert(1)';
break;
case 'saturate':
ui.background.style.filter='saturate(5)';
ui.background.style.webkitFilter='saturate(5)';
break;
case 'contrast':
ui.background.style.filter='contrast(1.4)';
ui.background.style.webkitFilter='contrast(1.4)';
break;
case 'hue':
ui.background.style.filter='hue-rotate(180deg)';
ui.background.style.webkitFilter='hue-rotate(180deg)';
break;
case 'brightness':
ui.background.style.filter='brightness(5)';
ui.background.style.webkitFilter='brightness(5)';
break;
default:
ui.background.style.filter='';
ui.background.style.webkitFilter='';
ui.background.style.transform='';
2015-10-30 09:13:19 +00:00
}
document.body.insertBefore(ui.background,document.body.firstChild);
if(animate) ui.background.animate('start');
if(lib.config.image_background=='default'){
ui.background.style.backgroundImage="none";
}
else{
ui.background.style.backgroundImage="url('image/background/"+lib.config.image_background+".jpg')";
}
ui.background.style.backgroundSize='cover';
},
},
image_background_filter:{
name:'背景特效',
init:'default',
item:{
default:'无',
blur:'模糊',
gray:'黑色',
sepia:'怀旧',
invert:'反色',
saturate:'饱和',
contrast:'对比',
hue:'偏色',
brightness:'高亮',
},
onclick:function(filter){
game.saveConfig('image_background_filter',filter);
ui.click.sidebar.image_background(lib.config.image_background);
},
},
2015-11-06 10:05:08 +00:00
card_style:{
name:'卡牌样式',
init:'mobile',
item:{
default:'默认',
wood:'木纹',
music:'音乐',
simple:'原版'
},
onclick:function(layout){
game.saveConfig('card_style',layout);
var style=ui.css.card_style;
ui.css.card_style=lib.init.css('theme/cardstyle',lib.config.card_style);
style.remove();
},
unfrequent:true,
},
2015-11-05 02:34:35 +00:00
auto_popped_config:{
name:'自动弹出选项',
2015-10-30 09:13:19 +00:00
init:true,
unfrequent:true,
},
2015-11-05 02:34:35 +00:00
auto_popped_history:{
name:'自动弹出历史',
init:false,
unfrequent:true,
},
2015-10-30 09:13:19 +00:00
only_fullskin:{
name:'隐藏无全身皮肤武将',
init:true,
unfrequent:true,
restart:true,
},
hide_card_image:{
name:'隐藏卡牌背景',
init:false,
unfrequent:true,
restart:true,
},
bottom_line:{
name:'指示线置底',
init:false,
unfrequent:true,
onclick:function(bool){
game.saveConfig('bottom_line',bool);
if(lib.config.bottom_line){
ui.canvas.style.zIndex=0;
}
else{
ui.canvas.style.zIndex='';
}
}
},
line_dash:{
name:'虚线指示线',
init:false,
unfrequent:true,
},
2015-11-06 10:05:08 +00:00
glow_phase:{
name:'当前回合角色高亮',
init:false,
unfrequent:true,
onclick:function(bool){
game.saveConfig('glow_phase',bool);
if(_status.currentPhase){
if(lib.config.glow_phase){
_status.currentPhase.classList.add('glow_phase');
}
else{
_status.currentPhase.classList.remove('glow_phase');
}
}
}
},
2015-10-30 09:13:19 +00:00
show_name:{
name:'显示武将名',
init:false,
unfrequent:true,
onclick:function(bool){
game.saveConfig('show_name',bool);
if(lib.config.show_name){
for(var i=0;i<game.players.length;i++){
game.players[i].node.name.style.display='';
}
}
else{
for(var i=0;i<game.players.length;i++){
game.players[i].node.name.style.display='none';
}
}
}
},
2015-11-06 10:05:08 +00:00
// savevideo:{
// name:'显示保存录像',
// init:true,
// onclick:function(bool){
// game.saveConfig('savevideo',bool);
// if(!lib.db) return;
// if(lib.config.savevideo){
// if(!ui.savevideo&&_status.over){
// ui.savevideo=ui.create.control('保存录像',game.saveVideo);
// }
// }
// else if(ui.savevideo){
// ui.savevideo.close();
// delete ui.savevideo;
// }
// },
// unfrequent:true,
// },
2015-10-30 09:13:19 +00:00
show_replay:{
name:'显示重来按钮',
init:false,
unfrequent:true,
onclick:function(bool){
game.saveConfig('show_replay',bool);
if(lib.config.show_replay){
ui.replay.style.display='';
}
else{
ui.replay.style.display='none';
}
}
},
show_playerids:{
name:'显示身份按钮',
init:true,
unfrequent:true,
onclick:function(bool){
game.saveConfig('show_playerids',bool);
if(lib.config.show_playerids){
ui.playerids.style.display='';
}
else{
ui.playerids.style.display='none';
}
}
},
show_pause:{
2015-11-07 09:20:15 +00:00
name:'显示暂停按钮',
2015-10-30 09:13:19 +00:00
init:true,
unfrequent:true,
onclick:function(bool){
game.saveConfig('show_pause',bool);
if(lib.config.show_pause){
ui.pause.style.display='';
}
else{
ui.pause.style.display='none';
}
}
},
show_auto:{
name:'显示托管按钮',
init:true,
unfrequent:true,
onclick:function(bool){
game.saveConfig('show_auto',bool);
if(lib.config.show_auto){
ui.auto.style.display='';
}
else{
ui.auto.style.display='none';
}
}
},
show_volumn:{
name:'显示音量按钮',
init:true,
unfrequent:true,
onclick:function(bool){
game.saveConfig('show_volumn',bool);
if(lib.config.show_volumn){
ui.volumn.style.display='';
}
else{
ui.volumn.style.display='none';
}
}
},
show_wuxie:{
name:'显示不询问无懈',
init:true,
unfrequent:true,
onclick:function(bool){
game.saveConfig('show_wuxie',bool);
if(lib.config.show_wuxie){
ui.wuxie.style.display='';
}
else{
ui.wuxie.style.display='none';
}
}
},
show_discardpile:{
name:'暂停时显示弃牌堆',
init:false,
unfrequent:true,
},
title:{
name:'标题栏显示信息',
init:false,
unfrequent:true,
onclick:function(bool){
game.saveConfig('title',bool);
if(!lib.config.title) document.title='无名杀';
}
},
fold_card:{
name:'折叠手牌',
init:true,
onclick:function(bool){
game.saveConfig('fold_card',bool);
if(bool){
ui.css.fold=lib.init.css('layout/default','fold');
}
else if(ui.css.fold){
ui.css.fold.remove();
}
2015-11-06 10:05:08 +00:00
},
unfrequent:true,
2015-10-30 09:13:19 +00:00
},
blur_ui:{
name:'模糊效果',
init:false,
unfrequent:true,
onclick:function(bool){
game.saveConfig('blur_ui',bool);
if(bool){
ui.css.blur_ui=lib.init.css('layout/default','blur');
}
else if(ui.css.blur_ui){
ui.css.blur_ui.remove();
}
}
},
animation:{
name:'游戏特效',
init:true,
},
update:function(config,map){
if(lib.config.image_background=='default'){
map.image_background_filter.hide();
}
else{
map.image_background_filter.show();
}
},
}
},
audio:{
name:'音效',
config:{
background_music:{
name:'背景音乐',
init:true,
item:{
music_default:'默认',
music_diaochan:'貂蝉',
music_shezhan:'舌战',
music_danji:'单骑',
music_random:'随机',
music_off:'关闭',
},
onclick:function(item){
game.saveConfig('background_music',item);
game.playBackgroundMusic();
}
},
background_audio:{
name:'游戏音效',
init:true,
},
background_speak:{
name:'人物配音',
init:true,
},
background_ogg:{
name:'补全配音',
init:false
}
}
},
playpack:{
name:'玩法',
config:{
character:{
name:'角色卡牌',
init:false,
restart:true,
onclick:function(bool){
if(bool){
lib.config.plays.add('character');
}
else{
lib.config.plays.remove('character');
}
game.saveConfig('plays',lib.config.plays);
}
},
soldier:{
name:'士兵模式',
init:false,
restart:true,
onclick:function(bool){
if(bool){
lib.config.plays.add('soldier');
}
else{
lib.config.plays.remove('soldier');
}
game.saveConfig('plays',lib.config.plays);
}
},
wuxing:{
name:'五行生克',
init:false,
restart:true,
onclick:function(bool){
if(bool){
lib.config.plays.add('wuxing');
}
else{
lib.config.plays.remove('wuxing');
}
game.saveConfig('plays',lib.config.plays);
}
},
2015-11-09 09:05:28 +00:00
weather:{
name:'天气变化',
init:false,
restart:true,
onclick:function(bool){
if(bool){
lib.config.plays.add('weather');
}
else{
lib.config.plays.remove('weather');
}
game.saveConfig('plays',lib.config.plays);
}
},
2015-10-30 09:13:19 +00:00
update:function(config,map){
for(var i in map){
if(lib.config.plays.contains(i)){
map[i].classList.add('on');
}
else{
map[i].classList.remove('on');
}
}
}
}
},
skill:{
name:'技能',
config:{
update:function(config,map){
for(var i in map){
if(map[i]._link.config.type=='autoskill'){
if(!lib.config.autoskilllist.contains(i)){
map[i].classList.add('on');
ui.autoskill[i].lastChild.classList.add('on');
}
else{
map[i].classList.remove('on');
ui.autoskill[i].lastChild.classList.remove('on');
}
}
else if(map[i]._link.config.type=='banskill'){
if(!lib.config.forbidlist.contains(i)){
map[i].classList.add('on');
}
else{
map[i].classList.remove('on');
}
}
}
}
}
},
others:{
name:'其它',
config:{
reset_game:{
name:'重置游戏',
onclick:function(){
var node=this;
if(node._clearing){
localStorage.clear();
2015-11-07 09:20:15 +00:00
indexedDB.deleteDatabase(lib.configprefix+'data');
game.reload();
2015-10-30 09:13:19 +00:00
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
},
import_data:{
name:'导入游戏数据',
onclick:function(){
ui.import_data_button.classList.toggle('hidden');
},
clear:true
},
import_data_button:{
name:'<div style="white-space:nowrap;width:calc(100% - 10px)">'+
'<input type="file" id="fileToLoad" style="width:calc(100% - 40px)">'+
'<button style="width:40px">确定</button></div>',
clear:true,
},
export_data:{
name:'导出游戏数据',
onclick:function(){
var data={};
for(var i in localStorage){
data[i]=localStorage[i];
}
2015-11-05 02:34:35 +00:00
game.export(lib.init.encode(JSON.stringify(data)),
'无名杀 - 数据 - '+(new Date()).toLocaleString());
2015-10-30 09:13:19 +00:00
},
clear:true
2015-10-29 17:36:14 +00:00
}
}
}
},
mode:{
identity:{
name:'身份',
config:{
2015-11-06 10:05:08 +00:00
update:function(config,map){
if(config.player_number=='8'){
map.double_nei.show();
}
else{
map.double_nei.hide();
}
2015-11-07 09:20:15 +00:00
if(config.identity_mode=='zhong'){
map.player_number.hide();
map.enhance_zhu.hide();
map.double_nei.hide();
map.auto_identity.hide();
}
else{
map.player_number.show();
map.enhance_zhu.show();
map.double_nei.show();
map.auto_identity.show();
}
},
identity_mode:{
name:'游戏模式',
init:'normal',
item:{
normal:'普通',
zhong:'明忠'
},
restart:true,
frequent:true,
2015-11-06 10:05:08 +00:00
},
2015-10-29 17:36:14 +00:00
player_number:{
name:'游戏人数',
init:'8',
item:{
'2':'两人',
'3':'三人',
'4':'四人',
'5':'五人',
'6':'六人',
'7':'七人',
'8':'八人'
},
2015-10-30 15:32:48 +00:00
frequent:true,
restart:true,
2015-10-29 17:36:14 +00:00
},
2015-11-06 10:05:08 +00:00
double_nei:{
name:'双内奸',
init:false,
frequent:true,
restart:true,
},
2015-10-29 17:36:14 +00:00
double_character:{
name:'双将模式',
init:false,
frequent:true,
restart:true,
},
double_hp:{
name:'双将体力上限',
init:'pingjun',
item:{
hejiansan:'和减三',
pingjun:'平均值',
zuidazhi:'最大值',
zuixiaozhi:'最小值',
zonghe:'相加',
},
restart:true,
},
auto_identity:{
name:'自动显示身份',
item:{
off:'关闭',
one:'一轮',
two:'两轮',
three:'三轮',
always:'始终'
},
init:'off',
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('auto_identity',bool,this._link.config.mode);
2015-11-07 09:20:15 +00:00
if(get.config('identity_mode')=='zhong') return;
2015-10-29 17:36:14 +00:00
var num;
switch(bool){
case '一轮':num=1;break;
case '两轮':num=2;break;
case '三轮':num=3;break;
default:num=0;break;
}
if(num&!_status.identityShown&&game.phaseNumber>game.players.length*num&&game.showIdentity){
_status.identityShown=true;
2015-11-01 07:54:42 +00:00
game.showIdentity(false);
2015-10-29 17:36:14 +00:00
}
}
},
ban_weak:{
name:'屏蔽弱将',
init:false,
restart:true,
},
enhance_zhu:{
name:'加强主公',
init:false,
restart:true,
frequent:true,
},
free_choose:{
name:'自由选将',
init:true,
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('free_choose',bool,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(!ui.cheat2&&get.config('free_choose')) ui.create.cheat2();
else if(ui.cheat2&&!get.config('free_choose')){
ui.cheat2.close();
delete ui.cheat2;
if(ui.cheat2x){
ui.cheat2x.close();
delete ui.cheat2;
}
}
}
},
change_identity:{
name:'自由选择身份和座位',
init:true,
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('change_identity',bool,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
var dialog;
if(ui.cheat2&&ui.cheat2.backup) dialog=ui.cheat2.backup;
else dialog=_status.event.dialog;
if(!dialog.querySelector('table')&&get.config('change_identity')) _status.event.parent.addSetting(dialog);
else _status.event.parent.removeSetting(dialog);
ui.update();
}
},
change_choice:{
name:'开启换将卡',
init:false,
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('change_choice',bool,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(!ui.cheat&&get.config('change_choice')) ui.create.cheat();
else if(ui.cheat&&!get.config('change_choice')){
ui.cheat.close();
delete ui.cheat;
}
}
},
change_card:{
name:'开启手气卡',
init:false,
},
dierestart:{
name:'死亡后显示重来',
init:true,
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('dierestart',bool,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(get.config('dierestart')){
if(!ui.restart&&game.me.isDead()){
ui.restart=ui.create.control('restart',game.reload);
}
}
else if(ui.restart){
ui.restart.close();
delete ui.restart;
}
}
},
2015-11-06 10:05:08 +00:00
// swap:{
// name:'死亡后显示换人',
// init:true,
// onclick:function(bool){
// game.saveConfig('swap',bool,this._link.config.mode);
// if(get.config('swap')){
// if(!ui.swap&&game.me.isDead()){
// ui.swap=ui.create.control('换人',ui.click.dieswap);
// }
// }
// else if(ui.swap){
// ui.swap.close();
// delete ui.swap;
// }
// }
// },
2015-10-29 17:36:14 +00:00
revive:{
name:'死亡后显示复活',
init:false,
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('revive',bool,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(get.config('revive')){
if(!ui.revive&&game.me.isDead()){
ui.revive=ui.create.control('revive',ui.click.dierevive);
}
}
else if(ui.revive){
ui.revive.close();
delete ui.revive;
}
}
},
ai_strategy:{
name:'内奸策略',
init:'ai_strategy_1',
item:{
ai_strategy_1:'均衡',
ai_strategy_2:'偏反',
ai_strategy_3:'偏忠',
ai_strategy_4:'酱油',
ai_strategy_5:'天使',
ai_strategy_6:'仇主',
}
},
difficulty:{
name:'AI对人类态度',
init:'normal',
item:{
easy:'友好',
normal:'一般',
hard:'仇视',
}
},
}
},
guozhan:{
name:'国战',
config:{
2015-11-09 17:04:18 +00:00
guozhan_mode:{
name:'游戏模式',
init:'normal',
item:{
normal:'普通',
mingjiang:'明将'
},
restart:true,
frequent:true,
},
2015-10-29 17:36:14 +00:00
player_number:{
name:'游戏人数',
init:'8',
item:{
'3':'三人',
'4':'四人',
'5':'五人',
'6':'六人',
'7':'七人',
'8':'八人'
},
2015-10-30 15:32:48 +00:00
frequent:true,
restart:true,
2015-10-29 17:36:14 +00:00
},
initshow_draw:{
name:'首亮摸牌',
item:{
'0':'无',
'1':'一张',
'2':'两张',
2015-11-07 09:20:15 +00:00
'3':'三张',
2015-10-29 17:36:14 +00:00
},
init:'2',
frequent:true,
},
zhulian:{
name:'珠联璧合',
init:true,
frequent:true,
},
double_hp:{
name:'双将体力上限',
init:'pingjun',
item:{
hejiansan:'和减三',
pingjun:'平均值',
zuidazhi:'最大值',
zuixiaozhi:'最小值',
zonghe:'相加',
},
restart:true,
},
free_choose:{
name:'自由选将',
init:true,
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('free_choose',bool,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(!ui.cheat2&&get.config('free_choose')) ui.create.cheat2();
else if(ui.cheat2&&!get.config('free_choose')){
ui.cheat2.close();
delete ui.cheat2;
if(ui.cheat2x){
ui.cheat2x.close();
delete ui.cheat2;
}
}
}
},
change_identity:{
name:'自由选择座位',
init:true,
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('change_identity',bool,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
var dialog;
if(ui.cheat2&&ui.cheat2.backup) dialog=ui.cheat2.backup;
else dialog=_status.event.dialog;
if(!dialog.querySelector('table')&&get.config('change_identity')) _status.event.parent.addSetting(dialog);
else _status.event.parent.removeSetting(dialog);
ui.update();
}
},
change_choice:{
name:'开启换将卡',
init:false,
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('change_choice',bool,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(!ui.cheat&&get.config('change_choice')) ui.create.cheat();
else if(ui.cheat&&!get.config('change_choice')){
ui.cheat.close();
delete ui.cheat;
}
}
},
change_card:{
name:'开启手气卡',
init:false,
},
dierestart:{
name:'死亡后显示重来',
init:true,
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('dierestart',bool,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(get.config('dierestart')){
if(!ui.restart&&game.me.isDead()){
ui.restart=ui.create.control('restart',game.reload);
}
}
else if(ui.restart){
ui.restart.close();
delete ui.restart;
}
}
},
2015-11-06 10:05:08 +00:00
// swap:{
// name:'死亡后显示换人',
// init:true,
// onclick:function(bool){
// game.saveConfig('swap',bool,this._link.config.mode);
// if(get.config('swap')){
// if(!ui.swap&&game.me.isDead()){
// ui.swap=ui.create.control('换人',ui.click.dieswap);
// }
// }
// else if(ui.swap){
// ui.swap.close();
// delete ui.swap;
// }
// }
// },
2015-10-29 17:36:14 +00:00
revive:{
name:'死亡后显示复活',
init:false,
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('revive',bool,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(get.config('revive')){
if(!ui.revive&&game.me.isDead()){
ui.revive=ui.create.control('revive',ui.click.dierevive);
}
}
else if(ui.revive){
ui.revive.close();
delete ui.revive;
}
}
},
difficulty:{
name:'AI对人类态度',
init:'normal',
item:{
easy:'友好',
normal:'一般',
hard:'仇视',
}
2015-11-04 01:59:00 +00:00
}
2015-10-29 17:36:14 +00:00
}
},
versus:{
name:'对决',
config:{
change_choice:{
name:'开启换将卡',
init:false,
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('change_choice',bool,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(!ui.cheat&&get.config('change_choice')) ui.create.cheat();
else if(ui.cheat&&!get.config('change_choice')){
ui.cheat.close();
delete ui.cheat;
}
},
frequent:true,
},
ban_weak:{
name:'屏蔽弱将',
init:false,
restart:true,
frequent:true,
},
}
},
boss:{
name:'挑战',
config:{
free_choose:{
name:'自由选将',
init:true,
frequent:true,
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('free_choose',bool,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(!ui.cheat2&&get.config('free_choose')) ui.create.cheat2();
else if(ui.cheat2&&!get.config('free_choose')){
ui.cheat2.close();
delete ui.cheat2;
if(ui.cheat2x){
ui.cheat2x.close();
delete ui.cheat2;
}
}
}
},
change_choice:{
name:'开启换将卡',
init:false,
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('change_choice',bool,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(!ui.cheat&&get.config('change_choice')) ui.create.cheat();
else if(ui.cheat&&!get.config('change_choice')){
ui.cheat.close();
delete ui.cheat;
}
},
frequent:true,
},
ban_weak:{
name:'屏蔽弱将',
init:false,
restart:true,
frequent:true,
},
}
},
chess:{
name:'战棋',
config:{
chess_mode:{
name:'游戏模式',
init:'combat',
item:{
combat:'对战',
leader:'统率'
},
restart:true,
frequent:true,
},
update:function(config,map){
if(config.chess_mode=='combat'){
map.chess_leader_save.hide();
map.chess_leader_clear.hide();
map.battle_number.show();
map.ban_weak.show();
map.free_choose.show();
map.change_choice.show();
map.chess_ordered.show();
map.chess_character.show();
}
else{
map.chess_leader_save.show();
map.chess_leader_clear.show();
map.battle_number.hide();
map.ban_weak.hide();
map.free_choose.hide();
map.change_choice.hide();
map.chess_ordered.hide();
map.chess_character.hide();
}
},
chess_leader_save:{
name:'选择历程',
init:'save1',
item:{
save1:'一',
save2:'二',
save3:'三',
save4:'四',
save5:'五',
},
restart:true,
frequent:true,
},
chess_leader_clear:{
name:'清除进度',
onclick:function(){
var node=this;
if(node._clearing){
game.save(get.config('chess_leader_save'),null);
window.location.reload();
return;
}
node._clearing=true;
node.innerHTML='单击以确认 (3)';
setTimeout(function(){
node.innerHTML='单击以确认 (2)';
setTimeout(function(){
node.innerHTML='单击以确认 (1)';
setTimeout(function(){
node.innerHTML='清除进度';
delete node._clearing;
},1000);
},1000);
},1000);
},
clear:true,
frequent:true,
},
battle_number:{
name:'对战人数',
init:'3',
frequent:true,
item:{
'2':'2v2',
'3':'3v3',
'4':'4v4',
'6':'6v6',
'8':'8v8',
},
onclick:function(num){
2015-10-30 15:32:48 +00:00
game.saveConfig('battle_number',num,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(_status.event.parent.changeDialog){
_status.event.parent.changeDialog();
}
},
},
2015-11-09 03:15:16 +00:00
chess_treasure:{
name:'特殊战场角色',
init:'0.2',
frequent:true,
item:{
'0':'关闭',
'0.1':'较少出现',
'0.2':'偶尔出现',
'0.333':'时常出现',
'0.5':'频繁出现',
}
},
chess_obstacle:{
name:'随机路障',
init:'0.333',
item:{
'0':'关闭',
'0.2':'少量',
'0.333':'中量',
'0.5':'大量',
},
frequent:true,
},
2015-11-09 17:04:18 +00:00
attack_move:{
name:'击退效果',
init:true,
// frequent:true,
},
2015-11-09 03:15:16 +00:00
show_distance:{
name:'显示距离',
init:true,
// frequent:true,
},
2015-10-29 17:36:14 +00:00
chess_ordered:{
name:'交替行动',
init:true,
2015-11-09 03:15:16 +00:00
// frequent:true,
2015-10-29 17:36:14 +00:00
},
chess_character:{
name:'战棋武将',
init:true,
2015-11-09 03:15:16 +00:00
// frequent:true,
2015-10-29 17:36:14 +00:00
},
2015-11-09 03:15:16 +00:00
chess_card:{
name:'战棋卡牌',
init:true,
// frequent:true,
2015-10-29 17:36:14 +00:00
},
free_choose:{
name:'自由选将',
init:true,
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('free_choose',bool,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(!ui.cheat2&&get.config('free_choose')) ui.create.cheat2();
else if(ui.cheat2&&!get.config('free_choose')){
ui.cheat2.close();
delete ui.cheat2;
if(ui.cheat2x){
ui.cheat2x.close();
delete ui.cheat2;
}
}
},
},
change_choice:{
name:'开启换将卡',
init:false,
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('change_choice',bool,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(!ui.cheat&&get.config('change_choice')) ui.create.cheat();
else if(ui.cheat&&!get.config('change_choice')){
ui.cheat.close();
delete ui.cheat;
}
},
},
ban_weak:{
name:'屏蔽弱将',
init:false,
restart:true,
},
2015-11-09 03:15:16 +00:00
chessscroll_speed:{
name:'边缘滚动速度',
init:'20',
item:{
'0':'不滚动',
'10':'10格/秒',
'20':'20格/秒',
'30':'30格/秒',
}
},
2015-10-29 17:36:14 +00:00
}
},
stone:{
name:'炉石',
config:{
battle_number:{
name:'出场人数',
init:'3',
frequent:true,
item:{
'2':'两人',
'3':'三人',
'4':'四人',
'6':'六人',
'8':'八人',
'10':'十人',
},
onclick:function(num){
2015-10-30 15:32:48 +00:00
game.saveConfig('battle_number',num,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(_status.event.parent.changeDialog){
_status.event.parent.changeDialog();
}
},
},
free_choose:{
name:'自由选将',
init:true,
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('free_choose',bool,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(!ui.cheat2&&get.config('free_choose')) ui.create.cheat2();
else if(ui.cheat2&&!get.config('free_choose')){
ui.cheat2.close();
delete ui.cheat2;
if(ui.cheat2x){
ui.cheat2x.close();
delete ui.cheat2;
}
}
},
frequent:true,
},
change_choice:{
name:'开启换将卡',
init:false,
onclick:function(bool){
2015-10-30 15:32:48 +00:00
game.saveConfig('change_choice',bool,this._link.config.mode);
2015-10-29 17:36:14 +00:00
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(!ui.cheat&&get.config('change_choice')) ui.create.cheat();
else if(ui.cheat&&!get.config('change_choice')){
ui.cheat.close();
delete ui.cheat;
}
},
frequent:true,
},
ban_weak:{
name:'屏蔽弱将',
init:false,
restart:true,
frequent:true,
},
}
}
},
2015-04-29 03:25:17 +00:00
status:{
running:false,
canvas:false,
time:0,
delayed:0,
frameId:0,
2015-11-04 01:59:00 +00:00
videoId:0,
2015-04-29 03:25:17 +00:00
},
help:{
2015-10-30 15:32:48 +00:00
'游戏选项':'<ul><li>控制台命令<br>开启后可用浏览器控制台控制游戏<li>自动确认<br>开启后当候选目标仅有1个时点击目标无需再点击确定<li>'+
'触屏模式<br>可消除iOS等设备上300ms的点击延迟但开启后无法使用鼠标<li>滚轮控制手牌<br>开启后滚轮可控制手牌的左右滚动建议Mac等具备横向滚动功能的设备关闭此选项'+
'<li>隐藏非全身皮肤<br>在新版布局中,若角色没有全身皮肤将被隐藏<li>游戏玩法<br>为游戏增加不同玩法,开启后可在帮助中查看介绍'+
'<li>加强主公<br>反贼人数多于2时主公会额外增加一个技能每个主公的额外技能固定非常备主公增加天命',
2015-11-09 17:04:18 +00:00
'游戏操作':'<ul><li>长按/鼠标悬停/右键单击(需在设置中开启)显示信息<li>触屏模式中双指点击切换暂停<li>移动布局中,点击顶部的左半边或右半边可显示按钮,双击顶部可令界面下移(方便标身份)<li>键盘快捷键<br>'+
2015-10-30 15:32:48 +00:00
'<table><tr><td>a<td>切换托管<tr><td>c<td>打开设置<tr><td>w<td>切换不询问无懈<tr><td>▭<td>暂停</ul>',
'游戏命令':'<div style="margin:10px">变量名</div><ul style="margin-top:0"><li>场上角色<br>game.players<li>阵亡角色<br>game.dead'+
'<li>玩家<br>game.me<li>玩家的上/下家<br>game.me.previous/next'+
'<li>玩家的上/下家(含阵亡)<br>game.me.previousSeat/<br>nextSeat'+
'<li>牌堆<br>ui.cardPile<li>弃牌堆<br>ui.discardPile</ul>'+
'<div style="margin:10px">角色属性</div><ul style="margin-top:0"><li>体力值<br>player.hp'+
'<li>体力上限<br>player.maxHp<li>身份<br>player.identity<li>手牌<br>player.get("h")<li>装备牌<br>player.get("e")<li>判定牌<br>player.get("j")'+
'<li>是否存活/横置/翻面<br>player.isAlive()/isLinked()/<br>isTurnedOver()</ul>'+
'<div style="margin:10px">角色操作</div><ul style="margin-top:0"><li>受到伤害<br>player.damage(source,<br>num)'+
'<li>回复体力<br>player.recover(num)<li>摸牌<br>player.draw(num)<li>获得牌<br>player.gain(cards)<li>弃牌<br>player.discard(cards)'+
'<li>使用卡牌<br>player.useCard(card,<br>targets)<li>死亡<br>player.die()<li>复活<br>player.revive(hp)</ul>'+
2015-10-31 03:20:59 +00:00
'<div style="margin:10px">游戏操作</div><ul style="margin-top:0"><li>在命令输入框中输出结果<br>game.print(str)<li>游戏结束<br>game.over(bool)'+
2015-11-07 09:20:15 +00:00
'<li>角色资料<br>lib.character<li>卡牌资料<br>lib.card',
'身份模式':'<div style="margin:10px">明忠</div><ul style="margin-top:0"><li>本模式需要8名玩家进行游戏使用的身份牌为1主公、2忠臣、4反贼和1内奸。游戏开始时每名玩家随机获得一个身份由系统随机选择一名忠臣身份的玩家亮出身份将忠臣牌正面朝上放在面前其他身份包括主公的玩家不亮出身份。<li>'+
'首先由亮出身份的忠臣玩家随机获得六张武将牌,挑选一名角色,并将选好的武将牌展示给其他玩家。之后其余每名玩家随机获得三张武将牌,各自从其中挑选一张同时亮出<li>'+
'亮出身份牌的忠臣增加1点体力上限。角色濒死和死亡的结算及胜利条件与普通身份局相同。',
2015-11-09 03:15:16 +00:00
'战棋模式':
'<div style="margin:10px">对阵模式</div><ul style="margin-top:0"><li>n人对战n人的模式由单人控制开始游戏后随机分配位置与出牌顺序<li>'+
2015-11-09 17:04:18 +00:00
'每人在出牌阶段有一次移动的机会可移动的最大距离为2<li>'+
2015-11-07 09:20:15 +00:00
'任何卡牌或技能无法指定位置相隔8个格以上的角色为目标<li>'+
'杀死对方阵营的角色可摸一张牌,杀死本方阵营无惩罚<li>'+
2015-11-09 03:15:16 +00:00
'开启交替行动时双方无论存活角色角色多少都将轮流进行行动。在一方所有角色行动完毕进行下一轮行动时若其人数比另一方少另一方可指定至多X名角色名摸一张牌X为人数之差<li>'+
'开启特殊战场角色后每个回合结束时有一定机率出现一个特殊角色该角色不参与战斗并有一个影响周围或全体角色的效果。该角色在出现后的5〜10个回合内消失<li>'+
2015-11-09 17:04:18 +00:00
'开启击退效果后,当一名角色对相邻目标造成伤害后,受伤害角色将沿反方向移动一格<li>'+
'战场上可设置出现随机路障,角色无法移动到路障处。当一名角色的周围四格有至少三格为路障或在战场外时,其可以在回合内清除一个相邻路障</ul>'+
2015-11-09 03:15:16 +00:00
'<div style="margin:10px">统率模式</div><ul style="margin-top:0"><li>收集武将进行战斗,根据战斗难度及我方出场武将的强度,战斗胜利后将获得数量不等的金钱。没有君主出场时,获得的金钱较多<li>'+
2015-11-07 09:20:15 +00:00
'金钱可以用来招募随机武将,招到已有武将,或遣返不需要的武将时可得到招募令<li>'+
'战斗中有君主出场时可招降敌将成功率取决于敌将的稀有度、剩余体力值以及手牌数。成功后战斗立即结束且没有金钱奖励。每发动一次招降无论成功还是失败都会扣除10招募令<li>'+
'挑战武将会与该武将以及与其强度相近的武将进行战斗敌方人数与我方出场人数相同但不少于3。胜利后可通过招募令招募该武将<li>'+
'竞技场:<br>随机选择9名武将每次派出1〜3名武将参战。战斗中阵亡的武将不能再次上场。<br><br>战斗后武将进入疲劳状态,若立即再次出场则初始体力值-1。<br><br>战斗中本方武将行动时可召唤后援,令一名未出场的已方武将加入战斗。后援武将在战斗结束后无论存活与否均不能再次出场<br><br>当取得12场胜利或所有武将全部阵亡后结束并根据胜场数获得随机奖励',
'炉石模式':'<ul><li>游戏流程类似1v1场上有两名主将进行对抗'+
'<li>主将出牌阶段的出牌数量行动值有上限先手为2后手为3装备牌不计入出牌上限<li>游戏每进行一轮,主将的出牌上限+1超过6时减至2并重新累加'+
'<li>牌堆中随机加入总量1/3的随从牌使用之可召唤一个随从随从出场时背面朝上。每一方在场的随从数不能超过4<li>随从于摸牌阶段摸牌基数为1随从的随从牌均视为闪装备牌均视为杀<li>'+
'随从与其他所有角色相互距离基数为1<li>'+
'主将杀死对方随从后获得一个额外的行动值并摸两张牌,杀死己方随从无惩罚,随从杀死随从无效果'+
'<li>牌堆中随机加入总量1/6的法术牌效果主要与随从有关法术牌根据强度不同可能会消耗额外的行动值'+
'<li>主将可重铸随从牌但回合内总的重铸次数不能超过3随从不能重铸任何牌包括铁索等默认可以重铸的牌'+
'<li>嘲讽:若一方阵营中有嘲讽角色,则同阵营的无嘲讽角色不以能成为杀或决斗的目标'+
'<li>行动顺序为先主将后随从。主将或随从死亡后立即移出游戏主将死亡后替补登场替补登场时摸2+X张牌X为对方存活的随从数无替补时游戏结束'
2015-04-29 03:25:17 +00:00
},
setPopped:function(node,func,width,height){
2015-04-30 03:09:07 +00:00
node._poppedfunc=func;
node._poppedwidth=width;
node._poppedheight=height;
2015-04-30 03:09:07 +00:00
node.addEventListener(lib.config.touchscreen?'touchstart':'mouseenter',ui.click.hoverpopped);
},
2015-04-29 03:25:17 +00:00
placePoppedDialog:function(dialog,e){
if(e.touches&&e.touches[0]){
e=e.touches[0];
}
dialog.style.height=Math.min(ui.window.offsetHeight-20,dialog.content.scrollHeight)+'px';
if(e.clientX<ui.window.offsetWidth/2){
dialog.style.left=(e.clientX+10)+'px';
}
else{
dialog.style.left=(e.clientX-dialog.offsetWidth-10)+'px';
}
var idealtop=e.clientY-dialog.offsetHeight/2;
if(idealtop<10){
idealtop=10;
}
else if(idealtop+dialog.offsetHeight+10>ui.window.offsetHeight){
idealtop=ui.window.offsetHeight-10-dialog.offsetHeight;
}
dialog.style.top=idealtop+'px';
},
2015-10-31 10:14:14 +00:00
isMobileMe:function(player){
2015-10-31 16:18:20 +00:00
return (lib.config.layout=='mobile'||lib.config.layout=='phone')&&lib.config.mode!='chess'&&player.dataset.position==0;
2015-10-31 10:14:14 +00:00
},
isNewLayout:function(){
if(lib.config.layout!='default') return true;
if(lib.config.layoutfixed.contains(lib.config.mode)) return true;
return false;
},
isSingleHandcard:function(){
2015-10-31 16:18:20 +00:00
if(game.singleHandcard||lib.config.layout=='mobile'||lib.config.layout=='phone'){
2015-10-31 10:14:14 +00:00
return true;
}
return false;
},
2015-04-29 03:25:17 +00:00
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;
},
2015-10-31 03:20:59 +00:00
setScroll:function(node){
node.ontouchstart=ui.click.touchStart;
node.ontouchmove = ui.click.touchScroll;
node.style.WebkitOverflowScrolling='touch';
return node;
},
2015-04-29 03:25:17 +00:00
setLongPress:function(node,func){
node.addEventListener('touchstart',ui.click.longpressdown);
node.addEventListener('touchend',ui.click.longpresscancel);
// node.addEventListener('mouseleave',ui.click.longpresscancel);
node._longpresscallback=func;
return node;
},
updateCanvas:function(time){
if(lib.canvasUpdates.length===0){
lib.status.canvas=false;
return false;
}
ui.canvas.width=ui.arena.offsetWidth;
ui.canvas.height=ui.arena.offsetHeight;
var ctx=ui.ctx;
ctx.shadowBlur=5;
ctx.shadowColor='rgba(0,0,0,0.3)';
ctx.strokeStyle='white';
2015-07-10 14:52:50 +00:00
// ctx.lineCap='round';
2015-04-29 03:25:17 +00:00
ctx.lineWidth=3;
ctx.save();
for(var i=0;i<lib.canvasUpdates.length;i++){
ctx.restore();
ctx.save();
var update=lib.canvasUpdates[i];
if(!update.starttime){
update.starttime=time;
}
if(update(time-update.starttime,ctx)===false){
lib.canvasUpdates.splice(i--,1);
}
}
},
run:function(time){
lib.status.time=time;
for(var i=0;i<lib.updates.length;i++){
if(!lib.updates[i].hasOwnProperty('_time')){
lib.updates[i]._time=time;
}
if(lib.updates[i](time-lib.updates[i]._time-lib.status.delayed)===false){
lib.updates.splice(i--,1);
}
}
if(lib.updates.length){
lib.status.frameId=requestAnimationFrame(lib.run);
}
else{
lib.status.time=0;
lib.status.delayed=0;
}
},
2015-11-04 01:59:00 +00:00
getUTC:function(date){
return date.getTime();
},
2015-11-06 10:05:08 +00:00
saveVideo:function(){
if(_status.videoToSave){
game.export(lib.init.encode(JSON.stringify(_status.videoToSave)),
'无名杀 - 录像 - '+_status.videoToSave.name[0]+' - '+_status.videoToSave.name[1]);
}
},
2015-04-29 03:25:17 +00:00
init:{
init:function(){
lib.config={};
var config2;
2015-05-11 11:57:44 +00:00
var config=window.config;
2015-04-29 03:25:17 +00:00
for(var i in config){
lib.config[i]=lib.init.eval(config[i]);
}
try{
config2=JSON.parse(localStorage.getItem(lib.configprefix+'config'));
if(!config2||typeof config2!='object') throw 'err'
}
catch(err){
config2={};
localStorage.setItem(lib.configprefix+'config',JSON.stringify({}));
}
if(config2.mode) lib.config.mode=config2.mode;
if(lib.config.mode_config[lib.config.mode]==undefined) lib.config.mode_config[lib.config.mode]={};
for(var i in lib.config.mode_config.global){
if(lib.config.mode_config[lib.config.mode][i]==undefined){
lib.config.mode_config[lib.config.mode][i]=lib.config.mode_config.global[i];
}
}
if(lib.config.characters){
lib.config.defaultcharacters=lib.config.characters.slice(0);
}
if(lib.config.cards){
lib.config.defaultcards=lib.config.cards.slice(0);
}
for(var i in config2){
2015-10-29 17:36:14 +00:00
if(i.indexOf('_mode_config')!=-1){
var thismode=i.substr(i.indexOf('_mode_config')+13);
if(!lib.config.mode_config[thismode]){
lib.config.mode_config[thismode]={};
}
lib.config.mode_config[thismode][i.substr(0,i.indexOf('_mode_config'))]=config2[i];
2015-04-29 03:25:17 +00:00
}
2015-04-29 05:58:19 +00:00
else{
2015-04-29 08:41:00 +00:00
lib.config[i]=config2[i];
2015-04-29 05:58:19 +00:00
}
2015-04-29 08:41:00 +00:00
2015-04-29 03:25:17 +00:00
}
for(var i in lib.config.translate){
lib.translate[i]=lib.config.translate[i];
}
2015-06-13 07:57:52 +00:00
2015-06-13 06:53:40 +00:00
lib.config.all.characters=[];
lib.config.all.cards=[];
lib.config.all.plays=[];
for(i in character.pack){
lib.config.all.characters.push(i);
lib.translate[i+'_character_config']=character.pack[i];
}
for(i in card.pack){
lib.config.all.cards.push(i);
lib.translate[i+'_card_config']=card.pack[i];
}
for(i in play.pack){
lib.config.all.plays.push(i);
lib.translate[i+'_play_config']=play.pack[i];
}
delete character.pack;
delete card.pack;
delete play.pack;
2015-04-29 03:25:17 +00:00
lib.init.js('mode',lib.config.mode);
lib.init.js('card',lib.config.all.cards);
lib.init.js('character',lib.config.all.characters);
lib.init.js('play',lib.config.plays);
2015-10-29 17:36:14 +00:00
lib.init.js('character','rank');
2015-04-29 03:25:17 +00:00
ui.css={};
2015-10-29 17:36:14 +00:00
lib.init.css('layout/default','menu');
2015-10-31 10:14:14 +00:00
var layout=lib.config.layout;
2015-05-11 11:57:44 +00:00
if(lib.config.layoutfixed.indexOf(lib.config.mode)!==-1){
2015-10-31 10:14:14 +00:00
if(layout=='default'){
layout='newlayout';
}
2015-04-29 03:25:17 +00:00
}
2015-10-31 10:14:14 +00:00
ui.css.layout=lib.init.css('layout/'+layout,'layout');
2015-04-29 03:25:17 +00:00
if(lib.config.fold_card) ui.css.fold=lib.init.css('layout/default','fold');
if(lib.config.threed_card) ui.css.threed=lib.init.css('layout/default','fold2');
if(lib.config.blur_ui) ui.css.blur_ui=lib.init.css('layout/default','blur');
ui.css.theme=lib.init.css('theme/'+lib.config.theme,'style');
2015-11-06 10:05:08 +00:00
ui.css.card_style=lib.init.css('theme/cardstyle',lib.config.card_style);
2015-10-30 09:13:19 +00:00
lib.config.duration=500;
2015-11-04 01:59:00 +00:00
2015-11-06 10:05:08 +00:00
var ua=navigator.userAgent.toLowerCase();
if(ua.indexOf('iphone')!=-1||ua.indexOf('ipad')!=-1||ua.indexOf('android')!=-1){
if(!lib.config.totouched&&!lib.config.touchscreen){
var totouch=window.confirm('您似乎在使用触屏设备,是否切换到触屏模式?');
game.saveConfig('totouched',true);
if(totouch){
game.saveConfig('touchscreen',true);
game.reload();
}
}
}
else if(ua.indexOf('macintosh')!=-1&&!lib.config.toscrolled){
game.saveConfig('toscrolled',true);
game.saveConfig('mousewheel',false);
}
2015-11-04 01:59:00 +00:00
if(window.indexedDB){
var request = window.indexedDB.open(lib.configprefix+'data', 1);
request.onupgradeneeded=function(e){
var db=e.target.result;
if(db.objectStoreNames.contains('video')){
db.deleteObjectStore('video');
}
db.createObjectStore('video',{keyPath:'time'});
};
request.onsuccess=function(e){
var db=e.target.result;
lib.db=db;
for(var i=0;i<lib._onDB.length;i++){
lib._onDB[i]();
}
}
}
2015-04-29 03:25:17 +00:00
},
css:function(path,file,before){
var style = document.createElement("link");
style.rel = "stylesheet";
style.href = path+'/'+file+".css";
if(before){
document.head.insertBefore(style,before);
}
else{
document.head.appendChild(style);
}
return style;
},
js:function(path,file){
if(typeof file=='object'){
for(var i=0;i<file.length;i++){
lib.init.js(path,file[i]);
}
}
else{
var script=document.createElement('script');
script.src = path+'/'+file+".js";
document.head.appendChild(script);
2015-10-20 17:44:00 +00:00
return script;
2015-04-29 03:25:17 +00:00
}
},
parse:function(func){
var k,func2;
var str='(';
str+=func.toString();
if(str.indexOf('step 0')==-1){
str=str.replace(/\{/,'{{if(event.step==1) {event.finish();return;}');
}
else{
for(k=1;k<99;k++){
if(str.indexOf('step '+k)==-1) break;
str=str.replace(new RegExp("'step "+k+"'",'g'),"break;case "+k+":");
str=str.replace(new RegExp('"step '+k+'"','g'),"break;case "+k+":");
}
str=str.replace(/'step 0'|"step 0"/,'if(event.step=='+k+') {event.finish();return;}switch(step){case 0:');
}
str+='})';
return str;
},
eval:function(func){
if(typeof func=='function'){
return eval('('+func.toString()+')');
}
else if(typeof func=='object'){
for(var i in func){
if(func.hasOwnProperty(i)){
func[i]=lib.init.eval(func[i]);
}
}
}
return func;
},
encode:function(strUni){
var strUtf = strUni.replace(
/[\u0080-\u07ff]/g,function(c){
var cc = c.charCodeAt(0);
return String.fromCharCode(0xc0 | cc>>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;
}
},
translate:{
'default':"默认",
2015-08-15 09:10:06 +00:00
zhenfa:'阵法',
2015-04-29 03:25:17 +00:00
heart:"♥︎",
diamond:"♦︎",
spade:"♠︎",
club:"♣︎",
2015-06-27 16:21:25 +00:00
ghujia:'护甲',
ghujia_bg:'甲',
2015-04-29 03:25:17 +00:00
heart2:"红桃",
diamond2:"方片",
spade2:"黑桃",
club2:"梅花",
red:'红色',
black:'黑色',
ok:"确定",
cancel:"取消",
restart:"重新开始",
setting:"设置",
start:"开始",
random:"随机",
_phasebegin:'回合开始',
_out:'无效',
agree:'同意',
refuse:'拒绝',
fire:"火",
thunder:"雷",
poison:"毒",
wei:'魏',
shu:'蜀',
wu:'吴',
qun:'群',
male:'男',
female:'女',
2015-05-13 10:26:54 +00:00
mad:'混乱',
mad_bg:'疯',
2015-04-29 03:25:17 +00:00
draw_card:'摸牌',
discard_card:'弃牌',
reset_character:'重置武将牌',
recover_hp:'回复体力',
lose_hp:'流失体力',
get_damage:'受伤害',
weiColor:"#b0d0e2",
shuColor:"#ffddb9",
wuColor:"#b2d9a9",
qunColor:"#f6f6f6",
basic:'基本',
equip:'装备',
trick:'锦囊',
delay:'延迟锦囊',
character:'角色',
revive:'复活',
equip1:'武器',
equip2:'防具',
equip3:'防御马',
equip4:'攻击马',
equip5:'宝物',
zero:'零',
one:'一',
two:'二',
three:'三',
four:'四',
five:'五',
six:'六',
seven:'七',
eight:'八',
nine:'九',
ten:'十',
},
element:{
playerproto:{
phase:function(){
"step 0"
player.phaseJudge();
"step 1"
player.phaseDraw();
2015-10-30 09:13:19 +00:00
if(player==game.me){
game.delay();
}
else{
game.delayx();
}
2015-04-29 03:25:17 +00:00
"step 2"
player.phaseUse();
"step 3"
player.phaseDiscard()
2015-11-05 02:34:35 +00:00
game.delayx();
2015-04-29 03:25:17 +00:00
},
phaseJudge:function(){
"step 0"
if(player.node.judges.childElementCount){
event.card=player.node.judges.firstChild;
player.lose(event.card);
2015-05-08 08:07:38 +00:00
player.$phaseJudge(event.card);
2015-04-29 03:25:17 +00:00
event.cancelled=false;
event.trigger('phaseJudge');
}
else event.finish();
"step 1"
if(!event.cancelled) player.judge(event.card);
"step 2"
var name=event.card.viewAs||event.card.name;
if(event.cancelled&&!event.direct){
if(lib.card[name].cancel){
var next=game.createEvent(name+'Cancelled');
next.content=lib.card[name].cancel;
next.card=event.card;
next.player=player;
}
}
else{
var next=game.createEvent(name);
next.content=lib.card[name].effect;
next._result=result;
next.card=event.card;
next.player=player;
}
ui.clear();
event.goto(0);
},
phaseDraw:function(){
player.draw(event.num);
},
phaseUse:function(){
"step 0";
player.chooseToUse();
"step 1"
if(result.bool){
event.goto(0);
}
},
phaseDiscard:function(){
"step 0"
event.num=player.num('h')-game.checkMod(player,player.hp,'maxHandcard',player.get('s'));
if(event.num<=0) event.finish();
event.trigger('phaseDiscard');
"step 1"
player.chooseToDiscard(num,true);
"step 2"
event.cards=result.cards;
},
chooseToUse:function(){
"step 0"
var ok=game.check();
if(event.isMine()){
if(!ok||!lib.config.auto_confirm){
game.pause();
}
if(typeof event.prompt=='string'){
if(!ok) event.dialog=ui.create.dialog(event.prompt);
}
else if(event.prompt=='function'){
if(!ok) event.dialog=ui.create.dialog(event.prompt(event));
}
else if(event.prompt==undefined){
var str;
if(typeof event.filterCard=='object'){
str='请使用'+get.cnNumber(event.selectCard[0])+'张'
if(filter.name){
str+=get.translation(filter.name);
}
else{
str+='牌';
}
}
else{
str='请选择要使用的牌';
}
if(!ok){
if(event.openskilldialog){
event.skillDialog=ui.create.dialog(event.openskilldialog);
delete event.openskilldialog;
event.dialog=str;
}
else if(typeof event.skillDialog!='string'){
event.dialog=ui.create.dialog(str);
}
else{
event.dialog=str;
}
}
}
}
else{
if(ok){
ui.click.ok();
}
else if(ai.basic.chooseCard(event.ai1)){
if(ai.basic.chooseTarget(event.ai2)){
ui.click.ok();
_status.event.aiexclude.length=0;
}
else{
if(event.skill){
var skill=event.skill;
ui.click.cancel();
event.aiexclude.add(skill);
}
else{
get.card().aiexclude();
game.uncheck();
}
event.redo();
game.resume();
}
}
else if(event.skill){
var skill=event.skill;
ui.click.cancel();
event.aiexclude.add(skill);
event.redo();
game.resume();
}
else{
ui.click.cancel();
}
}
"step 1"
if(event.skillDialog&&get.objtype(event.skillDialog)=='div'){
event.skillDialog.close();
}
if(event.result.bool){
if(event.result.card||!event.result.skill){
player.useCard(event.result.card,event.result.cards,event.result.targets,event.result.skill);
}
else if(event.result.skill){
player.useSkill(event.result.skill,event.result.cards,event.result.targets);
}
}
if(event.dialog&&typeof event.dialog=='object') event.dialog.close();
},
chooseToRespond:function(){
"step 0"
if(event.responded){
delete event.dialog;
return;
}
if(event.autochoose&&event.autochoose()){
event.result={bool:false};
}
else{
game.check();
if(event.isMine()){
game.pause();
if(event.dialog) event.dialog=ui.create.dialog(event.dialog);
}
else{
if(ai.basic.chooseCard(event.ai)||forced){
ui.click.ok();
}
else if(event.skill){
var skill=event.skill;
ui.click.cancel();
event.aiexclude.add(skill);
event.redo();
game.resume();
}
else{
ui.click.cancel();
}
}
}
"step 1"
if(event.result.bool){
player.respond(event.result.cards,event.result.card,event.animate,event.result.skill,event.source);
}
if(event.dialog&&event.dialog.close) event.dialog.close();
},
chooseToDiscard:function(){
"step 0"
if(event.autochoose()){
event.result={
bool:true,
cards:player.get(event.position||'h')
}
}
else{
var range=get.select(event.selectCard);
game.check();
if(event.isMine()){
game.pause();
if(range[1]>1){
event.promptdiscard=ui.create.control('提示',function(){
ai.basic.chooseCard(event.ai);
if(_status.event.custom.add.card){
_status.event.custom.add.card();
}
});
}
if(event.prompt!=false){
var str;
if(typeof(event.prompt)=='string') str=event.prompt;
else{
str='请弃置';
if(range[0]==range[1]) str+=get.cnNumber(range[0]);
else if(range[1]==Infinity) str+='至少'+get.cnNumber(range[0]);
else str+=get.cnNumber(range[0])+'至'+get.cnNumber(range[1]);
str+='张';
if(event.position=='h'||event.position==undefined) str+='手';
if(event.position=='e') str+='装备';
str+='牌';
}
event.dialog=ui.create.dialog(str);
event.dialog.add('0/'+event.selectCard[1]);
event.custom.add.card=function(){
_status.event.dialog.content.childNodes[1].innerHTML=
ui.selected.cards.length+'/'+_status.event.selectCard[1];
}
}
else if(get.itemtype(event.dialog)=='dialog'){
2015-05-08 08:07:38 +00:00
event.dialog.style.display='';
2015-04-29 03:25:17 +00:00
event.dialog.open();
}
}
else{
if(ai.basic.chooseCard(event.ai)||forced){
ui.click.ok();
}
else if(event.skill){
var skill=event.skill;
ui.click.cancel();
event.aiexclude.add(skill);
event.redo();
game.resume();
}
else{
ui.click.cancel();
}
}
}
"step 1"
if(event.promptdiscard){
event.promptdiscard.close();
}
player.discard(event.result.cards);
if(event.dialog) event.dialog.close();
},
chooseToCompare:function(){
"step 0"
if(player.num('h')==0||target.num('h')==0){
event.result={cancelled:true,bool:false}
event.finish();
return;
}
game.log(get.translation(player)+'对'+get.translation(target)+'发起拼点');
player.chooseCard('请选择拼点牌',true).ai=event.ai;
"step 1"
event.card1=result.cards[0];
target.chooseCard('请选择拼点牌',true).ai=event.ai;
"step 2"
event.card2=result.cards[0];
2015-09-03 03:49:14 +00:00
if(event.card2.number>=10||event.card2.number<=4){
if(target.num('h')>2){
event.addToAI=true;
}
}
2015-04-29 03:25:17 +00:00
player.lose(event.card1);
target.lose(event.card2);
"step 3"
2015-11-06 10:05:08 +00:00
ui.arena.classList.add('thrownhighlight');
game.addVideo('thrownhighlight1');
2015-04-29 03:25:17 +00:00
player.$compare(event.card1,target,event.card2);
// player.$throw(event.card1);
// target.$throw(event.card2);
game.log(get.translation(player)+'的拼点牌为'+get.translation(event.card1));
game.log(get.translation(target)+'的拼点牌为'+get.translation(event.card2));
event.result={
player:event.card1,
target:event.card2,
}
if(get.number(event.card1)>get.number(event.card2)){
event.result.bool=true;
setTimeout(function(){
event.dialog=ui.create.dialog(get.translation(player.name)+'拼点成功');
2015-05-09 02:56:55 +00:00
event.dialog.classList.add('center');
2015-04-29 03:25:17 +00:00
player.popup('胜');
target.popup('负');
game.resume();
},1500);
}
else{
event.result.bool=false;
if(get.number(event.card1)>get.number(event.card2)){
event.result.tie=true;
setTimeout(function(){
event.dialog=ui.create.dialog(get.translation(player.name)+'拼点失败');
2015-05-09 02:56:55 +00:00
event.dialog.classList.add('center');
2015-04-29 03:25:17 +00:00
player.popup('平');
target.popup('平');
game.resume();
},1500);
}
else{
setTimeout(function(){
event.dialog=ui.create.dialog(get.translation(player.name)+'拼点失败');
2015-05-09 02:56:55 +00:00
event.dialog.classList.add('center');
2015-04-29 03:25:17 +00:00
player.popup('负');
target.popup('胜');
game.resume();
},1500);
}
}
game.pause();
"step 4"
game.delay(2);
"step 5"
2015-09-03 03:49:14 +00:00
if(typeof event.target.ai.shown=='number'&&event.target.ai.shown<=0.85&&event.addToAI){
2015-04-29 03:25:17 +00:00
event.target.ai.shown+=0.1;
}
2015-11-06 10:05:08 +00:00
ui.arena.classList.remove('thrownhighlight');
game.addVideo('thrownhighlight2');
2015-04-29 03:25:17 +00:00
if(event.clear!==false) ui.clear();
event.dialog.close();
},
chooseButton:function(){
"step 0"
if(event.dialog==undefined) event.dialog=ui.dialog;
if(event.isMine()){
2015-05-08 08:07:38 +00:00
event.dialog.style.display='';
2015-04-29 03:25:17 +00:00
event.dialog.open();
}
game.check();
if(event.isMine()){
game.pause();
}
else{
if(ai.basic.chooseButton(event.ai)||forced) ui.click.ok();
else ui.click.cancel();
}
"step 1"
if(event.closeDialog){
event.dialog.close();
}
},
chooseCard:function(){
"step 0"
game.check();
if(event.isMine()){
game.pause();
if(event.prompt!=false){
var str;
if(typeof event.prompt=='string') str=event.prompt;
else{
str='请选择'
var range=get.select(event.selectCard);
if(range[0]==range[1]) str+=get.cnNumber(range[0]);
else if(range[1]==Infinity) str+='至少'+get.cnNumber(range[0]);
else str+=get.cnNumber(range[0])+'至'+get.cnNumber(range[1]);
str+='张';
if(event.position=='h'||event.position==undefined) str+='手';
if(event.position=='e') str+='装备';
str+='牌';
}
event.dialog=ui.create.dialog(str);
event.dialog.add('0/'+event.selectCard[1]);
event.custom.add.card=function(){
_status.event.dialog.content.childNodes[1].innerHTML=
ui.selected.cards.length+'/'+_status.event.selectCard[1];
}
}
}
else{
if(ai.basic.chooseCard(event.ai)||forced){
ui.click.ok();
}
else if(event.skill){
var skill=event.skill;
ui.click.cancel();
event.aiexclude.add(skill);
event.redo();
game.resume();
}
else{
ui.click.cancel();
}
}
"step 1"
if(event.dialog) event.dialog.close();
},
chooseTarget:function(){
"step 0"
game.check();
if(event.isMine()){
game.pause();
if(event.prompt!=false){
var str;
if(typeof event.prompt=='string') str=event.prompt;
else{
str='请选择'
var range=get.select(event.selectTarget);
if(range[0]==range[1]) str+=get.cnNumber(range[0]);
else if(range[1]==Infinity) str+='至少'+get.cnNumber(range[0]);
else str+=get.cnNumber(range[0])+'至'+get.cnNumber(range[1]);
str+='个目标';
}
event.dialog=ui.create.dialog(str);
event.dialog.add('0/'+event.selectTarget[1]);
event.custom.add.target=function(){
_status.event.dialog.content.childNodes[1].innerHTML=
ui.selected.targets.length+'/'+_status.event.selectTarget[1];
}
}
else if(get.itemtype(event.dialog)=='dialog'){
event.dialog.open();
}
}
else{
if(ai.basic.chooseTarget(event.ai)||forced){
ui.click.ok();
}
else{
ui.click.cancel();
}
}
"step 1"
if(event.result.bool){
for(var i=0;i<event.result.targets.length;i++){
event.result.targets[i].animate('target');
}
}
if(event.dialog) event.dialog.close();
},
chooseCardTarget:function(){
"step 0"
game.check();
if(event.isMine()){
game.pause();
if(event.prompt!=false){
event.dialog=ui.create.dialog(event.prompt||'请选择卡牌和目标');
}
}
else{
if(ai.basic.chooseCard(event.ai1)){
if(ai.basic.chooseTarget(event.ai2)){
ui.click.ok();
_status.event.aiexclude.length=0;
}
else{
get.card().aiexclude();
game.uncheck();
event.redo();
game.resume();
}
}
else{
ui.click.cancel();
}
}
"step 1"
if(event.result.bool){
for(var i=0;i<event.result.targets.length;i++){
event.result.targets[i].animate('target');
}
}
if(event.dialog) event.dialog.close();
},
chooseControl:function(){
"step 0"
if(event.controls.length==0){
event.finish();
return;
}
if(event.isMine()){
event.controlbar=ui.create.control(event.controls);
if(event.dialog){
event.dialog.open();
}
else if(event.prompt){
event.dialog=ui.create.dialog(event.prompt);
}
game.pause();
_status.imchoosing=true;
}
else{
event.result={};
if(event.ai){
var result=event.ai(event.parent,player);
if(typeof result=='number') event.result.control=event.controls[result];
else event.result.control=result;
}
else event.result.control=event.controls[event.choice];
}
"step 1"
_status.imchoosing=false;
if(event.dialog) event.dialog.close();
if(event.controlbar) event.controlbar.close();
},
chooseBool:function(){
"step 0"
if(event.isMine()){
ui.create.confirm('oc');
2015-06-19 15:31:36 +00:00
if(event.dialog){
event.dialog.open();
}
else if(event.prompt){
2015-04-29 03:25:17 +00:00
event.dialog=ui.create.dialog(event.prompt);
}
_status.imchoosing=true;
game.pause();
}
else{
if(event.ai){
event.choice=event.ai(event.parent,player);
}
event.result={bool:event.choice};
}
"step 1"
_status.imchoosing=false;
if(event.dialog) event.dialog.close();
},
choosePlayerCard:function(){
"step 0"
if(!event.dialog) event.dialog=ui.create.dialog('hidden');
else if(!event.isMine){
event.dialog.style.display='none';
}
if(event.prompt){
event.dialog.add(event.prompt);
}
else{
event.dialog.add('选择'+get.translation(target)+'的一张牌');
}
for(var i=0;i<event.position.length;i++){
if(event.position[i]=='h'&&target.num('h')){
event.dialog.add('手牌');
var hs=target.get('h');
2015-05-03 15:17:15 +00:00
hs.randomSort();
2015-04-29 03:25:17 +00:00
if(event.visible){
event.dialog.add(hs);
}
else{
event.dialog.add([hs,'blank']);
}
}
else if(event.position[i]=='e'&&target.num('e')){
event.dialog.add('装备牌');
event.dialog.add(target.get('e'));
}
else if(event.position[i]=='j'&&target.num('j')){
event.dialog.add('判定牌');
event.dialog.add(target.get('j'));
}
}
if(event.dialog.buttons.length==0){
event.finish();
return;
}
if(event.isMine()){
event.dialog.open();
}
game.check();
if(event.isMine()){
game.pause();
}
else{
if(ai.basic.chooseButton(event.ai)||forced) ui.click.ok();
else ui.click.cancel();
}
"step 1"
event.dialog.close();
},
discardPlayerCard:function(){
"step 0"
if(!event.dialog) event.dialog=ui.create.dialog('hidden');
else if(!event.isMine){
event.dialog.style.display='none';
}
if(event.prompt==undefined){
var str='弃置'+get.translation(target);
var range=get.select(event.selectButton);
if(range[0]==range[1]) str+=get.cnNumber(range[0]);
else if(range[1]==Infinity) str+='至少'+get.cnNumber(range[0]);
else str+=get.cnNumber(range[0])+'至'+get.cnNumber(range[1]);
str+='张';
if(event.position=='h'||event.position==undefined) str+='手';
if(event.position=='e') str+='装备';
str+='牌';
event.prompt=str;
}
if(event.prompt){
event.dialog.add(event.prompt);
}
for(var i=0;i<event.position.length;i++){
if(event.position[i]=='h'&&target.num('h')){
event.dialog.add('手牌');
var hs=target.get('h');
2015-05-03 15:17:15 +00:00
hs.randomSort();
2015-04-29 03:25:17 +00:00
if(event.visible){
event.dialog.add(hs);
}
else{
event.dialog.add([hs,'blank']);
}
}
else if(event.position[i]=='e'&&target.num('e')){
event.dialog.add('装备牌');
event.dialog.add(target.get('e'));
}
else if(event.position[i]=='j'&&target.num('j')){
event.dialog.add('判定牌');
event.dialog.add(target.get('j'));
}
}
if(event.dialog.buttons.length==0){
event.finish();
return;
}
if(event.isMine()){
event.dialog.open();
}
game.check();
if(event.isMine()){
game.pause();
}
else{
if(ai.basic.chooseButton(event.ai)||forced) ui.click.ok();
else ui.click.cancel();
}
"step 1"
event.dialog.close();
"step 2"
if(event.result.bool&&event.result.buttons){
var cards=[];
for(var i=0;i<event.result.buttons.length;i++){
cards.push(event.result.buttons[i].link);
}
target.discard(cards);
}
},
gainPlayerCard:function(){
"step 0"
if(!event.dialog) event.dialog=ui.create.dialog('hidden');
else if(!event.isMine){
event.dialog.style.display='none';
}
if(event.prompt==undefined){
var str='获得'+get.translation(target);
var range=get.select(event.selectButton);
if(range[0]==range[1]) str+=get.cnNumber(range[0]);
else if(range[1]==Infinity) str+='至少'+get.cnNumber(range[0]);
else str+=get.cnNumber(range[0])+'至'+get.cnNumber(range[1]);
str+='张';
if(event.position=='h'||event.position==undefined) str+='手';
if(event.position=='e') str+='装备';
str+='牌';
event.prompt=str;
}
if(event.prompt){
event.dialog.add(event.prompt);
}
for(var i=0;i<event.position.length;i++){
if(event.position[i]=='h'&&target.num('h')){
event.dialog.add('手牌');
var hs=target.get('h');
2015-05-03 15:17:15 +00:00
hs.randomSort();
2015-04-29 03:25:17 +00:00
if(event.visible){
event.dialog.add(hs);
}
else{
event.dialog.add([hs,'blank']);
}
}
else if(event.position[i]=='e'&&target.num('e')){
event.dialog.add('装备牌');
event.dialog.add(target.get('e'));
}
else if(event.position[i]=='j'&&target.num('j')){
event.dialog.add('判定牌');
event.dialog.add(target.get('j'));
}
}
if(event.dialog.buttons.length==0){
event.dialog.close();
event.finish();
return;
}
if(event.isMine()){
event.dialog.open();
}
game.check();
if(event.isMine()){
game.pause();
}
else{
if(ai.basic.chooseButton(event.ai)||forced) ui.click.ok();
else ui.click.cancel();
}
"step 1"
event.dialog.close();
"step 2"
var cards=[];
for(var i=0;i<event.result.buttons.length;i++){
cards.push(event.result.buttons[i].link);
}
2015-05-01 09:34:01 +00:00
target.lose(cards);
event.cards=cards;
2015-04-29 03:25:17 +00:00
var hs=[],oths=[];
for(var i=0;i<cards.length;i++){
if(get.position(cards[i])=='h'){
hs.push(cards[i]);
}
else{
oths.push(cards[i]);
}
}
if(hs.length){
target.$give(hs.length,player);
}
2015-05-01 09:34:01 +00:00
if(oths.length){
2015-04-29 03:25:17 +00:00
target.$give(oths,player);
}
2015-05-01 09:34:01 +00:00
"step 3"
if(player==game.me){
game.delay(2);
}
else{
2015-11-05 02:34:35 +00:00
game.delayx();
2015-05-01 09:34:01 +00:00
}
player.gain(event.cards);
2015-04-29 03:25:17 +00:00
},
showHandcards:function(){
"step 0"
if(player.num('h')==0){
event.finish();
return;
}
var cards=player.get('h');
2015-11-04 01:59:00 +00:00
var str=get.translation(player.name)+'的手牌';
event.dialog=ui.create.dialog(str,cards);
2015-04-29 03:25:17 +00:00
game.log(get.translation(player)+'展示了'+get.translation(cards));
2015-11-04 01:59:00 +00:00
game.addVideo('showCards',player,[str,get.cardsInfo(cards)]);
2015-11-05 02:34:35 +00:00
game.delayx(2);
2015-04-29 03:25:17 +00:00
"step 1"
event.dialog.close();
},
showCards:function(){
"step 0"
if(get.itemtype(cards)!='cards'){
event.finish();
return;
}
2015-06-27 16:21:25 +00:00
if(!event.str){
event.str=get.translation(player.name)+'展示的牌';
}
event.dialog=ui.create.dialog(event.str,cards);
2015-04-29 03:25:17 +00:00
var str=get.translation(player)+'展示了'+get.translation(cards[0]);
for(var i=1;i<cards.length;i++){
str+='、'+get.translation(cards[i]);
}
game.log(str);
2015-11-05 02:34:35 +00:00
game.delayx(2);
2015-11-04 01:59:00 +00:00
game.addVideo('showCards',player,[event.str,get.cardsInfo(cards)]);
2015-04-29 03:25:17 +00:00
"step 1"
event.dialog.close();
},
viewHandcards:function(){
"step 0"
if(player==game.me&&target){
event.dialog=ui.create.dialog(get.translation(target.name)+'的手牌',target.get('h'));
if(event.isMine()){
game.pause();
_status.imchoosing=true;
ui.create.confirm('o');
}
else{
event.finish();
setTimeout(function(){
event.dialog.close();
},2*lib.config.duration);
2015-11-05 02:34:35 +00:00
game.delayx(2);
2015-04-29 03:25:17 +00:00
}
}
else{
event.finish();
}
"step 1"
_status.imchoosing=false;
event.dialog.close();
},
useCard:function(){
"step 0"
2015-06-16 13:24:35 +00:00
if(!card){
console.log('err: no card',get.translation(event.player));
event.finish();
return;
}
2015-04-29 03:25:17 +00:00
player.lose(cards);
2015-06-13 07:57:52 +00:00
var cardaudio=true;
2015-04-29 03:25:17 +00:00
if(event.skill){
2015-06-13 07:57:52 +00:00
if(lib.skill[event.skill].audio){
cardaudio=false;
}
2015-05-04 03:17:03 +00:00
player.logSkill(event.skill);
2015-05-03 15:17:15 +00:00
player.popup(event.card.name);
2015-04-29 03:25:17 +00:00
}
2015-06-13 07:57:52 +00:00
if(cardaudio&&lib.config.background_audio){
2015-04-29 14:56:33 +00:00
var sex=player.sex=='female'?'female':'male';
2015-05-08 08:07:38 +00:00
if(lib.card[card.name].audio||lib.config.background_ogg){
if(card.name=='sha'&&(card.nature=='fire'||card.nature=='thunder')){
game.playAudio('card',sex,card.name+'_'+card.nature);
}
else{
game.playAudio('card',sex,card.name);
}
2015-04-29 14:56:33 +00:00
}
2015-05-14 09:23:45 +00:00
else if(get.type(card)!='equip'){
2015-05-08 08:07:38 +00:00
game.playAudio('card/default');
2015-04-29 14:56:33 +00:00
}
}
2015-04-29 03:25:17 +00:00
if(event.animate!=false){
if(card.name=='wuxie'&&event.parent.source){
2015-05-04 03:17:03 +00:00
player.line(event.parent.source2||event.parent.source,'green');
2015-04-29 03:25:17 +00:00
}
else{
var config={};
if(card.nature=='fire'||
(card.classList&&card.classList.contains('fire'))){
config.color='fire';
}
else if(card.nature=='thunder'||
(card.classList&&card.classList.contains('thunder'))){
config.color='thunder';
}
if(get.info(card).multitarget&&targets.length>1&&!get.info(card).multiline){
player.line2(targets,config);
}
else{
player.line(targets,config);
}
}
player.$throw(cards);
}
event.trigger('useCard');
2015-11-06 10:05:08 +00:00
// if(event.card.name=='sha'&&lib.config.animation){
// player.$sha(event.card.nature);
// }
2015-04-29 03:25:17 +00:00
if(get.type(card)!='equip'){
var str=get.translation(player);
if(targets.length){
str+='对'+(targets[0]==player?'自己':get.translation(targets[0]));
for(var i=1;i<targets.length;i++){
str+='、'+(targets[i]==player?'自己':get.translation(targets[i]));
}
}
str+='使用了'+get.translation(card);
if(cards.length&&(cards.length>1||cards[0]!=card)){
str+=''+get.translation(cards)+'';
}
game.log(str);
}
if(event.addCount!=false){
if(player.stat[player.stat.length-1].card[card.name]==undefined){
player.stat[player.stat.length-1].card[card.name]=1;
}
else{
player.stat[player.stat.length-1].card[card.name]++;
}
if(event.skill){
if(player.stat[player.stat.length-1].skill[event.skill]==undefined){
player.stat[player.stat.length-1].skill[event.skill]=1;
}
else{
player.stat[player.stat.length-1].skill[event.skill]++;
}
}
}
"step 1"
if(get.info(card).contentBefore){
var next=game.createEvent(card.name+'ContentBefore');
next.content=get.info(card).contentBefore;
next.targets=targets;
next.card=card;
next.cards=cards;
next.player=player;
}
"step 2"
if(targets[num]&&targets[num].isDead()) return;
if(targets[num]&&targets[num].isOut()) return;
if(targets[num]&&targets[num].removed) return;
var info=get.info(card);
if(targets.length==0&&!info.notarget) return;
var next=game.createEvent(card.name);
next.content=info.content;
next.targets=targets;
next.card=card;
next.cards=cards;
next.player=player;
next.num=num;
next.type='card';
next.skill=event.skill;
next.multitarget=info.multitarget;
2015-11-04 01:59:00 +00:00
next.preResult=event.preResult;
2015-04-29 03:25:17 +00:00
if(num==0&&next.targets.length>1){
if(!info.multitarget){
lib.tempSortSeat=player;
targets.sort(lib.sort.seat);
delete lib.tempSortSeat;
for(var i=0;i<targets.length;i++){
targets[i].animate('target');
}
}
else{
for(var i=0;i<targets.length;i++){
targets[i].animate('target');
}
}
}
next.target=targets[num];
if(next.target&&!info.multitarget){
if(num==0&&targets.length>1){
// var ttt=next.target;
// setTimeout(function(){ttt.animate('target');},0.5*lib.config.duration);
}
else{
next.target.animate('target');
}
}
if(event.animate!=false||num>0){
2015-10-30 09:13:19 +00:00
if(num==0)game.delayx();
else game.delayx(0.5);
2015-04-29 03:25:17 +00:00
}
"step 3"
if(!get.info(event.card).multitarget&&num<targets.length-1){
event.num++;
event.goto(2);
}
"step 4"
if(get.info(card).contentAfter){
var next=game.createEvent(card.name+'contentAfter');
next.content=get.info(card).contentAfter;
next.targets=targets;
next.card=card;
next.cards=cards;
next.player=player;
2015-11-04 01:59:00 +00:00
next.preResult=event.preResult;
2015-04-29 03:25:17 +00:00
}
"step 5"
if(document.getElementsByClassName('thrown').length){
2015-11-05 02:34:35 +00:00
game.delayx();
2015-04-29 03:25:17 +00:00
}
else{
event.finish();
}
"step 6"
2015-11-09 03:15:16 +00:00
if(event.card.name!='wuxie') ui.clear();
2015-04-29 03:25:17 +00:00
},
useSkill:function(){
"step 0"
var info=get.info(event.skill);
2015-05-12 15:10:35 +00:00
event._skill=event.skill;
2015-06-16 13:52:39 +00:00
if(lib.config.background_speak&&
(!lib.skill.global.contains(event.skill)||lib.skill[event.skill].forceaudio)){
2015-05-14 09:23:45 +00:00
if(typeof info.audio=='number'){
game.playAudio('skill',event.skill+Math.ceil(info.audio*Math.random()));
}
2015-05-14 09:23:45 +00:00
else if(info.audio){
2015-05-08 08:07:38 +00:00
game.playAudio('skill',event.skill);
}
2015-05-14 09:23:45 +00:00
else if(lib.config.background_ogg){
2015-05-16 11:22:27 +00:00
game.playSkillAudio(event.skill);
}
2015-04-29 14:56:33 +00:00
}
2015-04-29 03:25:17 +00:00
if(player.checkShow){
player.checkShow(event.skill);
}
if(info.discard!=false&&info.lose!=false&&!info.viewAs){
player.discard(cards).delay=false;
}
else{
if(info.lose!=false){
player.lose(cards,ui.special);
}
if(info.prepare){
info.prepare(cards,player,targets);
}
else if(info.viewAs){
player.$throw(cards);
}
}
if((info.line||info.discard!=false)&&targets.length){
var config={};
if(info.line=='fire'){
config.color='fire';
}
else if(info.line=='thunder'){
config.color='thunder';
}
2015-05-16 11:40:11 +00:00
else if(info.line===undefined){
config.color='green';
}
2015-04-29 03:25:17 +00:00
if(info.multitarget&&!info.multiline&&targets.length>1){
player.line2(targets,config);
}
else{
player.line(targets,config);
}
}
var str=get.translation(player);
if(targets&&targets.length){
str+='对'+(targets[0]==player?'自己':get.translation(targets[0]));
for(var i=1;i<targets.length;i++){
str+='、'+(targets[i]==player?'自己':get.translation(targets[i]));
}
}
str+='发动了'+get.translation(skill);
if(!info.direct){
game.log(str);
player.popup(skill);
}
if(event.addCount!=false){
if(player.stat[player.stat.length-1].skill[skill]==undefined){
player.stat[player.stat.length-1].skill[skill]=1;
}
else{
player.stat[player.stat.length-1].skill[skill]++;
}
}
"step 1"
if(!event.skill){
console.log('error: no skill',get.translation(event.player),event.player.get('s'));
2015-05-12 15:10:35 +00:00
if(event._skill){
event.skill=event._skill;
console.log(event._skill);
}
else{
event.finish();
return;
}
2015-04-29 03:25:17 +00:00
}
var info=get.info(event.skill);
if(targets[num]&&targets[num].isDead()||
targets[num]&&targets[num].isOut()||
targets[num]&&targets[num].removed){
if(!info.multitarget&&num<targets.length-1){
event.num++;
event.redo();
}
return;
}
var next=game.createEvent(event.skill);
next.content=info.content;
next.targets=targets;
next.cards=cards;
next.player=player;
next.num=num;
next.multitarget=info.multitarget;
if(num==0&&next.targets.length>1){
if(!info.multitarget){
lib.tempSortSeat=player;
targets.sort(lib.sort.seat);
delete lib.tempSortSeat;
}
for(var i=0;i<targets.length;i++){
targets[i].animate('target');
}
}
next.target=targets[num];
if(next.target&&!info.multitarget){
if(num==0&&targets.length>1){
// var ttt=next.target;
// setTimeout(function(){ttt.animate('target');},0.5*lib.config.duration);
}
else{
next.target.animate('target');
}
}
if(num==0){
if(typeof info.delay=='number') game.delay(info.delay);
2015-10-30 09:13:19 +00:00
else if(info.delay!==false&&info.delay!==0) game.delayx();
2015-04-29 03:25:17 +00:00
}
2015-10-30 09:13:19 +00:00
else game.delayx(0.5);
2015-04-29 03:25:17 +00:00
if(!info.multitarget&&num<targets.length-1){
event.num++;
event.redo();
}
"step 2"
if(document.getElementsByClassName('thrown').length){
2015-11-05 02:34:35 +00:00
if(event.skill&&get.info(event.skill).delay!==0) game.delayx();
2015-04-29 03:25:17 +00:00
}
else{
event.finish();
}
"step 3"
ui.clear();
},
draw:function(){
if(lib.config.background_audio){
game.playAudio('effect','draw');
}
if(event.log!=false){
game.log(get.translation(player)+'摸了'+get.cnNumber(num)+'张牌');
}
2015-04-29 03:25:17 +00:00
var cards=get.cards(num);
if(event.animate!=false){
player.gain(cards,'draw');
}
else{
player.gain(cards);
}
event.result=cards;
},
discard:function(){
"step 0"
if(lib.config.background_audio){
game.playAudio('effect','discard');
}
2015-04-29 03:25:17 +00:00
var str=get.translation(player)+'弃置了';
str+=get.translation(cards[0]);
for(var i=1;i<cards.length;i++){
str+='、'+get.translation(cards[i]);
}
game.log(str);
player.lose(cards);
if(event.animate!=false) player.$throw(cards,1000);
event.trigger('discard');
"step 1"
2015-11-05 02:34:35 +00:00
if(event.delay!=false) game.delayx();
2015-04-29 03:25:17 +00:00
},
respond:function(){
2015-06-13 07:57:52 +00:00
var cardaudio=true;
2015-04-29 03:25:17 +00:00
if(event.skill){
2015-06-13 07:57:52 +00:00
if(lib.skill[event.skill].audio){
cardaudio=false;
}
2015-04-30 08:24:57 +00:00
player.logSkill(event.skill);
2015-04-29 03:25:17 +00:00
if(player.checkShow){
player.checkShow(event.skill);
}
}
2015-06-13 07:57:52 +00:00
if(cardaudio&&event.parent.parent.parent.name=='useCard'){
if(lib.config.background_audio){
2015-04-29 14:56:33 +00:00
var sex=player.sex=='female'?'female':'male';
2015-05-08 08:07:38 +00:00
if(lib.card[card.name].audio||lib.config.background_ogg){
game.playAudio('card',sex,card.name);
}
else{
game.playAudio('card/default');
}
2015-04-29 14:56:33 +00:00
}
}
2015-04-29 03:25:17 +00:00
var str=get.translation(player)+'打出了';
str+=get.translation(card);
if(cards.length&&(cards.length>1||cards[0].name!=card.name)){
str+=''+get.translation(cards)+'';
}
game.log(str);
for(var i=0;i<cards.length;i++){
player.lose(cards[i]);
if(event.animate!=false) player.$throw(cards[i]);
2015-11-06 10:05:08 +00:00
if(event.highlight){
cards[i].clone.classList.add('thrownhighlight');
game.addVideo('highlightnode',player,get.cardInfo(cards[i]));
}
2015-04-29 03:25:17 +00:00
var name='';
if(event.skill) name=get.translation(event.skill)+'';
if(event.card) name+=get.translation(event.card.name);
}
event.trigger('respond');
2015-10-30 09:13:19 +00:00
game.delayx(0.5);
2015-04-29 03:25:17 +00:00
},
gain:function(){
"step 0"
if(cards){
event.source=get.owner(cards[0]);
if(event.source){
2015-05-01 09:34:01 +00:00
event.source.lose(cards,ui.special);
2015-04-29 03:25:17 +00:00
}
}
else{
event.finish();
}
"step 1"
2015-11-05 02:34:35 +00:00
if(event.source) game.delayx();
2015-04-29 03:25:17 +00:00
"step 2"
if(player.getStat().gain==undefined){
player.getStat().gain=cards.length;
}
else{
player.getStat().gain+=cards.length;
}
"step 3"
var j,sort,position;
var frag1=document.createDocumentFragment();
var frag2=document.createDocumentFragment();
2015-11-04 01:59:00 +00:00
var hs=player.get('h');
for(var i=0;i<cards.length;i++){
if(hs.contains(cards[i])){
cards.splice(i--,1);
}
}
2015-04-29 03:25:17 +00:00
for(var num=0;num<cards.length;num++){
sort=lib.config.sort_card(cards[num]);
if(lib.config.reverse_sort) sort=-sort;
cards[num].fix();
cards[num].animate('start');
2015-05-13 10:26:54 +00:00
2015-10-31 10:14:14 +00:00
if(lib.isSingleHandcard()||sort>0) frag1.appendChild(cards[num]);
2015-05-13 10:26:54 +00:00
else frag2.appendChild(cards[num]);
2015-04-29 03:25:17 +00:00
}
2015-11-04 01:59:00 +00:00
var addv=function(){
if(player==game.me){
game.addVideo('gain12',player,[get.cardsInfo(frag1.childNodes),get.cardsInfo(frag2.childNodes)]);
}
};
2015-05-13 10:26:54 +00:00
if(event.animate=='draw'){
player.$draw(cards.length);
2015-11-05 02:34:35 +00:00
game.delayx(1,500);
2015-05-13 10:26:54 +00:00
setTimeout(function(){
2015-11-04 01:59:00 +00:00
addv();
2015-04-29 03:25:17 +00:00
player.node.handcards1.insertBefore(frag1,player.node.handcards1.firstChild);
player.node.handcards2.insertBefore(frag2,player.node.handcards2.firstChild);
player.update();
2015-05-13 10:26:54 +00:00
},500);
}
else if(event.animate=='gain'){
player.$gain(cards);
2015-11-05 02:34:35 +00:00
game.delayx(1,700);
2015-05-13 10:26:54 +00:00
setTimeout(function(){
2015-11-04 01:59:00 +00:00
addv();
2015-05-13 10:26:54 +00:00
player.node.handcards1.insertBefore(frag1,player.node.handcards1.firstChild);
player.node.handcards2.insertBefore(frag2,player.node.handcards2.firstChild);
player.update();
},700);
}
else if(event.animate=='gain2'||event.animate=='draw2'){
player.$gain2(cards);
2015-11-05 02:34:35 +00:00
game.delayx(1,500);
2015-05-13 10:26:54 +00:00
setTimeout(function(){
2015-11-04 01:59:00 +00:00
addv();
2015-05-13 10:26:54 +00:00
player.node.handcards1.insertBefore(frag1,player.node.handcards1.firstChild);
player.node.handcards2.insertBefore(frag2,player.node.handcards2.firstChild);
player.update();
},500);
}
else{
2015-11-04 01:59:00 +00:00
addv();
2015-05-13 10:26:54 +00:00
player.node.handcards1.insertBefore(frag1,player.node.handcards1.firstChild);
player.node.handcards2.insertBefore(frag2,player.node.handcards2.firstChild);
player.update();
2015-04-29 03:25:17 +00:00
}
},
lose:function(){
"step 0"
2015-11-04 01:59:00 +00:00
var hs=[],es=[],js=[];
2015-04-29 03:25:17 +00:00
for(var i=0;i<cards.length;i++){
if(cards[i].parentNode){
if(cards[i].parentNode.classList.contains('equips')){
cards[i].original='e';
2015-11-04 01:59:00 +00:00
es.push(cards[i]);
2015-04-29 03:25:17 +00:00
}
else if(cards[i].parentNode.classList.contains('judges')){
cards[i].original='j';
2015-11-04 01:59:00 +00:00
js.push(cards[i]);
2015-04-29 03:25:17 +00:00
}
else if(cards[i].parentNode.id=='handcards1'||cards[i].parentNode.id=='handcards2'){
2015-04-29 03:25:17 +00:00
cards[i].original='h';
2015-11-04 01:59:00 +00:00
hs.push(cards[i]);
2015-04-29 03:25:17 +00:00
}
else{
cards[i].original=null;
}
2015-04-29 03:25:17 +00:00
}
if(event.position){
cards[i].goto(event.position);
}
else{
cards[i].delete();
}
}
2015-11-04 01:59:00 +00:00
game.addVideo('lose',player,[get.cardsInfo(hs),get.cardsInfo(es),get.cardsInfo(js)]);
2015-04-29 03:25:17 +00:00
player.update();
2015-11-04 01:59:00 +00:00
game.addVideo('loseAfter',player);
2015-04-29 03:25:17 +00:00
for(var i=player.node.handcards1.childNodes.length-1;i>0;i--){
if(player.node.handcards1.childNodes[i].classList.contains('removing')==false){
player.node.handcards1.childNodes[i].animate('last');
break;
}
}
for(var i=player.node.handcards2.childNodes.length-1;i>0;i--){
if(player.node.handcards2.childNodes[i].classList.contains('removing')==false){
player.node.handcards2.childNodes[i].animate('last');
break;
}
}
event.num=0;
"step 1"
if(num<cards.length){
if(cards[num].original=='e'){
var info=get.info(cards[num]);
if(info.onLose&&(!info.filterLose||info.filterLose(cards[num],player))){
event.goto(2);
return;
}
}
event.num++;
event.redo();
}
else{
event.finish();
}
"step 2"
player.popup(cards[num].name);
var next=game.createEvent('lose_'+cards[num].name);
var info=get.info(cards[num]);
next.content=info.onLose;
next.player=player;
next.card=cards[num];
2015-11-05 02:34:35 +00:00
game.delayx();
2015-04-29 03:25:17 +00:00
event.num++;
event.goto(1);
},
damage:function(){
"step 0"
2015-06-27 16:21:25 +00:00
if(num>0&&player.hujia&&!player.hasSkillTag('nohujia')){
if(num>=player.hujia){
num-=player.hujia;
game.log(get.translation(player)+'的护甲抵挡了'+get.cnNumber(player.hujia)+'点伤害');
player.hujia=0;
}
else{
player.hujia-=num;
game.log(get.translation(player)+'的护甲抵挡了'+get.cnNumber(num)+'点伤害');
num=0;
}
event.hujia=true;
player.update();
}
event.num=num;
2015-04-29 14:56:33 +00:00
if(lib.config.background_audio){
2015-05-14 09:23:45 +00:00
game.playAudio('effect','damage'+(num>1?'2':''));
2015-04-29 14:56:33 +00:00
}
2015-04-29 03:25:17 +00:00
var str=get.translation(player)+'受到了';
if(source) str+='来自'+(source==player?'自己':get.translation(source)+'的');
str+=get.cnNumber(num)+'点';
if(event.nature) str+=get.translation(event.nature)+'属性';
str+='伤害';
game.log(str);
if(player.stat[player.stat.length-1].damaged==undefined){
player.stat[player.stat.length-1].damaged=num;
}
else{
player.stat[player.stat.length-1].damaged+=num;
}
if(source){
if(source.stat[source.stat.length-1].damage==undefined){
source.stat[source.stat.length-1].damage=num;
}
else{
source.stat[source.stat.length-1].damage+=num;
}
}
player.changeHp(-num,false);
2015-09-25 00:26:16 +00:00
if(event.animate!==false){
player.$damage(source);
if(lib.config.animation){
if(event.nature=='fire'){
player.$fire();
}
else if(event.nature=='thunder'){
player.$thunder();
}
2015-09-26 13:11:55 +00:00
player.$damagepop(-num,event.nature);
}
else{
player.popup(-num,event.nature);
2015-09-25 00:26:16 +00:00
}
}
2015-08-15 09:10:06 +00:00
// if(source){
// if(player._damagetimeout!=source){
// player.$damage(source);
// player._damagetimeout=source;
// setTimeout(function(){
// delete player._damagetimeout;
// },500);
// }
// if(player._damagepopup){
// player._damagepopup-=num;
// player._damagenature=event.nature;
// }
// else{
// player._damagepopup=-num;
// player._damagenature=event.nature;
// setTimeout(function(){
// player.popup(player._damagepopup,player._damagenature);
// delete player._damagepopup;
// delete player._damagenature;
// },300);
// }
// }
// else{
// player.$damage();
// }
2015-04-29 03:25:17 +00:00
event.trigger('damage');
"step 1"
if(player.hp<=0&&player.isAlive()){
2015-11-05 02:34:35 +00:00
game.delayx();
2015-04-29 03:25:17 +00:00
player.dying(event);
}
},
recover:function(){
if(lib.config.background_audio){
game.playAudio('effect','recover');
}
2015-04-29 03:25:17 +00:00
if(num>player.maxHp-player.hp) num=player.maxHp-player.hp;
if(num>0){
2015-09-26 13:11:55 +00:00
player.changeHp(num,false);
if(lib.config.animation){
player.$damagepop(num,'wood');
player.$recover();
}
else{
player.popup(num);
}
2015-04-29 03:25:17 +00:00
game.log(get.translation(player)+'回复了'+get.cnNumber(num)+'点体力')
}
},
loseHp:function(){
"step 0"
2015-05-14 09:23:45 +00:00
if(lib.config.background_audio){
game.playAudio('effect','loseHp');
}
2015-04-29 03:25:17 +00:00
game.log(get.translation(player)+'失去了'+get.cnNumber(num)+'点体力')
player.changeHp(-num);
"step 1"
if(player.hp<=0){
2015-11-05 02:34:35 +00:00
game.delayx();
2015-04-29 03:25:17 +00:00
player.dying(event);
}
},
2015-04-29 10:02:31 +00:00
doubleDraw:function(){
2015-04-29 03:25:17 +00:00
"step 0"
2015-04-29 10:02:31 +00:00
player.chooseBool('你的武将牌上有单独的阴阳鱼,是否摸一张牌?');
"step 1"
if(result.bool){
player.draw();
2015-04-29 03:25:17 +00:00
}
2015-04-29 10:02:31 +00:00
},
loseMaxHp:function(){
"step 0"
2015-04-29 03:25:17 +00:00
game.log(get.translation(player)+'失去了'+get.cnNumber(num)+'点体力上限');
2015-04-29 10:02:31 +00:00
if(!event.forced&&typeof player.singleHp==='boolean'){
if(player.singleHp){
player.singleHp=false;
player.maxHp-=num-1;
}
else{
player.singleHp=true;
player.maxHp-=num;
}
2015-04-29 07:54:48 +00:00
}
else{
2015-04-29 03:25:17 +00:00
player.maxHp-=num;
}
2015-04-29 07:54:48 +00:00
player.update();
2015-04-29 03:25:17 +00:00
"step 1"
if(player.maxHp<=0){
player.die();
}
2015-04-29 10:02:31 +00:00
"step 2"
if(!event.forced&&player.singleHp===true&&
!player.classList.contains('unseen')&&!player.classList.contains('unseen2')){
player.doubleDraw();
}
2015-04-29 03:25:17 +00:00
},
gainMaxHp:function(){
2015-04-29 10:02:31 +00:00
"step 0"
2015-04-29 03:25:17 +00:00
game.log(get.translation(player)+'获得了'+get.cnNumber(num)+'点体力上限');
2015-04-29 10:02:31 +00:00
if(typeof player.singleHp==='boolean'){
if(player.singleHp){
player.singleHp=false;
player.maxHp+=num;
}
else{
player.singleHp=true;
player.maxHp+=num-1;
}
2015-04-29 07:54:48 +00:00
}
else{
2015-04-29 03:25:17 +00:00
player.maxHp+=num;
}
2015-04-29 07:54:48 +00:00
player.update();
2015-04-29 10:02:31 +00:00
"step 1"
if(player.singleHp===true&&!player.classList.contains('unseen')&&!player.classList.contains('unseen2')){
player.doubleDraw();
}
2015-04-29 03:25:17 +00:00
},
changeHp:function(){
player.hp+=num;
if(player.hp>player.maxHp) player.hp=player.maxHp;
player.update();
if(event.popup!==false){
player.popup(num);
}
event.trigger('changeHp');
},
dying:function(){
"step 0"
_status.dying=player;
event.trigger('dying');
game.log(get.translation(player)+'濒死')
"step 1"
if(_status.dying==player) delete _status.dying;
if(player.hp<=0) player.die(event.reason);
},
die:function(){
if(source){
game.log(get.translation(player)+'被'+get.translation(source)+'杀害');
if(source.stat[source.stat.length-1].kill==undefined){
source.stat[source.stat.length-1].kill=1;
}
else{
source.stat[source.stat.length-1].kill++;
}
}
else{
game.log(get.translation(player)+'遇难')
}
event.cards=player.get('hej');
2015-09-03 03:49:14 +00:00
event.playerCards=player.get('he');
2015-04-29 03:25:17 +00:00
if(event.cards.length){
2015-05-12 09:51:40 +00:00
for(var i=0;i<event.cards.length;i++){
2015-04-29 03:25:17 +00:00
event.cards[i].goto(ui.discardPile);
}
player.$throw(event.cards,1000);
var card=event.cards;
var str=get.translation(player)+'弃置了'+get.translation(card[0]);
for(var i=1;i<card.length;i++){
str+='、'+get.translation(card[i]);
}
game.log(str);
}
2015-05-03 15:17:15 +00:00
if(!game.reserveDead){
for(var mark in player.marks){
player.unmarkSkill(mark);
}
while(player.node.marks.childNodes.length){
player.node.marks.firstChild.remove();
}
2015-04-29 03:25:17 +00:00
}
2015-05-12 09:51:40 +00:00
for(var i in player.tempSkills){
player.skills.remove(i);
delete player.tempSkills[i];
}
2015-04-29 03:25:17 +00:00
player.classList.add('dead');
player.classList.remove('turnedover');
player.classList.remove('out');
2015-11-05 02:34:35 +00:00
player.node.count.innerHTML='0';
player.node.hp.hide();
player.node.equips.hide();
player.node.count.hide();
2015-04-29 03:25:17 +00:00
player.previous.next=player.next;
player.next.previous=player.previous;
game.players.remove(player);
game.dead.push(player);
2015-04-29 14:56:33 +00:00
if(lib.config.background_speak){
2015-05-11 03:43:37 +00:00
if(lib.character[player.name]&&
2015-04-29 14:56:33 +00:00
lib.character[player.name][4].contains('die_audio')){
game.playAudio('die',player.name);
}
else if(lib.config.background_ogg){
2015-05-08 08:07:38 +00:00
game.playAudio('die',player.name);
2015-04-29 14:56:33 +00:00
}
2015-11-01 07:54:42 +00:00
// else if(lib.config.background_audio){
// game.playAudio('effect','die_'+(player.sex==='female'?'female':'male'));
// }
2015-04-30 08:24:57 +00:00
}
2015-10-20 17:44:00 +00:00
if(player==game.me&&!_status.over&&!game.controlOver){
2015-04-29 03:25:17 +00:00
ui.control.show();
2015-11-06 10:05:08 +00:00
// if(get.config('swap')&&lib.config.mode_choice.contains('swap')){
// ui.swap=ui.create.control('换人',ui.click.dieswap);
// }
2015-05-04 03:17:03 +00:00
if(get.config('revive')&&lib.config.mode_choice.contains('revive')){
2015-04-29 03:25:17 +00:00
ui.revive=ui.create.control('revive',ui.click.dierevive);
}
2015-05-04 03:17:03 +00:00
if(get.config('dierestart')&&lib.config.mode_choice.contains('dierestart')){
2015-04-29 08:41:00 +00:00
ui.restart=ui.create.control('restart',game.reload);
2015-04-29 03:25:17 +00:00
}
}
2015-10-20 17:44:00 +00:00
if(player==game.me&&!game.modeSwapPlayer){
2015-11-06 10:05:08 +00:00
// _status.auto=false;
2015-11-05 02:34:35 +00:00
if(ui.auto){
2015-11-06 10:05:08 +00:00
// ui.auto.classList.remove('glow');
2015-11-05 02:34:35 +00:00
ui.auto.hide();
}
if(ui.wuxie) ui.wuxie.hide();
2015-04-29 03:25:17 +00:00
}
2015-11-04 01:59:00 +00:00
game.addVideo('diex',player);
2015-04-29 07:54:48 +00:00
player.$die(source);
2015-11-05 02:34:35 +00:00
if(player.dieAfter) player.dieAfter(source);
2015-04-29 03:25:17 +00:00
},
equip:function(){
"step 0"
2015-05-14 09:23:45 +00:00
if(get.owner(card)) get.owner(card).lose(card,ui.special);
2015-04-29 03:25:17 +00:00
if(card.clone){
2015-11-06 10:05:08 +00:00
card.clone.moveTo(player).delete();
2015-11-04 01:59:00 +00:00
game.addVideo('gain2',player,get.cardsInfo([card.clone]));
2015-04-29 03:25:17 +00:00
}
player.equiping=true;
player.lose(player.get('e',{subtype:get.subtype(card)}),false);
"step 1"
card.fix();
2015-05-03 15:17:15 +00:00
if(player.isMin()){
event.finish();
ui.discardPile.appendChild(card);
delete player.equiping;
return;
}
2015-04-30 08:24:57 +00:00
if(lib.config.background_audio){
game.playAudio('effect',get.subtype(card));
}
2015-11-04 01:59:00 +00:00
player.$equip(card);
game.addVideo('equip',player,get.cardInfo(card));
game.log(get.translation(player)+'装备了'+get.translation(card));
2015-04-29 03:25:17 +00:00
"step 2"
var info=get.info(card);
if(info.onEquip&&(!info.filterEquip||info.filterEquip(card,player))){
var next=game.createEvent('equip_'+card.name);
next.content=info.onEquip;
next.player=player;
next.card=card;
2015-11-05 02:34:35 +00:00
game.delayx();
2015-04-29 03:25:17 +00:00
}
delete player.equiping;
},
addJudge:function(){
"step 0"
if(cards&&get.owner(cards[0])) get.owner(cards[0]).lose(cards);
"step 1"
2015-04-30 08:24:57 +00:00
if(lib.config.background_audio){
game.playAudio('effect','judge');
}
2015-04-29 03:25:17 +00:00
cards[0].fix();
var viewAs=typeof card=='string'?card:card.name;
if(!lib.card[viewAs]||!lib.card[viewAs].effect){
ui.discardPile.appendChild(cards[0]);
}
else{
player.node.judges.insertBefore(cards[0],player.node.judges.firstChild);
player.$gain2(cards);
if(get.itemtype(card)!='card'){
if(typeof card=='string') cards[0].viewAs=card;
else cards[0].viewAs=card.name;
}
else{
delete cards[0].viewAs;
}
if(cards[0].viewAs&&cards[0].viewAs!=cards[0].name){
game.log(get.translation(player)+'被贴上了'+get.translation(cards[0].viewAs)+''+get.translation(cards)+'');
}
else{
game.log(get.translation(player)+'被贴上了'+get.translation(cards));
}
2015-11-04 01:59:00 +00:00
game.addVideo('addJudge',player,[get.cardInfo(cards[0]),cards[0].viewAs]);
2015-04-29 03:25:17 +00:00
}
},
judge:function(){
"step 0"
2015-11-04 01:59:00 +00:00
var judgestr=get.translation(player)+'的'+event.judgestr+'判定';
event.videoId=lib.status.videoId++;
2015-04-29 03:25:17 +00:00
player.judging=get.cards()[0];
2015-11-04 01:59:00 +00:00
game.addVideo('judge1',player,[get.cardInfo(player.judging),judgestr,event.videoId]);
2015-11-06 10:05:08 +00:00
if(lib.config.mode=='chess'){
event.node=player.judging.copy('thrown','center',ui.arena).animate('start');
}
else{
event.node=player.$throwordered(player.judging.copy(),true);
}
event.node.classList.add('thrownhighlight');
ui.arena.classList.add('thrownhighlight');
2015-11-04 01:59:00 +00:00
event.dialog=ui.create.dialog(judgestr);
2015-05-09 02:56:55 +00:00
event.dialog.classList.add('center');
2015-04-29 03:25:17 +00:00
game.log(get.translation(player)+'进行'+event.judgestr+'判定,亮出的判定牌为'+get.translation(player.judging));
game.delay(2);
event.trigger('judge');
"step 1"
event.result={
card:player.judging,
number:get.number(player.judging),
suit:get.suit(player.judging),
color:get.color(player.judging),
judge:event.judge(player.judging),
node:event.node,
};
if(event.result.judge>0) event.result.bool=true;
if(event.result.judge<0) event.result.bool=false;
delete player.judging;
if(event.result.judge>0){
player.popup('洗具');
}
else if(event.result.judge<0){
player.popup('杯具');
}
if(event.clearArena!=false) ui.clear();
event.dialog.close();
2015-11-04 01:59:00 +00:00
game.addVideo('judge2',null,event.videoId);
2015-11-06 10:05:08 +00:00
ui.arena.classList.remove('thrownhighlight');
2015-04-29 03:25:17 +00:00
game.log(get.translation(player)+'的判定结果为'+get.translation(event.result.card));
if(!get.owner(event.result.card)) event.position.appendChild(event.result.card);
},
turnOver:function(){
game.log(get.translation(player)+'翻面');
player.classList.toggle('turnedover');
2015-11-04 01:59:00 +00:00
game.addVideo('turnOver',player,player.classList.contains('turnedover'));
2015-04-29 03:25:17 +00:00
},
link:function(){
if(player.isLinked()){
game.log(get.translation(player)+'解除连环');
}
else{
game.log(get.translation(player)+'被连环');
}
2015-05-14 14:28:29 +00:00
if(lib.config.background_audio){
game.playAudio('effect','link');
}
2015-04-29 03:25:17 +00:00
player.classList.toggle('linked');
2015-11-04 01:59:00 +00:00
game.addVideo('link',player,player.classList.contains('linked'));
2015-04-29 03:25:17 +00:00
},
},
player:{
init:function(character,character2,skill){
if(character2==false){
skill=false;
character2=null;
}
var info=lib.character[character];
var skills=info[3];
this.skills.length=0;
2015-10-31 10:14:14 +00:00
if(!game.minskin&&lib.isNewLayout()&&info[4].contains('fullskin')){
2015-05-03 15:17:15 +00:00
this.classList.remove('minskin');
2015-04-29 03:25:17 +00:00
this.classList.add('fullskin');
2015-05-11 11:57:44 +00:00
if(lib.fakeavatar&&lib.fakeavatar[character]){
this.node.avatar.setBackground('character/fullskin/'+lib.fakeavatar[character]);
}
else{
this.node.avatar.setBackground('character/fullskin/'+character);
}
2015-04-29 03:25:17 +00:00
}
else{
2015-10-31 10:14:14 +00:00
if(info[4].contains('fullskin')){
this.classList.add('fullskin');
this.node.avatar.setBackground('character/fullskin/'+character);
}
else{
this.classList.remove('fullskin');
this.node.avatar.setBackground(character,'character');
}
2015-05-11 03:43:37 +00:00
if(info[4].contains('minskin')){
2015-05-03 15:17:15 +00:00
this.classList.add('minskin');
}
2015-05-08 08:07:38 +00:00
else if(game.minskin){
this.classList.add('minskin');
}
2015-04-29 03:25:17 +00:00
}
this.node.avatar.show();
this.node.count.show();
2015-11-05 02:34:35 +00:00
this.node.equips.show();
2015-04-29 03:25:17 +00:00
this.name=character;
this.sex=info[0];
this.group=info[1];
this.hp=info[2];
this.maxHp=info[2];
2015-06-27 16:21:25 +00:00
this.hujia=0;
2015-04-29 03:25:17 +00:00
this.node.intro.innerHTML=lib.config.intro;
if(lib.config.touchscreen){
lib.setLongPress(this,ui.click.intro);
}
2015-11-09 17:04:18 +00:00
else if(lib.config.hover_all){
lib.setHover(this,ui.click.hoverplayer);
}
2015-04-29 03:25:17 +00:00
if(lib.config.right_info){
this.oncontextmenu=ui.click.rightplayer;
}
var name=get.translation(character);
this.node.name.innerHTML='';
if(!lib.config.show_name){
this.node.name.style.display='none';
}
for(var i=0;i<name.length;i++){
this.node.name.innerHTML+=name[i]+'<br/>';
}
if(character2){
var info2=lib.character[character2];
2015-10-31 10:14:14 +00:00
if(lib.isNewLayout()&&lib.config.only_fullskin){
2015-04-29 03:25:17 +00:00
this.classList.add('fullskin2');
2015-05-11 11:57:44 +00:00
if(lib.fakeavatar&&lib.fakeavatar[character2]){
this.node.avatar2.setBackground('character/fullskin/'+lib.fakeavatar[character2]);
}
else{
this.node.avatar2.setBackground('character/fullskin/'+character2);
}
2015-04-29 03:25:17 +00:00
}
else{
2015-10-31 10:14:14 +00:00
if(info2[4].contains('fullskin')){
this.classList.add('fullskin2');
this.node.avatar2.setBackground('character/fullskin/'+character2);
}
else{
this.classList.remove('fullskin2');
this.node.avatar2.setBackground(character2,'character');
}
2015-04-29 03:25:17 +00:00
}
this.node.avatar2.show();
this.name2=character2;
2015-04-29 10:02:31 +00:00
var hp1=info[2],hp2=info2[2];
switch(get.config('double_hp')){
case 'pingjun':{
this.maxHp=Math.floor((hp1+hp2)/2);
this.singleHp=((hp1+hp2)%2===1);
break;
}
case 'zuidazhi':this.maxHp=Math.max(hp1,hp2);break;
case 'zuixiaozhi':this.maxHp=Math.min(hp1,hp2);break;
case 'zonghe':this.maxHp=hp1+hp2;break;
default:this.maxHp=hp1+hp2-3;
2015-04-29 03:25:17 +00:00
}
2015-04-29 10:02:31 +00:00
this.hp=this.maxHp;
2015-04-29 03:25:17 +00:00
this.node.count.classList.add('p2');
skills=skills.concat(info2[3]);
}
if(skill!=false){
for(var i=0;i<skills.length;i++){
this.addSkill(skills[i]);
}
}
lib.group.add(this.group);
if(this.inits){
for(var i=0;i<lib.element.player.inits.length;i++){
lib.element.player.inits[i](this);
}
}
this.update();
return this;
},
2015-05-05 14:57:35 +00:00
uninit:function(){
2015-04-29 03:25:17 +00:00
var that=this;
this.node.avatar.hide();
this.node.count.hide();
if(this.node.wuxing){
this.node.wuxing.hide();
}
delete this.name;
delete this.sex;
delete this.group;
delete this.hp;
delete this.maxHp;
2015-06-27 16:21:25 +00:00
delete this.hujia;
2015-04-29 03:25:17 +00:00
this.skills.length=0;
this.node.identity.style.backgroundColor='';
this.node.intro.innerHTML='';
this.node.name.innerHTML='';
this.node.hp.innerHTML='';
2015-11-05 02:34:35 +00:00
this.node.count.innerHTML='0';
2015-04-29 03:25:17 +00:00
if(this.name2){
this.node.avatar2.hide();
delete this.name2;
this.node.count.classList.remove('p2');
}
for(var mark in this.marks){
this.marks[mark].remove();
}
this.skipList=[];
this.skills=[];
this.initedSkills=[];
this.additionalSkills={};
this.disabledSkills={};
this.hiddenSkills=[];
this.forbiddenSkills=[];
this.modeSkills=[];
2015-05-05 14:57:35 +00:00
this.stat=[{card:{},skill:{}}];
2015-04-29 03:25:17 +00:00
this.tempSkills={};
this.storage={};
this.marks={};
this.ai={friend:[],enemy:[],neutral:[]};
return this;
},
update:function(){
2015-11-04 01:59:00 +00:00
if(_status.video&&arguments.length==0) return;
2015-04-29 03:25:17 +00:00
if(this.hp>=this.maxHp) this.hp=this.maxHp;
var hp=this.node.hp;
hp.style.transition='none';
2015-11-04 01:59:00 +00:00
if(!_status.video){
if(this.hujia){
this.markSkill('ghujia');
}
else{
this.unmarkSkill('ghujia');
}
2015-06-27 16:21:25 +00:00
}
2015-04-29 03:25:17 +00:00
if(lib.config.layout=='default'&&this.maxHp>14){
hp.innerHTML=this.hp+'/'+this.maxHp;
hp.classList.add('text');
}
2015-10-31 10:14:14 +00:00
else if(lib.isNewLayout()&&
(
this.maxHp>9||
(this.maxHp>5&&this.classList.contains('minskin'))||
2015-10-31 16:18:20 +00:00
((lib.config.layout=='mobile'||lib.config.layout=='phone')&&this.dataset.position==0&&this.maxHp>7)
2015-10-31 10:14:14 +00:00
)){
2015-05-11 11:57:44 +00:00
hp.innerHTML=this.hp+'<br>/<br>'+this.maxHp;
hp.classList.add('text');
hp.classList.remove('long');
}
2015-04-29 03:25:17 +00:00
else{
hp.innerHTML='';
hp.classList.remove('text');
while(this.maxHp>hp.childNodes.length){
ui.create.div(hp);
}
while(this.maxHp<hp.childNodes.length){
hp.removeChild(hp.lastChild);
}
for(var i=0;i<this.maxHp;i++){
if(i<this.hp){
hp.childNodes[i].classList.remove('lost');
}
else{
hp.childNodes[i].classList.add('lost');
}
}
2015-05-11 11:57:44 +00:00
if(this.maxHp==9){
hp.classList.add('long');
2015-05-03 15:17:15 +00:00
}
else{
2015-05-11 11:57:44 +00:00
hp.classList.remove('long');
2015-05-03 15:17:15 +00:00
}
2015-04-29 03:25:17 +00:00
}
2015-05-11 11:57:44 +00:00
if(this.hp==0){
hp.dataset.condition='';
}
else if(this.hp>Math.round(this.maxHp/2)||this.hp===this.maxHp){
hp.dataset.condition='high';
2015-04-29 03:25:17 +00:00
}
else if(this.hp>Math.floor(this.maxHp/3)){
2015-05-11 11:57:44 +00:00
hp.dataset.condition='mid';
2015-04-29 03:25:17 +00:00
}
else{
2015-05-11 11:57:44 +00:00
hp.dataset.condition='low';
2015-04-29 03:25:17 +00:00
}
setTimeout(function(){
hp.style.transition='';
});
var numh=this.num('h');
2015-11-04 01:59:00 +00:00
if(_status.video){
numh=arguments[0];
}
2015-04-29 03:25:17 +00:00
if(numh>=10){
numh=numh.toString();
this.node.count.dataset.condition='low';
this.node.count.innerHTML=numh[0]+'<br>'+numh[1];
}
else{
if(numh>5){
this.node.count.dataset.condition='higher';
}
else if(numh>2){
this.node.count.dataset.condition='high';
}
else if(numh>0){
this.node.count.dataset.condition='mid';
}
else{
this.node.count.dataset.condition='none';
}
this.node.count.innerHTML=numh;
}
this.node.equips.dataset.number=this.num('e');
if(this==game.me){
2015-05-07 04:48:00 +00:00
ui.updateh();
2015-04-29 03:25:17 +00:00
}
if(this.updates){
for(var i=0;i<lib.element.player.updates.length;i++){
lib.element.player.updates[i](this);
}
}
2015-11-04 01:59:00 +00:00
if(!_status.video){
game.addVideo('update',this,[this.num('h'),this.hp,this.maxHp,this.hujia]);
}
2015-04-29 03:25:17 +00:00
return this;
},
num:function(arg1,arg2,arg3){
var i,j,k;
if(get.itemtype(arg1)=='position'){
return this.get(arg1,arg2,arg3).length;
}
else if(arg1=='s'){
if(typeof arg2=='boolean'){
return game.expandSkills(this.get('s',arg2).concat(lib.skill.global)).contains(arg3);
}
else{
return game.expandSkills(this.get('s').concat(lib.skill.global)).contains(arg2);
}
}
},
line:function(target,config){
if(get.itemtype(target)=='players'){
for(var i=0;i<target.length;i++){
this.line(target[i],config);
}
}
else if(get.itemtype(target)=='player'){
if(target==this) return;
2015-11-04 01:59:00 +00:00
game.addVideo('line',this,[target.dataset.position,config]);
2015-04-29 03:25:17 +00:00
game.linexy([
this.offsetLeft+this.offsetWidth/2,
this.offsetTop+this.offsetHeight/2,
target.offsetLeft+target.offsetWidth/2,
target.offsetTop+target.offsetHeight/2
2015-05-08 08:07:38 +00:00
],config,true);
2015-04-29 03:25:17 +00:00
}
},
2015-11-04 01:59:00 +00:00
line2:function(targets,config,init){
2015-04-29 03:25:17 +00:00
this.line(targets[0],config);
targets=targets.slice(0);
for(var i=1;i<targets.length;i++){
(function(j){
setTimeout(function(){
targets[j-1].line(targets[j],config);
},lib.config.duration*i);
}(i));
}
},
get:function(arg1,arg2,arg3,arg4){
var i,j;
if(arg1=='s'){
this.checkConflict();
var skills=this.skills.slice(0);
for(var i in this.additionalSkills){
if(Array.isArray(this.additionalSkills[i])){
for(j=0;j<this.additionalSkills[i].length;j++){
if(this.additionalSkills[i][j]){
skills.add(this.additionalSkills[i][j]);
}
}
}
else if(this.additionalSkills[i]&&typeof this.additionalSkills[i]=='string'){
skills.add(this.additionalSkills[i]);
}
}
if(arg2) skills=skills.concat(this.hiddenSkills);
if(arg3!==false){
for(i=0;i<this.node.equips.childNodes.length;i++){
if(get.info(this.node.equips.childNodes[i]).skills){
skills=skills.concat(get.info(this.node.equips.childNodes[i]).skills);
}
}
}
for(i=0;i<this.forbiddenSkills.length;i++){
skills.remove(this.forbiddenSkills[i]);
}
if(arg4!==false){
skills=game.filterSkills(skills,this);
}
return skills;
}
else if(get.itemtype(arg1)=='position'){
var cards=[],cards1=[];
for(i=0;i<arg1.length;i++){
if(arg1[i]=='h'){
for(j=0;j<this.node.handcards1.childNodes.length;j++){
cards.push(this.node.handcards1.childNodes[j]);
}
for(j=0;j<this.node.handcards2.childNodes.length;j++){
cards.push(this.node.handcards2.childNodes[j]);
}
}
else if(arg1[i]=='e'){
for(j=0;j<this.node.equips.childNodes.length;j++){
cards.push(this.node.equips.childNodes[j]);
}
if(arguments.length==2&&typeof arg2=='string'&&/1|2|3|4|5/.test(arg2)){
for(j=0;j<cards.length;j++){
if(get.subtype(cards[j])=='equip'+arg2) return cards[j];
}
return;
}
}
else if(arg1[i]=='j'){
for(j=0;j<this.node.judges.childNodes.length;j++){
cards.push(this.node.judges.childNodes[j]);
if(this.node.judges.childNodes[j].viewAs){
this.node.judges.childNodes[j].tempJudge=this.node.judges.childNodes[j].name;
this.node.judges.childNodes[j].name=this.node.judges.childNodes[j].viewAs;
cards1.push(this.node.judges.childNodes[j]);
}
}
}
}
for(i=0;i<cards.length;i++){
if(cards[i].classList.contains('removing')){
cards.splice(i,1);i--;
}
}
if(arg2!=undefined){
if(typeof arg3=='function'){
var cards2=cards.slice(0);
cards.sort(function(a,b){
return arg3(b,cards2)-arg3(a,cards2);
});
}
if(typeof arg2=='string'){
for(i=0;i<cards.length;i++){
if(cards[i].name!=arg2){
cards.splice(i,1);i--;
}
}
}
else if(typeof arg2=='object'){
for(i=0;i<cards.length;i++){
for(j in arg2){
if(j=='type'){
if(typeof arg2[j]=='object'){
if(arg2[j].contains(get.type(cards[i]))==false){
cards.splice(i,1);i--;break;
}
}
else if(typeof arg2[j]=='string'){
if(get.type(cards[i])!=arg2[j]){
cards.splice(i,1);i--;break;
}
}
}
else if(j=='subtype'){
if(typeof arg2[j]=='object'){
if(arg2[j].contains(get.subtype(cards[i]))==false){
cards.splice(i,1);i--;break;
}
}
else if(typeof arg2[j]=='string'){
if(get.subtype(cards[i])!=arg2[j]){
cards.splice(i,1);i--;break;
}
}
}
else if(j=='color'){
if(typeof arg2[j]=='object'){
if(arg2[j].contains(get.color(cards[i]))==false){
cards.splice(i,1);i--;break;
}
}
else if(typeof arg2[j]=='string'){
if(get.color(cards[i])!=arg2[j]){
cards.splice(i,1);i--;break;
}
}
}
else if(j=='suit'){
if(typeof arg2[j]=='object'){
if(arg2[j].contains(get.suit(cards[i]))==false){
cards.splice(i,1);i--;break;
}
}
else if(typeof arg2[j]=='string'){
if(get.suit(cards[i])!=arg2[j]){
cards.splice(i,1);i--;break;
}
}
}
else if(j=='number'){
if(typeof arg2[j]=='object'){
if(arg2[j].contains(get.number(cards[i]))==false){
cards.splice(i,1);i--;break;
}
}
else if(typeof arg2[j]=='string'){
if(get.number(cards[i])!=arg2[j]){
cards.splice(i,1);i--;break;
}
}
}
else if(typeof arg2[j]=='object'){
if(arg2[j].contains(cards[i][j])==false){
cards.splice(i,1);i--;break;
}
}
else if(typeof arg2[j]=='string'){
if(cards[i][j]!=arg2[j]){
cards.splice(i,1);i--;break;
}
}
}
}
}
else if(typeof arg2=='number'&&arg2>0){
cards.splice(arg2);
}
else if(typeof arg2=='function'){
for(i=0;i<cards.length;i++){
if(!arg2(cards[i])){
cards.splice(i,1);i--;
}
}
}
}
for(i=0;i<cards1.length;i++){
if(cards1[i].tempJudge){
cards1[i].name=cards1[i].tempJudge;
delete cards1[i].tempJudge;
}
}
if(arg2===0) return cards[0];
if(typeof arg3=='number'){
if(arg3==0) return cards[0];
cards.splice(arg3);
}
if(typeof arg4=='number'){
if(arg4==0) return cards[0];
cards.splice(arg4);
}
return cards;
}
},
2015-11-09 03:15:16 +00:00
playerfocus:function(time){
time=time||1000;
this.classList.add('playerfocus');
ui.arena.classList.add('playerfocus');
var that=this;
setTimeout(function(){
that.classList.remove('playerfocus');
ui.arena.classList.remove('playerfocus');
},1000);
game.addVideo('playerfocus',this,time);
return this;
},
2015-06-27 16:21:25 +00:00
changeHujia:function(num){
if(typeof num!='number'){
num=1;
}
this.hujia+=num;
if(num>0){
game.log(get.translation(this)+'获得了'+get.cnNumber(num)+'点护甲值');
}
if(this.hujia<0){
this.hujia=0;
}
this.update();
},
2015-04-29 03:25:17 +00:00
setIdentity:function(identity){
if(!identity) identity=this.identity;
this.node.identity.firstChild.innerHTML=get.translation(identity);
this.node.identity.dataset.color=identity;
},
phase:function(){
var next=game.createEvent('phase');
next.player=this;
next.content=lib.element.playerproto.phase;
},
phaseJudge:function(){
var next=game.createEvent('phaseJudge');
next.player=this;
next.content=lib.element.playerproto.phaseJudge;
},
phaseDraw:function(){
var next=game.createEvent('phaseDraw');
next.player=this;
next.num=2;
next.content=lib.element.playerproto.phaseDraw;
},
phaseUse:function(){
var next=game.createEvent('phaseUse');
next.player=this;
next.content=lib.element.playerproto.phaseUse;
},
phaseDiscard:function(){
var next=game.createEvent('phaseDiscard');
next.player=this;
next.content=lib.element.playerproto.phaseDiscard;
},
chooseToUse:function(use){
var next=game.createEvent('chooseToUse');
next.player=this;
if(arguments.length==1){
for(var i in use){
next[i]=use[i];
}
}
else{
for(var i=0;i<arguments.length;i++){
if(typeof arguments[i]=='number'||get.itemtype(arguments[i])=='select'){
next.selectTarget=arguments[i];
}
else if(typeof arguments[i]=='object'||typeof arguments[i]=='function'){
if(get.itemtype(arguments[i])=='player'||next.filterCard){
next.filterTarget=arguments[i];
}
else next.filterCard=arguments[i];
}
else if(typeof arguments[i]=='boolean'){
next.forced=arguments[i];
}
else if(typeof arguments[i]=='string'){
next.prompt=arguments[i];
}
}
}
if(typeof next.filterCard=='object'){
next.filterCard=get.filter(next.filterCard);
}
if(typeof next.filterTarget=='object'){
next.filterTarget=get.filter(next.filterTarget,2);
}
if(next.filterCard==undefined){
next.filterCard=lib.filter.filterCard;
}
if(next.selectCard==undefined){
next.selectCard=lib.filter.selectCard;
}
if(next.filterTarget==undefined){
next.filterTarget=lib.filter.filterTarget;
}
if(next.selectTarget==undefined){
next.selectTarget=lib.filter.selectTarget;
}
if(next.ai1==undefined) next.ai1=ai.get.order;
if(next.ai2==undefined) next.ai2=ai.get.effect;
next.content=lib.element.playerproto.chooseToUse;
return next;
},
chooseToRespond:function(){
var next=game.createEvent('chooseToRespond');
next.player=this;
2015-05-11 11:57:44 +00:00
var filter;
2015-04-29 03:25:17 +00:00
for(var i=0;i<arguments.length;i++){
if(typeof arguments[i]=='number'){
next.selectCard=[arguments[i],arguments[i]];
}
else if(get.itemtype(arguments[i])=='select'){
next.selectCard=arguments[i];
}
else if(typeof arguments[i]=='boolean'){
next.forced=arguments[i];
}
else if(get.itemtype(arguments[i])=='position'){
next.position=arguments[i];
}
else if(typeof arguments[i]=='function'){
if(next.filterCard) next.ai=arguments[i];
else next.filterCard=arguments[i];
}
else if(typeof arguments[i]=='object'){
next.filterCard=get.filter(arguments[i]);
2015-05-11 11:57:44 +00:00
filter=arguments[i];
2015-04-29 03:25:17 +00:00
}
else if(arguments[i]=='nosource'){
next.nosource=true;
}
else if(typeof arguments[i]=='string'){
next.prompt=arguments[i];
}
}
if(next.filterCard==undefined) next.filterCard=lib.filter.all;
if(next.selectCard==undefined) next.selectCard=[1,1];
if(next.source==undefined&&!next.nosource) next.source=_status.event.player;
if(next.ai==undefined) next.ai=ai.get.unuseful2;
if(next.prompt!=false){
if(typeof next.prompt=='string'){
next.dialog=next.prompt;
}
else{
var str='请打出'+get.cnNumber(next.selectCard[0])+'张'
if(filter){
if(filter.name){
str+=get.translation(filter.name);
}
else{
str+='牌';
}
}
else{
str+='牌';
}
next.dialog=str;
}
}
next.content=lib.element.playerproto.chooseToRespond;
return next;
},
chooseToDiscard:function(){
var next=game.createEvent('chooseToDiscard');
next.player=this;
for(var i=0;i<arguments.length;i++){
if(typeof arguments[i]=='number'){
next.selectCard=[arguments[i],arguments[i]];
}
else if(get.itemtype(arguments[i])=='select'){
next.selectCard=arguments[i];
}
else if(get.itemtype(arguments[i])=='dialog'){
next.dialog=arguments[i];
next.prompt=false;
}
else if(typeof arguments[i]=='boolean'){
next.forced=arguments[i];
}
else if(get.itemtype(arguments[i])=='position'){
next.position=arguments[i];
}
else if(typeof arguments[i]=='function'){
if(next.filterCard) next.ai=arguments[i];
else next.filterCard=arguments[i];
}
else if(typeof arguments[i]=='object'){
next.filterCard=get.filter(arguments[i]);
}
else if(typeof arguments[i]=='string'){
next.prompt=arguments[i];
}
}
if(next.isMine()==false&&next.dialog) next.dialog.style.display='none';
if(next.filterCard==undefined) next.filterCard=lib.filter.all;
if(next.selectCard==undefined) next.selectCard=[1,1];
if(next.ai==undefined) next.ai=ai.get.unuseful;
next.autochoose=function(){
if(!this.forced) return false;
return get.select(this.selectCard)[0]>=this.player.num(this.position||'h');
}
next.content=lib.element.playerproto.chooseToDiscard;
return next;
},
chooseToCompare:function(target,check){
var next=game.createEvent('chooseToCompare');
next.player=this;
next.target=target;
if(check) next.ai=check;
else next.ai=function(card){
var player=get.owner(card);
var event=_status.event.parent;
2015-05-01 09:34:01 +00:00
var to=(player==event.player?event.target:event.player);
2015-05-01 07:35:43 +00:00
var addi=(ai.get.value(card)>=8&&get.type(card)!='equip')?-10:0;
if(player==event.player){
2015-05-01 09:34:01 +00:00
if(ai.get.attitude(player,to)>0&&event.small){
return -get.number(card)-ai.get.value(card)/2+addi;
}
return get.number(card)-ai.get.value(card)/2+addi;
2015-04-29 03:25:17 +00:00
}
2015-05-01 09:34:01 +00:00
else{
if(ai.get.attitude(player,to)>0&&!event.small){
return -get.number(card)-ai.get.value(card)/2+addi;
}
2015-05-01 09:34:01 +00:00
return get.number(card)-ai.get.value(card)/2+addi;
}
2015-04-29 03:25:17 +00:00
}
next.content=lib.element.playerproto.chooseToCompare;
return next;
},
chooseCardButton:function(){
var cards,prompt,forced,select;
for(var i=0;i<arguments.length;i++){
if(get.itemtype(arguments[i])=='cards') cards=arguments[i];
else if(typeof arguments[i]=='boolean') forced=arguments[i];
else if(typeof arguments[i]=='string') prompt=arguments[i];
else if(get.itemtype(arguments[i])=='select'||typeof arguments[i]=='number') select=arguments[i];
}
if(prompt==undefined) prompt='请选择卡牌';
return this.chooseButton(ui.create.dialog(prompt,cards),forced,select,'hidden');
},
chooseButton:function(){
var next=game.createEvent('chooseButton');
for(var i=0;i<arguments.length;i++){
if(typeof arguments[i]=='boolean'){
next.forced=arguments[i];
}
else if(get.itemtype(arguments[i])=='dialog'){
next.dialog=arguments[i];
next.closeDialog=true;
}
else if(get.itemtype(arguments[i])=='select'){
next.selectButton=arguments[i];
}
else if(typeof arguments[i]=='number'){
next.selectButton=[arguments[i],arguments[i]];
}
else if(typeof arguments[i]=='function'){
if(next.ai) next.filterButton=arguments[i];
else next.ai=arguments[i];
}
}
next.player=this;
if(next.isMine()==false&&next.dialog) next.dialog.style.display='none';
if(next.filterButton==undefined) next.filterButton=lib.filter.filterButton;
if(next.selectButton==undefined) next.selectButton=[1,1];
if(next.ai==undefined) next.ai=function(){return 1};
next.content=lib.element.playerproto.chooseButton;
return next;
},
chooseCard:function(){
var next=game.createEvent('chooseCard');
next.player=this;
for(var i=0;i<arguments.length;i++){
if(typeof arguments[i]=='number'){
next.selectCard=[arguments[i],arguments[i]];
}
else if(get.itemtype(arguments[i])=='select'){
next.selectCard=arguments[i];
}
else if(typeof arguments[i]=='boolean'){
next.forced=arguments[i];
}
else if(get.itemtype(arguments[i])=='position'){
next.position=arguments[i];
}
else if(typeof arguments[i]=='function'){
if(next.filterCard) next.ai=arguments[i];
else next.filterCard=arguments[i];
}
else if(typeof arguments[i]=='object'){
next.filterCard=get.filter(arguments[i]);
}
else if(typeof arguments[i]=='string'){
next.prompt=arguments[i];
}
}
if(next.filterCard==undefined) next.filterCard=lib.filter.all;
if(next.selectCard==undefined) next.selectCard=[1,1];
if(next.ai==undefined) next.ai=ai.get.unuseful2;
next.content=lib.element.playerproto.chooseCard;
return next;
},
chooseTarget:function(){
var next=game.createEvent('chooseTarget');
next.player=this;
for(var i=0;i<arguments.length;i++){
if(typeof arguments[i]=='number'){
next.selectTarget=[arguments[i],arguments[i]];
}
else if(get.itemtype(arguments[i])=='select'){
next.selectTarget=arguments[i];
}
else if(get.itemtype(arguments[i])=='dialog'){
next.dialog=arguments[i];
next.prompt=false;
}
else if(typeof arguments[i]=='boolean'){
next.forced=arguments[i];
}
else if(typeof arguments[i]=='function'){
if(next.filterTarget) next.ai=arguments[i];
else next.filterTarget=arguments[i];
}
else if(typeof arguments[i]=='string'){
next.prompt=arguments[i];
}
}
if(next.filterTarget==undefined) next.filterTarget=lib.filter.all;
if(next.selectTarget==undefined) next.selectTarget=[1,1];
if(next.ai==undefined) next.ai=ai.get.attitude2;
next.content=lib.element.playerproto.chooseTarget;
return next;
},
chooseCardTarget:function(choose){
var next=game.createEvent('chooseCardTarget');
next.player=this;
if(arguments.length==1){
for(var i in choose){
next[i]=choose[i];
}
}
if(typeof next.filterCard=='object'){
next.filterCard=get.filter(next.filterCard);
}
if(typeof next.filterTarget=='object'){
next.filterTarget=get.filter(next.filterTarget,2);
}
if(next.filterCard==undefined||next.filterCard===true){
next.filterCard=lib.filter.all;
}
if(next.selectCard==undefined){
next.selectCard=1;
}
if(next.filterTarget==undefined||next.filterTarget===true){
next.filterTarget=lib.filter.all;
}
if(next.selectTarget==undefined){
next.selectTarget=1;
}
if(next.ai1==undefined) next.ai1=ai.get.unuseful2;
if(next.ai2==undefined) next.ai2=ai.get.attitude2;
next.content=lib.element.playerproto.chooseCardTarget;
return next;
},
chooseControl:function(){
var next=game.createEvent('chooseControl');
next.controls=[];
for(var i=0;i<arguments.length;i++){
if(typeof arguments[i]=='string'){
next.controls.push(arguments[i]);
}
else if(get.objtype(arguments[i])=='array'){
next.controls=next.controls.concat(arguments[i]);
}
else if(typeof arguments[i]=='function'){
next.ai=arguments[i];
}
else if(typeof arguments[i]=='number'){
next.choice=arguments[i];
}
else if(get.itemtype(arguments[i])=='dialog'){
next.dialog=arguments[i];
}
}
next.player=this;
if(next.choice==undefined) next.choice=0;
next.content=lib.element.playerproto.chooseControl;
return next;
},
chooseBool:function(){
var next=game.createEvent('chooseBool');
for(var i=0;i<arguments.length;i++){
if(typeof arguments[i]=='boolean'){
next.choice=arguments[i];
}
else if(typeof arguments[i]=='function'){
next.ai=arguments[i];
}
else if(typeof arguments[i]=='string'){
next.prompt=arguments[i];
}
2015-06-19 15:31:36 +00:00
else if(get.itemtype(arguments[i])=='dialog'){
next.dialog=arguments[i];
}
2015-04-29 03:25:17 +00:00
if(next.choice==undefined) next.choice=true;
}
next.player=this;
next.content=lib.element.playerproto.chooseBool;
return next;
},
choosePlayerCard:function(){
var next=game.createEvent('choosePlayerCard');
next.player=this;
for(var i=0;i<arguments.length;i++){
if(get.itemtype(arguments[i])=='player'){
next.target=arguments[i];
}
else if(typeof arguments[i]=='number'){
next.selectButton=[arguments[i],arguments[i]];
}
else if(get.itemtype(arguments[i])=='select'){
next.selectButton=arguments[i];
}
else if(typeof arguments[i]=='boolean'){
next.forced=arguments[i];
}
else if(get.itemtype(arguments[i])=='position'){
next.position=arguments[i];
}
else if(arguments[i]=='visible'){
next.visible=true;
}
else if(typeof arguments[i]=='function'){
if(next.ai) next.filterButton=arguments[i];
else next.ai=arguments[i];
}
else if(typeof arguments[i]=='object'){
next.filterButton=get.filter(arguments[i]);
}
else if(typeof arguments[i]=='string'){
next.prompt=arguments[i];
}
}
if(next.filterButton==undefined) next.filterButton=lib.filter.all;
if(next.position==undefined) next.position='hej';
if(next.selectButton==undefined) next.selectButton=[1,1];
if(next.ai==undefined) next.ai=function(button){
var val=ai.get.buttonValue(button);
if(ai.get.attitude(_status.event.player,get.owner(button.link))>0) return -val;
return val;
};
next.content=lib.element.playerproto.choosePlayerCard;
return next;
},
discardPlayerCard:function(){
var next=game.createEvent('discardPlayerCard');
next.player=this;
for(var i=0;i<arguments.length;i++){
if(get.itemtype(arguments[i])=='player'){
next.target=arguments[i];
}
else if(typeof arguments[i]=='number'){
next.selectButton=[arguments[i],arguments[i]];
}
else if(get.itemtype(arguments[i])=='select'){
next.selectButton=arguments[i];
}
else if(typeof arguments[i]=='boolean'){
next.forced=arguments[i];
}
else if(get.itemtype(arguments[i])=='position'){
next.position=arguments[i];
}
else if(arguments[i]=='visible'){
next.visible=true;
}
else if(typeof arguments[i]=='function'){
if(next.ai) next.filterButton=arguments[i];
else next.ai=arguments[i];
}
else if(typeof arguments[i]=='object'){
next.filterButton=get.filter(arguments[i]);
}
else if(typeof arguments[i]=='string'){
next.prompt=arguments[i];
}
}
if(next.filterButton==undefined) next.filterButton=lib.filter.all;
if(next.position==undefined) next.position='hej';
if(next.selectButton==undefined) next.selectButton=[1,1];
if(next.ai==undefined) next.ai=function(button){
var val=ai.get.buttonValue(button);
if(ai.get.attitude(_status.event.player,get.owner(button.link))>0) return -val;
return val;
};
next.content=lib.element.playerproto.discardPlayerCard;
return next;
},
gainPlayerCard:function(){
var next=game.createEvent('gainPlayerCard');
next.player=this;
for(var i=0;i<arguments.length;i++){
if(get.itemtype(arguments[i])=='player'){
next.target=arguments[i];
}
else if(typeof arguments[i]=='number'){
next.selectButton=[arguments[i],arguments[i]];
}
else if(get.itemtype(arguments[i])=='select'){
next.selectButton=arguments[i];
}
else if(typeof arguments[i]=='boolean'){
next.forced=arguments[i];
}
else if(get.itemtype(arguments[i])=='position'){
next.position=arguments[i];
}
else if(arguments[i]=='visible'){
next.visible=true;
}
else if(typeof arguments[i]=='function'){
if(next.ai) next.filterButton=arguments[i];
else next.ai=arguments[i];
}
else if(typeof arguments[i]=='object'){
next.filterButton=get.filter(arguments[i]);
}
else if(typeof arguments[i]=='string'){
next.prompt=arguments[i];
}
}
if(next.filterButton==undefined) next.filterButton=lib.filter.all;
if(next.position==undefined) next.position='h';
if(next.selectButton==undefined) next.selectButton=[1,1];
if(next.ai==undefined) next.ai=function(button){
var val=ai.get.buttonValue(button);
if(ai.get.attitude(_status.event.player,get.owner(button.link))>0) return -val;
return val;
};
next.content=lib.element.playerproto.gainPlayerCard;
return next;
},
showHandcards:function(){
var next=game.createEvent('showHandcards');
next.player=this;
next.content=lib.element.playerproto.showHandcards;
},
2015-06-27 16:21:25 +00:00
showCards:function(cards,str){
2015-04-29 03:25:17 +00:00
var next=game.createEvent('showCards');
next.player=this;
2015-06-27 16:21:25 +00:00
next.str=str;
2015-04-29 03:25:17 +00:00
if(get.itemtype(cards)=='card') next.cards=[cards];
else if(get.itemtype(cards)=='cards') next.cards=cards;
else _status.event.next.remove(next);
next.content=lib.element.playerproto.showCards;
},
viewHandcards:function(target){
var next=game.createEvent('viewHandcards');
next.player=this;
next.target=target;
next.content=lib.element.playerproto.viewHandcards;
},
useCard:function(){
var next=game.createEvent('useCard');
next.player=this;
next.num=0;
for(var i=0;i<arguments.length;i++){
if(get.itemtype(arguments[i])=='cards'){
next.cards=arguments[i];
}
else if(get.itemtype(arguments[i])=='players'){
next.targets=arguments[i];
}
else if(get.itemtype(arguments[i])=='player'){
next.targets=[arguments[i]];
}
else if(get.itemtype(arguments[i])=='card'){
next.card=arguments[i];
}
else if(typeof arguments[i]=='object'&&arguments[i].name){
next.card=arguments[i];
}
else if(typeof arguments[i]=='string'){
next.skill=arguments[i];
}
else if(typeof arguments[i]=='boolean'){
next.addCount=arguments[i];
}
}
if(next.cards==undefined){
if(get.itemtype(next.card)=='card'){
next.cards=[next.card];
}
else next.cards=[];
}
else if(next.card==undefined){
if(next.cards){
next.card=next.cards[0];
}
}
if(!next.targets){
next.targets=[];
}
for(var i=0;i<next.targets.length;i++){
if(ai.get.attitude(this,next.targets[i])>=-1&&ai.get.attitude(this,next.targets[i])<0){
if(!this.ai.tempIgnore) this.ai.tempIgnore=[];
this.ai.tempIgnore.add(next.targets[i]);
}
}
if(typeof this.logAi=='function'){
this.logAi(next.targets,next.card);
}
next.content=lib.element.playerproto.useCard;
return next;
},
useSkill:function(){
var next=game.createEvent('useSkill');
next.player=this;
next.num=0;
for(var i=0;i<arguments.length;i++){
if(get.itemtype(arguments[i])=='cards'){
next.cards=arguments[i];
}
else if(get.itemtype(arguments[i])=='players'){
next.targets=arguments[i];
}
else if(get.itemtype(arguments[i])=='card'){
next.card=arguments[i];
}
else if(typeof arguments[i]=='string'){
next.skill=arguments[i];
}
else if(typeof arguments[i]=='boolean'){
next.addCount=arguments[i];
}
}
if(next.cards==undefined){
next.cards=[];
}
if(next.targets){
for(var i=0;i<next.targets.length;i++){
if(ai.get.attitude(this,next.targets[i])>=-1&&ai.get.attitude(this,next.targets[i])<0){
if(!this.ai.tempIgnore) this.ai.tempIgnore=[];
this.ai.tempIgnore.add(next.targets[i]);
}
}
if(typeof this.logAi=='function'){
this.logAi(next.targets,next.skill);
}
}
else{
next.targets=[];
}
next.content=lib.element.playerproto.useSkill;
},
draw:function(){
var next=game.createEvent('draw');
next.player=this;
for(var i=0;i<arguments.length;i++){
if(get.itemtype(arguments[i])=='player'){
next.source=arguments[i];
}
else if(typeof arguments[i]=='number'){
next.num=arguments[i];
}
else if(typeof arguments[i]=='boolean'){
next.animate=arguments[i];
}
}
if(next.num==undefined) next.num=1;
if(next.num==0) _status.event.next.remove(next);
next.content=lib.element.playerproto.draw;
return next;
},
discard:function(){
var next=game.createEvent('discard');
next.player=this;
next.num=0;
for(var i=0;i<arguments.length;i++){
if(get.itemtype(arguments[i])=='player'){
next.source=arguments[i];
}
else if(get.itemtype(arguments[i])=='cards'){
next.cards=arguments[i];
}
else if(get.itemtype(arguments[i])=='card'){
next.cards=[arguments[i]];
}
else if(typeof arguments[i]=='boolean'){
next.animate=arguments[i];
}
}
if(next.cards==undefined) _status.event.next.remove(next);
next.content=lib.element.playerproto.discard;
return next;
},
respond:function(){
var next=game.createEvent('respond');
next.player=this;
for(var i=0;i<arguments.length;i++){
if(get.itemtype(arguments[i])=='cards'){
next.cards=arguments[i];
}
else if(get.itemtype(arguments[i])=='card'){
next.card=arguments[i];
}
else if(get.itemtype(arguments[i])=='player'){
next.source=arguments[i];
}
else if(typeof arguments[i]=='object'&&arguments[i].name){
next.card=arguments[i];
}
else if(typeof arguments[i]=='boolean') next.animate=arguments[i];
2015-11-06 10:05:08 +00:00
else if(arguments[i]=='highlight') next.highlight=true;
2015-04-29 03:25:17 +00:00
else if(typeof arguments[i]=='string') next.skill=arguments[i];
}
if(next.cards==undefined){
if(get.itemtype(next.card)=='card'){
next.cards=[next.card];
}
else{
next.cards=[];
}
}
else if(next.card==undefined){
if(next.cards){
next.card=next.cards[0];
}
}
next.content=lib.element.playerproto.respond;
},
2015-11-05 02:34:35 +00:00
directgain:function(cards,animate){
2015-11-04 01:59:00 +00:00
var hs=this.get('h');
for(var i=0;i<cards.length;i++){
if(hs.contains(cards[i])){
cards.splice(i--,1);
}
}
2015-05-13 10:26:54 +00:00
for(var i=0;i<cards.length;i++){
var sort=lib.config.sort_card(cards[i]);
2015-11-05 02:34:35 +00:00
if(animate!==false){
cards[i].animate('start');
}
2015-10-31 10:14:14 +00:00
if(lib.isSingleHandcard()||sort>0){
2015-11-05 02:34:35 +00:00
this.node.handcards1.appendChild(cards[i]);
2015-05-13 10:26:54 +00:00
}
else{
2015-11-05 02:34:35 +00:00
this.node.handcards2.appendChild(cards[i]);
2015-05-13 10:26:54 +00:00
}
}
2015-11-04 01:59:00 +00:00
if(!_status.video){
game.addVideo('directgain',this,get.cardsInfo(cards));
this.update();
}
2015-05-13 10:26:54 +00:00
return this;
},
2015-04-29 03:25:17 +00:00
gain:function(){
var next=game.createEvent('gain');
next.player=this;
for(var i=0;i<arguments.length;i++){
if(get.itemtype(arguments[i])=='player'){
next.source=arguments[i];
}
else if(get.itemtype(arguments[i])=='cards'){
next.cards=arguments[i];
}
else if(get.itemtype(arguments[i])=='card'){
next.cards=[arguments[i]];
}
else if(typeof arguments[i]=='string'){
next.animate=arguments[i];
}
}
next.content=lib.element.playerproto.gain;
return next;
},
lose:function(){
var next=game.createEvent('lose');
next.player=this;
for(var i=0;i<arguments.length;i++){
if(get.itemtype(arguments[i])=='player'){
next.source=arguments[i];
}
else if(get.itemtype(arguments[i])=='cards'){
next.cards=arguments[i];
}
else if(get.itemtype(arguments[i])=='card'){
next.cards=[arguments[i]];
}
else if(get.objtype(arguments[i])=='div'){
next.position=arguments[i];
}
}
if(next.cards==undefined) _status.event.next.remove(next);
if(next.position==undefined) next.position=ui.discardPile;
next.content=lib.element.playerproto.lose;
return next;
},
damage:function(){
var next=game.createEvent('damage');
next.player=this;
var nocard,nosource;
var event=_status.event;
for(var i=0;i<arguments.length;i++){
if(get.itemtype(arguments[i])=='cards'){
next.cards=arguments[i];
}
else if(get.itemtype(arguments[i])=='card'){
next.card=arguments[i];
}
else if(typeof arguments[i]=='number'){
next.num=arguments[i];
}
else if(get.itemtype(arguments[i])=='player'){
next.source=arguments[i];
}
else if(typeof arguments[i]=='object'&&arguments[i].name){
next.card=arguments[i];
}
else if(arguments[i]=='nocard'){
nocard=true;
}
else if(arguments[i]=='nosource'){
nosource=true;
}
else if(get.itemtype(arguments[i])=='nature'){
next.nature=arguments[i];
}
}
if(next.card==undefined&&!nocard) next.card=event.card;
if(next.cards==undefined&&!nocard) next.cards=event.cards;
if(next.source==undefined&&!nosource) next.source=event.player;
if(next.num==undefined) next.num=1;
if(next.nature=='poison') delete next._triggered;
next.content=lib.element.playerproto.damage;
2015-09-25 00:26:16 +00:00
return next;
2015-04-29 03:25:17 +00:00
},
recover:function(){
var next=game.createEvent('recover');
next.player=this;
var nocard,nosource;
var event=_status.event;
for(var i=0;i<arguments.length;i++){
if(get.itemtype(arguments[i])=='cards'){
next.cards=arguments[i];
}
else if(get.itemtype(arguments[i])=='card'){
next.card=arguments[i];
}
else if(get.itemtype(arguments[i])=='player'){
next.source=arguments[i];
}
2015-11-01 07:54:42 +00:00
else if(typeof arguments[i]=='object'&&arguments[i].name){
next.card=arguments[i];
}
2015-04-29 03:25:17 +00:00
else if(typeof arguments[i]=='number'){
next.num=arguments[i];
}
else if(arguments[i]=='nocard'){
nocard=true;
}
else if(arguments[i]=='nosource'){
nosource=true;
}
}
if(next.card==undefined&&!nocard) next.card=event.card;
if(next.cards==undefined&&!nocard) next.cards=event.cards;
if(next.source==undefined&&!nosource) next.source=event.player;
if(next.num==undefined) next.num=1;
if(next.num<=0) _status.event.next.remove(next);
next.content=lib.element.playerproto.recover;
2015-11-01 07:54:42 +00:00
return next;
2015-04-29 03:25:17 +00:00
},
2015-04-29 10:02:31 +00:00
doubleDraw:function(){
var next=game.createEvent('doubleDraw');
next.player=this;
next.content=lib.element.playerproto.doubleDraw;
return next;
},
2015-04-29 03:25:17 +00:00
loseHp:function(num){
var next=game.createEvent('loseHp');
next.num=num;
next.player=this;
if(next.num==undefined) next.num=1;
next.content=lib.element.playerproto.loseHp;
},
2015-04-29 10:02:31 +00:00
loseMaxHp:function(){
2015-04-29 03:25:17 +00:00
var next=game.createEvent('loseMaxHp');
next.player=this;
2015-04-29 10:02:31 +00:00
next.num=1;
for(var i=0;i<arguments.length;i++){
if(typeof arguments[i]==='number'){
next.num=arguments[i];
}
else if(typeof arguments[i]==='boolean'){
next.forced=arguments[i];
}
}
2015-04-29 03:25:17 +00:00
next.content=lib.element.playerproto.loseMaxHp;
},
gainMaxHp:function(num){
var next=game.createEvent('gainMaxHp');
next.num=num;
next.player=this;
if(next.num==undefined) next.num=1;
next.content=lib.element.playerproto.gainMaxHp;
},
changeHp:function(num,popup){
var next=game.createEvent('changeHp',false);
next.num=num;
if(popup!=undefined) next.popup=popup;
next.player=this;
next.content=lib.element.playerproto.changeHp;
},
dying:function(reason){
var next=game.createEvent('dying',false);
next.player=this;
next.reason=reason;
next.source=reason.source;
next.content=lib.element.playerproto.dying;
},
die:function(reason){
var next=game.createEvent('die');
next.player=this;
next.reason=reason;
if(reason) next.source=reason.source;
next.content=lib.element.playerproto.die;
2015-05-05 09:23:31 +00:00
return next;
2015-04-29 03:25:17 +00:00
},
revive:function(hp){
game.log(get.translation(this)+'复活');
if(this.maxHp<1) this.maxHp=1;
if(hp) this.hp=hp;
2015-11-01 07:54:42 +00:00
else{
this.hp=1;
}
2015-11-04 01:59:00 +00:00
game.addVideo('revive',this);
2015-04-29 03:25:17 +00:00
this.classList.remove('dead');
this.removeAttribute('style');
2015-11-05 02:34:35 +00:00
this.node.avatar.style.transform='';
this.node.avatar2.style.transform='';
this.node.hp.show();
this.node.equips.show();
this.node.count.show();
2015-04-29 03:25:17 +00:00
this.update();
var player;
player=this.previousSeat;
while(player.isDead()) player=player.previousSeat;
player.next=this;
this.previous=player;
player=this.nextSeat;
while(player.isDead()) player=player.nextSeat;
player.previous=this;
this.next=player;
game.players.add(this);
game.dead.remove(this);
if(this==game.me){
if(ui.auto) ui.auto.show();
if(ui.wuxie) ui.wuxie.show();
2015-04-29 03:25:17 +00:00
if(ui.revive){
ui.revive.close();
delete ui.revive;
}
if(ui.swap){
ui.swap.close();
delete ui.swap;
}
if(ui.restart){
ui.restart.close();
delete ui.restart;
}
}
},
2015-05-13 10:26:54 +00:00
isMad:function(){
return this.skills.contains('mad');
},
goMad:function(){
this.addSkill('mad');
game.log(get.translation(this)+'进入混乱状态');
},
unMad:function(){
this.removeSkill('mad');
game.log(get.translation(this)+'解除混乱状态');
},
2015-04-29 03:25:17 +00:00
equip:function(card){
var next=game.createEvent('equip');
next.card=card;
next.player=this;
next.content=lib.element.playerproto.equip;
},
addJudge:function(card,cards){
var next=game.createEvent('addJudge');
next.card=card;
next.cards=cards;
if(next.cards==undefined) next.cards=[card];
if(get.itemtype(next.cards)=='card') next.cards=[next.cards];
next.player=this;
next.content=lib.element.playerproto.addJudge;
},
judge:function(){
var next=game.createEvent('judge');
next.player=this;
for(var i=0;i<arguments.length;i++){
if(get.itemtype(arguments[i])=='card'){
next.card=arguments[i];
}
else if(typeof arguments[i]=='string'){
next.skill=arguments[i];
}
else if(typeof arguments[i]=='function'){
next.judge=arguments[i];
}
else if(typeof arguments[i]=='boolean'){
next.clearArena=arguments[i];
}
else if(get.objtype(arguments[i])=='div'){
next.position=arguments[i];
}
}
if(next.card&&next.judge==undefined){
next.judge=get.judge(next.card);
}
if(next.judge==undefined) next.judge=function(){return 0};
if(next.position==undefined) next.position=ui.discardPile;
var str='';
if(next.card) str=get.translation(next.card.viewAs||next.card.name);
else if(next.skill) str=get.translation(next.skill);
else str=get.translation(_status.event.name);
next.judgestr=str;
next.content=lib.element.playerproto.judge;
},
turnOver:function(){
var next=game.createEvent('turnOver');
next.player=this;
next.content=lib.element.playerproto.turnOver;
},
out:function(bool){
if(this.lockOut) return;
if(this.isOut()){
game.log(get.translation(this)+'进入游戏');
}
else{
game.log(get.translation(this)+'离开游戏');
}
this.classList.toggle('out');
if(bool) this.lockOut=bool;
},
link:function(){
var next=game.createEvent('link');
next.player=this;
next.content=lib.element.playerproto.link;
},
skip:function(name){
this.skipList.add(name);
},
logSkill:function(name,targets,nature){
if(get.itemtype(targets)=='player') targets=[targets];
2015-08-15 09:10:06 +00:00
var nopop=false;
if(Array.isArray(name)){
this.popup(name[1]);
name=name[0];
nopop=true;
}
2015-05-04 03:17:03 +00:00
if(lib.translate[name]){
2015-08-15 09:10:06 +00:00
if(!nopop) this.popup(name);
2015-05-04 03:17:03 +00:00
if(typeof targets=='object'&&targets.length){
var str=get.translation(this)+'对'+get.translation(targets[0]);
for(var i=1;i<targets.length;i++){
str+='、'+get.translation(targets[i]);
}
str+='发动了'+get.translation(name);
game.log(str);
2015-04-29 03:25:17 +00:00
}
2015-05-04 03:17:03 +00:00
else{
game.log(get.translation(this)+'发动了'+get.translation(name));
2015-04-29 03:25:17 +00:00
}
}
2015-05-04 03:17:03 +00:00
if(nature!=false){
2015-05-16 11:40:11 +00:00
if(nature===undefined){
nature='green';
}
2015-05-04 03:17:03 +00:00
this.line(targets,nature);
2015-04-29 03:25:17 +00:00
}
if(lib.skill[name]&&lib.skill[name].ai&&lib.skill[name].ai.expose!=undefined&&this.logAi){
this.logAi(lib.skill[name].ai.expose);
}
if(this.checkShow){
this.checkShow(name);
}
2015-04-29 14:56:33 +00:00
var info=lib.skill[name];
if(info&&lib.config.background_speak){
2015-05-14 09:23:45 +00:00
if(typeof info.audio==='number'){
game.playAudio('skill',name+Math.ceil(info.audio*Math.random()));
}
else if(info.audio){
game.playAudio('skill',name);
}
else{
if(lib.config.background_ogg){
2015-05-16 11:22:27 +00:00
game.playSkillAudio(name);
2015-05-08 08:07:38 +00:00
}
}
2015-04-29 14:56:33 +00:00
}
2015-05-08 08:07:38 +00:00
if(lib.config.mode=='chess'){
this.chessFocus();
}
2015-04-29 03:25:17 +00:00
},
unprompt:function(){
if(this.node.prompt){
this.node.prompt.delete();
delete this.node.prompt;
}
},
prompt:function(name2,className){
var node;
if(this.node.prompt){
node=this.node.prompt;
node.innerHTML='';
node.className='popup';
}
else{
2015-05-08 08:07:38 +00:00
node=ui.create.div('.popup',this.parentNode);
2015-04-29 03:25:17 +00:00
this.node.prompt=node;
}
node.dataset.position=this.dataset.position;
2015-05-04 03:17:03 +00:00
if(this.dataset.position==0||parseInt(this.dataset.position)==parseInt(ui.arena.dataset.number)/2||
2015-05-03 15:17:15 +00:00
typeof name2=='number'||this.classList.contains('minskin')){
2015-04-29 03:25:17 +00:00
node.innerHTML=name2;
}
else{
for(var i=0;i<name2.length;i++){
node.innerHTML+=name2[i]+'<br/>';
}
}
if(className){
node.classList.add(className);
}
},
popup:function(name,className){
var name2=get.translation(name);
2015-05-08 08:07:38 +00:00
var node=ui.create.div('.popup',this.parentNode);
2015-08-15 09:10:06 +00:00
if(!name2){
node.remove();
return node;
}
2015-11-04 01:59:00 +00:00
game.addVideo('popup',this,[name,className]);
2015-04-29 03:25:17 +00:00
node.dataset.position=this.dataset.position;
2015-05-04 03:17:03 +00:00
if(this.dataset.position==0||parseInt(this.dataset.position)==parseInt(ui.arena.dataset.number)/2||
2015-05-03 15:17:15 +00:00
typeof name2=='number'||this.classList.contains('minskin')){
2015-04-29 03:25:17 +00:00
node.innerHTML=name2;
}
else{
for(var i=0;i<name2.length;i++){
node.innerHTML+=name2[i]+'<br/>';
}
}
if(className){
node.classList.add(className);
}
this.popups.push(node);
if(this.popups.length>1){
node.hide();
}
else{
var that=this;
setTimeout(function(){that._popup();},1000);
}
2015-06-12 05:35:29 +00:00
return node;
2015-04-29 03:25:17 +00:00
},
_popup:function(){
if(this.popups.length){
this.popups.shift().delete();
if(this.popups.length){
this.popups[0].show();
var that=this;
setTimeout(function(){that._popup();},1000);
}
}
},
markSkill:function(name,info,card){
2015-11-04 01:59:00 +00:00
if(get.itemtype(card)=='card'){
game.addVideo('markSkill',this,[name,get.cardInfo(card)]);
}
else{
game.addVideo('markSkill',this,[name]);
}
2015-04-29 03:25:17 +00:00
if(!info){
if(this.marks[name]){
return this;
}
if(lib.skill[name]){
info=lib.skill[name].intro;
}
if(!info){
return this;
}
}
if(this.marks[name]){
this.marks[name].info=info;
}
else{
if(card){
this.marks[name]=this.mark(card,info,name);
}
else{
this.marks[name]=this.mark(name,info);
}
}
return this;
},
unmarkSkill:function(name){
2015-11-04 01:59:00 +00:00
game.addVideo('unmarkSkill',this,name);
2015-04-29 03:25:17 +00:00
if(this.marks[name]){
this.marks[name].delete();
delete this.marks[name];
var info=lib.skill[name];
if(info&&info.intro&&info.intro.onunmark){
info.intro.onunmark(this.storage[name],this);
}
}
},
markCharacter:function(name,info,learn,learn2){
if(typeof name=='object'){
name=name.name;
}
if(!lib.character[name]) return this;
var node=ui.create.div('.card.mark',this.node.marks).setBackground(name,'character');
node.name=name+'_charactermark';
if(!info){
info={};
}
if(!info.name){
info.name=get.translation(name);
}
if(!info.content){
info.content=get.skillintro(name,learn,learn2)
}
node.info=info;
if(lib.config.touchscreen){
lib.setLongPress(node,ui.click.intro);
}
2015-11-09 17:04:18 +00:00
else if(lib.config.hover_all){
lib.setHover(node,ui.click.hoverplayer);
}
2015-04-29 03:25:17 +00:00
if(lib.config.right_info){
node.oncontextmenu=ui.click.rightplayer;
}
return node;
},
mark:function(name,info,skill){
if(get.itemtype(name)=='cards'){
var marks=[];
for(var i=0;i<name.length;i++){
marks.push(this.mark(name[i],info));
}
return marks;
}
else{
var node;
if(get.itemtype(name)=='card'){
node=name.copy('mark',this.node.marks);
node.suit=name.suit;
node.number=name.number;
name=name.name;
}
else{
node=ui.create.div('.card.mark',this.node.marks);
var str=lib.translate[name+'_bg'];
if(!str||str[0]=='+'||str[0]=='-'){
str=get.translation(name)[0];
}
ui.create.div('.background.skillmark',node).innerHTML=str;
// node.style.fontFamily=lib.config.card_font;
}
node.name=name;
node.skill=skill||name;
if(typeof info=='object'){
node.info=info;
}
else if(typeof info=='string'){
node.markidentifer=info;
}
if(lib.config.touchscreen){
lib.setLongPress(node,ui.click.intro);
}
2015-11-09 17:04:18 +00:00
else if(lib.config.hover_all){
lib.setHover(node,ui.click.hoverplayer);
}
2015-04-29 03:25:17 +00:00
if(lib.config.right_info){
node.oncontextmenu=ui.click.rightplayer;
}
return node;
}
},
unmark:function(name,info){
2015-11-04 01:59:00 +00:00
game.addVideo('unmarkname',this,name);
2015-04-29 03:25:17 +00:00
if(get.itemtype(name)=='card'){
this.unmark(name.name,info);
}
else if(get.itemtype(name)=='cards'){
for(var i=0;i<name.length;i++){
this.unmark(name[i].name,info);
}
}
else{
for(var i=0;i<this.node.marks.childNodes.length;i++){
if(this.node.marks.childNodes[i].name==name&&
(!info||this.node.marks.childNodes[i].markidentifer==info)){
this.node.marks.childNodes[i].delete();
return;
}
}
}
},
canUse:function(card,player,distance,includecard){
if(typeof card=='string') card={name:card};
if(includecard&&!lib.filter.filterCard(card,this)) return false;
if(distance==false) return lib.filter.targetEnabled(card,this,player);
return lib.filter.filterTarget(card,this,player);
},
addSkill:function(skill){
if(get.objtype(skill)=='array'){
for(var i=0;i<skill.length;i++){
this.addSkill(skill[i]);
}
}
else{
if(!lib.skill[skill]) return;
if(this.skills.contains(skill)) return;
this.skills.add(skill);
if(lib.skill[skill].global){
if(typeof lib.skill[skill].global=='string'){
lib.skill.global.add(lib.skill[skill].global);
}
else{
for(var j=0;j<lib.skill[skill].global.length;j++){
lib.skill.global.add(lib.skill[skill].global[j])
}
}
}
if(lib.skill[skill].init){
if(!this.initedSkills.contains(skill)){
lib.skill[skill].init(this);
this.initedSkills.push(skill);
}
}
if(lib.skill[skill].init2){
lib.skill[skill].init2(this);
}
if(lib.skill[skill].mark){
if(lib.skill[skill].mark=='card'&&
2015-06-10 09:10:24 +00:00
get.itemtype(this.storage[skill])=='card'){
this.markSkill(skill,null,this.storage[skill]);
}
else if(lib.skill[skill].mark=='image'){
this.markSkill(skill,null,ui.create.card(null,'noclick').init([null,null,skill]));
2015-04-29 03:25:17 +00:00
}
else{
this.markSkill(skill);
}
}
}
this.checkConflict();
return skill;
},
checkMarks:function(){
var skills=this.get('s');
for(var i in this.marks){
if(!skills.contains(i)&&!this.marks[i].info.fixed){
this.unmarkSkill(i);
}
}
return this;
},
removeSkill:function(skill){
this.unmarkSkill(skill);
this.skills.remove(skill);
this.checkConflict();
return skill;
},
addTempSkill:function(skill,expire){
if(this.skills.contains(skill)&&this.tempSkills[skill]==undefined) return;
this.addSkill(skill);
this.tempSkills[skill]=expire;
this.checkConflict();
return skill;
},
attitudeTo:function(target){
if(typeof ai.get.attitude=='function') return ai.get.attitude(this,target);
return 0;
},
clearSkills:function(){
var list=[];
var exclude=[];
for(var i=0;i<arguments.length;i++) exclude.push(arguments[i]);
for(i=0;i<this.skills.length;i++){
if(this.modeSkills.contains(this.skills[i])==false&&
exclude.contains(this.skills[i])==false){
list.push(this.skills[i]);
}
}
this.skills.remove(list);
this.checkConflict();
this.checkMarks();
return list;
},
checkConflict:function(){
if(this.name&&this.name2){
this.forbiddenSkills.length=0;
var forbid=[];
2015-10-30 09:13:19 +00:00
var getName=function(arr){
var str='';
for(var i=0;i<arr.length;i++){
str+=arr[i]+'+';
}
return str.slice(0,str.length-1);
}
2015-04-29 03:25:17 +00:00
for(var i=0;i<lib.config.forbid.length;i++){
2015-10-30 09:13:19 +00:00
if(!lib.config.forbidlist.contains(getName(lib.config.forbid[i]))){
2015-04-29 03:25:17 +00:00
for(var j=0;j<lib.config.forbid[i].length;j++){
if(this.skills.contains(lib.config.forbid[i][j])==false) break;
}
if(j==lib.config.forbid[i].length) forbid.push(lib.config.forbid[i]);
}
}
for(var i=0;i<forbid.length;i++){
this.forbiddenSkills.add(forbid[i][0]);
}
}
},
getStat:function(key){
if(!key) return this.stat[this.stat.length-1];
return this.stat[this.stat.length-1][key];
},
queue:function(time){
if(time==false){
clearTimeout(this.queueTimeout);
this.queueCount=0;
return;
}
if(time==undefined) time=500;
var player=this;
player.queueCount++;
this.queueTimeout=setTimeout(function(){
player.queueCount--;
if(player.queueCount==0){
player.removeAttribute('style');
2015-10-31 10:14:14 +00:00
player.node.avatar.style.transform='';
2015-11-04 01:59:00 +00:00
player.node.avatar2.style.transform='';
2015-04-29 03:25:17 +00:00
if(player==game.me) ui.me.removeAttribute('style');
}
},time)
},
isAlive:function(){
return this.classList.contains('dead')==false;
},
isDead:function(){
return this.classList.contains('dead');
},
isLinked:function(){
return this.classList.contains('linked');
},
isTurnedOver:function(){
return this.classList.contains('turnedover');
},
isOut:function(){
return this.classList.contains('out');
},
2015-05-12 09:51:40 +00:00
isMin:function(distance){
if(distance&&lib.config.mode!='stone') return false;
if(this.forcemin) return true;
2015-05-08 08:07:38 +00:00
return this.classList.contains('minskin')&&lib.config.mode!='chess';
2015-05-03 15:17:15 +00:00
},
2015-04-29 03:25:17 +00:00
isIn:function(){
return this.classList.contains('dead')==false&&this.classList.contains('out')==false&&!this.removed;
},
2015-05-01 07:35:43 +00:00
isUnderControl:function(){
2015-05-08 08:07:38 +00:00
if(this===game.me) return false;
2015-05-13 10:26:54 +00:00
if(this.isMad()) return false;
2015-05-01 07:35:43 +00:00
if(lib.config.mode=='versus'){
return ui.autoreplace&&ui.autoreplace.classList.contains('on')&&
2015-05-08 08:07:38 +00:00
this.side==game.me.side;
}
2015-05-13 10:26:54 +00:00
else if(lib.config.mode=='chess'||lib.config.mode=='boss'){
2015-05-08 08:07:38 +00:00
return this.side==game.me.side;
2015-05-01 07:35:43 +00:00
}
return false;
2015-04-29 03:25:17 +00:00
},
hasSkillTag:function(tag,hidden){
var skills=game.expandSkills(this.get('s',hidden));
for(var i=0;i<skills.length;i++){
var info=lib.skill[skills[i]];
2015-05-04 03:17:03 +00:00
if(info&&info.ai){
if(info.ai.skillTagFilter&&
info.ai.skillTagFilter(this,tag)===false) continue;
if(info.ai[tag]) return true;
}
2015-04-29 03:25:17 +00:00
}
return false;
},
hasJudge:function(name){
var judges=this.node.judges.childNodes;
for(var i=0;i<judges.length;i++){
if((judges[i].viewAs||judges[i].name)==name){
return true;
}
}
return false;
},
2015-05-05 14:57:35 +00:00
hasFriend:function(){
for(var i=0;i<game.players.length;i++){
if(game.players[i]!=this&&ai.get.attitude(game.players[i],this)>=0){
return true;
}
}
return false;
},
2015-05-02 06:59:31 +00:00
getJudge:function(name){
var judges=this.node.judges.childNodes;
for(var i=0;i<judges.length;i++){
if((judges[i].viewAs||judges[i].name)==name){
return judges[i];
}
}
return null;
},
2015-11-04 01:59:00 +00:00
$draw:function(num,init){
2015-04-29 03:25:17 +00:00
var cards,node;
if(get.itemtype(num)=='cards'){
cards=num;
num=cards.length;
}
else if(get.itemtype(num)=='card'){
cards=[num];
num=1;
}
2015-11-04 01:59:00 +00:00
if(init!==false){
if(cards){
game.addVideo('drawCard',this,get.cardsInfo(cards));
}
else{
game.addVideo('draw',this,num);
}
}
2015-04-29 03:25:17 +00:00
if(cards){
cards=cards.slice(0);
node=cards.shift().copy('drawing','thrown');
}
else{
node=ui.create.div('.card.drawing.thrown');
}
node.fixed=true;
node.dataset.position=this.dataset.position;
2015-05-08 08:07:38 +00:00
this.parentNode.appendChild(node);
2015-04-29 03:25:17 +00:00
setTimeout(function(){
node.remove();
},1000);
var that=this;
if(num&&num>1){
setTimeout(function(){
if(cards){
2015-11-04 01:59:00 +00:00
that.$draw(cards,false)
2015-04-29 03:25:17 +00:00
}
else{
2015-11-04 01:59:00 +00:00
that.$draw(num-1,false)
2015-04-29 03:25:17 +00:00
}
},200);
}
},
$compare:function(card1,target,card2){
2015-11-04 01:59:00 +00:00
game.addVideo('compare',this,[get.cardInfo(card1),target.dataset.position,get.cardInfo(card2)]);
2015-04-29 03:25:17 +00:00
var player=this;
var node1=player.$throwxy(card1,
'calc(50% - 114px)','calc(50% - 52px)'
);
node1.classList.add('infohidden');
2015-11-06 10:05:08 +00:00
node1.classList.add('thrownhighlight');
2015-11-05 02:34:35 +00:00
node1.style.transform='perspective(600px) rotateY(180deg) translateX(0)';
2015-04-29 03:25:17 +00:00
setTimeout(function(){
setTimeout(function(){
node1.style.transition='all ease-in 0.3s';
2015-11-05 02:34:35 +00:00
node1.style.transform='perspective(600px) rotateY(270deg) translateX(52px)';
var onEnd=function(){
2015-04-29 03:25:17 +00:00
node1.classList.remove('infohidden');
node1.classList.add('cardflip');
2015-11-05 02:34:35 +00:00
node1.style.transform='none';
2015-04-29 03:25:17 +00:00
node1.style.transition='';
2015-11-05 02:34:35 +00:00
}
// node1.addEventListener('transitionEnd',onEnd);
node1.addEventListener('webkitTransitionEnd',onEnd);
2015-04-29 03:25:17 +00:00
},600);
var node2=target.$throwxy(card2,
'calc(50% + 10px)','calc(50% - 52px)'
);
node2.classList.add('infohidden');
2015-11-06 10:05:08 +00:00
node2.classList.add('thrownhighlight');
2015-11-05 02:34:35 +00:00
node2.style.transform='perspective(600px) rotateY(180deg) translateX(0)';
2015-04-29 03:25:17 +00:00
setTimeout(function(){
node2.style.transition='all ease-in 0.3s';
2015-11-05 02:34:35 +00:00
node2.style.transform='perspective(600px) rotateY(270deg) translateX(52px)';
var onEnd=function(){
2015-04-29 03:25:17 +00:00
node2.classList.remove('infohidden');
node2.classList.add('cardflip');
2015-11-05 02:34:35 +00:00
node2.style.transform='none';
2015-04-29 03:25:17 +00:00
node2.style.transition='';
2015-11-05 02:34:35 +00:00
}
// node2.addEventListener('transitionEnd',onEnd);
node2.addEventListener('webkitTransitionEnd',onEnd);
2015-04-29 03:25:17 +00:00
},700);
},200);
},
2015-11-04 01:59:00 +00:00
$throw:function(card,time,init){
if(init!==false){
if(get.itemtype(card)!='cards'){
if(get.itemtype(card)=='card'){
card=[card];
}
else{
return;
}
}
game.addVideo('throw',this,[get.cardsInfo(card),time]);
}
2015-04-29 03:25:17 +00:00
if(get.itemtype(card)=='cards'){
for(var i=0;i<card.length;i++){
2015-11-04 01:59:00 +00:00
this.$throw(card[i],time,false);
2015-04-29 03:25:17 +00:00
}
}
else{
if(card==undefined||card.length==0) return;
2015-11-06 10:05:08 +00:00
if(false){
var node=this.$throwxy(card,
'calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*100+'px)',
'calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*80+'px)',true
);
}
else{
var node=this.$throwordered(card.copy('thrown'));
}
2015-04-29 03:25:17 +00:00
if(time!=undefined){
node.fixed=true;
setTimeout(function(){node.delete()},time);
}
}
},
2015-11-06 10:05:08 +00:00
$throwordered:function(node,nosource){
if(nosource){
node.style.transform='scale(0)';
2015-11-09 03:15:16 +00:00
node.classList.add('center');
2015-11-06 10:05:08 +00:00
}
else{
node.dataset.position=this.dataset.position;
}
node.classList.add('thrown');
node.hide();
node.style.transitionProperty='left,top,opacity,transform';
ui.arena.appendChild(node);
ui.refresh(node);
if(nosource){
node.style.transform='';
}
node.show();
for(var i=0;i<ui.thrown.length;i++){
if(ui.thrown[i].parentNode!=ui.arena||
ui.thrown[i].classList.contains('removing')){
ui.thrown.splice(i--,1);
}
}
ui.thrown.push(node);
var uithrowns=ui.thrown.slice(0);
var row=0;
var tops;
switch(Math.floor((ui.thrown.length-1)/4)){
case 0:
tops=['calc(50% - 52px)'];
break;
case 1:
tops=['calc(50% - 109px)','calc(50% + 5px)'];
break;
case 2:
tops=['calc(50% - 166px)','calc(50% - 52px)','calc(50% + 62px)'];
break;
default:
tops=['calc(50% - 223px)','calc(50% - 109px)',
'calc(50% + 5px)','calc(50% + 119px)'];
}
while(uithrowns.length){
var throwns=uithrowns.splice(0,Math.min(uithrowns.length,4));
switch(throwns.length){
case 1:
throwns[0].style.left='calc(50% - 52px)';
break;
case 2:
throwns[0].style.left='calc(50% - 109px)';
throwns[1].style.left='calc(50% + 5px)';
break;
case 3:
throwns[0].style.left='calc(50% - 166px)';
throwns[1].style.left='calc(50% - 52px)';
throwns[2].style.left='calc(50% + 62px)';
break;
case 4:
throwns[0].style.left='calc(50% - 223px)';
throwns[1].style.left='calc(50% - 109px)';
throwns[2].style.left='calc(50% + 5px)';
throwns[3].style.left='calc(50% + 119px)';
break;
}
var top;
if(tops.length){
top=tops.shift();
}
else{
top='calc(50% - 52px)';
}
for(var i=0;i<throwns.length;i++){
throwns[i].style.top=top;
}
}
return node;
},
2015-04-29 03:25:17 +00:00
$throwxy:function(card,left,top,transform){
var node=card.copy('thrown');
node.dataset.position=this.dataset.position;
node.hide();
node.style.transitionProperty='left,top,opacity';
if(transform){
2015-11-05 02:34:35 +00:00
node.style.transform='rotate('+(Math.random()*16-8)+'deg)';
2015-04-29 03:25:17 +00:00
}
ui.arena.appendChild(node);
ui.refresh(node);
node.show();
node.style.left=left;
node.style.top=top;
return node;
},
2015-11-04 01:59:00 +00:00
$give:function(card,player,log,init){
if(init!==false){
if(typeof card=='number'&&card>=0){
game.addVideo('give',this,[card,player.dataset.position]);
}
else{
if(get.itemtype(card)=='card'){
card=[card];
}
if(get.itemtype(card)=='cards'){
game.addVideo('giveCard',this,[get.cardsInfo(card),player.dataset.position]);
}
}
}
2015-04-29 03:25:17 +00:00
if(get.itemtype(card)=='cards'){
if(log!=false){
var str=get.translation(player)+'从'+get.translation(this)+'获得了'+get.translation(card[0]);
for(var i=1;i<card.length;i++){
str+='、'+get.translation(card[i]);
}
game.log(str);
}
2015-05-08 08:07:38 +00:00
if(this.$givemod){
this.$givemod(card,player);
}
else{
for(var i=0;i<card.length;i++){
2015-11-04 01:59:00 +00:00
this.$give(card[i],player,false,false);
2015-05-08 08:07:38 +00:00
}
2015-04-29 03:25:17 +00:00
}
}
2015-05-04 03:17:03 +00:00
else if(typeof card=='number'&&card>=0){
2015-04-29 03:25:17 +00:00
if(log!=false){
game.log(get.translation(player)+'从'+get.translation(this)+'获得了'+get.cnNumber(card)+'张牌');
}
2015-05-08 08:07:38 +00:00
if(this.$givemod){
this.$givemod(card,player);
}
else{
2015-11-04 01:59:00 +00:00
while(card--) this.$give('',player,false,false);
2015-05-08 08:07:38 +00:00
}
2015-04-29 03:25:17 +00:00
}
else{
if(log!=false){
if(get.itemtype(card)=='card'&&log!=false){
game.log(get.translation(player)+'从'+get.translation(this)+'获得了'+get.translation(card));
}
else{
game.log(get.translation(player)+'从'+get.translation(this)+'获得了一张牌');
}
}
2015-05-08 08:07:38 +00:00
if(this.$givemod){
this.$givemod(card,player);
2015-04-29 03:25:17 +00:00
}
else{
2015-05-08 08:07:38 +00:00
var node;
if(get.itemtype(card)=='card'){
node=card.copy('card','thrown',false);
}
else{
node=ui.create.div('.card.thrown');
}
node.dataset.position=this.dataset.position;
node.fixed=true;
2015-11-06 10:05:08 +00:00
this.$throwordered(node);
// node.hide();
// node.style.transitionProperty='left,top,opacity';
//
// node.style.transform='rotate('+(Math.random()*16-8)+'deg)';
//
// ui.arena.appendChild(node);
// ui.refresh(node);
// node.show();
// node.style.left='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*100+'px)';
// node.style.top='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*80+'px)';
2015-05-08 08:07:38 +00:00
setTimeout(function(){
node.removeAttribute('style');
node.dataset.position=player.dataset.position;
node.delete();
},700);
}
2015-04-29 03:25:17 +00:00
}
},
2015-11-04 01:59:00 +00:00
$equip:function(card){
var player=this;
var equipNum=get.equipNum(card);
var equipped=false;
for(var i=0;i<player.node.equips.childNodes.length;i++){
if(get.equipNum(player.node.equips.childNodes[i])>=equipNum){
player.node.equips.insertBefore(card,player.node.equips.childNodes[i]);
equipped=true;
break;
}
}
if(!equipped){
player.node.equips.appendChild(card);
}
player.node.equips.dataset.number=player.num('e');
return player;
},
$gain:function(card,log,init){
if(init!==false){
if(typeof card=='number'&&card>=0){
game.addVideo('gain',this,card);
}
else{
if(get.itemtype(card)=='card'){
card=[card];
}
if(get.itemtype(card)=='cards'){
game.addVideo('gainCard',this,get.cardsInfo(card));
}
else{
game.addVideo('gain',this,1);
}
}
}
2015-04-29 03:25:17 +00:00
if(get.itemtype(card)=='cards'){
if(log!=false){
var str=get.translation(this)+'获得了'+get.translation(card[0]);
for(var i=1;i<card.length;i++){
str+='、'+get.translation(card[i]);
}
game.log(str);
}
2015-05-08 08:07:38 +00:00
if(this.$gainmod){
this.$gainmod(card);
}
else{
for(var i=0;i<card.length;i++){
2015-11-04 01:59:00 +00:00
this.$gain(card[i],false,false);
2015-05-08 08:07:38 +00:00
}
2015-04-29 03:25:17 +00:00
}
}
else if(typeof card=='number'&&card>1){
if(log!=false){
game.log(get.translation(this)+'获得了'+get.cnNumber(card)+'张牌');
}
2015-05-08 08:07:38 +00:00
if(this.$gainmod){
this.$gainmod(card);
}
else{
for(var i=0;i<card;i++){
2015-11-04 01:59:00 +00:00
this.$gain(1,false,false);
2015-05-08 08:07:38 +00:00
}
2015-04-29 03:25:17 +00:00
}
}
else{
if(get.itemtype(card)=='card'&&log!=false){
game.log(get.translation(this)+'获得了'+get.translation(card));
}
2015-05-08 08:07:38 +00:00
if(this.$gainmod){
this.$gainmod(card);
2015-04-29 03:25:17 +00:00
}
else{
2015-05-08 08:07:38 +00:00
var node;
if(get.itemtype(card)=='card'){
node=card.copy('thrown',false);
}
else{
node=ui.create.div('.card.thrown');
node.moveTo=lib.element.card.moveTo;
}
node.fixed=true;
node.style.left='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*100+'px)';
node.style.top='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*100+'px)';
2015-11-05 02:34:35 +00:00
node.style.transform='scale(0)';
2015-05-08 08:07:38 +00:00
var player=this;
node.hide();
ui.arena.appendChild(node);
ui.refresh(node);
node.show();
2015-11-05 02:34:35 +00:00
node.style.transform='';
2015-05-08 08:07:38 +00:00
setTimeout(function(){
node.moveTo(player).delete();
},700);
}
2015-04-29 03:25:17 +00:00
}
},
$gain2:function(cards,log){
if(get.itemtype(cards)=='card') cards=[cards];
else if(get.itemtype(cards)!='cards') return;
2015-11-04 01:59:00 +00:00
var list=[],list2=[];
2015-04-29 03:25:17 +00:00
for(var i=0;i<cards.length;i++){
2015-05-08 08:07:38 +00:00
if(cards[i].clone&&cards[i].clone.parentNode==this.parentNode&&
2015-11-05 02:34:35 +00:00
parseFloat(getComputedStyle(cards[0].clone).opacity)>0.3){
2015-04-29 03:25:17 +00:00
cards[i].clone.moveTo(this).delete();
2015-11-04 01:59:00 +00:00
list2.push(cards[i].clone);
2015-04-29 03:25:17 +00:00
}
else{
list.push(cards[i]);
}
}
2015-11-04 01:59:00 +00:00
if(list2.length){
game.addVideo('gain2',this,get.cardsInfo(list2));
}
2015-04-29 03:25:17 +00:00
if(list.length) this.$draw(list);
},
2015-09-25 00:26:16 +00:00
$fire:function(){
2015-11-04 01:59:00 +00:00
game.addVideo('flame',this,'fire');
2015-09-30 07:24:45 +00:00
var left,top;
if(lib.config.mode=='chess'){
var rect=this.getBoundingClientRect();
left=rect.left;
top=rect.top;
}
else{
left=this.offsetLeft;
top=this.offsetTop;
}
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-20,700,'fire');
2015-09-25 00:26:16 +00:00
},
$thunder:function(){
2015-11-04 01:59:00 +00:00
game.addVideo('flame',this,'thunder');
2015-09-30 07:24:45 +00:00
var left,top;
if(lib.config.mode=='chess'){
var rect=this.getBoundingClientRect();
left=rect.left;
top=rect.top;
}
else{
left=this.offsetLeft;
top=this.offsetTop;
}
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,700,'thunder');
2015-09-25 00:26:16 +00:00
},
2015-11-09 03:15:16 +00:00
$rare2:function(){
game.addVideo('flame',this,'rare2');
var rect=this.getBoundingClientRect();
var left=rect.left;
var top=rect.top+15;
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,700,'rare');
},
$epic2:function(){
game.addVideo('flame',this,'epic2');
var rect=this.getBoundingClientRect();
var left=rect.left;
var top=rect.top+15;
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,700,'epic');
},
$legend2:function(){
game.addVideo('flame',this,'legend2');
var rect=this.getBoundingClientRect();
var left=rect.left;
var top=rect.top+15;
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,700,'legend');
},
2015-10-20 17:44:00 +00:00
$rare:function(){
2015-11-04 01:59:00 +00:00
game.addVideo('flame',this,'rare');
2015-11-07 09:20:15 +00:00
var left,top;
if(lib.config.mode=='chess'){
left=this.offsetLeft-ui.arena.offsetLeft;
top=this.offsetTop-ui.arena.offsetTop;
}
else{
left=this.offsetLeft;
top=this.offsetTop;
}
2015-10-20 17:44:00 +00:00
if(this.classList.contains('minskin')){
top+=15;
}
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,700,'rare');
},
$epic:function(){
2015-11-04 01:59:00 +00:00
game.addVideo('flame',this,'epic');
2015-11-07 09:20:15 +00:00
var left,top;
if(lib.config.mode=='chess'){
left=this.offsetLeft-ui.arena.offsetLeft;
top=this.offsetTop-ui.arena.offsetTop;
}
else{
left=this.offsetLeft;
top=this.offsetTop;
}
2015-10-20 17:44:00 +00:00
if(this.classList.contains('minskin')){
top+=15;
}
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,700,'epic');
},
$legend:function(){
2015-11-04 01:59:00 +00:00
game.addVideo('flame',this,'legend');
2015-11-07 09:20:15 +00:00
var left,top;
if(lib.config.mode=='chess'){
left=this.offsetLeft-ui.arena.offsetLeft;
top=this.offsetTop-ui.arena.offsetTop;
}
else{
left=this.offsetLeft;
top=this.offsetTop;
}
2015-10-20 17:44:00 +00:00
if(this.classList.contains('minskin')){
top+=15;
}
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,700,'legend');
},
$coin:function(){
2015-11-04 01:59:00 +00:00
game.addVideo('flame',this,'coin');
2015-10-20 17:44:00 +00:00
var left=this.offsetLeft-ui.arena.offsetLeft;
var top=this.offsetTop-ui.arena.offsetTop;
if(this.classList.contains('minskin')){
top+=15;
}
top-=25;
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,700,'coin');
},
$dust:function(){
2015-11-04 01:59:00 +00:00
game.addVideo('flame',this,'dust');
2015-10-20 17:44:00 +00:00
var left=this.offsetLeft-ui.arena.offsetLeft;
var top=this.offsetTop-ui.arena.offsetTop;
if(this.classList.contains('minskin')){
top+=15;
}
top-=25;
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,700,'dust');
},
2015-09-26 13:11:55 +00:00
$recover:function(){
2015-11-04 01:59:00 +00:00
game.addVideo('flame',this,'recover');
2015-09-30 07:24:45 +00:00
var left,top;
if(lib.config.mode=='chess'){
var rect=this.getBoundingClientRect();
left=rect.left;
top=rect.top;
}
else{
left=this.offsetLeft;
top=this.offsetTop;
}
game.animate.flame(left+this.offsetWidth/2,
top+this.offsetHeight-30,700,'recover');
2015-09-26 13:11:55 +00:00
},
2015-11-06 10:05:08 +00:00
$sha:function(nature){
if(this._shaing){
return;
}
this._shaing=true;
var player=this;
setTimeout(function(){
player._shaing=false;
},1000);
var node=ui.create.div('.cardeffect',this);
node.innerHTML='殺';
node.dataset.nature=nature||'black';
return node;
},
2015-09-26 13:11:55 +00:00
$damagepop:function(num,nature){
if(typeof num=='number'){
2015-11-04 01:59:00 +00:00
game.addVideo('damagepop',this,[num,nature]);
2015-09-26 13:11:55 +00:00
var node=ui.create.div('.damage');
if(num>0){
num='+'+num;
}
node.innerHTML=num;
this.damagepopups.push(node);
node.dataset.nature=nature||'soil';
if(this.damagepopups.length==1){
this.$damagepop();
}
}
else if(this.damagepopups.length){
var node=this.damagepopups[0];
this.appendChild(node);
ui.refresh(node);
node.classList.add('damageadded');
setTimeout(function(){
node.delete();
},500);
var that=this;
setTimeout(function(){
that.damagepopups.shift();
that.$damagepop();
},500);
}
},
2015-04-29 03:25:17 +00:00
$damage:function(source){
2015-11-04 01:59:00 +00:00
if(get.itemtype(source)=='player'){
game.addVideo('damage',this,source.dataset.position);
}
else{
game.addVideo('damage',this);
}
2015-04-29 03:25:17 +00:00
if(source&&source!=this){
var left,top;
if(source.offsetTop==this.offsetTop){
left=20;
top=0;
}
else{
var ratio=(source.offsetLeft-this.offsetLeft)/(source.offsetTop-this.offsetTop);
left=Math.abs(20*ratio/Math.sqrt(1+ratio*ratio));
top=Math.abs(20/Math.sqrt(1+ratio*ratio));
}
if(source.offsetLeft-this.offsetLeft>0) left=-left;
if(source.offsetTop-this.offsetTop>0) top=-top;
2015-10-31 10:14:14 +00:00
if(lib.isMobileMe(this)){
if(this.isLinked()){
2015-11-05 02:34:35 +00:00
this.node.avatar.style.transform='translate('+left+'px,'+top+'px) rotate(-90deg)';
this.node.avatar2.style.transform='translate('+left+'px,'+top+'px) rotate(-90deg)';
2015-10-31 10:14:14 +00:00
}
else{
2015-11-05 02:34:35 +00:00
this.node.avatar.style.transform='translate('+left+'px,'+top+'px)';
this.node.avatar2.style.transform='translate('+left+'px,'+top+'px)';
2015-10-31 10:14:14 +00:00
}
}
else if(this.isLinked()&&lib.isNewLayout()){
2015-11-05 02:34:35 +00:00
this.style.transform='translate('+left+'px,'+top+'px) rotate(-90deg)';
2015-04-29 03:25:17 +00:00
}
else{
2015-11-05 02:34:35 +00:00
this.style.transform='translate('+left+'px,'+top+'px)';
2015-04-29 03:25:17 +00:00
}
}
else{
2015-10-31 10:14:14 +00:00
if(lib.isMobileMe(this)){
if(this.isLinked()){
2015-11-05 02:34:35 +00:00
this.node.avatar.style.transform='scale(0.9) rotate(-90deg)';
this.node.avatar2.style.transform='scale(0.9) rotate(-90deg)';
2015-10-31 10:14:14 +00:00
}
else{
2015-11-05 02:34:35 +00:00
this.node.avatar.style.transform='scale(0.9)';
this.node.avatar2.style.transform='scale(0.9)';
2015-10-31 10:14:14 +00:00
}
}
else if(this.isLinked()&&lib.isNewLayout()){
2015-11-05 02:34:35 +00:00
this.style.transform='scale(0.95) rotate(-90deg)';
2015-04-29 03:25:17 +00:00
}
else{
2015-11-05 02:34:35 +00:00
this.style.transform='scale(0.95)';
2015-04-29 03:25:17 +00:00
}
}
this.queue();
},
$die:function(){
2015-11-04 01:59:00 +00:00
game.addVideo('die',this);
2015-04-29 03:25:17 +00:00
var top0=ui.window.offsetHeight/2;
var left0=ui.window.offsetWidth/2;
var ratio=(left0-this.offsetLeft)/(top0-this.offsetTop);
var left=Math.abs(50*ratio/Math.sqrt(1+ratio*ratio));
var top=Math.abs(50/Math.sqrt(1+ratio*ratio));
if(left0-this.offsetLeft>0) left=-left;
if(top0-this.offsetTop>0) top=-top;
2015-11-05 02:34:35 +00:00
if(lib.isMobileMe(this)){
left=-Math.random()*5-10;
top=Math.random()*5+10;
}
var transform='translate('+left+'px,'+top+'px) '+
2015-04-29 03:25:17 +00:00
'rotate('+(Math.random()*20-10)+'deg) '+
((Math.random()-0.5<0)?'rotateX(180deg)':'rotateY(180deg)');
2015-11-05 02:34:35 +00:00
if(lib.isMobileMe(this)){
this.node.avatar.style.transform=transform;
this.node.avatar2.style.transform=transform;
}
else{
this.style.transform=transform;
}
2015-04-29 03:25:17 +00:00
this.queue(false);
},
2015-05-08 08:07:38 +00:00
$phaseJudge:function(card){
2015-11-04 01:59:00 +00:00
game.addVideo('phaseJudge',this,get.cardInfo(card));
2015-05-08 08:07:38 +00:00
var player=this;
2015-11-06 10:05:08 +00:00
var clone=card.copy('thrown','thrownhighlight',ui.arena).animate('judgestart');
2015-05-08 08:07:38 +00:00
clone.style.opacity=0.6;
clone.style.left='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*50+'px)';
clone.style.top='calc(50% - 52px '+((Math.random()-0.5<0)?'+':'-')+' '+Math.random()*40+'px)';
game.delay();
game.linexy([
clone.offsetLeft+clone.offsetWidth/2,
clone.offsetTop+clone.offsetHeight/2,
player.offsetLeft+player.offsetWidth/2,
player.offsetTop+player.offsetHeight/2
2015-08-15 09:10:06 +00:00
],{opacity:0.5,dashed:true});
2015-05-08 08:07:38 +00:00
}
2015-04-29 03:25:17 +00:00
},
card:{
init:function(card){
var bg=card[2];
if(!lib.config.hide_card_image&&lib.card[card[2]].fullskin){
this.classList.add('fullskin');
this.node.image.style.backgroundImage='url("image/card/'+card[2]+'.png")'
}
else if(lib.card[card[2]].image=='background'){
if(card[3]) this.node.background.setBackground(bg+'_'+card[3],'card');
else this.node.background.setBackground(bg,'card');
}
else if(lib.card[card[2]].image=='card'){
if(card[3]) this.setBackground(bg+'_'+card[3],'card');
else this.setBackground(bg,'card');
}
else if(typeof lib.card[card[2]].image=='string'){
this.setBackground(lib.card[card[2]].image);
}
else{
this.node.background.innerHTML=lib.translate[bg+'_bg']||get.translation(bg)[0];
// this.node.background.style.fontFamily=lib.config.card_font;
if(this.node.background.innerHTML.length>1) this.node.background.classList.add('tight');
else this.node.background.classList.remove('tight');
}
2015-09-22 03:53:35 +00:00
if(lib.card[card[2]].noname){
this.node.name.style.display='none';
}
2015-04-29 03:25:17 +00:00
if(lib.card[card[2]].color){
this.style.color=lib.card[card[2]].color;
}
if(lib.card[card[2]].textShadow){
this.style.textShadow=lib.card[card[2]].textShadow;
}
if(lib.card[card[2]].opacity){
this.node.info.style.opacity=lib.card[card[2]].opacity;
this.node.name.style.opacity=lib.card[card[2]].opacity;
}
2015-05-04 14:27:10 +00:00
if(lib.card[card[2]].modinfo){
this.node.info.innerHTML=lib.card[card[2]].modinfo;
}
else{
this.node.info.innerHTML=get.translation(card[0])+' '+card[1];
}
if(lib.card[card[2]].addinfo){
this.node.addinfo=ui.create.div('.addinfo',this);
this.node.addinfo.innerHTML=lib.card[card[2]].addinfo;
}
2015-04-29 03:25:17 +00:00
if(card[0]=='heart'||card[0]=='diamond'){
this.node.info.classList.add('red');
}
this.node.name.innerHTML='';
var name=get.translation(card[2]);
if(card[2]=='sha'){
if(card[3]=='fire'){
name='火'+name;
this.node.image.classList.add('fire');
}
else if(card[3]=='thunder'){
name='雷'+name;
this.node.image.classList.add('thunder');
}
}
for(var i=0;i<name.length;i++){
this.node.name.innerHTML+=name[i]+'<br/>';
}
if(lib.card[card[2]].subtype=='equip3'){
this.node.name.innerHTML+='+';
}
else if(lib.card[card[2]].subtype=='equip4'){
this.node.name.innerHTML+='-';
}
this.node.name2.innerHTML=get.translation(card[0])+card[1]+' '+name;
this.suit=card[0];
this.number=card[1];
this.name=card[2];
this.classList.add('card');
if(card[3]){
if(lib.nature.contains(card[3])) this.nature=card[3];
this.classList.add(card[3]);
}
if(lib.card[card[2]].subtype) this.classList.add(lib.card[card[2]].subtype);
if(this.inits){
for(var i=0;i<lib.element.card.inits.length;i++){
lib.element.card.inits[i](this);
}
}
if(typeof lib.card[card[2]].init=='function') lib.card[card[2]].init();
return this;
},
aiexclude:function(){
_status.event.aiexclude.add(this);
},
moveTo:function(player,method){
this.fixed=true;
this.style.left='';
this.style.top='';
this.dataset.position=player.dataset.position;
if(method=='flip'){
this.style.transition='all 0.5s';
2015-11-05 02:34:35 +00:00
this.style.transform='rotate'+(Math.random()<0.5?'X':'Y')+'(180deg) perspective(1000px)';
2015-04-29 03:25:17 +00:00
}
else if(method=='rotate'){
this.style.transition='all 0.5s';
2015-11-05 02:34:35 +00:00
this.style.transform='rotate(180deg)';
2015-04-29 03:25:17 +00:00
}
return this;
},
copy:function(){
var node=this.cloneNode(true);
2015-11-04 01:59:00 +00:00
node.name=this.name;
node.suit=this.suit;
node.number=this.number;
2015-04-29 03:25:17 +00:00
node.classList.remove('hidden');
node.classList.remove('start');
node.classList.remove('thrown');
node.classList.remove('selectable');
node.classList.remove('selected');
node.classList.remove('removing');
node.node={
name:node.querySelector('.name'),
info:node.querySelector('.info'),
intro:node.querySelector('.intro'),
background:node.querySelector('.background'),
image:node.querySelector('.image'),
}
var clone=true;
var position;
for(var i=0;i<arguments.length;i++){
if(typeof arguments[i]=='string') node.classList.add(arguments[i]);
else if(get.objtype(arguments[i])=='div') position=arguments[i];
else if(typeof arguments[i]=='boolean') clone=arguments[i];
}
node.moveTo=lib.element.card.moveTo;
if(clone) this.clone=node;
if(position) position.appendChild(node);
return node;
}
},
button:{
exclude:function(){
if(_status.event.excludeButton==undefined){
_status.event.excludeButton=[];
}
_status.event.excludeButton.add(this);
}
},
event:{
finish:function(){
this.finished=true;
},
goto:function(step){
this.step=step-1;
},
redo:function(){
this.step--;
},
backup:function(skill){
this._backup={
filterButton:this.filterButton,
selectButton:this.selectButton,
filterTarget:this.filterTarget,
selectTarget:this.selectTarget,
filterCard:this.filterCard,
selectCard:this.selectCard,
position:this.position,
forced:this.forced,
aiexclude:this.aiexclude
}
if(skill){
var info=get.info(skill);
this.skill=skill;
this.aiexclude=[];
if(info.viewAs){
if(info.filterButton!=undefined) this.filterButton=get.filter(info.filterButton);
if(info.selectButton!=undefined) this.selectButton=info.selectButton;
if(info.filterTarget!=undefined) this.filterTarget=get.filter(info.filterTarget);
if(info.selectTarget!=undefined) this.selectTarget=info.selectTarget;
if(info.filterCard!=undefined) this.filterCard=get.filter(info.filterCard);
if(info.selectCard!=undefined) this.selectCard=info.selectCard;
if(info.position!=undefined) this.position=info.position;
if(info.forced!=undefined) this.forced=info.forced;
}
else{
this.filterButton=info.filterButton?get.filter(info.filterButton):undefined;
this.selectButton=info.selectButton;
this.filterTarget=info.filterTarget?get.filter(info.filterTarget):undefined;
this.selectTarget=info.selectTarget;
this.filterCard=info.filterCard?get.filter(info.filterCard):undefined;
this.selectCard=info.selectCard;
this.position=info.position;
this.forced=info.forced;
}
}
},
restore:function(){
if(this._backup){
this.filterButton=this._backup.filterButton;
this.selectButton=this._backup.selectButton;
this.filterTarget=this._backup.filterTarget;
this.selectTarget=this._backup.selectTarget;
this.filterCard=this._backup.filterCard;
this.selectCard=this._backup.selectCard;
this.position=this._backup.position;
this.forced=this._backup.forced;
this.aiexclude=this._backup.aiexclude;
}
delete this.skill;
},
isMine:function(){
2015-05-13 10:26:54 +00:00
return (this.player&&this.player==game.me&&!_status.auto&&!this.player.isMad());
2015-04-29 03:25:17 +00:00
},
trigger:function(name){
2015-11-04 01:59:00 +00:00
if(_status.video) return;
2015-04-29 03:25:17 +00:00
var event=this;
2015-05-04 03:17:03 +00:00
var i,j,iwhile,next,add;
var totalPopulation=game.players.length+game.dead.length+1;
2015-04-29 03:25:17 +00:00
if(event.player&&event.player.removed) return;
if(!event.player&&name!='gameStart') return;
event._endTrigger=event.player||game.me;
2015-05-12 09:51:40 +00:00
if(!game.players.contains(event._endTrigger)){
event._endTrigger=game.findNext(event._endTrigger);
2015-04-29 03:25:17 +00:00
}
2015-05-12 09:51:40 +00:00
2015-04-29 03:25:17 +00:00
var player=event._endTrigger;
var list=[],others=[];
for(i=0;i<game.players.length;i++){
for(j in game.players[i].tempSkills){
var expire=game.players[i].tempSkills[j];
if(expire==name||
(get.objtype(expire)=='array'&&expire.contains(name))||
(typeof expire=='function'&&expire(event,game.players[i],name))){
delete game.players[i].tempSkills[j];
game.players[i].removeSkill(j);
}
else if(typeof expire=='object'){
if(expire.player==name&&event.player==game.players[i]||
expire.target==name&&event.target==game.players[i]||
expire.source==name&&event.source==game.players[i]){
delete game.players[i].tempSkills[j];
game.players[i].removeSkill(j);
}
}
}
}
2015-05-04 03:17:03 +00:00
for(iwhile=0;iwhile<totalPopulation;iwhile++){
2015-04-29 03:25:17 +00:00
var skills=player.get('s',true).concat(lib.skill.global);
game.expandSkills(skills);
for(i=0;i<skills.length;i++){
var trigger=get.info(skills[i]).trigger;
if(trigger){
add=false;
if(player==event.player&&trigger.player){
if(typeof trigger.player=='string'){
if(trigger.player==name) add=true;
}
else if(trigger.player.contains(name)) add=true;
}
if((player==event.target||
(event.multitarget&&event.targets&&event.targets.contains(player)))&&
trigger.target){
if(typeof trigger.target=='string'){
if(trigger.target==name) add=true;
}
else if(trigger.target.contains(name)) add=true;
}
if(player==event.source&&trigger.source){
if(typeof trigger.source=='string'){
if(trigger.source==name) add=true;
}
else if(trigger.source.contains(name)) add=true;
}
if(trigger.global){
if(typeof trigger.global=='string'){
if(trigger.global==name) add=true;
}
else if(trigger.global.contains(name)) add=true;
}
if(add&&player.isOut()==false) list.push([skills[i],player]);
}
}
player=player.next;
2015-05-12 09:51:40 +00:00
if(!player||player==event._endTrigger){
2015-05-04 03:17:03 +00:00
break;
}
2015-04-29 03:25:17 +00:00
}
if(list.length){
list.sort(lib.sort.priority);
for(i=0;i<list.length;i++){
if(list[i][1].isOut()||list[i][1].isDead()||list[i][1].removed) continue;
var next=game.createEvent('trigger',false);
next.skill=list[i][0];
next.player=list[i][1];
next.triggername=name;
next._trigger=event;
next.content=function(){
"step 0"
var info=get.info(event.skill);
if(info.filter&&!info.filter(trigger,player,event.triggername)){
event.finish();
}
else{
var hidden=player.hiddenSkills.slice(0);
game.expandSkills(hidden);
if(hidden.contains(event.skill)&&!get.info(event.skill).direct){
event.trigger('triggerHidden');
}
}
"step 1"
if(event.cancelled){
event.finish();
}
else{
event.trigger('triggerBefore');
}
"step 2"
if(event.cancelled){
event.finish();
return;
}
if(!event.revealed&&!get.info(event.skill).forced){
2015-05-01 09:34:01 +00:00
if(get.info(event.skill).direct&&player.isUnderControl()){
game.modeSwapPlayer(player);
2015-04-29 03:25:17 +00:00
event._result={bool:true};
}
else if(get.info(event.skill).frequent&&!lib.config.autoskilllist.contains(event.skill)){
event._result={bool:true};
}
else if(get.info(event.skill).direct&&player==game.me&&!_status.auto){
event._result={bool:true};
}
else{
var str;
var check=get.info(event.skill).check;
if(get.info(event.skill).prompt) str=get.info(event.skill).prompt;
else str='是否发动【'+get.translation(event.skill)+'】?';
if(typeof str=='function'){str=str(trigger,player)}
player.chooseBool(str).ai=function(){
return !check||check(trigger,player);
};
}
}
"step 3"
if(result&&result.bool==false) return;
var info=get.info(event.skill);
var next=game.createEvent(event.skill);
next.player=player;
next._trigger=trigger;
next.content=info.content;
if(info.popup!=false&&!info.direct){
if(info.popup){
player.popup(info.popup);
game.log(get.translation(player)+'发动了'+get.translation(event.skill));
}
else{
player.logSkill(event.skill);
}
}
}
}
}
},
untrigger:function(all){
if(all){
this.next.length=0;
this._triggered=5;
}
else{
for(var i=0;i<this.next.length;i++){
if(this.next[i]._trigger==this) this.next.remove(this.next[i]);
}
}
}
},
dialog:{
add:function(item,noclick,zoom){
if(typeof item=='string'){
if(noclick){
var strstr=item;
item=ui.create.div('',this.content);
item.innerHTML=strstr;
}
else{
item=ui.create.caption(item,this.content);
}
}
else if(get.objtype(item)=='div'){
this.content.appendChild(item);
}
else if(get.itemtype(item)=='cards'){
var buttons=ui.create.div('.buttons',this.content);
if(zoom) buttons.classList.add('smallzoom');
this.buttons=this.buttons.concat(ui.create.buttons(item,'card',buttons,noclick));
}
else if(get.itemtype(item)=='players'){
var buttons=ui.create.div('.buttons',this.content);
if(zoom) buttons.classList.add('smallzoom');
this.buttons=this.buttons.concat(ui.create.buttons(item,'player',buttons,noclick));
}
else{
var buttons=ui.create.div('.buttons',this.content);
if(zoom) buttons.classList.add('smallzoom');
2015-05-02 09:54:39 +00:00
this.buttons=this.buttons.concat(ui.create.buttons(item[0],item[1],buttons,noclick));
2015-04-29 03:25:17 +00:00
}
ui.update();
return item;
},
addSmall:function(item,noclick){
return this.add(item,noclick,true);
},
open:function(){
2015-05-12 09:51:40 +00:00
if(this.noopen) return;
2015-04-29 03:25:17 +00:00
for(var i=0;i<ui.dialogs.length;i++){
2015-04-29 10:02:31 +00:00
if(ui.dialogs[i]==this){
this.show();
this.refocus();
ui.dialogs.remove(this);
ui.dialogs.unshift(this);
ui.update();
return this;
}
2015-04-29 03:25:17 +00:00
if(ui.dialogs[i].static) ui.dialogs[i].unfocus();
else ui.dialogs[i].hide();
}
ui.dialog=this;
ui.arena.appendChild(this);
ui.dialogs.unshift(this);
ui.update();
return this;
},
close:function(){
ui.dialogs.remove(this);
this.delete();
if(ui.dialogs.length>0){
ui.dialog=ui.dialogs[0];
ui.dialog.show();
ui.dialog.refocus();
ui.update();
}
return this;
},
setCaption:function(str){
this.querySelector('.caption').innerHTML=str;
return this;
}
},
control:{
add:function(item){
var node=document.createElement('div');
this.appendChild(node);
node.link=item;
node.innerHTML=get.translation(item);
node.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.control);
},
close:function(){
ui.controls.remove(this);
this.style.width=0;
this.style.paddingLeft=0;
this.style.paddingRight=0;
this.style.marginLeft=0;
this.style.marginRight=0;
this.delete();
if(ui.confirm==this) delete ui.confirm;
if(ui.skills==this) delete ui.skills;
},
replace:function(){
2015-05-04 03:17:03 +00:00
while(this.childNodes.length) this.firstChild.remove();
2015-04-29 03:25:17 +00:00
var i,controls;
if(get.objtype(arguments[0])=='array') controls=arguments[0];
else controls=arguments;
delete this.custom;
for(i=0;i<controls.length;i++){
if(typeof controls[i]=='function'){
this.custom=controls[i];
}
else{
this.add(controls[i]);
}
}
if(this.childNodes.length){
var width=0;
for(i=0;i<this.childNodes.length;i++) width+=this.childNodes[i].offsetWidth;
2015-10-13 11:15:02 +00:00
this.style.transition='width 0.2s';
ui.refresh(this);
2015-04-29 03:25:17 +00:00
this.style.width=width+'px';
2015-10-13 11:15:02 +00:00
var that=this;
setTimeout(function(){
that.style.transition='';
},200);
2015-04-29 03:25:17 +00:00
}
return this;
}
},
},
card:{
list:[],
},
filter:{
all:function(){
return true;
},
buttonIncluded:function(button){
return !(_status.event.excludeButton&&_status.event.excludeButton.contains(button));
},
filterButton:function(button){
return true;
},
cardEnabled:function(card,player,event){
if(player==undefined) player=_status.event.player;
var filter=get.info(card).enable;
if(!filter) return;
var mod=game.checkMod(card,player,'unchanged','cardEnabled',player.get('s'));
if(mod!='unchanged') return mod;
if(typeof filter=='boolean') return filter;
if(typeof filter=='function') return filter(card,player);
},
cardRespondable:function(card,player){
if(_status.event.name!='chooseToRespond') return true;
if(player==undefined) player=_status.event.player;
var mod=game.checkMod(card,player,'unchanged','cardRespondable',player.get('s'));
if(mod!='unchanged') return mod;
return true;
},
cardUsable:function(card,player,event){
if(player!=_status.event.player) return true;
event=event||_status.event;
if(event.parent.name!='phaseUse') return true;
if(event.parent.player!=player) return true;
var num=get.info(card).usable;
if(typeof num=='function') num=num(card,player);
num=game.checkMod(card,player,num,'cardUsable',player.get('s'));
if(typeof num!='number') return true;
else return(get.cardCount(card,player)<num);
},
cardAiIncluded:function(card){
if(_status.event.isMine()) return true;
return (_status.event.aiexclude.contains(card)==false);
},
filterCard:function(card,player,event){
return (lib.filter.cardEnabled(card,player,event)&&
lib.filter.cardUsable(card,player,event));
},
targetEnabled:function(card,player,target){
if(card==undefined) return false;
var filter=get.info(card).filterTarget;
var mod=game.checkMod(card,player,target,'unchanged','playerEnabled',player.get('s'));
if(mod==false) return false;
var mod=game.checkMod(card,player,target,'unchanged','targetEnabled',target.get('s'));
if(mod!='unchanged') return mod;
if(typeof filter=='boolean') return filter;
if(typeof filter=='function') return filter(card,player,target);
},
targetInRange:function(card,player,target){
var mod=game.checkMod(card,player,target,'unchanged','targetInRange',player.get('s'));
var extra=0;
if(mod!='unchanged'){
if(typeof mod=='boolean') return mod;
if(typeof mod=='number') extra=mod;
}
var range=get.info(card).range;
if(range==undefined) return true;
for(var i in range){
if(range[i]<get.distance(player,target,i)+extra) return false;
}
return true;
},
filterTarget:function(card,player,target){
return (lib.filter.targetEnabled(card,player,target)&&
lib.filter.targetInRange(card,player,target));
},
notMe:function(card,player,target){
return (player!=target)
},
isMe:function(card,player,target){
return (player==target)
},
selectCard:function(){
return [1,1];
},
selectTarget:function(){
var card=get.card(),player=get.player();
if(card==undefined) return;
var range;
var select=get.info(card).selectTarget;
if(select==undefined){
if(get.info(card).filterTarget==undefined) return[0,0];
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.get('s'));
return range;
},
judge:function(card,player,target){
var judges=target.get('j');
for(var i=0;i<judges.length;i++){
if(judges[i].name==card.name||judges[i].viewAs==card.name) return false;
}
return true;
},
autoRespondSha:function(){
if(this.player.num('h','sha')) return false;
if(this.player.num('h','hufu')) return false;
if(this.player.hasSkillTag('respondSha',true)) return false;
return true;
},
autoRespondShan:function(){
if(this.player.num('h','shan')) return false;
if(this.player.num('h','hufu')) return false;
if(this.player.hasSkillTag('respondShan',true)) return false;
return true;
},
},
sort:{
random:function(){
return (Math.random()-0.5);
},
seat:function(a,b){
var player=lib.tempSortSeat||_status.event.player;
2015-05-04 03:17:03 +00:00
var delta=get.distance(player,a,'absolute')-get.distance(player,b,'absolute');
if(delta) return delta;
delta=parseInt(a.dataset.position)-parseInt(b.dataset.position);
if(player.side==game.me.side) return delta;
return -delta;
2015-04-29 03:25:17 +00:00
},
position:function(a,b){
return parseInt(a.dataset.position)-parseInt(b.dataset.position);
},
priority:function(a,b){
var i1=get.info(a[0]),i2=get.info(b[0]);
if(i1.priority==undefined) i1.priority=0;
if(i2.priority==undefined) i2.priority=0;
if(i1.priority==i2.priority){
if(i1.forced==undefined&&i2.forced==undefined) return 0;
if(i1.forced&&i2.forced) return 0;
if(i1.forced) return 1;
if(i2.forced) return -1;
}
return i2.priority-i1.priority;
},
number:function(a,b){
return get.number(a)-get.number(b);
},
number2:function(a,b){
return get.number(b)-get.number(a);
},
},
skill:{
global:[],
storage:{},
unequip:{},
2015-05-13 10:26:54 +00:00
mad:{
mark:true,
intro:{
content:'已进入混乱状态',
name:'混乱'
}
},
2015-06-27 16:21:25 +00:00
ghujia:{
intro:{
content:function(content,player){
return '已有'+get.cnNumber(player.hujia)+'点护甲值';
}
}
},
2015-04-29 03:25:17 +00:00
_recoverCheck:{
trigger:{player:'recoverBefore'},
forced:true,
priority:20,
popup:false,
filter:function(event,player){
return player.hp>=player.maxHp;
},
content:function(){
trigger.untrigger();
trigger.finish();
},
},
_turnover:{
trigger:{player:'phaseBefore'},
forced:true,
priority:20,
popup:false,
// filter:function(event,player){
// return player.isTurnedOver();
// },
content:function(){
if(player.isTurnedOver()){
trigger.untrigger();
trigger.finish();
player.turnOver();
player.phaseSkipped=true;
}
else{
player.phaseSkipped=false;
}
},
},
_out:{
trigger:{target:'useCardToBefore',player:['damageBefore','phaseBefore']},
forced:true,
popup:false,
priority:20,
filter:function(event,player){
return player.isOut();
},
content:function(){
trigger.untrigger();
trigger.finish();
},
ai:{
effect:{
target:function(card,player,target){
if(target.isOut()) return 0;
}
},
threaten:function(player,target){
if(target.isOut()) return 0;
}
}
},
_phasebegin:{
trigger:{player:'phaseBegin'},
forced:true,
priority:20,
popup:false,
content:function(){
player.popup('_phasebegin');
2015-11-06 10:05:08 +00:00
if(lib.config.glow_phase){
if(_status.currentPhase){
_status.currentPhase.classList.remove('glow_phase');
}
player.classList.add('glow_phase');
}
game.addVideo('phaseChange',player);
2015-04-29 03:25:17 +00:00
_status.currentPhase=player;
game.log();
game.log(get.translation(player)+'的回合开始');
game.phaseNumber++;
2015-11-07 09:20:15 +00:00
if(get.config('identity_mode')!='zhong'){
var num;
switch(get.config('auto_identity')){
case 'one':num=1;break;
case 'two':num=2;break;
case 'three':num=3;break;
case 'always':num=-1;break;
default:num=0;break;
}
if(num&&!_status.identityShown&&game.phaseNumber>game.players.length*num&&game.showIdentity){
if(!_status.video) player.popup('显示身份');
_status.identityShown=true;
game.showIdentity(false);
}
2015-04-29 03:25:17 +00:00
}
player.ai.tempIgnore=[];
player.stat.push({card:{},skill:{}});
},
},
_save:{
trigger:{source:'dying',player:'dying'},
priority:5,
forced:true,
popup:false,
filter:function(event,player){
if(event.player.hp>0) return false;
if(event.source&&event.source!=player) return false;
return true;
},
content:function(){
"step 0"
event.dying=_status.dying;
"step 1"
trigger.start=trigger.source||trigger.player;
var str=get.translation(trigger.player.name)+'濒死,是否帮助?';
_status.dying=event.dying;
2015-09-03 03:49:14 +00:00
if(player.hasSkillTag('save',true)||player.num('h','tao')||
2015-04-29 03:25:17 +00:00
(player==event.dying&&(player.num('h','jiu')||player.num('h','hufu')||player.num('h','tianxianjiu')))){
player.chooseToUse({
filterCard:function(card,player){
var mod=game.checkMod(card,player,'unchanged','cardSavable',player.get('s'));
if(mod!='unchanged') return mod;
var savable=get.info(card).savable;
if(typeof savable=='function') savable=savable(card,player,event.dying);
return savable;
},
filterTarget:trigger.player,
prompt:str,
ai1:function(){return 1;},
ai2:ai.get.effect,
type:'dying',
2015-05-08 13:37:34 +00:00
targetRequired:true,
2015-04-29 03:25:17 +00:00
dying:event.dying
});
}
else{
event._result={bool:false}
}
"step 2"
if(result.bool){
if(trigger.player.hp<=0&&trigger.player.isAlive()&&!trigger.player.isOut()&&!trigger.player.removed) event.goto(0);
else trigger.untrigger();
}
else{
for(var i=0;i<20;i++){
if(event.player.next!=trigger.start){
event.player=event.player.next;
if(!event.player.isOut()){
event.goto(1);
break;
}
}
else{
break;
}
}
}
}
},
2015-05-13 10:26:54 +00:00
_ismin:{
mod:{
cardEnabled:function(card,player){
if(player.isMin()){
if(get.type(card)=='equip') return false;
}
}
}
},
2015-04-29 03:25:17 +00:00
_chongzhu:{
enable:'phaseUse',
2015-10-21 05:11:55 +00:00
prompt:'将要重铸的牌置于弃牌堆并摸一张牌',
2015-04-29 03:25:17 +00:00
filter:function(event,player){
2015-05-13 10:26:54 +00:00
if(player.isMin()&&lib.config.mode=='stone') return false;
2015-04-29 03:25:17 +00:00
return (player.get('h',function(card){
return get.info(card).chongzhu;
}).length);
},
filterCard:function(card){
return get.info(card).chongzhu;
},
prepare:function(cards,player){
player.$throw(cards,1000);
},
discard:false,
delay:0.5,
content:function(){
"step 0"
player.draw();
"step 1"
for(var i=0;i<cards.length;i++){
ui.discardPile.appendChild(cards[i]);
}
},
ai:{
basic:{
order:6
},
result:{
player:1,
},
}
},
_lianhuan:{
trigger:{player:'damageAfter'},
filter:function(event,player){
return (event.nature&&lib.linked.contains(event.nature)&&event.player.classList.contains('linked'));
},
forced:true,
popup:false,
content:function(){
"step 0"
player.link();
"step 1"
var players=game.players.slice(0);
lib.tempSortSeat=player;
players.sort(lib.sort.seat);
delete lib.tempSortSeat;
for(var i=0;i<players.length;i++){
if(players[i].classList.contains('linked')){
if(trigger.source){
players[i].damage(trigger.num,trigger.nature,trigger.source,trigger.cards,trigger.card);
}
else{
players[i].damage(trigger.num,trigger.nature,'nosource',trigger.cards,trigger.card);
}
return;
}
}
}
},
_lianhuan2:{
trigger:{global:'damageAfter'},
filter:function(event,player){
return (event.nature&&lib.linked.contains(event.nature)&&event.player.classList.contains('linked')&&
event.player.classList.contains('dead')&&player.classList.contains('linked'));
},
forced:true,
content:function(){
"step 0"
trigger.player.classList.remove('linked');
"step 1"
if(trigger.source){
player.damage(trigger.num,trigger.nature,trigger.source,trigger.cards,trigger.card);
}
else{
player.damage(trigger.num,trigger.nature,'nosource',trigger.cards,trigger.card);
}
}
},
},
character:{},
perfectPair:{},
2015-04-29 03:25:17 +00:00
group:['wei','shu','wu','qun'],
nature:['fire','thunder','poison'],
linked:['fire','thunder'],
};
var game={
2015-10-13 11:15:02 +00:00
version:1.31,
2015-04-29 14:56:33 +00:00
playAudio:function(){
var str='';
for(var i=0;i<arguments.length;i++){
if(typeof arguments[i]==='string'||typeof arguments[i]=='number'){
str+='/'+arguments[i];
}
}
2015-11-01 07:54:42 +00:00
if(_status.skillaudio.contains(str)) return;
_status.skillaudio.add(str);
setTimeout(function(){
_status.skillaudio.remove(str);
},1000);
2015-04-29 14:56:33 +00:00
var audio=document.createElement('audio');
audio.autoplay=true;
2015-04-30 03:09:07 +00:00
audio.volume=lib.config.volumn_audio/8;
2015-04-29 14:56:33 +00:00
audio.src='audio'+str+'.mp3';
audio.addEventListener('ended',function(){
this.remove();
});
2015-04-30 03:09:07 +00:00
audio.onerror=function(){
2015-05-16 14:18:03 +00:00
if(this._changed){
this.remove();
2015-05-16 11:22:27 +00:00
}
else{
2015-05-16 14:18:03 +00:00
this.src='audio'+str+'.ogg';
this._changed=true;
2015-05-16 11:22:27 +00:00
}
2015-04-30 03:09:07 +00:00
};
2015-04-30 08:24:57 +00:00
ui.window.appendChild(audio);
2015-04-29 14:56:33 +00:00
},
2015-05-16 11:22:27 +00:00
playSkillAudio:function(name){
2015-11-01 07:54:42 +00:00
if(_status.skillaudio.contains(name)) return;
_status.skillaudio.add(name);
setTimeout(function(){
_status.skillaudio.remove(name);
},1000);
2015-05-16 11:22:27 +00:00
var str='audio/skill/';
var audio=document.createElement('audio');
audio.autoplay=true;
audio.volume=lib.config.volumn_audio/8;
2015-05-16 11:22:27 +00:00
audio.src=str+name+'.mp3';
audio.addEventListener('ended',function(){
this.remove();
});
2015-05-16 14:18:03 +00:00
audio._changed=1;
2015-05-16 11:22:27 +00:00
audio.onerror=function(){
2015-05-16 14:18:03 +00:00
switch(this._changed){
case 1:{
audio.src=str+name+'.ogg';
this._changed=2;
break;
}
case 2:{
audio.src=str+name+Math.ceil(Math.random()*2)+'.mp3';
this._changed=3;
break;
}
case 3:{
audio.src=str+name+Math.ceil(Math.random()*2)+'.ogg';
this._changed=4;
break;
}
default:{
this.remove();
}
2015-05-16 11:22:27 +00:00
}
};
ui.window.appendChild(audio);
},
2015-04-29 14:56:33 +00:00
playBackgroundMusic:function(){
if(lib.config.background_music=='music_off'){
ui.backgroundMusic.src='';
}
else{
var music=lib.config.background_music;
if(music=='music_random'){
music=lib.config.all.background_music.randomGet('music_off','music_random',_status.currentMusic);
}
_status.currentMusic=music;
ui.backgroundMusic.src='audio/background/'+music+'.mp3';
}
},
2015-11-04 01:59:00 +00:00
export:function(textToWrite,name){
var textFileAsBlob = new Blob([textToWrite], {type:'text/plain'});
var fileNameToSaveAs = name||'noname';
var downloadLink = document.createElement("a");
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = "Download File";
downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
downloadLink.click();
},
playVideo:function(time,mode){
2015-11-05 02:34:35 +00:00
if(!_status.replayvideo){
localStorage.setItem(lib.configprefix+'playbackmode',lib.config.mode);
}
2015-11-04 01:59:00 +00:00
game.saveConfig('mode',mode);
localStorage.setItem(lib.configprefix+'playback',time);
game.reload();
},
playVideoContent:function(video){
var next=game.createEvent('video',false);
next.video=video;
ui.system.style.display='none';
ui.system.hide();
ui.arena.style.display='none';
ui.arena.hide();
_status.event=next;
_status.paused=false;
_status.paused2=false;
_status.over=false;
_status.video=true;
clearTimeout(_status.timeout);
for(var i in lib.characterPack){
for(var j in lib.characterPack[i]){
lib.character[j]=lib.character[j]||lib.characterPack[i][j];
}
}
next.content=function(){
'step 0'
game.delay(0,500);
'step 1'
if(lib.config.mode!='chess'){
ui.control.innerHTML='';
var nodes=[];
for(var i=0;i<ui.arena.childNodes.length;i++){
nodes.push(ui.arena.childNodes[i]);
}
for(var i=0;i<nodes.length;i++){
if(nodes[i]==ui.canvas) continue;
if(nodes[i]==ui.control) continue;
if(nodes[i]==ui.mebg) continue;
if(nodes[i]==ui.me) continue;
nodes[i].remove();
}
ui.me.innerHTML='';
ui.sidebar.innerHTML='';
ui.cardPile.innerHTML='';
ui.discardPile.innerHTML='';
ui.special.innerHTML='';
}
ui.system.firstChild.innerHTML='';
ui.system.lastChild.innerHTML='';
2015-11-05 02:34:35 +00:00
ui.system.firstChild.appendChild(ui.config2);
if(ui.updateVideoMenu){
ui.updateVideoMenu();
}
2015-11-04 01:59:00 +00:00
_status.videoDuration=1;
2015-11-05 02:34:35 +00:00
ui.create.system('返回',function(){
var mode=localStorage.getItem(lib.configprefix+'playbackmode');
if(mode){
game.saveConfig('mode',mode);
}
game.reload();
});
2015-11-04 01:59:00 +00:00
ui.create.system('重播',function(){
2015-11-05 02:34:35 +00:00
_status.replayvideo=true;
2015-11-04 01:59:00 +00:00
game.playVideo(_status.playback,lib.config.mode);
});
ui.create.system('暂停',ui.click.pause,true);
var slow=ui.create.system('减速',function(){
_status.videoDuration*=1.5;
updateDuration();
},true);
var fast=ui.create.system('加速',function(){
_status.videoDuration/=1.5;
updateDuration();
},true);
var updateDuration=function(){
if(_status.videoDuration>1){
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();
if(lib.config.mode!='versus'&&lib.config.mode!='boss'){
ui.arena.style.display='';
ui.refresh(ui.arena);
ui.arena.show();
}
if(lib.config.mode!='chess'){
game.playerMap={};
}
'step 2'
if(event.video.length){
var content=event.video.shift();
// console.log(content);
if(content.type=='delay'){
game.delay(content.content);
}
2015-11-09 03:15:16 +00:00
else if(typeof content.player=='string'&&game.playerMap[content.player]&&
game.playerMap[content.player].classList&&
!game.playerMap[content.player].classList.contains('obstacle')){
2015-11-04 01:59:00 +00:00
game.videoContent[content.type](game.playerMap[content.player],content.content);
}
else{
game.videoContent[content.type](content.content);
}
if(event.video.length){
game.delay(0,_status.videoDuration*Math.min(2000,event.video[0].delay));
}
event.redo();
}
else{
_status.over=true;
ui.system.lastChild.hide();
setTimeout(function(){
ui.system.lastChild.innerHTML='';
},500);
}
}
game.loop();
},
videoContent:{
init:function(players){
if(lib.config.mode=='chess') return;
ui.arena.dataset.number=players.length;
ui.arena.classList.add('video');
game.players.length=0;
game.dead.length=0;
ui.create.players(players.length);
game.me=game.players[0];
ui.handcards1=game.me.node.handcards1;
ui.handcards2=game.me.node.handcards2;
ui.me.appendChild(ui.handcards1);
ui.me.appendChild(ui.handcards2);
if(lib.config.mode=='versus'){
if(players.bool){
ui.arena.dataset.number=parseInt(ui.arena.dataset.number)+1;
for(var i=0;i<game.players.length;i++){
game.players[i].dataset.position=parseInt(game.players[i].dataset.position)+1;
}
game.singleHandcard=true;
ui.arena.classList.add('single-handcard');
ui.fakeme=ui.create.div('.player.controlfakeme');
ui.fakeme.line=lib.element.player.line;
ui.fakemebg=ui.create.div('.avatar',ui.fakeme).hide();
}
ui.arena.style.display='';
ui.refresh(ui.arena);
ui.arena.show();
}
else if(lib.config.mode=='boss'){
if(!players.boss){
game.singleHandcard=true;
ui.arena.classList.add('single-handcard');
ui.fakeme=ui.create.div('.player.controlfakeme');
ui.fakeme.dataset.position=0;
ui.fakeme.line=lib.element.player.line;
ui.fakemebg=ui.create.div('.avatar',ui.fakeme).hide();
ui.refresh(ui.fakemebg);
}
ui.arena.dataset.number=8;
}
ui.updateh(true);
for(var i=0;i<players.length;i++){
if(lib.config.mode=='identity'){
game.players[i].init(players[i].name,players[i].name2);
game.players[i].setIdentity(players[i].identity);
}
else if(lib.config.mode=='stone'){
game.players[i].init(players[i].name,players[i].name2);
game.players[i].classList.add('noidentity');
game.players[i].updateActCount(null,players[i].count,0);
}
else if(lib.config.mode=='boss'){
game.players[i].init(players[i].name,players[i].name2);
game.players[i].setIdentity(players[i].identity);
game.players[i].dataset.position=players[i].position;
2015-11-06 10:05:08 +00:00
game.players[i].node.action.innerHTML='行动';
2015-11-04 01:59:00 +00:00
}
else if(lib.config.mode=='versus'){
game.players[i].init(players[i].name,players[i].name2);
game.players[i].node.identity.firstChild.innerHTML=players[i].identity;
game.players[i].node.identity.dataset.color=players[i].color;
2015-11-06 10:05:08 +00:00
game.players[i].node.action.innerHTML='行动';
2015-11-04 01:59:00 +00:00
}
else if(lib.config.mode=='guozhan'){
game.players[i].name=players[i].name;
game.players[i].name1=players[i].name1;
game.players[i].name2=players[i].name2;
game.players[i].sex='unknown';
game.players[i].identity='unknown';
lib.translate[game.players[i].name]=players[i].translate;
game.players[i].init(players[i].name1,players[i].name2,false);
game.players[i].classList.add('unseen');
game.players[i].classList.add('unseen2');
if(game.players[i]!=game.me){
game.players[i].node.identity.firstChild.innerHTML='猜';
game.players[i].node.identity.dataset.color='unknown';
}
else{
game.players[i].setIdentity(game.players[i].group);
}
}
}
for(var i=0;i<game.players.length;i++){
game.playerMap[game.players[i].dataset.position]=game.players[i];
}
if(lib.config.mode=='versus'){
if(players.bool){
ui.fakemebg.show();
game.onSwapControl();
}
}
else if(lib.config.mode=='boss'){
if(!players.boss){
game.onSwapControl();
ui.fakemebg.show();
}
ui.arena.style.display='';
ui.refresh(ui.arena);
ui.arena.show();
ui.updateh(true);
}
},
2015-11-06 10:05:08 +00:00
phaseChange:function(player){
if(player){
var glowing=document.querySelector('.glow_phase');
if(glowing){
glowing.classList.remove('glow_phase');
}
if(lib.config.glow_phase){
player.classList.add('glow_phase');
}
}
else{
console.log(player);
}
},
2015-11-09 03:15:16 +00:00
playerfocus:function(player,time){
if(player&&player.playerfocus){
player.playerfocus(time);
2015-11-07 09:20:15 +00:00
}
else{
console.log(player);
}
},
2015-11-04 01:59:00 +00:00
chessSwap:function(content){
var me=game.playerMap[content[0]];
var player=game.playerMap[content[1]];
if(me){
me.node.avatar.classList.remove('glow2');
}
if(player){
player.node.avatar.classList.add('glow2');
}
},
chessgainmod:function(player,num){
if(Array.isArray(num)){
num=get.infoCards(num);
}
2015-11-05 02:34:35 +00:00
if(player&&player.$gainmod){
player.$gainmod(num);
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
moveTo:function(player,pos){
2015-11-05 02:34:35 +00:00
if(player&&player.moveTo&&pos){
player.moveTo(pos[0],pos[1]);
}
else{
console.log(player)
}
2015-11-04 01:59:00 +00:00
},
2015-11-09 03:15:16 +00:00
addObstacle:function(pos){
if(pos){
game.addObstacle(pos[0],pos[1]);
}
else{
console.log(pos)
}
},
removeObstacle:function(pos){
game.removeObstacle(pos);
},
2015-11-04 01:59:00 +00:00
moveTox:function(player,pos){
2015-11-05 02:34:35 +00:00
if(player&&player.dataset){
delete lib.posmap[player.dataset.position];
player.dataset.position=pos;
lib.posmap[pos]=player;
game.delay();
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
2015-11-06 10:05:08 +00:00
thrownhighlight1:function(){
ui.arena.classList.add('thrownhighlight');
},
thrownhighlight2:function(){
ui.arena.classList.remove('thrownhighlight');
},
2015-11-04 01:59:00 +00:00
chessFocus:function(player){
2015-11-05 02:34:35 +00:00
if(player){
player.chessFocus();
}
else{
console.log('chessFocus');
}
2015-11-04 01:59:00 +00:00
},
2015-11-09 03:15:16 +00:00
removeTreasure:function(pos){
if(game.playerMap[pos]){
game.playerMap[pos].delete();
delete game.playerMap[pos];
}
else{
console.log(pos);
}
},
initobs:function(obs){
if(obs){
for(var i=0;i<obs.length;i++){
game.addObstacle(obs[i]);
}
}
else{
console.log(obs);
}
},
2015-11-04 01:59:00 +00:00
stonePosition:function(content){
var player=game.playerMap[content[0]];
if(player){
delete game.playerMap[content[0]];
player.dataset.position=content[1];
game.playerMap[content[1]]=player;
}
2015-11-05 02:34:35 +00:00
else{
console.log(content);
}
2015-11-04 01:59:00 +00:00
},
stoneSwap:function(info){
var player=ui.create.player();
player.classList.add('noidentity');
player.dataset.position=info.position;
player.animate(info.me?'replaceme':'replaceenemy');
player.actcount=info.actcount;
player.init(info.name,info.name2);
game.players.push(player);
player.updateActCount(null,info.actcount,0);
ui.arena.appendChild(player);
game.playerMap[player.dataset.position]=player;
game.arrangePlayers();
},
2015-11-05 02:34:35 +00:00
chess_tongshuai:function(player,content){
if(player&&player.storage){
player.storage.tongshuai.owned=content;
}
else{
console.log(player);
}
},
chess_tongshuai_skill:function(player,content){
if(player&&content){
if(player.marks.tongshuai.firstChild){
player.marks.tongshuai.firstChild.remove();
}
player.marks.tongshuai.setBackground(content[0],'character');
player.additionalSkills.tongshuai=content[1];
}
else{
console.log(player);
}
},
2015-11-04 01:59:00 +00:00
reinit:function(source,content){
2015-11-05 02:34:35 +00:00
if(source&&content){
source.uninit();
source.init(content[0]);
source.node.identity.dataset.color=content[1];
}
else{
console.log(source);
}
2015-11-04 01:59:00 +00:00
},
skill:function(player,content){
if(typeof content=='string'){
lib.skill[content].video(player);
}
else if(Array.isArray(content)){
lib.skill[content[0]].video(player,content[1]);
}
2015-11-05 02:34:35 +00:00
else{
console.log(player,content)
}
2015-11-04 01:59:00 +00:00
},
addFellow:function(content){
var player=game.addFellow(content[0],content[1]);
game.playerMap[player.dataset.position]=player;
},
updateActCount:function(player,content){
2015-11-05 02:34:35 +00:00
if(player&&content){
player.updateActCount(content[0],content[1],content[2]);
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
showCharacter:function(player,num){
2015-11-05 02:34:35 +00:00
if(player&&player.classList){
switch(num){
case 0:
player.classList.remove('unseen');
break;
case 1:
player.classList.remove('unseen2');
break;
case 2:
player.classList.remove('unseen');
player.classList.remove('unseen2');
break;
}
}
else{
console.log(num);
2015-11-04 01:59:00 +00:00
}
},
popup:function(player,info){
2015-11-05 02:34:35 +00:00
if(player&&info){
player.popup(info[0],info[1]);
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
log:function(str){
game.log(str);
},
draw:function(player,info){
2015-11-05 02:34:35 +00:00
if(player&&player.$draw){
player.$draw(info);
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
drawCard:function(player,info){
2015-11-05 02:34:35 +00:00
if(player&&info){
player.$draw(get.infoCards(info));
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
throw:function(player,info){
2015-11-05 02:34:35 +00:00
if(player&&info){
player.$throw(get.infoCards(info[0]),info[1]);
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
compare:function(player,info){
2015-11-05 02:34:35 +00:00
if(player&&info){
player.$compare(get.infoCard(info[0]),game.playerMap[info[1]],get.infoCard(info[2]));
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
give:function(player,info){
2015-11-05 02:34:35 +00:00
if(player&&info){
player.$give(info[0],game.playerMap[info[1]]);
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
giveCard:function(player,info){
2015-11-05 02:34:35 +00:00
if(player&&info){
player.$give(get.infoCards(info[0]),game.playerMap[info[1]]);
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
gain:function(player,info){
2015-11-05 02:34:35 +00:00
if(player&&player.$gain){
player.$gain(info);
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
gainCard:function(player,info){
2015-11-05 02:34:35 +00:00
if(player&&info){
player.$gain(get.infoCards(info));
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
gain2:function(player,cards){
2015-11-05 02:34:35 +00:00
if(player&&player.$draw){
var nodeList=document.querySelectorAll('#arena>.card,#chess>.card');
var nodes=[];
for(var i=0;i<nodeList.length;i++){
nodes.push(nodeList[i]);
}
for(var i=0;i<cards.length;i++){
for(var j=0;j<nodes.length;j++){
if(cards[i][2]==nodes[j].name&&cards[i][0]==nodes[j].suit&&cards[i][1]==nodes[j].number){
nodes[j].moveTo(player).delete();
cards.splice(i--,1);
nodes.splice(j--,1);
break;
}
2015-11-04 01:59:00 +00:00
}
}
2015-11-05 02:34:35 +00:00
if(cards.length){
player.$draw(get.infoCards(cards));
}
2015-11-04 01:59:00 +00:00
}
2015-11-05 02:34:35 +00:00
else{
console.log(player);
2015-11-04 01:59:00 +00:00
}
},
deletenode:function(player,cards){
2015-11-05 02:34:35 +00:00
if(cards){
var nodeList=document.querySelectorAll('#arena>.card,#chess>.card');
var nodes=[];
for(var i=0;i<nodeList.length;i++){
nodes.push(nodeList[i]);
}
for(var i=0;i<cards.length;i++){
for(var j=0;j<nodes.length;j++){
if(cards[i][2]==nodes[j].name&&cards[i][0]==nodes[j].suit&&cards[i][1]==nodes[j].number){
nodes[j].delete();
cards.splice(i--,1);
nodes.splice(j--,1);
break;
}
2015-11-04 01:59:00 +00:00
}
}
}
2015-11-05 02:34:35 +00:00
else{
console.log(player,cards);
}
2015-11-04 01:59:00 +00:00
},
2015-11-06 10:05:08 +00:00
highlightnode:function(player,card){
if(card){
var nodeList=document.querySelectorAll('#arena>.card,#chess>.card');
var nodes=[];
for(var i=0;i<nodeList.length;i++){
nodes.push(nodeList[i]);
}
for(var j=nodes.length-1;j>=0;j--){
if(card[2]==nodes[j].name&&card[0]==nodes[j].suit&&card[1]==nodes[j].number){
nodes[j].classList.add('thrownhighlight');
break;
}
}
}
else{
console.log(player,cards);
}
},
2015-11-04 01:59:00 +00:00
uiClear:function(){
ui.clear();
},
judge1:function(player,content){
2015-11-05 02:34:35 +00:00
if(player&&content){
var judging=get.infoCard(content[0]);
2015-11-06 10:05:08 +00:00
if(lib.config.mode=='chess'){
judging.copy('thrown','center','thrownhighlight',ui.arena).animate('start');
}
else{
player.$throwordered(judging.copy('thrownhighlight'),true);
}
2015-11-05 02:34:35 +00:00
ui.create.dialog(content[1]).videoId=content[2];
2015-11-06 10:05:08 +00:00
ui.arena.classList.add('thrownhighlight');
2015-11-05 02:34:35 +00:00
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
centernode:function(content){
2015-11-06 10:05:08 +00:00
get.infoCard(content).copy('thrown','center','thrownhighlight',ui.arena).animate('start');
2015-11-04 01:59:00 +00:00
},
judge2:function(videoId){
for(var i=0;i<ui.dialogs.length;i++){
if(ui.dialogs[i].videoId==videoId){
ui.dialogs[i].close();
}
}
2015-11-06 10:05:08 +00:00
ui.arena.classList.remove('thrownhighlight');
2015-11-04 01:59:00 +00:00
},
unmarkname:function(player,name){
2015-11-05 02:34:35 +00:00
if(player&&player.unmark){
player.unmark(name);
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
unmark:function(player,name){
2015-11-05 02:34:35 +00:00
if(player&&player.marks&&player.marks[name]){
2015-11-04 01:59:00 +00:00
player.marks[name].delete();
delete player.marks[name];
}
},
flame:function(player,type){
2015-11-05 02:34:35 +00:00
if(player&&type){
player['$'+type]();
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
line:function(player,content){
2015-11-05 02:34:35 +00:00
if(player&&content){
player.line(game.playerMap[content[0]],content[1]);
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
damagepop:function(player,content){
2015-11-05 02:34:35 +00:00
if(player&&content){
player.$damagepop(content[0],content[1]);
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
damage:function(player,source){
2015-11-05 02:34:35 +00:00
if(player&&player.$damage){
player.$damage(game.playerMap[source]);
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
diex:function(player){
2015-11-05 02:34:35 +00:00
if(!player){
console.log('diex');
return;
}
2015-11-04 01:59:00 +00:00
var cards=player.get('hej');
for(var i=0;i<cards.length;i++){
cards[i].goto(ui.discardPile);
}
while(player.node.marks.childNodes.length){
player.node.marks.firstChild.remove();
}
player.classList.add('dead');
player.classList.remove('turnedover');
player.classList.remove('out');
2015-11-05 02:34:35 +00:00
player.node.count.innerHTML='0';
player.node.hp.hide();
player.node.equips.hide();
player.node.count.hide();
2015-11-04 01:59:00 +00:00
player.previous.next=player.next;
player.next.previous=player.previous;
game.players.remove(player);
game.dead.push(player);
if(lib.config.mode=='stone'){
setTimeout(function(){
player.delete();
},500);
}
},
addChessPlayer:function(content){
game.addChessPlayer.apply(this,content);
},
die:function(player){
2015-11-05 02:34:35 +00:00
if(!player){
console.log('die');
return;
}
2015-11-04 01:59:00 +00:00
player.$die();
if(lib.config.mode=='chess'){
delete lib.posmap[player.dataset.position];
setTimeout(function(){
player.delete();
},500);
for(var i=0;i<ui.phasequeue.length;i++){
if(ui.phasequeue[i].link==player){
ui.phasequeue[i].remove();
ui.phasequeue.splice(i,1);
break;
}
}
}
},
revive:function(player){
2015-11-05 02:34:35 +00:00
if(!player){
console.log('revive');
return;
}
2015-11-04 01:59:00 +00:00
player.classList.remove('dead');
2015-11-05 02:34:35 +00:00
player.node.hp.show();
player.node.equips.show();
player.node.count.show();
player.node.avatar.style.transform='';
player.node.avatar2.style.transform='';
2015-11-04 01:59:00 +00:00
player.removeAttribute('style');
},
update:function(player,info){
2015-11-05 02:34:35 +00:00
if(player&&info){
2015-11-04 01:59:00 +00:00
player.hp=info[1];
player.maxHp=info[2];
player.hujia=info[3];
player.update(info[0]);
}
2015-11-05 02:34:35 +00:00
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
phaseJudge:function(player,card){
2015-11-05 02:34:35 +00:00
if(player&&card){
player.$phaseJudge(get.infoCard(card));
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
directgain:function(player,cards){
2015-11-05 02:34:35 +00:00
if(player&&cards){
player.directgain(get.infoCards(cards));
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
gain12:function(player,cards12){
2015-11-05 02:34:35 +00:00
if(player&&cards12){
var cards1=get.infoCards(cards12[0]);
var cards2=get.infoCards(cards12[1]);
for(var i=0;i<cards1.length;i++){
cards1[i].animate('start');
player.node.handcards1.insertBefore(cards1[i],player.node.handcards1.firstChild);
}
for(var i=0;i<cards2.length;i++){
cards2[i].animate('start');
player.node.handcards2.insertBefore(cards2[i],player.node.handcards2.firstChild);
}
2015-11-04 01:59:00 +00:00
}
2015-11-05 02:34:35 +00:00
else{
console.log(player);
2015-11-04 01:59:00 +00:00
}
},
equip:function(player,card){
2015-11-05 02:34:35 +00:00
if(player&&card){
player.equip(get.infoCard(card));
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
addJudge:function(player,content){
2015-11-05 02:34:35 +00:00
if(player&&content){
var card=get.infoCard(content[0]);
card.viewAs=content[1];
player.node.judges.insertBefore(card,player.node.judges.firstChild);
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
markCharacter:function(player,content){
2015-11-05 02:34:35 +00:00
if(player&&content){
if(game.playerMap[content.target]){
content.target=game.playerMap[content.target];
}
var mark=player.markCharacter(content.target,content);
if(content.id){
player.marks[content.id]=mark;
}
2015-11-04 01:59:00 +00:00
}
2015-11-05 02:34:35 +00:00
else{
console.log(player);
2015-11-04 01:59:00 +00:00
}
},
mark:function(player,content){
if(player&&content){
var mark=player.mark(content.id,content);
}
2015-11-05 02:34:35 +00:00
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
markSkill:function(player,content){
if(player&&content){
if(content[1]){
player.markSkill(content[0],null,get.infoCard(content[1]));
}
else{
player.markSkill(content[0]);
}
}
2015-11-05 02:34:35 +00:00
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
unmarkSkill:function(player,name){
2015-11-09 03:15:16 +00:00
if(player&&player.unmarkSkill){
2015-11-04 01:59:00 +00:00
player.unmarkSkill(name);
}
2015-11-05 02:34:35 +00:00
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
storage:function(player,content){
if(player&&content){
if(content[2]){
switch(content[2]){
case 'cards':content[1]=get.infoCards(content[1]);break;
case 'card':content[1]=get.infoCard(content[1]);break;
}
}
player.storage[content[0]]=content[1];
}
2015-11-05 02:34:35 +00:00
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
markId:function(player,content){
2015-11-05 02:34:35 +00:00
if(player&&content){
player.mark(get.infoCard(content[0]),content[1]);
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
unmarkId:function(player,content){
2015-11-05 02:34:35 +00:00
if(player&&content){
player.unmark(get.infoCard(content[0]),content[1]);
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
lose:function(player,info){
2015-11-05 02:34:35 +00:00
if(player&&info){
var hs=info[0],es=info[1],js=info[2];
var phs=player.get('h'),pes=player.get('e'),pjs=player.get('j');
var checkMatch=function(l1,l2){
for(var i=0;i<l1.length;i++){
for(var j=0;j<l2.length;j++){
if(l2[j].suit==l1[i][0]&&l2[j].number==l1[i][1]&&l2[j].name==l1[i][2]){
l2[j].delete();
break;
}
2015-11-04 01:59:00 +00:00
}
}
}
2015-11-05 02:34:35 +00:00
checkMatch(hs,phs);
checkMatch(es,pes);
checkMatch(js,pjs);
}
else{
console.log(player);
2015-11-04 01:59:00 +00:00
}
},
loseAfter:function(player){
2015-11-05 02:34:35 +00:00
if(!player){
console.log('loseAfter');
return;
}
2015-11-04 01:59:00 +00:00
for(var i=player.node.handcards1.childNodes.length-1;i>0;i--){
if(player.node.handcards1.childNodes[i].classList.contains('removing')==false){
player.node.handcards1.childNodes[i].animate('last');
break;
}
}
for(var i=player.node.handcards2.childNodes.length-1;i>0;i--){
if(player.node.handcards2.childNodes[i].classList.contains('removing')==false){
player.node.handcards2.childNodes[i].animate('last');
break;
}
}
},
link:function(player,bool){
2015-11-05 02:34:35 +00:00
if(player&&player.classList){
if(bool){
player.classList.add('linked');
}
else{
player.classList.remove('linked');
}
2015-11-04 01:59:00 +00:00
}
else{
2015-11-05 02:34:35 +00:00
console.log(player);
2015-11-04 01:59:00 +00:00
}
},
turnOver:function(player,bool){
2015-11-05 02:34:35 +00:00
if(player&&player.classList){
if(bool){
player.classList.add('turnedover');
}
else{
player.classList.remove('turnedover');
}
2015-11-04 01:59:00 +00:00
}
else{
2015-11-05 02:34:35 +00:00
console.log(player);
2015-11-04 01:59:00 +00:00
}
},
showCards:function(player,info){
2015-11-05 02:34:35 +00:00
if(info){
var dialog=ui.create.dialog(info[0],get.infoCards(info[1]));
setTimeout(function(){
dialog.close();
},1000);
}
else{
console.log(player);
}
2015-11-04 01:59:00 +00:00
},
cardDialog:function(content){
if(Array.isArray(content)){
ui.create.dialog(content[0],get.infoCards(content[1])).videoId=content[2];
}
else if(typeof content=='number'){
for(var i=0;i<ui.dialogs.length;i++){
if(ui.dialogs[i].videoId==content){
ui.dialogs[i].close();
return;
}
}
}
},
dialogCapt:function(content){
for(var i=0;i<ui.dialogs.length;i++){
if(ui.dialogs[i].videoId==content[0]){
ui.dialogs[i].content.firstChild.innerHTML=content[1];
return;
}
}
},
swapSeat:function(content){
var player1=game.playerMap[content[0]];
var player2=game.playerMap[content[1]];
2015-11-05 02:34:35 +00:00
if(!player1||!player2){
console.log(content);
return;
}
2015-11-04 01:59:00 +00:00
var temp1,pos,i,num;
temp1=player1.dataset.position;
player1.dataset.position=player2.dataset.position;
player2.dataset.position=temp1;
game.arrangePlayers();
if(player1.dataset.position=='0'||player2.dataset.position=='0'){
pos=parseInt(player1.dataset.position);
if(pos==0) pos=parseInt(player2.dataset.position);
num=game.players.length+game.dead.length;
for(i=0;i<game.players.length;i++){
temp1=parseInt(game.players[i].dataset.position)-pos;
if(temp1<0) temp1+=num;
game.players[i].dataset.position=temp1;
}
for(i=0;i<game.dead.length;i++){
temp1=parseInt(game.dead[i].dataset.position)-pos;
if(temp1<0) temp1+=num;
game.dead[i].dataset.position=temp1;
}
}
game.playerMap={};
var players=game.players.concat(game.dead);
for(var i=0;i<players.length;i++){
game.playerMap[players[i].dataset.position]=players[i];
}
},
swapControl:function(player,hs){
2015-11-05 02:34:35 +00:00
if(player&&player.node){
var cards=get.infoCards(hs);
player.node.handcards1.innerHTML='';
player.node.handcards2.innerHTML='';
player.directgain(cards,false);
game.me.node.handcards1.delete();
game.me.node.handcards2.delete();
game.me=player;
ui.handcards1=player.node.handcards1.animate('start').fix();
ui.handcards2=player.node.handcards2.animate('start').fix();
ui.me.appendChild(ui.handcards1);
ui.me.appendChild(ui.handcards2);
2015-11-04 01:59:00 +00:00
2015-11-05 02:34:35 +00:00
ui.updateh(true);
if(lib.config.mode=='chess'){
ui.create.fakeme();
}
}
else{
console.log(player);
2015-11-04 01:59:00 +00:00
}
},
onSwapControl:function(){
game.onSwapControl();
},
swapPlayer:function(player,hs){
2015-11-05 02:34:35 +00:00
if(player&&player.node){
var cards=get.infoCards(hs);
player.node.handcards1.innerHTML='';
player.node.handcards2.innerHTML='';
player.directgain(cards,false);
var pos=parseInt(player.dataset.position);
var num=game.players.length+game.dead.length;
var players=game.players.concat(game.dead);
var temp;
for(var i=0;i<players.length;i++){
temp=parseInt(players[i].dataset.position)-pos;
if(temp<0) temp+=num;
players[i].dataset.position=temp;
}
game.me.node.handcards1.delete();
game.me.node.handcards2.delete();
game.me=player;
ui.handcards1=player.node.handcards1.animate('start').fix();
ui.handcards2=player.node.handcards2.animate('start').fix();
ui.me.appendChild(ui.handcards1);
ui.me.appendChild(ui.handcards2);
2015-11-04 01:59:00 +00:00
2015-11-05 02:34:35 +00:00
ui.updateh(true);
2015-11-04 01:59:00 +00:00
2015-11-05 02:34:35 +00:00
game.playerMap={};
var players=game.players.concat(game.dead);
for(var i=0;i<players.length;i++){
game.playerMap[players[i].dataset.position]=players[i];
}
}
else{
console.log(player);
2015-11-04 01:59:00 +00:00
}
},
over:function(str){
var dialog=ui.create.dialog('hidden');
dialog.content.innerHTML=str;
dialog.open();
}
},
2015-04-29 08:41:00 +00:00
reload:function(){
if(_status){
_status.reloading=true;
}
2015-11-05 02:34:35 +00:00
if(_status.video&&!_status.replayvideo){
localStorage.removeItem(lib.configprefix+'playbackmode');
}
2015-04-29 08:41:00 +00:00
window.location.reload();
},
2015-04-29 03:25:17 +00:00
update:function(func){
lib.updates.push(func);
if(lib.updates.length===1){
game.run();
}
2015-05-11 11:57:44 +00:00
return func;
},
unupdate:function(func){
lib.updates.remove(func);
2015-04-29 03:25:17 +00:00
},
stop:function(){
cancelAnimationFrame(lib.status.frameId);
},
run:function(){
if(lib.updates.length){
cancelAnimationFrame(lib.status.frameId);
lib.status.frameId=requestAnimationFrame(function(time){
if(lib.status.time!==0){
lib.status.delayed+=time-lib.status.time;
}
lib.status.frameId=requestAnimationFrame(lib.run);
});
}
},
2015-11-04 01:59:00 +00:00
addVideo:function(type,player,content){
if(_status.video) return;
if(!_status.videoInited) return;
if(game.getVideoName){
var time=get.time();
if(!_status.lastVideoLog){
_status.lastVideoLog=time;
}
if(get.itemtype(player)=='player'){
player=player.dataset.position;
}
lib.video.push({
type:type,
player:player,
content:content,
delay:time-_status.lastVideoLog
});
_status.lastVideoLog=time;
}
},
2015-04-29 03:25:17 +00:00
draw:function(func){
lib.canvasUpdates.push(func);
if(!lib.status.canvas){
lib.status.canvas=true;
game.update(lib.updateCanvas);
}
2015-09-25 00:26:16 +00:00
},
animate:{
flame:function(x,y,duration,type){
var particles=[];
var particle_count=50;
2015-09-26 13:11:55 +00:00
if(type=='thunder'||type=='recover'){
2015-09-25 05:05:26 +00:00
particle_count=30;
2015-09-25 00:26:16 +00:00
}
2015-10-20 17:44:00 +00:00
else if(type=='coin'||type=='dust'){
particle_count=50;
}
else if(type=='legend'){
particle_count=120;
}
else if(type=='epic'){
particle_count=80;
}
else if(type=='rare'){
particle_count=50;
}
2015-09-25 00:26:16 +00:00
for(var i = 0; i < particle_count; i++) {
particles.push(new particle());
}
function particle() {
this.speed = {x: -1+Math.random()*2, y: -5+Math.random()*5};
2015-10-20 17:44:00 +00:00
if(type=='thunder'||type=='coin'||type=='dust'){
2015-09-25 05:05:26 +00:00
this.speed.y=-3+Math.random()*5;
this.speed.x=-2+Math.random()*4;
}
2015-10-20 17:44:00 +00:00
if(type=='legend'||type=='rare'||type=='epic'){
this.speed.x*=3;
this.speed.y*=1.5;
}
2015-09-25 00:26:16 +00:00
this.location = {x: x, y: y};
this.radius = .5+Math.random()*1;
this.life = 10+Math.random()*10;
this.death = this.life;
switch(type){
case 'thunder':{
this.b = 255;
this.r = Math.round(Math.random()*255);
this.g = Math.round(Math.random()*255);
2015-09-25 05:05:26 +00:00
this.x+=Math.random()*20-10;
this.y+=Math.random()*20-10;
2015-09-25 00:26:16 +00:00
break;
}
case 'fire':{
this.r = 255;
this.g = Math.round(Math.random()*155);
this.b = 0;
break;
}
2015-10-20 17:44:00 +00:00
case 'coin':{
this.r = 255;
this.g = Math.round(Math.random()*25+230);
this.b = Math.round(Math.random()*100+50);
this.location.x+=Math.round(Math.random()*60)-30;
this.location.y+=Math.round(Math.random()*40)-20;
if(this.location.x<x){
this.speed.x=-Math.abs(this.speed.x);
}
else if(this.location.x>x){
this.speed.x=Math.abs(this.speed.x);
}
this.life*=1.3;
this.death*=1.3;
break;
}
case 'dust':{
this.r = Math.round(Math.random()*55)+105;
this.g = Math.round(Math.random()*55)+150;
this.b = 255;
this.location.x+=Math.round(Math.random()*60)-30;
this.location.y+=Math.round(Math.random()*40)-20;
if(this.location.x<x){
this.speed.x=-Math.abs(this.speed.x);
}
else if(this.location.x>x){
this.speed.x=Math.abs(this.speed.x);
}
this.life*=1.3;
this.death*=1.3;
break;
}
case 'legend':{
this.r = 255;
this.g = Math.round(Math.random()*100+155);
this.b = Math.round(Math.random()*100+50);
this.location.x+=Math.round(Math.random()*60)-30;
this.location.y+=Math.round(Math.random()*40)-20;
if(this.location.x<x){
this.speed.x=-Math.abs(this.speed.x);
}
else if(this.location.x>x){
this.speed.x=Math.abs(this.speed.x);
}
this.speed.x/=2;
this.speed.y/=2;
this.life*=2;
this.death*=2;
break;
}
case 'epic':{
this.r = Math.round(Math.random()*55)+200;
this.g = Math.round(Math.random()*100)+55;
this.b = 255;
this.location.x+=Math.round(Math.random()*60)-30;
this.location.y+=Math.round(Math.random()*40)-20;
if(this.location.x<x){
this.speed.x=-Math.abs(this.speed.x);
}
else if(this.location.x>x){
this.speed.x=Math.abs(this.speed.x);
}
this.speed.x/=2;
this.speed.y/=2;
this.life*=2;
this.death*=2;
break;
}
case 'rare':{
this.r = Math.round(Math.random()*55)+105;
this.g = Math.round(Math.random()*55)+150;
this.b = 255;
this.location.x+=Math.round(Math.random()*60)-30;
this.location.y+=Math.round(Math.random()*40)-20;
if(this.location.x<x){
this.speed.x=-Math.abs(this.speed.x);
}
else if(this.location.x>x){
this.speed.x=Math.abs(this.speed.x);
}
this.speed.x/=2;
this.speed.y/=2;
this.life*=2;
this.death*=2;
break;
}
2015-09-26 13:11:55 +00:00
case 'recover':{
this.g = 255;
this.r = Math.round(Math.random()*200+55);
this.b = Math.round(Math.random()*155+55);
this.location.x+=Math.round(Math.random()*60)-30;
this.location.y+=Math.round(Math.random()*40)-20;
if(this.location.x<x){
this.speed.x=-Math.abs(this.speed.x);
}
else if(this.location.x>x){
this.speed.x=Math.abs(this.speed.x);
}
this.speed.x/=2;
this.speed.y/=2;
this.life*=2;
this.death*=2;
break;
}
2015-09-25 00:26:16 +00:00
default:{
this.r = 255;
this.g = Math.round(Math.random()*155);
this.b = 0;
}
}
}
game.draw(function(time,surface){
surface.globalCompositeOperation = "source-over";
surface.globalCompositeOperation = "lighter";
for(var i = 0; i < particles.length; i++)
{
var p = particles[i];
surface.beginPath();
2015-09-25 05:05:26 +00:00
var middle=0.5;
var radius=p.radius;
2015-10-20 17:44:00 +00:00
if(type=='recover'||type=='legend'||type=='rare'||
type=='epic'||type=='coin'||type=='dust'){
2015-09-26 13:11:55 +00:00
middle=0.7;
radius/=3;
}
2015-09-25 00:26:16 +00:00
p.opacity = Math.round(p.death/p.life*100)/100
var gradient = surface.createRadialGradient(p.location.x, p.location.y, 0, p.location.x, p.location.y, p.radius);
gradient.addColorStop(0, "rgba("+p.r+", "+p.g+", "+p.b+", "+p.opacity+")");
2015-09-25 05:05:26 +00:00
gradient.addColorStop(middle, "rgba("+p.r+", "+p.g+", "+p.b+", "+p.opacity+")");
2015-09-25 00:26:16 +00:00
gradient.addColorStop(1, "rgba("+p.r+", "+p.g+", "+p.b+", 0)");
surface.fillStyle = gradient;
2015-09-25 05:05:26 +00:00
surface.arc(p.location.x, p.location.y, radius, Math.PI*2, false);
2015-09-25 00:26:16 +00:00
surface.fill();
p.death--;
2015-09-26 13:11:55 +00:00
if(type=='recover'){
p.radius+=0.5;
}
2015-10-20 17:44:00 +00:00
else if(type=='coin'||type=='dust'){
p.radius+=0.7;
}
else if(type=='legend'||type=='rare'||type=='epic'){
p.radius+=0.5;
}
2015-09-26 13:11:55 +00:00
else {
p.radius++;
}
2015-09-25 00:26:16 +00:00
p.location.x += (p.speed.x);
p.location.y += (p.speed.y);
if(p.death < 0 || p.radius < 0){
if(typeof duration=='number'&&time+500>=duration){
particles.splice(i--,1);
}
else{
particles[i] = new particle();
}
}
}
if(particles.length==0){
return false;
}
});
}
2015-04-29 03:25:17 +00:00
},
linexy:function(path){
var from=[path[0],path[1]];
var to=[path[2],path[3]];
var total=typeof arguments[1]==='number'?arguments[1]:lib.config.duration*2;
var opacity=1;
var color=[255,255,255];
2015-08-15 09:10:06 +00:00
var dashed=lib.config.line_dash;
2015-04-29 03:25:17 +00:00
if(typeof arguments[1]=='object'){
for(var i in arguments[1]){
switch(i){
case 'opacity':opacity=arguments[1][i];break;
case 'color':color=arguments[1][i];break;
case 'dashed':dashed=arguments[1][i];break;
case 'duration':total=arguments[1][i];break;
}
}
}
else if(arguments[1]=='fire'||arguments[1]=='thunder'||arguments[1]=='green'){
color=arguments[1];
}
if(color=='fire'){
color=[255, 146, 68];
}
else if(color=='thunder'){
color=[141, 216, 255];
}
else if(color=='green'){
color=[141, 255, 216];
}
2015-05-08 08:07:38 +00:00
var drawfunc=function(time,ctx){
2015-04-29 03:25:17 +00:00
var current;
if(time<total/3){
ctx.strokeStyle='rgba('+color.toString()+','+opacity*(time/(total/3))+')';
current=[from[0]+(to[0]-from[0])*time/(total/3),
from[1]+(to[1]-from[1])*time/(total/3)];
}
else if(time<=total){
current=to;
if(time>total/1.5){
ctx.strokeStyle='rgba('+color.toString()+','+opacity*(1-(time-total/1.5)/(total-total/1.5))+')';
}
else{
ctx.strokeStyle='rgba('+color.toString()+','+opacity+')';
}
}
else{
return false;
}
ctx.beginPath();
2015-08-15 09:10:06 +00:00
if(dashed){
2015-07-09 05:21:22 +00:00
ctx.lineCap='butt';
2015-04-29 03:25:17 +00:00
ctx.setLineDash([8,2]);
}
2015-08-15 09:10:06 +00:00
else{
ctx.lineCap='round';
}
2015-04-29 03:25:17 +00:00
ctx.moveTo(from[0],from[1]);
ctx.lineTo(current[0],current[1]);
ctx.stroke();
2015-05-08 08:07:38 +00:00
};
if(arguments[2]&&lib.config.mode=='chess'){
game.draw2(drawfunc);
}
else{
game.draw(drawfunc);
}
2015-04-29 03:25:17 +00:00
},
createEvent:function(name,trigger){
var next={
name:name,
step:0,
finished:false,
next:[],
aiexclude:[],
custom:{
add:{},
replace:{}
},
_result:{}
}
if(trigger!==false) next._triggered=0;
for(var i in lib.element.event){
next[i]=lib.element.event[i];
}
_status.event.next.push(next);
return next;
},
2015-08-15 09:10:06 +00:00
createCard:function(name,suit,number){
if(typeof name!='string'){
name='sha';
}
if(typeof suit!='string'){
suit=['heart','diamond','club','spade'].randomGet();
}
if(typeof number!='number'){
number=Math.ceil(Math.random()*13);
}
return ui.create.card(ui.special).init([suit,number,name]);
},
2015-04-29 03:25:17 +00:00
over:function(result){
var i,j,k,num,table,tr,td,dialog;
_status.over=true;
ui.control.show();
ui.clear();
2015-05-14 09:23:45 +00:00
if(lib.config.background_audio){
if(result===true){
game.playAudio('effect','win');
}
else if(result===false){
game.playAudio('effect','lose');
}
else{
game.playAudio('effect','tie');
}
}
2015-04-29 03:25:17 +00:00
if(result===true) result='战斗胜利';
if(result===false) result='战斗失败';
if(result==undefined) result='战斗结束';
dialog=ui.create.dialog(result);
2015-10-20 17:44:00 +00:00
if(game.addOverDialog){
game.addOverDialog(dialog,result);
}
2015-04-29 07:54:48 +00:00
if(true){
2015-04-29 03:25:17 +00:00
if(game.players.length){
table=document.createElement('table');
tr=document.createElement('tr');
tr.appendChild(document.createElement('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);
td=document.createElement('td');
td.innerHTML='出牌';
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML='杀敌';
tr.appendChild(td);
table.appendChild(tr);
for(i=0;i<game.players.length;i++){
tr=document.createElement('tr');
td=document.createElement('td');
td.innerHTML=get.translation(game.players[i]);
tr.appendChild(td);
td=document.createElement('td');
num=0;
for(j=0;j<game.players[i].stat.length;j++){
if(game.players[i].stat[j].damage!=undefined) num+=game.players[i].stat[j].damage;
}
td.innerHTML=num;
tr.appendChild(td);
td=document.createElement('td');
num=0;
for(j=0;j<game.players[i].stat.length;j++){
if(game.players[i].stat[j].damaged!=undefined) num+=game.players[i].stat[j].damaged;
}
td.innerHTML=num;
tr.appendChild(td);
td=document.createElement('td');
num=0;
for(j=0;j<game.players[i].stat.length;j++){
if(game.players[i].stat[j].gain!=undefined) num+=game.players[i].stat[j].gain;
}
td.innerHTML=num;
tr.appendChild(td);
td=document.createElement('td');
num=0;
for(j=0;j<game.players[i].stat.length;j++){
for(k in game.players[i].stat[j].card){
num+=game.players[i].stat[j].card[k];
}
}
td.innerHTML=num;
tr.appendChild(td);
td=document.createElement('td');
num=0;
for(j=0;j<game.players[i].stat.length;j++){
if(game.players[i].stat[j].kill!=undefined) num+=game.players[i].stat[j].kill;
}
td.innerHTML=num;
tr.appendChild(td);
table.appendChild(tr);
}
dialog.add(ui.create.div('.placeholder'));
dialog.content.appendChild(table);
}
if(game.dead.length){
table=document.createElement('table');
table.style.opacity='0.5';
if(game.players.length==0){
tr=document.createElement('tr');
tr.appendChild(document.createElement('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);
td=document.createElement('td');
td.innerHTML='出牌';
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML='杀敌';
tr.appendChild(td);
table.appendChild(tr);
}
for(i=0;i<game.dead.length;i++){
tr=document.createElement('tr');
td=document.createElement('td');
td.innerHTML=get.translation(game.dead[i]);
tr.appendChild(td);
td=document.createElement('td');
num=0;
for(j=0;j<game.dead[i].stat.length;j++){
if(game.dead[i].stat[j].damage!=undefined) num+=game.dead[i].stat[j].damage;
}
td.innerHTML=num;
tr.appendChild(td);
td=document.createElement('td');
num=0;
for(j=0;j<game.dead[i].stat.length;j++){
if(game.dead[i].stat[j].damaged!=undefined) num+=game.dead[i].stat[j].damaged;
}
td.innerHTML=num;
tr.appendChild(td);
td=document.createElement('td');
num=0;
for(j=0;j<game.dead[i].stat.length;j++){
if(game.dead[i].stat[j].gain!=undefined) num+=game.dead[i].stat[j].gain;
}
td.innerHTML=num;
tr.appendChild(td);
td=document.createElement('td');
num=0;
for(j=0;j<game.dead[i].stat.length;j++){
for(k in game.dead[i].stat[j].card){
num+=game.dead[i].stat[j].card[k];
}
}
td.innerHTML=num;
tr.appendChild(td);
td=document.createElement('td');
num=0;
for(j=0;j<game.dead[i].stat.length;j++){
if(game.dead[i].stat[j].kill!=undefined) num+=game.dead[i].stat[j].kill;
}
td.innerHTML=num;
tr.appendChild(td);
table.appendChild(tr);
}
dialog.add(ui.create.div('.placeholder'));
dialog.content.appendChild(table);
}
2015-05-05 14:57:35 +00:00
if(game.additionaldead&&game.additionaldead.length){
table=document.createElement('table');
table.style.opacity='0.5';
for(i=0;i<game.additionaldead.length;i++){
tr=document.createElement('tr');
td=document.createElement('td');
td.innerHTML=get.translation(game.additionaldead[i]);
tr.appendChild(td);
td=document.createElement('td');
num=0;
for(j=0;j<game.additionaldead[i].stat.length;j++){
if(game.additionaldead[i].stat[j].damage!=undefined) num+=game.additionaldead[i].stat[j].damage;
}
td.innerHTML=num;
tr.appendChild(td);
td=document.createElement('td');
num=0;
for(j=0;j<game.additionaldead[i].stat.length;j++){
if(game.additionaldead[i].stat[j].damaged!=undefined) num+=game.additionaldead[i].stat[j].damaged;
}
td.innerHTML=num;
tr.appendChild(td);
td=document.createElement('td');
num=0;
for(j=0;j<game.additionaldead[i].stat.length;j++){
if(game.additionaldead[i].stat[j].gain!=undefined) num+=game.additionaldead[i].stat[j].gain;
}
td.innerHTML=num;
tr.appendChild(td);
td=document.createElement('td');
num=0;
for(j=0;j<game.additionaldead[i].stat.length;j++){
for(k in game.additionaldead[i].stat[j].card){
num+=game.additionaldead[i].stat[j].card[k];
}
}
td.innerHTML=num;
tr.appendChild(td);
td=document.createElement('td');
num=0;
for(j=0;j<game.additionaldead[i].stat.length;j++){
if(game.additionaldead[i].stat[j].kill!=undefined) num+=game.additionaldead[i].stat[j].kill;
}
td.innerHTML=num;
tr.appendChild(td);
table.appendChild(tr);
}
dialog.add(ui.create.div('.placeholder'));
dialog.content.appendChild(table);
}
2015-04-29 03:25:17 +00:00
}
dialog.add(ui.create.div('.placeholder'));
dialog.add(ui.create.div('.placeholder'));
2015-11-04 01:59:00 +00:00
game.addVideo('over',null,dialog.content.innerHTML);
var vinum=parseInt(lib.config.video);
if(!_status.video&&vinum&&game.getVideoName&&window.indexedDB){
var store=lib.db.transaction(['video'],'readwrite').objectStore('video');
if(lib.videos.length>=vinum){
var toremove=lib.videos.pop();
store.delete(toremove.time);
}
var newvid={
name:game.getVideoName(),
mode:lib.config.mode,
video:lib.video,
win:result=='战斗胜利',
name1:game.me.name1||game.me.name,
name2:game.me.name2,
time:lib.getUTC(new Date())
};
lib.videos.unshift(newvid);
store.put(newvid);
2015-11-06 10:05:08 +00:00
lib.createVideoNode(newvid,true);
2015-11-04 01:59:00 +00:00
}
2015-11-06 10:05:08 +00:00
// _status.auto=false;
2015-11-05 02:34:35 +00:00
if(ui.auto){
2015-11-06 10:05:08 +00:00
// ui.auto.classList.remove('glow');
2015-11-05 02:34:35 +00:00
ui.auto.hide();
}
2015-10-20 17:44:00 +00:00
if(ui.wuxie) ui.wuxie.hide();
2015-11-04 01:59:00 +00:00
if(lib.storage.test){
setTimeout(game.reload,500);
}
2015-10-20 17:44:00 +00:00
if(game.controlOver){
game.controlOver();return;
}
2015-11-06 10:05:08 +00:00
// if(!ui.savevideo&&lib.db&&lib.config.savevideo){
// ui.savevideo=ui.create.control('保存录像',game.saveVideo);
// }
2015-04-29 03:25:17 +00:00
if(!ui.restart){
2015-04-29 08:41:00 +00:00
ui.restart=ui.create.control('restart',game.reload);
2015-04-29 03:25:17 +00:00
}
if(ui.revive){
ui.revive.close();
delete ui.revive;
}
if(ui.swap){
ui.swap.close();
delete ui.swap;
}
if(game.onOver) game.onOver(result);
},
loop:function(){
var event=_status.event;
var step=event.step;
var source=event.source;
var player=event.player;
var target=event.target;
var targets=event.targets;
var card=event.card;
var cards=event.cards;
var skill=event.skill;
var forced=event.forced;
var num=event.num;
var trigger=event._trigger;
var result=event._result;
2015-11-04 01:59:00 +00:00
if(_status.paused2||_status.imchoosing){
if(!lib.status.dateDelaying){
lib.status.dateDelaying=new Date();
}
2015-04-29 03:25:17 +00:00
}
2015-11-04 01:59:00 +00:00
if(_status.paused||_status.paused2||_status.over){
2015-04-29 03:25:17 +00:00
return;
}
2015-11-04 01:59:00 +00:00
if(lib.status.dateDelaying){
lib.status.dateDelayed+=lib.getUTC(new Date())-lib.getUTC(lib.status.dateDelaying);
delete lib.status.dateDelaying;
}
2015-04-29 03:25:17 +00:00
if(event.next.length>0){
var next=event.next.shift();
if(next.player&&next.player.skipList.contains(next.name)){
next.player.skipList.remove(next.name);
}
else{
next.parent=event;
_status.event=next;
}
}
else if(event.finished){
if(event._triggered==1){
if(event.type=='card') event.trigger('useCardToCancelled');
event.trigger(event.name+'Cancelled');
event._triggered=4;
}
else if(event._triggered==2){
if(event.type=='card') event.trigger('useCardToEnd');
event.trigger(event.name+'End');
event._triggered=3;
}
else if(event._triggered==3){
if(event.type=='card') event.trigger('useCardToAfter');
event.trigger(event.name+'After');
event._triggered++;
}
else{
if(event.parent){
if(event.result){
event.parent._result=event.result;
}
_status.event=event.parent;
}
else{
return;
}
}
}
else{
if(event._triggered==0){
if(event.type=='card') event.trigger('useCardToBefore');
event.trigger(event.name+'Before');
event._triggered++;
}
else if(event._triggered==1){
if(event.type=='card') event.trigger('useCardToBegin');
event.trigger(event.name+'Begin');
event._triggered++;
}
else{
if(player&&player.classList.contains('dead')&&event.name!='phaseLoop'){
2015-11-09 03:15:16 +00:00
while(_status.dieClose.length){
_status.dieClose.shift().close();
}
2015-04-29 03:25:17 +00:00
event.finish();
}
else if(player&&player.removed&&event.name!='phaseLoop'){
event.finish();
}
else if(player&&player.isOut()&&event.name!='phaseLoop'){
event.finish();
}
else{
eval(lib.init.parse(event.content))();
}
event.step++;
}
}
game.loop();
},
pause:function(){
clearTimeout(_status.timeout);
_status.paused=true;
},
pause2:function(){
_status.paused2=true;
},
resume:function(){
if(_status.paused){
_status.paused=false;
game.loop();
}
},
resume2:function(){
if(_status.paused2){
_status.paused2=false;
game.loop();
}
},
delay:function(time,time2){
if(_status.paused) return;
game.pause();
if(time==undefined) time=1;
if(time2==undefined) time2=0;
time=time*lib.config.duration+time2;
_status.timeout=setTimeout(game.resume,time);
},
2015-11-05 02:34:35 +00:00
delayx:function(time,time2){
2015-10-30 09:13:19 +00:00
if(typeof time!='number') time=1;
switch(lib.config.game_speed){
case 'vslow':time*=2.5;break;
case 'slow':time*=1.5;break;
case 'fast':time*=0.7;break;
case 'vfast':time*=0.4;break;
}
2015-11-05 02:34:35 +00:00
return game.delay(time,time2);
2015-10-30 09:13:19 +00:00
},
2015-04-29 03:25:17 +00:00
check:function(event){
var i,j,range;
if(event==undefined) event=_status.event;
var custom=event.custom||{};
var ok=true,auto=true;
var player=event.player;
if(!event.filterButton&&!event.filterCard&&!event.filterTarget&&!event.skill) return;
if(event.filterButton){
var dialog=event.dialog;
range=get.select(event.selectButton);
if(range[0]!=range[1]||range[0]>1) auto=false;
for(i=0;i<dialog.buttons.length;i++){
if(event.filterButton(dialog.buttons[i],player)&&lib.filter.buttonIncluded(dialog.buttons[i])){
if(ui.selected.buttons.length<range[1]){
dialog.buttons[i].classList.add('selectable');
}
else if(range[1]==-1){
dialog.buttons[i].classList.add('selected');
ui.selected.buttons.add(dialog.buttons[i]);
}
else{
dialog.buttons[i].classList.remove('selectable');
}
}
else{
dialog.buttons[i].classList.remove('selectable');
if(range[1]==-1){
dialog.buttons[i].classList.remove('selected');
ui.selected.buttons.remove(dialog.buttons[i]);
}
}
if(dialog.buttons[i].classList.contains('selected')){
dialog.buttons[i].classList.add('selectable');
}
}
if(ui.selected.buttons.length<range[0]){
if(!event.forced||get.selectableButtons().length)
ok=false;
if(event.complexSelect||event.parent.name=='chooseCharacter') ok=false;
}
if(custom.add.button){
custom.add.button();
}
}
if(event.filterCard){
if(ok==false){
game.uncheck('card');
}
else{
var cards;
if(event.position){
cards=player.get(event.position);
}
else{
cards=player.get('h');
}
range=get.select(event.selectCard);
if(range[0]!=range[1]||range[0]>1) auto=false;
for(i=0;i<cards.length;i++){
if(event.filterCard(cards[i],player)&&
lib.filter.cardAiIncluded(cards[i])&&
(player.isOut()==false||event.includeOutCard)&&
lib.filter.cardRespondable(cards[i],player)){
if(ui.selected.cards.length<range[1]){
cards[i].classList.add('selectable');
}
else if(range[1]==-1){
cards[i].classList.add('selected');
ui.selected.cards.add(cards[i]);
}
else{
cards[i].classList.remove('selectable');
}
}
else{
cards[i].classList.remove('selectable');
if(range[1]==-1){
cards[i].classList.remove('selected');
ui.selected.cards.remove(cards[i]);
}
}
if(cards[i].classList.contains('selected')){
cards[i].classList.add('selectable');
}
}
if(ui.selected.cards.length<range[0]){
if(!event.forced||get.selectableCards().length)
ok=false;
if(event.complexSelect) ok=false;
}
}
if(custom.add.card){
custom.add.card();
}
}
if(event.filterTarget){
if(ok==false){
game.uncheck('target');
}
else{
var card=get.card();
range=get.select(event.selectTarget);
if(range[0]!=range[1]||range[0]>1) auto=false;
for(i=0;i<game.players.length;i++){
2015-05-08 08:07:38 +00:00
var nochess=true;
2015-10-08 06:16:37 +00:00
if(lib.config.mode=='chess'&&!event.chessForceAll){
2015-05-08 08:07:38 +00:00
if(player&&get.distance(player,game.players[i],'pure')>7){
nochess=false;
}
}
2015-11-09 03:15:16 +00:00
if(event.filterTarget(card,player,game.players[i])&&!game.players[i].forceout&&
2015-05-08 08:07:38 +00:00
(game.players[i].isOut()==false||event.includeOutTarget)&&nochess){
2015-04-29 03:25:17 +00:00
if(ui.selected.targets.length<range[1]){
game.players[i].classList.add('selectable');
}
else if(range[1]==-1){
game.players[i].classList.add('selected');
ui.selected.targets.add(game.players[i]);
}
else{
game.players[i].classList.remove('selectable');
}
}
else{
game.players[i].classList.remove('selectable');
if(range[1]==-1){
game.players[i].classList.remove('selected');
ui.selected.targets.remove(game.players[i]);
}
}
if(game.players[i].classList.contains('selected')){
game.players[i].classList.add('selectable');
}
2015-05-11 11:57:44 +00:00
if(game.players[i].instance){
if(game.players[i].classList.contains('selected')){
game.players[i].instance.classList.add('selected');
}
else{
game.players[i].instance.classList.remove('selected');
}
if(game.players[i].classList.contains('selectable')){
game.players[i].instance.classList.add('selectable');
}
else{
game.players[i].instance.classList.remove('selectable');
}
}
2015-04-29 03:25:17 +00:00
}
if(ui.selected.targets.length<range[0]){
if(!event.forced||get.selectableTargets().length)
ok=false;
if(event.complexSelect) ok=false;
}
2015-05-08 13:37:34 +00:00
if(range[1]==-1&&ui.selected.targets.length==0&&event.targetRequired){
ok=false;
}
2015-04-29 03:25:17 +00:00
}
if(custom.add.target){
custom.add.target();
}
}
if(!event.skill&&get.noSelected()&&!_status.noconfirm){
var skills=[],enable,info;
var skills2=player.get('s').concat(player.hiddenSkills).concat(lib.skill.global);
game.expandSkills(skills2);
for(i=0;i<skills2.length;i++){
info=get.info(skills2[i]);
enable=false;
if(typeof info.enable=='function') enable=info.enable(event);
else if(typeof info.enable=='object') enable=info.enable.contains(event.name);
else if(info.enable=='phaseUse') enable=(event.parent.name=='phaseUse');
else if(typeof info.enable=='string') enable=(info.enable==event.name);
if(enable){
if(info.filter&&info.filter(event,player)==false) enable=false;
if(info.viewAs&&event.filterCard&&!event.filterCard(info.viewAs,player)) enable=false;
2015-06-27 16:21:25 +00:00
if(info.viewAs&&info.viewAsFilter&&info.viewAsFilter(player)==false) enable=false;
2015-04-29 03:25:17 +00:00
if(event.aiexclude.contains(skills2[i])) enable=false;
if(info.usable&&get.skillCount(skills2[i])>=info.usable) enable=false;
}
if(enable){
skills.add(skills2[i]);
}
}
if(skills.length){
ui.create.skills(skills);
}
else if(ui.skills){
ui.skills.close();
}
}
else if(ui.skills){
ui.skills.close()
}
_status.multitarget=false;
2015-05-10 05:34:37 +00:00
var skillinfo=get.info(_status.event.skill);
2015-04-29 03:25:17 +00:00
if(_status.event.name=='chooseToUse'){
if(skillinfo&&skillinfo.multitarget&&!skillinfo.multiline){
_status.multitarget=true;
}
if((skillinfo&&skillinfo.viewAs)||!_status.event.skill){
var cardinfo=get.info(get.card());
if(cardinfo&&cardinfo.multitarget&&!cardinfo.multiline){
_status.multitarget=true;
}
}
}
else if(_status.event.multitarget){
_status.multitarget=true;
}
if(event.isMine()){
2015-11-09 03:15:16 +00:00
if(lib.config.mode=='chess'&&game.me&&get.config('show_distance')){
for(var i=0;i<game.players.length;i++){
if(game.players[i]==game.me){
game.players[i].node.action.hide();
}
else{
game.players[i].node.action.show();
var dist=get.distance(game.me,game.players[i],'pure');
var dist2=get.distance(game.me,game.players[i]);
game.players[i].node.action.innerHTML='距离:'+dist2+'/'+dist;
if(dist>7){
game.players[i].node.action.classList.add('thunder');
}
else{
game.players[i].node.action.classList.remove('thunder');
}
}
}
}
2015-04-29 03:25:17 +00:00
if(ok&&auto&&lib.config.auto_confirm&&(!_status.mousedragging||!_status.mouseleft)&&!_status.mousedown){
2015-05-10 05:34:37 +00:00
if(ui.confirm){
if(!skillinfo||!skillinfo.preservecancel){
ui.confirm.close();
}
}
2015-04-29 03:25:17 +00:00
if(event.skillDialog==true) event.skillDialog=false;
ui.click.ok();
_status.mousedragging=null;
}
else{
ui.arena.classList.add('selecting');
_status.imchoosing=true;
if(!_status.noconfirm){
if(!_status.mousedown||_status.mouseleft){
var str='';
if(ok) str+='o';
if(!event.forced&&get.noSelected()) str+='c';
ui.create.confirm(str);
}
}
}
}
return ok;
},
uncheck:function(){
var i,j;
2015-05-08 13:37:34 +00:00
if(false){
if(lib.config.mode=='chess'){
var shadows=ui.chessContainer.getElementsByClassName('playergrid temp');
while(shadows.length){
shadows[0].remove();
}
}
}
2015-04-29 03:25:17 +00:00
if(arguments.length==0){
while(document.getElementsByClassName('selectable').length>0){
document.getElementsByClassName('selectable')[0].classList.remove('selectable');
}
while(document.getElementsByClassName('selected').length>0){
document.getElementsByClassName('selected')[0].classList.remove('selected');
}
if(_status.event.player){
var cards=_status.event.player.get('hej');
for(j=0;j<cards.length;j++){
cards[j].classList.remove('selected');
cards[j].classList.remove('selectable');
}
}
ui.selected.buttons.length=0;
ui.selected.cards.length=0;
ui.selected.targets.length=0;
}
else{
for(i=0;i<arguments.length;i++){
if(arguments[i]=='target'){
for(j=0;j<game.players.length;j++){
game.players[j].classList.remove('selected');
game.players[j].classList.remove('selectable');
2015-05-11 11:57:44 +00:00
if(game.players[j].instance){
game.players[j].instance.classList.remove('selected');
game.players[j].instance.classList.remove('selectable');
}
2015-04-29 03:25:17 +00:00
}
ui.selected.targets.length=0;
}
else if(arguments[i]=='card'){
var cards=_status.event.player.get('hej');
for(j=0;j<cards.length;j++){
cards[j].classList.remove('selected');
cards[j].classList.remove('selectable');
}
ui.selected.cards.length=0;
}
}
}
2015-07-09 05:21:22 +00:00
if(arguments[0]!='target'&&arguments[0]!='card'&&arguments[0]!='button'){
ui.arena.classList.remove('selecting');
_status.imchoosing=false;
_status.lastdragchange.length=0;
_status.mousedragging=null;
_status.mousedragorigin=null;
}
2015-04-29 03:25:17 +00:00
ui.canvas.width=ui.arena.offsetWidth;
ui.canvas.height=ui.arena.offsetHeight;
for(var i=0;i<game.players.length;i++){
game.players[i].unprompt();
}
},
swapSeat:function(player1,player2,prompt,behind){
if(behind){
2015-05-04 03:17:03 +00:00
var totalPopulation=game.players.length+game.dead.length+1;
2015-05-05 14:57:35 +00:00
for(var iwhile=0;iwhile<totalPopulation;iwhile++){
2015-05-04 03:17:03 +00:00
if(player1.next!=player2){
game.swapSeat(player1,player1.next,false,false);
}
else{
break;
}
2015-04-29 03:25:17 +00:00
}
if(prompt!=false){
game.log(get.translation(player1)+'将座位移至'+get.translation(player2)+'后');
}
}
else{
2015-11-04 01:59:00 +00:00
game.addVideo('swapSeat',null,[player1.dataset.position,player2.dataset.position]);
2015-04-29 03:25:17 +00:00
var temp1,pos,i,num;
temp1=player1.dataset.position;
player1.dataset.position=player2.dataset.position;
player2.dataset.position=temp1;
game.arrangePlayers();
2015-05-08 08:07:38 +00:00
if(lib.config.mode!='chess'){
if(player1.dataset.position=='0'||player2.dataset.position=='0'){
pos=parseInt(player1.dataset.position);
if(pos==0) pos=parseInt(player2.dataset.position);
num=game.players.length+game.dead.length;
for(i=0;i<game.players.length;i++){
temp1=parseInt(game.players[i].dataset.position)-pos;
if(temp1<0) temp1+=num;
game.players[i].dataset.position=temp1;
}
for(i=0;i<game.dead.length;i++){
temp1=parseInt(game.dead[i].dataset.position)-pos;
if(temp1<0) temp1+=num;
game.dead[i].dataset.position=temp1;
}
2015-04-29 03:25:17 +00:00
}
}
if(prompt!=false){
game.log(get.translation(player1)+'和'+get.translation(player2)+'交换了座位');
}
}
},
swapPlayer:function(player,player2){
if(player2){
if(player==game.me) game.swapPlayer(player2);
else if(player2==game.me) game.swapPlayer(player);
}
else{
if(player==game.me) return;
2015-11-04 01:59:00 +00:00
game.addVideo('swapPlayer',player,get.cardsInfo(player.get('h')));
2015-04-29 03:25:17 +00:00
var pos=parseInt(player.dataset.position);
var num=game.players.length+game.dead.length;
var players=game.players.concat(game.dead);
var temp;
for(var i=0;i<players.length;i++){
temp=parseInt(players[i].dataset.position)-pos;
if(temp<0) temp+=num;
players[i].dataset.position=temp;
}
game.me.node.handcards1.delete();
game.me.node.handcards2.delete();
game.me=player;
2015-04-29 14:56:33 +00:00
ui.handcards1=player.node.handcards1.animate('start').fix();
ui.handcards2=player.node.handcards2.animate('start').fix();
2015-04-29 03:25:17 +00:00
ui.me.appendChild(ui.handcards1);
ui.me.appendChild(ui.handcards2);
2015-05-07 04:48:00 +00:00
ui.updateh(true);
2015-04-29 03:25:17 +00:00
}
if(game.me.isAlive()){
if(ui.auto) ui.auto.show();
if(ui.wuxie) ui.wuxie.show();
2015-04-29 03:25:17 +00:00
if(ui.revive){
ui.revive.close();
delete ui.revive;
}
if(ui.swap){
ui.swap.close();
delete ui.swap;
}
if(ui.restart){
ui.restart.close();
delete ui.restart;
}
}
2015-10-31 10:14:14 +00:00
if(lib.config.mode=='identity'){
game.me.setIdentity(game.me.identity);
}
2015-04-29 03:25:17 +00:00
},
swapControl:function(player){
if(player==game.me) return;
game.me.node.handcards1.delete();
game.me.node.handcards2.delete();
game.me=player;
2015-04-29 14:56:33 +00:00
ui.handcards1=player.node.handcards1.animate('start').fix();
ui.handcards2=player.node.handcards2.animate('start').fix();
2015-04-29 03:25:17 +00:00
ui.me.appendChild(ui.handcards1);
ui.me.appendChild(ui.handcards2);
2015-05-07 04:48:00 +00:00
ui.updateh(true);
2015-11-04 01:59:00 +00:00
game.addVideo('swapControl',player,get.cardsInfo(player.get('h')));
2015-05-05 09:23:31 +00:00
if(game.me.isAlive()){
if(ui.auto) ui.auto.show();
if(ui.wuxie) ui.wuxie.show();
2015-05-05 09:23:31 +00:00
if(ui.revive){
ui.revive.close();
delete ui.revive;
}
if(ui.swap){
ui.swap.close();
delete ui.swap;
}
if(ui.restart){
ui.restart.close();
delete ui.restart;
}
}
2015-04-29 03:25:17 +00:00
},
2015-05-12 09:51:40 +00:00
findNext:function(player){
var players=get.players(lib.sort.position);
var position=parseInt(player.dataset.position);
for(var i=0;i<players.length;i++){
if(parseInt(players[i].dataset.position)>=position){
return players[i];
}
}
return players[0];
},
2015-04-29 03:25:17 +00:00
phaseLoop:function(player){
var next=game.createEvent('phaseLoop');
next.player=player;
next.content=function(){
"step 0"
player.phase();
"step 1"
2015-05-12 09:51:40 +00:00
if(!game.players.contains(event.player.next)){
event.player=game.findNext(event.player.next);
2015-04-29 03:25:17 +00:00
}
else{
event.player=event.player.next;
}
event.goto(0);
}
},
gameDraw:function(player,num){
var next=game.createEvent('gameDraw');
next.player=player;
if(num==undefined) next.num=4;
else next.num=num;
next.content=function(){
"step 0"
var end=player;
do{
2015-05-13 10:26:54 +00:00
player.directgain(get.cards(4));
2015-11-09 17:04:18 +00:00
if(player.singleHp===true&&lib.config.mode!='guozhan'){
2015-04-29 10:02:31 +00:00
player.doubleDraw();
}
2015-04-29 03:25:17 +00:00
player=player.next;
}
while(player!=end);
"step 1"
if(get.config('change_card')){
event.dialog=ui.create.dialog('是否使用手气卡?');
ui.create.confirm('oc');
event.custom.replace.confirm=function(bool){
_status.event.bool=bool;
game.resume();
}
}
else{
event.finish();
}
"step 2"
game.pause();
"step 3"
if(event.bool){
game.me.lose(game.me.get('h'))._triggered=null;
2015-04-29 03:25:17 +00:00
}
else{
event.dialog.close();
ui.confirm.close();
event.finish();
}
"step 4"
game.delay();
game.me.gain(get.cards(4))._triggered=null;
2015-04-29 03:25:17 +00:00
"step 5"
event.goto(2);
}
},
asyncDraw:function(players,num){
for(var i=0;i<players.length;i++){
var num2=1;
if(typeof num=='number'){
num2=num;
}
else if(Array.isArray(num)){
num2=num[i];
}
players[i].draw(num2,false);
players[i].$draw(num2);
}
},
finishCards:function(){
var i,j,k;
for(i in lib.card){
var card=lib.card[i];
if(card.type=='equip'){
if(card.enable==undefined) card.enable=true;
if(card.selectTarget==undefined) card.selectTarget=-1;
if(card.filterTarget==undefined) card.filterTarget=function(card,player,target){
return target==player;
};
if(card.content==undefined) card.content=function(){
target.equip(card);
};
if(card.ai==undefined) card.ai={basic:{}};
if(card.ai.basic==undefined) card.ai.basic={};
if(card.ai.result==undefined) card.ai.result={target:1.5};
2015-11-06 10:05:08 +00:00
if(card.ai.basic.order==undefined) card.ai.basic.order=function(card,player){
return 8+ai.get.equipValue(card,player)/20;
};
2015-04-29 03:25:17 +00:00
if(card.ai.basic.useful==undefined) card.ai.basic.useful=2;
if(card.subtype=='equip3'){
if(card.ai.basic.equipValue==undefined) card.ai.basic.equipValue=6;
}
else if(card.subtype=='equip4'){
if(card.ai.basic.equipValue==undefined) card.ai.basic.equipValue=5;
}
else{
if(card.ai.basic.equipValue==undefined) card.ai.basic.equipValue=1;
}
if(card.ai.basic.value==undefined)card.ai.basic.value=function(card,player){
var value=0;
var info=get.info(card);
if(player.get('e',info.subtype[5])&&card!=player.get('e',info.subtype[5])){
value=ai.get.value(player.get('e',info.subtype[5]),player);
}
var equipValue=info.ai.equipValue||info.ai.basic.equipValue;
if(typeof equipValue=='function') return equipValue(card,player)-value;
return equipValue-value;
}
card.ai.result.target=function(player,target){
var card=get.card();
if(card==undefined) return 0;
var value1=ai.get.value(card,target);
var value2=0;
if(target[get.subtype(card)]&&target[get.subtype(card)]!=card)
value2=ai.get.value(target[get.subtype(card)],target);
if(value1>value2) return 1;
return -1;
};
}
else if(card.type=='delay'){
if(card.enable==undefined) card.enable=true;
if(card.filterTarget==undefined) card.filterTarget=lib.filter.judge;
if(card.content==undefined) card.content=function(){
target.addJudge(card,cards);
};
}
}
for(i in lib.skill){
if(lib.skill[i].forbid&&lib.skill[i].forbid.contains(lib.config.mode)){
lib.skill[i]={};
if(lib.translate[i+'_info']){
lib.translate[i+'_info']='此模式下不可用';
}
continue;
}
if(lib.skill[i].mode&&lib.skill[i].mode.contains(lib.config.mode)==false){
lib.skill[i]={};
if(lib.translate[i+'_info']){
lib.translate[i+'_info']='此模式下不可用';
}
continue;
}
if(lib.skill[i].viewAs){
if(lib.skill[i].ai==undefined) lib.skill[i].ai={};
var skill=lib.skill[i].ai;
var card=lib.card[lib.skill[i].viewAs.name].ai;
for(j in card){
if(skill[j]==undefined) skill[j]=card[j];
else if(typeof skill[j]=='object'){
for(var k in card[j]){
if(skill[j][k]==undefined) skill[j][k]=card[j][k];
}
}
}
}
if(lib.skill[i].inherit){
var skill=lib.skill[lib.skill[i].inherit];
for(j in skill){
if(lib.skill[i][j]==undefined) lib.skill[i][j]=skill[j];
}
if(lib.translate[i+'_info']==undefined){
lib.translate[i+'_info']=lib.translate[lib.skill[i].inherit+'_info'];
}
}
if(i[0]=='_'){
lib.skill.global.add(i);
}
}
},
checkMod:function(){
var name=arguments[arguments.length-2];
var skills=arguments[arguments.length-1].concat(lib.skill.global);
game.expandSkills(skills);
var arg=[],i,info;
for(i=0;i<arguments.length-2;i++){
arg.push(arguments[i]);
}
for(i=0;i<skills.length;i++){
info=get.info(skills[i]);
if(info.mod&&info.mod[name]){
var result=info.mod[name].apply(this,arg);
if(typeof arg[arg.length-1]!='object'&&result!=undefined) arg[arg.length-1]=result;
}
}
return arg[arg.length-1];
},
prepareArena:function(num){
ui.create.arena();
ui.create.players(num);
ui.create.me();
ui.create.cards();
game.finishCards();
},
log:function(str){
if(str==undefined) str='';
var node=ui.create.div();
node.innerHTML=str;
ui.sidebar.insertBefore(node,ui.sidebar.firstChild);
2015-11-04 01:59:00 +00:00
game.addVideo('log',null,str);
2015-04-29 03:25:17 +00:00
if(lib.config.title) document.title=str;
},
save:function(key,value){
2015-04-29 08:41:00 +00:00
if(_status.reloading) return;
2015-04-29 03:25:17 +00:00
var config={};
if(arguments.length>0){
try{
config=JSON.parse(localStorage.getItem(lib.configprefix+lib.config.mode));
if(typeof config!='object') throw 'err';
}
catch(err){
config={};
}
if(value==undefined){
delete config[key];
delete lib.storage[key];
}
else{
config[key]=value;
lib.storage[key]=value;
}
}
config.version=game.version;
localStorage.setItem(lib.configprefix+lib.config.mode,JSON.stringify(config));
},
updateSave:function(){
2015-04-29 08:41:00 +00:00
if(_status.reloading) return;
2015-04-29 03:25:17 +00:00
localStorage.setItem(lib.configprefix+lib.config.mode,JSON.stringify(lib.storage));
},
saveConfig:function(key,value,local){
2015-04-29 08:41:00 +00:00
if(_status.reloading) return;
2015-04-29 03:25:17 +00:00
var config;
try{
config=JSON.parse(localStorage.getItem(lib.configprefix+'config'));
if(!config||typeof config!='object') throw 'err'
}
catch(err){
config={};
}
if(local){
2015-10-29 17:36:14 +00:00
var localmode;
if(typeof local=='string'){
localmode=local;
}
else{
localmode=lib.config.mode;
}
if(!lib.config.mode_config[localmode]){
lib.config.mode_config[localmode]={};
}
lib.config.mode_config[localmode][key]=value;
key+='_mode_config_'+localmode;
2015-04-29 03:25:17 +00:00
}
else{
2015-04-29 07:54:48 +00:00
lib.config[key]=value;
2015-04-29 03:25:17 +00:00
}
config[key]=value;
localStorage.setItem(lib.configprefix+'config',JSON.stringify(config));
},
addPlayer:function(position,character,character2){
if(position<0||position>game.players.length+game.dead.length||position==undefined){
position=Math.ceil(Math.random()*(game.players.length+game.dead.length));
}
var players=game.players.concat(game.dead);
ui.arena.dataset.number=players.length+1;
for(var i=0;i<players.length;i++){
if(parseInt(players[i].dataset.position)>=position){
players[i].dataset.position=parseInt(players[i].dataset.position)+1;
}
}
var player=ui.create.player(ui.arena).animate('start');
if(character) player.init(character,character2);
game.players.push(player);
player.dataset.position=position;
game.arrangePlayers();
return player;
},
2015-05-03 15:17:15 +00:00
addFellow:function(position,character){
2015-11-04 01:59:00 +00:00
game.addVideo('addFellow',null,[position,character]);
2015-05-03 15:17:15 +00:00
var player=ui.create.player(ui.arena).animate('start');
player.dataset.position=position||game.players.length+game.dead.length;
if(character) player.init(character);
game.players.push(player);game.arrangePlayers();
return player;
},
2015-04-29 03:25:17 +00:00
restorePlayer:function(player){
if(game.players.contains(player)||game.dead.contains(player)) return;
var position=parseInt(player.dataset.position);
if(position<0||position>game.players.length+game.dead.length||position==undefined){
position=Math.ceil(Math.random()*(game.players.length+game.dead.length));
}
var players=game.players.concat(game.dead);
ui.arena.dataset.number=players.length+1;
for(var i=0;i<players.length;i++){
if(parseInt(players[i].dataset.position)>=position){
players[i].dataset.position=parseInt(players[i].dataset.position)+1;
}
}
game.players.push(player);
delete player.removed;
player.removeAttribute('style');
player.animate('start');
ui.arena.appendChild(player);
game.arrangePlayers();
return player;
},
removePlayer:function(player){
var players=game.players.concat(game.dead);
player.style.top=player.offsetTop+'px';
player.style.left=player.offsetLeft+'px';
if(player==undefined) player=game.dead[0]||game.me.next;
var position=parseInt(player.dataset.position);
for(var i=0;i<players.length;i++){
if(parseInt(players[i].dataset.position)>position){
players[i].dataset.position=parseInt(players[i].dataset.position)-1;
}
}
if(player.isAlive()){
player.next.previous=player.previous;
player.previous.next=player.next;
}
player.nextSeat.previousSeat=player.previousSeat;
player.previousSeat.nextSeat=player.nextSeat;
player.delete();
game.players.remove(player);
game.dead.remove(player);
ui.arena.dataset.number=players.length-1;
player.removed=true;
if(player==game.me){
ui.me.hide();
ui.auto.hide();
ui.wuxie.hide();
2015-04-29 03:25:17 +00:00
}
setTimeout(function(){
player.removeAttribute('style');
},500);
return player;
},
replacePlayer:function(player,character,character2){
player.removed=true;
var position=parseInt(player.dataset.position);
game.players.remove(player);
game.dead.remove(player);
player.delete();
var player2=ui.create.player(ui.arena).animate('start');
if(character) player2.init(character,character2);
game.players.push(player2);
player2.dataset.position=position;
player2.nextSeat=player.nextSeat;
player2.previousSeat=player.previousSeat;
player2.nextSeat.previousSeat=player2;
player2.previousSeat.nextSeat=player2;
var player3=player2.nextSeat;
while(player3.isDead()) player3=player3.nextSeat;
player3.previous=player2;
player2.next=player3;
var player4=player2.previousSeat;
while(player4.isDead()) player4=player4.previousSeat;
player4.next=player2;
player2.previous=player4;
return player2;
},
arrangePlayers:function(){
game.players.sort(lib.sort.position);
var players=game.players.concat(game.dead);
players.sort(lib.sort.position);
for(var i=0;i<players.length;i++){
if(i==0){
players[i].previousSeat=players[players.length-1];
}
else{
players[i].previousSeat=players[i-1];
}
if(i==players.length-1){
players[i].nextSeat=players[0];
}
else{
players[i].nextSeat=players[i+1];
}
}
for(var i=0;i<game.players.length;i++){
if(i==0){
game.players[i].previous=game.players[game.players.length-1];
}
else{
game.players[i].previous=game.players[i-1];
}
if(i==game.players.length-1){
game.players[i].next=game.players[0];
}
else{
game.players[i].next=game.players[i+1];
}
}
},
filterSkills:function(skills,player){
var out=skills.slice(0);
var filter=[];
for(var i in player.disabledSkills){
if(typeof player.disabledSkills[i]=='string'){
filter.add(player.disabledSkills[i]);
}
else if(Array.isArray(player.disabledSkills[i])){
for(var j=0;j<player.disabledSkills[i].length;j++){
filter.add(player.disabledSkills[i][j]);
}
}
}
for(var i=0;i<filter.length;i++){
if(filter[i]){
out.remove(filter[i]);
}
}
return out;
},
expandSkills:function(skills){
var skills2=[];
for(var i=0;i<skills.length;i++){
if(get.info(skills[i]).group) skills2=skills2.concat(get.info(skills[i]).group);
}
for(var i=0;i<skills2.length;i++){
skills.add(skills2[i]);
}
return skills;
},
css:function(style){
for(var i in style){
if(ui.style[i]) ui.style[i].innerHTML=i+JSON.stringify(style[i]).replace(/"/g,"");
else{
ui.style[i]=document.createElement('style');
ui.style[i].innerHTML=i+JSON.stringify(style[i]).replace(/"/g,"");
document.head.appendChild(ui.style[i]);
}
}
},
players:[],
dead:[],
imported:[],
phaseNumber:0
};
var ui={
updates:[],
2015-11-06 10:05:08 +00:00
thrown:[],
2015-04-29 03:25:17 +00:00
refresh:function(node){
void window.getComputedStyle(node, null).getPropertyValue("opacity");
},
create:{
2015-10-29 17:36:14 +00:00
div:function(){
var str,innerHTML,position,position2,style,divposition,listen;
2015-04-29 03:25:17 +00:00
for(var i=0;i<arguments.length;i++){
2015-10-29 17:36:14 +00:00
if(typeof arguments[i]=='string'){
if(typeof str=='string'){
innerHTML=arguments[i];
}
else{
str=arguments[i];
}
}
2015-04-29 03:25:17 +00:00
else if(get.objtype(arguments[i])=='div'||
get.objtype(arguments[i])=='table'||
get.objtype(arguments[i])=='tr'||
get.objtype(arguments[i])=='td'||
get.objtype(arguments[i])=='body') position=arguments[i];
else if(typeof arguments[i]=='number') position2=arguments[i];
else if(get.itemtype(arguments[i])=='divposition') divposition=arguments[i];
else if(typeof arguments[i]=='object') style=arguments[i];
2015-10-29 17:36:14 +00:00
else if(typeof arguments[i]=='function') listen=arguments[i];
2015-04-29 03:25:17 +00:00
}
if(str==undefined) str='';
var node=document.createElement('div');
for(var i=0;i<str.length;i++){
if(str[i]=='.'){
if(node.className.length!=0){
node.className+=' ';
}
while(str[i+1]!='.'&&str[i+1]!='#'&&i+1<str.length){
node.className+=str[i+1];
i++;
}
}
else if(str[i]=='#'){
while(str[i+1]!='.'&&str[i+1]!='#'&&i+1<str.length){
node.id+=str[i+1];
i++;
}
}
}
if(position){
if(typeof position2=='number'&&position.childNodes.length>position2){
position.insertBefore(node,position.childNodes[position2]);
}
else{
position.appendChild(node);
}
}
if(style) node.css(style);
if(divposition) node.setPosition(divposition);
2015-10-29 17:36:14 +00:00
if(innerHTML) node.innerHTML=innerHTML;
if(listen) node.listen(listen);
2015-04-29 03:25:17 +00:00
return node;
},
table:function(){
var str,row,col,position,position2,fixed,style,divposition;
for(var i=0;i<arguments.length;i++){
if(typeof arguments[i]=='string') str=arguments[i];
else if(typeof arguments[i]=='number'){
if(typeof row=='number'){
if(typeof col=='number') position2=arguments[i];
else col=arguments[i];
}
else row=arguments[i];
}
else if(get.objtype(arguments[i])=='div'||
get.objtype(arguments[i])=='table'||
get.objtype(arguments[i])=='tr'||
get.objtype(arguments[i])=='td'||
get.objtype(arguments[i])=='body') position=arguments[i];
else if(typeof arguments[i]=='boolean') fixed=arguments[i];
else if(get.itemtype(arguments[i])=='divposition') divposition=arguments[i];
else if(typeof arguments[i]=='object') style=arguments[i];
}
if(str==undefined) str='';
var node=document.createElement('table');
for(var i=0;i<str.length;i++){
if(str[i]=='.'){
if(node.className.length!=0){
node.className+=' ';
}
while(str[i+1]!='.'&&str[i+1]!='#'&&i+1<str.length){
node.className+=str[i+1];
i++;
}
}
else if(str[i]=='#'){
while(str[i+1]!='.'&&str[i+1]!='#'&&i+1<str.length){
node.id+=str[i+1];
i++;
}
}
}
var tr,td;
for(var i=0;i<row;i++){
tr=document.createElement('tr');
if(fixed) tr.style.height=(100/row)+'%';
node.appendChild(tr);
for(var j=0;j<col;j++){
td=document.createElement('td');
tr.appendChild(td);
}
}
if(position){
if(typeof position2=='number'&&position.childNodes.length>position2){
position.insertBefore(node,position.childNodes[position2]);
}
else{
position.appendChild(node);
}
}
return node;
},
2015-05-02 09:54:39 +00:00
groupControl:function(dialog){
return ui.create.control('wei','shu','wu','qun',function(link,node){
if(link=='全部'){
dialog.currentcapt='';
dialog.currentgroup='';
for(var i=0;i<dialog.buttons.length;i++){
dialog.buttons[i].style.display='';
}
}
else{
if(node.classList.contains('thundertext')){
dialog.currentgroup=null;
dialog.currentgroupnode=null;
node.classList.remove('thundertext');
for(var i=0;i<dialog.buttons.length;i++){
if(dialog.currentcapt&&dialog.buttons[i].capt!=dialog.currentcapt){
dialog.buttons[i].style.display='none';
}
else{
dialog.buttons[i].style.display='';
}
}
}
else{
if(dialog.currentgroupnode){
dialog.currentgroupnode.classList.remove('thundertext');
}
dialog.currentgroup=link;
dialog.currentgroupnode=node;
node.classList.add('thundertext');
for(var i=0;i<dialog.buttons.length;i++){
if(dialog.buttons[i].group!=link||
(dialog.currentcapt&&dialog.buttons[i].capt!=dialog.currentcapt)){
dialog.buttons[i].style.display='none';
}
else{
dialog.buttons[i].style.display='';
}
}
}
}
});
},
cardDialog:function(){
var args=['thisiscard'];
for(var i=0;i<arguments.length;i++){
args.push(arguments[i]);
}
return ui.create.characterDialog.apply(this,args);
},
characterDialog:function(){
var filter,str,noclick,thisiscard;
for(var i=0;i<arguments.length;i++){
if(arguments[i]==='thisiscard'){
thisiscard=true;
}
else if(typeof arguments[i]==='string'){
str=arguments[i];
}
else if(typeof arguments[i]==='function'){
filter=arguments[i];
}
else if(typeof arguments[i]=='boolean'){
noclick=arguments[i];
}
}
var list=[];
var dialog;
var node=ui.create.div('.caption');
var namecapt=[];
var getCapt=function(str){
if(str.indexOf('_')==-1){
return str[0];
}
return str[str.indexOf('_')+1];
}
if(thisiscard){
for(var i in lib.card){
if(!lib.translate[i+'_info']) continue;
if(filter&&filter(i)) continue;
list.push(['',get.translation(lib.card[i].type),i]);
if(namecapt.indexOf(getCapt(i))==-1){
namecapt.push(getCapt(i));
}
}
}
else{
for(var i in lib.character){
2015-05-11 03:43:37 +00:00
if(lib.character[i][4].contains('minskin')) continue;
2015-05-11 11:57:44 +00:00
if(lib.character[i][4].contains('boss')) continue;
if(lib.character[i][4].contains('hiddenboss')) continue;
2015-05-02 09:54:39 +00:00
if(filter&&filter(i)) continue;
list.push(i);
if(namecapt.indexOf(getCapt(i))==-1){
namecapt.push(getCapt(i));
}
}
}
namecapt.sort(function(a,b){
return a>b?1:-1;
});
var clickCapt=function(e){
if(_status.dragged) return;
if(this.classList.contains('thundertext')){
dialog.currentcapt=null;
dialog.currentcaptnode=null;
this.classList.remove('thundertext');
for(var i=0;i<dialog.buttons.length;i++){
if(dialog.currentgroup&&dialog.buttons[i].group!=dialog.currentgroup){
dialog.buttons[i].style.display='none';
}
else{
dialog.buttons[i].style.display='';
}
}
}
else{
if(dialog.currentcaptnode){
dialog.currentcaptnode.classList.remove('thundertext');
}
dialog.currentcapt=this.link;
dialog.currentcaptnode=this;
this.classList.add('thundertext');
for(var i=0;i<dialog.buttons.length;i++){
if(dialog.buttons[i].capt!=dialog.currentcapt||
(dialog.currentgroup&&dialog.buttons[i].group!=dialog.currentgroup)){
dialog.buttons[i].style.display='none';
}
else{
dialog.buttons[i].style.display='';
}
}
}
e.stopPropagation();
};
for(i=0;i<namecapt.length;i++){
var span=document.createElement('span');
span.innerHTML=' '+namecapt[i].toUpperCase()+' ';
span.link=namecapt[i];
span.addEventListener(lib.config.touchscreen?'touchend':'click',clickCapt);
node.appendChild(span);
}
var groupSort;
if(thisiscard){
2015-05-03 15:17:15 +00:00
groupSort=function(name){
if(lib.card[name[2]].type=='basic') return 0;
2015-06-16 13:24:35 +00:00
if(lib.card[name[2]].type=='stonecard') return 0.5;
2015-05-03 15:17:15 +00:00
if(lib.card[name[2]].type=='stonecharacter') return 1;
2015-05-10 05:34:37 +00:00
if(lib.card[name[2]].type=='chess') return 1.5;
2015-05-03 15:17:15 +00:00
if(lib.card[name[2]].type=='trick') return 2;
if(lib.card[name[2]].type=='delay') return 3;
if(lib.card[name[2]].type=='equip') return 4;
if(lib.card[name[2]].type=='zhenfa') return 5;
return 6;
};
2015-05-02 09:54:39 +00:00
}
else{
groupSort=function(name){
if(lib.character[name][1]=='wei') return 0;
if(lib.character[name][1]=='shu') return 1;
if(lib.character[name][1]=='wu') return 2;
if(lib.character[name][1]=='qun') return 3;
}
}
list.sort(function(a,b){
var del=groupSort(a)-groupSort(b);
if(del!=0) return del;
var aa=a,bb=b;
if(a.indexOf('_')!=-1){
a=a.slice(a.indexOf('_')+1);
}
if(b.indexOf('_')!=-1){
b=b.slice(b.indexOf('_')+1);
}
if(a!=b){
return a>b?1:-1;
}
return aa>bb?1:-1;
});
dialog=ui.create.dialog('hidden');
if(str){
dialog.add(str);
}
dialog.add(node);
if(thisiscard){
dialog.add([list,'vcard'],noclick);
}
else{
dialog.add([list,'character'],noclick);
}
dialog.add(ui.create.div('.placeholder'));
for(i=0;i<dialog.buttons.length;i++){
if(thisiscard){
dialog.buttons[i].capt=getCapt(dialog.buttons[i].link[2]);
}
else{
dialog.buttons[i].group=lib.character[dialog.buttons[i].link][1];
dialog.buttons[i].capt=getCapt(dialog.buttons[i].link);
}
}
return dialog;
},
2015-04-29 03:25:17 +00:00
dialog:function(){
var i;
var hidden=false;
var dialog=ui.create.div('.dialog');
dialog.contentContainer=ui.create.div('.content-container',dialog);
dialog.content=ui.create.div('.content',dialog.contentContainer);
dialog.bar1=ui.create.div('.bar.top',dialog);
dialog.bar2=ui.create.div('.bar.bottom',dialog);
dialog.buttons=[];
for(i in lib.element.dialog){
dialog[i]=lib.element.dialog[i];
}
for(i=0;i<arguments.length;i++){
if(typeof arguments[i]=='boolean') dialog.static=arguments[i];
else if(arguments[i]=='hidden') hidden=true;
else dialog.add(arguments[i]);
}
if(!hidden){
dialog.open();
}
if(!lib.config.touchscreen) dialog.contentContainer.onscroll=ui.update;
dialog.contentContainer.ontouchstart=ui.click.touchStart;
dialog.contentContainer.ontouchmove = ui.click.touchScroll;
dialog.contentContainer.style.WebkitOverflowScrolling='touch';
return dialog;
},
line2:function(){
var node=ui.create.line.apply(this,arguments);
node.classList.add('line2');
return node;
},
line:function(){
var two=false,func;
var node=ui.create.div('.config');
for(var i=0;i<arguments.length;i++){
if(typeof arguments[i]=='string'||typeof arguments[i]=='number'){
if(two) ui.create.div('.toggle',node).innerHTML=arguments[i];
else {
ui.create.div(node).innerHTML=arguments[i];
two=true;
}
}
else if(typeof arguments[i]=='function') func=arguments[i];
}
if(func){
for(var i=0;i<node.childNodes.length;i++) node.childNodes[i].listen(func);
}
return node;
},
switcher:function(name,current,current2){
var func;
var node=ui.create.div('.config');
ui.create.div(node).innerHTML=get.translation(name+'_config');
var switcher=ui.create.div('.toggle',node);
switcher.name=name;
for(var i=0;i<arguments.length;i++){
if(typeof arguments[i]=='function'){
func=arguments[i];break;
}
}
if(typeof current=='string'){
switcher.link=current;
switcher.innerHTML=get.translation(current);
switcher.contentEditable=true;
switcher.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.editor);
}
else if(typeof current=='object'){
switcher.link=current2||current[0];
switcher.innerHTML=get.translation(switcher.link);
switcher.choice=current;
switcher.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.switcher);
}
else{
if(current){
switcher.classList.add('on');
}
switcher.classList.add('onoff');
ui.create.div(ui.create.div(switcher));
switcher.link=current?true:false;
switcher.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.toggle);
}
if(func) switcher.additionalCommand=func;
return node;
},
caption:function(str,position){
var caption=ui.create.div('.caption',position);
caption.innerHTML=str;
return caption;
},
control:function(){
var i,controls;
2015-10-20 17:44:00 +00:00
var nozoom=false;
2015-04-29 03:25:17 +00:00
if(get.objtype(arguments[0])=='array') controls=arguments[0];
else controls=arguments;
2015-05-10 05:34:37 +00:00
var control=ui.create.div('.control');
2015-09-03 03:49:14 +00:00
ui.control.insertBefore(control,_status.createControl||ui.confirm);
2015-04-29 03:25:17 +00:00
for(i in lib.element.control){
control[i]=lib.element.control[i];
}
for(i=0;i<controls.length;i++){
if(typeof controls[i]=='function'){
control.custom=controls[i];
}
2015-10-20 17:44:00 +00:00
else if(controls[i]=='nozoom'){
nozoom=true;
}
2015-04-29 03:25:17 +00:00
else{
control.add(controls[i]);
}
}
ui.controls.unshift(control);
2015-10-20 17:44:00 +00:00
if(nozoom){
control.classList.add('nozoom');
}
2015-04-29 03:25:17 +00:00
if(control.childNodes.length){
2015-10-20 17:44:00 +00:00
if(nozoom){
control.style.transition='opacity 0.5s';
}
2015-04-29 03:25:17 +00:00
var width=0;
for(i=0;i<control.childNodes.length;i++) width+=control.childNodes[i].offsetWidth;
2015-05-01 03:25:06 +00:00
ui.refresh(control);
control.style.width=width+'px';
control.style.opacity=1;
2015-10-20 17:44:00 +00:00
ui.refresh(control);
control.style.transition='';
2015-04-29 03:25:17 +00:00
}
return control;
},
confirm:function(str,func){
if(ui.confirm&&ui.confirm.str==str){
return;
}
if(str=='o'){
if(ui.confirm){
ui.confirm.replace('ok');
}
else{
ui.confirm=ui.create.control('ok');
}
}
else if(str=='oc'||str=='co'){
if(ui.confirm){
ui.confirm.replace('ok','cancel');
}
else{
ui.confirm=ui.create.control('ok','cancel');
}
}
else if(str=='c'){
if(ui.confirm){
ui.confirm.replace('cancel');
}
else{
ui.confirm=ui.create.control('cancel');
}
}
else if(ui.confirm){
ui.confirm.close();
delete ui.confirm;
}
if(ui.confirm){
ui.confirm.str=str;
if(func) ui.confirm.custom=func;
else delete ui.confirm.custom;
}
},
skills:function(skills){
var i,same;
if(ui.skills){
if(ui.skills.skills.length==skills.length&&ui.skills.style.display!='none'){
same=true;
for(i=0;i<skills.length;i++){
if(ui.skills.skills.contains(skills[i])==false){
same=false;
break;
}
}
}
if(same) return;
ui.skills.close();
delete ui.skills;
}
if(skills==undefined||skills.length==0) return;
2015-05-01 03:25:06 +00:00
ui.skills=ui.create.control(skills.concat([ui.click.skill]));
if(!_status.event.isMine()){
2015-04-29 03:25:17 +00:00
ui.skills.style.display='none';
}
ui.skills.skills=skills;
return ui.skills;
},
arena:function(){
var i,j;
ui.window=ui.create.div('#window',document.body).animate('start');
ui.window.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.window);
ui.system=ui.create.div("#system.",ui.window);
ui.arena=ui.create.div('#arena',ui.window);
2015-10-31 16:18:20 +00:00
if(lib.config.layout=='mobile'||lib.config.layout=='phone'){
2015-10-31 10:14:14 +00:00
ui.arena.classList.add('mobile');
}
2015-11-01 09:56:48 +00:00
ui.updatePhone();
2015-04-29 14:56:33 +00:00
ui.backgroundMusic=document.createElement('audio');
2015-04-30 03:09:07 +00:00
ui.backgroundMusic.volume=lib.config.volumn_background/8;
2015-04-29 14:56:33 +00:00
game.playBackgroundMusic();
ui.backgroundMusic.autoplay=true;
ui.backgroundMusic.addEventListener('ended',game.playBackgroundMusic);
ui.window.appendChild(ui.backgroundMusic);
2015-04-30 03:09:07 +00:00
2015-04-29 03:25:17 +00:00
ui.sidebar=ui.create.div('#sidebar');
ui.sidebar3=ui.create.div('#sidebar3');
2015-04-29 03:25:17 +00:00
ui.canvas=document.createElement('canvas');
2015-08-15 09:10:06 +00:00
if(lib.config.bottom_line){
ui.canvas.style.zIndex=0;
}
2015-04-29 03:25:17 +00:00
ui.arena.appendChild(ui.canvas);
ui.canvas.id='canvas';
ui.ctx=ui.canvas.getContext('2d');
2015-05-01 07:35:43 +00:00
ui.configbg=ui.create.div("#click");
ui.configbg.listen(ui.click.config2);
ui.configbg.oncontextmenu=ui.click.config2;
2015-04-29 03:25:17 +00:00
ui.config=ui.create.div('#sidebar2.content');
2015-05-02 06:59:31 +00:00
ui.config.listen(function(){
2015-05-08 08:07:38 +00:00
if(_status.reloading) return;
if(_status.choosing){
if(!_status.choosing.expand){
_status.choosing.parentNode.style.height='';
_status.choosing.nextSibling.delete();
_status.choosing.previousSibling.show();
delete _status.choosing;
}
}
_status.clicked=true;
if(ui.arena.classList.contains('selecting')){
game.check();
}
2015-04-30 08:24:57 +00:00
});
2015-04-29 07:54:48 +00:00
ui.config.oncontextmenu=function(e){
e.stopPropagation();
return false;
};
2015-04-29 03:25:17 +00:00
ui.sidebar.ontouchstart=ui.click.touchStart;
ui.config.ontouchstart=ui.click.touchStart;
ui.sidebar.ontouchmove = ui.click.touchScroll;
ui.config.ontouchmove = ui.click.touchScroll;
ui.sidebar.style.WebkitOverflowScrolling='touch';
ui.config.style.WebkitOverflowScrolling='touch';
2015-10-29 17:36:14 +00:00
if(false&&lib.config.right_sidebar){
ui.sidebar.classList.add('right');
ui.sidebar3.classList.add('left');
2015-04-29 03:25:17 +00:00
ui.config.classList.add('right');
}
2015-10-29 17:36:14 +00:00
// var folditems=[];
// var foldsubitems=[];
//
// var fold=function(list){
// if(foldsubitems.contains(list)){
// for(var i=0;i<list.length;i++){
// if(!list[i].link.classList.contains('hidden')){
// list[i].link.hide();
// list[i].link.parentNode.style.height='20px';
// }
// }
// }
// for(i=0;i<list.length;i++){
// if(list[i]) list[i].delete();
// }
// }
// var unfold=function(node,list){
// for(var i=0;i<folditems.length;i++){
// if(folditems[i]!=list){
// if(folditems[i]._configstr){
// game.saveConfig(folditems[i]._configstr,false);
// }
// else{
// folditems[i].fold=false;
// }
// fold(folditems[i]);
// }
// }
// for(i=list.length-1;i>=0;i--){
// if(list[i]){
// list[i].animate('start');
// node.parentNode.parentNode.insertBefore(list[i],node.parentNode.nextSibling);
// }
// }
// node.clicked=true;
// setTimeout(function(){
// node.clicked=false;
// },600);
// }
//
//
// var newgame=[];
// newgame._configstr='newgame';
// folditems.push(newgame);
// ui.config.appendChild(ui.create.line2('新游戏',function(){
// if(this.clicked) return;
// if(lib.config.newgame){
// game.saveConfig('newgame',false);
// fold(newgame);
// }
// else{
// game.saveConfig('newgame',true);
// unfold(this,newgame);
// }
//
// }));
// var span1='<div style="width:20px;text-align:center;padding-right:0">-</div>';
// var span2='<div style="width:20px;text-align:center;padding-right:0">·</div>';
// var clickmode=function(){
// game.saveConfig('mode',this.parentNode.link);
// game.reload();
// };
// for(var i=0;i<lib.config.all.mode.length;i++){
// var thismode=lib.config.all.mode[i];
// var line=ui.create.line((lib.config.mode==thismode?span1:span2)+lib.translate[thismode]+'模式',clickmode);
// line.link=thismode;
// newgame.push(line);
// }
//
// if(!lib.config.modeconfig&&!lib.config.gameconfig&&!lib.config.appearence){
// for(i=0;i<newgame.length;i++){
// ui.config.appendChild(newgame[i]);
// }
// }
//
// ui.config.appendChild(ui.create.div('.placeholder'));
//
//
//
// var modeconfig=[];
// modeconfig._configstr='modeconfig';
// folditems.push(modeconfig);
// ui.config.appendChild(ui.create.line2(get.translation(lib.config.mode)+'选项',function(){
// if(this.clicked) return;
// if(lib.config.modeconfig){
// game.saveConfig('modeconfig',false);
// fold(modeconfig);
// }
// else{
// game.saveConfig('modeconfig',true);
// unfold(this,modeconfig);
// }
// }));
// for(i=0;i<lib.config.current_mode.length;i++){
// if(typeof lib.config.current_mode[i]==='function'){
// var result=lib.config.current_mode[i](game,lib,get,ui);
// if(typeof result=='string'){
// lib.config.current_mode[i]=result;
// }
// else{
// if(get.objtype(result)=='div'){
// modeconfig.push(result);
// }
// continue;
// }
// }
// switch(lib.config.current_mode[i]){
// case 'difficulty':
// modeconfig.push(ui.create.switcher('difficulty',['easy','normal','hard'],get.config('difficulty'),ui.click.sidebar.local));break;
// case 'initshow_draw':
// modeconfig.push(ui.create.switcher('initshow_draw',[0,1,2],get.config('initshow_draw'),ui.click.sidebar.local));break;
// case 'ai_strategy':
// modeconfig.push(ui.create.switcher('ai_strategy',
// ['ai_strategy_1','ai_strategy_2','ai_strategy_3','ai_strategy_4','ai_strategy_5','ai_strategy_6'],
// get.config('ai_strategy'),ui.click.sidebar.local));break;
// case 'ai_identity':
// modeconfig.push(ui.create.switcher('ai_identity',get.config('ai_identity'),ui.click.sidebar.local));break;
// case 'auto_identity':
// modeconfig.push(ui.create.switcher('auto_identity',['一轮','两轮','三轮','关闭'],get.config('auto_identity'),ui.click.sidebar.auto_identity));break;
// case 'player_number':
// modeconfig.push(ui.create.switcher('player_number',[2,3,4,5,6,7,8],get.config('player_number'),ui.click.sidebar.player_number));break;
// case 'battle_number':
// var battle_number;
// if(lib.config.mode=='chess'){
// battle_number=[2,3,4,6,8];
// }
// else{
// battle_number=[1,2,3,5,8,16];
// }
// modeconfig.push(ui.create.switcher('battle_number',battle_number,get.config('battle_number'),ui.click.sidebar.battle_number));break;
// case 'double_character':
// modeconfig.push(ui.create.switcher('double_character',get.config('double_character'),ui.click.sidebar.local));break;
// case 'double_hp':
// modeconfig.push(ui.create.switcher('double_hp',lib.config.all.double_hp,get.config('double_hp'),ui.click.sidebar.local2));break;
// case 'free_choose':
// modeconfig.push(ui.create.switcher('free_choose',get.config('free_choose'),ui.click.sidebar.free_choose));break;
// case 'change_card':
// modeconfig.push(ui.create.switcher('change_card',get.config('change_card'),ui.click.sidebar.local));break;
// case 'change_choice':
// modeconfig.push(ui.create.switcher('change_choice',get.config('change_choice'),ui.click.sidebar.change_choice));break;
// case 'change_identity':
// modeconfig.push(ui.create.switcher('change_identity',get.config('change_identity'),ui.click.sidebar.change_identity));break;
// case 'swap':
// modeconfig.push(ui.create.switcher('swap',get.config('swap'),ui.click.sidebar.swap));break;
// case 'revive':
// modeconfig.push(ui.create.switcher('revive',get.config('revive'),ui.click.sidebar.revive));break;
// case 'dierestart':
// modeconfig.push(ui.create.switcher('dierestart',get.config('dierestart'),ui.click.sidebar.local2));break;
// case 'ban_weak':
// modeconfig.push(ui.create.switcher('ban_weak',get.config('ban_weak'),ui.click.sidebar.local2));break;
// case 'enhance_zhu':
// modeconfig.push(ui.create.switcher('enhance_zhu',get.config('enhance_zhu'),ui.click.sidebar.local2));break;
// case 'strict_sort':
// modeconfig.push(ui.create.switcher('strict_sort',get.config('strict_sort'),ui.click.sidebar.local));
// modeconfig.push(ui.create.switcher('reverse_sort',get.config('reverse_sort'),ui.click.sidebar.reverse_sort));break;
// default:{
// if(Array.isArray(lib.config.current_mode[i])){
// modeconfig.push(ui.create.switcher.apply(this,lib.config.current_mode[i]));
// }
// else{
// modeconfig.push(ui.create.div('.placeholder'));
// }
// }
// }
// }
// for(i in lib.config.current_mode){
// if(i=='difficulty'&&lib.config.current_mode[i]==true){
//
// }
// else if(i=='initshow_draw'&&lib.config.current_mode[i]==true){
//
// }
// }
// if(lib.config.modeconfig){
// for(i=0;i<modeconfig.length;i++){
// ui.config.appendChild(modeconfig[i]);
// }
// }
// var gameconfig=[];
// gameconfig._configstr='gameconfig';
// folditems.push(gameconfig);
// ui.config.appendChild(ui.create.line2('通用选项',function(){
// if(this.clicked) return;
// if(lib.config.gameconfig){
// game.saveConfig('gameconfig',false);
// fold(gameconfig);
// }
// else{
// game.saveConfig('gameconfig',true);
// unfold(this,gameconfig);
// }
// }));
//
// gameconfig.push(ui.create.switcher('cheat',lib.config.cheat,ui.click.sidebar.cheat));
// gameconfig.push(ui.create.switcher('auto_confirm',lib.config.auto_confirm,ui.click.sidebar.global));
// gameconfig.push(ui.create.switcher('enable_drag',lib.config.enable_drag,ui.click.sidebar.global));
// ui.wuxie_self=ui.create.switcher('wuxie_self',lib.config.wuxie_self,ui.click.sidebar.global);
// gameconfig.push(ui.wuxie_self);
// gameconfig.push(ui.create.switcher('duration',[500,700,1000],lib.config.duration,ui.click.sidebar.global));
// gameconfig.push(ui.create.switcher('hoveration',[700,1000,1500],lib.config.hoveration,ui.click.sidebar.global));
// gameconfig.push(ui.create.div('.placeholder'));
// gameconfig.push(ui.create.switcher('right_click',['pause','config','auto'],lib.config.right_click,ui.click.sidebar.global));
// gameconfig.push(ui.create.switcher('right_info',lib.config.right_info,ui.click.sidebar.global2));
// gameconfig.push(ui.create.switcher('hover_all',lib.config.hover_all,ui.click.sidebar.hover_all));
// ui.hoverhandcardconfig=ui.create.switcher('hover_handcard',lib.config.hover_handcard,ui.click.sidebar.global);
// gameconfig.push(ui.hoverhandcardconfig);
// if(!lib.config.hover_all) ui.hoverhandcardconfig.classList.add('disabled');
// gameconfig.push(ui.create.switcher('touchscreen',lib.config.touchscreen,ui.click.sidebar.touchscreen));
// // gameconfig.push(ui.create.switcher('no_ios_zoom',lib.config.no_ios_zoom,ui.click.sidebar.global));
// ui.handcardmousewheel=ui.create.switcher('mousewheel',lib.config.mousewheel,ui.click.sidebar.mousewheel);
// if(lib.config.touchscreen) ui.handcardmousewheel.classList.add('disabled');
// gameconfig.push(ui.handcardmousewheel);
//
// gameconfig.push(ui.create.div('.placeholder'));
// gameconfig.push(ui.create.switcher('background_music',lib.config.all.background_music,lib.config.background_music,ui.click.sidebar.background_music));
// gameconfig.push(ui.create.switcher('background_audio',lib.config.background_audio,ui.click.sidebar.global));
// gameconfig.push(ui.create.switcher('background_speak',lib.config.background_speak,ui.click.sidebar.global));
// gameconfig.push(ui.create.switcher('background_ogg',lib.config.background_ogg,ui.click.sidebar.global));
// gameconfig.push(ui.create.div('.placeholder'));
//
// if(lib.config.gameconfig){
// for(i=0;i<gameconfig.length;i++){
// ui.config.appendChild(gameconfig[i]);
// }
// }
2015-10-30 09:13:19 +00:00
switch(lib.config.ui_zoom){
case 'esmall':ui.window.style.zoom=0.8;break;
case 'vsmall':ui.window.style.zoom=0.9;break;
case 'small':ui.window.style.zoom=0.95;break;
case 'big':ui.window.style.zoom=1.05;break;
case 'vbig':ui.window.style.zoom=1.1;break;
2015-11-05 02:34:35 +00:00
case 'ebig':ui.window.style.zoom=1.2;break;
2015-10-30 09:13:19 +00:00
default:ui.window.style.zoom=1;
}
2015-10-29 17:36:14 +00:00
// if(true||lib.config.no_ios_zoom){
// var meta=document.createElement('meta');
// meta.name='viewport';
// meta.content="user-scalable=0";
// document.head.appendChild(meta);
// }
//
// var appearence=[];
// appearence._configstr='appearence';
// folditems.push(appearence);
// ui.config.appendChild(ui.create.line2('外观选项',function(){
// if(this.clicked) return;
// if(lib.config.appearence){
// game.saveConfig('appearence',false);
// fold(appearence);
// }
// else{
// game.saveConfig('appearence',true);
// unfold(this,appearence);
// }
// }));
// appearence.push(ui.create.switcher('theme',lib.config.all.theme,lib.config.theme,ui.click.sidebar.theme));
// var layoutconfig=ui.create.switcher('layout',lib.config.all.layout,lib.config.layout,ui.click.sidebar.layout);
// appearence.push(layoutconfig);
// if(lib.config.layoutfixed.contains(lib.config.mode)){
// layoutconfig.classList.add('disabled');
// }
// appearence.push(ui.create.switcher('image_background',lib.config.all.image_background,lib.config.image_background,ui.click.sidebar.image_background));
// appearence.push(ui.create.switcher('image_background_filter',lib.config.all.image_background_filter,lib.config.image_background_filter,ui.click.sidebar.image_background_filter));
// appearence.push(ui.create.switcher('ui_zoom',['极小','很小','较小','原始','较大','很大'],lib.config.ui_zoom,ui.click.sidebar.ui_zoom));
//
2015-04-29 03:25:17 +00:00
// appearence.push(ui.create.div('.placeholder'));
2015-10-29 17:36:14 +00:00
// appearence.push(ui.create.switcher('auto_popped',lib.config.auto_popped,ui.click.sidebar.global));
// appearence.push(ui.create.switcher('only_fullskin',lib.config.only_fullskin,ui.click.sidebar.global2));
// appearence.push(ui.create.switcher('hide_card_image',lib.config.hide_card_image,ui.click.sidebar.global2));
// appearence.push(ui.create.switcher('bottom_line',lib.config.bottom_line,ui.click.sidebar.bottom_line));
// appearence.push(ui.create.switcher('line_dash',lib.config.line_dash,ui.click.sidebar.global2));
// appearence.push(ui.create.switcher('show_name',lib.config.show_name,ui.click.sidebar.show_name));
// appearence.push(ui.create.switcher('show_replay',lib.config.show_replay,ui.click.sidebar.show_replay));
// appearence.push(ui.create.switcher('show_playerids',lib.config.show_playerids,ui.click.sidebar.show_playerids));
// appearence.push(ui.create.switcher('show_pause',lib.config.show_pause,ui.click.sidebar.show_pause));
// appearence.push(ui.create.switcher('show_auto',lib.config.show_auto,ui.click.sidebar.show_auto));
// appearence.push(ui.create.switcher('show_volumn',lib.config.show_volumn,ui.click.sidebar.show_volumn));
// appearence.push(ui.create.switcher('show_wuxie',lib.config.show_wuxie,ui.click.sidebar.show_wuxie));
// appearence.push(ui.create.switcher('show_wuxie_self',lib.config.show_wuxie_self,ui.click.sidebar.global));
// appearence.push(ui.create.switcher('show_discardpile',lib.config.show_discardpile,ui.click.sidebar.global));
// appearence.push(ui.create.div('.placeholder'));
// appearence.push(ui.create.switcher('title',lib.config.title,ui.click.sidebar.title));
//
// appearence.push(ui.create.switcher('fold_card',lib.config.fold_card,ui.click.sidebar.fold_card));
// appearence.push(ui.create.switcher('threed_card',lib.config.threed_card,ui.click.sidebar.threed_card));
// appearence.push(ui.create.switcher('blur_ui',lib.config.blur_ui,ui.click.sidebar.blur_ui));
// appearence.push(ui.create.switcher('right_sidebar',lib.config.right_sidebar,ui.click.sidebar.right_sidebar));
// appearence.push(ui.create.switcher('animation',lib.config.animation,ui.click.sidebar.global));
// appearence.push(ui.create.switcher('config_menu',lib.config.config_menu,ui.click.sidebar.global));
//
// // appearence.push(ui.create.div('.placeholder'));
// // appearence.push(ui.create.switcher('intro',['⦿','☯','●','❖','✻','i'],lib.config.intro,ui.click.sidebar.intro));
//
// // appearence.push(ui.create.switcher('sort',['type_sort','suit_sort','number_sort'],lib.config.sort,ui.click.sidebar.sort));
//
// if(lib.config.appearence){
// for(i=0;i<appearence.length;i++){
// ui.config.appendChild(appearence[i]);
// }
// }
// ui.config.appendChild(ui.create.div('.placeholder'));
// var characterpack=[];
// folditems.push(characterpack);
// ui.config.appendChild(ui.create.line2('选择武将',function(){
// if(this.clicked) return;
// if(characterpack.fold){
// characterpack.fold=false;
// fold(characterpack);
// }
// else{
// characterpack.fold=true;
// unfold(this,characterpack);
// }
//
// }));
// var characters=lib.config.all.characters;
// for(i=0;i<characters.length;i++){
// var node=ui.create.switcher(characters[i]+'_character',
// lib.config.characters.contains(characters[i]),ui.click.sidebar.characters);
// node.link=characters[i]+'_character';
// characterpack[i]=node;
// }
// var reset_characterpack=ui.create.div('.config');
// reset_characterpack.innerHTML='恢复默认';
// reset_characterpack.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
// if(_status.dragged) return;
// game.saveConfig('characters',lib.config.defaultcharacters);
// for(var i=0;i<characterpack.length;i++){
// if(characterpack[i].link){
// var pnme=characterpack[i].link.slice(0,characterpack[i].link.indexOf('_character'));
// if(lib.config.defaultcharacters.contains(pnme)){
// if(!characterpack[i].lastChild.classList.contains('on')){
// characterpack[i].querySelector('.toggle').link=true;
// characterpack[i].lastChild.classList.add('on');
// }
// }
// else{
// if(characterpack[i].lastChild.classList.contains('on')){
// characterpack[i].querySelector('.toggle').link=false;
// characterpack[i].lastChild.classList.remove('on');
// }
// }
// }
// }
// ui.sidebarrestart.classList.add('thundertext');
// });
// var all_characterpack=ui.create.div('.config');
// all_characterpack.innerHTML='全部开启';
// all_characterpack.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
// if(_status.dragged) return;
// game.saveConfig('characters',lib.config.all.characters);
// for(var i=0;i<characterpack.length;i++){
// if(characterpack[i].link){
// if(!characterpack[i].lastChild.classList.contains('on')){
// characterpack[i].querySelector('.toggle').link=true;
// characterpack[i].lastChild.classList.add('on');
// }
// }
// }
// ui.sidebarrestart.classList.add('thundertext');
// });
// characterpack.push(reset_characterpack);
// characterpack.push(all_characterpack);
//
// var cardpack=[];
// folditems.push(cardpack);
// ui.config.appendChild(ui.create.line2('选择卡牌',function(){
// if(this.clicked) return;
// if(cardpack.fold){
// cardpack.fold=false;
// fold(cardpack);
// }
// else{
// cardpack.fold=true;
// unfold(this,cardpack);
// }
//
// }));
// var cards=lib.config.all.cards;
// for(i=0;i<cards.length;i++){
// var node=ui.create.switcher(cards[i]+'_card',
// lib.config.cards.contains(cards[i]),ui.click.sidebar.cards);
// node.link=cards[i]+'_card';
// cardpack[i]=node;
// }
// var reset_cardpack=ui.create.div('.config');
// reset_cardpack.innerHTML='恢复默认';
// reset_cardpack.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
// if(_status.dragged) return;
// game.saveConfig('cards',lib.config.defaultcards);
// for(var i=0;i<cardpack.length;i++){
// if(cardpack[i].link){
// var pnme=cardpack[i].link.slice(0,cardpack[i].link.indexOf('_card'));
// if(lib.config.defaultcards.contains(pnme)){
// if(!cardpack[i].lastChild.classList.contains('on')){
// cardpack[i].querySelector('.toggle').link=true;
// cardpack[i].lastChild.classList.add('on');
// }
// }
// else{
// if(cardpack[i].lastChild.classList.contains('on')){
// cardpack[i].querySelector('.toggle').link=false;
// cardpack[i].lastChild.classList.remove('on');
// }
// }
// }
// }
// ui.sidebarrestart.classList.add('thundertext');
// });
// var all_cardpack=ui.create.div('.config');
// all_cardpack.innerHTML='全部开启';
// all_cardpack.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
// if(_status.dragged) return;
// game.saveConfig('cards',lib.config.all.cards);
// for(var i=0;i<cardpack.length;i++){
// if(cardpack[i].link){
// if(!cardpack[i].lastChild.classList.contains('on')){
// cardpack[i].querySelector('.toggle').link=true;
// cardpack[i].lastChild.classList.add('on');
// }
// }
// }
// ui.sidebarrestart.classList.add('thundertext');
// });
// cardpack.push(reset_cardpack);
// cardpack.push(all_cardpack);
//
// var playpack=[];
// folditems.push(playpack);
// ui.config.appendChild(ui.create.line2('游戏玩法',function(){
// if(this.clicked) return;
// if(playpack.fold){
// playpack.fold=false;
// fold(playpack);
// }
// else{
// playpack.fold=true;
// unfold(this,playpack);
// }
//
// }));
// var plays=lib.config.all.plays;
// for(i=0;i<plays.length;i++){
// var node=ui.create.switcher(plays[i]+'_play',
// lib.config.plays.contains(plays[i]),ui.click.sidebar.plays);
// node.link=plays[i]+'_play';
// playpack[i]=node;
// }
// ui.config.appendChild(ui.create.div('.placeholder'));
//
// var cardlist=[];
// folditems.push(cardlist);
// ui.config.appendChild(ui.create.line2('游戏资料',function(){
// if(this.clicked) return;
// if(cardlist.fold){
// cardlist.fold=false;
// fold(cardlist);
// }
// else{
// cardlist.fold=true;
// unfold(this,cardlist);
// }
//
// }));
// ui.cardviewdialog=(function(){
// var dialog=ui.create.cardDialog(true);
// dialog.classList.add('fullheight');
// var stopprop=function(e){e.stopPropagation();return false;};
// var clickpop=function(){
// this.delete();
// if(dialog.popped==this) delete dialog.popped;
// }
// var clickbutt=function(e){
// if(dialog.popped){
// dialog.popped.delete();
// if(dialog.popped.node==this&&dialog.popped.parentNode){
// delete dialog.popped;
// return;
// }
// }
// var uiintro=get.nodeintro(this);
// uiintro.classList.add('popped');
// uiintro.classList.add('static');
// uiintro.addEventListener(lib.config.touchscreen?'touchend':'click',clickpop);
// ui.window.appendChild(uiintro);
// lib.placePoppedDialog(uiintro,e);
//
// dialog.popped=uiintro;
// dialog.popped.node=this;
// };
// for(var i=0;i<dialog.buttons.length;i++){
// dialog.buttons[i].listen(clickbutt);
// }
// dialog.listen(stopprop);
// dialog.oncontextmenu=stopprop;
// dialog.origin='card';
// dialog.style.zIndex=6;
// dialog.classList.add('scroll1');
// dialog.classList.add('scroll2');
// return dialog;
// }());
// cardlist.push(ui.create.line('卡牌一览',function(){
// if(ui.gameviewdialog){
// if(ui.gameviewdialog.popped){
// ui.gameviewdialog.popped.delete();
// delete ui.gameviewdialog.popped;
// }
// ui.gameviewdialog.close();
// ui.arena.classList.remove('paused2');
// if(ui.gameviewdialog.origin=='card'){
// this.classList.remove('thundertext');
// delete ui.gameviewdialog;
// return;
// }
// }
// this.classList.add('thundertext');
// ui.currentgameview=this;
// this.parentNode.nextSibling.firstChild.classList.remove('thundertext');
// ui.arena.classList.add('paused2');
// ui.gameviewdialog=ui.cardviewdialog;
// ui.configbg.appendChild(ui.cardviewdialog);
// }));
// ui.characterviewdialog=(function(){
// var dialog=ui.create.characterDialog(true);
// dialog.classList.add('fullheight');
// var stopprop=function(e){e.stopPropagation();return false;};
// var clickpop=function(){
// this.delete();
// if(dialog.popped==this) delete dialog.popped;
// }
// var clickbutt=function(e){
// if(dialog.popped){
// dialog.popped.delete();
// if(dialog.popped.node==this&&dialog.popped.parentNode){
// delete dialog.popped;
// return;
// }
// }
// var uiintro=get.nodeintro(this);
// uiintro.classList.add('popped');
// uiintro.classList.add('static');
// uiintro.addEventListener(lib.config.touchscreen?'touchend':'click',clickpop);
// ui.window.appendChild(uiintro);
// lib.placePoppedDialog(uiintro,e);
//
// dialog.popped=uiintro;
// dialog.popped.node=this;
// };
// for(var i=0;i<dialog.buttons.length;i++){
// dialog.buttons[i].listen(clickbutt);
// }
// dialog.listen(stopprop);
// dialog.oncontextmenu=stopprop;
// dialog.origin='character';
// dialog.style.zIndex=6;
// dialog.classList.add('scroll1');
// dialog.classList.add('scroll2');
// return dialog;
// }());
// cardlist.push(ui.create.line('武将一览',function(){
// if(ui.gameviewdialog){
// if(ui.gameviewdialog.popped){
// ui.gameviewdialog.popped.delete();
// delete ui.gameviewdialog.popped;
// }
// ui.gameviewdialog.close();
// ui.arena.classList.remove('paused2');
// if(ui.gameviewdialog.origin=='character'){
// this.classList.remove('thundertext');
// delete ui.gameviewdialog;
// return;
// }
// }
// this.classList.add('thundertext');
// ui.currentgameview=this;
// this.parentNode.previousSibling.firstChild.classList.remove('thundertext');
// ui.arena.classList.add('paused2');
// ui.gameviewdialog=ui.characterviewdialog;
// ui.configbg.appendChild(ui.characterviewdialog);
// }));
//
2015-10-30 09:13:19 +00:00
var autoskill={};
2015-10-29 17:36:14 +00:00
// folditems.push(autoskill);
2015-05-01 07:35:43 +00:00
ui.autoskill=autoskill;
2015-10-29 17:36:14 +00:00
// ui.config.appendChild(ui.create.line2('自动发动',function(){
// if(this.clicked) return;
// var sks=[];
// if(game.players){
// for(var i=0;i<game.players.length;i++){
// if(game.players[i]==game.me||game.players[i].isUnderControl()){
// sks=sks.concat(game.expandSkills(game.players[i].get('s')));
// }
// }
// }
// for(var i=0;i<autoskill.length-1;i++){
// if(!sks.contains(autoskill[i].link)){
// autoskill[i].style.display='none';
// }
// else{
// autoskill[i].style.display='';
// }
// }
// autoskillempty.classList.remove('underlined');
// if(autoskill.fold){
// autoskill.fold=false;
// fold(autoskill);
// }
// else{
// autoskill.fold=true;
// unfold(this,autoskill);
// }
//
// }));
2015-04-29 03:25:17 +00:00
if(!lib.config.autoskilllist){
lib.config.autoskilllist=[];
}
var nodex;
for(i in lib.skill){
if(lib.skill[i].frequent&&lib.translate[i]){
lib.translate[i+'_forbid_config']=lib.translate[i];
nodex=ui.create.switcher(i+'_forbid',
!lib.config.autoskilllist.contains(i),ui.click.sidebar.autoskill);
nodex.link=i;
2015-10-30 09:13:19 +00:00
autoskill[i]=nodex;
2015-04-29 03:25:17 +00:00
}
}
2015-10-29 17:36:14 +00:00
//
// var autoskillempty=ui.create.div('.config');
// autoskillempty.listen(function(){
// var sks=[];
// if(game.players){
// for(var i=0;i<game.players.length;i++){
// if(game.players[i]==game.me||game.players[i].isUnderControl()){
// sks=sks.concat(game.expandSkills(game.players[i].get('s')));
// }
// }
// }
// if(this.classList.contains('underlined')){
// this.classList.remove('underlined');
// for(var i=0;i<autoskill.length-1;i++){
// if(!sks.contains(autoskill[i].link)){
// autoskill[i].style.display='none';
// }
// else{
// autoskill[i].style.display='';
// }
// }
// }
// else{
// this.classList.add('underlined');
// for(var i=0;i<autoskill.length-1;i++){
// autoskill[i].style.display='';
// }
// }
// });
// autoskill.push(autoskillempty);
// ui.create.div(autoskillempty).innerHTML='显示所有技能';
//
// var forbidskill=[];
// folditems.push(forbidskill);
// ui.config.appendChild(ui.create.line2('技能禁配',function(){
// if(this.clicked) return;
// if(forbidskill.fold){
// forbidskill.fold=false;
// fold(forbidskill);
// }
// else{
// forbidskill.fold=true;
// unfold(this,forbidskill);
// }
//
// }));
// var forbid=lib.config.forbid;
// if(!lib.config.forbidlist){
// var list=[];
// for(i=0;i<forbid.length;i++){
// list.push(true);
// }
// game.saveConfig('forbidlist',list);
// }
// var str,node,omit;
// for(i=0;i<forbid.length;i++){
// str='';
// omit=false;
// for(j=0;j<forbid[i].length;j++){
// if(!lib.skill[forbid[i][j]]){
// omit=true;break;
// }
// str+=get.translation(forbid[i][j])+'+';
// }
// if(omit) continue;
// lib.translate['forbid'+i+'_forbid_config']=str.slice(0,str.length-1);
// node=ui.create.switcher('forbid'+i+'_forbid',
// lib.config.forbidlist[i],ui.click.sidebar.forbid);
// node.link=i;
// forbidskill[i]=node;
// }
// // ui.config.appendChild(ui.create.div('.placeholder'));
//
// var skilllist=[];
// folditems.push(skilllist);
// foldsubitems.push(skilllist);
// ui.config.appendChild(ui.create.line2('游戏帮助',function(){
// if(this.clicked) return;
// if(skilllist.fold){
// skilllist.fold=false;
// fold(skilllist);
// }
// else{
// skilllist.fold=true;
// unfold(this,skilllist);
// }
// }));
// var skillinfo,skillinfo2;
// var clickskillinfo=function(){
// var node=this.parentNode.link;
// if(node.classList.contains('hidden')){
// node.show();
// setTimeout(function(){
// node.parentNode.style.height=(30+node.parentNode.lastChild.offsetHeight)+'px';
// })
// }
// else{
// node.hide();
// node.parentNode.style.height='20px';
// }
// };
// for(i in lib.help){
// skillinfo=ui.create.line(i,clickskillinfo);
// skillinfo.style.height='20px';
// skillinfo2=ui.create.div('.configinfo');
// skillinfo2.innerHTML=lib.help[i];
// skillinfo2.hide();
// skillinfo.link=skillinfo2;
// skillinfo.appendChild(skillinfo2);
// skilllist.push(skillinfo);
// }
2015-04-29 03:25:17 +00:00
// ui.config.appendChild(ui.create.div('.placeholder'));
2015-10-29 17:36:14 +00:00
//
// var node=ui.create.div('.config.line2',ui.config);
// ui.create.div(node).innerHTML='重置游戏';
// node.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
// if(_status.dragged) return;
// if(_status.reset){
// this.firstChild.innerHTML='重置游戏';
// _status.reset=false;
// }
// else{
// this.firstChild.innerHTML+=' ●';
// _status.reset=true;
// }
// });
//
// var node=ui.create.div('.config.line2',ui.config);
// ui.sidebarrestart=node;
// ui.create.div(node).innerHTML='重新开始';
// node.listen(function(){
// if(_status.reset) localStorage.clear();
// ui.arena.hide();
// ui.config.hide();
// setTimeout(game.reload,500);
// });
2015-04-29 03:25:17 +00:00
2015-10-31 16:18:20 +00:00
ui.system1=ui.create.div('#system1',ui.system);
ui.system2=ui.create.div('#system2',ui.system);
if(lib.config.touchscreen){
ui.system1.addEventListener('touchstart',ui.click.system);
2015-11-09 17:04:18 +00:00
// ui.system1.addEventListener('touchend',ui.click.system);
// ui.system1.addEventListener('touchmove',ui.click.system);
2015-10-31 16:18:20 +00:00
ui.system2.addEventListener('touchstart',ui.click.system);
2015-11-09 17:04:18 +00:00
// ui.system2.addEventListener('touchend',ui.click.system);
// ui.system2.addEventListener('touchmove',ui.click.system);
2015-04-29 03:25:17 +00:00
}
else{
2015-10-31 16:18:20 +00:00
ui.system1.listen(ui.click.system);
ui.system2.listen(ui.click.system);
2015-04-29 03:25:17 +00:00
}
2015-10-31 16:18:20 +00:00
2015-04-29 08:41:00 +00:00
ui.replay=ui.create.system('重来',game.reload,true);
2015-10-29 17:36:14 +00:00
ui.config2=ui.create.system('选项',ui.click.config);
2015-11-05 02:34:35 +00:00
ui.pause=ui.create.system('暂停',ui.click.pause);
2015-04-30 08:24:57 +00:00
if(!lib.config.touchscreen){
lib.setPopped(ui.pause,ui.click.pausehistory,220,400);
2015-04-30 08:24:57 +00:00
}
2015-04-29 03:25:17 +00:00
if(!lib.config.show_pause){
ui.pause.style.display='none';
}
2015-10-28 03:47:35 +00:00
ui.wuxie=ui.create.system('不询问无懈',ui.click.wuxie,true);
2015-04-30 08:24:57 +00:00
if(!lib.config.touchscreen){
2015-05-08 08:07:38 +00:00
lib.setPopped(ui.config2,ui.click.pauseconfig,170);
2015-10-29 17:36:14 +00:00
// lib.setPopped(ui.wuxie,ui.click.wuxieconfig,170);
2015-04-30 08:24:57 +00:00
}
2015-04-29 03:25:17 +00:00
ui.auto=ui.create.system('托管',ui.click.auto);
2015-04-30 08:24:57 +00:00
ui.volumn=ui.create.system('♫');
lib.setPopped(ui.volumn,ui.click.volumn,200);
// if(lib.config.show_pause) ui.auto.style.marginLeft='10px';
2015-04-30 03:09:07 +00:00
if(!lib.config.show_volumn){
ui.volumn.style.display='none';
}
2015-04-29 03:25:17 +00:00
if(!lib.config.show_auto){
ui.auto.style.display='none';
}
if(!lib.config.show_wuxie){
ui.wuxie.style.display='none';
}
if(lib.config.touchscreen&&!lib.config.confirmtouch){
var backtomouse=ui.create.system('返回鼠标模式');
backtomouse.addEventListener('click',function(){
game.saveConfig('touchscreen',false);
2015-04-29 08:41:00 +00:00
game.reload();
2015-04-29 03:25:17 +00:00
});
var keeptouch=ui.create.system('确认触屏');
keeptouch.addEventListener('touchend',function(){
game.saveConfig('confirmtouch',true);
keeptouch.remove();
backtomouse.remove();
});
}
ui.playerids=ui.create.system('显示身份',function(){
if(game.showIdentity){
game.showIdentity();
_status.identityShown=true;
}
},true);
2015-05-08 08:07:38 +00:00
if(!lib.config.show_playerids||!game.showIdentity){
2015-04-29 03:25:17 +00:00
ui.playerids.style.display='none';
}
if(!lib.config.show_replay){
ui.replay.style.display='none';
}
ui.control=ui.create.div('#control',ui.arena);
ui.cardPile=ui.create.div('#cardPile');
ui.discardPile=ui.create.div('#discardPile');
ui.special=ui.create.div('#special');
ui.dialogs=[];
ui.controls=[];
ui.style={};
2015-10-29 17:36:14 +00:00
(function(){
var menu,menuContainer;
var startButton;
var popupContainer;
var closeMenu=function(){
popupContainer.classList.add('hidden');
if(popupContainer.onclose){
popupContainer.onclose();
}
};
popupContainer=ui.create.div('.popup-container.hidden',ui.window,closeMenu);
var openMenu=function(node,e,onclose){
popupContainer.innerHTML='';
if(e){
node.style.left=e.x+'px';
node.style.top=e.y+'px';
}
popupContainer.appendChild(node);
popupContainer.classList.remove('hidden');
popupContainer.onclose=onclose;
};
var clickToggle=function(){
this.classList.toggle('on');
var config=this._link.config;
if(config.onclick){
config.onclick.call(this,this.classList.contains('on'));
}
if(config.update){
config.update();
}
};
var clickSwitcher=function(){
var node=this;
this.classList.add('on');
if(this._link.menu){
var pos1=this.lastChild.getBoundingClientRect();
var pos2=ui.window.getBoundingClientRect();
openMenu(this._link.menu,{
x:pos1.left+pos1.width+5-pos2.left,
y:pos1.top-pos2.top
},function(){
node.classList.remove('on');
});
}
};
var clickContainer=function(){
if(this.animating){
return;
}
this.animating=true;
menu.classList.add('zoomout');
menu.classList.remove('zoomin');
setTimeout(function(){
menuContainer.classList.add('hidden');
menuContainer.animating=false;
},300);
game.resume2();
if(game.onresume2){
game.onresume2();
}
2015-11-06 10:05:08 +00:00
ui.arena.classList.remove('menupaused');
2015-10-29 17:36:14 +00:00
};
var clickMenuItem=function(){
var node=this.parentNode._link;
var config=node._link.config;
node._link.current=this.link;
node.lastChild.innerHTML=config.item[this._link];
if(config.onclick){
config.onclick.call(node,this._link);
}
if(config.update){
config.update();
}
};
var createMenu=function(tabs,config){
var createPage=function(position){
var node=ui.create.div(position);
2015-10-31 03:20:59 +00:00
lib.setScroll(ui.create.div('.left.pane',node));
lib.setScroll(ui.create.div('.right.pane',node));
2015-10-29 17:36:14 +00:00
return node;
};
var menu=ui.create.div('.main.menu.dialog.popped.static',config.position,function(e){
e.stopPropagation();
});
var menuTab=ui.create.div('.menu-tab',menu);
var menuTabBar=ui.create.div('.menu-tab-bar',menu);
menuTabBar.style.left=(config.bar||0)+'px';
var menuContent=ui.create.div('.menu-content',menu);
var clickTab=function(){
2015-11-05 02:34:35 +00:00
if(this.classList.contains('disabled')) return;
2015-10-29 17:36:14 +00:00
var active=this.parentNode.querySelector('.active');
if(active){
active.classList.remove('active');
active._link.remove();
}
this.classList.add('active');
menuTabBar.style.left=this.offsetLeft+'px';
menuContent.appendChild(this._link);
};
var pages=[];
for(var i=0;i<tabs.length;i++){
var active=(i===(config.init||0));
pages[i]=createPage(active?menuContent:null);
ui.create.div(active?'.active':'',tabs[i],menuTab,clickTab)._link=pages[i];
}
return {
menu:menu,
pages:pages
};
};
var createConfig=function(config,position){
var node=ui.create.div('.config',config.name);
node._link={config:config};
if(config.item){
if(Array.isArray(config.init)){
}
else{
node.classList.add('switcher');
2015-10-31 16:26:25 +00:00
node.listen(clickSwitcher);
2015-10-29 17:36:14 +00:00
ui.create.div('',config.item[config.init],node);
node._link.menu=ui.create.div('.menu');
node._link.menu._link=node;
node._link.current=config.init;
for(var i in config.item){
ui.create.div('',config.item[i],node._link.menu,clickMenuItem)._link=i;
}
}
}
else if(config.range){
}
else if(config.clear){
node.listen(clickToggle);
}
else{
node.classList.add('toggle');
node.listen(clickToggle);
ui.create.div(ui.create.div(node));
if(config.init==true){
node.classList.add('on');
}
}
if(position){
position.appendChild(node);
}
return node;
};
2015-10-30 15:32:48 +00:00
var menuUpdates=[];
2015-10-29 17:36:14 +00:00
menuContainer=ui.create.div('.menu-container.hidden',ui.window,clickContainer);
2015-10-30 15:32:48 +00:00
ui.menuContainer=menuContainer;
2015-10-29 17:36:14 +00:00
ui.click.configMenu=function(){
if(menuContainer.classList.contains('hidden')){
menu.classList.remove('zoomout');
menu.classList.add('zoomin');
menuContainer.classList.remove('hidden');
menuContainer.animating=true;
setTimeout(function(){
menuContainer.animating=false;
},300);
2015-10-30 15:32:48 +00:00
for(var i=0;i<menuUpdates.length;i++){
menuUpdates[i]();
}
2015-11-06 10:05:08 +00:00
ui.arena.classList.add('menupaused');
2015-10-29 17:36:14 +00:00
}
else{
clickContainer.call(menuContainer);
}
}
2015-10-30 09:13:19 +00:00
var menux=createMenu(['开始','选项','武将','卡牌','战局','帮助'],{
2015-10-29 17:36:14 +00:00
position:menuContainer,bar:40
});
menu=menux.menu;
var copyObj=function(obj){
var copy={};
for(var i in obj){
if(get.objtype(obj[i])=='object'){
copy[i]=util.copy(obj[i]);
}
else if(Array.isArray(obj[i])){
copy[i]=obj[i].slice(0);
}
else{
copy[i]=obj[i];
}
}
return copy;
};
(function(){
var start=menux.pages[0];
var rightPane=start.lastChild;
startButton=ui.create.div('.menubutton.round.highlight','启',start,function(){
if(this.animating||this.classList.contains('dim')){
return;
}
var active=this.parentNode.querySelector('.active');
if(active){
game.saveConfig('mode',active.mode);
game.reload();
}
});
var clickMode=function(){
var active=this.parentNode.querySelector('.active');
if(active===this){
return;
}
active.classList.remove('active');
active.link.remove();
active=this;
this.classList.add('active');
rightPane.appendChild(this.link);
};
var createModeConfig=function(mode,position){
var info=lib.mode[mode];
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large',info.name,position,clickMode);
node.link=page;
node.mode=mode;
if(mode==lib.config.mode){
node.classList.add('active');
}
var map={};
if(info.config){
var hiddenNodes=[];
for(var j in info.config){
if(j==='update'){
continue;
}
var cfg=copyObj(info.config[j]);
cfg._name=j;
2015-10-30 15:32:48 +00:00
cfg.mode=mode;
2015-10-29 17:36:14 +00:00
var config=lib.config.mode_config[mode]||{};
if(!config.hasOwnProperty(j)){
game.saveConfig(j,cfg.init,mode);
}
else{
cfg.init=config[j];
}
if(!cfg.onclick){
cfg.onclick=function(result){
var cfg=this._link.config;
game.saveConfig(cfg._name,result,mode);
if(cfg.onsave){
cfg.onsave.call(this,result);
}
if(cfg.restart){
startButton.classList.add('glowing');
}
};
}
if(info.config.update){
cfg.update=function(){
info.config.update(config,map);
};
}
var cfgnode=createConfig(cfg);
map[j]=cfgnode;
if(cfg.frequent){
page.appendChild(cfgnode);
}
else{
cfgnode.classList.add('auto-hide');
hiddenNodes.push(cfgnode);
}
}
var expanded=false;
if(hiddenNodes.length){
ui.create.div('.config.more','更多 <div>&gt;</div>',page,function(){
if(expanded){
this.classList.remove('on');
this.parentNode.classList.remove('expanded');
}
else{
this.classList.add('on');
this.parentNode.classList.add('expanded');
}
expanded=!expanded;
});
for(var k=0;k<hiddenNodes.length;k++){
page.appendChild(hiddenNodes[k]);
}
}
if(info.config.update){
info.config.update(config,map);
}
}
return node;
};
for(var i in lib.mode){
createModeConfig(i,start.firstChild);
}
var active=start.firstChild.querySelector('.active');
if(!active){
active=start.firstChild.firstChild;
active.classList.add('active');
}
rightPane.appendChild(active.link);
}());
(function(){
var start=menux.pages[1];
var rightPane=start.lastChild;
var clickMode=function(){
var active=this.parentNode.querySelector('.active');
if(active===this){
return;
}
active.classList.remove('active');
active.link.remove();
active=this;
this.classList.add('active');
rightPane.appendChild(this.link);
};
2015-10-30 09:13:19 +00:00
var clickAutoSkill=function(bool){
var name=this._link.config._name;
var list=lib.config.autoskilllist;
if(bool){
list.remove(name);
}
else{
list.add(name);
}
game.saveConfig('autoskilllist',list);
};
for(var i in lib.skill){
2015-11-06 10:05:08 +00:00
if(!lib.skilllist.contains(i)) continue;
2015-10-30 09:13:19 +00:00
if(lib.skill[i].frequent&&lib.translate[i]){
lib.configMenu.skill.config[i]={
name:lib.translate[i],
init:true,
type:'autoskill',
onclick:clickAutoSkill
}
}
}
var clickBanSkill=function(bool){
var name=this._link.config._name;
var list=lib.config.forbidlist;
if(bool){
list.remove(name);
}
else{
list.add(name);
}
game.saveConfig('forbidlist',list);
};
var forbid=lib.config.forbid;
lib.config.forbidmap={};
if(!lib.config.forbidlist){
game.saveConfig('forbidlist',[]);
}
for(var i=0;i<forbid.length;i++){
2015-11-06 10:05:08 +00:00
var skip=false;
2015-10-30 09:13:19 +00:00
var str='';
var str2='';
for(var j=0;j<forbid[i].length;j++){
2015-11-06 10:05:08 +00:00
if(!lib.skilllist.contains(forbid[i][j])){
skip=true;
break;
}
2015-10-30 09:13:19 +00:00
str+=get.translation(forbid[i][j])+'+';
str2+=forbid[i][j]+'+';
}
2015-11-06 10:05:08 +00:00
if(skip) continue;
2015-10-30 09:13:19 +00:00
lib.config.forbidmap[str2]=forbid[i];
str=str.slice(0,str.length-1);
str2=str2.slice(0,str2.length-1);
lib.configMenu.skill.config[str2]={
name:str,
init:true,
type:'banskill',
onclick:clickBanSkill
}
}
2015-10-29 17:36:14 +00:00
var createModeConfig=function(mode,position){
var info=lib.configMenu[mode];
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large',info.name,position,clickMode);
node.link=page;
node.mode=mode;
var map={};
if(info.config){
var hiddenNodes=[];
2015-10-30 09:13:19 +00:00
var autoskillNodes=[];
var banskillNodes=[];
var banskill;
if(mode=='skill'){
var autoskillexpanded=false;
var banskillexpanded=false;
ui.create.div('.config.more','自动发动 <div>&gt;</div>',page,function(){
if(autoskillexpanded){
this.classList.remove('on');
for(var k=0;k<autoskillNodes.length;k++){
autoskillNodes[k].hide();
}
}
else{
this.classList.add('on');
for(var k=0;k<autoskillNodes.length;k++){
autoskillNodes[k].show();
}
}
autoskillexpanded=!autoskillexpanded;
});
banskill=ui.create.div('.config.more','双将禁配 <div>&gt;</div>',page,function(){
if(banskillexpanded){
this.classList.remove('on');
for(var k=0;k<banskillNodes.length;k++){
banskillNodes[k].hide();
}
}
else{
this.classList.add('on');
for(var k=0;k<banskillNodes.length;k++){
banskillNodes[k].show();
}
}
banskillexpanded=!banskillexpanded;
});
2015-11-06 10:05:08 +00:00
page.style.paddingBottom='10px';
2015-10-30 09:13:19 +00:00
}
2015-10-29 17:36:14 +00:00
for(var j in info.config){
if(j==='update'){
continue;
}
var cfg=copyObj(info.config[j]);
cfg._name=j;
var config=lib.config;
if(!config.hasOwnProperty(j)){
2015-11-05 02:34:35 +00:00
if(cfg.type!='autoskill'&&cfg.type!='banskill'){
game.saveConfig(j,cfg.init);
}
2015-10-29 17:36:14 +00:00
}
else{
cfg.init=config[j];
}
if(!cfg.onclick){
cfg.onclick=function(result){
var cfg=this._link.config;
game.saveConfig(cfg._name,result);
if(cfg.onsave){
cfg.onsave.call(this,result);
}
};
}
if(info.config.update){
cfg.update=function(){
info.config.update(config,map);
};
}
var cfgnode=createConfig(cfg);
2015-10-30 09:13:19 +00:00
if(cfg.type=='autoskill'){
autoskillNodes.push(cfgnode);
cfgnode.style.transition='all 0s';
cfgnode.classList.add('indent');
cfgnode.hide();
}
else if(cfg.type=='banskill'){
banskillNodes.push(cfgnode);
cfgnode.style.transition='all 0s';
cfgnode.classList.add('indent');
cfgnode.hide();
}
if(j=='import_data_button'){
ui.import_data_button=cfgnode;
cfgnode.hide();
cfgnode.querySelector('button').onclick=function(){
var fileToLoad = document.getElementById("fileToLoad").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));
localStorage.clear();
for(var i in data){
localStorage.setItem(i,data[i]);
}
}
catch(e){
alert('导入失败');
return;
}
alert('导入成功');
game.reload();
};
fileReader.readAsText(fileToLoad, "UTF-8");
}
}
2015-10-29 17:36:14 +00:00
map[j]=cfgnode;
if(!cfg.unfrequent){
2015-10-30 09:13:19 +00:00
if(cfg.type=='autoskill'){
page.insertBefore(cfgnode,banskill);
}
else{
page.appendChild(cfgnode);
}
2015-10-29 17:36:14 +00:00
}
else{
cfgnode.classList.add('auto-hide');
hiddenNodes.push(cfgnode);
}
}
var expanded=false;
if(hiddenNodes.length){
ui.create.div('.config.more','更多 <div>&gt;</div>',page,function(){
if(expanded){
this.classList.remove('on');
this.parentNode.classList.remove('expanded');
}
else{
this.classList.add('on');
this.parentNode.classList.add('expanded');
}
expanded=!expanded;
});
for(var k=0;k<hiddenNodes.length;k++){
page.appendChild(hiddenNodes[k]);
}
}
if(info.config.update){
info.config.update(config,map);
}
}
return node;
};
for(var i in lib.configMenu){
createModeConfig(i,start.firstChild);
}
var active=start.firstChild.querySelector('.active');
if(!active){
active=start.firstChild.firstChild;
active.classList.add('active');
}
rightPane.appendChild(active.link);
}());
2015-10-30 15:32:48 +00:00
(function(){
var start=menux.pages[2];
var rightPane=start.lastChild;
var clickMode=function(){
var active=this.parentNode.querySelector('.active');
if(active===this){
return;
}
active.classList.remove('active');
active.link.remove();
active=this;
this.classList.add('active');
rightPane.appendChild(this.link);
};
var updateNodes=function(){
for(var i=0;i<start.firstChild.childNodes.length;i++){
var node=start.firstChild.childNodes[i];
if(node.link){
2015-11-09 03:15:16 +00:00
if(node.mode.indexOf('mode_')==0) continue;
2015-10-30 15:32:48 +00:00
if(lib.config.characters.contains(node.mode)){
node.classList.remove('off');
node.link.firstChild.classList.add('on');
}
else{
node.classList.add('off');
node.link.firstChild.classList.remove('on');
}
}
}
}
var togglePack=function(bool){
var name=this._link.config._name;
if(bool){
lib.config.characters.add(name);
}
else{
lib.config.characters.remove(name);
}
game.saveConfig('characters',lib.config.characters);
updateNodes();
};
var createModeConfig=function(mode,position){
var info=lib.characterPack[mode];
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large',lib.translate[mode+'_character_config'],position,clickMode);
node.link=page;
node.mode=mode;
var list=[];
for(var i in info){
list.push(i);
}
var cfgnode=createConfig({
name:'开启',
_name:mode,
init:lib.config.characters.contains(mode),
onclick:togglePack
});
2015-11-09 03:15:16 +00:00
if(mode.indexOf('mode_')!=0){
page.appendChild(cfgnode);
}
2015-10-30 15:32:48 +00:00
var banCharacter=function(){
2015-11-09 03:15:16 +00:00
if(mode.indexOf('mode_')==0){
return;
}
2015-10-30 15:32:48 +00:00
this.classList.toggle('unselectable');
if(this.classList.contains('unselectable')){
lib.config.banned.add(this.link);
}
else{
lib.config.banned.remove(this.link);
}
game.saveConfig('banned',lib.config.banned);
};
var buttons=ui.create.buttons(list,'character',page);
for(var i=0;i<buttons.length;i++){
buttons[i].classList.add('noclick');
buttons[i].listen(banCharacter);
if(lib.config.banned.contains(buttons[i].link)){
buttons[i].classList.add('unselectable');
}
}
page.classList.add('menu-buttons');
return node;
};
for(var i=0;i<lib.config.all.characters.length;i++){
createModeConfig(lib.config.all.characters[i],start.firstChild);
}
2015-11-09 03:15:16 +00:00
for(var i in lib.characterPack){
if(i.indexOf('mode_')==0){
createModeConfig(i,start.firstChild);
}
}
2015-10-30 15:32:48 +00:00
var active=start.firstChild.querySelector('.active');
if(!active){
active=start.firstChild.firstChild;
active.classList.add('active');
}
rightPane.appendChild(active.link);
var node1=ui.create.div('.lefttext','全部开启',start.firstChild,function(){
game.saveConfig('characters',lib.config.all.characters);
updateNodes();
});
var node2=ui.create.div('.lefttext','恢复默认',start.firstChild,function(){
game.saveConfig('characters',lib.config.defaultcharacters);
updateNodes();
});
node1.style.marginTop='12px';
node2.style.marginTop='7px';
updateNodes();
}());
(function(){
var start=menux.pages[3];
var rightPane=start.lastChild;
var clickMode=function(){
var active=this.parentNode.querySelector('.active');
if(active===this){
return;
}
active.classList.remove('active');
active.link.remove();
active=this;
this.classList.add('active');
rightPane.appendChild(this.link);
};
var updateNodes=function(){
for(var i=0;i<start.firstChild.childNodes.length;i++){
var node=start.firstChild.childNodes[i];
if(node.link){
2015-11-09 03:15:16 +00:00
if(node.mode.indexOf('mode_')==0) continue;
2015-10-30 15:32:48 +00:00
if(lib.config.cards.contains(node.mode)){
node.classList.remove('off');
node.link.firstChild.classList.add('on');
}
else{
node.classList.add('off');
node.link.firstChild.classList.remove('on');
}
}
}
}
var togglePack=function(bool){
var name=this._link.config._name;
if(bool){
lib.config.cards.add(name);
}
else{
lib.config.cards.remove(name);
}
game.saveConfig('cards',lib.config.cards);
updateNodes();
};
var createModeConfig=function(mode,position){
var info=lib.cardPack[mode];
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large',lib.translate[mode+'_card_config'],position,clickMode);
node.link=page;
node.mode=mode;
var list=[];
for(var i=0;i<info.length;i++){
list.push(['',get.translation(get.type(info[i],'trick')),info[i]]);
}
var cfgnode=createConfig({
name:'开启',
_name:mode,
init:lib.config.cards.contains(mode),
onclick:togglePack
});
2015-11-09 03:15:16 +00:00
if(mode.indexOf('mode_')!=0){
page.appendChild(cfgnode);
}
2015-10-30 15:32:48 +00:00
var banCard=function(){
2015-11-09 03:15:16 +00:00
if(mode.indexOf('mode_')==0){
return;
}
2015-10-30 15:32:48 +00:00
this.classList.toggle('unselectable');
if(this.classList.contains('unselectable')){
lib.config.bannedcards.add(this.link[2]);
}
else{
lib.config.bannedcards.remove(this.link[2]);
}
game.saveConfig('bannedcards',lib.config.bannedcards);
};
var buttons=ui.create.buttons(list,'vcard',page);
for(var i=0;i<buttons.length;i++){
buttons[i].classList.add('noclick');
buttons[i].listen(banCard);
if(lib.config.bannedcards.contains(buttons[i].link[2])){
buttons[i].classList.add('unselectable');
}
}
page.classList.add('menu-buttons');
return node;
};
for(var i=0;i<lib.config.all.cards.length;i++){
createModeConfig(lib.config.all.cards[i],start.firstChild);
}
2015-11-09 03:15:16 +00:00
for(var i in lib.cardPack){
if(i.indexOf('mode_')==0){
createModeConfig(i,start.firstChild);
}
}
2015-10-30 15:32:48 +00:00
var active=start.firstChild.querySelector('.active');
if(!active){
active=start.firstChild.firstChild;
active.classList.add('active');
}
rightPane.appendChild(active.link);
var node1=ui.create.div('.lefttext','全部开启',start.firstChild,function(){
game.saveConfig('cards',lib.config.all.cards);
updateNodes();
});
var node2=ui.create.div('.lefttext','恢复默认',start.firstChild,function(){
game.saveConfig('cards',lib.config.defaultcards);
updateNodes();
});
node1.style.marginTop='12px';
node2.style.marginTop='7px';
updateNodes();
}());
(function(){
var start=menux.pages[4];
var rightPane=start.lastChild;
var cheatButton=ui.create.div('.menubutton.round.highlight','作',start);
var runButton=ui.create.div('.menubutton.round.highlight','执',start);
2015-11-01 07:54:42 +00:00
runButton.style.display='none';
2015-11-04 01:59:00 +00:00
var playButton=ui.create.div('.menubutton.round.highlight','播',start);
playButton.style.display='none';
playButton.style.left='215px';
var deleteButton=ui.create.div('.menubutton.round.highlight','删',start);
deleteButton.style.display='none';
deleteButton.style.left='275px';
var saveButton=ui.create.div('.menubutton.round.highlight','存',start);
saveButton.style.display='none';
2015-10-30 15:32:48 +00:00
var clickMode=function(){
if(this.classList.contains('off')) return;
var active=this.parentNode.querySelector('.active');
if(active===this){
return;
}
active.classList.remove('active');
active.link.remove();
active=this;
this.classList.add('active');
rightPane.appendChild(this.link);
if(this.type=='cheat'){
cheatButton.style.display='';
}
else{
cheatButton.style.display='none';
}
if(this.type=='cmd'){
runButton.style.display='';
}
else{
runButton.style.display='none';
}
2015-11-04 01:59:00 +00:00
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';
}
2015-10-30 15:32:48 +00:00
};
(function(){
var checkCheat=function(){
if(currentrow1&&currentrow2&&row3.querySelector('.glow')){
cheatButton.classList.add('glowing');
return true;
}
else{
cheatButton.classList.remove('glowing');
return false;
}
}
cheatButton.listen(function(){
if(checkCheat()){
var num;
switch(currentrow2.innerHTML){
case '一':num=1;break;
case '二':num=2;break;
case '三':num=3;break;
case '四':num=4;break;
case '五':num=5;break;
}
var targets=[];
var buttons=row3.querySelectorAll('.glow');
for(var i=0;i<buttons.length;i++){
targets.push(buttons[i].link);
}
while(targets.length){
var target=targets.shift();
switch(currentrow1.innerHTML){
case '伤害':target.damage(num,'nosource');break;
case '回复':target.recover(num,'nosource');break;
case '摸牌':target.draw(num);break;
case '弃牌':
var hs=target.get('he');
if(hs.length){
target.discard(hs.randomGets(num));
}
break;
}
}
clickContainer.call(menuContainer);
}
});
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','作弊',start.firstChild,clickMode);
node.link=page;
node.type='cheat';
page.classList.add('menu-sym');
var currentrow1=null;
var row1=ui.create.div('.menu-cheat',page);
var clickrow1=function(){
if(currentrow1==this){
this.classList.remove('selecting');
currentrow1=null;
}
else{
this.classList.add('selecting');
if(currentrow1){
currentrow1.classList.remove('selecting');
}
currentrow1=this;
}
checkCheat();
};
var nodedamage=ui.create.div('.menubutton','伤害',row1,clickrow1);
var noderecover=ui.create.div('.menubutton','回复',row1,clickrow1);
var nodedraw=ui.create.div('.menubutton','摸牌',row1,clickrow1);
var nodediscard=ui.create.div('.menubutton','弃牌',row1,clickrow1);
var currentrow2=null;
var row2=ui.create.div('.menu-cheat',page);
var clickrow2=function(){
if(currentrow2==this){
this.classList.remove('selecting');
currentrow2=null;
}
else{
this.classList.add('selecting');
if(currentrow2){
currentrow2.classList.remove('selecting');
}
currentrow2=this;
}
checkCheat();
};
var nodex1=ui.create.div('.menubutton','一',row2,clickrow2);
var nodex2=ui.create.div('.menubutton','二',row2,clickrow2);
var nodex3=ui.create.div('.menubutton','三',row2,clickrow2);
var nodex4=ui.create.div('.menubutton','四',row2,clickrow2);
var nodex5=ui.create.div('.menubutton','五',row2,clickrow2);
var row3=ui.create.div('.menu-buttons',page);
row3.style.marginTop='3px';
var clickrow3=function(){
this.classList.toggle('glow');
checkCheat();
};
menuUpdates.push(function(){
2015-11-05 02:34:35 +00:00
if(_status.video){
node.classList.add('off');
node.classList.remove('active');
node.remove();
page.remove();
cheatButton.style.display='none';
return;
}
2015-10-30 15:32:48 +00:00
var list=[];
for(var i=0;i<game.players.length;i++){
if(lib.character[game.players[i].name]&&game.players[i].isAlive()){
list.push(game.players[i]);
}
else if(game.players[i]==game.me&&game.me.name1){
list.push(game.me);
}
}
if(list.length){
row1.show();
row2.show();
row3.innerHTML='';
var buttons=ui.create.buttons(list,'player',row3,true);
for(var i=0;i<buttons.length;i++){
buttons[i].listen(clickrow3);
}
}
else{
row1.hide();
row2.hide();
}
checkCheat();
});
}());
(function(){
if(lib.config.mode!='identity'&&lib.config.mode!='guozhan') return;
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','换人',start.firstChild,clickMode);
node.link=page;
page.classList.add('menu-sym');
var caption=ui.create.div('','选择一个换人目标',page);
caption.style.margin='5px';
caption.style.marginTop='6px';
var row3=ui.create.div('.menu-buttons',page);
row3.style.marginTop='3px';
var currentrow3=null;
var clickrow3=function(){
game.swapPlayer(this.link);
};
menuUpdates.push(function(){
var list=[];
for(var i=0;i<game.players.length;i++){
if(lib.character[game.players[i].name]&&
game.players[i].isAlive()&&game.players[i]!=game.me){
list.push(game.players[i]);
}
}
2015-11-05 02:34:35 +00:00
if(_status.video){
node.remove();
}
if(!_status.video&&list.length&&game.phaseNumber&&!_status.event.isMine()){
2015-10-30 15:32:48 +00:00
node.classList.remove('off');
row3.innerHTML='';
var buttons=ui.create.buttons(list,'player',row3,true);
for(var i=0;i<buttons.length;i++){
buttons[i].listen(clickrow3);
}
}
else{
node.classList.add('off');
var active=start.firstChild.querySelector('.active');
if(active==node){
node.classList.remove('active');
node.link.remove();
active=start.firstChild.firstChild;
active.classList.add('active');
rightPane.appendChild(active.link);
cheatButton.style.display='';
}
}
});
}());
(function(){
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','命令',start.firstChild,clickMode);
node.type='cmd';
node.link=page;
page.classList.add('menu-sym');
var caption=ui.create.div('','输入要执行的命令',page);
caption.style.margin='6px';
var text=document.createElement('textarea');
text.style.width='200px';
text.style.height='80px';
text.style.resize='none';
page.appendChild(text);
2015-10-31 03:20:59 +00:00
var textstr='';
var perserveMenu=false;
game.print=function(str){
textstr+=str+'\n';
text.value=textstr;
perserveMenu=true;
}
2015-10-30 15:32:48 +00:00
runButton.listen(function(){
2015-10-31 03:20:59 +00:00
textstr='';
perserveMenu=false;
2015-10-30 15:32:48 +00:00
try{
eval(text.value);
}
catch(e){}
2015-10-31 03:20:59 +00:00
if(!perserveMenu){
text.value='';
clickContainer.call(menuContainer);
}
2015-10-30 15:32:48 +00:00
});
}());
2015-11-04 01:59:00 +00:00
(function(){
if(!window.indexedDB) return;
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large','录像',start.firstChild,clickMode);
node.type='video';
node.link=page;
lib.onDB(function(){
var store=lib.db.transaction(['video'],'readwrite').objectStore('video');
lib.videos=[];
store.openCursor().onsuccess=function(e){
var cursor=e.target.result;
if(cursor){
lib.videos.push(cursor.value);
cursor.continue();
}
else{
lib.videos.sort(function(a,b){
return parseInt(b.time)-parseInt(a.time);
});
var clickcapt=function(){
var current=this.parentNode.querySelector('.videonode.active');
if(current&&current!=this){
current.classList.remove('active');
}
this.classList.toggle('active');
};
var createNode=function(video,before){
var node=ui.create.div('.videonode.menubutton.large',clickcapt);
node.link=video;
ui.create.div('.menubutton.videoavatar',node).setBackground(video.name1,'character');
if(video.name2){
ui.create.div('.menubutton.videoavatar2',node).setBackground(video.name2,'character');
}
var date=new Date(video.time);
var str=date.getFullYear()+'.'+(date.getMonth()+2)+'.'+(date.getDay()+1)+' '+
date.getHours()+':';
var minutes=date.getMinutes();
if(minutes<10){
str+='0';
}
str+=minutes;
ui.create.div('.caption',video.name[0],node);
ui.create.div('.text',str+'<br>'+video.name[1],node);
if(video.win){
ui.create.div('.victory','胜',node);
}
if(before){
page.insertBefore(node,page.firstChild);
}
else{
page.appendChild(node);
}
}
for(var i=0;i<lib.videos.length;i++){
createNode(lib.videos[i]);
}
2015-11-06 10:05:08 +00:00
lib.createVideoNode=createNode;
2015-11-04 01:59:00 +00:00
var importVideoNode=ui.create.div('.config.switcher',
'<span class="underlinenode slim">导入录像...</span>',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='<input type="file" style="width:calc(100% - 40px)">'+
'<button style="width:40px">确定</button>';
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){
alert('导入失败');
return;
}
var store=lib.db.transaction(['video'],'readwrite').objectStore('video');
if(lib.videos.length>=parseInt(lib.config.video)&&lib.videos.length){
var toremove=lib.videos.pop();
store.delete(toremove.time);
for(var i=0;i<page.childNodes.length;i++){
if(page.childNodes[i].link==toremove){
page.childNodes[i].remove();
break;
}
}
}
for(var i=0;i<lib.videos.length;i++){
if(lib.videos[i].time==data.time){
alert('录像已存在');
return;
}
}
lib.videos.unshift(data);
store.put(data);
createNode(data,true);
};
fileReader.readAsText(fileToLoad, "UTF-8");
}
playButton.listen(function(){
var current=this.parentNode.querySelector('.videonode.active');
if(current){
game.playVideo(current.link.time,current.link.mode);
}
});
deleteButton.listen(function(){
var current=this.parentNode.querySelector('.videonode.active');
if(current){
lib.videos.remove(current.link);
var store=lib.db.transaction(['video'],'readwrite').objectStore('video');
store.delete(current.link.time);
current.remove();
}
});
saveButton.listen(function(){
var current=this.parentNode.querySelector('.videonode.active');
if(current){
2015-11-05 02:34:35 +00:00
game.export(lib.init.encode(JSON.stringify(current.link)),
'无名杀 - 录像 - '+current.link.name[0]+' - '+current.link.name[1]);
2015-11-04 01:59:00 +00:00
}
});
2015-11-05 02:34:35 +00:00
ui.updateVideoMenu=function(){
node.classList.add('active');
rightPane.appendChild(page);
playButton.style.display='';
deleteButton.style.display='';
saveButton.style.display='';
}
2015-11-04 01:59:00 +00:00
}
};
});
}());
2015-10-30 15:32:48 +00:00
var active=start.firstChild.querySelector('.active');
if(!active){
active=start.firstChild.firstChild;
active.classList.add('active');
}
rightPane.appendChild(active.link);
}());
2015-11-04 01:59:00 +00:00
2015-10-30 15:32:48 +00:00
(function(){
var start=menux.pages[5];
var rightPane=start.lastChild;
var clickMode=function(){
if(this.classList.contains('off')) return;
var active=this.parentNode.querySelector('.active');
if(active===this){
return;
}
active.classList.remove('active');
active.link.remove();
active=this;
this.classList.add('active');
rightPane.appendChild(this.link);
};
for(var i in lib.help){
var page=ui.create.div('');
var node=ui.create.div('.menubutton.large',i,start.firstChild,clickMode);
node.link=page;
page.classList.add('menu-help');
page.innerHTML=lib.help[i];
}
var active=start.firstChild.querySelector('.active');
if(!active){
active=start.firstChild.firstChild;
active.classList.add('active');
}
rightPane.appendChild(active.link);
}());
2015-10-29 17:36:14 +00:00
}());
2015-10-31 10:14:14 +00:00
// ui.systemButton=ui.create.div('.menubutton.round.highlight#systembutton','设',ui.arena,function(){
//
// });
2015-11-04 01:59:00 +00:00
lib.status.date=new Date();
lib.status.dateDelayed=0;
2015-11-09 09:05:28 +00:00
while(lib.arenaReady.length){
(lib.arenaReady.shift())();
}
delete lib.arenaReady;
2015-10-30 09:13:19 +00:00
clearTimeout(window.resetGameTimeout);
delete window.resetGameTimeout;
2015-04-29 03:25:17 +00:00
},
system:function(str,func,right){
var node=ui.create.div(right?ui.system2:ui.system1);
node.innerHTML=str;
if(func){
node.addEventListener(lib.config.touchscreen?'touchend':'click',function(e){
if(_status.dragged) return;
func.call(this,e);
});
}
return node;
},
pause:function(){
2015-04-29 03:44:48 +00:00
if(_status.pausing) return;
2015-04-29 03:25:17 +00:00
var node=ui.create.div("#paused",ui.window);
2015-04-29 03:44:48 +00:00
_status.pausing=true;
setTimeout(function(){
_status.pausing=false;
},500);
2015-04-29 03:25:17 +00:00
if(lib.config.touchscreen){
setTimeout(function(){
node.addEventListener('touchend',ui.click.resume);
},500);
}
else{
node.addEventListener('click',ui.click.resume);
}
node.oncontextmenu=ui.click.resume;
var node2=ui.create.div('#paused2',node);
node2.innerHTML='已暂停';
2015-10-28 03:47:35 +00:00
2015-10-10 14:38:33 +00:00
// 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();
// }
// });
2015-04-29 03:25:17 +00:00
return node;
},
button:function(item,type,position,noclick){
var node;
switch(type){
case 'blank':
node=ui.create.div('.button.card',position);
node.link=item;
break;
case 'card':
node=item.cloneNode(true);
node.classList.add('button');
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);
}
break;
case 'vcard':
2015-05-02 09:54:39 +00:00
node=ui.create.card(position,'noclick',noclick).init(item);
2015-04-29 03:25:17 +00:00
node.classList.add('button');
node.link=item;
break;
case 'character':case 'player':
node=ui.create.div('.button.character',position);
node.link=item;
if(type=='character'){
node.setBackground(item,'character');
node.node={
name:ui.create.div('.name',node),
hp:ui.create.div('.hp',node),
intro:ui.create.div('.intro',node),
group:ui.create.div('.identity',node)
}
2015-10-30 15:32:48 +00:00
var infoitem=lib.character[item];
if(!infoitem){
for(var itemx in lib.characterPack){
if(lib.characterPack[itemx][item]){
infoitem=lib.characterPack[itemx][item];break;
}
}
}
if(infoitem[2]>14){
node.node.hp.innerHTML=infoitem[2];
2015-05-13 10:26:54 +00:00
node.node.hp.classList.add('text');
}
else{
2015-10-30 15:32:48 +00:00
for(var i =0;i<infoitem[2];i++){
2015-05-13 10:26:54 +00:00
ui.create.div('',node.node.hp);
}
2015-04-29 03:25:17 +00:00
}
2015-10-30 09:13:19 +00:00
// if(!lib.config.show_name){
2015-04-29 03:25:17 +00:00
node.node.name.style.display='none';
2015-10-30 09:13:19 +00:00
// }
2015-04-29 03:25:17 +00:00
var name=get.translation(item);
node.node.name.innerHTML='';
for(var i=0;i<name.length;i++){
node.node.name.innerHTML+=name[i]+'<br/>';
}
node.node.intro.innerHTML=lib.config.intro;
2015-05-02 09:54:39 +00:00
if(!noclick){
if(lib.config.touchscreen){
lib.setLongPress(node,ui.click.intro);
}
2015-11-09 17:04:18 +00:00
else if(lib.config.hover_all){
lib.setHover(node,ui.click.hoverplayer);
}
2015-05-02 09:54:39 +00:00
if(lib.config.right_info){
node.oncontextmenu=ui.click.rightplayer;
}
2015-04-29 03:25:17 +00:00
}
2015-11-09 03:15:16 +00:00
if(infoitem[1]){
node.node.group.innerHTML='<div>'+get.translation(infoitem[1])+'</div>';
node.node.group.style.backgroundColor=get.translation(infoitem[1]+'Color');
}
else{
node.node.group.style.display='none';
}
2015-04-29 03:25:17 +00:00
}
else{
if(item.name.indexOf('unknown')==0){
node.setBackground(item.name1,'character');
}
else{
node.setBackground(item.name,'character');
}
}
break;
case 'text':
node=ui.create.div('.button.text',position);
node.innerHTML=lib.get.translate(item);
break;
}
if(!noclick){
node.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.button);
}
else{
node.classList.add('noclick');
if(node.querySelector('.intro')){
node.querySelector('.intro').remove();
}
}
for(var i in lib.element.button){
node[i]=lib.element.button[i];
}
return node;
},
buttons:function(list,type,position,noclick,zoom){
var buttons=[];
for(var i=0;i<list.length;i++){
buttons.push(ui.create.button(list[i],type,position,noclick));
}
return buttons;
},
player:function(position){
var node=ui.create.div('.player',position);
node.node={
avatar:ui.create.div('.avatar',node).hide(),
avatar2:ui.create.div('.avatar2',node).hide(),
intro:ui.create.div('.intro',node),
identity:ui.create.div('.identity',node),
hp:ui.create.div('.hp',node),
name:ui.create.div('.name',node),
count:ui.create.div('.count',node).hide(),
2015-11-05 02:34:35 +00:00
equips:ui.create.div('.equips',node).hide(),
2015-04-29 03:25:17 +00:00
judges:ui.create.div('.judges',node),
marks:ui.create.div('.marks',node),
handcards1:ui.create.div('#handcards1'),
handcards2:ui.create.div('#handcards2'),
};
2015-11-06 10:05:08 +00:00
node.node.action=ui.create.div('.action',node.node.avatar);
2015-04-29 03:25:17 +00:00
node.skipList=[];
node.skills=[];
node.initedSkills=[];
node.additionalSkills={};
node.disabledSkills={};
node.hiddenSkills=[];
node.forbiddenSkills=[];
node.modeSkills=[];
node.popups=[];
2015-09-26 13:11:55 +00:00
node.damagepopups=[];
2015-04-29 03:25:17 +00:00
node.stat=[{card:{},skill:{}}];
node.tempSkills={};
node.storage={};
node.marks={};
node.ai={friend:[],enemy:[],neutral:[]};
node.queueCount=0;
if(lib.config.mousewheel&&!lib.config.touchscreen){
node.node.handcards1.onmousewheel=ui.click.mousewheel;
node.node.handcards2.onmousewheel=ui.click.mousewheel;
// node.node.equips.onmousewheel=ui.click.mousewheel;
}
node.node.handcards1.ontouchstart = ui.click.touchStart;
node.node.handcards2.ontouchstart = ui.click.touchStart;
node.node.handcards1.ontouchmove = ui.click.touchScroll;
node.node.handcards2.ontouchmove = ui.click.touchScroll;
node.node.handcards1.style.WebkitOverflowScrolling='touch';
node.node.handcards2.style.WebkitOverflowScrolling='touch';
for(var i in lib.element.player){
node[i]=lib.element.player[i];
}
ui.create.div(node.node.identity);
node.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.target);
node.node.identity.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.identity);
return node;
},
players:function(num){
2015-05-08 08:07:38 +00:00
if(num===0){
return;
}
2015-04-29 03:25:17 +00:00
if(num==undefined) num=lib.config.mode_config[lib.config.mode].player_number;
2015-10-29 17:36:14 +00:00
if(typeof num=='string'){
num=parseInt(num);
}
if(!num) num=5;
2015-04-29 03:25:17 +00:00
for(var i=0;i<num;i++){
var player=ui.create.player(ui.arena).animate('start');
game.players.push(player);
player.dataset.position=i;
}
var players=game.players;
for(var i=0;i<players.length;i++){
if(i>0){
players[i].previous=players[i-1];
players[i].previousSeat=players[i-1];
}
if(i<players.length-1){
players[i].next=players[i+1];
players[i].nextSeat=players[i+1];
}
}
players[0].previous=players[players.length-1];
players[0].previousSeat=players[players.length-1];
players[players.length-1].next=players[0];
players[players.length-1].nextSeat=players[0];
ui.arena.dataset.number=num;
2015-11-04 01:59:00 +00:00
return players;
2015-04-29 03:25:17 +00:00
},
me:function(){
ui.mebg=ui.create.div('#mebg',ui.arena);
ui.me=ui.create.div('#me',ui.arena).animate('start');
2015-05-08 08:07:38 +00:00
if(game.players.length){
game.me=game.players[0];
ui.handcards1=game.me.node.handcards1;
ui.handcards2=game.me.node.handcards2;
ui.me.appendChild(ui.handcards1);
ui.me.appendChild(ui.handcards2);
ui.updateh(true);
}
2015-04-29 03:25:17 +00:00
},
2015-05-02 09:54:39 +00:00
card:function(position,info,noclick){
2015-04-29 03:25:17 +00:00
var node=ui.create.div('.card',position);
node.node={
image:ui.create.div('.image',node),
info:ui.create.div('.info',node),
name:ui.create.div('.name',node),
name2:ui.create.div('.name2',node),
background:ui.create.div('.background',node),
intro:ui.create.div('.intro',node),
}
for(var i in lib.element.card){
node[i]=lib.element.card[i];
}
node.node.intro.innerHTML=lib.config.intro;
2015-05-02 09:54:39 +00:00
if(!noclick){
if(lib.config.touchscreen){
lib.setLongPress(node,ui.click.intro);
}
2015-11-09 17:04:18 +00:00
else if(lib.config.hover_all){
lib.setHover(node,ui.click.hoverplayer);
}
2015-05-02 09:54:39 +00:00
if(lib.config.right_info){
node.oncontextmenu=ui.click.rightplayer;
}
2015-04-29 03:25:17 +00:00
}
node.storage={};
if(info!='noclick'){
node.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.card);
}
return node;
},
cards:function(random){
if(!random){
2015-05-03 15:17:15 +00:00
lib.card.list.randomSort();
2015-04-29 03:25:17 +00:00
}
for(var i=0;i<lib.card.list.length;i++){
if(lib.card[lib.card.list[i][2]]){
2015-10-30 15:32:48 +00:00
if(lib.config.bannedcards.contains(lib.card.list[i][2])) continue;
2015-04-29 03:25:17 +00:00
ui.create.card(ui.cardPile).init(lib.card.list[i]);
}
}
},
},
click:{
2015-10-31 16:18:20 +00:00
system:function(){
if(lib.config.layout!='phone') return;
_status.clicked=true;
2015-11-09 17:04:18 +00:00
this.classList.add('shown');
if(this._tempclicking){
ui.arena.classList.add('phonetop');
2015-10-31 16:18:20 +00:00
}
2015-11-09 17:04:18 +00:00
else{
this._tempclicking=true;
var that=this;
setTimeout(function(){
that._tempclicking=false;
},300);
}
if(this.nextSibling) this.nextSibling.classList.remove('shown');
if(this.previousSibling) this.previousSibling.classList.remove('shown');
2015-10-31 16:18:20 +00:00
},
2015-04-30 08:24:57 +00:00
pausehistory:function(){
2015-11-05 02:34:35 +00:00
if(!lib.config.auto_popped_history) return;
2015-04-30 08:24:57 +00:00
if(!ui.sidebar.childNodes.length) return;
var uiintro=ui.create.dialog('hidden');
uiintro.style.maxHeight='400px';
2015-04-30 08:24:57 +00:00
uiintro.add(ui.sidebar);
return uiintro;
},
2015-10-28 03:47:35 +00:00
wuxieconfig:function(){
if(!lib.config.auto_popped) return;
2015-10-29 17:36:14 +00:00
// if(!ui.config.childNodes.length) return;
2015-10-28 03:47:35 +00:00
var uiintro=ui.create.dialog('hidden');
2015-10-29 17:36:14 +00:00
var node=ui.create.switcher('wuxie_self',lib.config.wuxie_self,ui.click.sidebar.global);
2015-10-28 03:47:35 +00:00
uiintro.add(node);
return uiintro;
},
2015-04-30 08:24:57 +00:00
pauseconfig:function(){
2015-11-05 02:34:35 +00:00
if(!lib.config.auto_popped_config) return;
2015-10-29 17:36:14 +00:00
// if(!ui.config.childNodes.length) return;
2015-04-30 08:24:57 +00:00
var uiintro=ui.create.dialog('hidden');
2015-11-09 17:04:18 +00:00
uiintro.listen(function(e){
e.stopPropagation();
});
2015-05-08 08:07:38 +00:00
var rows=Math.ceil(lib.config.all.mode.length/3);
2015-10-29 17:36:14 +00:00
uiintro.type='config';
2015-05-08 08:07:38 +00:00
for(var k=0;k<rows;k++){
var node=ui.create.div('.newgame');
for(var i=0;i<3&&i+k*3<lib.config.all.mode.length;i++){
var thismode=lib.config.all.mode[i+k*3];
var div=ui.create.div(thismode==lib.config.mode?'.underlinenode.on':'.underlinenode',node);
div.innerHTML=lib.translate[thismode];
div.link=thismode;
div.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
game.saveConfig('mode',this.link);
game.reload();
});
}
uiintro.add(node);
}
2015-11-05 02:34:35 +00:00
if(_status.video) return uiintro;
2015-05-01 07:35:43 +00:00
var auto=null;
2015-05-08 08:07:38 +00:00
var ng=null;
2015-05-01 07:35:43 +00:00
var sks=[];
var autoskill=ui.autoskill;
if(game.players){
for(var i=0;i<game.players.length;i++){
if(game.players[i]==game.me||game.players[i].isUnderControl()){
sks=sks.concat(game.expandSkills(game.players[i].get('s')));
}
}
}
2015-10-30 09:13:19 +00:00
for(var i=0;i<sks.length;i++){
if(autoskill[sks[i]]){
2015-05-01 07:35:43 +00:00
if(!auto){
2015-05-08 08:07:38 +00:00
ng=ui.create.div('.text');
ng.style.marginBottom=0;
ng.innerHTML='新游戏';
uiintro.content.insertBefore(ng,uiintro.content.firstChild);
2015-05-01 07:35:43 +00:00
auto=ui.create.div('.text');
auto.style.marginBottom=0;
auto.innerHTML='自动发动';
uiintro.add(auto);
}
2015-10-30 09:13:19 +00:00
autoskill[sks[i]].style.display='';
uiintro.add(autoskill[sks[i]]);
2015-05-01 07:35:43 +00:00
}
}
2015-04-30 08:24:57 +00:00
return uiintro;
},
2015-04-30 03:09:07 +00:00
volumn:function(){
var uiintro=ui.create.dialog('hidden');
2015-11-09 17:04:18 +00:00
uiintro.listen(function(e){
e.stopPropagation();
});
2015-04-30 03:09:07 +00:00
uiintro.add('背景音乐');
var vol1=ui.create.div('.volumn');
uiintro.add(vol1);
for(var i=0;i<8;i++){
var span=document.createElement('span');
span.link=i+1;
span.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.volumn_background);
if(i<lib.config.volumn_background){
span.innerHTML='●';
}
else{
span.innerHTML='○';
}
vol1.appendChild(span);
}
uiintro.add('游戏音效');
var vol2=ui.create.div('.volumn');
uiintro.add(vol2);
for(var i=0;i<8;i++){
var span=document.createElement('span');
span.link=i+1;
span.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.volumn_audio);
if(i<lib.config.volumn_audio){
span.innerHTML='●';
}
else{
span.innerHTML='○';
}
vol2.appendChild(span);
}
uiintro.add(ui.create.div('.placeholder'));
return uiintro;
},
volumn_background:function(e){
if(_status.dragged) return;
2015-05-16 14:27:14 +00:00
var volume=this.link;
if(volume===1&&lib.config.volumn_background===1){
volume=0;
}
game.saveConfig('volumn_background',volume);
ui.backgroundMusic.volume=volume/8;
2015-04-30 03:09:07 +00:00
for(var i=0;i<8;i++){
if(i<lib.config.volumn_background){
this.parentNode.childNodes[i].innerHTML='●';
}
else{
this.parentNode.childNodes[i].innerHTML='○';
}
}
e.stopPropagation();
},
volumn_audio:function(e){
if(_status.dragged) return;
2015-05-16 14:27:14 +00:00
var volume=this.link;
if(volume===1&&lib.config.volumn_audio===1){
volume=0;
}
game.saveConfig('volumn_audio',volume);
2015-04-30 03:09:07 +00:00
for(var i=0;i<8;i++){
if(i<lib.config.volumn_audio){
this.parentNode.childNodes[i].innerHTML='●';
}
else{
this.parentNode.childNodes[i].innerHTML='○';
}
}
e.stopPropagation();
},
hoverpopped:function(){
if(this._uiintro){
return;
}
if(!this._poppedfunc){
return;
}
2015-11-09 17:04:18 +00:00
if(lib.config.touchscreen){
_status.touchpopping=true;
setTimeout(function(){
_status.touchpopping=false;
},500);
}
2015-04-30 08:24:57 +00:00
var uiintro=this._poppedfunc();
if(!uiintro) return;
2015-04-30 03:09:07 +00:00
if(ui.currentpopped&&ui.currentpopped._uiintro){
ui.currentpopped._uiintro.delete();
delete ui.currentpopped._uiintro;
}
ui.currentpopped=this;
uiintro.classList.add('popped');
uiintro.classList.add('static');
this._uiintro=uiintro;
ui.window.appendChild(uiintro);
var width=this._poppedwidth||330;
uiintro.style.width=width+'px';
var height=this._poppedheight||uiintro.content.scrollHeight;
uiintro.style.height=Math.min(ui.window.offsetHeight-260,height)+'px';
2015-04-30 03:09:07 +00:00
uiintro.style.top='50px';
var left=this.parentNode.offsetLeft+this.offsetLeft+this.offsetWidth/2-width/2;
if(left<10){
left=10;
}
else if(left+width>ui.window.offsetWidth-10){
left=ui.window.offsetWidth-width-10;
}
uiintro.style.left=left+'px';
uiintro._poppedorigin=this;
uiintro.addEventListener(lib.config.touchscreen?'touchend':'mouseleave',ui.click.leavehoverpopped);
},
leavehoverpopped:function(){
if(_status.dragged) return;
this.delete();
2015-10-29 17:36:14 +00:00
var button=this._poppedorigin;
var uiintro=this;
2015-04-30 03:09:07 +00:00
setTimeout(function(){
2015-10-29 17:36:14 +00:00
if(button._uiintro==uiintro){
delete button._uiintro;
}
2015-04-30 03:09:07 +00:00
},500);
2015-10-29 17:36:14 +00:00
2015-04-30 03:09:07 +00:00
},
2015-04-29 03:25:17 +00:00
dierevive:function(){
if(game.me.isDead()){
2015-10-29 17:36:14 +00:00
game.me.revive(Math.max(1,game.me.maxHp));
2015-04-29 03:25:17 +00:00
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;i<game.players.length;i++){
if(game.players[i].isAlive()){
players.push(game.players[i]);
}
}
ui.intro.add(players,true);
var buttons=ui.intro.querySelectorAll('.button');
for(var i=0;i<buttons.length;i++){
buttons[i].addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.dieswap2);
}
}
else{
if(ui.swap){
ui.swap.close();
delete ui.swap;
}
}
},
dieswap2:function(){
if(_status.dragged) return;
game.swapPlayer(this.link);
},
2015-10-29 17:36:14 +00:00
windowmousewheel:function(e){
_status.tempunpopup=e;
},
2015-04-29 03:25:17 +00:00
windowmousemove:function(e){
2015-10-29 17:36:14 +00:00
if(_status.tempunpopup){
if(get.evtDistance(_status.tempunpopup,e)>5){
delete _status.tempunpopup;
}
}
2015-04-29 03:25:17 +00:00
if(e.button==2) return;
if(!Array.isArray(e.path)) return;
var dialogs=document.querySelectorAll('#window>.dialog.popped:not(.static)');
for(var i=0;i<dialogs.length;i++){
dialogs[i].delete();
}
var node=_status.currentmouseenter;
if(_status.mousedragging){
2015-05-08 08:07:38 +00:00
e.preventDefault();
2015-04-29 03:25:17 +00:00
ui.canvas.width=ui.arena.offsetWidth;
ui.canvas.height=ui.arena.offsetHeight;
var ctx=ui.ctx;
ctx.shadowBlur=5;
ctx.shadowColor='rgba(0,0,0,0.3)';
ctx.strokeStyle='white';
ctx.lineWidth=3;
ctx.setLineDash([8,2]);
ctx.beginPath();
ctx.moveTo(_status.mousedragging.x-ui.arena.offsetLeft,_status.mousedragging.y-ui.arena.offsetTop);
if(_status.multitarget){
for(var i=0;i<_status.lastdragchange.length;i++){
var exy=_status.lastdragchange[i]._lastdragchange;
ctx.lineTo(exy[0],exy[1]);
}
}
if(!_status.selectionfull){
ctx.lineTo(e.x-ui.arena.offsetLeft,e.y-ui.arena.offsetTop);
}
ctx.stroke();
if(!_status.multitarget){
for(var i=0;i<_status.lastdragchange.length;i++){
ctx.moveTo(_status.mousedragging.x-ui.arena.offsetLeft,_status.mousedragging.y-ui.arena.offsetTop);
var exy=_status.lastdragchange[i]._lastdragchange;
ctx.lineTo(exy[0],exy[1]);
ctx.stroke();
}
}
for(var i=0;i<e.path.length;i++){
if(e.path[i]==_status.mousedragorigin){
if(_status.mouseleft){
_status.mousedragging=null;
_status.mousedragorigin=null;
_status.clicked=false;
game.uncheck();
game.check();
ui.canvas.width=ui.arena.offsetWidth;
ui.canvas.height=ui.arena.offsetHeight;
_status.clicked=true;
}
return;
}
var itemtype=get.itemtype(e.path[i]);
if(itemtype=='card'||itemtype=='button'||itemtype=='player'){
_status.mouseleft=true;
var item=e.path[i];
var ex=e.x-ui.arena.offsetLeft;
var ey=e.y-ui.arena.offsetTop;
2015-05-08 08:07:38 +00:00
var exx=ex,eyy=ey;
if(lib.config.mode=='chess'){
ex-=-ui.chessContainer.scrollLeft+ui.chess.offsetLeft;
ey-=-ui.chessContainer.scrollTop+ui.chess.offsetTop;
}
2015-04-29 03:25:17 +00:00
if(itemtype!='player'||(ex>item.offsetLeft&&ex<item.offsetLeft+item.offsetWidth&&
ey>item.offsetTop&&ey<item.offsetTop+item.offsetHeight)){
2015-07-09 05:21:22 +00:00
var targetfixed=false;
if(itemtype=='player'){
if(get.select(_status.event.selectTarget)[1]==-1){
targetfixed=true;
}
}
if(!targetfixed&&item.classList.contains('selectable')&&_status.dragstatuschanged!=item){
2015-04-29 03:25:17 +00:00
_status.mouseleft=true;
_status.dragstatuschanged=item;
_status.clicked=false;
var notbefore=itemtype=='player'&&!item.classList.contains('selected');
ui.click[itemtype].call(item);
if(item.classList.contains('selected')){
if(notbefore){
_status.lastdragchange.push(item);
2015-05-08 08:07:38 +00:00
e.path[i]._lastdragchange=[exx,eyy];
2015-04-29 03:25:17 +00:00
}
}
else{
_status.lastdragchange.remove(item);
}
_status.selectionfull=true;
if(_status.event.filterButton&&ui.selected.buttons.length<get.select(_status.event.selectButton)[1]){
_status.selectionfull=false;
}
else if(_status.event.filterCard&&ui.selected.cards.length<get.select(_status.event.selectCard)[1]){
_status.selectionfull=false;
}
else if(_status.event.filterTarget&&ui.selected.targets.length<get.select(_status.event.selectTarget)[1]){
_status.selectionfull=false;
}
}
}
return;
}
}
_status.mouseleft=true;
_status.dragstatuschanged=null;
}
else{
if(e.path.contains(node)&&!node._mouseentercreated){
ui.click.mouseentercancel();
var hoveration;
if(typeof node._hoveration=='number'){
hoveration=node._hoveration;
}
else{
2015-10-30 09:13:19 +00:00
hoveration=parseInt(lib.config.hoveration);
2015-04-29 03:25:17 +00:00
if(node.classList.contains('button')||
(node.parentNode&&node.parentNode.parentNode)==ui.me){
hoveration+=500;
}
}
_status._mouseentertimeout=setTimeout(function(){
2015-10-29 17:36:14 +00:00
if(_status.currentmouseenter!=node||node._mouseentercreated||_status.tempunpopup||
2015-04-29 03:25:17 +00:00
_status.mousedragging||_status.mousedown||!node.offsetWidth||!node.offsetHeight){
return;
}
2015-10-20 17:44:00 +00:00
if(node._hoverfunc&&!node._nopup){
2015-04-29 03:25:17 +00:00
var dialog=node._hoverfunc.call(node,e);
dialog.classList.add('popped');
ui.window.appendChild(dialog);
lib.placePoppedDialog(dialog,e);
if(node._hoverwidth){
dialog.style.width=node._hoverwidth+'px';
dialog._hovercustomed=true;
}
node._mouseenterdialog=dialog;
node._mouseentercreated=true;
}
},hoveration);
}
2015-05-08 08:07:38 +00:00
if(_status.draggingdialog){
var ddialog=_status.draggingdialog;
if(ddialog._dragorigin&&ddialog._dragtransform){
var translate=ddialog._dragtransform.slice(0);
translate[0]+=e.x-ddialog._dragorigin.x;
translate[1]+=e.y-ddialog._dragorigin.y;
2015-11-05 02:34:35 +00:00
ddialog.style.transform='translate('+translate[0]+'px,'+translate[1]+'px)'
2015-05-08 08:07:38 +00:00
}
2015-06-14 05:07:39 +00:00
_status.clicked=true;
2015-05-08 08:07:38 +00:00
}
2015-04-29 03:25:17 +00:00
}
},
windowmousedown:function(e){
if(e.button==2) return;
_status.mousedown=true;
var dialogs=ui.window.querySelectorAll('#window>.dialog.popped:not(.static)');
for(var i=0;i<dialogs.length;i++){
dialogs[i].delete();
}
2015-09-03 03:49:14 +00:00
if(e.path){
for(var i=0;i<e.path.length;i++){
var itemtype=get.itemtype(e.path[i]);
if(itemtype=='button') break;
2015-10-20 17:44:00 +00:00
if(itemtype=='dialog'&&
!e.path[i].classList.contains('popped')&&
!e.path[i].classList.contains('fixed')){
2015-09-03 03:49:14 +00:00
var ddialog=e.path[i];
_status.draggingdialog=ddialog;
ddialog._dragorigin=e;
if(!ddialog._dragtransform){
ddialog._dragtransform=[0,0];
}
return;
2015-05-08 08:07:38 +00:00
}
}
}
2015-09-03 03:49:14 +00:00
2015-04-29 03:25:17 +00:00
var evt=_status.event;
if(!lib.config.enable_drag) return;
if(!ui.arena.classList.contains('selecting')) return;
if(!evt.isMine()) return;
if(!Array.isArray(e.path)) return;
for(var i=0;i<e.path.length;i++){
var itemtype=get.itemtype(e.path[i]);
if(itemtype=='card'||itemtype=='button'||itemtype=='player'){
if(e.path[i].classList.contains('selectable')&&
!e.path[i].classList.contains('selected')&&
!e.path[i].classList.contains('noclick')){
_status.clicked=false;
ui.click[itemtype].call(e.path[i]);
if(e.path[i].classList.contains('selected')){
_status.mousedragging=e;
_status.mousedragorigin=e.path[i];
_status.mouseleft=false;
_status.selectionfull=false;
_status.multitarget=false;
2015-10-20 17:44:00 +00:00
// if(ui.confirm&&ui.confirm.str=='c') ui.confirm.close();
}
2015-04-29 03:25:17 +00:00
}
return;
}
}
},
windowmouseup:function(e){
2015-05-08 08:07:38 +00:00
if(_status.draggingdialog){
var ddialog=_status.draggingdialog;
if(ddialog._dragorigin&&ddialog._dragtransform){
var translate=ddialog._dragtransform;
translate[0]+=e.x-ddialog._dragorigin.x;
translate[1]+=e.y-ddialog._dragorigin.y;
2015-11-05 02:34:35 +00:00
ddialog.style.transform='translate('+translate[0]+'px,'+translate[1]+'px)';
2015-05-08 08:07:38 +00:00
delete ddialog._dragorigin;
}
delete _status.draggingdialog;
}
2015-04-29 03:25:17 +00:00
if(e.button==2){
if(_status.mousedragging){
_status.mousedragging=null;
_status.mouseleft=false;
_status.mousedragorigin=null;
_status.dragstatuschanged=false;
ui.canvas.width=ui.arena.offsetWidth;
ui.canvas.height=ui.arena.offsetHeight;
game.uncheck();
game.check();
_status.noright=true;
}
}
else{
var tmpflag=false;
_status.mousedown=false;
if(_status.mousedragging&&_status.mouseleft){
if(game.check()){
if(ui.confirm){
ui.confirm.close();
}
ui.click.ok();
}
else{
game.uncheck();
game.check();
}
}
else if(_status.mousedragging&&_status.mousedragorigin){
tmpflag=_status.mousedragorigin;
}
_status.lastdragchange.length=0;
_status.mousedragging=null;
_status.mouseleft=false;
_status.mousedragorigin=null;
_status.dragstatuschanged=false;
ui.canvas.width=ui.arena.offsetWidth;
ui.canvas.height=ui.arena.offsetHeight;
if(tmpflag){
ui.click[get.itemtype(tmpflag)].call(tmpflag);
game.check();
}
}
},
mousemove:function(){
if(!lib.config.hover_handcard&&this.parentNode&&this.parentNode.parentNode==ui.me){
return;
}
if(!_status.currentmouseenter){
_status.currentmouseenter=this;
}
},
mouseenter:function(){
if(!lib.config.hover_handcard&&this.parentNode&&this.parentNode.parentNode==ui.me){
return;
}
_status.currentmouseenter=this;
},
mouseleave:function(){
ui.click.mouseentercancel();
if(_status.currentmouseenter==this){
_status.currentmouseenter=null;
}
this._mouseentercreated=false;
},
mousedown:function(){
ui.click.mouseentercancel();
if(_status.currentmouseenter==this){
_status.currentmouseenter=null;
}
this._mouseentercreated=true;
},
mouseentercancel:function(){
if(_status._mouseentertimeout){
clearTimeout(_status._mouseentertimeout);
delete _status._mouseentertimeout
}
},
hoverplayer:function(e){
return get.nodeintro(this,true);
},
longpressdown:function(e){
if(_status.longpressed) return;
if(this._longpresstimeout){
clearTimeout(this._longpresstimeout);
}
var func=this._longpresscallback;
var node=this;
this._longpresstimeout=setTimeout(function(){
delete node._longpresstimeout;
if(_status.mousedragging&&_status.mouseleft) return;
if(!_status.longpressed){
_status.longpressed=true;
setTimeout(function(){
_status.longpressed=false;
},500);
func.call(node,e);
}
},500);
},
longpresscancel:function(){
if(this._longpresstimeout){
clearTimeout(this._longpresstimeout);
delete this._longpresstimeout;
}
},
window:function(){
2015-05-13 10:26:54 +00:00
var clicked=_status.clicked;
2015-04-29 03:25:17 +00:00
if(_status.dragged) return;
2015-11-09 17:04:18 +00:00
if(_status.touchpopping) return;
2015-05-05 14:57:35 +00:00
if(_status.reloading) return;
2015-04-29 03:25:17 +00:00
if(_status.clicked){
_status.clicked=false;
}
2015-05-01 07:35:43 +00:00
else{
if(_status.editing){
if(_status.editing.innerHTML.length){
_status.editing.link=_status.editing.innerHTML;
}
_status.editing.innerHTML=get.translation(_status.editing.link);
delete _status.editing;
2015-04-29 03:25:17 +00:00
}
2015-05-02 06:59:31 +00:00
else if(_status.choosing){
if(!_status.choosing.expand){
_status.choosing.parentNode.style.height='';
_status.choosing.nextSibling.delete();
_status.choosing.previousSibling.show();
delete _status.choosing;
}
}
2015-05-01 07:35:43 +00:00
else if(ui.intro){
ui.intro.close();
delete ui.intro;
ui.control.show();
game.resume2();
2015-04-29 03:25:17 +00:00
}
2015-05-01 07:35:43 +00:00
else if(_status.event.isMine()){
if(_status.event.custom.replace.window){
_status.event.custom.replace.window();
2015-04-29 03:25:17 +00:00
}
else{
2015-05-01 07:35:43 +00:00
if(_status.event.skill&&_status.event.name=='chooseToUse'){
ui.click.cancel();
}
else{
game.uncheck();
game.check();
}
2015-04-29 03:25:17 +00:00
}
}
2015-10-31 16:18:20 +00:00
if(lib.config.layout=='phone'){
2015-11-09 17:04:18 +00:00
ui.arena.classList.remove('phonetop');
2015-10-31 16:18:20 +00:00
ui.system1.classList.remove('shown');
ui.system2.classList.remove('shown');
2015-11-09 17:04:18 +00:00
if(ui.chessinfo){
ui.chessinfo.classList.remove('zoomed');
}
2015-10-31 16:18:20 +00:00
}
2015-04-29 03:25:17 +00:00
}
2015-05-01 07:35:43 +00:00
if(_status.tempunpop){
_status.tempunpop=false;
}
else{
2015-05-02 09:54:39 +00:00
if(ui.currentpopped){
if(ui.currentpopped._uiintro){
ui.currentpopped._uiintro.delete();
delete ui.currentpopped._uiintro;
}
2015-05-01 07:35:43 +00:00
delete ui.currentpopped;
}
2015-04-30 03:09:07 +00:00
}
2015-04-29 03:25:17 +00:00
if(_status.event.custom.add.window){
2015-05-13 10:26:54 +00:00
_status.event.custom.add.window(clicked);
2015-04-29 03:25:17 +00:00
}
},
toggle:function(){
if(_status.dragged) return;
if(this.parentNode.classList.contains('disabled')) return;
2015-05-01 07:35:43 +00:00
_status.tempunpop=true;
2015-04-29 03:25:17 +00:00
if(this.link){
this.link=false;
this.classList.remove('on');
if(this.additionalCommand) this.additionalCommand(false,this.parentNode);
}
else{
this.link=true;
this.classList.add('on');
if(this.additionalCommand) this.additionalCommand(true,this.parentNode);
}
},
editor:function(){
if(_status.dragged) return;
if(_status.editing) return;
_status.clicked=true;
this.innerHTML='';
_status.editing=this;
if(this.additionalCommand) this.additionalCommand(this);
},
switcher:function(){
if(_status.dragged) return;
2015-05-11 11:57:44 +00:00
if(this.parentNode.classList.contains('disabled')) return;
2015-04-29 03:25:17 +00:00
if(_status.choosing) return;
_status.clicked=true;
2015-05-01 07:35:43 +00:00
_status.tempunpop=true;
2015-04-29 03:25:17 +00:00
this.previousSibling.hide();
var node=ui.create.div('.switcher',this.parentNode).animate('start');
for(var i=0;i<this.choice.length;i++){
var choice=ui.create.div(node);
choice.innerHTML=get.translation(this.choice[i]);
choice.link=this.choice[i];
choice.addEventListener(lib.config.touchscreen?'touchend':'click',ui.click.choice);
}
this.parentNode.style.height=(node.offsetHeight)+'px';
_status.choosing=this;
2015-05-02 06:59:31 +00:00
if(!_status.choosing.expand){
_status.choosing.expand=true;
setTimeout(function(){
_status.choosing.expand=false;
},500);
}
2015-04-29 03:25:17 +00:00
},
choice:function(){
if(_status.dragged) return;
2015-04-29 07:54:48 +00:00
if(!_status.choosing) return;
2015-04-29 03:25:17 +00:00
_status.choosing.link=this.link;
_status.choosing.innerHTML=get.translation(this.link);
this.parentNode.parentNode.style.height='';
this.parentNode.delete();
_status.choosing.previousSibling.show();
delete _status.choosing;
if(this.parentNode.parentNode.querySelector('.toggle').additionalCommand){
this.parentNode.parentNode.querySelector('.toggle').additionalCommand(this.link,this.parentNode.parentNode);
}
},
button:function(){
if(_status.dragged) return;
if(_status.clicked) return;
2015-05-13 10:26:54 +00:00
if(this.classList.contains('noclick')) return;
2015-04-29 03:25:17 +00:00
_status.clicked=true;
var custom=_status.event.custom;
if(custom.replace.button){
custom.replace.button(this);
return;
}
if(this.classList.contains('selectable')==false) return;
if(this.classList.contains('selected')){
ui.selected.buttons.remove(this);
if(_status.multitarget){
game.uncheck();
game.check();
}
}
else{
ui.selected.buttons.add(this);
}
this.classList.toggle('selected');
if(custom.add.button){
custom.add.button();
}
game.check();
},
card:function(){
if(_status.dragged) return;
if(_status.clicked) return;
if(ui.intro) return;
_status.clicked=true;
var custom=_status.event.custom;
if(custom.replace.card){
custom.replace.card(this);
return;
}
if(this.classList.contains('selectable')==false) return;
if(this.classList.contains('selected')){
ui.selected.cards.remove(this);
if(_status.multitarget){
game.uncheck();
game.check();
}
}
else{
ui.selected.cards.add(this);
}
this.classList.toggle('selected');
2015-05-08 13:37:34 +00:00
if(false){
if(lib.config.mode=='chess'&&!_status.event.skill&&this.classList.contains('selected')&&
_status.event.isMine()&&_status.event.name=='chooseToUse'){
var player=_status.event.player;
var range=get.info(this).range;
if(range){
if(typeof range.attack==='number'){
player.createRangeShadow(get.attackRange(player)+range.attack-1);
}
else if(typeof range.global==='number'){
player.createRangeShadow(get.globalFrom(player)+range.global);
}
}
}
}
2015-04-29 03:25:17 +00:00
if(custom.add.card){
custom.add.card();
}
game.check();
},
player:function(){
return ui.click.target.apply(this,arguments);
},
2015-05-12 09:51:40 +00:00
target:function(e){
2015-04-29 03:25:17 +00:00
if(_status.dragged) return;
if(_status.clicked) return;
if(ui.intro) return;
_status.clicked=true;
var custom=_status.event.custom;
if(custom.replace.target){
2015-05-12 09:51:40 +00:00
custom.replace.target(this,e);
2015-04-29 03:25:17 +00:00
return;
}
if(this.classList.contains('selectable')==false) return;
this.unprompt();
if(this.classList.contains('selected')){
ui.selected.targets.remove(this);
if(_status.multitarget){
game.uncheck();
game.check();
}
else{
this.classList.remove('selected');
}
}
else{
ui.selected.targets.add(this);
2015-05-12 09:51:40 +00:00
if(_status.event.name=='chooseToUse'){
var targetprompt=null;
if(_status.event.targetprompt){
targetprompt=_status.event.targetprompt;
2015-04-29 03:25:17 +00:00
}
2015-05-12 09:51:40 +00:00
else if(_status.event.skill&&!get.info(_status.event.skill).viewAs){
targetprompt=get.info(_status.event.skill).targetprompt;
2015-04-29 03:25:17 +00:00
}
2015-05-12 09:51:40 +00:00
else{
var currentcard=get.card();
if(currentcard){
targetprompt=get.info(currentcard).targetprompt;
}
2015-04-29 03:25:17 +00:00
}
2015-05-12 09:51:40 +00:00
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);
}
2015-04-29 03:25:17 +00:00
}
}
this.classList.add('selected');
}
if(custom.add.target){
custom.add.target();
}
game.check();
},
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(this.parentNode.classList.contains('hidden')) 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();
}
},
skill:function(skill){
var info=get.info(skill);
var event=_status.event;
event.backup(skill);
if(typeof event.skillDialog=='object'){
event.skillDialog.close();
}
if(event.isMine()){
event.skillDialog=true;
}
game.uncheck();
game.check();
if(event.skillDialog){
var str=get.translation(skill);
if(info.prompt){
if(typeof info.prompt=='function'){
str+=''+info.prompt(event);
}
else{
str+=''+info.prompt;
}
event.skillDialog=ui.create.dialog(str);
}
2015-10-20 17:44:00 +00:00
else if(info.promptfunc){
event.skillDialog=ui.create.dialog(str,'<div><div style="width:100%">'+info.promptfunc(event,event.player)+'</div></div>');
}
2015-04-29 03:25:17 +00:00
else if(lib.translate[skill+'_info']){
event.skillDialog=ui.create.dialog(str,'<div><div style="width:100%">'+lib.translate[skill+'_info']+'</div></div>');
}
}
},
ok:function(node){
var event=_status.event;
if(event.custom.replace.confirm){
event.custom.replace.confirm(true);return;
}
event.result={
buttons:ui.selected.buttons.slice(0),
cards:ui.selected.cards.slice(0),
targets:ui.selected.targets.slice(0),
confirm:'ok',
bool:true,
links:get.links(ui.selected.buttons)
};
if(node){
node.parentNode.close();
}
if(event.skill){
event.result.skill=event.skill;
event.result.card=get.info(event.skill).viewAs;
if(event.result.cards.length==1&&event.result.card){
event.result.card.suit=event.result.cards[0].suit;
}
if(event.skillDialog&&get.objtype(event.skillDialog)=='div'){
event.skillDialog.close();
}
event.restore();
}
if(ui.skills) ui.skills.close();
game.uncheck();
if(event.custom.add.confirm){
event.custom.add.confirm(true);
}
game.resume();
},
cancel:function(node){
var event=_status.event;
if(event.custom.replace.confirm){
event.custom.replace.confirm(false);return;
}
if(event.skill){
if(event.skillDialog&&get.objtype(event.skillDialog)=='div'){
event.skillDialog.close();
}
if(typeof event.dialog=='string'&&event.isMine()){
event.dialog=ui.create.dialog(event.dialog);
}
event.restore();
game.uncheck();
game.check();
return;
}
event.result={
confirm:'cancel',
bool:false
};
if(node){
node.parentNode.close();
}
if(ui.skills) ui.skills.close();
game.uncheck();
if(event.custom.add.confirm){
event.custom.add.confirm(true);
}
game.resume();
},
oldintro:function(e){
if(_status.dragged) return;
_status.clicked=true;
if(this.classList.contains('player')&&!this.name){
return;
}
var i,translation,intro,str;
ui.click.intro2.call(this);
game.pause2();
ui.control.hide();
ui.intro=get.nodeintro(this).open();
ui.intro.source=this;
},
intro:function(e){
if(_status.dragged) return;
_status.clicked=true;
if(this.classList.contains('player')&&!this.name){
return;
}
var uiintro=get.nodeintro(this);
uiintro.classList.add('popped');
uiintro.classList.add('static');
ui.window.appendChild(uiintro);
var layer=ui.create.div('.poplayer',ui.arena);
var clicklayer=function(e){
uiintro.delete();
this.remove();
game.resume2();
e.stopPropagation();
return false;
}
layer.addEventListener(lib.config.touchscreen?'touchend':'click',clicklayer);
layer.oncontextmenu=clicklayer;
lib.placePoppedDialog(uiintro,e);
uiintro.style.zIndex=21;
var clickintro=function(){
layer.remove();
this.delete();
game.resume2();
};
uiintro.addEventListener('mouseleave',clickintro);
uiintro.addEventListener('click',clickintro);
game.pause2();
2015-05-02 09:54:39 +00:00
return uiintro;
2015-04-29 03:25:17 +00:00
},
intro2:function(){
if(ui.intro){
ui.intro.close();
if(ui.intro.source==this){
delete ui.intro;
ui.control.show();
game.resume2();
return;
}
}
},
auto:function(){
if(ui.auto.classList.contains('hidden')) return;
if(!_status.auto){
_status.auto=true;
// ui.auto.innerHTML='手动';
ui.auto.classList.add('glow');
if(ui.confirm) ui.confirm.close();
ui.control.hide();
if(_status.event.switchToAuto){
_status.event.switchToAuto();
}
else{
if(_status.paused&&_status.imchoosing){
game.uncheck();
_status.event.redo();
}
}
game.resume();
}
else{
ui.control.show();
_status.auto=false;
ui.auto.classList.remove('glow');
// ui.auto.innerHTML='托管';
}
},
wuxie:function(){
2015-04-30 03:09:07 +00:00
if(this.classList.contains('hidden')) return;
2015-04-29 03:25:17 +00:00
this.classList.toggle('glow');
if(this.classList.contains('glow')&&
(_status.event.parent.name=='_wuxie1'||_status.event.parent.name=='_wuxie2')&&
_status.event.isMine()&&ui.confirm){
ui.click.cancel(ui.confirm.lastChild);
}
},
pause:function(){
if(_status.paused2) return;
ui.system.hide();
game.pause2();
var node=ui.create.pause().animate('start');
ui.sidebar3.innerHTML='';
2015-05-01 09:34:01 +00:00
if(lib.config.show_discardpile){
for(var i=0;i<ui.discardPile.childNodes.length;i++){
var div=ui.create.div(ui.sidebar3);
div.innerHTML=get.translation(ui.discardPile.childNodes[i]);
ui.sidebar3.insertBefore(div,ui.sidebar3.firstChild);
}
}
2015-04-29 03:25:17 +00:00
node.appendChild(ui.sidebar);
node.appendChild(ui.sidebar3);
2015-04-29 03:25:17 +00:00
ui.arena.classList.add('paused');
2015-05-11 11:57:44 +00:00
if(game.onpause){
game.onpause();
}
2015-04-29 03:25:17 +00:00
},
resume:function(e){
2015-04-29 03:44:48 +00:00
if(_status.pausing) return;
2015-04-29 03:25:17 +00:00
if(_status.dragged) return;
if(_status.clicked) return;
this.delete();
ui.system.show();
ui.arena.classList.remove('paused');
game.resume2();
e.stopPropagation();
2015-05-11 11:57:44 +00:00
if(game.onresume){
game.onresume();
}
2015-04-29 03:25:17 +00:00
return false;
},
config:function(){
if(_status.paused2) _status.config2=false;
else _status.config2=true;
2015-05-01 07:35:43 +00:00
2015-04-29 03:25:17 +00:00
_status.clicked=true;
game.pause2();
2015-10-29 17:36:14 +00:00
if(lib.config.config_menu){
ui.click.configMenu();
}
else{
ui.system.hide();
if(false&&lib.config.right_sidebar) ui.arena.classList.add('left');
else ui.arena.classList.add('right');
ui.window.appendChild(ui.configbg);
setTimeout(function(){
ui.config.animate('start');
ui.window.appendChild(ui.config);
},100);
if(game.onpause2){
game.onpause2();
}
2015-05-11 11:57:44 +00:00
}
2015-04-29 03:25:17 +00:00
},
2015-04-29 07:54:48 +00:00
config2:function(e){
2015-04-29 03:25:17 +00:00
_status.clicked=true;
ui.system.show();
ui.arena.classList.remove('right');
ui.arena.classList.remove('left');
2015-05-02 09:54:39 +00:00
ui.arena.classList.remove('paused2');
2015-04-29 03:25:17 +00:00
// ui.arena.classList.remove('paused');
this.remove();
2015-05-02 09:54:39 +00:00
if(ui.gameviewdialog){
if(ui.gameviewdialog.popped){
ui.gameviewdialog.popped.delete();
delete ui.gameviewdialog.popped;
}
ui.gameviewdialog.close();
delete ui.gameviewdialog;
ui.currentgameview.classList.remove('thundertext');
}
2015-04-29 03:25:17 +00:00
ui.config.delete();
if(_status.config2){
game.resume2();
}
2015-05-02 14:43:52 +00:00
// e.stopPropagation();
2015-05-11 11:57:44 +00:00
if(game.onresume2){
game.onresume2();
}
2015-04-29 07:54:48 +00:00
return false;
2015-04-29 03:25:17 +00:00
},
swap:function(){
if(_status.dragged) return;
if(this.classList.contains('dead')) return;
if(_status.over) return;
if(ui.auto) ui.auto.show();
if(ui.wuxie) ui.wuxie.show();
2015-04-29 03:25:17 +00:00
game.swapPlayer(this);
},
2015-05-11 11:57:44 +00:00
mousewheel:function(evt){
2015-04-29 03:25:17 +00:00
var node=this;
2015-05-11 11:57:44 +00:00
var num=this._scrollnum||6;
var speed=this._scrollspeed||16;
2015-04-29 03:25:17 +00:00
clearInterval(node.interval);
if(evt.detail > 0 || evt.wheelDelta < 0){
node.interval=setInterval(function(){
2015-05-11 11:57:44 +00:00
if(num--&&Math.abs(node.scrollLeft+node.clientWidth-node.scrollWidth)>0){
node.scrollLeft +=speed;
2015-04-29 03:25:17 +00:00
}
else{
clearInterval(node.interval);
}
2015-05-11 11:57:44 +00:00
},16);
2015-04-29 03:25:17 +00:00
}
else{
node.interval=setInterval(function(){
if(num--&&node.scrollLeft>0){
2015-05-11 11:57:44 +00:00
node.scrollLeft -=speed;
2015-04-29 03:25:17 +00:00
}
else{
clearInterval(node.interval);
}
2015-05-11 11:57:44 +00:00
},16);
2015-04-29 03:25:17 +00:00
}
},
touchStart:function(e){
this.startX=e.touches[0].clientX;
this.startY=e.touches[0].clientY;
_status.dragged=false;
},
touchScroll:function(e) {
if(!_status.dragged){
if (Math.abs(e.touches[0].clientX - this.startX) > 10 ||
Math.abs(e.touches[0].clientY - this.startY) > 10) {
_status.dragged=true;
}
}
if(this.scrollWidth<=this.offsetWidth&&
this.scrollHeight<=this.offsetHeight){
e.preventDefault();
}
else{
e.stopPropagation();
}
},
sidebar:{
2015-04-29 07:54:48 +00:00
local:function(item){
game.saveConfig(this.name,item,true);
},
local2:function(item){
game.saveConfig(this.name,item,true);
ui.sidebarrestart.classList.add('thundertext');
},
2015-10-28 03:47:35 +00:00
wuxie_self:function(item){
ui.wuxie_self.lastChild.click();
},
2015-04-29 07:54:48 +00:00
global:function(item){
game.saveConfig(this.name,item);
},
global2:function(item){
game.saveConfig(this.name,item);
ui.sidebarrestart.classList.add('thundertext');
},
2015-04-29 14:56:33 +00:00
background_music:function(item){
game.saveConfig(this.name,item);
game.playBackgroundMusic();
},
2015-04-29 03:25:17 +00:00
cheat:function(bool){
if(lib.config.cheat&&bool==false){
lib.cheat=window.cheat;
delete window.cheat;
delete window.game;
delete window.ui;
delete window.get;
delete window.ai;
delete window.lib;
delete window._status;
}
else if(!lib.config.cheat&&bool){
window.cheat=lib.cheat;
window.cheat.i();
}
game.saveConfig('cheat',bool);
},
free_choose:function(bool){
game.saveConfig('free_choose',bool,true);
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(!ui.cheat2&&get.config('free_choose')) ui.create.cheat2();
else if(ui.cheat2&&!get.config('free_choose')){
ui.cheat2.close();
delete ui.cheat2;
2015-05-08 08:07:38 +00:00
if(ui.cheat2x){
ui.cheat2x.close();
delete ui.cheat2;
}
2015-04-29 03:25:17 +00:00
}
},
change_identity:function(bool){
game.saveConfig('change_identity',bool,true);
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
var dialog;
if(ui.cheat2&&ui.cheat2.backup) dialog=ui.cheat2.backup;
else dialog=_status.event.dialog;
if(!dialog.querySelector('table')&&get.config('change_identity')) _status.event.parent.addSetting(dialog);
else _status.event.parent.removeSetting(dialog);
2015-04-29 03:25:17 +00:00
ui.update();
},
2015-05-04 03:17:03 +00:00
battle_number:function(num){
game.saveConfig('battle_number',num,true);
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(_status.event.parent.changeDialog){
_status.event.parent.changeDialog();
}
},
2015-04-29 03:25:17 +00:00
change_choice:function(bool){
game.saveConfig('change_choice',bool,true);
if(!_status.event.parent.showConfig&&!_status.event.showConfig) return;
if(!ui.cheat&&get.config('change_choice')) ui.create.cheat();
else if(ui.cheat&&!get.config('change_choice')){
ui.cheat.close();
delete ui.cheat;
}
},
player_number:function(num){
game.saveConfig('player_number',num,true);
2015-04-29 08:41:00 +00:00
game.reload();
2015-04-29 03:25:17 +00:00
},
2015-10-29 17:36:14 +00:00
auto_identity:function(item){
2015-04-29 03:25:17 +00:00
game.saveConfig('auto_identity',bool,true);
var num;
2015-10-29 17:36:14 +00:00
switch(item){
case 'one':num=1;break;
case 'two':num=2;break;
case 'three':num=3;break;
case 'always':num=-1;break;
2015-04-29 03:25:17 +00:00
default:num=0;break;
}
if(num&!_status.identityShown&&game.phaseNumber>game.players.length*num&&game.showIdentity){
_status.identityShown=true;
2015-11-01 07:54:42 +00:00
game.showIdentity(false);
2015-04-29 03:25:17 +00:00
}
},
swap:function(bool){
game.saveConfig('swap',bool,true);
if(get.config('swap')){
if(!ui.swap&&game.me.isDead()){
ui.swap=ui.create.control('换人',ui.click.dieswap);
}
}
else if(ui.swap){
ui.swap.close();
delete ui.swap;
}
},
revive:function(bool){
game.saveConfig('revive',bool,true);
if(get.config('revive')){
if(!ui.revive&&game.me.isDead()){
ui.revive=ui.create.control('revive',ui.click.dierevive);
}
}
else if(ui.revive){
ui.revive.close();
delete ui.revive;
}
},
hover_all:function(bool){
game.saveConfig('hover_all',bool);
if(!lib.config.hover_all) ui.hoverhandcardconfig.classList.add('disabled');
else ui.hoverhandcardconfig.classList.remove('disabled');
ui.sidebarrestart.classList.add('thundertext');
},
theme:function(theme){
game.saveConfig('theme',theme);
ui.arena.hide();
setTimeout(function(){
var theme=ui.css.theme;
ui.css.theme=lib.init.css('theme/'+lib.config.theme,'style');
theme.remove();
setTimeout(function(){ui.arena.show();},100);
},500);
},
layout:function(layout){
game.saveConfig('layout',layout);
2015-05-08 08:07:38 +00:00
if(lib.config.mode!='chess'){
ui.arena.hide();
setTimeout(function(){
var layout=ui.css.layout;
ui.css.layout=lib.init.css('layout/'+lib.config.layout,'layout',layout);
2015-04-29 03:25:17 +00:00
2015-05-08 08:07:38 +00:00
setTimeout(function(){layout.remove();ui.arena.show();},100);
},500);
}
2015-04-29 03:25:17 +00:00
},
2015-04-29 07:54:48 +00:00
image_background:function(background){
var animate=lib.config.image_background=='default';
game.saveConfig('image_background',background);
2015-04-29 03:25:17 +00:00
ui.background.delete();
ui.background=ui.create.div('.background');
2015-04-29 07:54:48 +00:00
switch (lib.config.image_background_filter){
2015-11-05 02:34:35 +00:00
case 'blur':
ui.background.style.filter='blur(8px)';
ui.background.style.webkitFilter='blur(8px)';
ui.background.style.transform='scale(1.05)';break;
case 'gray':
ui.background.style.filter='grayscale(1)';
ui.background.style.webkitFilter='grayscale(1)';
break;
case 'sepia':
ui.background.style.filter='sepia(0.5)';
ui.background.style.webkitFilter='sepia(0.5)';
break;
case 'invert':
ui.background.style.filter='invert(1)';
ui.background.style.webkitFilter='invert(1)';
break;
case 'saturate':
ui.background.style.filter='saturate(5)';
ui.background.style.webkitFilter='saturate(5)';
break;
case 'contrast':
ui.background.style.filter='contrast(1.4)';
ui.background.style.webkitFilter='contrast(1.4)';
break;
case 'hue':
ui.background.style.filter='hue-rotate(180deg)';
ui.background.style.webkitFilter='hue-rotate(180deg)';
break;
case 'brightness':
ui.background.style.filter='brightness(5)';
ui.background.style.webkitFilter='brightness(5)';
break;
default:
ui.background.style.filter='';
ui.background.style.webkitFilter='';
ui.background.style.transform='';
2015-04-29 03:25:17 +00:00
}
2015-04-29 07:54:48 +00:00
2015-04-29 03:25:17 +00:00
document.body.insertBefore(ui.background,document.body.firstChild);
if(animate) ui.background.animate('start');
2015-04-29 07:54:48 +00:00
if(lib.config.image_background=='default'){
2015-04-29 03:25:17 +00:00
ui.background.style.backgroundImage="none";
}
else{
2015-04-29 07:54:48 +00:00
ui.background.style.backgroundImage="url('image/background/"+lib.config.image_background+".jpg')";
2015-04-29 03:25:17 +00:00
}
2015-04-29 07:54:48 +00:00
ui.background.style.backgroundSize='cover';
2015-04-29 03:25:17 +00:00
},
2015-04-29 07:54:48 +00:00
image_background_filter:function(filter){
game.saveConfig('image_background_filter',filter);
ui.click.sidebar.image_background(lib.config.image_background);
2015-04-29 03:25:17 +00:00
},
ui_zoom:function(zoom){
game.saveConfig('ui_zoom',zoom);
switch(zoom){
case '极小':ui.window.style.zoom=0.8;break;
case '很小':ui.window.style.zoom=0.9;break;
case '较小':ui.window.style.zoom=0.95;break;
case '较大':ui.window.style.zoom=1.05;break;
case '很大':ui.window.style.zoom=1.1;break;
default:ui.window.style.zoom=1;
}
},
show_name:function(bool){
game.saveConfig('show_name',bool);
var players=get.players(false,true);
if(lib.config.show_name){
for(var i=0;i<players.length;i++){
game.players[i].node.name.style.display='';
}
}
else{
for(var i=0;i<players.length;i++){
game.players[i].node.name.style.display='none';
}
}
},
show_replay:function(bool){
game.saveConfig('show_replay',bool);
if(lib.config.show_replay){
ui.replay.style.display='';
}
else{
ui.replay.style.display='none';
}
},
2015-08-15 09:10:06 +00:00
bottom_line:function(bool){
game.saveConfig('bottom_line',bool);
if(lib.config.bottom_line){
ui.canvas.style.zIndex=0;
}
else{
ui.canvas.style.zIndex='';
}
},
2015-04-29 03:25:17 +00:00
show_playerids:function(bool){
game.saveConfig('show_playerids',bool);
if(lib.config.show_playerids){
ui.playerids.style.display='';
}
else{
ui.playerids.style.display='none';
}
},
show_auto:function(bool){
game.saveConfig('show_auto',bool);
if(lib.config.show_auto){
ui.auto.style.display='';
}
else{
ui.auto.style.display='none';
}
},
2015-04-30 03:09:07 +00:00
show_volumn:function(bool){
game.saveConfig('show_volumn',bool);
if(lib.config.show_volumn){
ui.volumn.style.display='';
}
else{
ui.volumn.style.display='none';
}
},
2015-04-29 03:25:17 +00:00
show_wuxie:function(bool){
game.saveConfig('show_wuxie',bool);
if(lib.config.show_wuxie){
ui.wuxie.style.display='';
}
else{
ui.wuxie.style.display='none';
}
},
show_pause:function(bool){
game.saveConfig('show_pause',bool);
if(lib.config.show_pause){
ui.pause.style.display='';
ui.auto.style.marginLeft='10px';
}
else{
ui.pause.style.display='none';
ui.auto.style.marginLeft='';
}
},
show_scrollbar:function(bool){
game.saveConfig('show_scrollbar',bool);
if(lib.config.touchscreen) return;
if(bool){
ui.css.scrollbar=lib.init.css('layout/default','scrollbar');
}
else{
ui.css.scrollbar.remove();
}
},
mousewheel:function(bool){
game.saveConfig('mousewheel',bool);
if(lib.config.touchscreen) return;
if(lib.config.mousewheel){
game.me.node.handcards1.onmousewheel=ui.click.mousewheel;
game.me.node.handcards2.onmousewheel=ui.click.mousewheel;
}
else{
game.me.node.handcards1.onmousewheel=null;
game.me.node.handcards2.onmousewheel=null;
}
},
2015-04-29 07:54:48 +00:00
touchscreen:function (bool){
2015-04-29 03:25:17 +00:00
game.saveConfig('touchscreen',bool);
if(bool){
game.saveConfig('confirmtouch',false);
ui.handcardmousewheel.classList.add('disabled');
}
else{
ui.handcardmousewheel.classList.remove('disabled');
}
ui.sidebarrestart.classList.add('thundertext');
},
fold_card:function(bool){
game.saveConfig('fold_card',bool);
if(bool){
ui.css.fold=lib.init.css('layout/default','fold');
}
else if(ui.css.fold){
ui.css.fold.remove();
}
},
threed_card:function(bool){
game.saveConfig('threed_card',bool);
if(bool){
ui.css.threed=lib.init.css('layout/default','fold2');
}
else if(ui.css.threed){
ui.css.threed.remove();
}
},
blur_ui:function(bool){
game.saveConfig('blur_ui',bool);
if(bool){
ui.css.blur_ui=lib.init.css('layout/default','blur');
}
else if(ui.css.blur_ui){
ui.css.blur_ui.remove();
}
},
right_sidebar:function(bool){
game.saveConfig('right_sidebar',bool);
if(bool){
ui.config.classList.add('right');
ui.sidebar.classList.add('right');
ui.sidebar3.classList.add('left');
2015-04-29 03:25:17 +00:00
ui.arena.classList.add('left');
ui.arena.classList.remove('right');
ui.system.appendChild(ui.system1);
}
else{
ui.config.classList.remove('right');
ui.sidebar.classList.remove('right');
ui.sidebar3.classList.remove('left');
2015-04-29 03:25:17 +00:00
ui.arena.classList.add('right');
ui.arena.classList.remove('left');
ui.system.appendChild(ui.system2);
}
},
title:function(bool){
game.saveConfig('title',bool);
if(!lib.config.title) document.title='无名杀';
},
characters:function(bool,node){
2015-04-29 08:41:00 +00:00
var name=node.link.slice(0,node.link.length-10);
if(bool){
lib.config.characters.add(name);
}
else{
lib.config.characters.remove(name);
}
game.saveConfig('characters',lib.config.characters);
2015-04-29 03:25:17 +00:00
ui.sidebarrestart.classList.add('thundertext');
},
cards:function(bool,node){
2015-04-29 08:41:00 +00:00
var name=node.link.slice(0,node.link.length-5);
if(bool){
lib.config.cards.add(name);
}
else{
lib.config.cards.remove(name);
}
game.saveConfig('cards',lib.config.cards);
2015-04-29 03:25:17 +00:00
ui.sidebarrestart.classList.add('thundertext');
},
plays:function(bool,node){
2015-04-29 08:41:00 +00:00
var name=node.link.slice(0,node.link.length-5);
if(bool){
lib.config.plays.add(name);
}
else{
lib.config.plays.remove(name);
}
game.saveConfig('plays',lib.config.plays);
2015-04-29 03:25:17 +00:00
ui.sidebarrestart.classList.add('thundertext');
},
forbid:function(bool,node){
var list=lib.config.forbidlist;
list[node.link]=bool;
game.saveConfig('forbidlist',list);
ui.sidebarrestart.classList.add('thundertext');
},
autoskill:function(bool,node){
var list=lib.config.autoskilllist;
if(bool){
list.remove(node.link);
}
else{
list.add(node.link);
}
game.saveConfig('autoskilllist',list);
},
sort:function(func){
game.saveConfig('sort',func);
lib.config.sort_card=get.sortCard(lib.config.sort);
var i,cards=game.me.get('h');
for(i=0;i<cards.length;i++) cards[i].remove();
cards.sort(function(a,b){
if(get.config('reverse_sort')) return lib.config.sort_card(a)-lib.config.sort_card(b);
return lib.config.sort_card(b)-lib.config.sort_card(a);
});
2015-10-31 10:14:14 +00:00
if(!lib.isSingleHandcard()){
2015-05-08 08:07:38 +00:00
for(i=0;i<cards.length;i++){
if(lib.config.sort_card(cards[i])>0){
game.me.node.handcards1.appendChild(cards[i]);
}
else{
game.me.node.handcards2.appendChild(cards[i]);
}
2015-04-29 03:25:17 +00:00
}
}
},
reverse_sort:function(bool){
game.saveConfig('reverse_sort',bool,true);
var cards1=[];
var cards2=[];
var i;
for(i=0;i<game.me.node.handcards1.childNodes.length;i++){
cards1.unshift(game.me.node.handcards1.childNodes[i]);
}
for(i=0;i<game.me.node.handcards2.childNodes.length;i++){
cards2.unshift(game.me.node.handcards2.childNodes[i]);
}
2015-10-31 10:14:14 +00:00
if(!lib.isSingleHandcard()){
2015-05-08 08:07:38 +00:00
var cards=game.me.num('h');
for(var i=0;i<cards.length;i++) cards[i].remove();
for(i=0;i<cards1.length;i++){
game.me.node.handcards2.appendChild(cards1[i]);
}
for(i=0;i<cards2.length;i++){
game.me.node.handcards1.appendChild(cards2[i]);
}
2015-04-29 03:25:17 +00:00
}
}
},
rightplayer:function(e){
2015-10-20 17:44:00 +00:00
if(this._nopup) return false;
2015-04-29 03:25:17 +00:00
if(_status.clickedplayer){
return false;
}
ui.click.intro.call(this,e);
_status.clickedplayer=true;
_status.clicked=false;
ui.click.longpresscancel.call(this);
return false;
},
right:function(){
if(_status.noright){
_status.noright=false;
return false;
}
if(_status.clickedplayer){
_status.clickedplayer=false;
return;
}
2015-11-05 02:34:35 +00:00
if(ui.currentpopped){
if(ui.currentpopped._uiintro){
ui.currentpopped._uiintro.delete();
delete ui.currentpopped._uiintro;
}
delete ui.currentpopped;
}
2015-04-29 03:25:17 +00:00
switch(lib.config.right_click){
case 'pause':ui.click.pause();break;
case 'auto':ui.click.auto();break;
case 'config':ui.click.config();break;
}
return false;
}
},
selected:{
buttons:[],cards:[],targets:[]
},
clear:function(){
2015-11-04 01:59:00 +00:00
game.addVideo('uiClear');
2015-04-29 03:25:17 +00:00
var thrown=document.getElementsByClassName('thrown');
var nodes=[];
var i;
for(i=0;i<thrown.length;i++){
nodes.push(thrown[i]);
}
for(i=0;i<nodes.length;i++){
if(!nodes[i].fixed) nodes[i].delete();
}
},
2015-05-07 04:48:00 +00:00
updatex:function(){
ui.update.apply(this,arguments);
ui.updateh(true);
},
updateh:function(compute){
2015-05-08 08:07:38 +00:00
if(!game.me) return;
2015-05-07 04:48:00 +00:00
if(compute){
game.me.node.handcards1._handcardsWidth=game.me.node.handcards1.offsetWidth;
game.me.node.handcards2._handcardsWidth=game.me.node.handcards2.offsetWidth;
}
ui.updatehx(game.me.node.handcards1);
ui.updatehx(game.me.node.handcards2);
},
updatehxx:function(node){
node.dataset.fold=Math.min(6,node.childElementCount-
node.getElementsByClassName('removing').length)-3;
},
updatehx:function(node){
var num=node.childElementCount-node.getElementsByClassName('removing').length;
var width=node._handcardsWidth;
if(num*78+40>=width){
node.dataset.fold=3;
}
else if(num*93+25>=width){
node.dataset.fold=2;
}
else if(num*112+6>=width){
node.dataset.fold=1;
}
else{
node.dataset.fold=0;
}
},
2015-04-29 03:25:17 +00:00
update:function(){
for(var i=0;i<ui.updates.length;i++){
ui.updates[i]();
}
if(ui.dialog){
2015-05-08 08:07:38 +00:00
if(lib.config.mode=='chess'){
2015-05-09 02:56:55 +00:00
if(ui.dialog.content.offsetHeight<240&&(!ui.dialog.buttons||!ui.dialog.buttons.length)){
2015-05-08 08:07:38 +00:00
ui.dialog.style.height=ui.dialog.content.offsetHeight+'px';
2015-05-09 02:56:55 +00:00
ui.dialog.classList.add('slim');
2015-05-08 08:07:38 +00:00
}
else{
ui.dialog.style.height='';
2015-05-09 02:56:55 +00:00
ui.dialog.classList.remove('slim');
2015-05-08 08:07:38 +00:00
}
}
2015-10-31 10:14:14 +00:00
if(false&&lib.config.layout=='mobile'){
ui.dialog.style.height='';
if(ui.dialog.contentContainer.offsetHeight>=ui.dialog.content.offsetHeight){
ui.dialog.style.height=ui.dialog.content.offsetHeight+'px';
}
else{
ui.dialog.style.height='';
}
if(ui.dialog.content.offsetHeight<240){
ui.dialog.classList.add('slim');
ui.dialog.classList.remove('scroll1');
ui.dialog.classList.remove('scroll2');
}
else{
ui.dialog.classList.remove('slim');
ui.dialog.classList.add('scroll1');
ui.dialog.classList.add('scroll2');
}
2015-04-29 03:25:17 +00:00
}
else{
2015-10-31 10:14:14 +00:00
if(ui.dialog.content.offsetHeight<=240||
ui.dialog.contentContainer.offsetHeight>=ui.dialog.content.offsetHeight){
ui.dialog.classList.remove('scroll1');
ui.dialog.classList.remove('scroll2');
}
else{
ui.dialog.classList.add('scroll1');
ui.dialog.classList.add('scroll2');
}
2015-04-29 03:25:17 +00:00
}
2015-11-01 09:56:48 +00:00
}
// ui.updatePhone();
},
updatePhone:function(){
if(lib.config.layout=='phone'&&lib.config.touchscreen){
if(document.body.offsetWidth<document.body.offsetHeight){
var windowWidth=document.body.offsetHeight;
var windowHeight=document.body.offsetWidth;
ui.window.style.height=windowHeight+'px';
ui.window.style.width=windowWidth+'px';
ui.window.style.transform='rotate(90deg)';
ui.window.style.transformOrigin='top left';
ui.window.style.left=windowHeight+'px';
}
else{
ui.window.removeAttribute('style');
}
2015-04-29 03:25:17 +00:00
}
},
recycle:function(node,key){
if(!ui._recycle) ui._recycle={};
if(typeof node=='string'){
return ui._recycle[node]
}
ui._recycle[key]=node;
},
};
var get={
config:function(item){
if(!lib.config.mode_config[lib.config.mode]) return;
return lib.config.mode_config[lib.config.mode][item];
},
2015-11-04 01:59:00 +00:00
cardInfo:function(card){
return [card.suit,card.number,card.name,card.nature];
},
cardsInfo:function(cards){
var info=[];
for(var i=0;i<cards.length;i++){
info.push(get.cardInfo(cards[i]));
}
return info;
},
infoCard:function(info){
return ui.create.card().init(info);
},
infoCards:function(info){
var cards=[];
for(var i=0;i<info.length;i++){
cards.push(get.infoCard(info[i]));
}
return cards;
},
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;
}
},
2015-10-29 17:36:14 +00:00
evtDistance:function(e1,e2){
return Math.sqrt((e1.x-e2.x)*(e1.x-e2.x)+(e1.y-e2.y)*(e1.y-e2.y));
},
2015-04-29 03:25:17 +00:00
skillLocked:function(skill){
var info=lib.skill[skill];
if(info.locked==false) return false;
if(info.trigger&&info.forced) return true;
if(info.mod) return true;
if(info.locked) return true;
return false;
},
itemtype:function(obj){
var i,j;
if(typeof obj=='string'){
if(obj.length<=3){
for(i=0;i<obj.length;i++){
if(/h|e|j/.test(obj[i])==false) return;
}
return 'position';
}
if(lib.nature.contains(obj)) return 'nature';
}
if(get.objtype(obj)=='array'&&obj.length){
var isPlayers=true;
for(i=0;i<obj.length;i++){
if(get.itemtype(obj[i])!='player') {isPlayers=false;break;}
}
if(isPlayers) return 'players';
var isCards=true;
for(i=0;i<obj.length;i++){
if(get.itemtype(obj[i])!='card') {isCards=false;break;}
}
if(isCards) return 'cards';
if(obj.length==2){
if(typeof obj[0]=='number'&&typeof obj[1]=='number'){
if(obj[0]<=obj[1]) return 'select';
}
}
if(obj.length==4){
var isPosition=true;
for(i=0;i<obj.length;i++){
if(typeof obj[i]!='number') {isPosition=false;break;}
}
if(isPosition) return 'divposition';
}
}
if(get.objtype(obj)=='div'){
if(obj.classList.contains('button')) return 'button';
if(obj.classList.contains('card')) return 'card';
if(obj.classList.contains('player')) return 'player';
if(obj.classList.contains('dialog')) return 'dialog';
}
},
equipNum:function(card){
if(get.type(card)=='equip'){
return parseInt(get.subtype(card)[5]);
}
return 0;
},
objtype:function(obj){
if(Object.prototype.toString.call(obj) === '[object Array]') return 'array';
if(Object.prototype.toString.call(obj) === '[object HTMLDivElement]') return 'div';
if(Object.prototype.toString.call(obj) === '[object HTMLTableElement]') return 'table';
if(Object.prototype.toString.call(obj) === '[object HTMLTableRowElement]') return 'tr';
if(Object.prototype.toString.call(obj) === '[object HTMLTableCellElement]') return 'td';
if(Object.prototype.toString.call(obj) === '[object HTMLBodyElement]') return 'td';
},
type:function(obj,method){
2015-10-30 15:32:48 +00:00
if(typeof obj=='string') obj={name:obj};
2015-04-29 03:25:17 +00:00
if(typeof obj!='object') return;
if(!lib.card[obj.name]) return;
if(method=='trick'&&lib.card[obj.name].type=='delay') return 'trick';
return lib.card[obj.name].type;
},
subtype:function(obj){
if(!lib.card[obj.name]) return;
return lib.card[obj.name].subtype;
},
suit:function(card){
if(get.itemtype(card)=='cards'){
var suit=get.suit(card[0])
for(var i=1;i<card.length;i++){
if(get.suit(card[i])!=suit) return 'none';
}
return suit;
}
else{
if(get.owner(card)){
return game.checkMod(card,card.suit,'suit',get.owner(card).get('s'));
}
return card.suit;
}
},
color:function(card){
if(get.itemtype(card)=='cards'){
var color=get.color(card[0])
for(var i=1;i<card.length;i++){
if(get.color(card[i])!=color) return 'none';
}
return color;
}
else{
if(get.suit(card)=='spade'||get.suit(card)=='club') return 'black';
if(get.suit(card)=='heart'||get.suit(card)=='diamond') return 'red';
return 'none';
}
},
number:function(card){
return card.number;
},
nature:function(card){
return card.nature;
},
cards:function(num){
var list=[];
var card=false;
2015-05-04 03:17:03 +00:00
if(typeof num!='number') num=1;
2015-04-29 03:25:17 +00:00
if(num==0) {card=true;num=1;}
while(num--){
if(ui.cardPile.hasChildNodes()==false){
if(_status.maxShuffle!=undefined){
if(_status.maxShuffle==0){
game.over('平局');
return;
}
_status.maxShuffle--;
}
var cards=[],i;
for(i=0;i<ui.discardPile.childNodes.length;i++){
cards.push(ui.discardPile.childNodes[i]);
}
2015-05-03 15:17:15 +00:00
cards.randomSort();
2015-04-29 03:25:17 +00:00
for(var i=0;i<cards.length;i++){
ui.cardPile.appendChild(cards[i]);
}
}
if(ui.cardPile.hasChildNodes()==false){
game.over('平局');
return;
}
list.push(ui.cardPile.removeChild(ui.cardPile.firstChild));
}
if(card) return list[0];
return list;
},
judge:function(card){
if(card.viewAs) return lib.card[card.viewAs].judge;
return get.info(card).judge;
},
distance:function(from,to,method){
if(from==to) return 0;
2015-05-04 03:17:03 +00:00
if(!game.players.contains(from)&&!game.dead.contains(from)) return Infinity;
if(!game.players.contains(to)&&!game.dead.contains(to)) return Infinity;
2015-04-29 03:25:17 +00:00
var player=from,m,n=1,i;
2015-05-08 08:07:38 +00:00
var fxy,txy;
if(lib.config.mode=='chess'){
fxy=from.getXY();
txy=to.getXY();
n=Math.abs(fxy[0]-txy[0])+Math.abs(fxy[1]-txy[1]);
if(method=='raw'||method=='pure'||method=='absolute') return n;
}
2015-05-12 09:51:40 +00:00
else if(to.isMin(true)||from.isMin(true)){
2015-05-08 08:07:38 +00:00
if(method=='raw'||method=='pure'||method=='absolute') return 1;
2015-04-29 03:25:17 +00:00
}
2015-05-03 15:17:15 +00:00
else{
var length=game.players.length;
2015-05-04 03:17:03 +00:00
var totalPopulation=game.players.length+game.dead.length+1;
2015-05-05 14:57:35 +00:00
for(var iwhile=0;iwhile<totalPopulation;iwhile++){
2015-05-04 03:17:03 +00:00
if(player.nextSeat!=to){
player=player.nextSeat;
2015-05-12 09:51:40 +00:00
if(player.isAlive()&&!player.isOut()&&!player.isMin(true)) n++;
2015-05-04 03:17:03 +00:00
}
else{
break;
}
2015-05-03 15:17:15 +00:00
}
for(i=0;i<game.players.length;i++){
2015-05-12 09:51:40 +00:00
if(game.players[i].isOut()||game.players[i].isMin(true)) length--;
2015-05-03 15:17:15 +00:00
}
if(method=='absolute') return n;
if(from.isDead()) length++;
if(to.isDead()) length++;
n=Math.min(n,length-n);
2015-05-08 08:07:38 +00:00
if(method=='raw'||method=='pure') return n;
2015-04-29 03:25:17 +00:00
}
n=game.checkMod(from,to,n,'globalFrom',from.get('s'));
n=game.checkMod(from,to,n,'globalTo',to.get('s'));
m=n;
m=game.checkMod(from,to,m,'attackFrom',from.get('s'));
m=game.checkMod(from,to,m,'attackTo',to.get('s'));
var equips1=from.get('e'),equips2=to.get('e');
for(i=0;i<equips1.length;i++){
var info=get.info(equips1[i]).distance;
if(!info) continue;
if(info.globalFrom){
m+=info.globalFrom;
n+=info.globalFrom;
}
if(info.attackFrom){
m+=info.attackFrom;
}
}
for(i=0;i<equips2.length;i++){
var info=get.info(equips2[i]).distance;
if(!info) continue;
if(info.globalTo){
m+=info.globalTo;
n+=info.globalTo;
}
if(info.attaclTo){
m+=info.attaclTo;
}
}
if(method=='attack') return m;
return n;
},
attackRange:function(player){
var range=0;
range=game.checkMod(player,player,range,'globalFrom',player.get('s'));
range=game.checkMod(player,player,range,'attackFrom',player.get('s'));
var equips=player.get('e');
for(var i=0;i<equips.length;i++){
var info=get.info(equips[i]).distance;
if(!info) continue;
if(info.globalFrom){
range+=info.globalFrom;
}
if(info.attackFrom){
range+=info.attackFrom;
}
}
return (1-range);
},
globalFrom:function(player){
var range=0;
range=game.checkMod(player,player,range,'globalFrom',player.get('s'));
var equips=player.get('e');
for(var i=0;i<equips.length;i++){
var info=get.info(equips[i]).distance;
if(!info) continue;
if(info.globalFrom){
range+=info.globalFrom;
}
}
return (-range);
},
globalTo:function(player){
var range=0;
range=game.checkMod(player,player,range,'globalTo',player.get('s'));
var equips=player.get('e');
for(var i=0;i<equips.length;i++){
var info=get.info(equips[i]).distance;
if(!info) continue;
if(info.globalTo){
range+=info.globalTo;
}
}
return (range);
},
info:function(item){
if(typeof item=='string'){
return lib.skill[item];
}
if(typeof item=='object'){
return lib.card[item.name];
}
},
select:function(select){
if(typeof select=='number') return [select,select];
if(get.itemtype(select)=='select') return select;
if(typeof select=='function') return get.select(select());
return [1,1]
},
card:function(){
if(_status.event.skill){
var card=get.info(_status.event.skill).viewAs;
if(card) return card;
}
return ui.selected.cards[0];
},
player:function(){
return _status.event.player;
},
players:function(sort,dead){
var players=game.players.slice(0);
if(sort!=false){
if(typeof sort=='function'){
players.sort(sort);
}
else{
if(get.itemtype(sort)!='player') lib.tempSortSeat=_status.event.player;
else lib.tempSortSeat=sort;
players.sort(lib.sort.seat);
delete lib.tempSortSeat;
lib.temp={};
}
}
if(dead) players=players.concat(game.dead);
return players;
},
position:function(card){
if(get.itemtype(card)=='player') return parseInt(card.dataset.position);
if(card.timeout&&card.destiny){
if(card.destiny.classList.contains('equips')) return 'e';
if(card.destiny.classList.contains('judges')) return 'j';
if(card.destiny.id=='handcards1'||
card.destiny.id=='handcards2') return 'h';
if(card.destiny.id=='discardPile') return 'd';
if(card.destiny.id=='special') return 's';
return;
}
if(!card.parentNode) return;
if(card.parentNode.classList.contains('equips')) return 'e';
if(card.parentNode.classList.contains('judges')) return 'j';
if(card.parentNode.id=='handcards1'||
card.parentNode.id=='handcards2') return 'h';
if(card.parentNode.id=='discardPile') return 'd';
if(card.parentNode.id=='special') return 's';
},
translation:function(str,arg){
2015-05-04 14:27:10 +00:00
if(str&&typeof str=='object'&&str.name){
2015-04-29 03:25:17 +00:00
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;
}
}
if(get.itemtype(str)=='card'&&str.suit&&str.number){
str2+='【'+get.translation(get.suit(str))+get.number(str)+'】'
}
return str2;
}
if(get.itemtype(str)=='cards'||get.itemtype(str)=='players'){
var str2=get.translation(str[0],arg);
for(var i=1;i<str.length;i++){
str2+='、'+get.translation(str[i],arg);
}
return str2;
}
return lib.translate[str]||str;
},
cnNumber:function(num,two){
if(num==Infinity) return '∞';
if(typeof num!='number') return num;
if(num<0||num>99) return num;
if(num<=10){
switch(num){
2015-05-11 11:57:44 +00:00
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 '十';
2015-04-29 03:25:17 +00:00
}
}
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<buttons.length;i++){
if(buttons[i].classList.contains('selectable')&&
buttons[i].classList.contains('selected')==false){
selectable.push(buttons[i]);
}
}
if(sort){
selectable.sort(sort);
}
return selectable;
},
selectableCards:function(sort){
if(!_status.event.player) return[];
var cards=_status.event.player.get('hej');
var selectable=[];
for(var i=0;i<cards.length;i++){
if(cards[i].classList.contains('selectable')&&
cards[i].classList.contains('selected')==false){
selectable.push(cards[i]);
}
}
if(sort){
selectable.sort(sort);
}
return selectable;
},
skills:function(){
if(!ui.skills) return [];
return ui.skills.skills.slice(0);
},
selectableTargets:function(sort){
var selectable=[];
for(var i=0;i<game.players.length;i++){
if(game.players[i].classList.contains('selectable')&&
game.players[i].classList.contains('selected')==false){
selectable.push(game.players[i]);
}
}
2015-05-03 15:17:15 +00:00
selectable.randomSort();
2015-04-29 03:25:17 +00:00
if(sort){
selectable.sort(sort);
}
return selectable;
},
filter:function(filter,i){
if(typeof filter=='function') return filter;
if(i==undefined) i=0;
return function(){
if(filter==arguments[i]) return true;
for(var j in filter){
if(filter.hasOwnProperty(j)){
if(get.itemtype(arguments[i])=='card'){
if(j=='type'){
if(typeof filter[j]=='object'){
if(filter[j].contains(get.type(arguments[i]))==false) return false;
}
else if(typeof filter[j]=='string'){
if(get.type(arguments[i])!=filter[j]) return false;
}
}
else if(j=='subtype'){
if(typeof filter[j]=='object'){
if(filter[j].contains(get.subtype(arguments[i]))==false) return false;
}
else if(typeof filter[j]=='string'){
if(get.subtype(arguments[i])!=filter[j]) return false;
}
}
else if(j=='color'){
if(typeof filter[j]=='object'){
if(filter[j].contains(get.color(arguments[i]))==false) return false;
}
else if(typeof filter[j]=='string'){
if(get.color(arguments[i])!=filter[j]) return false;
}
}
else if(j=='suit'){
if(typeof filter[j]=='object'){
if(filter[j].contains(get.suit(arguments[i]))==false) return false;
}
else if(typeof filter[j]=='string'){
if(get.suit(arguments[i])!=filter[j]) return false;
}
}
else if(j=='number'){
if(typeof filter[j]=='object'){
if(filter[j].contains(get.number(arguments[i]))==false) return false;
}
else if(typeof filter[j]=='string'){
if(get.number(arguments[i])!=filter[j]) return false;
}
}
else if(typeof filter[j]=='object'){
if(filter[j].contains(arguments[i][j])==false) return false;
}
else if(typeof filter[j]=='string'){
if(arguments[i][j]!=filter[j]) return false;
}
}
else{
if(arguments[i][j]!=filter[j]) return false;
}
}
}
return true;
}
},
cardCount:function(card,player){
var num;
if(card==true){
num=0;
var stat=player.getStat('card');
for(var i in stat){
if(typeof stat[i]=='number') num+=stat[i];
}
return num;
}
if(player==undefined) player=_status.event.player;
if(typeof card=='object'){
card=card.name;
}
num=player.getStat('card')[card];
if(num==undefined) return 0;
return num;
},
skillCount:function(skill,player){
if(player==undefined) player=_status.event.player;
var num=player.getStat('skill')[skill];
if(num==undefined) return 0;
return num;
},
owner:function(card){
for(var i=0;i<game.players.length;i++){
if(game.players[i].get('hej').contains(card)||game.players[i].judging==card)
return game.players[i];
}
},
noSelected:function(){
return (ui.selected.buttons.length+ui.selected.cards.length+ui.selected.targets.length==0)
},
population:function(identity){
if(identity==undefined) return game.players.length+game.dead.length;
var i;
var num=0;
for(i=0;i<game.players.length;i++){
if(game.players[i].identity==identity) num++;
}
return num;
},
totalPopulation:function(identity){
if(identity==undefined) return game.players.length+game.dead.length;
var i,players=game.players.concat(game.dead);
var num=0;
for(i=0;i<players.length;i++){
if(players[i].identity==identity) num++;
}
return num;
},
tag:function(item,tag,item2){
if(get.info(item)&&get.info(item).ai&&get.info(item).ai.tag){
var result=get.info(item).ai.tag[tag];
}
if(typeof result=='function') return result(item,item2);
return result;
},
sortCard:function(sort){
var func;
if(sort=='type_sort'){
func=function(card){
2015-05-03 15:17:15 +00:00
if(get.type(card)=='basic') return 2;
2015-06-16 13:24:35 +00:00
if(get.type(card)=='stonecard') return -0.5;
2015-05-03 15:17:15 +00:00
if(get.type(card)=='stonecharacter') return 1;
2015-05-10 05:34:37 +00:00
if(get.type(card)=='chess') return 1.5;
2015-04-29 03:25:17 +00:00
if(get.type(card)=='trick') return -1;
if(get.type(card)=='delay') return -2;
if(get.type(card)=='equip') return -3;
return -4;
}
}
else if(sort=='suit_sort'){
func=function(card){
if(get.suit(card)=='heart') return 2;
if(get.suit(card)=='diamond') return 1;
if(get.suit(card)=='spade') return -1;
if(get.suit(card)=='club') return -2;
}
}
else if(sort=='number_sort'){
func=function(card){
return get.number(card)-7+0.5;
}
}
return func;
},
difficulty:function(){
switch(get.config('difficulty')){
case 'easy':return 1;
case 'normal':return 2;
case 'hard':return 3;
default: return 1;
}
},
cardPile:function(name){
2015-08-15 09:10:06 +00:00
var card;
2015-04-29 03:25:17 +00:00
for(var i=0;i<ui.cardPile.childNodes.length;i++){
2015-08-15 09:10:06 +00:00
card=ui.cardPile.childNodes[i];
if(typeof name=='string'){
if(card.name==name){
return card;
}
}
else if(typeof name=='function'){
if(name(card)){
return card;
}
2015-04-29 03:25:17 +00:00
}
}
for(var i=0;i<ui.discardPile.childNodes.length;i++){
2015-08-15 09:10:06 +00:00
card=ui.discardPile.childNodes[i];
if(typeof name=='string'){
if(card.name==name){
return card;
}
}
else if(typeof name=='function'){
if(name(card)){
return card;
}
2015-04-29 03:25:17 +00:00
}
}
2015-08-15 09:10:06 +00:00
return null;
2015-04-29 03:25:17 +00:00
},
aiStrategy:function(){
switch(get.config('ai_strategy')){
case 'ai_strategy_1':return 1;
case 'ai_strategy_2':return 2;
case 'ai_strategy_3':return 3;
case 'ai_strategy_4':return 4;
case 'ai_strategy_5':return 5;
case 'ai_strategy_6':return 6;
default: return 1;
}
},
skillintro:function(name,learn,learn2){
var str='';
2015-10-31 10:14:14 +00:00
var infoitem=lib.character[name];
2015-10-30 15:32:48 +00:00
if(!infoitem){
for(var itemx in lib.characterPack){
2015-10-31 10:14:14 +00:00
if(lib.characterPack[itemx][name]){
infoitem=lib.characterPack[itemx][name];break;
2015-10-30 15:32:48 +00:00
}
}
}
var skills=infoitem[3];
2015-04-29 03:25:17 +00:00
var opacity;
for(var i=0;i<skills.length;i++){
if(lib.translate[skills[i]]&&lib.translate[skills[i]+'_info']&&lib.skill[skills[i]]){
if(learn&&lib.skill[skills[i]].unique&&(learn2||!lib.skill[skills[i]].gainable)){
opacity='opacity:0.5';
}
else{
opacity='';
}
str+='<div class="skill" style="'+opacity+
'">【'+get.translation(skills[i]).slice(0,2)+'】</div><div style="'+opacity+'">'+
lib.translate[skills[i]+'_info']+'</div><div style="display:block;height:10px"></div>';
}
}
return str;
},
intro:function(name){
var info=lib.character[name];
var str='性别:'+get.translation(info[0])+'<br/>';
str+='势力:'+get.translation(info[1])+'<br/>';
str+='体力:'+get.translation(info[2])+'<br/>';
str+='技能:';
if(info[3].length){
str+=get.translation(info[3][0]);
for(var i=1;i<info[3].length;i++){
str+='、'+get.translation(info[3][i]);
}
}
return str;
},
storageintro:function(type,content,player,dialog){
switch(type){
case 'mark':{
if(content>0){
return '共有'+content+'个标记';
}
2015-05-11 11:57:44 +00:00
return false;
2015-04-29 03:25:17 +00:00
}
case 'turn':{
if(content>0){
return '还剩'+content+'个回合';
}
2015-05-11 11:57:44 +00:00
return false;
2015-04-29 03:25:17 +00:00
}
case 'time':{
if(content>0){
return '还剩'+content+'次';
}
2015-05-11 11:57:44 +00:00
return false;
2015-04-29 03:25:17 +00:00
}
case 'limited':{
if(content){
return '已发动';
}
2015-05-11 11:57:44 +00:00
return '未发动';
2015-04-29 03:25:17 +00:00
}
case 'cardCount':{
if(typeof content=='object'&&typeof content.length=='number'){
return '共有'+get.cnNumber(content.length)+'张牌';
}
2015-05-11 11:57:44 +00:00
return false;
2015-04-29 03:25:17 +00:00
}
case 'card':case 'cards':{
if(get.itemtype(content)=='card'){
content=[content];
}
if(dialog&&get.itemtype(content)=='cards'){
if(content.length>6&&!dialog._hovercustomed){
dialog.addSmall(content);
}
else{
dialog.add(content);
}
}
else{
if(content&&content.length){
return get.translation(content);
}
}
2015-05-11 11:57:44 +00:00
return false;
2015-04-29 03:25:17 +00:00
}
case 'player':case 'players':{
if(get.itemtype(content)=='player'){
content=[content];
}
if(dialog&&get.itemtype(content)=='players'){
if(content.length>6&&!dialog._hovercustomed){
dialog.addSmall(content);
}
else{
dialog.add(content);
}
return false;
}
else{
if(content&&content.length){
return get.translation(content);
}
2015-05-11 11:57:44 +00:00
return false;
2015-04-29 03:25:17 +00:00
}
2015-07-09 05:21:22 +00:00
break;
2015-04-29 03:25:17 +00:00
}
default:{
if(typeof type=='string'){
return type.replace(/#/g,content);
}
else if(typeof type=='function'){
return type(content,player);
}
return false;
}
}
},
nodeintro:function(node,simple){
var uiintro=ui.create.dialog('hidden');
if(node.classList.contains('player')&&!node.name){
return uiintro;
}
var i,translation,intro,str;
if(node.classList.contains('player')){
var capt=get.translation(node.name);
2015-11-09 03:15:16 +00:00
if(lib.character[node.name]&&lib.character[node.name][1]){
2015-04-29 03:25:17 +00:00
capt+='&nbsp;&nbsp;'+lib.translate[lib.character[node.name][1]];
}
uiintro.add(capt);
var skills=node.skills;
var skills2=game.filterSkills(node.skills,node);
for(i=0;i<skills.length;i++){
2015-09-22 03:53:35 +00:00
if(lib.skill[skills[i]]&&lib.skill[skills[i]].nopop) continue;
2015-04-29 03:25:17 +00:00
if(lib.translate[skills[i]+'_info']){
translation=get.translation(skills[i]).slice(0,2);
if(!skills2.contains(skills[i])){
uiintro.add('<div style="opacity:0.5"><div class="skill">【'+translation+'】</div><div>'+lib.translate[skills[i]+'_info']+'</div></div>');
}
else{
uiintro.add('<div><div class="skill">【'+translation+'】</div><div>'+lib.translate[skills[i]+'_info']+'</div></div>');
}
}
}
var forbidden=node.forbiddenSkills;
for(i=0;i<forbidden.length;i++){
if(lib.translate[forbidden[i]+'_info']){
translation=get.translation(forbidden[i]).slice(0,2);
uiintro.add('<div><div class="skill">【'+translation+'】</div><div>'+'已禁用'+'</div></div>');
}
}
2015-06-16 13:24:35 +00:00
// if(!simple)
if(false){
2015-04-29 03:25:17 +00:00
var storage=node.storage;
for(i in storage){
if(get.info(i)&&get.info(i).intro){
intro=get.info(i).intro;
if(node.get('s').concat(lib.skill.global).contains(i)==false&&!intro.show) continue;
var name=intro.name?intro.name:get.translation(i);
if(typeof name=='function'){
name=name(storage[i],node);
}
translation='<div><div class="skill">『'+name[0]+name[1]+'』</div><div>';
var stint=get.storageintro(intro.content,storage[i],node);
if(stint){
translation+=stint+'</div></div>';
uiintro.add(translation);
}
}
}
uiintro.add(ui.create.div('.placeholder'));
var table,tr,td;
table=document.createElement('table');
tr=document.createElement('tr');
table.appendChild(tr);
td=document.createElement('td');
td.innerHTML='攻击范围';
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML='进攻距离';
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML='防御距离';
tr.appendChild(td);
tr=document.createElement('tr');
table.appendChild(tr);
td=document.createElement('td');
td.innerHTML=get.attackRange(node);
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML=get.globalFrom(node);
tr.appendChild(td);
td=document.createElement('td');
td.innerHTML=get.globalTo(node);
tr.appendChild(td);
uiintro.content.appendChild(table);
}
uiintro.add(ui.create.div('.placeholder.slim'));
}
else if(node.classList.contains('mark')&&node.info&&
node.parentNode&&node.parentNode.parentNode&&node.parentNode.parentNode.classList.contains('player')){
var info=node.info;
var player=node.parentNode.parentNode;
if(info.name){
if(typeof info.name=='function'){
var named=info.name(player.storage[node.skill],player);
if(named){
uiintro.add(named);
}
}
else{
uiintro.add(info.name);
}
}
else if(info.name!==false){
uiintro.add(get.translation(node.skill));
}
if(typeof info.mark=='function'){
var stint=info.mark(uiintro,player.storage[node.skill],player);
if(stint){
2015-09-22 03:53:35 +00:00
if(stint.length<=100){
2015-04-29 03:25:17 +00:00
uiintro.add('<div class="text center">'+stint+'</div>');
}
else{
uiintro.add('<div class="text">'+stint+'</div>');
}
}
}
else{
var stint=get.storageintro(info.content,player.storage[node.skill],player,uiintro);
if(stint){
2015-06-16 13:24:35 +00:00
if(stint[0]=='$'){
uiintro.add('<div class="caption">'+stint.slice(1)+'</div>');
}
2015-09-22 03:53:35 +00:00
else if(stint.length<=100){
2015-04-29 03:25:17 +00:00
uiintro.add('<div class="text center">'+stint+'</div>');
}
else{
uiintro.add('<div class="text">'+stint+'</div>');
}
}
}
uiintro.add(ui.create.div('.placeholder.slim'));
}
else if(node.classList.contains('card')){
var name=node.name;
if(get.position(node)=='j'&&node.viewAs&&node.viewAs!=name){
uiintro.add(get.translation(node.viewAs)+''+get.translation(node)+'');
name=node.viewAs;
}
else{
uiintro.add(get.translation(node));
}
if(node.name=='muniu'&&get.position(node)=='e'){
var num=0;
if(node.cards){
num=node.cards.length;
}
if(get.owner(node)==game.me&&num){
uiintro.add(node.cards,true,num>4);
}
else{
uiintro.add('<div class="text center">'+'共有'+get.cnNumber(num)+'张牌'+'</div>');
}
}
2015-09-03 03:49:14 +00:00
else if(node.name=='lianyaohu'&&get.position(node)=='e'){
var num=0;
if(node.storage.shouna){
num=node.storage.shouna.length;
}
if(num){
uiintro.add(node.storage.shouna,true,num>4);
}
else{
uiintro.add('<div class="text center">炼妖壶内没有牌</div>');
}
}
else if(lib.translate[name+'_info']){
2015-09-22 03:53:35 +00:00
if(lib.translate[name+'_info'].length<=100){
uiintro.add('<div class="text center">'+lib.translate[name+'_info']+'</div>');
}
else{
uiintro.add('<div class="text">'+lib.translate[name+'_info']+'</div>');
}
2015-04-29 03:25:17 +00:00
}
uiintro.add(ui.create.div('.placeholder.slim'));
}
else if(node.classList.contains('character')){
var character=node.link;
uiintro.add(get.translation(character));
2015-10-30 15:32:48 +00:00
var infoitem=lib.character[character];
if(!infoitem){
for(var itemx in lib.characterPack){
if(lib.characterPack[itemx][character]){
infoitem=lib.characterPack[itemx][character];break;
}
}
}
var skills=infoitem[3];
2015-04-29 03:25:17 +00:00
for(i=0;i<skills.length;i++){
if(lib.translate[skills[i]+'_info']){
translation=get.translation(skills[i])[0]+get.translation(skills[i])[1];
uiintro.add('<div><div class="skill">【'+translation+'】</div><div>'+lib.translate[skills[i]+'_info']+'</div></div>');
}
}
uiintro.add(ui.create.div('.placeholder.slim'));
}
return uiintro;
},
groups:function(){
return ['wei','shu','wu','qun'];
},
types:function(){
var types=[];
for(var i in lib.card){
if(lib.card[i].mode&&lib.card[i].mode.contains(lib.config.mode)==false) continue;
if(lib.card[i].forbid&&lib.card[i].forbid.contains(lib.config.mode)) continue;
if(lib.card[i].type){
if(lib.card[i].type=='delay') types.add('trick');
else types.add(lib.card[i].type);
}
}
return types;
},
links:function(buttons){
var links=[];
for(var i=0;i<buttons.length;i++){
if(buttons[i].link!=undefined) links.push(buttons[i].link);
}
return links;
}
};
var ai={
basic:{
chooseButton:function(check){
var event=_status.event;
var i,j,range,buttons,buttons2;
var ok=false,forced=event.forced;
2015-05-04 03:17:03 +00:00
var iwhile=100;
while(iwhile--){
2015-04-29 03:25:17 +00:00
range=get.select(event.selectButton);
if(range[1]==-1){
j=0;
for(i=0;i<ui.selected.buttons.length;i++){
j+=check(ui.selected.buttons[i]);
}
return (j>0);
}
lib.temp={};
buttons=get.selectableButtons();
buttons2=buttons.slice(0);
buttons.sort(function(a,b){
return check(b,buttons2)-check(a,buttons2);
});
if(buttons.length==0){
return ok;
}
if(check(buttons[0])<=0){
if(!forced||ok){
return ok;
}
}
buttons[0].classList.add('selected');
ui.selected.buttons.add(buttons[0]);
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;
2015-05-04 03:17:03 +00:00
var iwhile=100;
while(iwhile--){
2015-04-29 03:25:17 +00:00
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;i<ui.selected.cards.length;i++){
effect=check(ui.selected.cards[i]);
if(effect<0) j-=Math.sqrt(-effect);
else j+=Math.sqrt(effect);
}
return (j>0);
}
lib.temp={};
cards=get.selectableCards().concat(get.skills());
cards2=cards.slice(0);
cards.sort(function(a,b){
return (check(b,cards2)-check(a,cards2));
});
if(cards.length==0){
return ok;
}
if(check(cards[0])<=0){
if(!forced||ok){
return ok;
}
}
if(typeof cards[0]=='string'){
ui.click.skill(cards[0]);
var info=get.info(event.skill);
if(info.filterCard){
check=info.check||ai.get.unuseful2;
return (ai.basic.chooseCard(check));
}
else{
return true;
}
}
else{
cards[0].classList.add('selected');
ui.selected.cards.add(cards[0]);
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;
2015-05-04 03:17:03 +00:00
var iwhile=100;
while(iwhile--){
2015-04-29 03:25:17 +00:00
range=get.select(event.selectTarget);
if(range[1]==-1){
j=0;
for(i=0;i<ui.selected.targets.length;i++){
effect=check(ui.selected.targets[i]);
if(effect<0) j-=Math.sqrt(-effect);
else j+=Math.sqrt(effect);
}
return (j>0);
}
else if(range[1]==0){
return check()>0
}
lib.temp={};
targets=get.selectableTargets();
targets2=targets.slice(0);
targets.sort(function(a,b){
return check(b)-check(a);
});
if(targets.length==0){
return ok;
}
if(check(targets[0])<=0){
if(!forced||ok){
return ok;
}
}
targets[0].classList.add('selected');
ui.selected.targets.add(targets[0]);
game.check();
if(ui.selected.targets.length>=range[0]){
ok=true;
}
if(ui.selected.targets.length==range[1]){
return true;
}
}
}
},
get:{
useful:function(card){
if(get.position(card)=='j') return -1;
if(get.position(card)=='e') return ai.get.equipValue(card);
if(lib.temp[card.name]==undefined) lib.temp[card.name]=[card];
else lib.temp[card.name].add(card);
var i=lib.temp[card.name].find(card);
var aii=get.info(card).ai;
var useful;
if(aii&&aii.useful) useful=aii.useful;
else if(aii&&aii.basic) useful=aii.basic.useful;
if(useful==undefined) return -1;
if(typeof useful=='function'){
return useful(card,i);
}
if(typeof useful=='number') return useful;
if(i<useful.length){
return useful[i];
}
return useful[useful.length-1];
},
unuseful:function(card){
return -ai.get.useful(card);
},
unuseful2:function(card){
return 10-ai.get.useful(card);
},
value:function(card,player,method){
var aii=get.info(card).ai;
var value;
if(aii&&aii.value) value=aii.value;
else if(aii&&aii.basic) value=aii.basic.value;
if(value==undefined) return 0;
if(player==undefined||get.itemtype(player)!='player') player=_status.event.player;
if(typeof value=='function') return value(card,player);
if(typeof value=='number') return value;
if(get.objtype(value)=='array'){
if(method=='raw') return value[0];
var num=0,i;
var cards=player.get('h');
for(i=0;i<cards.length;i++){
if(cards[i].name==card.name&&
cards[i]!=card&&
cards[i].classList.contains('selected')==false) num++;
}
if(num<value.length) return value[num];
return value[value.length-1];
}
return 0;
},
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);
return 0;
},
disvalue:function(card,player){
return -ai.get.value(card,player);
},
2015-05-09 02:56:55 +00:00
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;
},
2015-04-29 03:25:17 +00:00
order:function(item){
var aii=get.info(item).ai;
var order;
if(aii&&aii.order) order=aii.order;
else if(aii&&aii.basic) order=aii.basic.order;
if(order==undefined) return -1;
if(typeof(order)=='function'){
return order(item,_status.event.player);
}
return order;
},
result:function(item){
var result;
if(get.info(item).ai) result=get.info(item).ai.result;
if(result==undefined) return {};
if(typeof(result)=='function') return result(item);
return result;
},
effect:function(target,card,player,player2){
var event=_status.event;
if(player==undefined) player=_status.event.player;
if(typeof card!='string'&&(typeof card!='object'||!card.name)){
if(event.skill&&get.info(event.skill).viewAs==undefined) card=_status.event.skill;
else card=get.card();
}
var result=ai.get.result(card);
var result1=result.player,result2=result.target;
if(typeof result1=='function') result1=result1(player,target,card);
if(typeof result2=='function') result2=result2(player,target,card);
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.get('s').concat(lib.skill.global);
game.expandSkills(skills1);
var zerotarget=false,zeroplayer=false;
for(var i=0;i<skills1.length;i++){
temp1=get.info(skills1[i]).ai;
if(temp1&&typeof temp1.effect=='object'&&typeof temp1.effect.player=='function'){
temp1=temp1.effect.player(card,player,target,result1);
}
else temp1=undefined;
if(typeof temp1=='object'){
if(temp1.length==2||temp1.length==4){
result1*=temp1[0];
temp01+=temp1[1];
}
if(temp1.length==4){
result2*=temp1[2];
temp02+=temp1[3];
}
}
else if(typeof temp1=='number'){
result1*=temp1;
}
else if(temp1=='zeroplayer'){
zeroplayer=true;
}
else if(temp1=='zerotarget'){
zerotarget=true;
}
2015-11-06 10:05:08 +00:00
else if(temp1=='zeroplayertarget'){
zeroplayer=true;
zerotarget=true;
}
2015-04-29 03:25:17 +00:00
}
if(target){
var skills2=target.get('s').concat(lib.skill.global);
game.expandSkills(skills2);
for(var i=0;i<skills2.length;i++){
temp2=get.info(skills2[i]).ai;
if(temp2&&temp2.threaten) temp3=temp2.threaten;
else temp3=undefined;
if(temp2&&typeof temp2.effect=='function'){
temp2=temp2.effect(card,player,target,result2);
}
else if(temp2&&typeof temp2.effect=='object'&&typeof temp2.effect.target=='function'){
temp2=temp2.effect.target(card,player,target,result2);
}
else temp2=undefined;
if(typeof temp2=='object'){
if(temp2.length==2||temp2.length==4){
result2*=temp2[0];
temp02+=temp2[1];
}
if(temp2.length==4){
result1*=temp2[2];
temp01+=temp2[3];
}
}
else if(typeof temp2=='number'){
result2*=temp2;
}
else if(temp2=='zeroplayer'){
zeroplayer=true;
}
else if(temp2=='zerotarget'){
zerotarget=true;
}
2015-11-06 10:05:08 +00:00
else if(temp2=='zeroplayertarget'){
zeroplayer=true;
zerotarget=true;
}
2015-04-29 03:25:17 +00:00
if(typeof temp3=='function'&&temp3(player,target)!=undefined){
threaten*=temp3(player,target);
}
else if(typeof temp3=='object'){
if(typeof temp3.target=='number'){
threaten*=temp3;
}
else if(typeof temp3.target=='function'&&temp3(player,target)!=undefined){
threaten*=temp3(player,target);
}
}
else if(typeof temp3=='number'){
threaten*=temp3;
}
}
result2+=temp02;
result1+=temp01;
if(ai.get.attitude(player,target)<0){
result2*=threaten;
}
else{
result2*=Math.sqrt(threaten);
}
if(target.hp<=1) result2*=2;
if(target.hp==2) result2*=1.1;
if(target.num('h')==0){
result2*=1.1;
if(get.tag(card,'respondSha')||get.tag(card,'respondShan')) result2*=1.4;
}
if(target.num('h')==1) result2*=1.05;
if(target.num('h')==2) result2*=1.02;
if(target.num('h')>3) result2*=0.9;
if(target.hp==4) result2*=0.9;
if(target.hp==5) result2*=0.8;
if(target.hp>5) result2*=0.6;
}
else{
result2+=temp02;
result1+=temp01;
}
if(zeroplayer) result1=0;
if(zerotarget) result2=0;
if(player2){
return (result1*ai.get.attitude(player2,player)+(target?result2*ai.get.attitude(player2,target):0));
}
return (result1*ai.get.attitude(player,player)+(target?result2*ai.get.attitude(player,target):0));
},
damageEffect:function(target,player,viewer,nature){
if(!player){
player=target;
}
if(!viewer){
viewer=target;
}
var name='damage';
if(nature=='fire'){
name='firedamage';
}
else if(nature=='thunder'){
name='thunderdamage';
}
return ai.get.effect(target,{name:name},player,viewer);
},
recoverEffect:function(target,player,viewer){
if(target.hp==target.maxHp) return 0;
if(!player){
player=target;
}
if(!viewer){
viewer=target;
}
return ai.get.effect(target,{name:'recover'},player,viewer);
},
buttonValue:function(button){
var card=button.link;
var player=get.owner(card);
if(!player) player=_status.event.player;
if(player.get('j').contains(card)){
var efff=ai.get.effect(player,card,player,player);
if(efff>0) return 0.5;
if(efff==0) return 0;
return -1.5;
}
if(player.get('e').contains(card)){
return ai.get.equipValue(card)/3;
}
2015-05-12 09:51:40 +00:00
var nh=player.num('h');
switch(nh){
case 1:return 2;
case 2:return 1.6;
case 3:return 1;
case 4:return 0.8;
case 5:return 0.6;
default:return 0.4;
}
2015-04-29 03:25:17 +00:00
},
attitude2:function(to){
return ai.get.attitude(_status.event.player,to);
},
players:function(range,sort){
var players=[];
if(range.max==undefined) range.max=Infinity;
if(range.min==undefined) range.min=-Infinity;
if(range.player==undefined) range.player=_status.event.player;
for(var i=0;i<game.players.length;i++){
if(ai.get.attitude(range.player,game.players[i])<=range.max&&
ai.get.attitude(range.player,game.players[i])>=range.min){
players.push(game.players[i]);
}
}
if(sort) players.sort(sort);
return players;
}
},
};
2015-05-09 02:56:55 +00:00
lib.init.init();
2015-04-29 03:25:17 +00:00
HTMLDivElement.prototype.animate=function(name){
this.classList.add(name);
var that=this;
setTimeout(function(){
that.classList.remove(name);
},1000);
return this;
};
HTMLDivElement.prototype.hide=function(){
this.classList.add('hidden');
return this;
};
HTMLDivElement.prototype.unfocus=function(){
this.classList.add('transparent');
return this;
};
HTMLDivElement.prototype.refocus=function(){
this.classList.remove('transparent');
return this;
};
HTMLDivElement.prototype.show=function(){
this.classList.remove('hidden');
return this;
};
HTMLDivElement.prototype.delete=function(time){
if(time==undefined) time=500;
this.classList.add('removing');
var that=this;
this.timeout=setTimeout(function(){
that.remove();
that.classList.remove('removing');
},time);
return this;
};
HTMLDivElement.prototype.goto=function(position,time){
if(time==undefined) time=500;
this.classList.add('removing');
var that=this;
this.timeout=setTimeout(function(){
position.appendChild(that);
that.classList.remove('removing');
delete that.destiny;
},time);
this.destiny=position;
return this;
};
HTMLDivElement.prototype.fix=function(){
clearTimeout(this.timeout);
delete this.destiny;
this.classList.remove('removing');
return this;
};
2015-10-20 17:44:00 +00:00
HTMLDivElement.prototype.setBackground=function(name,type,ext,subfolder){
2015-04-29 03:25:17 +00:00
var src;
2015-10-13 11:15:02 +00:00
ext=ext||'.jpg';
2015-10-20 17:44:00 +00:00
subfolder=subfolder||'default'
2015-04-29 03:25:17 +00:00
if(type){
2015-10-20 17:44:00 +00:00
src='image/'+type+'/'+subfolder+'/'+name+ext;
2015-04-29 03:25:17 +00:00
}
else{
2015-10-13 11:15:02 +00:00
src='image/'+name+ext;
2015-04-29 03:25:17 +00:00
}
this.style.backgroundImage="url('"+src+"')";
this.style.backgroundSize="cover";
return this;
};
HTMLDivElement.prototype.listen=function(func){
this.addEventListener(lib.config.touchscreen?'touchend':'click',function(e){
if(_status.dragged) return;
func.call(this,e);
})
return this;
};
HTMLDivElement.prototype.setPosition=function(){
var position;
if(arguments.length==4){
position=[];
for(var i=0;i<arguments.length;i++) position.push(arguments[i]);
}
else if(arguments.length==1&&get.objtype(arguments[0])=='array'&&arguments[0].length==4){
position=arguments[0];
}
else{
return this;
}
var top='calc('+position[0]+'% ';
if(position[1]>0) top+='+ '+position[1]+'px)';
else top+='- '+Math.abs(position[1])+'px)';
var left='calc('+position[2]+'% ';
if(position[3]>0) left+='+ '+position[3]+'px)';
else left+='- '+Math.abs(position[3])+'px)';
this.style.top=top;
this.style.left=left;
return this;
};
HTMLDivElement.prototype.css=function(style){
for(var i in style){
if(i=='innerHTML'){
this.innerHTML=style[i];
}
else{
this.style[i]=style[i];
}
}
return this;
};
HTMLDivElement.prototype.transform=function(transform){
var str='';
for(var i in transform){
switch(i){
case 'scale':str+='scale('+transform[i]+') ';break;
case 'rotate':str+='rotate('+transform[i]+'deg) ';break;
}
}
if(typeof transform=='object'){
if(transform.left&&transform.top){
str+='translate('+parseInt(transform.left)+'px,'+parseInt(transform.top)+'px) ';
}
else if(transform.left){
str+='translate('+parseInt(transform.left)+'px) ';
}
else if(transform.top){
str+='translate(0,'+parseInt(transform.top)+'px) ';
}
}
2015-11-05 02:34:35 +00:00
this.style.transform=str;
2015-04-29 03:25:17 +00:00
return this;
};
HTMLTableElement.prototype.get=function(row,col){
if(row<this.childNodes.length){
return this.childNodes[row].childNodes[col];
}
};
Array.prototype.find=function(item){
return this.indexOf(item);
};
Array.prototype.contains=function(item){
return this.indexOf(item)!=-1;
};
Array.prototype.add=function(){
for(var i=0;i<arguments.length;i++){
if(this.contains(arguments[i])){
return false;
}
this.push(arguments[i]);
}
return this;
};
Array.prototype.remove=function(item){
if(get.objtype(item)=='array'){
for(var i=0;i<item.length;i++) this.remove(item[i]);
return;
}
var pos=this.find(item);
if(pos==-1){
return false;
}
this.splice(pos,1);
return this;
};
Array.prototype.randomGet=function(){
var arr=this.slice(0);
for(var i=0;i<arguments.length;i++) arr.remove(arguments[i]);
return arr[Math.floor(Math.random()*arr.length)];
};
Array.prototype.randomRemove=function(){
var num=Math.floor(Math.random()*this.length);
return this.splice(num,1)[0];
};
2015-05-03 15:17:15 +00:00
Array.prototype.randomSort=function(){
var list=[];
while(this.length){
list.push(this.randomRemove());
}
for(var i=0;i<list.length;i++){
this.push(list[i]);
}
return this;
};
2015-04-29 03:25:17 +00:00
Array.prototype.randomGets=function(num){
2015-09-03 03:49:14 +00:00
if(num>this.length){
num=this.length;
}
2015-04-29 03:25:17 +00:00
var arr=this.slice(0);
var list=[];
for(var i=0;i<num;i++){
list.push(arr.splice(Math.floor(Math.random()*arr.length),1)[0]);
}
return list;
};
window.cheat={
i:function(){
window.game=game;
window.ui=ui;
window.get=get;
window.ai=ai;
window.lib=lib;
window._status=_status;
},
2015-06-12 07:15:23 +00:00
h:function(player){
console.log(get.translation(player.get('h')));
2015-04-29 03:25:17 +00:00
},
2015-09-25 05:05:26 +00:00
g:function(){
for(var i=0;i<arguments.length;i++){
if(i>0&&typeof arguments[i]=='number'){
for(var j=0;j<arguments[i]-1;j++){
cheat.gx(arguments[i-1]);
}
}
else{
cheat.gx(arguments[i]);
}
}
},
gx:function(name,target){
2015-04-29 03:25:17 +00:00
target=target||game.me;
2015-09-25 05:05:26 +00:00
var fire=false,thunder=false;
var suit=null;
var suits=['club','spade','diamond','heart'];
for(var i=0;i<suits.length;i++){
if(name.indexOf(suits[i])==0){
suit=suits[i];
name=name.slice(suits[i].length);
break;
}
}
if(name=='huosha'){
name='sha';
fire=true;
}
else if(name=='leisha'){
name='sha';
thunder=true;
}
2015-04-29 03:25:17 +00:00
for(var i=0;i<ui.cardPile.childNodes.length;i++){
2015-09-25 05:05:26 +00:00
if(fire&&ui.cardPile.childNodes[i].nature!='fire'){
continue;
}
if(thunder&&ui.cardPile.childNodes[i].nature!='thunder'){
continue;
}
if(suit&&ui.cardPile.childNodes[i].suit!=suit){
continue;
}
2015-04-29 03:25:17 +00:00
if(ui.cardPile.childNodes[i].name==name){
var card=ui.cardPile.childNodes[i];
target.node.handcards1.appendChild(card);
game.check();
target.update();
return;
}
}
for(var i=0;i<ui.discardPile.childNodes.length;i++){
2015-09-25 05:05:26 +00:00
if(fire&&ui.cardPile.childNodes[i].nature!='fire'){
continue;
}
if(thunder&&ui.cardPile.childNodes[i].nature!='thunder'){
continue;
}
if(suit&&ui.cardPile.childNodes[i].suit!=suit){
continue;
}
2015-04-29 03:25:17 +00:00
if(ui.discardPile.childNodes[i].name==name){
var card=ui.discardPile.childNodes[i];
target.node.handcards1.appendChild(card);
game.check();
target.update();
return;
}
}
},
ge:function(){
cheat.g('zhuge');
cheat.g('qilin');
cheat.g('bagua');
cheat.g('dilu');
cheat.g('chitu');
cheat.g('muniu');
},
gj:function(){
cheat.g('shandian');
cheat.g('huoshan');
cheat.g('hongshui');
cheat.g('lebu');
cheat.g('bingliang');
cheat.g('guiyoujie');
},
d:function(num,target){
if(num==undefined) num=1;
var cards=get.cards(num);
for(var i=0;i<num;i++){
var card=cards[i];
game.me.node.handcards1.appendChild(card);
game.check();
game.me.update();
}
},
s:function(skill){
game.me.addSkill(skill);
game.check();
},
t:function(num){
if(num==undefined){
for(var i=0;i<game.players.length;i++) cheat.t(i);
return;
}
var player=game.players[num];
var cards=player.get('hej');
for(var i=0;i<cards.length;i++){
ui.discardPile.appendChild(cards[i]);
}
player.update();
},
k:function(i){
if(i==undefined) i=1;
game.players[i].hp=1;
cheat.t(i);
cheat.g('juedou');
},
z:function(name){
game.zhu.init(name);
game.zhu.maxHp++;
game.zhu.hp++;
game.zhu.update();
},
cp:function(){
cheat.z('caopi');
},
cc:function(){
2015-09-10 13:56:57 +00:00
cheat.z('re_caocao');
2015-04-29 03:25:17 +00:00
},
ls:function(){
cheat.z('liushan');
},
zj:function(){
2015-09-10 13:56:57 +00:00
cheat.z('diy_zhangjiao');
},
sc:function(){
cheat.z('sunce');
},
lc:function(){
cheat.z('liushan');
},
lb:function(){
cheat.z('liubei');
2015-04-29 03:25:17 +00:00
}
}
window.countGroups=function(){
var a=0,b=0,c=0,d=0;
var sa=0,sb=0,sc=0,sd=0;
for(var i in lib.character){
switch(lib.character[i][1]){
case 'wei':a++;if(lib.config.forbidsingle.contains(i)) sa++;break;
case 'shu':b++;if(lib.config.forbidsingle.contains(i)) sb++;break;
case 'wu':c++;if(lib.config.forbidsingle.contains(i)) sc++;break;
case 'qun':d++;if(lib.config.forbidsingle.contains(i)) sd++;break;
}
}
console.log('魏:'+(a-sa)+'/'+a);
console.log('蜀:'+(b-sb)+'/'+b);
console.log('吴:'+(c-sc)+'/'+c);
console.log('群:'+(d-sd)+'/'+d);
return ((a+b+c+d)-(sa+sb+sc+sd))+'/'+(a+b+c+d);
}
window.countSkills=function(){
for(var i in lib.skill){
if(lib.translate[i+'_info']){
console.log(lib.translate[i],lib.translate[i+'_info'])
}
}
}
window.countCards=function(){
var a=0,b=0,c=0,d=0;
var aa=0,bb=0,cc=0,dd=0;
var sa=0,sb=0,sc=0,sd=0;
var sha=0,shan=0,tao=0,jiu=0,wuxie=0,heisha=0,hongsha=0;
var num={1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0};
for(var i in lib.card){
if(typeof lib.card[i]=='object'){
switch(lib.card[i].type){
case 'basic':a++;break;
case 'trick':b++;break;
case 'equip':c++;break;
default:d++;break;
}
}
}
for(var i=0;i<lib.card.list.length;i++){
if(typeof lib.card[lib.card.list[i][2]]=='object'){
switch(lib.card[lib.card.list[i][2]].type){
case 'basic':aa++;break;
case 'trick':case 'delay':bb++;break;
case 'equip':cc++;break;
default:dd++;break;
}
switch(lib.card.list[i][0]){
case 'heart':sa++;break;
case 'diamond':sb++;break;
case 'club':sc++;break;
case 'spade':sd++;break;
}
if(lib.card.list[i][2]=='sha'){
sha++;
if(lib.card.list[i][0]=='club'||lib.card.list[i][0]=='spade'){
heisha++;
}
else{
hongsha++;
}
}
if(lib.card.list[i][2]=='shan'){
shan++;
}
if(lib.card.list[i][2]=='tao'){
tao++;
}
if(lib.card.list[i][2]=='jiu'){
jiu++;
}
if(lib.card.list[i][2]=='wuxie'){
wuxie++;
}
num[lib.card.list[i][1]]++;
}
}
var str='基本牌'+aa+' '+'锦囊牌'+bb+' '+'装备牌'+cc+' '+'其它牌'+dd
console.log(str);
str='红桃牌'+sa+' '+'方片牌'+sb+' '+'梅花牌'+sc+' '+'黑桃牌'+sd
console.log(str);
str='杀'+sha+' '+'黑杀'+heisha+' '+'红杀'+hongsha+' '+'闪'+shan+' '+'桃'+tao+' '+'酒'+jiu+' '+'无懈'+wuxie
console.log(str);
for(var i=1;i<=13;i++){
2015-09-16 02:45:45 +00:00
if(i<10){
console.log(i+' ',num[i]);
}
else{
console.log(i,num[i]);
}
2015-04-29 03:25:17 +00:00
}
return aa+bb+cc+dd;
}
window.onkeydown=function(e){
2015-10-30 15:32:48 +00:00
if(!ui.menuContainer.classList.contains('hidden')) return;
2015-10-28 03:47:35 +00:00
if(ui.currentpopped){
if(ui.currentpopped._uiintro){
ui.currentpopped._uiintro.delete();
delete ui.currentpopped._uiintro;
}
delete ui.currentpopped;
}
var dialogs=document.querySelectorAll('#window>.dialog.popped:not(.static)');
for(var i=0;i<dialogs.length;i++){
dialogs[i].delete();
}
2015-04-29 03:25:17 +00:00
if(e.keyCode==32){
var node=ui.window.querySelector('#paused');
if(node){
node.click();
}
else{
ui.click.pause();
}
}
else if(e.keyCode==65){
if(ui.auto) ui.auto.click();
}
else if(e.keyCode==87){
if(ui.wuxie&&ui.wuxie.style.display!='none'){
ui.wuxie.classList.toggle('glow')
}
}
else if(e.keyCode==67){
var node=ui.window.querySelector('#click');
if(node){
node.click();
}
else{
ui.click.config();
}
}
else if(e.keyCode==116||((e.ctrlKey||e.metaKey)&&e.keyCode==82)){
2015-04-29 08:41:00 +00:00
_status.reloading=true;
game.reload();
2015-04-29 03:25:17 +00:00
}
};
window.onload=function(){
2015-05-07 04:48:00 +00:00
document.body.onresize=ui.updatex;
2015-04-29 03:25:17 +00:00
if(lib.config.touchscreen){
document.body.addEventListener('touchstart',function(e){
this.startX=e.touches[0].clientX;
this.startY=e.touches[0].clientY;
_status.dragged=false;
});
document.body.addEventListener('touchmove',function(e){
if(_status.dragged) return;
if (Math.abs(e.touches[0].clientX - this.startX) > 10 ||
Math.abs(e.touches[0].clientY - this.startY) > 10) {
_status.dragged=true;
}
});
}
ui.background=document.querySelector('.background.static');
ui.background.classList.remove('static');
ui.dynamicBackground=document.querySelector('.background.dynamic');
var i,j,k;
for(i in mode[lib.config.mode].element){
if(!lib.element[i]) lib.element[i]=[];
for(j in mode[lib.config.mode].element[i]){
if(j=='init'){
if(!lib.element[i].inits) lib.element[i].inits=[];
lib.element[i].inits.push(lib.init.eval(mode[lib.config.mode].element[i][j]));
}
else{
lib.element[i][j]=lib.init.eval(mode[lib.config.mode].element[i][j]);
}
}
}
for(i in mode[lib.config.mode].ai){
if(typeof mode[lib.config.mode].ai[i]=='object'){
if(ai[i]==undefined) ai[i]={};
for(j in mode[lib.config.mode].ai[i]){
ai[i][j]=lib.init.eval(mode[lib.config.mode].ai[i][j]);
}
}
else{
ai[i]=lib.init.eval(mode[lib.config.mode].ai[i]);
}
}
for(i in mode[lib.config.mode].ui){
if(typeof mode[lib.config.mode].ui[i]=='object'){
if(ui[i]==undefined) ui[i]={};
for(j in mode[lib.config.mode].ui[i]){
ui[i][j]=lib.init.eval(mode[lib.config.mode].ui[i][j]);
}
}
else{
ui[i]=lib.init.eval(mode[lib.config.mode].ui[i]);
}
}
for(i in mode[lib.config.mode].game){
game[i]=lib.init.eval(mode[lib.config.mode].game[i]);
}
for(i in mode[lib.config.mode].get){
get[i]=lib.init.eval(mode[lib.config.mode].get[i]);
}
2015-05-04 03:17:03 +00:00
lib.config.current_mode=mode[lib.config.mode].config||[];
2015-04-29 03:25:17 +00:00
lib.config.mode_choice=mode[lib.config.mode].config;
2015-10-30 09:13:19 +00:00
lib.rank=window.characterRank;
2015-10-29 17:36:14 +00:00
delete window.characterRank;
2015-04-29 03:25:17 +00:00
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(lib[i]==undefined) lib[i]=(get.objtype(mode[lib.config.mode][i])=='array')?[]:{};
for(j in mode[lib.config.mode][i]){
lib[i][j]=lib.init.eval(mode[lib.config.mode][i][j]);
}
}
2015-11-06 10:05:08 +00:00
lib.skilllist=[];
2015-11-09 03:15:16 +00:00
if(!lib.characterPack) lib.characterPack={};
2015-04-29 03:25:17 +00:00
for(i in character){
2015-10-30 09:13:19 +00:00
if(character[i].character){
2015-10-30 15:32:48 +00:00
lib.characterPack[i]=character[i].character
2015-10-30 09:13:19 +00:00
}
2015-04-29 03:25:17 +00:00
if(character[i].forbid&&character[i].forbid.contains(lib.config.mode)) continue;
if(character[i].mode&&character[i].mode.contains(lib.config.mode)==false) continue;
for(j in character[i]){
if(j=='mode'||j=='forbid') continue;
2015-10-13 11:15:02 +00:00
if(j=='character'&&!lib.config.characters.contains(i)){
2015-10-27 07:56:42 +00:00
if(lib.config.mode=='chess'&&get.config('chess_mode')=='leader'){
for(k in character[i][j]){
lib.hiddenCharacters.push(k);
}
}
else{
2015-10-13 11:15:02 +00:00
continue;
}
}
2015-04-29 03:25:17 +00:00
for(k in character[i][j]){
if(j=='character'){
2015-05-11 03:43:37 +00:00
if(!character[i][j][k][4]){
character[i][j][k][4]=[];
}
2015-10-31 10:14:14 +00:00
if(lib.config.only_fullskin&&lib.isNewLayout()&&lib.config.mode!='chess'){
2015-05-03 15:17:15 +00:00
if(!character[i][j][k][4].contains('fullskin')&&!character[i][j][k][4].contains('minskin')){
2015-04-29 03:25:17 +00:00
continue;
}
}
2015-10-30 15:32:48 +00:00
if(lib.config.banned.contains(k)){
if(lib.config.mode=='chess'&&get.config('chess_mode')=='leader'){
lib.hiddenCharacters.push(k);
}
else{
continue;
}
}
2015-11-06 10:05:08 +00:00
for(var l=0;l<character[i][j][k][3].length;l++){
lib.skilllist.add(character[i][j][k][3][l]);
}
2015-04-29 03:25:17 +00:00
}
2015-06-13 06:53:40 +00:00
if(j=='translate'&&k==i){
lib[j][k+'_character_config']=character[i][j][k];
2015-04-29 03:25:17 +00:00
}
else{
2015-06-13 06:53:40 +00:00
if(lib[j][k]==undefined){
lib[j][k]=lib.init.eval(character[i][j][k]);
}
else{
alert('dublicate '+j+' in character '+i+':\n'+k+'\n'+': '+lib[j][k]+'\n'+character[i][j][k]);
}
2015-04-29 03:25:17 +00:00
}
}
}
}
2015-11-09 03:15:16 +00:00
if(!lib.cardPack) lib.cardPack={};
2015-04-29 03:25:17 +00:00
for(i in card){
2015-10-30 15:32:48 +00:00
lib.cardPack[i]=[];
if(card[i].card){
for(var j in card[i].card){
if(card[i].translate[j+'_info']){
lib.cardPack[i].push(j);
}
}
}
2015-04-29 03:25:17 +00:00
if(card[i].forbid&&card[i].forbid.contains(lib.config.mode)) continue;
if(card[i].mode&&card[i].mode.contains(lib.config.mode)==false) continue;
for(j in card[i]){
if(j=='mode'||j=='forbid') continue;
if(j=='list'){
if(lib.config.cards.contains(i)){
if(typeof card[i][j]=='function'){
lib.card.list=lib.card.list.concat(lib.init.eval(card[i][j])());
}
else{
lib.card.list=lib.card.list.concat(card[i][j]);
}
}
}
else{
for(k in card[i][j]){
2015-06-13 06:53:40 +00:00
if(j=='translate'&&k==i){
lib[j][k+'_card_config']=card[i][j][k];
}
else{
if(lib[j][k]==undefined) lib[j][k]=lib.init.eval(card[i][j][k]);
else alert('dublicate '+j+' in card '+i+':\n'+k+'\n'+lib[j][k]+'\n'+card[i][j][k]);
}
2015-04-29 03:25:17 +00:00
}
}
}
}
for(i in play){
if(play[i].forbid&&play[i].forbid.contains(lib.config.mode)) continue;
if(play[i].mode&&play[i].mode.contains(lib.config.mode)==false) continue;
for(j in play[i].element){
if(!lib.element[j]) lib.element[j]=[];
for(k in play[i].element[j]){
if(k=='init'){
if(!lib.element[j].inits) lib.element[j].inits=[];
lib.element[j].inits.push(lib.init.eval(play[i].element[j][k]));
}
else{
lib.element[j][k]=lib.init.eval(play[i].element[j][k]);
}
}
}
for(j in play[i].ui){
if(typeof play[i].ui[j]=='object'){
if(ui[j]==undefined) ui[j]={};
for(k in play[i].ui[j]){
ui[j][k]=lib.init.eval(play[i].ui[j][k]);
}
}
else{
ui[j]=lib.init.eval(play[i].ui[j]);
}
}
for(j in play[i].game){
game[j]=lib.init.eval(play[i].game[j]);
}
for(j in play[i].get){
get[j]=lib.init.eval(play[i].get[j]);
}
2015-05-04 03:17:03 +00:00
if(play[i].config){
lib.config.current_mode=lib.config.current_mode.concat(play[i].config);
2015-04-29 03:25:17 +00:00
}
for(j in play[i]){
2015-11-09 09:05:28 +00:00
if(j=='mode'||j=='forbid'||j=='init'||j=='element'||
j=='game'||j=='get'||j=='config'||j=='ui'||j=='arenaReady') continue;
2015-04-29 03:25:17 +00:00
for(k in play[i][j]){
2015-06-13 06:53:40 +00:00
if(j=='translate'&&k==i){
lib[j][k+'_play_config']=play[i][j][k];
}
else{
if(lib[j][k]!=undefined){
console.log('dublicate '+j+' in play '+i+':\n'+k+'\n'+': '+lib[j][k]+'\n'+play[i][j][k]);
}
lib[j][k]=lib.init.eval(play[i][j][k]);
2015-04-29 03:25:17 +00:00
}
}
}
if(typeof play[i].init=='function') (lib.init.eval(play[i].init))();
2015-11-09 09:05:28 +00:00
if(typeof play[i].arenaReady=='function') lib.arenaReady.push(play[i].arenaReady);
2015-04-29 03:25:17 +00:00
}
for(i=0;i<lib.card.list.length;i++){
if(!lib.card[lib.card.list[i][2]]){
lib.card.list.splice(i,1);i--;
}
else if(lib.card[lib.card.list[i][2]].mode&&
lib.card[lib.card.list[i][2]].mode.contains(lib.config.mode)==false){
lib.card.list.splice(i,1);i--;
}
}
try{
lib.storage=JSON.parse(localStorage.getItem(lib.configprefix+lib.config.mode));
if(typeof lib.storage!='object') throw('err');
if(lib.storage==null) throw('err');
}
catch(err){
lib.storage={};
localStorage.setItem(lib.configprefix+lib.config.mode,"{}");
}
if(lib.config.cheat) cheat.i();
else{
lib.cheat=window.cheat;
delete window.cheat;
}
lib.config.sort_card=get.sortCard(lib.config.sort);
delete window.config;
delete window.mode;
delete window.card;
delete window.character;
delete window.play;
game.start();
game.loop();
};
2015-10-29 17:36:14 +00:00
document.onmousewheel=ui.click.windowmousewheel;
2015-04-29 03:25:17 +00:00
document.onmousemove=ui.click.windowmousemove;
document.onmousedown=ui.click.windowmousedown;
document.onmouseup=ui.click.windowmouseup;
document.oncontextmenu=ui.click.right;
document.ontouchend=function(e){
if(e.touches.length==1&&!_status.dragged){
ui.click.pause();
}
}
document.ontouchmove = function(e) {
2015-05-05 09:23:31 +00:00
e.preventDefault();
2015-04-29 03:25:17 +00:00
};
}());