Skip to content
This repository has been archived by the owner on Nov 11, 2021. It is now read-only.

Commit

Permalink
Added game mode tag to stats tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasK33 committed Jan 28, 2021
1 parent e127da8 commit 7677e5a
Show file tree
Hide file tree
Showing 9 changed files with 7,715 additions and 929 deletions.
2 changes: 1 addition & 1 deletion services/fsm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion services/fsm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fsm",
"version": "1.9.0",
"version": "1.10.0",
"description": "Finite State Machine",
"author": {
"name": "Thomas Kosiewski"
Expand Down
11 changes: 10 additions & 1 deletion services/fsm/src/processors/stateChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
PublicPlayerState,
} from "@shared/definitions/gsiTypes";
import { EventService } from "@shared/services/eventService";
import { MatchState } from "@shared/state";
import { FortifyGameMode, MatchState } from "@shared/state";
import { Logger } from "@shared/logger";
import {
AllianceStatsEvent,
Expand Down Expand Up @@ -32,6 +32,7 @@ export interface StateSourceData {
*/
fightOutcome: number;
averageMMR?: number;
gameMode?: FortifyGameMode;
}

@injectable()
Expand Down Expand Up @@ -65,6 +66,7 @@ export class StateChangeHandler {
publicPlayerState: next,
fightOutcome: playerFightOutcome,
averageMMR: matchState.averageMMR,
gameMode: matchState.mode,
timestamp,
};
// Track unit stats
Expand Down Expand Up @@ -103,6 +105,7 @@ export class StateChangeHandler {
publicPlayerState: { synergies, units, item_slots },
fightOutcome: wonFight,
averageMMR = 0,
gameMode,
timestamp,
}: StateSourceData): UnitStatsEvent[] {
const activeAlliances =
Expand Down Expand Up @@ -136,6 +139,8 @@ export class StateChangeHandler {
entindex,
)
.map((itemSlot) => itemSlot.item_id) ?? [],
// Game mode
gameMode,
);
event.timestamp = new Date(timestamp);

Expand All @@ -149,6 +154,7 @@ export class StateChangeHandler {
fightOutcome: wonFight,
averageMMR = 0,
timestamp,
gameMode,
}: StateSourceData): AllianceStatsEvent[] {
const activeAlliances =
synergies?.map((synergy) => synergy.keyword) ?? [];
Expand All @@ -166,6 +172,7 @@ export class StateChangeHandler {
estimatedRoundNumber,
averageMMR,
activeAlliances,
gameMode,
);
event.timestamp = new Date(timestamp);
return event;
Expand All @@ -177,6 +184,7 @@ export class StateChangeHandler {
fightOutcome: wonFight,
averageMMR = 0,
timestamp,
gameMode,
}: StateSourceData): ItemStatsEvent[] {
const activeAlliances =
synergies?.map((synergy) => synergy.keyword) ?? [];
Expand All @@ -201,6 +209,7 @@ export class StateChangeHandler {
estimatedRoundNumber,
averageMMR,
activeAlliances,
gameMode,
);
event.timestamp = new Date(timestamp);
return event;
Expand Down
Loading

0 comments on commit 7677e5a

Please sign in to comment.