From 4faf7d142e11bc7ba34dceb069b0b98769640b7d Mon Sep 17 00:00:00 2001 From: adeFuLoDgu <64475795+adeFuLoDgu@users.noreply.github.com> Date: Sun, 27 Oct 2024 22:37:11 +0800 Subject: [PATCH] Fix connect mode. --- card/yunchou.js | 16 ++ .../MVP\346\211\251\345\261\225/extension.js" | 244 +++++++++--------- .../extension.js" | 62 ++--- game/config.js | 2 +- noname/game/index.js | 2 +- noname/library/element/player.js | 29 +++ noname/ui/create/index.js | 2 + 7 files changed, 192 insertions(+), 165 deletions(-) diff --git a/card/yunchou.js b/card/yunchou.js index 3eaa845b5e..149232f05e 100644 --- a/card/yunchou.js +++ b/card/yunchou.js @@ -45,6 +45,15 @@ game.import("card", function () { dialog.videoId = lib.status.videoId++; game.addVideo("cardDialog", null, ["调兵遣将", get.cardsInfo(cards), dialog.videoId]); event.getParent().preResult = dialog.videoId; + game.broadcast( + function (cards, id) { + var dialog = ui.create.dialog("调兵遣将", cards, true); + _status.dieClose.push(dialog); + dialog.videoId = id; + }, + cards, + dialog.videoId + ); }, content: function () { "step 0"; @@ -144,6 +153,13 @@ game.import("card", function () { var dialog = event.dialog; dialog.close(); _status.dieClose.remove(dialog); + game.broadcast(function (id) { + var dialog = get.idDialog(id); + if (dialog) { + dialog.close(); + _status.dieClose.remove(dialog); + } + }, event.preResult); game.addVideo("cardDialog", null, event.preResult); }, ai: { diff --git "a/extension/MVP\346\211\251\345\261\225/extension.js" "b/extension/MVP\346\211\251\345\261\225/extension.js" index 422faa6dcf..089ae878d7 100644 --- "a/extension/MVP\346\211\251\345\261\225/extension.js" +++ "b/extension/MVP\346\211\251\345\261\225/extension.js" @@ -6,109 +6,111 @@ game.import("extension", function (lib, game, ui, get, ai, _status) { precontent: function (config) { "use strict;" lib.onover.push(resultbool=>{ - var 手杀MVP=function (){ - if(_status.showShoushaMvp) return false; - _status.showShoushaMvp=true; - setTimeout(item=>{ - var dialog=Array.from(ui.arena.querySelectorAll(".dialog")); - dialog.forEach(value => value.hide()); - game.playAudio('..', 'extension', 'MVP扩展','images/asqx.mp3'); - var players=game.players.slice(0); - game.players=game.players.concat(game.dead); - if(!_status.showShouSha局势){ - game.players.forEach(value=>{ - if(game.dead.includes(value)){ - value.局势分数-=20; - } - value.getEnemies().forEach(current=>{ - if(game.dead.includes(current)||current.isDead()){ - value.局势分数+=2; + game.broadcastAll(function(){ + var 手杀MVP=function (){ + if(_status.showShoushaMvp) return false; + _status.showShoushaMvp=true; + setTimeout(item=>{ + var dialog=Array.from(ui.arena.querySelectorAll(".dialog")); + dialog.forEach(value => value.hide()); + game.playAudio('..', 'extension', 'MVP扩展','images/asqx.mp3'); + var players=game.players.slice(0); + game.players=game.players.concat(game.dead); + if(!_status.showShouSha局势){ + game.players.forEach(value=>{ + if(game.dead.includes(value)){ + value.局势分数-=20; } + value.getEnemies().forEach(current=>{ + if(game.dead.includes(current)||current.isDead()){ + value.局势分数+=2; + } + }) + value.getFriends().forEach(current=>{ + if(current.isDead()||game.dead.includes(current)) + value.局势分数-=2; + }) }) - value.getFriends().forEach(current=>{ - if(current.isDead()||game.dead.includes(current)) - value.局势分数-=2; - }) - }) - } - _status.showShouSha局势=true; - game.players=players; - /** - * 冒泡排序 - * @param arr - * @param len - */ - var sort=function (arr){ - var temp, len=arr.length; - var i, j; - for (i=0; i arr[j+1].mvpCount) { /* 相邻元素比较,若逆序则交换(升序为左大于右,降序反之) */ - temp = arr[j]; - arr[j] = arr[j+1]; - arr[j+1] = temp; + } + _status.showShouSha局势=true; + game.players=players; + /** + * 冒泡排序 + * @param arr + * @param len + */ + var sort=function (arr){ + var temp, len=arr.length; + var i, j; + for (i=0; i arr[j+1].mvpCount) { /* 相邻元素比较,若逆序则交换(升序为左大于右,降序反之) */ + temp = arr[j]; + arr[j] = arr[j+1]; + arr[j+1] = temp; + } } + return arr; } - return arr; - } - var sorts=sort(game.players.concat(game.dead)).reverse(); - var player=sorts[0]; - var popuperContainer=ui.create.div('.popup-container',{background:"rgb(0,0,0,.7)"},ui.window); - popuperContainer.addEventListener('click',event=>{ - event.stopPropagation(); - popuperContainer.delete(200); - dialog.forEach(value=>value.show()); - _status.showShoushaMvp=false; - }); - var skills = player.skills.filter(value => lib.skill[value].audio); - skills.length&&game.trySkillAudio(skills.randomGet(),player,true); - var qycontainer=ui.create.div('.qy-mvp-container',popuperContainer); + var sorts=sort(game.players.concat(game.dead)).reverse(); + var player=sorts[0]; + var popuperContainer=ui.create.div('.popup-container',{background:"rgb(0,0,0,.7)"},ui.window); + popuperContainer.addEventListener('click',event=>{ + event.stopPropagation(); + popuperContainer.delete(200); + dialog.forEach(value=>value.show()); + _status.showShoushaMvp=false; + }); + var skills = player.skills.filter(value => lib.skill[value].audio); + skills.length&&game.trySkillAudio(skills.randomGet(),player,true); + var qycontainer=ui.create.div('.qy-mvp-container',popuperContainer); - var backgroundRight=ui.create.div('.qy-mvp-piaodai-right',qycontainer); - var container=ui.create.div('.qy-center-container',qycontainer); - var backgroundLeft=ui.create.div('.qy-mvp-piaodai-left',qycontainer); + var backgroundRight=ui.create.div('.qy-mvp-piaodai-right',qycontainer); + var container=ui.create.div('.qy-center-container',qycontainer); + var backgroundLeft=ui.create.div('.qy-mvp-piaodai-left',qycontainer); - var avatarbox=ui.create.div('.qy-mvp-avatarbox',container); - if(navigator.userAgent.match(/(Android|iPhone|SymbianOS|Windows Phone|iPad|iPod)/i)!==null){ - avatarbox.css({ - height: '120%', - top: '-4%', - }); - } - var avatarborder=ui.create.div('.qy-mvp-avatarborder',avatarbox); - avatarborder.dataset.name=get.translation(player.name); - avatarborder.setBackgroundImage(`extension/MVP扩展/images/border_${player.group}.png`); - var image=new Image(); - image.src=`${lib.assetURL}extension/MVP扩展/images/border_${player.group}.png`; - image.onerror=function (){ - avatarborder.setBackgroundImage(`extension/MVP扩展/images/border_qun.png`); - } - var avatar=ui.create.div('.qy-mvp-avatar',avatarbox); - avatar.style.backgroundImage=player.node.avatar.style.backgroundImage; - var qyInfo=ui.create.div('.qy-mvp-qyInfo',container); - ui.create.div('.qy-mvp-title',qyInfo); - var qycenter=ui.create.div('.qy-mvp-center',qyInfo); - var qyIcon=ui.create.div('.qy-mvp-icon',qycenter); - var qyPlayerInfo=ui.create.div('.qy-player-info',qycenter); - ui.create.div(qyPlayerInfo,'.qy-mvp-name-title','玩家昵称'); - var nickname=ui.create.div('.qy-mvp-player-nickname',qyPlayerInfo,player===game.me?lib.config.connect_nickname:get.translation(player.name)); - if(game.me===player) ui.create.node('img',nickname).src=lib.assetURL+'extension/MVP扩展/images/mvp_me_tag.png'; - ui.create.div(qyPlayerInfo,'.qy-mvp-name-title',`技术分:${player.mvpCount||0}`); - var qyScoreInfo=ui.create.div('.qy-mvp-scoreInfo',qyInfo); - var table=ui.create.node('table',qyScoreInfo,{width:"100%"}); - var list=['攻击分数','治疗分数','辅助分数','局势分数','惩罚扣分']; - list.forEach(value => { - var tr=ui.create.node('tr',table); - tr.style.colo='rgb(234, 138, 76)'; - var td=ui.create.node('td',tr,value); - var num=(player[value]||0); - var num2=(sorts[1][value]); - td=ui.create.node('td',tr).innerHTML=num+(num-num2>=30?'(遥遥领先)':''); + var avatarbox=ui.create.div('.qy-mvp-avatarbox',container); + if(navigator.userAgent.match(/(Android|iPhone|SymbianOS|Windows Phone|iPad|iPod)/i)!==null){ + avatarbox.css({ + height: '120%', + top: '-4%', + }); + } + var avatarborder=ui.create.div('.qy-mvp-avatarborder',avatarbox); + avatarborder.dataset.name=get.translation(player.name); + avatarborder.setBackgroundImage(`extension/MVP扩展/images/border_${player.group}.png`); + var image=new Image(); + image.src=`${lib.assetURL}extension/MVP扩展/images/border_${player.group}.png`; + image.onerror=function (){ + avatarborder.setBackgroundImage(`extension/MVP扩展/images/border_qun.png`); + } + var avatar=ui.create.div('.qy-mvp-avatar',avatarbox); + avatar.style.backgroundImage=player.node.avatar.style.backgroundImage; + var qyInfo=ui.create.div('.qy-mvp-qyInfo',container); + ui.create.div('.qy-mvp-title',qyInfo); + var qycenter=ui.create.div('.qy-mvp-center',qyInfo); + var qyIcon=ui.create.div('.qy-mvp-icon',qycenter); + var qyPlayerInfo=ui.create.div('.qy-player-info',qycenter); + ui.create.div(qyPlayerInfo,'.qy-mvp-name-title','玩家昵称'); + var nickname=ui.create.div('.qy-mvp-player-nickname',qyPlayerInfo,player===game.me?lib.config.connect_nickname:get.translation(player.name)); + if(game.me===player) ui.create.node('img',nickname).src=lib.assetURL+'extension/MVP扩展/images/mvp_me_tag.png'; + ui.create.div(qyPlayerInfo,'.qy-mvp-name-title',`技术分:${player.mvpCount||0}`); + var qyScoreInfo=ui.create.div('.qy-mvp-scoreInfo',qyInfo); + var table=ui.create.node('table',qyScoreInfo,{width:"100%"}); + var list=['攻击分数','治疗分数','辅助分数','局势分数','惩罚扣分']; + list.forEach(value => { + var tr=ui.create.node('tr',table); + tr.style.colo='rgb(234, 138, 76)'; + var td=ui.create.node('td',tr,value); + var num=(player[value]||0); + var num2=(sorts[1][value]); + td=ui.create.node('td',tr).innerHTML=num+(num-num2>=30?'(遥遥领先)':''); + }) }) - }) - } - ui.create.control("手杀MVP",手杀MVP); - 手杀MVP(); + } + ui.create.control("手杀MVP",手杀MVP); + 手杀MVP(); + }); }); ['攻击分数','治疗分数','辅助分数','惩罚扣分'].forEach(value=>{ HTMLDivElement.prototype[value]=0; @@ -144,16 +146,18 @@ game.import("extension", function (lib, game, ui, get, ai, _status) { return get.attitude(event.source, event.player) < 0; }, content:function (){ - if (event.triggername==='damageSource') { - if (get.attitude(trigger.source,trigger.player)<0||trigger.source.identity == 'nei') trigger.num>5?trigger.source.攻击分数+=15:trigger.source.攻击分数+=3*trigger.num; - }else if(trigger.card){ - if (get.tag({name: trigger.card.name}, 'damage')) - player.攻击分数+=2 - if(trigger.card.name==='wuxie') - player.辅助分数+=2; - if((get.info(trigger.card).selectTarget===-1||get.info(trigger.card).selectTarget>1)&&(!get.info(trigger.card).toself&&get.type(trigger.card)==='trick')) - player.辅助分数+=1; - } + game.broadcastAll(function(event, trigger, player){ + if (event.triggername==='damageSource') { + if (get.attitude(trigger.source,trigger.player)<0||trigger.source.identity == 'nei') trigger.num>5?trigger.source.攻击分数+=15:trigger.source.攻击分数+=3*trigger.num; + }else if(trigger.card){ + if (get.tag({name: trigger.card.name}, 'damage')) + player.攻击分数+=2 + if(trigger.card.name==='wuxie') + player.辅助分数+=2; + if((get.info(trigger.card).selectTarget===-1||get.info(trigger.card).selectTarget>1)&&(!get.info(trigger.card).toself&&get.type(trigger.card)==='trick')) + player.辅助分数+=1; + } + }, event, trigger, player); } } lib.skill['_qy-mvp-effect2']={ @@ -178,8 +182,10 @@ game.import("extension", function (lib, game, ui, get, ai, _status) { } }, content:function(){ - if(event.triggername=='gainEnd') trigger.player.辅助分数+=1*trigger.cards.length; - if(event.triggername=='discardEnd') trigger.source.辅助分数+=1*trigger.cards.length; + game.broadcastAll(function(event, trigger){ + if(event.triggername=='gainEnd') trigger.player.辅助分数+=1*trigger.cards.length; + if(event.triggername=='discardEnd') trigger.source.辅助分数+=1*trigger.cards.length; + }, event, trigger); }, } lib.skill['_qy-mvp-effect3']={ @@ -195,7 +201,9 @@ game.import("extension", function (lib, game, ui, get, ai, _status) { return event.player.getFriends().includes(event.source)||event.player==event.source; }, content:function(){ - trigger.num>5?trigger.source.治疗分数+=10:trigger.source.治疗分数+=2*trigger.num; + game.broadcastAll(function(trigger){ + trigger.num>5?trigger.source.治疗分数+=10:trigger.source.治疗分数+=2*trigger.num; + }, trigger); }, } lib.skill['_qy-mvp-effect4']={ @@ -209,16 +217,18 @@ game.import("extension", function (lib, game, ui, get, ai, _status) { return (event.source&&event.source.isIn()); }, content:function(){ - if(trigger.player.getFriends().includes(trigger.source)){ - trigger.source.惩罚扣分+=5; - if(trigger.source.identity == 'nei'&&trigger.player.identity!='zhu'){ - trigger.source.惩罚扣分-=5; + game.broadcastAll(function(trigger){ + if(trigger.player.getFriends().includes(trigger.source)){ + trigger.source.惩罚扣分+=5; + if(trigger.source.identity == 'nei'&&trigger.player.identity!='zhu'){ + trigger.source.惩罚扣分-=5; + trigger.source.攻击分数+=3; + } + } + if(trigger.player.getEnemies().includes(trigger.source)){ trigger.source.攻击分数+=3; } - } - if(trigger.player.getEnemies().includes(trigger.source)){ - trigger.source.攻击分数+=3; - } + }, trigger); }, } lib.init.css(lib.assetURL+'extension/MVP扩展','extension'); diff --git "a/extension/\345\215\201\345\221\250\345\271\264UI/extension.js" "b/extension/\345\215\201\345\221\250\345\271\264UI/extension.js" index 3c4c63f776..ce569c3970 100644 --- "a/extension/\345\215\201\345\221\250\345\271\264UI/extension.js" +++ "b/extension/\345\215\201\345\221\250\345\271\264UI/extension.js" @@ -185,21 +185,6 @@ game.import('extension', async function(lib, game, ui, get, ai, _status){ }; var Game = (function(Game){ - Game.phaseLoop = function (player) { - game.broadcastAll(function(firstAction){ - var cur; - for (var i = 0; i < game.players.length; i++) { - cur = game.players[i]; - if (!cur.node.seat) - cur.node.seat = decadeUI.element.create('seat', cur); - - cur.seat = cur.getSeatNum(); - cur.node.seat.innerHTML = get.cnNumber(cur.seat, true); - } - }, player); - - return this._super.phaseLoop.apply(this, arguments); - }; Game.swapSeat = function(player1,player2,prompt,behind,noanimate){ base.game.swapSeat.apply(this,arguments); player1.seat = player1.getSeatNum(); @@ -1969,6 +1954,17 @@ game.import('extension', async function(lib, game, ui, get, ai, _status){ } setSeatNum() { super.setSeatNum(...arguments); + game.broadcastAll(function(firstAction){ + let cur; + for (var i = 0; i < game.players.length; i++) { + cur = game.players[i]; + if (!cur.node.seat) + cur.node.seat = decadeUI.element.create('seat', cur); + + cur.seat = cur.getSeatNum(); + cur.node.seat.innerHTML = get.cnNumber(cur.seat, true); + } + }, this); this.seat = this.getSeatNum(); this.node.seat.innerHTML = get.cnNumber(this.seat, true); } @@ -2464,6 +2460,11 @@ game.import('extension', async function(lib, game, ui, get, ai, _status){ player.$throwordered2(card1.copy(false)); } $throw(cards, time, record, nosource) { + if (_status.connectMode) { + super.$throw(...arguments) + return; + } + var itemtype; var duiMod = (cards.duiMod && game.me == this && !nosource); if (typeof cards == 'number') { @@ -2876,37 +2877,6 @@ game.import('extension', async function(lib, game, ui, get, ai, _status){ $dieflip() { if (!decadeUI.config.playerDieEffect) super.$dieflip(...arguments); } - $dieAfter() { - this.stopDynamic(); - - if (!decadeUI.config.playerDieEffect) { - if (super.$dieAfter) super.$dieAfter(...arguments); - return; - } - - if (!this.node.dieidentity) this.node.dieidentity = ui.create.div('died-identity', this); - this.node.dieidentity.classList.add('died-identity'); - - var that = this; - var image = new Image(); - var identity = decadeUI.getPlayerIdentity(this); - var url = decadeUIPath + 'image/decoration/dead_' + identity + '.png'; - image.onerror = function () { - that.node.dieidentity.innerHTML = decadeUI.getPlayerIdentity(that, that.identity, true) + '
阵亡'; - }; - - that.node.dieidentity.innerHTML = ''; - that.node.dieidentity.style.backgroundImage = 'url("' + url + '")'; - image.src = url; - setTimeout(function () { - var rect = that.getBoundingClientRect(); - decadeUI.animation.playSpine('effect_zhenwang', { - x: rect.left + rect.width / 2 - 7, - y: decadeUI.get.bodySize().height - rect.top - rect.height / 2 + 1, - scale: 0.8, - }); - }, 250); - } setModeState(info) { if (info && info.seat) { if (!this.node.seat) this.node.seat = ui.create.div('.seat', this); diff --git a/game/config.js b/game/config.js index dbe046152b..782f68ae3e 100644 --- a/game/config.js +++ b/game/config.js @@ -132,7 +132,7 @@ window.config = { characters: ["standard", "shenhua", "sp", "sp2", "yijiang", "newjiang", "sixiang", "refresh", "mobile", "extra", "yingbian", "sb", "tw", "offline", "clan", "collab", "xianding", "huicui", "shiji", "jsrg", "onlyOL", "old"], moderned_chracters: ["standard", "shenhua", "sp", "sp2", "yijiang", "newjiang", "sixiang", "refresh", "mobile", "extra", "yingbian", "sb", "tw", "offline", "clan", "collab", "xianding", "huicui", "shiji", "onlyOL", "jsrg", "old", "diy", "ddd", "key"], connect_characters: ["diy", "ddd", "key"], - connect_cards: ["huanlekapai", "guozhan", "sp", "zhulu", "yingbian", "yongjian", "yunchou"], + connect_cards: ["huanlekapai", "guozhan"], plays: [], extensions: [], banned: [], diff --git a/noname/game/index.js b/noname/game/index.js index c2da1765a4..162cf677bc 100644 --- a/noname/game/index.js +++ b/noname/game/index.js @@ -5734,7 +5734,7 @@ export class Game extends GameCompatible { game.saveConfig("pagecfg" + window.isNonameServer, [lib.configOL, game.roomId, _status.onlinenickname, _status.onlineavatar]); game.reload(); } else if (_status.connectMode && !game.online) { - setTimeout(game.reload, 15000); + setTimeout(game.reload, 600000); } } /** diff --git a/noname/library/element/player.js b/noname/library/element/player.js index ac85fe4296..298ad5236f 100644 --- a/noname/library/element/player.js +++ b/noname/library/element/player.js @@ -11651,6 +11651,35 @@ export class Player extends HTMLDivElement { } if (this.$dieAfter) { this.$dieAfter(); + + if (window.decadeUI) { + this.stopDynamic(); + + if (decadeUI.config.playerDieEffect) { + if (!this.node.dieidentity) this.node.dieidentity = ui.create.div('died-identity', this); + this.node.dieidentity.classList.add('died-identity'); + + var that = this; + var image = new Image(); + var identity = decadeUI.getPlayerIdentity(this); + var url = decadeUIPath + 'image/decoration/dead_' + identity + '.png'; + image.onerror = function () { + that.node.dieidentity.innerHTML = decadeUI.getPlayerIdentity(that, that.identity, true) + '
阵亡'; + }; + + that.node.dieidentity.innerHTML = ''; + that.node.dieidentity.style.backgroundImage = 'url("' + url + '")'; + image.src = url; + setTimeout(function () { + var rect = that.getBoundingClientRect(); + decadeUI.animation.playSpine('effect_zhenwang', { + x: rect.left + rect.width / 2 - 7, + y: decadeUI.get.bodySize().height - rect.top - rect.height / 2 + 1, + scale: 0.8, + }); + }, 250); + } + } } } $dieflip(type) { diff --git a/noname/ui/create/index.js b/noname/ui/create/index.js index 70e54da509..75235e61a9 100644 --- a/noname/ui/create/index.js +++ b/noname/ui/create/index.js @@ -2935,10 +2935,12 @@ export class Create { for (var i of game.connectPlayers) { if (!i.nickname && !i.classList.contains("unselectable2")) num++; } + /* if (num >= lib.configOL.number - 1) { alert("至少要有两名玩家才能开始游戏!"); return; } + */ game.resume(); } button.delete();