Structure de données jeu client

This commit is contained in:
2024-12-11 17:26:36 +01:00
parent d1adba04da
commit 7aa9dde5a9
14 changed files with 238 additions and 28 deletions

View File

@ -0,0 +1,33 @@
import { createSlice } from '@reduxjs/toolkit'
export interface ChallengeAction {
id: number
challengeId: number
title: string,
description: string,
reward: number,
success: boolean,
start: Date,
end: Date | null,
penaltyStart: Date | null,
penaltyEnd: Date | null,
}
export interface ActionsState {
challengeActions: ChallengeAction[]
}
const initialState: ActionsState = {
challengeActions: []
}
export const challengeActionsSlice = createSlice({
name: 'challengeActions',
initialState: initialState,
reducers: {
},
})
export const { } = challengeActionsSlice.actions
export default challengeActionsSlice.reducer

View File

@ -0,0 +1,27 @@
import { createSlice } from '@reduxjs/toolkit'
export interface Challenge {
id: number
title: string,
description: string,
reward: number,
}
export interface ChallengesState {
challenges: Challenge[]
}
const initialState: ChallengesState = {
challenges: []
}
export const challengesSlice = createSlice({
name: 'challenges',
initialState: initialState,
reducers: {
},
})
export const { } = challengesSlice.actions
export default challengesSlice.reducer

View File

@ -0,0 +1,38 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
export interface GameState {
playerId: number | null
gameStarted: boolean
money: number
currentRunner: boolean
chaseFreeTime: Date | null
penaltyStart: Date | null
penaltyEnd: Date | null
}
const initialState: GameState = {
playerId: null,
gameStarted: false,
money: 0,
currentRunner: false,
chaseFreeTime: null,
penaltyStart: null,
penaltyEnd: null,
}
export const gameSlice = createSlice({
name: 'game',
initialState: initialState,
reducers: {
setPlayerId: (state, action: PayloadAction<number>) => {
state.playerId = action.payload
},
updateMoney: (state, action: PayloadAction<number>) => {
state.money = action.payload
},
},
})
export const { setPlayerId, updateMoney } = gameSlice.actions
export default gameSlice.reducer

View File

@ -0,0 +1,107 @@
import { createSlice } from '@reduxjs/toolkit'
export interface InterrailLeg {
infoJson?: string
info?: InterrailLegInfo
sortOrder: number
}
export interface InterrailTravel {
date: string
infoJson?: string
info?: InterrailTravelInfo
from: string
to: string
type: number
legs: InterrailLeg[]
}
export interface InterrailJourneyData {
travels: InterrailTravel[]
}
export interface InterrailJourney {
data: InterrailJourneyData
}
export interface InterrailTime {
hours: number
minutes: number
offset: number
}
export interface InterrailDate {
day: number
month: number
year: number
}
export interface InterrailTravelInfo {
arrivalTime: InterrailTime
date: InterrailDate
departureTime: InterrailTime
haconVersion: number
dataSource: number
}
export interface InterrailStopExtraInfo {
departureTime: InterrailTime
index: number
}
export interface InterrailStopCoordinates {
latitude: number
longitude: number
}
export interface InterrailStopStation {
coordinates: InterrailStopCoordinates
country: string
name: string
stationId: number
}
export interface InterrailLegInfo {
attributeCodes: string[]
attributes: object
duration: InterrailTime
directionStation: string
endTime: InterrailTime
isSeparateTicket: boolean
operationDays: string
operator: object
dataSource: number
startTime: InterrailTime
stopExtraInfo: InterrailStopExtraInfo[]
trainName: string
trainStopStations: InterrailStopStation[]
trainType: number
}
export interface TrainTrip {
id: string
distance: number,
from: string,
to: string,
departureTime: Date,
arrivalTime: Date,
}
export interface TrainsState {
trains: TrainTrip[]
}
const initialState: TrainsState = {
trains: []
}
export const trainSlice = createSlice({
name: 'train',
initialState: initialState,
reducers: {
},
})
export const { } = trainSlice.actions
export default trainSlice.reducer