fix: update game ticket fee display
This commit is contained in:
parent
fdf64baed2
commit
805cd8c991
@ -4,7 +4,7 @@
|
|||||||
"diceMatch.match": "مطابقة",
|
"diceMatch.match": "مطابقة",
|
||||||
"diceMatch.matching": "جارٍ البحث...",
|
"diceMatch.matching": "جارٍ البحث...",
|
||||||
"diceMatch.winnerReceives": "الفائز يحصل على",
|
"diceMatch.winnerReceives": "الفائز يحصل على",
|
||||||
"diceMatch.feeNote": "يدفع اللاعب الفائز رسوم معاملة 5%",
|
"diceMatch.feeNote": "",
|
||||||
"diceMatch.unknownOpponent": "?",
|
"diceMatch.unknownOpponent": "?",
|
||||||
"diceMatch.win": "فوز",
|
"diceMatch.win": "فوز",
|
||||||
"diceMatch.coins": "عملات",
|
"diceMatch.coins": "عملات",
|
||||||
@ -18,7 +18,7 @@
|
|||||||
"diceMatch.apiUnavailable": "واجهة لعبة النرد غير متاحة",
|
"diceMatch.apiUnavailable": "واجهة لعبة النرد غير متاحة",
|
||||||
"diceMatch.selectStake": "اختر قيمة الرهان",
|
"diceMatch.selectStake": "اختر قيمة الرهان",
|
||||||
"diceMatch.requestFailed": "فشل الطلب",
|
"diceMatch.requestFailed": "فشل الطلب",
|
||||||
"diceMatch.configFeeNote": "الرسوم {fee}%",
|
"diceMatch.configFeeNote": "Tickets {fee}%",
|
||||||
"rockGame.pageTitle": "حجر ورقة مقص",
|
"rockGame.pageTitle": "حجر ورقة مقص",
|
||||||
"rockGame.pageLabel": "لعبة حجر ورقة مقص",
|
"rockGame.pageLabel": "لعبة حجر ورقة مقص",
|
||||||
"rockGame.start": "ابدأ",
|
"rockGame.start": "ابدأ",
|
||||||
@ -38,7 +38,7 @@
|
|||||||
"rockGame.playAgain": "العب مرة أخرى",
|
"rockGame.playAgain": "العب مرة أخرى",
|
||||||
"rockGame.changeLanguage": "تغيير اللغة",
|
"rockGame.changeLanguage": "تغيير اللغة",
|
||||||
"rockGame.selectStake": "اختر قيمة الرهان",
|
"rockGame.selectStake": "اختر قيمة الرهان",
|
||||||
"rockGame.configFeeNote": "الرسوم {fee}%",
|
"rockGame.configFeeNote": "Tickets {fee}%",
|
||||||
"rockGame.apiUnavailable": "واجهة RPS غير متاحة",
|
"rockGame.apiUnavailable": "واجهة RPS غير متاحة",
|
||||||
"rockGame.refundNote": "إذا لم ينضم أحد إلى لعبة حجر ورقة مقص، سيتم رد العملات خلال 10 دقائق.",
|
"rockGame.refundNote": "إذا لم ينضم أحد إلى لعبة حجر ورقة مقص، سيتم رد العملات خلال 10 دقائق.",
|
||||||
"roomReward.pageTitle": "فعالية مكافآت الغرفة",
|
"roomReward.pageTitle": "فعالية مكافآت الغرفة",
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
"diceMatch.match": "Match",
|
"diceMatch.match": "Match",
|
||||||
"diceMatch.matching": "Matching...",
|
"diceMatch.matching": "Matching...",
|
||||||
"diceMatch.winnerReceives": "The winner receives",
|
"diceMatch.winnerReceives": "The winner receives",
|
||||||
"diceMatch.feeNote": "The winning player pays a 5% transaction fee",
|
"diceMatch.feeNote": "",
|
||||||
"diceMatch.unknownOpponent": "?",
|
"diceMatch.unknownOpponent": "?",
|
||||||
"diceMatch.win": "Win",
|
"diceMatch.win": "Win",
|
||||||
"diceMatch.coins": "Coins",
|
"diceMatch.coins": "Coins",
|
||||||
@ -18,7 +18,7 @@
|
|||||||
"diceMatch.apiUnavailable": "Dice API unavailable",
|
"diceMatch.apiUnavailable": "Dice API unavailable",
|
||||||
"diceMatch.selectStake": "Select a stake",
|
"diceMatch.selectStake": "Select a stake",
|
||||||
"diceMatch.requestFailed": "Request failed",
|
"diceMatch.requestFailed": "Request failed",
|
||||||
"diceMatch.configFeeNote": "Fee {fee}%",
|
"diceMatch.configFeeNote": "Tickets {fee}%",
|
||||||
"rockGame.pageTitle": "Rock Paper Scissors",
|
"rockGame.pageTitle": "Rock Paper Scissors",
|
||||||
"rockGame.pageLabel": "Rock paper scissors",
|
"rockGame.pageLabel": "Rock paper scissors",
|
||||||
"rockGame.start": "START",
|
"rockGame.start": "START",
|
||||||
@ -38,7 +38,7 @@
|
|||||||
"rockGame.playAgain": "Play again",
|
"rockGame.playAgain": "Play again",
|
||||||
"rockGame.changeLanguage": "Change language",
|
"rockGame.changeLanguage": "Change language",
|
||||||
"rockGame.selectStake": "Select a stake",
|
"rockGame.selectStake": "Select a stake",
|
||||||
"rockGame.configFeeNote": "Fee {fee}%",
|
"rockGame.configFeeNote": "Tickets {fee}%",
|
||||||
"rockGame.apiUnavailable": "RPS API unavailable",
|
"rockGame.apiUnavailable": "RPS API unavailable",
|
||||||
"rockGame.refundNote": "If no one joins the rock-paper-scissors game, the coins will be refunded in 10 minutes.",
|
"rockGame.refundNote": "If no one joins the rock-paper-scissors game, the coins will be refunded in 10 minutes.",
|
||||||
"roomReward.pageTitle": "Room Reward Event",
|
"roomReward.pageTitle": "Room Reward Event",
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
"diceMatch.match": "Emparejar",
|
"diceMatch.match": "Emparejar",
|
||||||
"diceMatch.matching": "Emparejando...",
|
"diceMatch.matching": "Emparejando...",
|
||||||
"diceMatch.winnerReceives": "El ganador recibe",
|
"diceMatch.winnerReceives": "El ganador recibe",
|
||||||
"diceMatch.feeNote": "El jugador ganador paga una comisión del 5%",
|
"diceMatch.feeNote": "",
|
||||||
"diceMatch.unknownOpponent": "?",
|
"diceMatch.unknownOpponent": "?",
|
||||||
"diceMatch.win": "Victoria",
|
"diceMatch.win": "Victoria",
|
||||||
"diceMatch.coins": "Monedas",
|
"diceMatch.coins": "Monedas",
|
||||||
@ -18,7 +18,7 @@
|
|||||||
"diceMatch.apiUnavailable": "API del juego de dados no disponible",
|
"diceMatch.apiUnavailable": "API del juego de dados no disponible",
|
||||||
"diceMatch.selectStake": "Selecciona una apuesta",
|
"diceMatch.selectStake": "Selecciona una apuesta",
|
||||||
"diceMatch.requestFailed": "Error de solicitud",
|
"diceMatch.requestFailed": "Error de solicitud",
|
||||||
"diceMatch.configFeeNote": "Comisión {fee}%",
|
"diceMatch.configFeeNote": "Tickets {fee}%",
|
||||||
"rockGame.pageTitle": "Piedra, papel o tijeras",
|
"rockGame.pageTitle": "Piedra, papel o tijeras",
|
||||||
"rockGame.pageLabel": "Piedra, papel o tijeras",
|
"rockGame.pageLabel": "Piedra, papel o tijeras",
|
||||||
"rockGame.start": "INICIAR",
|
"rockGame.start": "INICIAR",
|
||||||
@ -38,7 +38,7 @@
|
|||||||
"rockGame.playAgain": "Jugar otra vez",
|
"rockGame.playAgain": "Jugar otra vez",
|
||||||
"rockGame.changeLanguage": "Cambiar idioma",
|
"rockGame.changeLanguage": "Cambiar idioma",
|
||||||
"rockGame.selectStake": "Selecciona una apuesta",
|
"rockGame.selectStake": "Selecciona una apuesta",
|
||||||
"rockGame.configFeeNote": "Comisión {fee}%",
|
"rockGame.configFeeNote": "Tickets {fee}%",
|
||||||
"rockGame.apiUnavailable": "API de RPS no disponible",
|
"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.",
|
"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",
|
"roomReward.pageTitle": "Evento de recompensas de sala",
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
"diceMatch.match": "Match",
|
"diceMatch.match": "Match",
|
||||||
"diceMatch.matching": "Mencari...",
|
"diceMatch.matching": "Mencari...",
|
||||||
"diceMatch.winnerReceives": "Pemenang menerima",
|
"diceMatch.winnerReceives": "Pemenang menerima",
|
||||||
"diceMatch.feeNote": "Pemain yang menang membayar biaya transaksi 5%",
|
"diceMatch.feeNote": "",
|
||||||
"diceMatch.unknownOpponent": "?",
|
"diceMatch.unknownOpponent": "?",
|
||||||
"diceMatch.win": "Menang",
|
"diceMatch.win": "Menang",
|
||||||
"diceMatch.coins": "Koin",
|
"diceMatch.coins": "Koin",
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
"diceMatch.match": "Eşleş",
|
"diceMatch.match": "Eşleş",
|
||||||
"diceMatch.matching": "Eşleşiyor...",
|
"diceMatch.matching": "Eşleşiyor...",
|
||||||
"diceMatch.winnerReceives": "Kazanan alır",
|
"diceMatch.winnerReceives": "Kazanan alır",
|
||||||
"diceMatch.feeNote": "Kazanan oyuncu %5 işlem ücreti öder",
|
"diceMatch.feeNote": "",
|
||||||
"diceMatch.unknownOpponent": "?",
|
"diceMatch.unknownOpponent": "?",
|
||||||
"diceMatch.win": "Kazan",
|
"diceMatch.win": "Kazan",
|
||||||
"diceMatch.coins": "Coin",
|
"diceMatch.coins": "Coin",
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
"diceMatch.match": "匹配",
|
"diceMatch.match": "匹配",
|
||||||
"diceMatch.matching": "匹配中...",
|
"diceMatch.matching": "匹配中...",
|
||||||
"diceMatch.winnerReceives": "获胜者可获得",
|
"diceMatch.winnerReceives": "获胜者可获得",
|
||||||
"diceMatch.feeNote": "获胜玩家需支付 5% 交易手续费",
|
"diceMatch.feeNote": "",
|
||||||
"diceMatch.unknownOpponent": "?",
|
"diceMatch.unknownOpponent": "?",
|
||||||
"diceMatch.win": "胜利",
|
"diceMatch.win": "胜利",
|
||||||
"diceMatch.coins": "金币",
|
"diceMatch.coins": "金币",
|
||||||
|
|||||||
@ -1799,7 +1799,10 @@
|
|||||||
>
|
>
|
||||||
START
|
START
|
||||||
</button>
|
</button>
|
||||||
<div class="rps-refund-note">Fee 5%</div>
|
<div
|
||||||
|
class="rps-refund-note"
|
||||||
|
style="display: none"
|
||||||
|
></div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@ -3030,10 +3033,7 @@
|
|||||||
|
|
||||||
function totalFeeBPSForMatch(match) {
|
function totalFeeBPSForMatch(match) {
|
||||||
var config = state.config || {};
|
var config = state.config || {};
|
||||||
var feeBPS = numberFromFields(match, [
|
var feeBPS = numberFromFields(match, ['fee_bps', 'feeBps']);
|
||||||
'fee_bps',
|
|
||||||
'feeBps',
|
|
||||||
]);
|
|
||||||
var poolBPS = numberFromFields(match, [
|
var poolBPS = numberFromFields(match, [
|
||||||
'pool_bps',
|
'pool_bps',
|
||||||
'poolBps',
|
'poolBps',
|
||||||
@ -3152,18 +3152,34 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderFeeNote(config) {
|
function renderFeeNote(config) {
|
||||||
var hasConfig = !!config;
|
var note = document.querySelector('.rps-refund-note');
|
||||||
var totalFee = hasConfig
|
if (!note) return;
|
||||||
? (Number(config.fee_bps || 0) +
|
var feeBPS = numberFromFields(config, [
|
||||||
Number(config.pool_bps || 0)) /
|
'fee_bps',
|
||||||
100
|
'feeBps',
|
||||||
: 5;
|
]);
|
||||||
|
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(
|
setText(
|
||||||
document.querySelector('.rps-refund-note'),
|
note,
|
||||||
i18nFormat('rockGame.configFeeNote', 'Fee {fee}%', {
|
i18nFormat('rockGame.configFeeNote', 'Tickets {fee}%', {
|
||||||
fee: totalFee,
|
fee: totalFee,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
note.style.display = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function pollMatch(matchID) {
|
function pollMatch(matchID) {
|
||||||
|
|||||||
@ -2336,10 +2336,8 @@
|
|||||||
<div
|
<div
|
||||||
class="fee-note waiting-only"
|
class="fee-note waiting-only"
|
||||||
data-node-id="466:92"
|
data-node-id="466:92"
|
||||||
data-i18n="diceMatch.feeNote"
|
style="display: none"
|
||||||
>
|
></div>
|
||||||
The winning player pays a 5% transaction fee
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="matching-action"
|
class="matching-action"
|
||||||
@ -2975,6 +2973,65 @@
|
|||||||
return Math.floor(number / 1000) + 'K';
|
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) {
|
function setCoin(value) {
|
||||||
var number = Number(value || 0);
|
var number = Number(value || 0);
|
||||||
if (!Number.isFinite(number)) number = 0;
|
if (!Number.isFinite(number)) number = 0;
|
||||||
@ -3341,22 +3398,7 @@
|
|||||||
selectStake(
|
selectStake(
|
||||||
selectedButton || document.querySelector('.stake')
|
selectedButton || document.querySelector('.stake')
|
||||||
);
|
);
|
||||||
if (config) {
|
renderFeeNote(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,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetFrame() {
|
function resetFrame() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user