fix: update game ticket fee display

This commit is contained in:
zhx 2026-06-24 10:31:15 +08:00
parent fdf64baed2
commit 805cd8c991
8 changed files with 103 additions and 45 deletions

View File

@ -4,7 +4,7 @@
"diceMatch.match": "مطابقة",
"diceMatch.matching": "جارٍ البحث...",
"diceMatch.winnerReceives": "الفائز يحصل على",
"diceMatch.feeNote": "يدفع اللاعب الفائز رسوم معاملة 5%",
"diceMatch.feeNote": "",
"diceMatch.unknownOpponent": "?",
"diceMatch.win": "فوز",
"diceMatch.coins": "عملات",
@ -18,7 +18,7 @@
"diceMatch.apiUnavailable": "واجهة لعبة النرد غير متاحة",
"diceMatch.selectStake": "اختر قيمة الرهان",
"diceMatch.requestFailed": "فشل الطلب",
"diceMatch.configFeeNote": "الرسوم {fee}%",
"diceMatch.configFeeNote": "Tickets {fee}%",
"rockGame.pageTitle": "حجر ورقة مقص",
"rockGame.pageLabel": "لعبة حجر ورقة مقص",
"rockGame.start": "ابدأ",
@ -38,7 +38,7 @@
"rockGame.playAgain": "العب مرة أخرى",
"rockGame.changeLanguage": "تغيير اللغة",
"rockGame.selectStake": "اختر قيمة الرهان",
"rockGame.configFeeNote": "الرسوم {fee}%",
"rockGame.configFeeNote": "Tickets {fee}%",
"rockGame.apiUnavailable": "واجهة RPS غير متاحة",
"rockGame.refundNote": "إذا لم ينضم أحد إلى لعبة حجر ورقة مقص، سيتم رد العملات خلال 10 دقائق.",
"roomReward.pageTitle": "فعالية مكافآت الغرفة",

View File

@ -4,7 +4,7 @@
"diceMatch.match": "Match",
"diceMatch.matching": "Matching...",
"diceMatch.winnerReceives": "The winner receives",
"diceMatch.feeNote": "The winning player pays a 5% transaction fee",
"diceMatch.feeNote": "",
"diceMatch.unknownOpponent": "?",
"diceMatch.win": "Win",
"diceMatch.coins": "Coins",
@ -18,7 +18,7 @@
"diceMatch.apiUnavailable": "Dice API unavailable",
"diceMatch.selectStake": "Select a stake",
"diceMatch.requestFailed": "Request failed",
"diceMatch.configFeeNote": "Fee {fee}%",
"diceMatch.configFeeNote": "Tickets {fee}%",
"rockGame.pageTitle": "Rock Paper Scissors",
"rockGame.pageLabel": "Rock paper scissors",
"rockGame.start": "START",
@ -38,7 +38,7 @@
"rockGame.playAgain": "Play again",
"rockGame.changeLanguage": "Change language",
"rockGame.selectStake": "Select a stake",
"rockGame.configFeeNote": "Fee {fee}%",
"rockGame.configFeeNote": "Tickets {fee}%",
"rockGame.apiUnavailable": "RPS API unavailable",
"rockGame.refundNote": "If no one joins the rock-paper-scissors game, the coins will be refunded in 10 minutes.",
"roomReward.pageTitle": "Room Reward Event",

View File

@ -4,7 +4,7 @@
"diceMatch.match": "Emparejar",
"diceMatch.matching": "Emparejando...",
"diceMatch.winnerReceives": "El ganador recibe",
"diceMatch.feeNote": "El jugador ganador paga una comisión del 5%",
"diceMatch.feeNote": "",
"diceMatch.unknownOpponent": "?",
"diceMatch.win": "Victoria",
"diceMatch.coins": "Monedas",
@ -18,7 +18,7 @@
"diceMatch.apiUnavailable": "API del juego de dados no disponible",
"diceMatch.selectStake": "Selecciona una apuesta",
"diceMatch.requestFailed": "Error de solicitud",
"diceMatch.configFeeNote": "Comisión {fee}%",
"diceMatch.configFeeNote": "Tickets {fee}%",
"rockGame.pageTitle": "Piedra, papel o tijeras",
"rockGame.pageLabel": "Piedra, papel o tijeras",
"rockGame.start": "INICIAR",
@ -38,7 +38,7 @@
"rockGame.playAgain": "Jugar otra vez",
"rockGame.changeLanguage": "Cambiar idioma",
"rockGame.selectStake": "Selecciona una apuesta",
"rockGame.configFeeNote": "Comisión {fee}%",
"rockGame.configFeeNote": "Tickets {fee}%",
"rockGame.apiUnavailable": "API de RPS no disponible",
"rockGame.refundNote": "Si nadie se une al juego de piedra, papel o tijeras, las monedas se reembolsarán en 10 minutos.",
"roomReward.pageTitle": "Evento de recompensas de sala",

View File

@ -4,7 +4,7 @@
"diceMatch.match": "Match",
"diceMatch.matching": "Mencari...",
"diceMatch.winnerReceives": "Pemenang menerima",
"diceMatch.feeNote": "Pemain yang menang membayar biaya transaksi 5%",
"diceMatch.feeNote": "",
"diceMatch.unknownOpponent": "?",
"diceMatch.win": "Menang",
"diceMatch.coins": "Koin",

View File

@ -4,7 +4,7 @@
"diceMatch.match": "Eşleş",
"diceMatch.matching": "Eşleşiyor...",
"diceMatch.winnerReceives": "Kazanan alır",
"diceMatch.feeNote": "Kazanan oyuncu %5 işlem ücreti öder",
"diceMatch.feeNote": "",
"diceMatch.unknownOpponent": "?",
"diceMatch.win": "Kazan",
"diceMatch.coins": "Coin",

View File

@ -4,7 +4,7 @@
"diceMatch.match": "匹配",
"diceMatch.matching": "匹配中...",
"diceMatch.winnerReceives": "获胜者可获得",
"diceMatch.feeNote": "获胜玩家需支付 5% 交易手续费",
"diceMatch.feeNote": "",
"diceMatch.unknownOpponent": "?",
"diceMatch.win": "胜利",
"diceMatch.coins": "金币",

View File

@ -1799,7 +1799,10 @@
>
START
</button>
<div class="rps-refund-note">Fee 5%</div>
<div
class="rps-refund-note"
style="display: none"
></div>
</div>
</section>
@ -3030,10 +3033,7 @@
function totalFeeBPSForMatch(match) {
var config = state.config || {};
var feeBPS = numberFromFields(match, [
'fee_bps',
'feeBps',
]);
var feeBPS = numberFromFields(match, ['fee_bps', 'feeBps']);
var poolBPS = numberFromFields(match, [
'pool_bps',
'poolBps',
@ -3152,18 +3152,34 @@
}
function renderFeeNote(config) {
var hasConfig = !!config;
var totalFee = hasConfig
? (Number(config.fee_bps || 0) +
Number(config.pool_bps || 0)) /
100
: 5;
var note = document.querySelector('.rps-refund-note');
if (!note) return;
var feeBPS = numberFromFields(config, [
'fee_bps',
'feeBps',
]);
var poolBPS = numberFromFields(config, [
'pool_bps',
'poolBps',
]);
// 费率必须来自后端配置;没有明确字段时隐藏,避免把历史兜底 5% 当成真实规则展示。
if (feeBPS === null && poolBPS === null) {
setText(note, '');
note.style.display = 'none';
return;
}
var totalFee =
Math.max(
0,
Math.min(10000, (feeBPS || 0) + (poolBPS || 0))
) / 100;
setText(
document.querySelector('.rps-refund-note'),
i18nFormat('rockGame.configFeeNote', 'Fee {fee}%', {
note,
i18nFormat('rockGame.configFeeNote', 'Tickets {fee}%', {
fee: totalFee,
})
);
note.style.display = '';
}
function pollMatch(matchID) {

View File

@ -2336,10 +2336,8 @@
<div
class="fee-note waiting-only"
data-node-id="466:92"
data-i18n="diceMatch.feeNote"
>
The winning player pays a 5% transaction fee
</div>
style="display: none"
></div>
<div
class="matching-action"
@ -2975,6 +2973,65 @@
return Math.floor(number / 1000) + 'K';
}
function configBPSValue(config, fields) {
if (!config) return null;
for (var i = 0; i < fields.length; i += 1) {
if (
!Object.prototype.hasOwnProperty.call(
config,
fields[i]
)
) {
continue;
}
var raw = config[fields[i]];
if (raw === null || raw === undefined || raw === '') {
continue;
}
var value = Number(raw);
if (Number.isFinite(value)) return value;
}
return null;
}
function configTicketPercent(config) {
var feeBPS = configBPSValue(config, ['fee_bps', 'feeBps']);
var poolBPS = configBPSValue(config, [
'pool_bps',
'poolBps',
]);
if (feeBPS === null && poolBPS === null) return null;
return (
Math.max(
0,
Math.min(10000, (feeBPS || 0) + (poolBPS || 0))
) / 100
);
}
function renderFeeNote(config) {
var note = document.querySelector('.fee-note');
if (!note) return;
var ticketPercent = configTicketPercent(config);
// 费率必须来自后端配置;没有明确字段时隐藏,避免把历史兜底 5% 当成真实规则展示。
if (ticketPercent === null) {
setText(note, '');
note.style.display = 'none';
return;
}
setText(
note,
i18nFormat(
'diceMatch.configFeeNote',
'Tickets {fee}%',
{
fee: ticketPercent,
}
)
);
note.style.display = '';
}
function setCoin(value) {
var number = Number(value || 0);
if (!Number.isFinite(number)) number = 0;
@ -3341,22 +3398,7 @@
selectStake(
selectedButton || document.querySelector('.stake')
);
if (config) {
var totalFee =
(Number(config.fee_bps || 0) +
Number(config.pool_bps || 0)) /
100;
setText(
document.querySelector('.fee-note'),
i18nFormat(
'diceMatch.configFeeNote',
'Fee {fee}%',
{
fee: totalFee,
}
)
);
}
renderFeeNote(config);
}
function resetFrame() {