Split state parsing on adapter into separate func
This commit is contained in:
@@ -39,14 +39,17 @@ def ask_engine(command):
|
||||
return result
|
||||
|
||||
|
||||
@app.route("/get_state/")
|
||||
def get_state():
|
||||
state_str = ask_engine("get_state")
|
||||
state = {
|
||||
def parse_state(state_str):
|
||||
return {
|
||||
state_str[i + 2 : i + 4]: make_piece(state_str[i : i + 2])
|
||||
for i in range(0, len(state_str), 4)
|
||||
}
|
||||
return flask.jsonify(state)
|
||||
|
||||
|
||||
@app.route("/get_state/")
|
||||
def get_state():
|
||||
state_str = ask_engine("get_state")
|
||||
return flask.jsonify(parse_state(state_str))
|
||||
|
||||
|
||||
@app.route("/get_moves/", methods=["POST"])
|
||||
|
||||
Reference in New Issue
Block a user