def api_get_games(machine_id): try: if not is_machine(machine_id): return str( generate_error_reply_JSON( "machine with that id don't exists!")) return str(generate_list_of_games_reply_JSON(machine_id)) except Exception as e: return str(generate_error_reply_JSON(str(e)))
def api_enter_game(machine_id, game_id): try: if not is_machine(machine_id): return str( generate_error_reply_JSON( "machine with that id don't exists!")) enter_game(machine_id, game_id) return str(generate_success_reply_JSON()) except Exception as e: return str(generate_error_reply_JSON(str(e)))
def api_spin(machine_id): try: if not is_machine(machine_id): return str( generate_error_reply_JSON( "machine with that id don't exists!")) body = request.get_json(force=True) spin(machine_id, body['bet'], body['timestamp']) return str(generate_success_reply_JSON()) except Exception as e: return str(generate_error_reply_JSON(str(e)))
def api_login_card_into_machine(machine_id, card_serial_number): try: if not is_machine(machine_id): return str( generate_error_reply_JSON( "machine with that id don't exists!")) if not is_card(card_serial_number): return str(generate_error_reply_JSON("this card don't exists!")) card_login(machine_id, card_serial_number) return str(generate_success_reply_JSON()) except Exception as e: return str(generate_error_reply_JSON(str(e)))