Skip to content

Commit 25731d9

Browse files
committed
a disgustingly large update
1 parent 66ed049 commit 25731d9

27 files changed

+5165
-1321
lines changed

waddlebet/server/db/models/User.js

Lines changed: 21 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const userSchema = new mongoose.Schema({
2828
},
2929
characterType: {
3030
type: String,
31-
enum: ['penguin', 'marcus', 'whiteWhale', 'blackWhale', 'silverWhale', 'goldWhale', 'doginal', 'frog', 'shrimp', 'duck', 'tungTung', 'gake', 'pump'],
31+
enum: ['penguin', 'marcus', 'whiteWhale', 'blackWhale', 'silverWhale', 'goldWhale', 'doginal', 'frog', 'shrimp'],
3232
default: 'penguin'
3333
},
3434

@@ -363,66 +363,7 @@ const userSchema = new mongoose.Schema({
363363

364364
// ========== MIGRATION TRACKING ==========
365365
migrationSource: { type: String, default: null },
366-
migratedAt: { type: Date, default: null },
367-
368-
// ========== DAILY LOGIN BONUS ==========
369-
dailyBonus: {
370-
lastClaimAt: { type: Date, default: null }, // Last successful claim timestamp
371-
sessionStartTime: { type: Date, default: null }, // When current session started
372-
currentSessionMinutes: { type: Number, default: 0 }, // Minutes accumulated this session
373-
totalClaimed: { type: Number, default: 0 }, // Total bonuses claimed ever
374-
totalWaddleEarned: { type: Number, default: 0 }, // Total $WADDLE earned from daily bonus
375-
claimNonce: { type: String, default: null } // Unique nonce to prevent replay attacks
376-
},
377-
378-
// ========== REFERRAL SYSTEM ==========
379-
referral: {
380-
// Who referred this user (their wallet address)
381-
referredBy: { type: String, default: null },
382-
// When the referral was registered
383-
referredAt: { type: Date, default: null },
384-
385-
// Referral code (defaults to username, can be customized later)
386-
// Used in link: waddle.bet/ref/CODE
387-
referralCode: { type: String, default: null },
388-
389-
// Revenue share earnings (Tier 1: 15%, Tier 2: 3%)
390-
earnings: {
391-
// Accumulated balance (in SOL lamports) - paid out when >= 0.5 SOL
392-
pendingLamports: { type: String, default: '0' }, // String for BigInt precision
393-
// Total lifetime earnings paid out
394-
totalPaidOutLamports: { type: String, default: '0' },
395-
// Last payout info
396-
lastPayoutAt: { type: Date, default: null },
397-
lastPayoutTx: { type: String, default: null },
398-
lastPayoutAmount: { type: String, default: '0' }
399-
},
400-
401-
// Stats
402-
stats: {
403-
// Direct referrals (Tier 1)
404-
tier1Count: { type: Number, default: 0 }, // Users directly referred
405-
tier1ActiveCount: { type: Number, default: 0 }, // Active referrals (played 1hr+)
406-
tier1EarningsLamports: { type: String, default: '0' },
407-
// Indirect referrals (Tier 2)
408-
tier2Count: { type: Number, default: 0 },
409-
tier2EarningsLamports: { type: String, default: '0' },
410-
// Total revenue generated by network
411-
totalNetworkRevenueLamports: { type: String, default: '0' }
412-
},
413-
414-
// Launch promo: 1000 $CP for both referrer and referred
415-
// Requires: wallet connected + 60 min playtime
416-
promoReward: {
417-
eligible: { type: Boolean, default: false }, // Has met requirements
418-
claimed: { type: Boolean, default: false }, // 1000 $CP sent
419-
claimedAt: { type: Date, default: null },
420-
claimTxSignature: { type: String, default: null },
421-
// Also track if referrer got their bonus for this referral
422-
referrerRewarded: { type: Boolean, default: false },
423-
referrerRewardedAt: { type: Date, default: null }
424-
}
425-
}
366+
migratedAt: { type: Date, default: null }
426367

427368
}, {
428369
timestamps: true // Adds createdAt and updatedAt
@@ -439,9 +380,6 @@ userSchema.index({ 'gameStats.ticTacToe.wins': -1 });
439380
userSchema.index({ 'gameStats.overall.totalGamesWon': -1 });
440381
userSchema.index({ lastActiveAt: -1 });
441382
userSchema.index({ createdAt: -1 });
442-
// Referral system indexes
443-
userSchema.index({ 'referral.referralCode': 1 }, { sparse: true }); // Lookup by referral code
444-
userSchema.index({ 'referral.referredBy': 1 }, { sparse: true }); // Find all referrals for a user
445383

446384
// ==================== METHODS ====================
447385

@@ -699,25 +637,19 @@ userSchema.methods.getFullData = function() {
699637
createdAt: this.createdAt,
700638
lastUsernameChangeAt: this.lastUsernameChangeAt,
701639
canChangeUsername: this.canChangeUsername(),
702-
isEstablishedUser: isEstablished, // Tells client if user has entered world before
703-
// Referral info (basic - full stats via referral_info message)
704-
referral: {
705-
referralCode: this.referral?.referralCode || this.username,
706-
hasReferrer: !!this.referral?.referredBy,
707-
tier1Count: this.referral?.stats?.tier1Count || 0
708-
}
640+
isEstablishedUser: isEstablished // Tells client if user has entered world before
709641
};
710642
};
711643

712644
/**
713-
* Get full user data including gacha-owned cosmetic IDs and puffles
714-
* Call this when you need to include owned gacha items and puffles
645+
* Get full user data including gacha-owned cosmetic IDs
646+
* Call this when you need to include owned gacha items
715647
*/
716648
userSchema.methods.getFullDataAsync = async function() {
717649
const baseData = this.getFullData();
718650

651+
// Fetch gacha-owned cosmetic template IDs
719652
try {
720-
// Fetch gacha-owned cosmetic template IDs
721653
const OwnedCosmetic = mongoose.model('OwnedCosmetic');
722654
const ownedGacha = await OwnedCosmetic.find(
723655
{ ownerId: this.walletAddress, convertedToGold: false },
@@ -727,29 +659,15 @@ userSchema.methods.getFullDataAsync = async function() {
727659
// Get unique template IDs
728660
const gachaOwnedIds = [...new Set(ownedGacha.map(c => c.templateId))];
729661

730-
// Fetch user's puffles and update their stats based on time passed
731-
const Puffle = mongoose.model('Puffle');
732-
const puffles = await Puffle.find({ ownerWallet: this.walletAddress });
733-
734-
// Update stats for each puffle based on time decay and save
735-
const puffleData = [];
736-
for (const puffle of puffles) {
737-
puffle.updateStats();
738-
await puffle.save();
739-
puffleData.push(puffle.toClientData());
740-
}
741-
742662
return {
743663
...baseData,
744-
gachaOwnedCosmetics: gachaOwnedIds,
745-
puffles: puffleData
664+
gachaOwnedCosmetics: gachaOwnedIds
746665
};
747666
} catch (error) {
748-
console.error('Error fetching user async data:', error);
667+
console.error('Error fetching gacha-owned cosmetics:', error);
749668
return {
750669
...baseData,
751-
gachaOwnedCosmetics: [],
752-
puffles: []
670+
gachaOwnedCosmetics: []
753671
};
754672
}
755673
};
@@ -865,22 +783,21 @@ userSchema.methods.changeUsername = async function(newUsername) {
865783
* Update customization
866784
*/
867785
userSchema.methods.updateCustomization = function(customization) {
868-
// Always update if provided (including animated skins like 'cosmic', 'galaxy', etc.)
869-
if (customization.skin !== undefined) this.customization.skin = customization.skin;
870-
if (customization.hat !== undefined) this.customization.hat = customization.hat;
871-
if (customization.eyes !== undefined) this.customization.eyes = customization.eyes;
872-
if (customization.mouth !== undefined) this.customization.mouth = customization.mouth;
873-
if (customization.bodyItem !== undefined) this.customization.bodyItem = customization.bodyItem;
874-
if (customization.mount !== undefined) this.customization.mount = customization.mount;
875-
if (customization.characterType !== undefined) this.characterType = customization.characterType;
786+
if (customization.skin) this.customization.skin = customization.skin;
787+
if (customization.hat) this.customization.hat = customization.hat;
788+
if (customization.eyes) this.customization.eyes = customization.eyes;
789+
if (customization.mouth) this.customization.mouth = customization.mouth;
790+
if (customization.bodyItem) this.customization.bodyItem = customization.bodyItem;
791+
if (customization.mount) this.customization.mount = customization.mount;
792+
if (customization.characterType) this.characterType = customization.characterType;
876793
// Doginal freestyle colors
877-
if (customization.dogPrimaryColor !== undefined) this.customization.dogPrimaryColor = customization.dogPrimaryColor;
878-
if (customization.dogSecondaryColor !== undefined) this.customization.dogSecondaryColor = customization.dogSecondaryColor;
794+
if (customization.dogPrimaryColor) this.customization.dogPrimaryColor = customization.dogPrimaryColor;
795+
if (customization.dogSecondaryColor) this.customization.dogSecondaryColor = customization.dogSecondaryColor;
879796
// Frog freestyle colors
880-
if (customization.frogPrimaryColor !== undefined) this.customization.frogPrimaryColor = customization.frogPrimaryColor;
881-
if (customization.frogSecondaryColor !== undefined) this.customization.frogSecondaryColor = customization.frogSecondaryColor;
797+
if (customization.frogPrimaryColor) this.customization.frogPrimaryColor = customization.frogPrimaryColor;
798+
if (customization.frogSecondaryColor) this.customization.frogSecondaryColor = customization.frogSecondaryColor;
882799
// Shrimp color
883-
if (customization.shrimpPrimaryColor !== undefined) this.customization.shrimpPrimaryColor = customization.shrimpPrimaryColor;
800+
if (customization.shrimpPrimaryColor) this.customization.shrimpPrimaryColor = customization.shrimpPrimaryColor;
884801
return true;
885802
};
886803

waddlebet/src/App.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ const AppContent = () => {
197197
}
198198
};
199199

200-
ws.addEventListener('message', handleTip);
201-
return () => ws.removeEventListener('message', handleTip);
200+
ws.addEventListener('message', handleMessage);
201+
return () => ws.removeEventListener('message', handleMessage);
202202
}, []);
203203

204204
// Challenge context for P2P matches

waddlebet/src/VoxelPenguinDesigner.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,9 +2053,9 @@ function VoxelPenguinDesigner({ onEnterWorld, currentData, updateData }) {
20532053
c === 'rainbow' || c === 'prismatic' ? 'rainbowShift 8s linear infinite' :
20542054
c === 'holographic' ? 'rainbowShift 10s ease infinite' :
20552055
'cosmicShift 12s ease infinite';
2056-
return {
2056+
return {
20572057
background: style.background,
2058-
backgroundSize: '400% 400%',
2058+
backgroundSize: '400% 400%',
20592059
animation: animationName,
20602060
glowColor: style.glowColor
20612061
};

0 commit comments

Comments
 (0)