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

dev.robocode.tankroyale.botapi.mapper.BulletStateMapper Maven / Gradle / Ivy

The newest version!
package dev.robocode.tankroyale.botapi.mapper;

import dev.robocode.tankroyale.botapi.BulletState;
import dev.robocode.tankroyale.botapi.Color;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

/**
 * Utility class for mapping a bot state.
 */
public final class BulletStateMapper {

    // Hide constructor to prevent instantiation
    private BulletStateMapper() {
    }

    public static BulletState map(final dev.robocode.tankroyale.schema.game.BulletState source) {
        return new BulletState(
                source.getBulletId(),
                source.getOwnerId(),
                source.getPower(),
                source.getX(),
                source.getY(),
                source.getDirection(),
                Color.fromString(source.getColor()));
    }

    public static Set map(final Collection source) {
        Set bulletStates = new HashSet<>();
        source.forEach(bulletState -> bulletStates.add(map(bulletState)));
        return bulletStates;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy