Skip to content

Connection protocol

Lordmordevil edited this page Apr 2, 2015 · 34 revisions

Login process:

  • [input] Login command
{
    "Command": "login", 
    "Username": "JohnDoe", 
    "TwitterId": "some twitter ID"
}

We have to figure out the Twitter login process. Kiril will investigate for the best way to login via Twitter's OAuth API. Until then we will just expect username in order to be able to start the connection.

  • [output] Server params command
{
  "Command": "server_params",
  "Timestamp": 1403805541437,
  "HomeSPM": 3,
  "PlanetsSPM": {
    "1": 1,
    "2": 1,
    "3": 1.2,
    "4": 1.2,
    "5": 1.2,
    "6": 1.5,
    "7": 1.5,
    "8": 1.5,
    "9": 2,
    "10": 2
  },
  "ShipsDeathModifier": 1,
  "Races": {
    "initLab": {
      "ID": 0,
      "Name": "initLab",
      "Color": {
        "R": 0.89215684,
        "G": 0.031372547,
        "B": 0.05490196
      }
    }
  }
}

This will return to the client information about the teams and how many ships will every planet produce per minute.

  • [output] If this is the first login of the user the server will request additional information.
{
    "Command": "request_setup_params",
    "Timestamp": 1394583903733
}
  • [input] Enter setup parameters
{
    "Command": "setup_parameters", 
    "Fraction": 0, 
    "SunTextureId": 0
}
  • [output] The server should return the player's position
{
    "Command": "login_success", 
    "Timestamp": 1383172903062, 
    "Username": "JohnDoe",
    "Fraction": {
        "Id":1,
        "Color":{
                        "R":218,
                        "G":75,
                        "B":15
	        },
        "Name": "Red Panda"
    }, 
    "Position":{
        "X":2631,
        "Y":1872
        },
    "HomePlanet":{
        "Name":"KVL1208",
        "Position":{
            "X":2631,
            "Y":1872
            }
        }
    }
}

or

{
    "Command": "login_fail", 
    "Username": "JohnDoe", 
    "Timestamp": 1383172903062
}
  • [input] The client should give us the information about his screen. Note: Even though we name it resolution, we mean the size of the playable canvas
{
    "Command": "scope_of_view", 
    "Position": {
        "X": 200, 
        "Y": 300
        }, 
    "Resolution": [800, 600]
}
  • [output] We give you every single thing you should write on the screen: suns, planets and active missions and what are the canvas points of the thing.
{
    "Command": "scope_of_view_result",
    "Planets": {
        "planet.80_200": {
                "Color":{
                        "R":218,
		        "G":75,
		        "B":15
	        },
	        "Texture":4,
	        "Size":2,
	        "LastShipCountUpdate":1378819273,
	        "ShipCount":17,
	        "MaxShipCount":0,
	        "Owner":"johny"
        },
        "planet.-3914_-5145": {
                "Color":{
                        "R":218,
		        "G":75,
		        "B":15
	        },
	        "Texture":2,
	        "Size":10,
	        "LastShipCountUpdate":1378819273,
	        "ShipCount":597,
	        "MaxShipCount":0,
	        "Owner":"gophie"
        },
        [..]
      "Suns": [..],
      "Missions": [..],
      "CanvasPoints":{
                 "TopLeft":{"X":-5200,"Y":5600},
                 "BottomRight":{"X":5600,"Y":-5000}
       }
    }
}

Action:

  • [input] When starting mission the client should provide:

  • Mission Type ("Attack", "Supply", "Spy")

  • Start planet key (planet.KVL3232 for example).

  • Path is a set of way-points for the mission.

  • End planet key (planet.KVL3231 for example).

  • Percentage of the ships that need to be send

{
    "Command": "start_mission",
    "Type": "Attack",
    "StartPlanets": ["planet.USE9070","planet.USE9071","planet.USE9074"],
    "Path": [{"X": -605, "Y": 136}, {"X": 102, "Y": 64}],
    "EndPlanet": "planet.USE9074",
    "Fleet": 40
}
  • [output] If the query is valid, we return the mission object
{
  "Command": "send_missions",
  "Timestamp": 1406667530272,
  "Missions": {
    "mission.1406667530269_USE9070": {
      "Color": {
        "R": 0.89215684,
        "G": 0.031372547,
        "B": 0.05490196
      },
      "Source": {
        "Name": "USE9070",
        "Owner": "Mordevil",
        "Position": {
          "X": -605,
          "Y": 136
        }
      },
      "Target": {
        "Name": "USE9074",
        "Owner": "",
        "Position": {
          "X": 937,
          "Y": -1682
        }
      },
      "Type": "Attack",
      "StartTime": 1406667530269,
      "TravelTime": 23838,
      "Player": "Mordevil",
      "ShipCount": 28661
    },
    "mission.1406667530270_USE9071": {
      "Color": {
        "R": 0.89215684,
        "G": 0.031372547,
        "B": 0.05490196
      },
      "Source": {
        "Name": "USE9071",
        "Owner": "Mordevil",
        "Position": {
          "X": 773,
          "Y": 551
        }
      },
      "Target": {
        "Name": "USE9074",
        "Owner": "",
        "Position": {
          "X": 937,
          "Y": -1682
        }
      },
      "Type": "Attack",
      "StartTime": 1406667530270,
      "TravelTime": 22390,
      "Player": "Mordevil",
      "ShipCount": 21195
    }
  },
  "FailedMissions": {
    "planet.USE9074": "The mission owner does not own the start planet."
  }
}

State changes

At some point the client will receive changes relevant to him. End of a mission if the planet's owner has changed for example

{
    "Command": "state_change",
    "Planets": {
        "planet.7434_6033": {
            "Color":{
                "R":218,
                "G":75,
                "B":15
            },
            "Texture":6,
            "Size":8,
            "LastShipCountUpdate":1378818882,
            "ShipCount":14,
            "MaxShipCount":0,
            "Owner":"gophie"
        }
    }
}

Owner change

  • [output] This message is sent to the user if he looses a planet.
{
  "Command": "owner_change",
  "Timestamp": 1398374487884,
  "Planet": {
    "planet.PAN6287": {
      "Name": "PAN6287",
      "Color": {
        "R": 0.89215684,
        "G": 0.031372547,
        "B": 0.05490196
      },
      "Position": {
        "X": -2664,
        "Y": -1121
      },
      "IsHome": false,
      "Texture": 4,
      "Size": 8,
      "LastShipCountUpdate": 1398374487,
      "ShipCount": -1,
      "MaxShipCount": 0,
      "Owner": "RedPanda"
    }
  }
}

It contains list of the lost planet

Errors

At any point of the communication if wrong message is sent the following response will be returned.

  • [output] Error message
{
  "Command": "error",
  "Timestamp": 1394584234844,
  "Message": "Unable to parse request"
}
Clone this wiki locally