Actualizar README.md con secciones de demostración y arquitectura, y mejorar la interfaz de usuario en app.py para manejar bloques HTML. También se corrigen comentarios y traducciones en obr.py y test.py.
18f4e71
| from tools.obr import ( | |
| create_shape, | |
| create_token, | |
| game_state, | |
| move_item, | |
| delete_item, | |
| fill_fog, | |
| clear_fog, | |
| add_token_light, | |
| animate_token_viewport, | |
| insert_map, | |
| clean_map | |
| ) | |
| import time | |
| # === TEST FUNCTION === | |
| def test_function(tab_id): | |
| """Test function that demonstrates all OBR functionalities""" | |
| results = [] | |
| try: | |
| # 1. Clean the map | |
| results.append({"step": "1. Cleaning map", "result": clean_map(tab_id)}) | |
| time.sleep(1) | |
| # 2. Clear fog | |
| results.append({"step": "2. Clearing fog", "result": clear_fog(tab_id)}) | |
| time.sleep(1) | |
| # 3. Insert map | |
| results.append({"step": "3. Inserting map", "result": insert_map(tab_id, "FOREST")}) | |
| time.sleep(1) | |
| # 4. Create geometric shapes (red circles in diagonal) | |
| for i in range(0, 30, 6): | |
| shape_result = create_shape( | |
| width=2, | |
| height=2, | |
| x=i, | |
| y=i, | |
| shape_type="CIRCLE", | |
| fill_color="#FF0000", | |
| stroke_color="#FF0000", | |
| tab_id=tab_id | |
| ) | |
| results.append({"step": f"4. Creating circle at ({i},{i})", "result": shape_result}) | |
| time.sleep(0.5) | |
| # 5. Create main token (Knight) | |
| knight_result = create_token( | |
| name="Knight", | |
| type="KNIGHT", | |
| x=0, | |
| y=0, | |
| size=1, | |
| tab_id=tab_id | |
| ) | |
| knight_id = [i for i in knight_result['result']["gameState"]['images'] if i["name"] == "Knight"][0]["id"] | |
| results.append({"step": "5. Creating Knight", "result": knight_result, "token_id": knight_id}) | |
| time.sleep(1) | |
| # 6. Move the knight to intermediate position | |
| if knight_id: | |
| results.append({"step": "6. Moving Knight to (14,14)", "result": move_item(tab_id, knight_id, 14, 14)}) | |
| time.sleep(1) | |
| # 7. Move the knight to final position | |
| results.append({"step": "7. Moving Knight to (29,29)", "result": move_item(tab_id, knight_id, 29, 29)}) | |
| time.sleep(1) | |
| # 8. Create dragon token | |
| dragon_result = create_token( | |
| name="Red Dragon", | |
| type="DRAGON", | |
| x=14, | |
| y=14, | |
| size=3, | |
| tab_id=tab_id | |
| ) | |
| dragon_id = [i for i in dragon_result['result']["gameState"]['images'] if i["name"] == "Red Dragon"][0]["id"] | |
| results.append({"step": "8. Creating Red Dragon", "result": dragon_result, "token_id": dragon_id}) | |
| time.sleep(1) | |
| # 9. Animate viewport to dragon | |
| if dragon_id: | |
| results.append({"step": "9. Animating viewport to dragon", "result": animate_token_viewport(tab_id, dragon_id)}) | |
| time.sleep(1) | |
| # 10. Fill with fog | |
| results.append({"step": "10. Filling with fog", "result": fill_fog(tab_id)}) | |
| time.sleep(1) # 11. Add light to knight | |
| if knight_id: | |
| results.append({"step": "11. Adding light to Knight", "result": add_token_light(tab_id, knight_id, 5)}) | |
| time.sleep(1) | |
| # 12. Move knight back to center | |
| results.append({"step": "12. Moving Knight back to (14,14)", "result": move_item(tab_id, knight_id, 14, 14)}) | |
| time.sleep(1) | |
| # 13. Animate viewport to knight | |
| results.append({"step": "13. Animating viewport to Knight", "result": animate_token_viewport(tab_id, knight_id)}) | |
| time.sleep(1) | |
| # 14. Get final game state | |
| final_state = game_state(tab_id) | |
| results.append({"step": "14. Final game state", "result": final_state}) | |
| time.sleep(5) | |
| #15. Clean map at the end | |
| results.append({"step": "15. Cleaning map", "result": clean_map(tab_id)}) | |
| return { | |
| "success": True, | |
| "message": "Test completed successfully", | |
| "total_steps": len(results), | |
| "results": results | |
| } | |
| except Exception as e: | |
| return { | |
| "success": False, | |
| "error": str(e), | |
| "completed_steps": len(results), | |
| "results": results | |
| } |