def get_dungeons_monster(id): if dungeon := Dungeon.find(id): response = { "level": dungeon.level, "Boss Level": dungeon.boss_level, "monsters": [m.long() for m in dungeon.monsters], } return jsonify(response)
def remove_dungeons_monster(id): payload = request.get_json() monster_id = payload.get("monster_id", None) if not monster_id: abort(400) if dungeon := Dungeon.find(id): if monster := Monster.find(monster_id): dungeon.monsters.remove(monster) dungeon.update()
def update_dungeon(id): payload = request.get_json() if not payload: abort(400) if dungeon := Dungeon.find(id): if level := payload.get("level", None): if checker := Dungeon.find_by(level): if dungeon.id != checker.id: abort( Response( response= f"level id: {level} belongs to another dungeon.", status=405, ))
def get_dungeon(id): if dungeon := Dungeon.find(id): result = {"success": True, "Dungeon": dungeon.long()} return jsonify(result)
def remove_dungeon(id): if dungeon := Dungeon.find(id): level = dungeon.level dungeon.delete() result = {"success": True, "removed dungeon level": level} return jsonify(result)