Skip to content

Instantly share code, notes, and snippets.

@jlisee
Last active June 6, 2022 22:43
Show Gist options
  • Save jlisee/2c0187a23c373e42d1fed769ff6930ba to your computer and use it in GitHub Desktop.
Save jlisee/2c0187a23c373e42d1fed769ff6930ba to your computer and use it in GitHub Desktop.
Leek Wars API Notes

See the this JavaClient for the API: https://sourcegraph.com/github.com/bjansen/IDEALeek/-/blob/src/com/plopiplop/leekwars/apiclient/LeekWarsApiClient.java

Looks like the flow:

  • list all scripts

New folder

api/ai-folder/new-name Parmas:

  • folder_id: 0
  • name: <name>

Response: {"id":20934}

New Script

Will have place holder AI content.

api/ai-folder/new-name

Params

  • folder_id: <which folder to contain>
  • version: 3
  • name: <name>

Response:

{"ai":{"id":358451,"name":"Test AI In Folder","level":1,"code":"\/**\r\n * Welcome to Leek Wars!\r\n * To know how the game works: leekwars.com\/help\/general\r\n * To learn the LeekScript language: leekwars.com\/help\/tutorial\r\n * To learn more about the available functions: leekwars.com\/help\/documentation\r\n**\/\r\n\r\n\/\/ This is a very basic example code:\r\n\r\n\/\/ We take the pistol\r\nsetWeapon(WEAPON_PISTOL); \/\/ Warning: costs 1 TP\r\n\r\n\/\/ We get the nearest enemy\r\nvar enemy = getNearestEnemy();\r\n\r\n\/\/ We move towards him\r\nmoveToward(enemy);\r\n\r\n\/\/ We try to shoot him!\r\nuseWeapon(enemy);","folder":20934}}

Update Script

POST api/ai/save

Params:

  • ai_id - ID of script
  • code - contents of file

Response: (first number is ID) {"result":{"356074":[]},"modified":1654554958901}

Delete

DELETE api/ai/delete

Params:

  • ai_id - ID of script

Response: []

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment