def start(table_id): player_id = request.cookies['player_id'] tc = TableController(table_id, player_id) tc.start() data = table_schema.dump(tc).data logging.info(data) return jsonify(success=True, data=data)
def observe(table_id): """observer""" player_id = request.cookies.get('player_id', 0) tc = TableController(table_id, player_id) data = table_schema.dump(tc).data logging.info(data) return jsonify(success=True, data=data)
def join(table_id): """join""" player_id = request.cookies['player_id'] tc = TableController(table_id) tc.join(player_id) data = table_schema.dump(tc).data # return jsonify(data) return render_template('table.html', **data)
def create(): """create a game table""" player_id = request.cookies['player_id'] table = Table.create_table(player_id) tc = TableController(table.table_id, player_id) data = table_schema.dump(tc).data # return jsonify(data) return render_template('table.html', **data)
def step(table_id): player_id = request.cookies['player_id'] tc = TableController(table_id, player_id) logging.info(request.form) schema_id = request.form.get('schema_id', type=int) p_x = request.form.get('p_x', type=int) p_y = request.form.get('p_y', type=int) rotate = request.form.get('rotate', 0, type=int) symmetry = request.form.get('symmetry', 0, type=int) tc.step(schema_id, [p_y, p_x], rotate, bool(symmetry)) data = table_schema.dump(tc).data logging.info(data) return jsonify(success=True, data=data)
def observe(table_id): """observer""" tc = TableController(table_id) return jsonify(success=True, data=table_schema.dump(tc).data)