diff --git a/slop_with_models.py b/slop_with_models.py index 6c43ea2..e65a3d4 100644 --- a/slop_with_models.py +++ b/slop_with_models.py @@ -299,6 +299,9 @@ def get_or_create_stats(game, agent_id): def update_resource(resource_id, new_content): with resource_lock: + # If the resource doesn't exist, initialize it with the correct structure + if resource_id not in resources: + resources[resource_id] = {"id": resource_id, "content": None} resources[resource_id]["content"] = new_content save_resources_to_file(resources) logger.debug(f"Updated resource {resource_id}: {new_content}") @@ -808,7 +811,7 @@ def pay(): logger.debug(f"Pay request data: {data}") amount = data.get("amount", 0) transaction_id = f"tx_{int(datetime.now().timestamp())}" - logger.info(f"Processed payment of {amount} with transaction ID: {transaction_id}") + logger.info(f"Processed payment of {amount} with transaction_id: {transaction_id}") return ( jsonify( {