Skip to content

Commit 3374478

Browse files
authored
Merge pull request #117 from slamanna212/dev
v0.3.0
2 parents 13f9e45 + 2d9f34f commit 3374478

36 files changed

+335
-48
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"id": "cs2",
3+
"name": "Counter-Strike 2",
4+
"color": "#FF6600",
5+
"genre": "Tactical FPS",
6+
"developer": "Valve Corporation",
7+
"releaseDate": "2023-09-27",
8+
"patch": "2024-12-10",
9+
"dataVersion": "1.0.6",
10+
"minPlayers": 2,
11+
"maxPlayers": 20,
12+
"maxSignups": 30,
13+
"mapCodesSupported": false,
14+
"assets": {
15+
"iconUrl": "/assets/games/cs2/cs2icon.png",
16+
"coverUrl": "/assets/games/cs2/cs2cover.png"
17+
}
18+
}
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
[
2+
{
3+
"id": "ancient",
4+
"name": "Ancient",
5+
"supportedModes": ["premier", "normal", "deathmatch"],
6+
"location": "Peru",
7+
"thumbnailUrl": "/public/assets/games/cs2/maps/ancient.jpg"
8+
},
9+
{
10+
"id": "anubis",
11+
"name": "Anubis",
12+
"supportedModes": ["premier", "normal", "deathmatch"],
13+
"location": "Egypt",
14+
"thumbnailUrl": "/public/assets/games/cs2/maps/anubis.jpg"
15+
},
16+
{
17+
"id": "dust2",
18+
"name": "Dust II",
19+
"supportedModes": ["premier", "normal", "deathmatch"],
20+
"location": "Morocco",
21+
"thumbnailUrl": "/public/assets/games/cs2/maps/dust2.jpg"
22+
},
23+
{
24+
"id": "inferno",
25+
"name": "Inferno",
26+
"supportedModes": ["premier", "normal", "deathmatch", "wingman"],
27+
"location": "Italy",
28+
"thumbnailUrl": "/public/assets/games/cs2/maps/inferno.jpeg"
29+
},
30+
{
31+
"id": "mirage",
32+
"name": "Mirage",
33+
"supportedModes": ["premier", "normal", "deathmatch"],
34+
"location": "Morocco",
35+
"thumbnailUrl": "/public/assets/games/cs2/maps/mirage.jpg"
36+
},
37+
{
38+
"id": "nuke",
39+
"name": "Nuke",
40+
"supportedModes": ["premier", "normal", "deathmatch", "wingman"],
41+
"location": "Germany",
42+
"thumbnailUrl": "/public/assets/games/cs2/maps/nuke.jpeg"
43+
},
44+
{
45+
"id": "train",
46+
"name": "Train",
47+
"supportedModes": ["premier", "normal", "deathmatch"],
48+
"location": "Russia",
49+
"thumbnailUrl": "/public/assets/games/cs2/maps/train.png"
50+
},
51+
{
52+
"id": "overpass",
53+
"name": "Overpass",
54+
"supportedModes": ["normal", "deathmatch", "wingman"],
55+
"location": "Germany",
56+
"thumbnailUrl": "/public/assets/games/cs2/maps/overpass.jpg"
57+
},
58+
{
59+
"id": "vertigo",
60+
"name": "Vertigo",
61+
"supportedModes": ["normal", "deathmatch", "wingman"],
62+
"location": "France",
63+
"thumbnailUrl": "/public/assets/games/cs2/maps/vertigo.jpeg"
64+
},
65+
{
66+
"id": "grail",
67+
"name": "Grail",
68+
"supportedModes": ["normal", "deathmatch"],
69+
"location": "Castle",
70+
"thumbnailUrl": "/public/assets/games/cs2/maps/grail.webp"
71+
},
72+
{
73+
"id": "jura",
74+
"name": "Jura",
75+
"supportedModes": ["normal", "deathmatch"],
76+
"location": "Switzerland",
77+
"thumbnailUrl": "/public/assets/games/cs2/maps/jura.webp"
78+
},
79+
{
80+
"id": "office",
81+
"name": "Office",
82+
"supportedModes": ["normal", "deathmatch"],
83+
"location": "Office Building",
84+
"thumbnailUrl": "/public/assets/games/cs2/maps/office.webp"
85+
},
86+
{
87+
"id": "italy",
88+
"name": "Italy",
89+
"supportedModes": ["normal", "deathmatch"],
90+
"location": "Italy",
91+
"thumbnailUrl": "/public/assets/games/cs2/maps/italy.webp"
92+
},
93+
{
94+
"id": "agency",
95+
"name": "Agency",
96+
"supportedModes": ["normal", "deathmatch"],
97+
"location": "Office Building",
98+
"thumbnailUrl": "/public/assets/games/cs2/maps/agency.webp"
99+
},
100+
{
101+
"id": "brewery",
102+
"name": "Brewery",
103+
"supportedModes": ["wingman"],
104+
"location": "Germany",
105+
"thumbnailUrl": "/public/assets/games/cs2/maps/brewery.webp"
106+
},
107+
{
108+
"id": "dogtown",
109+
"name": "Dogtown",
110+
"supportedModes": ["wingman"],
111+
"location": "Urban",
112+
"thumbnailUrl": "/public/assets/games/cs2/maps/dogtown.webp"
113+
},
114+
{
115+
"id": "baggage",
116+
"name": "Baggage",
117+
"supportedModes": ["arms-race"],
118+
"location": "Airport",
119+
"thumbnailUrl": "/public/assets/games/cs2/maps/baggage.webp"
120+
},
121+
{
122+
"id": "shoots",
123+
"name": "Shoots",
124+
"supportedModes": ["arms-race"],
125+
"location": "Western USA",
126+
"thumbnailUrl": "/public/assets/games/cs2/maps/shoots.webp"
127+
},
128+
{
129+
"id": "pool-day",
130+
"name": "Pool Day",
131+
"supportedModes": ["arms-race"],
132+
"location": "Resort",
133+
"thumbnailUrl": "/public/assets/games/cs2/maps/pool-day.webp"
134+
},
135+
{
136+
"id": "custom-map",
137+
"name": "Custom Map",
138+
"supportedModes": ["premier", "normal", "deathmatch", "wingman", "arms-race", "hostage-rescue"],
139+
"location": "Custom",
140+
"thumbnailUrl": "/public/assets/games/cs2/maps/custom-map.jpg"
141+
}
142+
]
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[
2+
{
3+
"id": "normal",
4+
"name": "Normal",
5+
"description": "Standard competitive and casual gameplay with standard CS2 rules.",
6+
"scoringType": "Normal"
7+
},
8+
{
9+
"id": "premier",
10+
"name": "Premier",
11+
"description": "Premier competitive mode with pick/ban phase and rating system.",
12+
"scoringType": "Normal"
13+
},
14+
{
15+
"id": "deathmatch",
16+
"name": "Deathmatch",
17+
"description": "Free-for-all combat with respawns and weapon pickups.",
18+
"scoringType": "FFA"
19+
},
20+
{
21+
"id": "wingman",
22+
"name": "Wingman",
23+
"description": "2v2 competitive matches on smaller maps.",
24+
"scoringType": "Normal"
25+
},
26+
{
27+
"id": "arms-race",
28+
"name": "Arms Race",
29+
"description": "Progress through weapons by getting kills, first to finish wins.",
30+
"scoringType": "FFA"
31+
},
32+
{
33+
"id": "hostage-rescue",
34+
"name": "Hostage Rescue",
35+
"description": "Counter-Terrorists must rescue hostages from Terrorist control.",
36+
"scoringType": "Normal"
37+
}
38+
]

eslint.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const eslintConfig = [{
1515
files: ["processes/**/*.ts"],
1616
rules: {
1717
"@typescript-eslint/no-explicit-any": "off",
18-
"@typescript-eslint/ban-ts-comment": "off"
18+
"@typescript-eslint/ban-ts-comment": "off",
19+
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
1920
}
2021
}];
2122

lib/database/seeder.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,37 @@ export class DatabaseSeeder {
222222
// Clear existing maps for this game
223223
await this.db.run('DELETE FROM game_maps WHERE game_id = ?', [gameId]);
224224

225-
if (supportsAllModes) {
225+
// Check if any map has supportedModes array
226+
const hasSupportedModes = mapsData.some(map => Array.isArray((map as MapData & { supportedModes?: string[] }).supportedModes));
227+
228+
if (hasSupportedModes) {
229+
// New approach: maps define their supported modes via supportedModes array
230+
for (const map of mapsData) {
231+
const mapWithModes = map as MapData & { supportedModes?: string[] };
232+
// Fix image URL by removing /public prefix for Next.js static assets
233+
let imageUrl = map.thumbnailUrl || null;
234+
if (imageUrl && imageUrl.startsWith('/public/')) {
235+
imageUrl = imageUrl.replace('/public/', '/');
236+
}
237+
238+
if (mapWithModes.supportedModes && Array.isArray(mapWithModes.supportedModes)) {
239+
// Create an entry for each supported mode
240+
for (const modeId of mapWithModes.supportedModes) {
241+
const mapIdWithMode = `${map.id}-${modeId}`;
242+
await this.db.run(`
243+
INSERT INTO game_maps (id, game_id, name, mode_id, image_url, location, updated_at)
244+
VALUES (?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)
245+
`, [mapIdWithMode, gameId, map.name, modeId, imageUrl, map.location || null]);
246+
}
247+
} else {
248+
// Fallback: create with null mode_id
249+
await this.db.run(`
250+
INSERT INTO game_maps (id, game_id, name, mode_id, image_url, location, updated_at)
251+
VALUES (?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP)
252+
`, [map.id, gameId, map.name, null, imageUrl, map.location || null]);
253+
}
254+
}
255+
} else if (supportsAllModes) {
226256
// For games that support all modes on all maps (like Valorant)
227257
// Get all modes for this game first
228258
const modes = await this.db.all<{ id: string }>('SELECT id FROM game_modes WHERE game_id = ?', [gameId]);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "match-bot",
3-
"version": "0.2.7",
3+
"version": "0.3.0",
44
"private": true,
55
"scripts": {
66
"dev": "next dev --turbo",

processes/discord-bot/modules/interaction-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ export class InteractionHandler {
229229
if (field.id === 'username' || field.id === 'battlenet_name') {
230230
displayUsername = value;
231231
}
232-
} catch (_e) {
232+
} catch {
233233
// Field might not exist in modal if we hit the 5-field limit
234234
if (field.required) {
235235
throw new Error(`Required field ${field.id} is missing`);

processes/discord-bot/modules/queue-processor.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class QueueProcessor {
138138
if (announcement.maps) {
139139
try {
140140
maps = JSON.parse(announcement.maps);
141-
} catch (_e) {
141+
} catch {
142142
maps = [];
143143
}
144144
}
@@ -163,7 +163,7 @@ export class QueueProcessor {
163163
try {
164164
const timingData = JSON.parse(announcement.announcement_data);
165165
eventData._timingInfo = timingData;
166-
} catch (_e) {
166+
} catch {
167167
console.warn('Could not parse timing data for timed announcement:', announcement.id);
168168
}
169169
}
@@ -291,16 +291,13 @@ export class QueueProcessor {
291291
WHERE match_id = ?
292292
`, [matchId]);
293293

294-
// Track deleted count for logging if needed
295-
let _deletedCount = 0;
296294

297295
for (const record of messages) {
298296
try {
299297
// Delete the Discord message
300298
const channel = await this.client.channels.fetch(record.channel_id);
301299
if (channel?.isTextBased() && 'messages' in channel) {
302300
await channel.messages.delete(record.message_id);
303-
_deletedCount++;
304301
}
305302

306303
// Delete thread if exists
@@ -403,8 +400,6 @@ export class QueueProcessor {
403400
WHERE id = ?
404401
`, [finalStatus, errorMessage, update.id]);
405402

406-
// Status icon for logging if needed
407-
const _statusIcon = success ? '✅' : '❌';
408403

409404
} catch (error) {
410405
console.error(`❌ Error processing status update ${update.id}:`, error);
@@ -492,8 +487,6 @@ export class QueueProcessor {
492487
WHERE id = ?
493488
`, [status, reminder.id]);
494489

495-
// Result icon for logging if needed
496-
const _resultIcon = success ? '✅' : '❌';
497490

498491
} catch (error) {
499492
console.error(`❌ Error processing reminder ${reminder.id}:`, error);
@@ -574,8 +567,6 @@ export class QueueProcessor {
574567
WHERE id = ?
575568
`, [status, reminder.id]);
576569

577-
// Result icon for logging if needed
578-
const _resultIcon = success ? '✅' : '❌';
579570

580571
} catch (error) {
581572
console.error(`❌ Error processing player reminder ${reminder.id}:`, error);
@@ -682,8 +673,6 @@ export class QueueProcessor {
682673
request.id
683674
]);
684675

685-
// Status icon for logging if needed
686-
const _statusIcon = result.success ? '✅' : '❌';
687676

688677
} finally {
689678
// Always remove user from processing set
@@ -763,7 +752,7 @@ export class QueueProcessor {
763752
let winningPlayers: string[] = [];
764753
try {
765754
winningPlayers = JSON.parse(notification.winning_players);
766-
} catch (_e) {
755+
} catch {
767756
console.warn('Could not parse winning players JSON for notification:', notification.id);
768757
}
769758

@@ -1020,7 +1009,7 @@ export class QueueProcessor {
10201009
let winningPlayers: string[] = [];
10211010
try {
10221011
winningPlayers = JSON.parse(notification.winning_players);
1023-
} catch (_e) {
1012+
} catch {
10241013
console.warn('Could not parse winning players JSON for winner notification:', notification.id);
10251014
}
10261015

0 commit comments

Comments
 (0)