mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-10-18 14:51:26 +02:00
single_game payment and audio alerts working
This commit is contained in:
@@ -126,8 +126,14 @@ const AudioAlerts = {
|
||||
playFile(tag) {
|
||||
if (!this._enabled) return;
|
||||
const now = Date.now();
|
||||
if (now - this._lastPlay < this._cooldownMs) return;
|
||||
this._lastPlay = now;
|
||||
// Per-tag cooldown so different event types can fire back-to-back (e.g. payment_confirmed -> game_start)
|
||||
if (!this._audioTagTimes) this._audioTagTimes = {}; // tag -> last play timestamp
|
||||
const lastForTag = this._audioTagTimes[tag] || 0;
|
||||
const elapsed = now - lastForTag;
|
||||
const allow = elapsed >= this._cooldownMs || (tag === 'game_start' && this._lastTag !== 'game_start');
|
||||
if (!allow) return;
|
||||
this._audioTagTimes[tag] = now;
|
||||
this._lastTag = tag;
|
||||
const el = this._getAudio(tag);
|
||||
if (!el) return;
|
||||
try { el.currentTime = 0; el.play().catch(()=>{}); } catch(_) {}
|
||||
|
||||
Reference in New Issue
Block a user