Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- app.py +6 -2
- demo_rules.py +6 -6
app.py
CHANGED
|
@@ -1736,12 +1736,16 @@ def _format_world_info_panel(gs: GameState | None) -> str:
|
|
| 1736 |
|
| 1737 |
|
| 1738 |
def _progress_bar(current: int, maximum: int, label: str, length: int = 10) -> str:
|
| 1739 |
-
"""生成
|
| 1740 |
ratio = current / maximum if maximum > 0 else 0
|
| 1741 |
filled = int(ratio * length)
|
| 1742 |
empty = length - filled
|
| 1743 |
bar = "█" * filled + "░" * empty
|
| 1744 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1745 |
|
| 1746 |
|
| 1747 |
# ============================================================
|
|
|
|
| 1736 |
|
| 1737 |
|
| 1738 |
def _progress_bar(current: int, maximum: int, label: str, length: int = 10) -> str:
|
| 1739 |
+
"""生成 HTML 进度条(数值单独一行,低于 40% 高亮红色)"""
|
| 1740 |
ratio = current / maximum if maximum > 0 else 0
|
| 1741 |
filled = int(ratio * length)
|
| 1742 |
empty = length - filled
|
| 1743 |
bar = "█" * filled + "░" * empty
|
| 1744 |
+
value_color = "#b91c1c" if ratio < 0.4 else "#0f172a"
|
| 1745 |
+
return (
|
| 1746 |
+
f"{label}: <span style='font-family:monospace;'>{bar}</span>"
|
| 1747 |
+
f"<br><span style='color:{value_color};font-weight:600;'>{current}/{maximum}</span>"
|
| 1748 |
+
)
|
| 1749 |
|
| 1750 |
|
| 1751 |
# ============================================================
|
demo_rules.py
CHANGED
|
@@ -818,7 +818,7 @@ def build_scene_actions(game_state, location_name: str | None = None) -> list[di
|
|
| 818 |
_make_action(
|
| 819 |
action_type="ATTACK",
|
| 820 |
target="哥布林",
|
| 821 |
-
text="
|
| 822 |
priority=120,
|
| 823 |
)
|
| 824 |
)
|
|
@@ -911,7 +911,7 @@ def build_scene_actions(game_state, location_name: str | None = None) -> list[di
|
|
| 911 |
_make_action(
|
| 912 |
action_type="ATTACK",
|
| 913 |
target="盗贼斥候",
|
| 914 |
-
text="
|
| 915 |
priority=120,
|
| 916 |
)
|
| 917 |
)
|
|
@@ -932,7 +932,7 @@ def build_scene_actions(game_state, location_name: str | None = None) -> list[di
|
|
| 932 |
_make_action(
|
| 933 |
action_type="ATTACK",
|
| 934 |
target="游荡幽灵",
|
| 935 |
-
text="
|
| 936 |
priority=120,
|
| 937 |
)
|
| 938 |
)
|
|
@@ -953,7 +953,7 @@ def build_scene_actions(game_state, location_name: str | None = None) -> list[di
|
|
| 953 |
_make_action(
|
| 954 |
action_type="ATTACK",
|
| 955 |
target="骷髅兵",
|
| 956 |
-
text="
|
| 957 |
priority=120,
|
| 958 |
)
|
| 959 |
)
|
|
@@ -1042,7 +1042,7 @@ def build_scene_actions(game_state, location_name: str | None = None) -> list[di
|
|
| 1042 |
_make_action(
|
| 1043 |
action_type="ATTACK",
|
| 1044 |
target="森林巨魔",
|
| 1045 |
-
text="
|
| 1046 |
priority=120,
|
| 1047 |
)
|
| 1048 |
)
|
|
@@ -1225,7 +1225,7 @@ def build_goal_directed_actions(game_state) -> list[dict[str, Any]]:
|
|
| 1225 |
_make_action(
|
| 1226 |
action_type="ATTACK",
|
| 1227 |
target=enemy_name,
|
| 1228 |
-
text=f"
|
| 1229 |
priority=100,
|
| 1230 |
)
|
| 1231 |
)
|
|
|
|
| 818 |
_make_action(
|
| 819 |
action_type="ATTACK",
|
| 820 |
target="哥布林",
|
| 821 |
+
text="与哥布林战斗",
|
| 822 |
priority=120,
|
| 823 |
)
|
| 824 |
)
|
|
|
|
| 911 |
_make_action(
|
| 912 |
action_type="ATTACK",
|
| 913 |
target="盗贼斥候",
|
| 914 |
+
text="与盗贼斥候战斗",
|
| 915 |
priority=120,
|
| 916 |
)
|
| 917 |
)
|
|
|
|
| 932 |
_make_action(
|
| 933 |
action_type="ATTACK",
|
| 934 |
target="游荡幽灵",
|
| 935 |
+
text="与游荡幽灵战斗",
|
| 936 |
priority=120,
|
| 937 |
)
|
| 938 |
)
|
|
|
|
| 953 |
_make_action(
|
| 954 |
action_type="ATTACK",
|
| 955 |
target="骷髅兵",
|
| 956 |
+
text="与骷髅兵战斗",
|
| 957 |
priority=120,
|
| 958 |
)
|
| 959 |
)
|
|
|
|
| 1042 |
_make_action(
|
| 1043 |
action_type="ATTACK",
|
| 1044 |
target="森林巨魔",
|
| 1045 |
+
text="与森林巨魔战斗",
|
| 1046 |
priority=120,
|
| 1047 |
)
|
| 1048 |
)
|
|
|
|
| 1225 |
_make_action(
|
| 1226 |
action_type="ATTACK",
|
| 1227 |
target=enemy_name,
|
| 1228 |
+
text=f"与{enemy_name}战斗",
|
| 1229 |
priority=100,
|
| 1230 |
)
|
| 1231 |
)
|