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

dev.robocode.tankroyale.botapi.internal.BotHandshakeFactory Maven / Gradle / Ivy

There is a newer version: 0.26.1
Show newest version
package dev.robocode.tankroyale.botapi.internal;

import dev.robocode.tankroyale.botapi.BotInfo;
import dev.robocode.tankroyale.botapi.mapper.InitialPositionMapper;
import dev.robocode.tankroyale.schema.BotHandshake;
import dev.robocode.tankroyale.schema.Message.Type;

import java.util.ArrayList;

/**
 * Utility class used for creating bot handshakes.
 */
final class BotHandshakeFactory {

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

    static BotHandshake create(String sessionId, BotInfo botInfo, boolean isDroid, String secret) {
        BotHandshake handshake = new BotHandshake();
        handshake.setSessionId(sessionId);
        handshake.setType(Type.BOT_HANDSHAKE);
        handshake.setName(botInfo.getName());
        handshake.setVersion(botInfo.getVersion());
        handshake.setAuthors(new ArrayList<>(botInfo.getAuthors()));
        handshake.setDescription(botInfo.getDescription());
        handshake.setHomepage(botInfo.getHomepage());
        handshake.setCountryCodes(new ArrayList<>(botInfo.getCountryCodes()));
        handshake.setGameTypes(new ArrayList<>(botInfo.getGameTypes()));
        handshake.setPlatform(botInfo.getPlatform());
        handshake.setProgrammingLang(botInfo.getProgrammingLang());
        handshake.setInitialPosition(InitialPositionMapper.map(botInfo.getInitialPosition()));
        handshake.setTeamId(EnvVars.getTeamId());
        handshake.setTeamName(EnvVars.getTeamName());
        handshake.setTeamVersion(EnvVars.getTeamVersion());
        handshake.setIsDroid(isDroid);
        handshake.setSecret(secret);
        return handshake;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy