From 0f9f5f35f7fe38ba6fa2aa00d5c89dea488f1b1f Mon Sep 17 00:00:00 2001 From: bridge Date: Tue, 2 Sep 2025 21:19:58 +0800 Subject: [PATCH] add history action --- src/classes/ai.py | 2 +- src/classes/avatar.py | 6 ++++++ src/front/front.py | 6 ++---- 台本/vol1.txt | 9 +++++++++ 4 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 台本/vol1.txt diff --git a/src/classes/ai.py b/src/classes/ai.py index 26c7694..f26d0d8 100644 --- a/src/classes/ai.py +++ b/src/classes/ai.py @@ -70,7 +70,7 @@ class RuleAI(AI): else: return "Cultivate", {} else: - return "MoveToRegion", {"region": best_region} + return "MoveToRegion", {"region": best_region.name} def get_best_region(self, regions: list[Region]) -> Region: """ diff --git a/src/classes/avatar.py b/src/classes/avatar.py index 8d3c82b..3b08f1d 100644 --- a/src/classes/avatar.py +++ b/src/classes/avatar.py @@ -182,6 +182,12 @@ class Avatar: def is_in_region(self, region: Region) -> bool: return self.tile.region == region + def get_history_action_pairs_str(self) -> str: + """ + 获取历史动作对的字符串 + """ + return "\n".join([f"{action.__class__.__name__}: {action_params}" for action, action_params in self.history_action_pairs]) + def get_new_avatar_from_ordinary(world: World, current_month_stamp: MonthStamp, name: str, age: Age): """ 从凡人中来的新修士 diff --git a/src/front/front.py b/src/front/front.py index 447ffe5..50039cc 100644 --- a/src/front/front.py +++ b/src/front/front.py @@ -124,6 +124,7 @@ class Front: elif event.key == pygame.K_SPACE: self._step_once() + # 自动步进 if self._auto_step and self._last_step_ms >= self.step_interval_ms: self._step_once() @@ -423,10 +424,7 @@ class Front: # 添加历史动作信息 lines.append("") # 空行分隔 lines.append("历史动作:") - for i, (action, params) in enumerate(avatar.history_action_pairs): - action_name = action.__class__.__name__ - lines.append(f" {i+1}. {action_name}") - + lines.extend(avatar.get_history_action_pairs_str().split("\n")) self._draw_tooltip(lines, *self.pygame.mouse.get_pos(), self.tooltip_font) def _draw_tooltip_for_region(self, region, mouse_x: int, mouse_y: int): diff --git a/台本/vol1.txt b/台本/vol1.txt new file mode 100644 index 0000000..43169c6 --- /dev/null +++ b/台本/vol1.txt @@ -0,0 +1,9 @@ +标题党致歉 +总得有人来做 +目前的进度 +鬼谷八荒 +战斗——火焰纹章like +战棋类其实很适合表现花样很多的仙侠技能 +更丰富,像矮人地牢 +代码更灵活,配表更好入门——怎么做trade off? +可以github点赞 \ No newline at end of file