Skip to content

Commit

Permalink
pull in changes from ts branch (UNTESTED)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenruidigao committed Jan 17, 2025
1 parent 11747e0 commit d8c7c02
Showing 1 changed file with 38 additions and 7 deletions.
45 changes: 38 additions & 7 deletions routes/socket/user-events/moderation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1049,21 +1049,52 @@ module.exports.handleModerationAction = (socket, passport, data, skipCheck, modU
Account.findOne({ username: data.userName })
.then(account => {
if (account) {
account[setType] = isPlusOrMinus
if (!account.overall) {
account.overall = {
wins: 0,
losses: 0,
rainbowWins: 0,
rainbowLosses: 0,
elo: 1600,
xp: 0
};
}

account.overall[setType] = isPlusOrMinus
? number.charAt(0) === '+'
? account[setType] + parseInt(number.substr(1, number.length))
: account[setType] - parseInt(number.substr(1, number.length))
? account.overall[setType] + parseInt(number.substr(1, number.length))
: account.overall[setType] - parseInt(number.substr(1, number.length))
: parseInt(number);

if (!data.action.isNonSeason) {
account[`${setType}Season${currentSeasonNumber}`] = isPlusOrMinus
? account[`${setType}Season${currentSeasonNumber}`]
if (!account.seasons) {
account.seasons = new Map();
}

let currentSeason = account.seasons.get(CURRENT_SEASON_NUMBER.toString()); // TODO: NEED TO CHANGE ON OTHER BRANCHES

if (!currentSeason) {
currentSeason = {
wins: 0,
losses: 0,
rainbowWins: 0,
rainbowLosses: 0,
elo: 1600,
xp: 0
};
}

currentSeason[setType] = isPlusOrMinus
? currentSeason[setType]
? number.charAt(0) === '+'
? account[`${setType}Season${currentSeasonNumber}`] + parseInt(number.substr(1, number.length))
: account[`${setType}Season${currentSeasonNumber}`] - parseInt(number.substr(1, number.length))
? currentSeason[setType] + parseInt(number.substr(1, number.length))
: currentSeason[setType] - parseInt(number.substr(1, number.length))
: parseInt(number.substr(1, number.length))
: parseInt(number);

account.seasons.set(CURRENT_SEASON_NUMBER.toString(), currentSeason); // TODO: NEED TO CHANGE ON OTHER BRANCHES
}

account.save();
} else socket.emit('sendAlert', `No account found with a matching username: ${data.userName}`);
})
Expand Down

0 comments on commit d8c7c02

Please sign in to comment.