Skip to content

Commit

Permalink
Add matchMapCount field to some events
Browse files Browse the repository at this point in the history
  • Loading branch information
JensForstmann committed Apr 3, 2024
1 parent ca7379c commit 740acdd
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 11 deletions.
5 changes: 5 additions & 0 deletions backend/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export const onKnifeRoundEnd = (match: Match.Match, matchMap: IMatchMap, winnerT
...getBaseEvent(match, 'KNIFE_END'),
mapIndex: match.data.currentMap,
mapName: matchMap.name,
matchMapCount: match.data.matchMaps.length,
winnerTeam: winnerTeam,
};
send(match, data);
Expand All @@ -125,6 +126,7 @@ export const onRoundEnd = (match: Match.Match, matchMap: IMatchMap, winnerTeam:
...getBaseEvent(match, 'ROUND_END'),
mapIndex: match.data.currentMap,
mapName: matchMap.name,
matchMapCount: match.data.matchMaps.length,
winnerTeam: winnerTeam,
scoreTeamA: matchMap.score.teamA,
scoreTeamB: matchMap.score.teamB,
Expand Down Expand Up @@ -185,6 +187,7 @@ export const onMatchEnd = (match: Match.Match, wonMapsTeamA: number, wonMapsTeam
? match.data.teamA
: match.data.teamB,
})),
matchMapCount: match.data.matchMaps.length,
};
send(match, data);
};
Expand All @@ -194,6 +197,7 @@ export const onMapStart = (match: Match.Match, matchMap: IMatchMap) => {
...getBaseEvent(match, 'MAP_START'),
mapIndex: match.data.currentMap,
mapName: matchMap.name,
matchMapCount: match.data.matchMaps.length,
};
send(match, data);
};
Expand All @@ -203,6 +207,7 @@ export const onMapEnd = (match: Match.Match, matchMap: IMatchMap) => {
...getBaseEvent(match, 'MAP_END'),
mapIndex: match.data.currentMap,
mapName: matchMap.name,
matchMapCount: match.data.matchMaps.length,
scoreTeamA: matchMap.score.teamA,
scoreTeamB: matchMap.score.teamB,
winnerTeam:
Expand Down
22 changes: 21 additions & 1 deletion backend/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,21 @@ const models: TsoaRoute.Models = {
additionalProperties: false,
},
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
TTeamString: {
dataType: 'refAlias',
type: {
dataType: 'union',
subSchemas: [
{ dataType: 'enum', enums: ['Unassigned'] },
{ dataType: 'enum', enums: ['CT'] },
{ dataType: 'enum', enums: ['TERRORIST'] },
{ dataType: 'enum', enums: [''] },
{ dataType: 'enum', enums: ['Spectator'] },
],
validators: {},
},
},
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
EventType: {
dataType: 'refAlias',
type: {
Expand Down Expand Up @@ -684,7 +699,7 @@ const models: TsoaRoute.Models = {
},
message: { dataType: 'string', required: true },
isTeamChat: { dataType: 'boolean', required: true },
teamString: { dataType: 'string' },
teamString: { ref: 'TTeamString' },
},
additionalProperties: false,
},
Expand Down Expand Up @@ -718,6 +733,7 @@ const models: TsoaRoute.Models = {
type: { dataType: 'enum', enums: ['ROUND_END'], required: true },
mapIndex: { dataType: 'double', required: true },
mapName: { dataType: 'string', required: true },
matchMapCount: { dataType: 'double', required: true },
winnerTeam: { ref: 'ITeam', required: true },
scoreTeamA: { dataType: 'double', required: true },
scoreTeamB: { dataType: 'double', required: true },
Expand All @@ -738,6 +754,7 @@ const models: TsoaRoute.Models = {
type: { dataType: 'enum', enums: ['MAP_END'], required: true },
mapIndex: { dataType: 'double', required: true },
mapName: { dataType: 'string', required: true },
matchMapCount: { dataType: 'double', required: true },
scoreTeamA: { dataType: 'double', required: true },
scoreTeamB: { dataType: 'double', required: true },
winnerTeam: {
Expand Down Expand Up @@ -784,6 +801,7 @@ const models: TsoaRoute.Models = {
},
required: true,
},
matchMapCount: { dataType: 'double', required: true },
},
additionalProperties: false,
},
Expand All @@ -801,6 +819,7 @@ const models: TsoaRoute.Models = {
type: { dataType: 'enum', enums: ['KNIFE_END'], required: true },
mapIndex: { dataType: 'double', required: true },
mapName: { dataType: 'string', required: true },
matchMapCount: { dataType: 'double', required: true },
winnerTeam: { ref: 'ITeam', required: true },
},
additionalProperties: false,
Expand All @@ -819,6 +838,7 @@ const models: TsoaRoute.Models = {
type: { dataType: 'enum', enums: ['MAP_START'], required: true },
mapIndex: { dataType: 'double', required: true },
mapName: { dataType: 'string', required: true },
matchMapCount: { dataType: 'double', required: true },
},
additionalProperties: false,
},
Expand Down
58 changes: 51 additions & 7 deletions backend/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,17 @@
"type": "object",
"additionalProperties": false
},
"TTeamString": {
"type": "string",
"enum": [
"Unassigned",
"CT",
"TERRORIST",
"",
"Spectator"
],
"description": "Possible ingame sides of a player."
},
"EventType": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -1204,15 +1215,17 @@
"$ref": "#/components/schemas/IPlayer"
}
],
"nullable": true
"nullable": true,
"description": "`null` when not a player (e.g. CONSOLE via rcon)"
},
"playerTeam": {
"allOf": [
{
"$ref": "#/components/schemas/ITeam"
}
],
"nullable": true
"nullable": true,
"description": "`null` when not a player (e.g. CONSOLE via rcon)"
},
"message": {
"type": "string"
Expand All @@ -1221,7 +1234,7 @@
"type": "boolean"
},
"teamString": {
"type": "string"
"$ref": "#/components/schemas/TTeamString"
}
},
"required": [
Expand Down Expand Up @@ -1301,6 +1314,11 @@
"mapName": {
"type": "string"
},
"matchMapCount": {
"type": "number",
"format": "double",
"description": "number of maps that could be played"
},
"winnerTeam": {
"$ref": "#/components/schemas/ITeam"
},
Expand All @@ -1320,6 +1338,7 @@
"type",
"mapIndex",
"mapName",
"matchMapCount",
"winnerTeam",
"scoreTeamA",
"scoreTeamB"
Expand Down Expand Up @@ -1354,6 +1373,11 @@
"mapName": {
"type": "string"
},
"matchMapCount": {
"type": "number",
"format": "double",
"description": "number of maps that could be played"
},
"scoreTeamA": {
"type": "number",
"format": "double"
Expand All @@ -1369,7 +1393,7 @@
}
],
"nullable": true,
"description": "winner of the match or null if it's a draw"
"description": "winner of the map or null if it's a draw"
}
},
"required": [
Expand All @@ -1379,6 +1403,7 @@
"type",
"mapIndex",
"mapName",
"matchMapCount",
"scoreTeamA",
"scoreTeamB",
"winnerTeam"
Expand Down Expand Up @@ -1457,7 +1482,13 @@
],
"type": "object"
},
"type": "array"
"type": "array",
"description": "all map results (but only for finished maps)"
},
"matchMapCount": {
"type": "number",
"format": "double",
"description": "number of maps that could have been played"
}
},
"required": [
Expand All @@ -1468,7 +1499,8 @@
"wonMapsTeamA",
"wonMapsTeamB",
"winnerTeam",
"mapResults"
"mapResults",
"matchMapCount"
],
"type": "object",
"additionalProperties": false
Expand Down Expand Up @@ -1500,6 +1532,11 @@
"mapName": {
"type": "string"
},
"matchMapCount": {
"type": "number",
"format": "double",
"description": "number of maps that could be played"
},
"winnerTeam": {
"$ref": "#/components/schemas/ITeam"
}
Expand All @@ -1511,6 +1548,7 @@
"type",
"mapIndex",
"mapName",
"matchMapCount",
"winnerTeam"
],
"type": "object",
Expand Down Expand Up @@ -1542,6 +1580,11 @@
},
"mapName": {
"type": "string"
},
"matchMapCount": {
"type": "number",
"format": "double",
"description": "number of maps that could be played"
}
},
"required": [
Expand All @@ -1550,7 +1593,8 @@
"matchPassthrough",
"type",
"mapIndex",
"mapName"
"mapName",
"matchMapCount"
],
"type": "object",
"additionalProperties": false
Expand Down
19 changes: 16 additions & 3 deletions common/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TMapMode, TSideMode } from './electionStep';
import { IMatchResponse } from './match';
import { IPlayer } from './player';
import { TTeamSides } from './stuff';
import { ITeam } from './team';
import { ITeam, TTeamString } from './team';

export type EventType =
| 'CHAT'
Expand Down Expand Up @@ -30,11 +30,13 @@ export interface BaseEvent {

export interface ChatEvent extends BaseEvent {
type: 'CHAT';
/** `null` when not a player (e.g. CONSOLE via rcon) */
player: IPlayer | null;
/** `null` when not a player (e.g. CONSOLE via rcon) */
playerTeam: ITeam | null;
message: string;
isTeamChat: boolean;
teamString?: string;
teamString?: TTeamString;
}

export interface ElectionEndEvent extends BaseEvent {
Expand All @@ -46,6 +48,8 @@ export interface RoundEndEvent extends BaseEvent {
type: 'ROUND_END';
mapIndex: number;
mapName: string;
/** number of maps that could be played */
matchMapCount: number;
winnerTeam: ITeam;
scoreTeamA: number;
scoreTeamB: number;
Expand All @@ -55,9 +59,11 @@ export interface MapEndEvent extends BaseEvent {
type: 'MAP_END';
mapIndex: number;
mapName: string;
/** number of maps that could be played */
matchMapCount: number;
scoreTeamA: number;
scoreTeamB: number;
/** winner of the match or null if it's a draw */
/** winner of the map or null if it's a draw */
winnerTeam: ITeam | null;
}

Expand All @@ -69,26 +75,33 @@ export interface MatchEndEvent extends BaseEvent {
wonMapsTeamB: number;
/** winner of the match or null if it's a draw */
winnerTeam: ITeam | null;
/** all map results (but only for finished maps) */
mapResults: {
mapName: string;
scoreTeamA: number;
scoreTeamB: number;
/** winner of the match or null if it's a draw */
winnerTeam: ITeam | null;
}[];
/** number of maps that could have been played */
matchMapCount: number;
}

export interface KnifeRoundEndEvent extends BaseEvent {
type: 'KNIFE_END';
mapIndex: number;
mapName: string;
/** number of maps that could be played */
matchMapCount: number;
winnerTeam: ITeam;
}

export interface MapStartEvent extends BaseEvent {
type: 'MAP_START';
mapIndex: number;
mapName: string;
/** number of maps that could be played */
matchMapCount: number;
}

export interface LogEvent extends BaseEvent {
Expand Down

0 comments on commit 740acdd

Please sign in to comment.