All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.robocode.tankroyale.server.mapper.TurnToTickEventForObserverMapper.kt Maven / Gradle / Ivy

package dev.robocode.tankroyale.server.mapper

import dev.robocode.tankroyale.schema.game.Message
import dev.robocode.tankroyale.schema.game.Participant
import dev.robocode.tankroyale.schema.game.TickEventForObserver
import dev.robocode.tankroyale.server.mapper.BotsToBotsWithIdMapper.map
import dev.robocode.tankroyale.server.mapper.BulletsToBulletStatesMapper.map
import dev.robocode.tankroyale.server.model.BotId
import dev.robocode.tankroyale.server.model.ITurn
import java.util.Collections.unmodifiableList

object TurnToTickEventForObserverMapper {
    fun map(roundNumber: Int, turn: ITurn, participantsMap: Map): TickEventForObserver {
        val tick = TickEventForObserver()
        tick.apply {
            type = Message.Type.TICK_EVENT_FOR_OBSERVER
            this.roundNumber = roundNumber
            turnNumber = turn.turnNumber
            botStates = unmodifiableList(map(turn.bots, participantsMap))
            bulletStates = unmodifiableList(map(turn.bullets))
            events = unmodifiableList(EventsMapper.map(turn.observerEvents))
        }
        return tick
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy