Merge feature/ingame-farben in main
This commit is contained in:
commit
123c2f11d7
3 files changed
+86
-28
No files matched your search
@@ -838,7 +838,7 @@ test('Ingame-Chat: Hinweise nach dem Laden, beim Start und am Map-Ende', async (
|
||||
const said = [];
|
||||
const send = app.adapter.sendCommands.bind(app.adapter);
|
||||
app.adapter.sendCommands = async (h, commands) => {
|
||||
said.push(...commands.filter((c) => c.startsWith('say ')).map((c) => c.slice(4)));
|
||||
said.push(...commands.filter((c) => c.startsWith('say ')).map((c) => c.slice(4).replace(/[-]/g, '').trim()));
|
||||
return send(h, commands);
|
||||
};
|
||||
const { id, org, tokens } = await readyWingmanMatch(call, 'bo3');
|
||||
|
||||
@@ -1,32 +1,34 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { chatText, mapEndLines, mapLoadedLines, matchStartLines, sayCommands } from '../src/servers/chatAnnouncements.js';
|
||||
import { chatText, COLOR, mapEndLines, mapLoadedLines, matchStartLines, sayCommands } from '../src/servers/chatAnnouncements.js';
|
||||
|
||||
const teams = { A: 'Nordlicht', B: 'Hafenkante' };
|
||||
// Text ohne Farbcodes, zum Vergleichen des Inhalts
|
||||
const plain = (lines) => lines.map((l) => l.replace(/[-]/g, ''));
|
||||
|
||||
test('Hinweise nach dem Laden: Map, Wahl, Seiten, Serienstand, Aufwärmphase', () => {
|
||||
const lines = mapLoadedLines({
|
||||
teams, total: 3, series: { A: 1, B: 0 },
|
||||
map: { number: 2, mapName: 'Inferno', pickedBy: 'B', sideChosenBy: 'A', ctTeam: 'A' },
|
||||
});
|
||||
assert.deepEqual(lines, [
|
||||
assert.deepEqual(plain(lines), [
|
||||
'Map 2 von 3: Inferno - gewählt von Hafenkante',
|
||||
'Nordlicht hat die Seite gewählt: Nordlicht startet als CT, Hafenkante als T',
|
||||
'Serienstand: Nordlicht 1:0 Hafenkante',
|
||||
'Aufwärmphase - das Match startet, sobald der Organisator es freigibt',
|
||||
]);
|
||||
const bo1 = mapLoadedLines({ teams, total: 1, series: { A: 0, B: 0 }, map: { number: 1, mapName: 'Nuke', pickedBy: null, sideChosenBy: 'B', ctTeam: 'B' } });
|
||||
assert.equal(bo1[0], 'Map: Nuke - Entscheidungsmap');
|
||||
assert.equal(plain(bo1)[0], 'Map: Nuke - Entscheidungsmap');
|
||||
assert.ok(!bo1.some((l) => l.startsWith('Serienstand')), 'kein Serienstand im BO1');
|
||||
});
|
||||
|
||||
test('Hinweise bei Match-Start und Map-Ende', () => {
|
||||
assert.deepEqual(matchStartLines({ teams, ctTeam: 'B' }), ['Match live! Hafenkante (CT) gegen Nordlicht (T) - viel Glück, have fun']);
|
||||
assert.deepEqual(plain(matchStartLines({ teams, ctTeam: 'B' })), ['Match live! Hafenkante (CT) gegen Nordlicht (T) - viel Glück, have fun']);
|
||||
const next = mapEndLines({
|
||||
teams, total: 3, decided: null, nextMapName: 'Inferno', autoAdvanceSeconds: 30, series: { A: 1, B: 0 },
|
||||
map: { number: 1, mapName: 'Mirage', winner: 'A', score: { A: 13, B: 9 } },
|
||||
});
|
||||
assert.deepEqual(next, [
|
||||
assert.deepEqual(plain(next), [
|
||||
'Map 1 (Mirage) geht an Nordlicht mit 13:9',
|
||||
'Serienstand: Nordlicht 1:0 Hafenkante',
|
||||
'Nächste Map: Inferno, wird in 30 s geladen - bleibt auf dem Server',
|
||||
@@ -35,11 +37,28 @@ test('Hinweise bei Match-Start und Map-Ende', () => {
|
||||
teams, total: 3, decided: 'B', nextMapName: null, autoAdvanceSeconds: 30, series: { A: 0, B: 2 },
|
||||
map: { number: 2, mapName: 'Nuke', winner: 'B', score: { A: 5, B: 13 } },
|
||||
});
|
||||
assert.equal(won[1], 'Hafenkante gewinnt die Serie 2:0 - danke fürs Spielen!');
|
||||
assert.equal(plain(won)[1], 'Hafenkante gewinnt die Serie 2:0 - danke fürs Spielen!');
|
||||
});
|
||||
|
||||
test('Chattexte können keine weiteren Befehle anhängen', () => {
|
||||
assert.equal(chatText('Team"; rcon_password x; say "'), 'Team rcon_password x say');
|
||||
assert.deepEqual(sayCommands(['Hallo; quit', '', 'Stand 13:9']), ['say Hallo quit', 'say Stand 13:9']);
|
||||
assert.deepEqual(sayCommands(['Hallo; quit', '', 'Stand 13:9']), ['say Hallo quit', 'say Stand 13:9']);
|
||||
assert.ok(chatText('x'.repeat(300)).length <= 120);
|
||||
});
|
||||
|
||||
test('Farben: CT blau, T gold, Sieger grün, Aufwärmphase gelb; Eingaben bringen keine eigenen Farben mit', () => {
|
||||
const loaded = mapLoadedLines({ teams, total: 1, series: { A: 0, B: 0 }, map: { number: 1, mapName: 'Nuke', pickedBy: null, sideChosenBy: 'B', ctTeam: 'B' } });
|
||||
const sides = loaded.find((l) => l.includes('startet als'));
|
||||
assert.ok(sides.includes(`${COLOR.blue}Hafenkante${COLOR.white}`), 'CT-Team blau');
|
||||
assert.ok(sides.includes(`${COLOR.gold}Nordlicht${COLOR.white}`), 'T-Team gold');
|
||||
assert.ok(loaded.at(-1).startsWith(COLOR.yellow), 'Aufwärmphase gelb');
|
||||
assert.ok(matchStartLines({ teams, ctTeam: 'A' })[0].startsWith(`${COLOR.green}Match live!`));
|
||||
const end = mapEndLines({ teams, total: 1, decided: null, nextMapName: null, autoAdvanceSeconds: 30, series: { A: 1, B: 0 }, map: { number: 1, mapName: 'Nuke', winner: 'A', score: { A: 13, B: 2 } } });
|
||||
assert.ok(end[0].includes(`${COLOR.green}Nordlicht${COLOR.white}`), 'Sieger grün');
|
||||
|
||||
// Farbcodes im Teamnamen werden entfernt, die eigenen Farben bleiben
|
||||
const evil = matchStartLines({ teams: { A: `BöseRot`, B: 'Gut' }, ctTeam: 'A' })[0];
|
||||
assert.ok(evil.includes(`${COLOR.blue}BöseRot${COLOR.white}`));
|
||||
const [cmd] = sayCommands([`${COLOR.yellow}gelb ${COLOR.blue}blau"; quit`]);
|
||||
assert.equal(cmd, `say ${COLOR.yellow}gelb ${COLOR.blue}blau quit`, 'nur erlaubte Codes, kein Befehl anhängbar, Farben am Anfang bleiben');
|
||||
});
|
||||
Reference in new issue
Block a user