Code.RTS() API Reference

Code.RTS() is a video game that uses a Python API that players must use to play the game.
Visit www.code-rts.com for news, manual, and download.

Buildings

buildCamp(position)

Builds a Camp at specified position. Camps generate population and provide additional population capacity.

Parameters:

position (int) – A value between 1 and 9 that specifies the position to build the building.

Returns:

True on success, False on failure.

Return type:

bool

Population:

-5

Population Production:

1

Population Capacity:

5

Health:

10000

buildLumberCamp(position)

Builds a Lumber Camp at specified position. Lumber Camps generate wood and provide additional wood capacity.

Parameters:

position (int) – A value between 1 and 9 that specifies the position to build the building.

Returns:

True on success, False on failure.

Return type:

bool

Population:

-5

Wood Production:

10

Wood Capacity:

500

Health:

10000

buildMarket(position)

Builds a Market at specified position. Markets enable trading (buyPopulation, sellPopulation, buyWood, sellWood).

Parameters:

position (int) – A value between 1 and 9 that specifies the position to build the building.

Returns:

True on success, False on failure.

Return type:

bool

Population:

-5

Wood:

-400

Health:

10000

Enables:

buyPopulation, sellPopulation, buyWood, sellWood

buildTower(position)

Builds a Tower at specified position. Towers are defensive buildings that will attack enemies.

Parameters:

position (int) – A value between 1 and 9 that specifies the position to build the building.

Returns:

True on success, False on failure.

Return type:

bool

Population:

-5

Wood:

-400

Health:

10000

Damage:

10

Range:

20

Attack Speed:

1

repairBuilding(position, amount)

Repairs building at specified position. Costs 1 wood per HP.

Parameters:
  • position (int) – A value between 1 and 9 that specifies the position of the building to repair.

  • amount (int) – A integer value for how much HP to repair.

Returns:

True on success, False on failure.

Return type:

bool

Wood:

-amount

Health:

+amount

destroyBuilding(position)

Destroys building at specified position.

Parameters:

position (int) – A value between 1 and 9 that specifies the position of the building to destroy.

Returns:

True on success, False on failure.

Return type:

bool

Units

createArcher()

Creates an Archer. Archers are ranged units that will attack your enemies.

Returns:

True on success, False on failure.

Return type:

bool

Population:

-1

Wood:

-2

Health:

100

Damage:

10

Range:

10

Attack Speed:

1

Movement Speed:

5

createSpearman()

Creates a Spearman. Spearmen are melee units that will attack your enemies.

Returns:

True on success, False on failure.

Return type:

bool

Population:

-1

Wood:

-2

Health:

100

Damage:

10

Range:

1

Attack Speed:

2

Movement Speed:

10

Intel

getCurrentPopulation()

Gets your current Population value.

Returns:

How much Population you currently have.

Return type:

int

getMaxPopulation()

Gets your Maximum Population capacity value.

Returns:

How much Maximum Population capacity you currently have.

Return type:

int

getCurrentWood()

Gets your current Population value.

Returns:

How much Population you currently have.

Return type:

int

getMaxWood()

Gets your Maximum Wood capacity value.

Returns:

How much Maximum Wood capacity you currently have.

Return type:

int

getCurrentGold()

Gets your current Gold value.

Returns:

How much Gold you currently have.

Return type:

int

getBuildingCurrentHealth(position)

Gets the Health of the Building at the specified position.

Parameters:

position (int) – A value between 1 and 9 that specifies the position of the building to get current health of.

Returns:

How much health the building currently has.

Return type:

int

getBuildingMaxtHealth(position)

Gets the Maximum Health of the Building at the specified position.

Parameters:

position (int) – A value between 1 and 9 that specifies the position of the building to get maximum health of.

Returns:

How much maximum health the building has.

Return type:

int

Trading

buyPopulation(amount)

Buy Population for Gold.

Parameters:

amount (int) – How much Population you want to buy.

Returns:

True if the trade succeeded, False otherwise.

Return type:

bool

Requirement:

Market

Population:

1 * amount

Gold:

-11 * amount

sellPopulation(amount)

Sell Population for Gold.

Parameters:

amount (int) – How much Population you want to sell.

Returns:

True if the trade succeeded, False otherwise.

Return type:

bool

Requirement:

Market

Population:

-1 * amount

Gold:

9 * amount

buyWood(amount)

Buy Wood for Gold.

Parameters:

amount (int) – How much Wood you want to buy. Must be a multiple of 10. 10 Wood costs 11 Gold.

Returns:

True if the trade succeeded, False otherwise.

Return type:

bool

Requirement:

Market

Wood:

10 * amount

Gold:

-11 * amount

sellWood(amount)

Sell Wood for Gold.

Parameters:

amount (int) – How much Wood you want to sell. Must be a multiple of 10.

Returns:

True if the trade succeeded, False otherwise.

Return type:

bool

Requirement:

Market

Wood:

-10 * amount

Gold:

9 * amount