Package dev.robocode.tankroyale.botapi
Class BotInfo
java.lang.Object
dev.robocode.tankroyale.botapi.BotInfo
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Builder interface for providing a builder for buildingBotInfo
objects, and which supports method chaining. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Maximum number of characters accepted for an author name.static final int
Maximum number of characters accepted for the description.static final int
Maximum number of characters accepted for a game type.static final int
Maximum number of characters accepted for the link to the homepage.static final int
Maximum number of characters accepted for the name.static final int
Maximum number of authors accepted.static final int
Maximum number of country codes accepted.static final int
Maximum number of game types accepted.static final int
Maximum number of characters accepted for the platform name.static final int
Maximum number of characters accepted for the programming language name.static final int
Maximum number of characters accepted for the version. -
Constructor Summary
ConstructorDescriptionBotInfo
(String name, String version, List<String> authors, String description, String homepage, List<String> countryCodes, Collection<String> gameTypes, String platform, String programmingLang, InitialPosition initialPosition) Initializes a new instance of the BotInfo class.
Note that the recommended method for creating a BotInfo class is to use theBotInfo.IBuilder
interface provided with the staticbuilder()
method. -
Method Summary
Modifier and TypeMethodDescriptionstatic BotInfo.IBuilder
builder()
Returns a builder for a convenient way of building aBotInfo
object using the builder pattern.
Example of use:static BotInfo
Reads the bot info from a local file on a file system.
The file is assumed to be in JSON format.
See thefromInputStream(java.io.InputStream)
to see the required JSON format for the file.static BotInfo
fromInputStream
(InputStream inputStream) Reads the bot info from an input stream.
The file is assumed to be in JSON format.
Example file in JSON format:static BotInfo
fromResourceFile
(String filename) Reads the bot info from a resource file, e.g.Returns the list of authors of the bot, e.g., "John Doe (johndoe@somewhere.io)".Returns a list of country code(s) defined by ISO 3166-1 alpha-2, e.g.Returns a short description of the bot, preferably a one-liner.
This field is optional.Returns the game type(s) accepted by the bot, e.g., "classic", "melee", "1v1".Returns the URL of a web page for the bot.
This field is optional.Returns the initial starting position used for debugging only, which must be enabled at the server.
This field is optional.getName()
Returns the name, e.g., "MyBot".Returns the platform used for running the bot, e.g., "Java Runtime Environment (JRE) 11".
This field is optional.Returns the programming language used for developing the bot, e.g., "Java 11" or "Kotlin 1.7.20".
This field is optional.Returns the version, e.g., "1.0".
-
Field Details
-
MAX_NAME_LENGTH
public static final int MAX_NAME_LENGTHMaximum number of characters accepted for the name.- See Also:
-
MAX_VERSION_LENGTH
public static final int MAX_VERSION_LENGTHMaximum number of characters accepted for the version.- See Also:
-
MAX_AUTHOR_LENGTH
public static final int MAX_AUTHOR_LENGTHMaximum number of characters accepted for an author name.- See Also:
-
MAX_DESCRIPTION_LENGTH
public static final int MAX_DESCRIPTION_LENGTHMaximum number of characters accepted for the description.- See Also:
-
MAX_HOMEPAGE_LENGTH
public static final int MAX_HOMEPAGE_LENGTHMaximum number of characters accepted for the link to the homepage.- See Also:
-
MAX_GAME_TYPE_LENGTH
public static final int MAX_GAME_TYPE_LENGTHMaximum number of characters accepted for a game type.- See Also:
-
MAX_PLATFORM_LENGTH
public static final int MAX_PLATFORM_LENGTHMaximum number of characters accepted for the platform name.- See Also:
-
MAX_PROGRAMMING_LANG_LENGTH
public static final int MAX_PROGRAMMING_LANG_LENGTHMaximum number of characters accepted for the programming language name.- See Also:
-
MAX_NUMBER_OF_AUTHORS
public static final int MAX_NUMBER_OF_AUTHORSMaximum number of authors accepted.- See Also:
-
MAX_NUMBER_OF_COUNTRY_CODES
public static final int MAX_NUMBER_OF_COUNTRY_CODESMaximum number of country codes accepted.- See Also:
-
MAX_NUMBER_OF_GAME_TYPES
public static final int MAX_NUMBER_OF_GAME_TYPESMaximum number of game types accepted.- See Also:
-
-
Constructor Details
-
BotInfo
public BotInfo(String name, String version, List<String> authors, String description, String homepage, List<String> countryCodes, Collection<String> gameTypes, String platform, String programmingLang, InitialPosition initialPosition) Initializes a new instance of the BotInfo class.
Note that the recommended method for creating a BotInfo class is to use theBotInfo.IBuilder
interface provided with the staticbuilder()
method.- Parameters:
name
- is the name of the bot (required).version
- is the version of the bot (required).authors
- is the author(s) of the bot (required).description
- is a short description of the bot (optional).homepage
- is the link to a homepage for the bot (optional).countryCodes
- is the country code(s) for the bot (optional).gameTypes
- is the game types that this bot can handle (optional).platform
- is the platform used for running the bot (optional).programmingLang
- is the programming language used for developing the bot (optional).initialPosition
- is the initial position with starting coordinate and angle (optional).
-
-
Method Details
-
builder
Returns a builder for a convenient way of building aBotInfo
object using the builder pattern.
Example of use:BotInfo botInfo = BotInfo.builder() .setName("Rampage") .setVersion("1.0") .addAuthor("John Doh") .setGameTypes(List.of(GameType.CLASSIC, GameType.MELEE)) .build();
- Returns:
- a builder for building a
BotInfo
object.
-
getName
Returns the name, e.g., "MyBot". This field must always be provided with the bot info.- Returns:
- The name of the bot.
-
getVersion
Returns the version, e.g., "1.0". This field must always be provided with the bot info.- Returns:
- The version of the bot.
-
getAuthors
-
getDescription
Returns a short description of the bot, preferably a one-liner.
This field is optional.- Returns:
- a short description of the bot.
-
getHomepage
Returns the URL of a web page for the bot.
This field is optional.- Returns:
- The URL of a web page for the bot.
-
getCountryCodes
Returns a list of country code(s) defined by ISO 3166-1 alpha-2, e.g. { "us" } This field is optional. If no country codes are provided, the locale of the system is being used instead.- Returns:
- The country code(s) for the bot.
-
getGameTypes
Returns the game type(s) accepted by the bot, e.g., "classic", "melee", "1v1". At least one game type must be provided to indicate the type(s) of games that this bot can participate in. The game types define which game types the bot can participate in. SeeGameType
for using predefined game type.- Returns:
- The game type(s) that this bot can handle.
-
getPlatform
Returns the platform used for running the bot, e.g., "Java Runtime Environment (JRE) 11".
This field is optional.- Returns:
- The platform used for running the bot.
-
getProgrammingLang
Returns the programming language used for developing the bot, e.g., "Java 11" or "Kotlin 1.7.20".
This field is optional.- Returns:
- The programming language used for developing the bot.
-
getInitialPosition
Returns the initial starting position used for debugging only, which must be enabled at the server.
This field is optional.- Returns:
- The initial starting position used for debugging only.
-
fromResourceFile
Reads the bot info from a resource file, e.g. when the file is located in a jar file or resource path in IDE.
The file is assumed to be in JSON format.
See thefromInputStream(java.io.InputStream)
to see the required JSON format for the file.- Parameters:
filename
- is the filename of the file containing bot properties.- Returns:
- A BotInfo instance containing the bot properties read from the file.
- Throws:
BotException
- if the resource file could not be read, or if some field read from the file is invalid.- See Also:
-
fromFile
Reads the bot info from a local file on a file system.
The file is assumed to be in JSON format.
See thefromInputStream(java.io.InputStream)
to see the required JSON format for the file.- Parameters:
filename
- is the filename of the file containing bot properties.- Returns:
- A BotInfo instance containing the bot properties read from the file.
- Throws:
BotException
- if the file could not be read, or if some field read from the file is invalid.- See Also:
-
fromInputStream
Reads the bot info from an input stream.
The file is assumed to be in JSON format.
Example file in JSON format:
Note that these fields are required as these are used to identify the bot:{ "name": "MyBot", "version": "1.0", "authors": "John Doe", "description": "Short description", "homepage": "https://somewhere.net/MyBot", "countryCodes": "us", "gameTypes": "classic, melee, 1v1", "platform": "JVM", "programmingLang": "Java 11", "initialPosition": "50,50, 90" }
- name
- version
- authors
- authors, e.g. "John Doe, Jane Doe"
- countryCodes, e.g. "se, no, dk"
- gameTypes, e.g. "classic, melee, 1v1"
initialPosition
variable is optional and should only be used for debugging.
ThegameTypes
is optional, but can be used to limit which game types the bot is capable of participating in.- Parameters:
inputStream
- is the input stream providing the bot properties.- Returns:
- A BotInfo instance containing the bot properties read from the stream.
- Throws:
BotException
- if some fields read from the stream is invalid.- See Also:
-