#
# ms1.py
#
# Skeleton API server for writing meatshields bots:
# see https://meatshields.com/createBotGuide.php
#
# 1. install Flask-Restful on a fresh Ubuntu 16.04 install:
# sudo apt-get update; sudo apt-get upgrade
# sudo apt-get install python3-pip
# pip3 install flask flask-restful
# 
# 2. run the bot server
# ./run.sh
#
# 3. in a separate window, test the heartbeat interface:
# ./test_heartbeat.sh
# OK
#
# 4. in a separate window, test the nextmove interface:
# ./test_nextmove.sh
# {
#     "status": "success",
#     "data": {
#         "purchase": false,
#         "end_turn": true,
#         "move": false
#     }
# }
#

from flask import Flask, request, json
from flask_restful import Resource, Api

app = Flask(__name__)
api = Api(app)

class Heartbeat(Resource):
    def post(self):
        return { "status": "success", "data": "OK" }

class NullNextMove(Resource):
    def post(self):
        botPlayerId = request.form['botPlayerId']
        gameInfo = json.loads(request.form['gameInfo'])
        app.logger.debug('tiles[0]: {}...'.format(gameInfo['tiles'][0]))

        # ... write your bot here ...
        
        return { "status": "success", "data": {
            "move": False,
            "purchase": False,
            "end_turn": True,
            }}

api.add_resource(Heartbeat, '/meatshields/bot/getHeartbeat')
api.add_resource(NullNextMove, '/meatshields/bot/getNextMove')

if __name__ == '__main__':
    app.run(debug=True)

@@ -1,636 +1,18 @@
 #%0A# 
-ms1.py%0A#%0A# Skeleton API server for writing meatshields bots:%0A# see https://meatshields.com/createBotGuide.php%0A#%0A# 1. install Flask-Restful on a fresh Ubuntu 16.04 install:%0A# sudo apt-get update; sudo apt-get upgrade%0A# sudo apt-get install python3-pip%0A# pip3 install flask flask-restful%0A# %0A# 2. run the bot server%0A# ./run.sh%0A#%0A# 3. in a separate window, test the heartbeat interface:%0A# ./test_heartbeat.sh%0A# OK%0A#%0A# 4. in a separate window, test the nextmove interface:%0A# ./test_nextmove.sh%0A# %7B%0A#     %22status%22: %22success%22,%0A#     %22data%22: %7B%0A#         %22purchase%22: false,%0A#         %22end_turn%22: true,%0A#         %22move%22: false%0A#     %7D%0A# %7D
+nullbot.py
 %0A#%0A%0A

move docs to README.md