This commit is contained in:
libccy 2016-04-03 17:03:46 +08:00
parent 1fd46f55ab
commit 8e190a7382
8 changed files with 244 additions and 80 deletions

View File

@ -1381,6 +1381,7 @@ card.standard={
event.state=true; event.state=true;
event.card=trigger.card; event.card=trigger.card;
event.blacklist=[]; event.blacklist=[];
event._global_waiting=true;
'step 1' 'step 1'
var list=[],list2=[]; var list=[],list2=[];
for(var i=0;i<game.players.length;i++){ for(var i=0;i<game.players.length;i++){

View File

@ -2712,7 +2712,7 @@
frequent:true, frequent:true,
onclick:function(item){ onclick:function(item){
game.saveConfig('connect_avatar',item); game.saveConfig('connect_avatar',item);
game.saveConfig('connect_avatar',item,true); game.saveConfig('connect_avatar',item,'connect');
} }
}, },
} }
@ -6187,13 +6187,15 @@
cards[0].style.transform=''; cards[0].style.transform='';
player.node.judges.insertBefore(cards[0],player.node.judges.firstChild); player.node.judges.insertBefore(cards[0],player.node.judges.firstChild);
game.broadcast(function(player,card){ game.broadcast(function(player,card){
card.style.transform=''; card.fix();
card.style.transform='';
card.classList.remove('drawinghidden');
player.node.judges.insertBefore(card,player.node.judges.firstChild); player.node.judges.insertBefore(card,player.node.judges.firstChild);
if(card.clone&&card.clone.parentNode==player.parentNode){ if(card.clone&&card.clone.parentNode==player.parentNode){
card.clone.moveDelete(player); card.clone.moveDelete(player);
game.addVideo('gain2',player,get.cardsInfo([card])); game.addVideo('gain2',player,get.cardsInfo([card]));
} }
},player,card); },player,cards[0]);
if(cards[0].clone&&cards[0].clone.parentNode==player.parentNode){ if(cards[0].clone&&cards[0].clone.parentNode==player.parentNode){
cards[0].clone.moveDelete(player); cards[0].clone.moveDelete(player);
game.addVideo('gain2',player,get.cardsInfo(cards)); game.addVideo('gain2',player,get.cardsInfo(cards));
@ -8050,9 +8052,26 @@
else{ else{
lib.node.torespond[this.playerid]='_noname_waiting'; lib.node.torespond[this.playerid]='_noname_waiting';
} }
clearTimeout(lib.node.torespondtimeout[this.playerid]);
if(this.ws&&!this.ws.closed){
var player=this;
var time=parseInt(lib.configOL.choose_timeout)*1000;
if(!_status.event._global_waiting){
player.showTimer(time);
}
lib.node.torespondtimeout[this.playerid]=setTimeout(function(){
player.unwait('ai');
player.ws.ws.close();
},time+5000);
}
} }
}, },
unwait:function(result){ unwait:function(result){
if(!_status.event._global_waiting){
this.hideTimer();
}
clearTimeout(lib.node.torespondtimeout[this.playerid]);
delete lib.node.torespondtimeout[this.playerid];
if(!lib.node.torespond.hasOwnProperty(this.playerid)){ if(!lib.node.torespond.hasOwnProperty(this.playerid)){
return; return;
} }
@ -8193,6 +8212,37 @@
} }
} }
}, },
showTimer:function(time){
if(_status.connectMode&&!game.online){
game.broadcast(function(player,time){
player.showTimer(time);
},this,time);
}
if(this==game.me){
return;
}
if(this.node.timer){
this.node.timer.remove();
}
var timer=ui.create.div('.timerbar',this);
this.node.timer=timer;
ui.create.div(this.node.timer);
var bar=ui.create.div(this.node.timer);
ui.refresh(bar);
bar.style.transitionDuration=(time/1000)+'s';
bar.style.width=0;
},
hideTimer:function(){
if(_status.connectMode&&!game.online){
game.broadcast(function(player){
player.hideTimer();
},this);
}
if(this.node.timer){
this.node.timer.delete();
delete this.node.timer;
}
},
markSkill:function(name,info,card){ markSkill:function(name,info,card){
if(get.itemtype(card)=='card'){ if(get.itemtype(card)=='card'){
game.addVideo('markSkill',this,[name,get.cardInfo(card)]); game.addVideo('markSkill',this,[name,get.cardInfo(card)]);
@ -8592,13 +8642,19 @@
return false; return false;
}, },
isOnline:function(){ isOnline:function(){
if(this.ws&&lib.node&&lib.node.clients.contains(this.ws)&&this.ws.inited){ if(this.ws&&lib.node&&!this.ws.closed&&this.ws.inited&&!this.isAuto){
return true;
}
return false;
},
isOnline2:function(){
if(this.ws&&lib.node&&!this.ws.closed){
return true; return true;
} }
return false; return false;
}, },
isOffline:function(){ isOffline:function(){
if(this.ws&&lib.node&&!lib.node.clients.contains(this.ws)){ if(this.ws&&lib.node&&this.ws.closed){
return true; return true;
} }
return false; return false;
@ -10394,7 +10450,12 @@
for(var i=1;i<args.length;i++){ for(var i=1;i<args.length;i++){
args[i]=get.stringifiedResult(args[i]); args[i]=get.stringifiedResult(args[i]);
} }
this.ws.send(JSON.stringify(args)); try{
this.ws.send(JSON.stringify(args));
}
catch(e){
this.ws.close();
}
return this; return this;
}, },
close:function(){ close:function(){
@ -10427,13 +10488,11 @@
delete _status.connectCallback; delete _status.connectCallback;
} }
game.send('init',lib.versionOL,{ game.send('init',lib.versionOL,{
id:game.onlineID,
avatar:lib.config.connect_avatar, avatar:lib.config.connect_avatar,
nickname:lib.config.connect_nickname nickname:lib.config.connect_nickname
}); });
}, },
onreconnect:function(){
game.send('reinit',game.onlineID);
},
onmessage:function(messageevent){ onmessage:function(messageevent){
var message; var message;
try{ try{
@ -10467,11 +10526,12 @@
_status.connectCallback(false); _status.connectCallback(false);
delete _status.connectCallback; delete _status.connectCallback;
} }
game.saveConfig('reconnect_info');
if(game.online){ if(game.online){
game.saveConfig('reconnect_more',game.ip);
game.reload(); game.reload();
} }
else{
game.saveConfig('reconnect_info');
}
game.online=false; game.online=false;
game.ws=null; game.ws=null;
} }
@ -10772,7 +10832,7 @@
if(lib.config.tao_enemy&&event.dying.side!=player.side&&lib.config.mode!='identity'&&lib.config.mode!='guozhan'){ if(lib.config.tao_enemy&&event.dying.side!=player.side&&lib.config.mode!='identity'&&lib.config.mode!='guozhan'){
event._result={bool:false} event._result={bool:false}
} }
else if(player.hasSkillTag('save',true)||player.num('h','tao')||player.num('h','spell_zhiliaoshui')|| else if(player.isOnline()||player.hasSkillTag('save',true)||player.num('h','tao')||player.num('h','spell_zhiliaoshui')||
(player==event.dying&&(player.num('h','jiu')||player.num('h','hufu')||player.num('h','tianxianjiu')))){ (player==event.dying&&(player.num('h','jiu')||player.num('h','hufu')||player.num('h','tianxianjiu')))){
player.chooseToUse({ player.chooseToUse({
filterCard:function(card,player){ filterCard:function(card,player){
@ -10962,7 +11022,17 @@
message:{ message:{
server:{ server:{
init:function(version,config){ init:function(version,config){
if(version!=lib.versionOL){ if(config.id&&lib.playerOL&&lib.playerOL[config.id]&&lib.playerOL[config.id].isOffline()){
var player=lib.playerOL[config.id];
player.setNickname();
player.ws=this;
this.id=config.id;
game.broadcast(function(player){
player.setNickname();
},player);
this.send('reinit',lib.configOL,get.arenaState(),game.getState?game.getState():{},game.ip);
}
else if(version!=lib.versionOL){
this.send('denied','version'); this.send('denied','version');
} }
else if(!_status.waitingForPlayer){ else if(!_status.waitingForPlayer){
@ -10986,21 +11056,6 @@
this.send('init',this.id,lib.configOL,game.ip); this.send('init',this.id,lib.configOL,game.ip);
} }
}, },
reinit:function(id){
if(lib.playerOL&&lib.playerOL[id]&&lib.playerOL[id].isOffline()){
var player=lib.playerOL[id];
player.setNickname();
player.ws=this;
this.id=id;
game.broadcast(function(player){
player.setNickname();
},player);
this.send('reinit',lib.configOL,get.arenaState(),game.getState?game.getState():{},game.ip);
}
else{
this.send('denied','offline');
}
},
inited:function(){ inited:function(){
this.inited=true; this.inited=true;
if(_status.waitingForPlayer){ if(_status.waitingForPlayer){
@ -11016,6 +11071,26 @@
player.unwait(result); player.unwait(result);
} }
}, },
auto:function(){
var player=lib.playerOL[this.id];
if(player){
player.isAuto=true;
player.setNickname(player.nickname+' - 托管');
game.broadcast(function(player){
player.setNickname(player.nickname+' - 托管');
},player);
}
},
unauto:function(){
var player=lib.playerOL[this.id];
if(player){
player.isAuto=false;
player.setNickname(player.nickname);
game.broadcast(function(player){
player.setNickname(player.nickname);
},player);
}
},
exec:function(func){ exec:function(func){
if(typeof func=='function'){ if(typeof func=='function'){
var args=Array.from(arguments); var args=Array.from(arguments);
@ -11091,6 +11166,14 @@
} }
}, },
reinit:function(config,state,state2,ip){ reinit:function(config,state,state2,ip){
if(ui.ipnode){
ui.ipnode.delete();
delete ui.ipnode;
}
if(ui.iptext){
ui.iptext.delete();
delete ui.iptext;
}
game.online=true; game.online=true;
game.ip=ip; game.ip=ip;
game.saveConfig('reconnect_info',[_status.ip,game.onlineID]); game.saveConfig('reconnect_info',[_status.ip,game.onlineID]);
@ -11378,12 +11461,7 @@
} }
return; return;
} }
if(typeof game.onlineID==='string'){ game.ws.onopen=lib.element.ws.onopen;
game.ws.onopen=lib.element.ws.onreconnect;
}
else{
game.ws.onopen=lib.element.ws.onopen;
}
game.ws.onmessage=lib.element.ws.onmessage; game.ws.onmessage=lib.element.ws.onmessage;
game.ws.onerror=lib.element.ws.onerror; game.ws.onerror=lib.element.ws.onerror;
game.ws.onclose=lib.element.ws.onclose; game.ws.onclose=lib.element.ws.onclose;
@ -11401,18 +11479,25 @@
createServer:function(){ createServer:function(){
lib.node.clients=[]; lib.node.clients=[];
lib.node.torespond={}; lib.node.torespond={};
lib.node.torespondtimeout={};
lib.configOL={}; lib.configOL={};
lib.playerOL={}; lib.playerOL={};
lib.cardOL={}; lib.cardOL={};
var WebSocketServer=require('ws').Server; var WebSocketServer=require('ws').Server;
var wss=new WebSocketServer({port:8080}); var wss=new WebSocketServer({port:8080});
var os=require('os');
var en0 = os.networkInterfaces().en0; var interfaces = require('os').networkInterfaces();
for(var i=0;i<en0.length;i++){ for(var devName in interfaces){
if(en0[i].family=='IPv4'){ var iface = interfaces[devName];
game.ip=en0[i].address;break; for(var i=0;i<iface.length;i++){
var alias = iface[i];
if(alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal){
game.ip=alias.address;break;
}
} }
if(game.ip) break;
} }
wss.on('connection',function(ws){ wss.on('connection',function(ws){
var client={ var client={
ws:ws, ws:ws,
@ -13660,8 +13745,14 @@
ui.clear(); ui.clear();
game.stopCountChoose(); game.stopCountChoose();
if(game.online){ if(game.online){
game.saveConfig('reconnect_info'); var dialog=ui.create.dialog();
ui.create.dialog().content.innerHTML=result; dialog.content.innerHTML=result;
if(arguments[1]==true){
dialog.content.firstChild.innerHTML='战斗胜利';
}
else if(arguments[1]==false){
dialog.content.firstChild.innerHTML='战斗失败';
}
ui.update(); ui.update();
if(!ui.restart){ if(!ui.restart){
ui.restart=ui.create.control('restart',game.reload); ui.restart=ui.create.control('restart',game.reload);
@ -13957,7 +14048,12 @@
} }
dialog.add(ui.create.div('.placeholder')); dialog.add(ui.create.div('.placeholder'));
dialog.add(ui.create.div('.placeholder')); dialog.add(ui.create.div('.placeholder'));
game.broadcast(game.over,dialog.content.innerHTML); for(var i=0;i<game.players.length;i++){
if(game.players[i].isOnline2()){
console.log(game.players[i]);
game.players[i].send(game.over,dialog.content.innerHTML,game.checkOnlineResult(game.players[i]));
}
}
game.addVideo('over',null,dialog.content.innerHTML); game.addVideo('over',null,dialog.content.innerHTML);
var vinum=parseInt(lib.config.video); var vinum=parseInt(lib.config.video);
if(!_status.video&&vinum&&game.getVideoName&&window.indexedDB&&!game.online){ if(!_status.video&&vinum&&game.getVideoName&&window.indexedDB&&!game.online){
@ -15726,6 +15822,30 @@
} }
return node; return node;
}, },
giveup:function(){
ui.create.system('投降',function(){
var player=game.me;
if(game.online){
game.send(function(player){
game.log(player,'投降');
player.popup('投降');
setTimeout(function(){
player.die('nosource');
},1000);
},player);
}
else{
game.log(player,'投降');
player.popup('投降');
setTimeout(function(){
player.die('nosource');
},1000);
}
if(_status.paused&&_status.imchoosing&&!_status.auto){
ui.click.auto();
}
},true);
},
groupControl:function(dialog){ groupControl:function(dialog){
return ui.create.control('wei','shu','wu','qun',function(link,node){ return ui.create.control('wei','shu','wu','qun',function(link,node){
if(link=='全部'){ if(link=='全部'){
@ -16799,7 +16919,7 @@
input.innerHTML='无名玩家'; input.innerHTML='无名玩家';
} }
game.saveConfig('connect_nickname',input.innerHTML); game.saveConfig('connect_nickname',input.innerHTML);
game.saveConfig('connect_nickname',input.innerHTML,true); game.saveConfig('connect_nickname',input.innerHTML,'connect');
} }
} }
else{ else{
@ -19065,7 +19185,7 @@
}); });
var text=document.createElement('div'); var text=document.createElement('div');
text.style.width='194px'; text.style.width='194px';
text.style.height='104px'; text.style.height='124px';
text.style.padding='3px'; text.style.padding='3px';
text.style.borderRadius='2px'; text.style.borderRadius='2px';
text.style.boxShadow='rgba(0, 0, 0, 0.2) 0 0 0 1px'; text.style.boxShadow='rgba(0, 0, 0, 0.2) 0 0 0 1px';
@ -19074,22 +19194,22 @@
text.style.overflow='scroll'; text.style.overflow='scroll';
text.style.position='absolute'; text.style.position='absolute';
text.style.left='30px'; text.style.left='30px';
text.style.top='12px'; text.style.top='50px';
text.style.wordBreak='break-all'; text.style.wordBreak='break-all';
page.appendChild(text); page.appendChild(text);
var caption=ui.create.div('','输入命令',page); // var caption=ui.create.div('','输入命令',page);
caption.style.margin='6px'; // caption.style.margin='6px';
caption.style.position='absolute'; // caption.style.position='absolute';
caption.style.width='120px'; // caption.style.width='120px';
caption.style.top='129px'; // caption.style.top='129px';
caption.style.left='64px'; // caption.style.left='64px';
var text2=document.createElement('input'); var text2=document.createElement('input');
text2.style.width='200px'; text2.style.width='200px';
text2.style.height='20px'; text2.style.height='20px';
text2.style.padding='0'; text2.style.padding='0';
text2.style.position='absolute'; text2.style.position='absolute';
text2.style.top='162px'; text2.style.top='15px';
text2.style.left='30px'; text2.style.left='30px';
text2.style.resize='none'; text2.style.resize='none';
text2.style.border='none'; text2.style.border='none';
@ -21902,11 +22022,19 @@
} }
game.resume(); game.resume();
} }
if(game.online){
game.send('auto');
}
} }
else{ else{
ui.control.show(); ui.control.show();
_status.auto=false; _status.auto=false;
ui.auto.classList.remove('glow'); ui.auto.classList.remove('glow');
if(game.online){
game.send('unauto');
}
} }
}, },
wuxie:function(){ wuxie:function(){

View File

@ -37,7 +37,6 @@ window.noname_source_list=[
'game/source.js', 'game/source.js',
'game/update.js', 'game/update.js',
'layout/default/blur.css', 'layout/default/blur.css',
'layout/default/filter.css',
'layout/default/layout.css', 'layout/default/layout.css',
'layout/default/menu.css', 'layout/default/menu.css',
'layout/mobile/equip.css', 'layout/mobile/equip.css',

View File

@ -1,8 +1,8 @@
window.noname_update={ window.noname_update={
version:'1.8.2.2', version:'1.8.2.4',
changeLog:[ changeLog:[
'修复一个卡死问题', '投降按钮',
'联机预览版(身份模式,标准包)', '出牌进度条',
'新卡牌样式by @_游离感_ ', '修复若干卡死问题',
] ]
} }

View File

@ -1510,6 +1510,16 @@ div:hover>.wunature{
top:59px; top:59px;
} }
.timerbar>div{left: 25px;box-shadow:0px 1px 3px rgba(0,0,0,0.3);border-radius: 8px;height: 4px;width: 100px;}
.timerbar>div:first-child{background: rgba(255,255,255,0.6);}
.timerbar>div{top:9px;}
.timerbar>div:last-child{background: linear-gradient(#FFDA47, #CE0404);transition-timing-function: linear;}
/*.timerbar>div:last-child{background: linear-gradient(#FFFFFF,#F0F0F0);}
.timerbar[data-color="red"]>div:last-child{background: linear-gradient(#FF0000, #CE0404)}
.timerbar[data-color="blue"]>div:last-child{background: linear-gradient(#8EE0FA, #0F637E)}
.timerbar[data-color="green"]>div:last-child{background: linear-gradient(#7AFF00, #589103)}
.timerbar[data-color="purple"]>div:last-child{background: linear-gradient(#E247FF, #CE0404)}
.timerbar[data-color="orange"]>div:last-child{background: linear-gradient(#FFDA47, #CE0404)}*/
.player.selectable{ .player.selectable{
box-shadow: rgba(0, 0, 0, 0.2) 0 0 0 1px, rgba(0, 133, 255, 0.5) 0 0 5px, rgba(0, 133, 255, 0.6) 0 0 12px, rgba(0, 133, 255, 0.8) 0 0 15px; box-shadow: rgba(0, 0, 0, 0.2) 0 0 0 1px, rgba(0, 133, 255, 0.5) 0 0 5px, rgba(0, 133, 255, 0.6) 0 0 12px, rgba(0, 133, 255, 0.8) 0 0 15px;

View File

@ -4,26 +4,14 @@ mode.connect={
'step 0' 'step 0'
if(lib.config.reconnect_info){ if(lib.config.reconnect_info){
var info=lib.config.reconnect_info; var info=lib.config.reconnect_info;
game.onlineID=info[1];
game.connect(info[0],game.resume);
game.saveConfig('reconnect_info'); game.saveConfig('reconnect_info');
game.pause(); game.onlineID=info[1];
}
'step 1'
delete game.onlineID;
if(lib.config.reconnect_more){
var n=5; var n=5;
var connect=function(){ var connect=function(){
game.connect(lib.config.reconnect_more,function(success){ game.connect(info[0],function(success){
if(success){ if(!success&&n--){
game.saveConfig('reconnect_more');
}
else if(n--){
event.timeout=setTimeout(connect,1000); event.timeout=setTimeout(connect,1000);
} }
else{
game.saveConfig('reconnect_more');
}
}); });
}; };
event.timeout=setTimeout(connect,500); event.timeout=setTimeout(connect,500);

View File

@ -451,6 +451,17 @@ mode.identity={
} }
} }
}, },
checkOnlineResult:function(player){
if(game.zhu.isAlive()){
return (player.identity=='zhu'||player.identity=='zhong');
}
else if(game.players.length==1&&game.players[0].identity=='nei'){
return player.isAlive();
}
else{
return player.identity=='fan';
}
},
chooseCharacter:function(){ chooseCharacter:function(){
var next=game.createEvent('chooseCharacter',false); var next=game.createEvent('chooseCharacter',false);
next.showConfig=true; next.showConfig=true;
@ -1001,17 +1012,21 @@ mode.identity={
event.list.remove(game.zhu.name); event.list.remove(game.zhu.name);
event.list.remove(game.zhu.name2); event.list.remove(game.zhu.name2);
game.zhu.maxHp++; if(game.players.length>4){
game.zhu.hp++; game.zhu.maxHp++;
game.zhu.update(); game.zhu.hp++;
game.broadcast(function(zhu,name,name2){ game.zhu.update();
}
game.broadcast(function(zhu,name,name2,addMaxHp){
if(game.zhu!=game.me){ if(game.zhu!=game.me){
zhu.init(name,name2); zhu.init(name,name2);
} }
zhu.maxHp++; if(addMaxHp){
zhu.hp++; zhu.maxHp++;
zhu.update(); zhu.hp++;
},game.zhu,game.zhu.name,game.zhu.name2); zhu.update();
}
},game.zhu,game.zhu.name,game.zhu.name2,game.players.length>4);
var list=[]; var list=[];
var selectButton=(lib.configOL.double_character?2:1); var selectButton=(lib.configOL.double_character?2:1);
@ -1149,6 +1164,29 @@ mode.identity={
} }
setIdentity(this); setIdentity(this);
game.broadcast(setIdentity,this); game.broadcast(setIdentity,this);
if(!_status.over){
var giveup;
if(get.population('fan')+get.population('nei')==1){
for(var i=0;i<game.players.length;i++){
if(game.players[i].identity=='fan'||game.players[i].identity=='nei'){
giveup=game.players[i];break;
}
}
}
else if(get.population('zhong')+get.population('mingzhong')+get.population('nei')==0){
giveup=game.zhu;
}
if(giveup){
if(giveup==game.me){
ui.create.giveup();
}
else if(giveup.isOnline2()){
giveup.send(ui.create.giveup);
}
}
}
}, },
logAi:function(targets,card){ logAi:function(targets,card){
if(this.ai.shown==1) return; if(this.ai.shown==1) return;