Skip to content
stanislawbartkowski edited this page May 28, 2020 · 28 revisions

Welcome to the CivilizationEngine wiki! This wiki describes different formats to executeCommand.

executeCommand(token,actionname,row,col,jsparam)

  • Parameters
    • token : Returned by REGISTERGAME
    • action : Command to execute: SETCAPITAL, SETSITY, SPENDPRODUCTION
    • row,col : Square position identifying the object. Depends on the action. For instance: SETCITY - the square where the city is supposed to be built
    • jsparam : Additional parameter in JSON format. Depends on the action.
      For instance: STARTMODE - figures or armies to move.
      Null if parameter is not required.
  • Result: if null then command executed successfully. If not null, the command failed and the result contains failure description
  • Usage example: executeCommand("secret token","SETCITY",2,2,null)
  • Description: Executes command and moves the game from one state to another. After success call getData(GETBOARDGAME) to receive current game state.

itemizeCommand(token,command)

  • Parameters: token and command name
  • Returns: List of possible parameters for the command. The content depends on a particular command
  • Usage example: val l : String = itemizeCommand("secret token","SETCAPITAL")
  • Description: Returns more detailed information. For instance: if the command is SETCAPITAL the command will return a list of all points where the capital can be built. Can be used by the user interface to customize screen.

Common formats

Battle

Format

{
'endofbattle' : boolean,
'attackerwinner, : boolean,
'bothsides' : boolean
'attacker' : <army>
'defender' : <army>
'winnerloot': <loot>
}
  • endofbattle
    • 'true' - the battled is completed and the game is waiting for ENDOFBATTLE command.
    • 'false' - the battle is going on
  • attackerwinner : has meaning only if 'endofbattle' is true. The battle result. If false the defender won
  • bothsides : is true only if training game and village is attacked. The player should play both sides during the battle.
  • attacker': the attacker army
  • defender: the defender army
  • winnerloot: set if "endofbattle". List of possible loots the winner is authorized to steal.

```

Army description, attacker and defender

{
  'combatbonus' : int,
  'front': list of units fighting
  'waiting': list of standing unit ready to be engaged
  'killedunits': list of killed units
  'canuseiron' : boolean
  'you' : boolean
  'turn' : boolean
  'points' : int
  'saveunit' : boolean
  'civ' : text
}
  • combatbonus: starting combat bonus
  • front: list of units fighting now, standing in the front row
  • waiting: list of standing units waiting for their turn
  • killedunits: list of killed units
  • canuseiron: if true then PLAYUNITIRON is possible
  • you: the player is attacker or defender. If 'bothsides', 'you' is true for 'attacker' and 'defender'
  • turn: if true then the player, attacker or defender is expected to play the unit
  • points: winning points at this moment of the battle
  • saveunit: if the player can resurrect one killed unit after the battle, Spain civilization
  • civ: attacker or defender civilization. If the village is defending, the attacker civilization

Winner loot

{
 'loot' : int
 list : list of loots
}
  • loot : integer, number of loots the winner can take
  • list : list of possible loots

Example:

{ 
  'loot': 1, 
  'list': 
  [
    {'name': 'trade', 'loot': 1, 'tech': None, 'resource': None, 'level': None, 'coinsheet': None}, 
    {'name': 'hut', 'loot': 1, 'tech': None, 'resource': None, 'level': None, 'coinsheet': None}
  ]
}

Loot

{
  'name' : name of the loot
  'loot' : cost of this loot, 1 or 2
  'tech' : if not None then the tech name to steal
  'resource' : if not None then the resource name to steal
  'level' : int
  'coinsheet' : int
}

Example:

{'name': 'trade', 'loot': 1, 'tech': None, 'resource': None, 'level': None, 'coinsheet': None}

SUSPEND

"Suspend" attribute allows annulling opponent action if the player has resources and technology at hand. For instance: "Writing" technology and "Spy" token.
If annulling is possible then "suspend" attribute is None and the player has the option: "Do nothing" or cancel the opponent action. Format

{
"command": the opponent command exposed for annulling.
"list": list of player action to use to cancel.
}

"Command" format

{
 "command" : the opponent command name
 "civ" : the opponent civilization name
 "p" : the point here opponent city action is supposed to be conducted
 "param" : addtional parameter for command
}

"List" format

[ {
 "command" : the player command to cancel
 "civ" : the player civilization
 "param" : additional parameter, for instance: the resource token
}]

Example:

{
"suspend" :
   "command" :
     { 'command': 'BUYMOUNTED', 'civ': 'China', 'p': {'row': 2, 'col': 2}, 'param': None }
   "list" : [
     {'civ': 'Rome', 'command': 'WRITINGACTION', 'param': 'Spy'} 
   ]
} 

The opponent civilization "China" is going to play city action BUYMOUNTED, the action is suspended and waiting for the player decision. The player can use technology "Writing" and spend "Spy" resource to cancel the action. If the player decides to do nothing, should issue LETSUSPENDGO command and the opponent action is implemented as if nothing has happened.

Main Board

  • map current board *matrix : array[array[8 * squares]]
  • game
    • current state of the game
  • units
    • list of units to buy
  • killedunis
    • list of units already killed
  • resource
    • list of resources on the market
  • hutvillagesused
    • list of hut/villages spent already
  • you
    • your deck
  • others
    • list of decks of other players
  • wonders
    • list of currently available wonders
  • battle BATTLE
    • if not null, the battle is currently on the way
  • buildings
    • list of buildings on the market
  • cultureused
    • list of culture cards already spent
  • endofgame
    • if not null, game is completed already

Game

game current state of game

  • active: String
    • Active civilization
  • phase : String
    • Game phase
  • roundno : number
    • Game round number starting from 0
{
  game: {
    active: "China",
    phase: "StartOfTurn",
    roundno: 0,
  }
}

Square

  • revealed : true/false
    • The square is already revealed or still hidden
  • terrain: "Mountain|Grassland|Forest|Desert|Water "
    • Terrain
  • trade: /number/
    • Current trade from this square
  • production: /number/
    • Current production from the square
  • resource: |Culture|Wheat|Coin|Silk|Incense|Iron|null
    • Square resource
  • capciv: /civname/|null
    • if not null starting tile of the civilization
  • civ: /civname/|null
    • if not null, civilization is possessing this square
  • city: /city type|null
    • if nut null, city built here
  • defence: /number/
    • defence factor of the city
  • numberofArmies: /number/
    • number of armies here
  • numberofScouts: /number/
    • number of scouts here
  • tile: /name/
    • tile id
  • hv: |hut|village|null
    • if not null, hut or village here
  • building: |building name|null
    • if not null, the building is bought here
  • wonder: |wonder name|null
    • if not null, wonder is bought here
  • culture: number
    • number of culture here
  • greatperson: /great person name/|null
    • if not null, great person is here
  • greatpersontype: /great person type/|null
    • great person type here
{
      "revealed" : true,
      "terrain" : "Grassland",
      "trade" : 0,
      "production" : 0,
      "resource" : "Wheat",
      "capciv" : "China",
      "civ" : null,
      "city" : null,
      "defence" : 0,
      "numberofArmies" : -1,
      "numberofScouts" : -1,
      "tile" : "RTILECHINA.json",
      "hv" : null,
      "building" : null,
      "wonder" : null,
      "culture" : 0,
      "greatperson" : null,
      "greatpersontype" : null
    }

Player view (you)

  • tech /list/
    • list of acquired technologies
  • gover /string/
    • current government
  • civ /string/
    • player civilization
  • trade /number/
    • current trade
  • commands /list/
    • list of currently available commands
  • citylimit /number/
    • maximum number of cities to build
  • armieslimit /number/
    • maximum number of armiers allowed
  • scoutslimit /number/
    • maximum number of scouts allowed
  • tradeforprod /number/
    • multiplier while selling trade for production
  • units /list/
    • units /list/
      • number of unit in army branch and military strength level
    • list /list/
      • list of units and
  • resources /list/
    • list of resources taken
  • hutvillages /list/
    • list of taken hut and villages
  • coins /number/
    • number of coins
  • combatbonus /number/
    • current combat bonus
  • cultureprogress /number/
    • place on the culture progress ladder
  • handsize /number/
    • size of combat hand
  • travelspeed /number/
    • armies or scouts travel speed
  • stacklimit /number/
    • maximum number of armies and scouts on the square
  • cultureresource /map/
  • suspended

Military strength

"units": [
        {
          "name": "Artillery",
          "num": 1,
          "militarystrength": 0
        },
        {
          "name": "Infantry",
          "num": 1,
          "militarystrength": 0
        },
 
       {
          "name": "Mounted",
          "num": 1,
          "militarystrength": 0
        },
        {
          "name": "Aircraft",
          "num": 0,
          "militarystrength": 0
        }

Unit description

  • name : string
    • Infantry,Mounted,Artillery,Aircraft
  • strength : array
    • Four elements array of number, strength of the unit at the appropriate level
{
  "name": "Artillery",
  "strength": [2,3, 4, 5]
}

List of resource

List of resources

  • resource : resource name
  • num : number of resources
  "resources": [
      {
        "resource": "Incense",
        "num": 0
      },
      {
        "resource": "Spy",
        "num": 0
      },
      {
        "resource": "Coin",
        "num": 0
      },
      {
        "resource": "Culture",
        "num": 0
      },
      {
        "resource": "Silk",
        "num": 0
      },
      {
        "resource": "Iron",
        "num": 0
      },
      {
        "resource": "Uranium",
        "num": 0
      },
      {
        "resource": "Wheat",
        "num": 0
      }
    ],