mirror of
https://github.com/Such-Software/wownerogue.git
synced 2026-10-25 01:58:33 +02:00
fix payout calcs
This commit is contained in:
@@ -73,8 +73,8 @@ class GameModeManager {
|
||||
this.singleGamePrice = parseAtomicEnvValue(process.env.SINGLE_GAME_PRICE, this.singleGamePrice);
|
||||
this.creditsPackagePrice = parseAtomicEnvValue(process.env.CREDITS_PACKAGE_PRICE, this.creditsPackagePrice);
|
||||
this.creditsPerGameCost = parseAtomicEnvValue(process.env.CREDITS_PER_GAME, 1) || 1;
|
||||
this.creditsPayoutEnabled = /^true$/i.test(process.env.CREDITS_PAYOUT_ENABLED || 'false');
|
||||
this.creditsPayoutBaseValue = this.singleGamePrice;
|
||||
this.creditsPayoutEnabled = /^true$/i.test(process.env.CREDITS_PAYOUTS_ENABLED || process.env.CREDITS_PAYOUT_ENABLED || 'false');
|
||||
this.creditsPayoutBaseValue = parseAtomicEnvValue(process.env.CREDITS_PAYOUT_BASE, this.singleGamePrice);
|
||||
process.env.CREDITS_PER_GAME = String(this.creditsPerGameCost);
|
||||
|
||||
const directEscape = Number(process.env.DIRECT_PAYOUT_ESCAPE);
|
||||
@@ -370,7 +370,7 @@ class GameModeManager {
|
||||
console.log(`🧮 Payout multipliers - direct: ${JSON.stringify(this.directPayoutMultipliers)}, credits: ${JSON.stringify(this.creditPayoutMultipliers)}`);
|
||||
console.log(`🔁 Mode availability - direct: ${this.directModeEnabled}, credits: ${this.creditsModeEnabled}, preferCreditsFirst: ${this.preferCreditsFirst}`);
|
||||
if (this.creditsPayoutEnabled) {
|
||||
console.log('🎁 Credits payout mode ENABLED (will pay rewards in PAID_CREDITS).');
|
||||
console.log(`🎁 Credits payout mode ENABLED - base value: ${this.creditsPayoutBaseValue} atomic (~${this.formatAtomic(this.creditsPayoutBaseValue)} ${this.cryptoType})`);
|
||||
}
|
||||
console.log(`⚙️ Payments enabled: ${this.paymentsEnabled}`);
|
||||
}
|
||||
@@ -1011,6 +1011,9 @@ class GameModeManager {
|
||||
* Get game mode info for frontend
|
||||
*/
|
||||
getGameModeInfo() {
|
||||
// Debug: Log credits payout base value being sent
|
||||
console.log(`📤 getGameModeInfo: creditsPayoutBaseValue = ${this.creditsPayoutBaseValue} (${this.formatAtomic(this.creditsPayoutBaseValue)} ${this.cryptoType})`);
|
||||
|
||||
// Determine if we should show a testnet warning
|
||||
// Only for XMR on stagenet/testnet - WOW only has mainnet
|
||||
const showTestnetWarning = this.cryptoType === 'XMR' && this.isTestNetwork;
|
||||
|
||||
@@ -8,10 +8,23 @@ class BroadcastManager {
|
||||
constructor(io) {
|
||||
this.io = io;
|
||||
this._lastBroadcastBlock = null;
|
||||
this._lastUserCount = -1;
|
||||
}
|
||||
|
||||
// ====== GLOBAL BROADCASTS (All Clients) ======
|
||||
|
||||
/**
|
||||
* Broadcast connected user count to all clients
|
||||
*/
|
||||
broadcastUserCount() {
|
||||
const count = this.io.engine ? this.io.engine.clientsCount : 0;
|
||||
// Only broadcast if count changed to avoid spam
|
||||
if (count !== this._lastUserCount) {
|
||||
this._lastUserCount = count;
|
||||
this.io.emit('user_count', { count });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast block height to all connected clients
|
||||
* @param {number} blockHeight - Current block height
|
||||
|
||||
@@ -64,6 +64,9 @@ class ConnectionHandler {
|
||||
// Send current state
|
||||
this._sendConnectionStatus(socket);
|
||||
|
||||
// Broadcast updated user count to all clients
|
||||
this.broadcastManager.broadcastUserCount();
|
||||
|
||||
return { sessionInfo, memUser };
|
||||
|
||||
} catch (error) {
|
||||
@@ -112,6 +115,9 @@ class ConnectionHandler {
|
||||
// Clean up user records
|
||||
user.removeUser(socket.client.id);
|
||||
|
||||
// Broadcast updated user count to all clients
|
||||
this.broadcastManager.broadcastUserCount();
|
||||
|
||||
// Call additional cleanup if provided
|
||||
if (additionalCleanup && typeof additionalCleanup === 'function') {
|
||||
additionalCleanup(socket);
|
||||
|
||||
Reference in New Issue
Block a user