From 5b27bee3bd3e3124c8003ffbe6f6106e55ef9b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9odore=20Noel?= Date: Sun, 25 May 2025 20:02:13 +0200 Subject: [PATCH] Allow lowercase letters in clan name (#877) ## Description: Added possibility to use lowercase letters in clan name. See issue #876 ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: theodoreleon.aetarax --- src/core/game/Game.ts | 2 +- tests/PlayerInfo.test.ts | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/core/game/Game.ts b/src/core/game/Game.ts index d82862b21..112083238 100644 --- a/src/core/game/Game.ts +++ b/src/core/game/Game.ts @@ -334,7 +334,7 @@ export class PlayerInfo { if (!name.startsWith("[") || !name.includes("]")) { this.clan = null; } else { - const clanMatch = name.match(/^\[([A-Z]{2,5})\]/); + const clanMatch = name.match(/^\[([a-zA-Z]{2,5})\]/); this.clan = clanMatch ? clanMatch[1] : null; } } diff --git a/tests/PlayerInfo.test.ts b/tests/PlayerInfo.test.ts index 9cb1275e2..2d61676ab 100644 --- a/tests/PlayerInfo.test.ts +++ b/tests/PlayerInfo.test.ts @@ -46,6 +46,28 @@ describe("PlayerInfo", () => { expect(playerInfo.clan).toBe("ABCDE"); }); + test("should extract clan from name when format is [xxxxx]Name", () => { + const playerInfo = new PlayerInfo( + "fr", + "[abcde]PlayerName", + PlayerType.Human, + null, + "player_id", + ); + expect(playerInfo.clan).toBe("abcde"); + }); + + test("should extract clan from name when format is [XxXxX]Name", () => { + const playerInfo = new PlayerInfo( + "fr", + "[AbCdE]PlayerName", + PlayerType.Human, + null, + "player_id", + ); + expect(playerInfo.clan).toBe("AbCdE"); + }); + test("should return null when name doesn't start with [", () => { const playerInfo = new PlayerInfo( "fr", @@ -79,10 +101,10 @@ describe("PlayerInfo", () => { expect(playerInfo.clan).toBeNull(); }); - test("should return null when clan tag contains non-uppercase letters", () => { + test("should return null when clan tag contains non alphanumeric characters", () => { const playerInfo = new PlayerInfo( "fr", - "[Abc]PlayerName", + "[A1c]PlayerName", PlayerType.Human, null, "player_id",