Skip to content

Commit

Permalink
WIP: support for MissionSiteExpiredEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
Konrad Jamrozik committed Jun 10, 2024
1 parent 7e2cf1d commit ee448a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions web/src/lib/codesync/GameSessionTurn.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
// codesync: UfoGameLib.State.GameSessionTurn
import _ from 'lodash'
import type { GameEventBase } from './GameEvent'
import type { GameEvent } from './GameEvent'
import type { GameState } from './GameState'
import type { PlayerActionEvent } from './PlayerActionEvent'
import type { WorldEvent } from './WorldEvent'

export type GameSessionTurn = {
readonly EventsUntilStartState: GameEventBase[]
readonly EventsUntilStartState: WorldEvent[]
readonly StartState: GameState
readonly EventsInTurn: GameEventBase[]
readonly EventsInTurn: PlayerActionEvent[]
readonly EndState: GameState
readonly AdvanceTimeEvent?: GameEventBase | undefined
readonly AdvanceTimeEvent?: PlayerActionEvent | undefined
readonly NextEventId?: number | undefined
}

export function getEvents(turn: GameSessionTurn): GameEventBase[] {
export function getEvents(turn: GameSessionTurn): GameEvent[] {
return [
...turn.EventsUntilStartState,
...turn.EventsInTurn,
Expand All @@ -22,7 +24,7 @@ export function getEvents(turn: GameSessionTurn): GameEventBase[] {

export function getGameEvents(
turns: readonly GameSessionTurn[],
): readonly GameEventBase[] {
): readonly GameEvent[] {
return _.flatMap(turns, (turn) => getEvents(turn))
}

Expand Down
4 changes: 2 additions & 2 deletions web/src/lib/gameSession/GameSessionData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import _ from 'lodash'
import {
addTurnToGameEvent,
type GameEventBase,
type GameEvent,
type GameEventWithTurn,
} from '../codesync/GameEvent'
import {
Expand Down Expand Up @@ -99,7 +99,7 @@ export class GameSessionData {
turns.at(0)!,
)

const gameEvents: readonly GameEventBase[] = getGameEvents(turns)
const gameEvents: readonly GameEvent[] = getGameEvents(turns)
if (!_.isEmpty(gameEvents)) {
const firstEventId = gameEvents.at(0)!.Id
for (const eventIndex of _.range(1, gameEvents.length)) {
Expand Down

0 comments on commit ee448a5

Please sign in to comment.