Skip to content

Commit 0a3893a

Browse files
committed
Fuck hard for abandons
1 parent d815ec8 commit 0a3893a

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

src/gameserver/event-handler/crime-log-created.handler.ts

+21-11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ import { PlayerId } from 'gateway/shared-types/player-id';
1111
import { PlayerBanEntity } from 'gameserver/model/player-ban.entity';
1212
import { MatchmakingMode } from 'gateway/shared-types/matchmaking-mode';
1313

14+
const ABANDON_PUNISHMENTS = [
15+
1000 * 60 * 60 * 12, // 12 hours
16+
1000 * 60 * 60 * 24, // 24 hours
17+
1000 * 60 * 60 * 24 * 5, // 5 days
18+
1000 * 60 * 60 * 24 * 14, // 2 weeks
19+
1000 * 60 * 60 * 24 * 30, // 1 month
20+
];
21+
1422
export const getBasePunishment = (crime: BanReason) => {
1523
switch (crime) {
1624
case BanReason.INFINITE_BAN:
@@ -35,7 +43,7 @@ export const getPunishmentCumulativeInterval = (crime: BanReason): string => {
3543
case BanReason.LOAD_FAILURE:
3644
return "24h";
3745
case BanReason.ABANDON:
38-
return "7d";
46+
return "21d";
3947
default:
4048
return "1m";
4149
}
@@ -129,17 +137,19 @@ export class CrimeLogCreatedHandler
129137

130138
// We do `+1` because it doesn't count current crime, but we want to
131139
let totalPunishmentCount = (countedCrimes.get(thisCrime.crime) || 0) + 1;
132-
const basePunishment = getBasePunishment(thisCrime.crime);
133-
let punishmentDuration = basePunishment * totalPunishmentCount;
134-
135-
// console.log(
136-
// countedCrimes,
137-
// totalPunishmentCount,
138-
// basePunishment,
139-
// punishmentDuration,
140-
// thisCrime,
141-
// );
142140

141+
let punishmentDuration: number;
142+
if (thisCrime.crime === BanReason.ABANDON) {
143+
// Use predefined punishments
144+
const punishmentIdx = Math.min(
145+
totalPunishmentCount,
146+
ABANDON_PUNISHMENTS.length - 1,
147+
);
148+
punishmentDuration = ABANDON_PUNISHMENTS[punishmentIdx];
149+
} else {
150+
const basePunishment = getBasePunishment(thisCrime.crime);
151+
punishmentDuration = basePunishment * totalPunishmentCount;
152+
}
143153
this.logger.log(
144154
`Punishment: ${punishmentDuration / 1000 / 60} minutes for ${
145155
thisCrime.steam_id

0 commit comments

Comments
 (0)