diff --git a/play.pokemonshowdown.com/src/battle-log.ts b/play.pokemonshowdown.com/src/battle-log.ts index ad4f056..106a31e 100644 --- a/play.pokemonshowdown.com/src/battle-log.ts +++ b/play.pokemonshowdown.com/src/battle-log.ts @@ -30,7 +30,156 @@ declare function MD5(input: string): string; declare function formatText(input: string, isTrusted?: boolean): string; export { MD5, formatText }; +// Translate presentation only; keep Showdown IDs and player input intact. +const arenaFormatTerms: Record = { + "Random Battle": "随机对战", + "Random Doubles Battle": "随机双打", + "Free-For-All": "四人混战", + "Unrated": "非排位", + "Multi": "多人", + "Blitz": "快节奏", + "Baby": "幼年宝可梦", + "Featured Tiers": "推荐赛制", + "Champions": "宝可梦冠军", + "National Dex": "全国图鉴", + "NatDex": "全国图鉴", + "Past Generations": "历代赛制", + "Past Gens": "历代", + "Past VGC Regulations": "历届世锦赛规则", + "Challengeable OMs": "可约战的特殊玩法", + "Ladder Spotlight": "天梯精选", + "Randomized Metas": "随机玩法", + "Other Metagames": "特殊玩法", + "Unofficial Metagames": "非官方玩法", + "Temporary Tour Metas": "限时锦标赛", + "Pet Mods's Halloween!": "自制规则万圣节", + "Pet Mods": "自制规则", + "Doubles/Triples": "双打/三打", + "Doubles": "双打", + "Triples": "三打", + "Singles": "单打", + "S/V": "朱紫", + "Sw/Sh": "剑盾", + "US/UM": "究极日月", + "OR/AS": "欧米伽红宝石/阿尔法蓝宝石", + "B2/W2": "黑2白2", + "DPP": "钻石珍珠白金", + "ADV": "红蓝宝石", + "BW1": "黑白", + "FRLG": "火红叶绿", + "Custom Game": "自定义对战", + "Almost Any Ability": "自由特性", + "Balanced Hackmons": "平衡魔改", + "Pure Hackmons": "纯魔改", + "Hackmons Cup": "魔改杯", + "Anything Goes": "无限制", + "AAA": "自由特性(AAA)", + "AG": "无限制(AG)", + "BH": "平衡魔改(BH)", + "OU": "标准级(OU)", + "Ubers": "强力级(Ubers)", + "UU": "低使用率级(UU)", + "RU": "稀用级(RU)", + "NU": "少用级(NU)", + "PU": "冷门级(PU)", + "ZU": "极冷门级(ZU)", + "SU": "超冷门级(SU)", + "LC": "小小杯(LC)", + "UUBL": "低使用率禁用名单(UUBL)", + "NFE": "非最终进化", + "Monotype": "单一属性", + "CAP": "自创宝可梦(CAP)", + "Draft": "选秀", + "Factory": "工厂", + "Battle Factory": "对战工厂", + "BSS": "排位单打(BSS)", + "VGC": "世锦赛双打(VGC)", + "Reg": "规则", + "Bo3": "三局两胜", + "1v1": "一对一", + "2v2": "二对二", + "Battle Stadium Singles": "对战竞技场单打", + "Battle Spot": "对战广场", + "Challenge Cup": "挑战杯", + "Battle Festival": "对战庆典", + "Battlefields": "对战场地", + "Monocolor": "单一颜色", + "Random Roulette": "随机轮盘", + "Mayhem": "大乱斗", + "Shared Power": "特性共享", + "B12P6": "十二选六", + "Tera Override": "太晶覆盖", + "Tera Donation": "太晶传递", + "Mix and Mega": "混合超级进化", + "Limited Supply": "限量", + "Metronome Battle": "挥指对战", + "Roster Ranch Rumble": "牧场乱斗", + "STABmons": "同属性招式扩展", + "Pokebilities": "多重特性", + "Typemons": "属性变换", + "Camomons": "招式定属性", + "Touhoumons": "东方宝可梦", + "Godly Gift": "神之馈赠", + "Partners in Crime": "共犯搭档", + "VoltTurn Mayhem": "伏特折返大乱斗", + "Inheritance": "继承", + "Revelationmons": "招式属性重塑", + "Inverse": "反转对战", + "Sketchmons": "写生对战", + "Full Potential": "潜能解放", + "Tier Shift": "分级能力调整", + "Alphabet Cup": "字母杯", + "350 Cup": "350杯", + "Broken Cup": "超规格杯", + "Statmons": "能力改造", + "Nature Swap": "性格互换", + "Convergence": "汇聚", + "Cross Evolution": "跨种进化", + "Foresighters": "先见之明", + "Pokemoves": "宝可梦招式化", + "Frantic Fusions": "狂热融合", + "Flipped": "能力反转", + "Formemons": "形态对战", + "Fortemons": "招式特性化", + "Force of the Fallen": "倒下者之力", + "Monoletter": "同首字母", + "Trademarked": "招牌招式", + "Type Split": "属性拆分", + "Category Swap": "招式分类互换", + "Fervent Impersonation": "狂热模仿", + "Tradebacks": "跨代回传", + "GBU": "全球对战联盟", + "Japanese": "日版", + "Platinum": "白金", + "Orre Colosseum": "欧雷竞技场", + "Hoenn Stadium": "丰缘竞技场", + "Stadium Rentals": "竞技场租借队", + "Stadium": "竞技场", + "NC": "任天堂杯", + "Relay Race": "接力赛", + "No Holds Barred!": "无限制大赛", + "The Card Game": "集换式卡牌", + "The Loser's Game": "求败对战", + "Passive Aggressive": "被动进攻", + "Sharing is Caring": "资源共享", + "Super Staff Bros Ultimate": "管理员终极乱斗", + "Bad 'n Boosted": "弱者强化", + "Linked": "连锁招式", + "35 Pokes": "35只宝可梦", + "Bio Mech Mons": "生物机械宝可梦", + "ChatBats": "聊天室蝙蝠", + "1-2 Switch": "一二换位", + "9 for 9": "九代轮战" +}; +const arenaTermPattern = new RegExp('(^|[^A-Za-z0-9])(' + Object.keys(arenaFormatTerms) + .sort((a, b) => b.length - a.length).join('|') + ')(?![A-Za-z0-9])', 'g'); + export class BattleLog { + static arenaFormatLabel(name: string): string { + return name.replace(/\[Gen (\d+)([^\]]*)\]/g, '【世代 $1$2】') + .replace(arenaTermPattern, (_, prefix, term) => prefix + arenaFormatTerms[term]); + } + elem: HTMLDivElement; innerElem: HTMLDivElement; scene: BattleScene | null = null; @@ -1117,10 +1266,10 @@ export class BattleLog { let atIndex = formatid.indexOf('@@@'); if (atIndex >= 0) { const customRules = this.escapeHTML(formatid.slice(atIndex + 3)); - return this.escapeHTML(this.formatName(formatid.slice(0, atIndex), fixGen6)) + + return this.escapeHTML(this.arenaFormatLabel(this.formatName(formatid.slice(0, atIndex), fixGen6))) + '
' + TL.label(TL('Custom rules'), customRules); } - return this.escapeHTML(this.formatName(formatid, fixGen6)); + return this.escapeHTML(this.arenaFormatLabel(this.formatName(formatid, fixGen6))); } static formatId(format: string): ID { const atIndex = format.indexOf('@@@'); diff --git a/play.pokemonshowdown.com/src/oldclient/client-battle.js b/play.pokemonshowdown.com/src/oldclient/client-battle.js index 43da388..398c349 100644 --- a/play.pokemonshowdown.com/src/oldclient/client-battle.js +++ b/play.pokemonshowdown.com/src/oldclient/client-battle.js @@ -302,7 +302,7 @@ if (this.battle.ended) { - var replayDownloadButton = ' Download replay

'; + var replayDownloadButton = Config.arena ? '查看我的战报

下载本场回放
' : ' Download replay

'; // battle has ended if (this.side) { diff --git a/play.pokemonshowdown.com/src/oldclient/client-chat.js b/play.pokemonshowdown.com/src/oldclient/client-chat.js index 39e254b..61603d3 100644 --- a/play.pokemonshowdown.com/src/oldclient/client-chat.js +++ b/play.pokemonshowdown.com/src/oldclient/client-chat.js @@ -1533,12 +1533,7 @@ if (silent && !Dex.prefs('showbattles')) return; this.addJoinLeave(); - var battletype = 'Battle'; - if (format) { - battletype = format + ' battle'; - if (format === 'Random Battle') battletype = 'Random Battle'; - } - this.$chat.append('
' + battletype + ' started between ' + BattleLog.escapeHTML(name) + ' and ' + BattleLog.escapeHTML(name2) + '.
'); + this.$chat.append('
' + (format || '对战') + '开始:' + BattleLog.escapeHTML(name) + ' 对阵 ' + BattleLog.escapeHTML(name2) + '。
'); break; case 'j': @@ -1577,7 +1572,12 @@ case 'raw': case 'html': - this.$chat.append('
' + BattleLog.sanitizeHTML(row.slice(1).join('|')) + '
'); + var raw = row.slice(1).join('|').replace(/^
You joined ([^<]*)<\/div>$/, function (_, title) { + title = title.replace(/^Lobby(?= \[|$)/, '大厅').replace(/ \[([^\]]+) or higher to talk\]/g, '[发言权限:$1 及以上]') + .replace(/ \[([^\]]+) or higher to join\]/g, '[加入权限:$1 及以上]').replace(/ \[Slowchat (\d+)s\]/g, '[发言间隔:$1 秒]'); + return '
你已加入' + title + '。
'; + }); + this.$chat.append('
' + BattleLog.sanitizeHTML(raw) + '
'); break; case 'notify': @@ -1792,21 +1792,21 @@ } for (var j = 0; j < list.length; j++) { if (j >= 5) { - message += ', and ' + (list.length - 5) + ' others'; + message += ' 等另外 ' + (list.length - 5) + ' 人'; break; } if (j > 0) { if (j === 1 && list.length === 2) { - message += ' and '; + message += ' 和 '; } else if (j === list.length - 1) { - message += ', and '; + message += ' 和 '; } else { - message += ', '; + message += '、'; } } message += BattleLog.escapeHTML(list[j]); } - return message + ' ' + action; + return message + (action === 'joined' ? ' 加入了房间。' : ' 离开了房间。'); }, addChat: function (name, message, pm, msgTime) { var userid = toUserid(name); @@ -1937,7 +1937,7 @@ 'click .userlist-count': 'toggleUserlist' }, construct: function () { - var plural = this.room.userCount.users === 1 ? ' user' : ' users'; + var plural = ' 人在线'; var buf = ''; var usersString = "" + (this.room.userCount.users || '0') + plural; buf += '
  • '; @@ -1958,7 +1958,7 @@ buf += this.getNoNamedUsersOnline(); } if (this.room.userCount.guests) { - buf += '
  • (' + this.room.userCount.guests + ' guest' + (this.room.userCount.guests === 1 ? '' : 's') + ')
  • '; + buf += '
  • (' + this.room.userCount.guests + ' 位游客)
  • '; } this.$el.html(buf); }, @@ -1984,7 +1984,7 @@ }, updateUserCount: function () { var users = Math.max(this.room.userCount.users || 0, this.room.userCount.globalUsers || 0); - $('#' + this.room.id + '-usercount-users').html('' + users + (users === 1 ? ' user' : ' users')); + $('#' + this.room.id + '-usercount-users').html('' + users + ' 人在线'); }, add: function (userid) { $('#' + this.room.id + '-userlist-user-' + userid).remove(); @@ -2067,7 +2067,7 @@ return (a > b ? 1 : -1); }, getNoNamedUsersOnline: function () { - return '
  • Only guests
  • '; + return '
  • 仅访客
  • '; }, updateNoUsersOnline: function () { var elem = $('#' + this.room.id + '-userlist-empty'); @@ -2099,15 +2099,7 @@ initialize: function () { this.$el.addClass('ps-room-light').addClass('scrollable'); var buf = '
    '; - buf += '

    PS! Informational Resources


    '; - buf += 'PS! is a wide and varied site, with more facets than can be covered here easily.
    '; - buf += 'While this page chiefly documents the ever-shifting set of commands available to PS! users, here are some useful resources for newcomers:
    '; - buf += '- Beginner\'s Guide to Pokémon Showdown
    '; - buf += '- An introduction to competitive Pokémon
    '; - buf += '- What do \'OU\', \'UU\', etc mean?
    '; - buf += '- What are the rules for each format?
    '; - buf += '- What is \'Sleep Clause\' and other clauses?
    '; - buf += '- Next Steps for Competitive Battling
    '; + buf += '

    本站对战资源

    查询宝可梦与招式 · 阅读中文对战攻略 · 进入训练家论坛 · 本站规则

    '; buf += '-
    '; buf += '- '; buf += '
    Commands:
    '; diff --git a/play.pokemonshowdown.com/src/oldclient/client-ladder.js b/play.pokemonshowdown.com/src/oldclient/client-ladder.js index 7ba982b..5c24175 100644 --- a/play.pokemonshowdown.com/src/oldclient/client-ladder.js +++ b/play.pokemonshowdown.com/src/oldclient/client-ladder.js @@ -123,9 +123,7 @@ leave: function () {}, update: function () { if (!this.curFormat) { - var buf = '

    See a user\'s ranking with User lookup

    ' + - // '

    I\'m really really sorry, but as a warning: we\'re going to reset the ladder again soon to fix some more ladder bugs.

    ' + - '

    (btw if you couldn\'t tell the ladder screens aren\'t done yet; they\'ll look nicer than this once I\'m done.)

    ' + + var buf = '

    选择赛制查看本站排名。

    ' + '

      '; if (!window.BattleFormats) { this.$el.html('
      Loading...
      '); diff --git a/play.pokemonshowdown.com/src/oldclient/client-mainmenu.js b/play.pokemonshowdown.com/src/oldclient/client-mainmenu.js index 5122549..7e49d79 100644 --- a/play.pokemonshowdown.com/src/oldclient/client-mainmenu.js +++ b/play.pokemonshowdown.com/src/oldclient/client-mainmenu.js @@ -114,20 +114,20 @@ var settings = Storage.prefs('serversettings') || {}; buf += '

      '; buf += '

      '; - buf += '

      '; + buf += '

      '; buf += '

    '; } buf += ''; buf += ''; + buf += '

    本站对战攻略

    '; this.$('.mainmenu').html(buf); @@ -145,7 +145,7 @@ this.$pmBox = this.$activityMenu.find('.pmbox'); var newClientMessage = NEW_CLIENT_LANGUAGE_MESSAGES[Dex.text.getBrowserLanguage()]; - if (newClientMessage) { + if (!Config.arena && newClientMessage) { this.addPseudoPM({ title: newClientMessage.title, html: '

    ' + newClientMessage.body + '

    ' + @@ -1356,7 +1356,7 @@ var FormatPopup = this.FormatPopup = this.Popup.extend({ events: { - 'keyup input[name=search]': 'updateSearch', + 'input input[name=search]': 'updateSearch', 'click details': 'updateOpen', 'click i.fa': 'updateStar' }, @@ -1380,7 +1380,7 @@ this.$form = this.sourceEl.closest('form'); if (!this.selectType) this.selectType = (this.$form.data('search') ? 'search' : 'challenge'); - var html = '

    • '; + var html = '

      • '; html += '

      '; html += this.renderFormats(); html += '

      '; @@ -1392,7 +1392,7 @@ var bufs = []; var curBuf = 0; if (this.selectType === 'watch' && !this.search) { - bufs[1] = '
    • '; + bufs[1] = '
    • '; } for (var i in this.starred) { @@ -1403,7 +1403,7 @@ continue; } if (!this.shouldDisplayFormat(format)) continue; - if (this.search && !i.includes(toID(this.search))) { + if (this.search && !this.matchesFormat(format)) { continue; } // @@ -1419,7 +1419,7 @@ for (var i in BattleFormats) { var format = BattleFormats[i]; if (!this.shouldDisplayFormat(format)) continue; - if (this.search && !format.id.includes(toID(this.search))) continue; + if (this.search && !this.matchesFormat(format)) continue; if (this.starred[i]) continue; // only show it in the starred section if (format.section && format.section !== curSection) { @@ -1433,10 +1433,10 @@ if (!bufs[curBuf]) { bufs[curBuf] = ''; } - var open = (curSection === 'Featured Tiers' || this.open[curSection] || toID(this.search)) ? ' open' : ''; + var open = (curSection === 'Featured Tiers' || this.open[curSection] || this.search.trim()) ? ' open' : ''; bufs[curBuf] += '

      '; bufs[curBuf] += '

      '; - bufs[curBuf] += BattleLog.escapeHTML(curSection) + ''; + bufs[curBuf] += BattleLog.escapeHTML(BattleLog.arenaFormatLabel(curSection)) + ''; } var formatName = BattleLog.escapeFormat(format.id); bufs[curBuf] += ( @@ -1447,7 +1447,7 @@ } var html = ''; if (bufs.every(function (buf) { return !buf; })) { - html = '
        No formats found
      '; + html = '
        没有找到匹配的赛制
      '; } else { for (var i = 1, l = bufs.length; i < l; i++) { if (!bufs[i]) continue; @@ -1490,6 +1490,12 @@ this.search = $(event.currentTarget).val(); this.update(); }, + matchesFormat: function (format) { + var query = this.search.trim().toLowerCase(); + var key = toID(query); + return !query || BattleLog.arenaFormatLabel(format.name).toLowerCase().includes(query) || + (!/[^\x00-\x7f]/.test(query) && !!key && format.id.includes(key)); + }, shouldDisplayFormat: function (format) { if (this.selectType === 'teambuilder') { if (!format.isTeambuilderFormat) return false; diff --git a/play.pokemonshowdown.com/src/oldclient/client-teambuilder.js b/play.pokemonshowdown.com/src/oldclient/client-teambuilder.js index 0f5bcfd..419289a 100644 --- a/play.pokemonshowdown.com/src/oldclient/client-teambuilder.js +++ b/play.pokemonshowdown.com/src/oldclient/client-teambuilder.js @@ -191,6 +191,7 @@ return; } teambuilder.formatResources[format] = true; // true - loading, array - loaded + if (Config.arena) return; // The standalone site has its own strategy pages. $.get('https://www.smogon.com/dex/api/formats/by-ps-name/' + format, {}, function (data) { // if the data doesn't exist, set it to true so it stops trying to load it teambuilder.formatResources[format] = data || true; @@ -1866,7 +1867,7 @@ for (var set in smogonSets) { $smogonSetDiv.append(''); } - $smogonSetDiv.append(' (Smogon analysis)'); + $smogonSetDiv.append(' (查看宝可梦图鉴)'); } $userSetDiv.text('Box sets: '); @@ -2247,6 +2248,7 @@ minus: '', smogdexLink: function (s) { var species = this.curTeam.dex.species.get(s); + if (Config.arena) return '/dex/pokemon/' + species.id; var format = this.curTeam && this.curTeam.format; var smogdexid = toID(species.baseSpecies); @@ -2328,7 +2330,7 @@ var guessedMinus = guess.minusStat; buf += '

      Guessed spread:'; if (role === '?') { - buf += ' (Please choose 4 moves to get a guessed spread) (Smogon analysis)

      '; + buf += ' (Please choose 4 moves to get a guessed spread) (查看宝可梦图鉴)

      '; } else { buf += ' (Smogon analysis)

      '; + buf += ' (查看宝可梦图鉴)

      '; // buf += ' (' + role + ' | bulk: phys ' + Math.round(guess.moveCount.physicalBulk/1000) + ' + spec ' + Math.round(guess.moveCount.specialBulk/1000) + ' = ' + Math.round(guess.moveCount.bulk/1000) + ')'; } diff --git a/play.pokemonshowdown.com/src/oldclient/client-topbar.js b/play.pokemonshowdown.com/src/oldclient/client-topbar.js index ef1ae51..1fa39ad 100644 --- a/play.pokemonshowdown.com/src/oldclient/client-topbar.js +++ b/play.pokemonshowdown.com/src/oldclient/client-topbar.js @@ -1143,10 +1143,10 @@ } else if (data.reason) { buf += '

      ' + BattleLog.escapeHTML(data.reason) + '

      '; } else { - buf += '

      The name you chose is registered.

      '; + buf += '

      本站账号与官方 Showdown 独立。首次输入昵称和密码即创建账号。

      '; } - buf += '

      If this is your account:

      '; + buf += '

      请输入本站专用密码(至少 8 字节),不要填写官方账号密码。

      '; buf += '

      '; if (data.special === '@gmail') { buf += '
      '; diff --git a/play.pokemonshowdown.com/src/oldclient/client.js b/play.pokemonshowdown.com/src/oldclient/client.js index 65c513d..057bc2d 100644 --- a/play.pokemonshowdown.com/src/oldclient/client.js +++ b/play.pokemonshowdown.com/src/oldclient/client.js @@ -7,7 +7,7 @@ function toId() { (function ($) { Config.sockjsprefix = '/showdown'; - Config.root = '/'; + Config.root = Config.arena ? '/play/' : '/'; if (window.nodewebkit) { window.gui = require('nw.gui'); @@ -217,6 +217,7 @@ function toId() { * domain in order to have access to the correct cookies. */ getActionPHP: function () { + if (Config.arena) return '/action.php'; var ret = '/~~' + Config.server.id + '/action.php'; if (Config.testclient) { ret = 'https://' + Config.routes.client + ret; @@ -386,7 +387,7 @@ function toId() { }); this.App = Backbone.Router.extend({ - root: '/', + root: Config.root, routes: { '*path': 'dispatchFragment' }, @@ -431,7 +432,7 @@ function toId() { Dex.loadTextData(); if (!Config.server.registered) { app.send('/autojoin'); - Backbone.history.start({ pushState: !Config.testclient }); + Backbone.history.start({ root: Config.root, pushState: !Config.testclient }); return; } // Support legacy tournament setting and migrate to new pref @@ -463,7 +464,7 @@ function toId() { if (Object.keys(settings).length) app.user.set('settings', settings); // HTML5 history throws exceptions when running on file:// var useHistory = !Config.testclient && (location.pathname.slice(-5) !== '.html'); - Backbone.history.start({ pushState: useHistory }); + Backbone.history.start({ root: Config.root, pushState: useHistory }); app.ignore = app.loadIgnore(); }); } diff --git a/play.pokemonshowdown.com/src/oldclient/storage.js b/play.pokemonshowdown.com/src/oldclient/storage.js index 2c3f9ba..ab3e565 100644 --- a/play.pokemonshowdown.com/src/oldclient/storage.js +++ b/play.pokemonshowdown.com/src/oldclient/storage.js @@ -337,6 +337,7 @@ Storage.whenPrefsLoaded(updatePrefs); Storage.initPrefs = function () { Storage.loadTeams(); + if (Config.arena) { this.whenPrefsLoaded.load(); this.whenTeamsLoaded.load(); return; } if (Config.testclient) { return this.initTestClient(); } else if (location.protocol + '//' + location.hostname === Storage.origin) {