自由选择座位、暂停时显示弃牌堆

This commit is contained in:
libccy 2015-05-01 14:16:03 +08:00
parent 6e7ca4e346
commit eae6e90d42
8 changed files with 214 additions and 35 deletions

View File

@ -134,6 +134,9 @@ card.extra={
},
chongzhu:true,
ai:{
wuxie:function(){
if(Math.random()<0.5) return 0;
},
basic:{
useful:4,
value:4,
@ -144,7 +147,7 @@ card.extra={
if(target.classList.contains('linked')) return 1;
if(ai.get.attitude(player,target)>=0) return -1;
for(var i=0;i<game.players.length;i++){
if(ai.get.attitude(player,game.players[i])<0&&
if(ai.get.attitude(player,game.players[i])<=-1&&
game.players[i]!=target&&!game.players[i].isLinked()){
return -1;
}

View File

@ -213,6 +213,7 @@ window.config={
volumn_background:8,
volumn_audio:8,
auto_popped:true,
auto_skill:true,
auto_confirm:true,
enable_drag:true,
@ -250,7 +251,6 @@ window.config={
paused:false,
title:false,
right_sidebar:false,
hide_history:false,
modeconfig:false,
gameconfig:false,

View File

@ -37,9 +37,10 @@ window.play={};
'游戏操作':'<ul><li>长按/鼠标悬停/右键单击(需在设置中开启)显示信息<li>触屏模式中双指点击切换暂停<li>键盘快捷键<br>'+
'<table><tr><td>a<td>切换托管<tr><td>c<td>打开设置<tr><td>w<td>切换不询问无懈<tr><td>▭<td>暂停</ul>'
},
setPopped:function(node,func,width){
setPopped:function(node,func,width,height){
node._poppedfunc=func;
node._poppedwidth=width;
node._poppedheight=height;
node.addEventListener(lib.config.touchscreen?'touchstart':'mouseenter',ui.click.hoverpopped);
},
placePoppedDialog:function(dialog,e){
@ -6538,15 +6539,14 @@ window.play={};
ui.sidebar=ui.create.div('#sidebar');
ui.sidebar3=ui.create.div('#sidebar3');
ui.canvas=document.createElement('canvas');
ui.arena.appendChild(ui.canvas);
ui.canvas.id='canvas';
ui.ctx=ui.canvas.getContext('2d');
lib.config.hide_history=false;
if(lib.config.right_sidebar) ui.sidebar.classList.add('right');
ui.config=ui.create.div('#sidebar2.content');
ui.config.listen(function(e){
e.stopPropagation()
e.stopPropagation();
if(_status.choosing){
if(_status.choosing.expand) _status.choosing.expand=false;
else{
@ -6556,6 +6556,7 @@ window.play={};
delete _status.choosing;
}
}
return false;
});
ui.config.oncontextmenu=function(e){
e.stopPropagation();
@ -6569,6 +6570,8 @@ window.play={};
ui.sidebar.style.WebkitOverflowScrolling='touch';
ui.config.style.WebkitOverflowScrolling='touch';
if(lib.config.right_sidebar){
ui.sidebar.classList.add('right');
ui.sidebar3.classList.add('left');
ui.config.classList.add('right');
}
var folditems=[];
@ -7261,14 +7264,14 @@ window.play={};
ui.replay=ui.create.system('重来',game.reload,true);
ui.pause=ui.create.system('历史',ui.click.pause);
if(!lib.config.touchscreen){
lib.setPopped(ui.pause,ui.click.pausehistory,220);
lib.setPopped(ui.pause,ui.click.pausehistory,220,400);
}
if(!lib.config.show_pause){
ui.pause.style.display='none';
}
ui.config2=ui.create.system('选项',ui.click.config);
if(!lib.config.touchscreen){
lib.setPopped(ui.config2,ui.click.pauseconfig,220);
lib.setPopped(ui.config2,ui.click.pauseconfig,170);
}
ui.wuxie=ui.create.system('不询问无懈',ui.click.wuxie,true);
ui.auto=ui.create.system('托管',ui.click.auto);
@ -7349,9 +7352,14 @@ window.play={};
node2.innerHTML='已暂停';
node2.listen(function(){
_status.clicked=true;
lib.config.hide_history=!lib.config.hide_history;
if(lib.config.hide_history) ui.sidebar.hide();
else ui.sidebar.show();
if(ui.sidebar.classList.contains('hidden')){
ui.sidebar.show();
ui.sidebar3.show();
}
else{
ui.sidebar.hide();
ui.sidebar3.hide();
}
});
return node;
},
@ -7591,6 +7599,7 @@ window.play={};
if(!lib.config.auto_popped) return;
if(!ui.sidebar.childNodes.length) return;
var uiintro=ui.create.dialog('hidden');
uiintro.style.maxHeight='400px';
uiintro.add(ui.sidebar);
return uiintro;
},
@ -7598,7 +7607,18 @@ window.play={};
if(!lib.config.auto_popped) return;
if(!ui.config.childNodes.length) return;
var uiintro=ui.create.dialog('hidden');
uiintro.add(ui.config);
var node=ui.create.div('.newgame');
var list=[['identity','身份'],['guozhan','国战'],['versus','对决']];
for(var i=0;i<list.length;i++){
var div=ui.create.div(list[i][0]==lib.config.mode?'.bordered':'',node);
div.innerHTML=list[i][1];
div.link=list[i][0];
div.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
game.saveConfig('mode',this.link);
game.reload();
});
}
uiintro.add(node);
return uiintro;
},
volumn:function(){
@ -7685,7 +7705,9 @@ window.play={};
ui.window.appendChild(uiintro);
var width=this._poppedwidth||330;
uiintro.style.width=width+'px';
uiintro.style.height=Math.min(ui.window.offsetHeight-260,uiintro.content.scrollHeight)+'px';
var height=this._poppedheight||uiintro.content.scrollHeight;
uiintro.style.height=Math.min(ui.window.offsetHeight-260,height)+'px';
uiintro.style.top='50px';
var left=this.parentNode.offsetLeft+this.offsetLeft+this.offsetWidth/2-width/2;
if(left<10){
@ -8472,7 +8494,14 @@ window.play={};
ui.system.hide();
game.pause2();
var node=ui.create.pause().animate('start');
ui.sidebar3.innerHTML='';
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);
}
node.appendChild(ui.sidebar);
node.appendChild(ui.sidebar3);
ui.arena.classList.add('paused');
},
resume:function(e){
@ -8622,13 +8651,7 @@ window.play={};
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 if(dialog.querySelector('table')&&!get.config('change_identity')){
dialog.querySelector('table').previousSibling.remove();
dialog.querySelector('table').nextSibling.remove();
dialog.querySelector('table').nextSibling.remove();
dialog.querySelector('table').nextSibling.remove();
dialog.querySelector('table').remove();
}
else _status.event.parent.removeSetting(dialog);
ui.update();
},
change_choice:function(bool){
@ -8888,6 +8911,7 @@ window.play={};
if(bool){
ui.config.classList.add('right');
ui.sidebar.classList.add('right');
ui.sidebar3.classList.add('left');
ui.arena.classList.add('left');
ui.arena.classList.remove('right');
ui.system.appendChild(ui.system1);
@ -8895,6 +8919,7 @@ window.play={};
else{
ui.config.classList.remove('right');
ui.sidebar.classList.remove('right');
ui.sidebar3.classList.remove('left');
ui.arena.classList.add('right');
ui.arena.classList.remove('left');
ui.system.appendChild(ui.system2);

View File

@ -30,12 +30,15 @@ table{table-layout: fixed;}
#system>div>div{position: relative;padding-top: 6px;padding-bottom: 6px;padding-left: 8px;padding-right: 8px;text-align: center;margin:4px}
#paused,#click{left: 0;top:0;width: 100%;height: 100%;z-index: 5;}
#paused2{font-size: 30px;top:calc(50% - 17px);left:calc(50% - 45px);}
#sidebar,#sidebar2{left: 0;top: 0;width: 200px;height: calc(100% - 40px);text-align: left;padding: 20px;overflow-y: scroll;z-index: 6;}
#sidebar.right{left:calc(100% - 220px);}
#sidebar.right,#sidebar2.right{left: calc(100% - 240px);}
#sidebar,#sidebar2,#sidebar3{
left: 0;top: 0;width: 200px;height: calc(100% - 40px);text-align: left;padding: 20px;overflow-y: scroll;z-index: 6;
}
#sidebar3{text-align:right}
#paused>#sidebar.right,#sidebar2.right,#sidebar3{left: calc(100% - 240px);}
#sidebar3.left{left:0;text-align:left;}
.dialog.popped #sidebar,
.dialog.popped #sidebar2{padding:0;}
#sidebar>div{margin: 10px;position: relative;display: block;min-height: 5px;}
#sidebar>div,#sidebar3>div{margin: 10px;position: relative;display: block;min-height: 5px;}
#scrollzone1{left: 0;}
#scrollzone2{left: calc(50% - 140px);}
#scrollzone3{right: calc(50% - 140px);}
@ -142,7 +145,7 @@ margin-bottom: 5px;
.content>.placeholder.slim{margin:1px;}
.content>.placeholder.removing{margin-top: -13px;}
.content{display: block;width: 100%;}
.dialog:not('.popped') .content>.config{
.dialog:not(.popped) .content>.config{
width:200px;
left:0;
margin-left: 20px;

View File

@ -362,7 +362,6 @@
.card[data-position='0']{top:calc(100% - 130px);left:calc(50% - 52px);}
.popup[data-position='0']{top:calc(100% - 206px);left:calc(50% - 61px);}
#me,#mebg{top:calc(100% - 150px);}
#control{top: calc(200% / 3 - 10px);}
#handcards1,#handcards2{width: calc(50% - 95px);height: 127px;padding: 10px;}
#handcards2{left: calc(50% + 75px);}
.dialog{
@ -378,7 +377,13 @@
.dialog.removing{
top:auto;
}
#control{z-index:5}
#control{
z-index:5;
top:auto;
bottom:190px;
width: calc(100% - 300px);
left:150px;
}
.popup{z-index:6}
.dialog.scroll1,
.dialog.scroll2{
@ -394,6 +399,23 @@
height:100%;
top:0;
}
.newgame{
width:150px;
display:flex;
}
.newgame>div{
padding-left:5px;
padding-right:5px;
padding-top:3px;
padding-bottom:3px;
position:relative;
margin:auto;
border-radius:4px;
}
.bordered{
border:1px solid white;
box-shadow:black 0 0 2px;
}
@media screen and (min-width: 1150px) {
.dialog{width: 630px;left: calc(50% - 315px);}

View File

@ -9,7 +9,6 @@ mode.guozhan={
"step 1"
if(lib.storage.test){
_status.auto=true;
// ui.auto.innerHTML='手动';
ui.auto.classList.add('glow');
}
game.chooseCharacter();
@ -21,7 +20,21 @@ mode.guozhan={
}
console.log(str);
}
var player=game.players[Math.floor(Math.random()*game.players.length)];
var player;
if(_status.cheat_seat){
var seat=_status.cheat_seat.link;
if(seat==0){
player=game.me;
}
else{
player=game.players[game.players.length-seat];
}
if(!player) player=game.me;
delete _status.cheat_seat;
}
else{
player=game.players[Math.floor(Math.random()*game.players.length)];
}
event.trigger('gameStart');
game.gameDraw(player);
if(get.config('ai_identity')){
@ -32,6 +45,12 @@ mode.guozhan={
game.players[i].ai.shown=0;
}
}
for(var i=0;i<game.players.length;i++){
game.players[i].name='unknown'+get.distance(player,game.players[i],'absolute');
if(game.players[i]==game.me){
lib.translate[game.players[i].name]+='(你)';
}
}
game.phaseLoop(player);
}
},
@ -82,7 +101,52 @@ mode.guozhan={
}
next.content=function(){
"step 0"
// ui.auto.hide();
var addSetting=function(dialog){
dialog.add('选择座位');
var seats=document.createElement('table');
seats.style.margin='0 auto';
seats.style.maxWidth='490px';
var tr=document.createElement('tr');
seats.appendChild(tr);
for(var i=1;i<=game.players.length;i++){
var td=document.createElement('td');
tr.appendChild(td);
td.style.width='40px';
td.style.fontSize='18px';
td.innerHTML=get.cnNumber(i,true);
td.link=i-1;
td.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
if(_status.dragged) return;
if(_status.cheat_seat){
_status.cheat_seat.classList.remove('thundertext');
}
this.classList.add('thundertext');
_status.cheat_seat=this;
});
}
dialog.content.appendChild(seats);
if(game.me==game.zhu){
seats.previousSibling.style.display='none';
seats.style.display='none';
}
dialog.add(ui.create.div('.placeholder'));
dialog.add(ui.create.div('.placeholder'));
dialog.add(ui.create.div('.placeholder'));
};
var removeSetting=function(){
var dialog=_status.event.dialog;
if(dialog.querySelector('table')&&!get.config('change_identity')){
dialog.querySelector('table').previousSibling.remove();
dialog.querySelector('table').nextSibling.remove();
dialog.querySelector('table').nextSibling.remove();
dialog.querySelector('table').nextSibling.remove();
dialog.querySelector('table').remove();
}
};
event.addSetting=addSetting;
event.removeSetting=removeSetting;
var i;
event.list=[];
for(i in lib.character){
@ -99,6 +163,9 @@ mode.guozhan={
}
else{
var dialog=ui.create.dialog('选择角色',[list,'character']);
if(get.config('change_identity')){
addSetting(dialog);
}
var next=game.me.chooseButton(dialog,true,2);
next.filterButton=function(button){
if(ui.selected.buttons.length==0) return true;
@ -286,7 +353,6 @@ mode.guozhan={
for(var i=0;i<game.players.length;i++){
game.players[i].classList.add('unseen');
game.players[i].classList.add('unseen2');
// game.players[i].node.identity.style.background='none';
if(game.players[i]!=game.me){
game.players[i].node.identity.firstChild.innerHTML='猜';
game.players[i].node.identity.dataset.color='unknown';
@ -295,7 +361,7 @@ mode.guozhan={
game.players[i].group='unknown';
game.players[i].sex='unknown';
game.players[i].name1=game.players[i].name;
game.players[i].name='unknown'+game.players[i].dataset.position;
game.players[i].name='unknown';
game.players[i].identity='unknown';
for(var j=0;j<game.players[i].hiddenSkills.length;j++){
var ifo=get.info(game.players[i].hiddenSkills[j]);
@ -315,7 +381,6 @@ mode.guozhan={
}
}
}
// ui.auto.show();
}
},
},
@ -338,6 +403,7 @@ mode.guozhan={
}
},
translate:{
change_identity_config:'自由选择座位',
guozhan_mode:'国战',
ye:'野',
unknown:'无名氏',
@ -739,6 +805,7 @@ mode.guozhan={
player_number:true,
initshow_draw:true,
free_choose:true,
change_identity:true,
change_choice:true,
change_card:true,
swap:true,

View File

@ -211,9 +211,10 @@ mode.identity={
var list3=[];
var identityList=lib.config.mode_config.identity.identity[game.players.length-2].slice(0);
var addSetting=function(dialog){
dialog.add('更换身份');
dialog.add('选择身份');
var table=document.createElement('table');
table.style.margin='0 auto';
table.style.maxWidth='500px';
var tr=document.createElement('tr');
table.appendChild(tr);
var list=['random','zhu','zhong','nei','fan'];
@ -223,6 +224,9 @@ mode.identity={
td.style.width='40px';
td.style.fontSize='18px';
td.link=list[i];
if(td.link===game.me.identity){
td.classList.add('thundertext');
}
td.innerHTML=get.translation(list[i]+'2');
td.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
if(_status.dragged) return;
@ -243,11 +247,63 @@ mode.identity={
});
}
dialog.content.appendChild(table);
dialog.add('选择座位');
var seats=document.createElement('table');
seats.style.margin='0 auto';
seats.style.maxWidth='490px';
var tr=document.createElement('tr');
seats.appendChild(tr);
for(var i=2;i<=game.players.length;i++){
var td=document.createElement('td');
tr.appendChild(td);
td.style.width='40px';
td.style.fontSize='18px';
td.innerHTML=get.cnNumber(i,true);
td.link=i-1;
if(get.distance(game.zhu,game.me,'absolute')===i-1){
td.classList.add('thundertext');
}
td.addEventListener(lib.config.touchscreen?'touchend':'click',function(){
if(_status.dragged) return;
if(get.distance(game.zhu,game.me,'absolute')==this.link) return;
var current=this.parentNode.querySelector('.thundertext');
if(current){
current.classList.remove('thundertext');
}
this.classList.add('thundertext');
for(var i=0;i<game.players.length;i++){
if(get.distance(game.players[i],game.me,'absolute')==this.link){
game.swapSeat(game.zhu,game.players[i],false);return;
}
}
});
}
dialog.content.appendChild(seats);
if(game.me==game.zhu){
seats.previousSibling.style.display='none';
seats.style.display='none';
}
dialog.add(ui.create.div('.placeholder'));
dialog.add(ui.create.div('.placeholder'));
dialog.add(ui.create.div('.placeholder'));
};
var removeSetting=function(){
var dialog=_status.event.dialog;
if(dialog.querySelector('table')&&!get.config('change_identity')){
dialog.querySelector('table').previousSibling.remove();
dialog.querySelector('table').nextSibling.remove();
dialog.querySelector('table').nextSibling.remove();
dialog.querySelector('table').nextSibling.remove();
dialog.querySelector('table').nextSibling.remove();
dialog.querySelector('table').nextSibling.remove();
dialog.querySelector('table').remove();
}
};
event.addSetting=addSetting;
event.removeSetting=removeSetting;
event.list=[];
for(i=0;i<identityList.length;i++){
identityList.sort(lib.sort.random);
@ -756,9 +812,9 @@ mode.identity={
ban_weak:true,
enhance_zhu:true,
free_choose:true,
change_identity:true,
change_choice:true,
change_card:true,
change_identity:true,
dierestart:true,
swap:true,
revive:true,

View File

@ -62,3 +62,6 @@ html{
color:rgb(77, 60, 51);
text-shadow:none;
}
.bordered{
border:1px solid rgba(255, 255, 255,0.5);
}