From 9e9283ecaf102327e146079a10e8ea63ddf6318f Mon Sep 17 00:00:00 2001 From: Tipx-L <138244655+Tipx-L@users.noreply.github.com> Date: Thu, 19 Oct 2023 07:54:44 -0700 Subject: [PATCH] Make Kingdom War: Separatism online ready. --- game/game.js | 56 +++---- mode/brawl.js | 384 ----------------------------------------------- mode/guozhan.js | 36 +++-- mode/identity.js | 4 +- 4 files changed, 59 insertions(+), 421 deletions(-) diff --git a/game/game.js b/game/game.js index aa38dfbda..e6d60dc26 100644 --- a/game/game.js +++ b/game/game.js @@ -5589,6 +5589,9 @@ frequent:true, restart:true, }, + get connect_separatism(){ + return lib.mode.guozhan.config.separatism; + }, connect_initshow_draw:{ name:'首亮奖励', item:{ @@ -5679,6 +5682,13 @@ frequent:true, restart:true, }, + separatism:{ + name:'群雄割据', + init:false, + frequent:true, + restart:true, + intro:'开放不同势力组合,以优先亮出的武将牌作为自己的势力,双势力武将则使用列表的第一个势力' + }, initshow_draw:{ name:'首亮奖励', item:{ @@ -7258,11 +7268,6 @@ init:true, frequent:true }, - qunxionggeju:{ - name:'群雄割据', - init:true, - frequent:true - }, duzhansanguo:{ name:'毒战三国', init:true, @@ -7577,8 +7582,6 @@ }else if(newMessage.includes("has already been declared")){ messageName=newMessage.replace('SyntaxError: Identifier ', '').replace(' has already been declared', ''); newMessage=messageName +"变量已经被声明过,不能被重新声明"; - }else if(newMessage.includes("Invalid or unexpected token")){ - newMessage="查询无效或意外的标记,可能是字符串的引号不成对,错误使用了转义序列,字符串在多行中解析异常"; }else if(newMessage.includes("Duplicate parameter name not allowed in this context")) { newMessage="参数名不允许重复"; }else if(newMessage.includes("Unexpected reserved word")||newMessage.includes( @@ -11112,10 +11115,10 @@ } }, layout:function(layout,nosave){ - const previousTransitionDuration=document.body.style.transitionDuration; - document.body.style.transitionDuration='1s'; - const previousFilter=document.body.style.filter,previousWebkitFilter=document.body.style.webkitFilter; - document.body.style.filter=document.body.style.webkitFilter='brightness(0)'; + const previousTransitionDuration=document.documentElement.style.transitionDuration; + document.documentElement.style.transitionDuration='1s'; + const previousFilter=document.documentElement.style.filter,previousWebkitFilter=document.documentElement.style.webkitFilter; + document.documentElement.style.filter=document.documentElement.style.webkitFilter='brightness(0)'; if(layout=='default') layout='mobile'; if(!nosave) game.saveConfig('layout',layout); game.layout=layout; @@ -11226,14 +11229,14 @@ return new Promise(resolve=>setTimeout(resolve,500)); }).then(()=>{ ui.updatec(); - if(previousFilter) document.body.style.filter=previousFilter; - else document.body.style.removeProperty('filter'); - if(previousWebkitFilter) document.body.style.webkitFilter=previousWebkitFilter; - else document.body.style.removeProperty('-webkit-filter'); + if(previousFilter) document.documentElement.style.filter=previousFilter; + else document.documentElement.style.removeProperty('filter'); + if(previousWebkitFilter) document.documentElement.style.webkitFilter=previousWebkitFilter; + else document.documentElement.style.removeProperty('-webkit-filter'); return new Promise(resolve=>setTimeout(resolve,1000)); }).then(()=>{ - if(previousTransitionDuration) document.body.style.transitionDuration=previousTransitionDuration; - else document.body.style.removeProperty('transition-duration'); + if(previousTransitionDuration) document.documentElement.style.transitionDuration=previousTransitionDuration; + else document.documentElement.style.removeProperty('transition-duration'); }); }, background:function(){ @@ -42906,13 +42909,13 @@ player2.previousSeat=player.previousSeat; player2.nextSeat.previousSeat=player2; player2.previousSeat.nextSeat=player2; - const player3=player2.nextSeat; + let player3=player2.nextSeat; while(player3.isDead()){ player3=player3.nextSeat; } player3.previous=player2; player2.next=player3; - const player4=player2.previousSeat; + let player4=player2.previousSeat; while(player4.isDead()){ player4=player4.previousSeat; } @@ -52936,22 +52939,22 @@ //单个人物的宽度。这里要设置玩家的实际的宽度 const temporaryPlayer=ui.create.div('.player',ui.arena).hide(); const computedStyle=getComputedStyle(temporaryPlayer); - const scale=8/numberOfPlayers; + const scale=6/numberOfPlayers; //玩家顶部距离父容器上边缘的距离偏移的单位距离 - const oneThirdHeight=parseFloat(computedStyle.height)/3*scale; + const quarterHeight=parseFloat(computedStyle.height)/4*scale; const halfWidth=parseFloat(computedStyle.width)/2; temporaryPlayer.remove(); //列数,即假如8人场,除去自己后,上面7个人占7列 const columnCount=numberOfPlayers-1; - const percentage=100/numberOfPlayers; + const percentage=90/(columnCount-1); //仅当游戏人数大于8人,且玩家的座位号大于0时,设置玩家的位置。因为0号位是game.me在最下方,无需设置。 for(let ordinal=1;ordinal.player[data-position='${ordinal}']{`, - `left:calc(${percentage*(reversedOrdinal+1)}% - ${halfWidth}px);`, + `left:calc(${percentage*reversedOrdinal+5}% - ${halfWidth}px);`, `top:${top}px;`, `transform:scale(${scale});`, '}' @@ -58716,8 +58719,9 @@ default:return get.cnNumber(parseInt(config.number))+'人'+(config.double_character?'双将':'')+'身份'; } } - else if(config.mode=='guozhan'&&config.guozhan_mode!='normal'){ - switch(config.guozhan_mode){ + else if(config.mode=='guozhan'){ + if(config.separatism) return '群雄割据'; + if(config.guozhan_mode!='normal') switch(config.guozhan_mode){ case 'yingbian':return '应变国战'; case 'old':return '怀旧国战'; } diff --git a/mode/brawl.js b/mode/brawl.js index 020d2151b..8c80048b5 100644 --- a/mode/brawl.js +++ b/mode/brawl.js @@ -1143,377 +1143,6 @@ game.import('mode',function(lib,game,ui,get,ai,_status){ }, }, }, - qunxionggeju:{ - name:'群雄割据', - mode:'guozhan', - intro:[ - '开放不同势力组合,以优先亮出的武将牌作为自己的势力,双势力武将则使用列表的第一个势力', - ], - showcase:function(init){ - var node=this; - var list=[ - ['re_yuanshao','re_lidian'], - ['zhangliao','sunquan'], - ['xin_fazheng','sp_lvfan'], - ['sunjian','lvbu'], - ['jin_simashi','re_weiyan'], - ['guanyu','sunce'], - ['zhenji','sp_zhangjiao'], - ['guojia','sp_zhugeliang'], - ]; - list.randomSort(); - var func=function(){ - var card=ui.create.player(null,true); - var name=list.shift(); - card.init(name[0],name[1]); - card.node.marks.remove(); - card.node.count.remove(); - card.node.hp.remove(); - card.classList.remove('unseen'); - node.nodes.push(card); - card.style.position='absolute'; - card.style.zIndex=2; - card.style.transition='all 2s'; - var rand1=Math.round(Math.random()*100); - var rand2=Math.round(Math.random()*100); - var rand3=Math.round(Math.random()*40)-20; - card.style.left='calc('+rand1+'% - '+(rand1*1.5)+'px)'; - card.style.top='calc('+rand2+'% - '+(rand2*1.8)+'px)'; - card.style.transform='scale(0.8) rotate('+rand3+'deg)'; - node.appendChild(card); - ui.refresh(card); - }; - - var list2=['feilongduofeng','taipingyaoshu','dinglanyemingzhu']; - var func2=function(){ - var card=game.createCard(list2.shift(),'noclick'); - node.nodes.push(card); - card.style.position='absolute'; - card.style.zIndex=2; - card.style.transition='all 2s'; - var rand1=Math.round(Math.random()*100); - var rand2=Math.round(Math.random()*100); - var rand3=Math.round(Math.random()*40)-20; - card.style.left='calc('+rand1+'% - '+rand1+'px)'; - card.style.top='calc('+rand2+'% - '+rand2+'px)'; - card.style.transform='rotate('+rand3+'deg)'; - node.appendChild(card); - ui.refresh(card); - }; - if(init){ - node.nodes=[]; - } - else{ - while(node.nodes.length){ - node.nodes.shift().remove(); - } - } - for(var i=0;i<5;i++){ - func(); - } - for(var i=0;i<3;i++){ - func2(); - func(); - } - }, - init:function(){}, - content:{ - chooseCharacterBefore:function(){ - game.chooseCharacter=function(){ - var next=game.createEvent('chooseCharacter'); - next.showConfig=true; - next.addPlayer=true; - next.ai=function(player,list,back){ - var mainx=list[0]; - var vicex=list[1]; - if(get.guozhanReverse(mainx,vicex)){ - mainx=list[1]; - vicex=list[0]; - } - player.init(mainx,vicex,false); - if(back){ - list.remove(player.name1); - list.remove(player.name2); - for(var i=0;i'; - td.link=i-1; - seats.appendChild(td); - td.addEventListener(lib.config.touchscreen?'touchend':'click',function(){ - if(_status.dragged) return; - if(_status.justdragged) return; - if(_status.cheat_seat){ - _status.cheat_seat.classList.remove('bluebg'); - if(_status.cheat_seat==this){ - delete _status.cheat_seat; - return; - } - } - this.classList.add('bluebg'); - _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.add-setting')); - dialog.add(ui.create.div('.placeholder.add-setting')); - if(get.is.phoneLayout()) dialog.add(ui.create.div('.placeholder.add-setting')); - }; - var removeSetting=function(){ - var dialog=_status.event.dialog; - if(dialog){ - dialog.style.height=''; - delete dialog._scrollset; - var list=Array.from(dialog.querySelectorAll('.add-setting')); - while(list.length){ - list.shift().remove(); - } - ui.update(); - } - }; - event.addSetting=addSetting; - event.removeSetting=removeSetting; - - var chosen=lib.config.continue_name||[]; - game.saveConfig('continue_name'); - event.chosen=chosen; - - var i; - event.list=[]; - for(i in lib.character){ - if(i.indexOf('gz_shibing')==0) continue; - if(chosen.contains(i)) continue; - if(lib.filter.characterDisabled(i)) continue; - if(get.config('onlyguozhan')){ - if(!lib.characterPack.mode_guozhan[i]) continue; - if(get.is.jun(i)) continue; - } - if(lib.character[i][4].contains('hiddenSkill')) continue; - if(lib.character[i][2]==3||lib.character[i][2]==4||lib.character[i][2]==5) - event.list.push(i); - } - _status.characterlist=event.list.slice(0); - _status.yeidentity=[]; - event.list.randomSort(); - // var list=event.list.splice(0,parseInt(get.config('choice_num'))); - var list=event.list.randomRemove(parseInt(get.config('choice_num'))); - if(_status.auto){ - event.ai(game.me,list); - lib.init.onfree(); - } - else if(chosen.length){ - game.me.init(chosen[0],chosen[1],false); - lib.init.onfree(); - } - else{ - var dialog=ui.create.dialog('选择角色','hidden',[list,'character']); - if(get.config('change_identity')){ - addSetting(dialog); - } - var next=game.me.chooseButton(dialog,true,2).set('onfree',true); - next.filterButton=function(button){ - if(ui.dialog.buttons.length<=10){ - for(var i=0;i=8){ - addCharacter.disabled=true; - } return player; }; @@ -4711,12 +4333,6 @@ game.import('mode',function(lib,game,ui,get,ai,_status){ line9.style.display='none'; line9.style.marginTop='20px'; var resetStatus=function(all){ - if(line7.childElementCount>=8){ - addCharacter.disabled=true; - } - else{ - addCharacter.disabled=false; - } // editCode.disabled=false; saveButton.disabled=false; // exportButton.disabled=false; diff --git a/mode/guozhan.js b/mode/guozhan.js index 5a91b83c3..ed0f15a64 100644 --- a/mode/guozhan.js +++ b/mode/guozhan.js @@ -99,11 +99,13 @@ game.import('mode',function(lib,game,ui,get,ai,_status){ if(_status.brawl&&_status.brawl.submode){ _status.mode=_status.brawl.submode; } + if(get.config('separatism')) _status.separatism=true; } "step 1" if(_status.connectMode){ _status.mode=lib.configOL.guozhan_mode; if(!['normal','yingbian','old'].contains(_status.mode)) _status.mode='normal'; + if(lib.configOL.separatism) _status.separatism=true; //决定牌堆 switch(_status.mode){ case 'old':lib.card.list=lib.guozhanPile_old.slice(0);break; @@ -115,8 +117,9 @@ game.import('mode',function(lib,game,ui,get,ai,_status){ default:lib.card.list=lib.guozhanPile.slice(0);break; } game.fixedPile=true; - game.broadcastAll(function(mode){ + game.broadcastAll((mode,separatism)=>{ _status.mode=mode; + if(separatism) _status.separatism=true; if(mode=='yingbian'){ delete lib.translate.shuiyanqijunx_info_guozhan; } @@ -145,7 +148,7 @@ game.import('mode',function(lib,game,ui,get,ai,_status){ } } lib.characterReplace={}; - },_status.mode); + },_status.mode,_status.separatism); game.randomMapOL(); } else{ @@ -13504,6 +13507,7 @@ game.import('mode',function(lib,game,ui,get,ai,_status){ else{ num={mark:'标记',draw:'摸牌'}[lib.configOL.initshow_draw]; } + uiintro.add('
群雄割据:'+(lib.configOL.separatism?'开启':'关闭')); uiintro.add('
首亮奖励:'+num); uiintro.add('
珠联璧合:'+(lib.configOL.zhulian?'开启':'关闭')); uiintro.add('
出牌时限:'+lib.configOL.choose_timeout+'秒'); @@ -13585,7 +13589,10 @@ game.import('mode',function(lib,game,ui,get,ai,_status){ }, getVideoName:function(){ var str=get.translation(game.me.name1)+'/'+get.translation(game.me.name2); - var str2=get.cnNumber(parseInt(get.config('player_number')))+'人'+ + var str2=_status.separatism?get.modetrans({ + mode:lib.config.mode, + separatism:true + }):get.cnNumber(parseInt(get.config('player_number')))+'人'+ get.translation(lib.config.mode); if(game.me.identity=='ye'){ str2+=' - 野心家'; @@ -13689,6 +13696,7 @@ game.import('mode',function(lib,game,ui,get,ai,_status){ } } var filterChoice=function(name1,name2){ + if(_status.separatism) return true; var group1=lib.character[name1][1]; var group2=lib.character[name2][1]; var doublex=get.is.double(name1,true); @@ -13849,6 +13857,7 @@ game.import('mode',function(lib,game,ui,get,ai,_status){ } if(lib.character[button.link][4].contains('hiddenSkill')) return false; var filterChoice=function(name1,name2){ + if(_status.separatism) return true; var group1=lib.character[name1][1]; var group2=lib.character[name2][1]; var doublex=get.is.double(name1,true); @@ -14078,6 +14087,7 @@ game.import('mode',function(lib,game,ui,get,ai,_status){ } } var filterChoice=function(name1,name2){ + if(_status.separatism) return true; var group1=lib.character[name1][1]; var group2=lib.character[name2][1]; var doublex=get.is.double(name1,true); @@ -14113,13 +14123,21 @@ game.import('mode',function(lib,game,ui,get,ai,_status){ }).set('processAI',function(){ var buttons=_status.event.dialog.buttons; var filterChoice=function(name1,name2){ - if(get.is.double(name1)) return false; + if(_status.separatism) return true; var group1=lib.character[name1][1]; var group2=lib.character[name2][1]; - if(group1=='ye') return group2!='ye'; - var double=get.is.double(name2,true); - if(double) return double.contains(group1); - return group1==group2; + var doublex=get.is.double(name1,true); + if(doublex){ + var double=get.is.double(name2,true); + if(double) return doublex.some(group=>double.contains(group)); + return doublex.contains(group2); + } + else{ + if(group1=='ye') return group2!='ye'; + var double=get.is.double(name2,true); + if(double) return double.contains(group1); + return group1==group2; + } }; for(var i=0;i=Math.max(Math.round(get.totalPopulation()/2),3); + return game.roundNumber>=Math.max(Math.round(get.population()/2),3); } - if(event.name=='die') return game.dead.length>=Math.max(Math.round(get.totalPopulation()/3),2); + if(event.name=='die') return game.dead.length>=Math.max(Math.round(get.population()/3),2); } return false; },