update readme
This commit is contained in:
@@ -12,6 +12,7 @@ from src.classes.event import Event, NULL_EVENT
|
||||
from src.classes.item import Item, items_by_name
|
||||
from src.classes.prices import prices
|
||||
from src.classes.hp_and_mp import HP_MAX_BY_REALM, MP_MAX_BY_REALM
|
||||
from src.classes.battle import decide_battle
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from src.classes.avatar import Avatar
|
||||
@@ -572,16 +573,26 @@ class Sold(DefineAction, ActualActionMixin):
|
||||
return isinstance(region, CityRegion) and bool(self.avatar.items)
|
||||
|
||||
|
||||
ALL_ACTION_CLASSES = [Move, Cultivate, Breakthrough, MoveToRegion, MoveToAvatar, Play, Hunt, Harvest, Sold]
|
||||
ALL_ACTUAL_ACTION_CLASSES = [Cultivate, Breakthrough, MoveToRegion, MoveToAvatar, Play, Hunt, Harvest, Sold]
|
||||
ALL_ACTION_NAMES = ["Move", "Cultivate", "Breakthrough", "MoveToRegion", "MoveToAvatar", "Play", "Hunt", "Harvest", "Sold"]
|
||||
ALL_ACTUAL_ACTION_NAMES = ["Cultivate", "Breakthrough", "MoveToRegion", "MoveToAvatar", "Play", "Hunt", "Harvest", "Sold"]
|
||||
|
||||
ACTION_INFOS = {
|
||||
action.__name__: {
|
||||
"comment": action.COMMENT,
|
||||
"doable_requirements": action.DOABLES_REQUIREMENTS,
|
||||
"params": action.PARAMS,
|
||||
} for action in ALL_ACTUAL_ACTION_CLASSES
|
||||
}
|
||||
ACTION_INFOS_STR = json.dumps(ACTION_INFOS, ensure_ascii=False)
|
||||
class Battle(DefineAction, ChunkActionMixin):
|
||||
COMMENT = "与目标进行对战,判定胜负"
|
||||
DOABLES_REQUIREMENTS = "任何时候都可以执行"
|
||||
PARAMS = {"avatar_name": "AvatarName"}
|
||||
def _execute(self, avatar_name: str) -> None:
|
||||
target = None
|
||||
for v in self.world.avatar_manager.avatars.values():
|
||||
if v.name == avatar_name:
|
||||
target = v
|
||||
break
|
||||
if target is None:
|
||||
return
|
||||
winner, loser, _ = decide_battle(self.avatar, target)
|
||||
# 简化:失败者HP小额扣减
|
||||
if hasattr(loser, "hp"):
|
||||
loser.hp.reduce(10)
|
||||
def is_finished(self, avatar_name: str) -> bool:
|
||||
return True
|
||||
def get_event(self, avatar_name: str) -> Event:
|
||||
return Event(self.world.month_stamp, f"{self.avatar.name} 与 {avatar_name} 进行对战")
|
||||
@property
|
||||
def is_doable(self) -> bool:
|
||||
return True
|
||||
|
||||
@@ -3,8 +3,6 @@ from __future__ import annotations
|
||||
import json
|
||||
|
||||
from src.classes.action import (
|
||||
DefineAction,
|
||||
ActualActionMixin,
|
||||
Move,
|
||||
Cultivate,
|
||||
Breakthrough,
|
||||
@@ -14,19 +12,19 @@ from src.classes.action import (
|
||||
Hunt,
|
||||
Harvest,
|
||||
Sold,
|
||||
Battle,
|
||||
)
|
||||
from src.classes.mutual_action import (
|
||||
MutualAction,
|
||||
DriveAway,
|
||||
AttackInteract,
|
||||
MoveAwayFromAvatar,
|
||||
MoveAwayFromRegion,
|
||||
Battle,
|
||||
)
|
||||
|
||||
|
||||
ALL_ACTION_CLASSES = [
|
||||
Move,
|
||||
Battle,
|
||||
Cultivate,
|
||||
Breakthrough,
|
||||
MoveToRegion,
|
||||
@@ -40,7 +38,6 @@ ALL_ACTION_CLASSES = [
|
||||
AttackInteract,
|
||||
MoveAwayFromAvatar,
|
||||
MoveAwayFromRegion,
|
||||
Battle,
|
||||
]
|
||||
|
||||
ALL_ACTUAL_ACTION_CLASSES = [
|
||||
@@ -56,7 +53,6 @@ ALL_ACTUAL_ACTION_CLASSES = [
|
||||
AttackInteract,
|
||||
MoveAwayFromAvatar,
|
||||
MoveAwayFromRegion,
|
||||
Battle,
|
||||
]
|
||||
|
||||
ALL_ACTION_NAMES = [action.__name__ for action in ALL_ACTION_CLASSES]
|
||||
|
||||
@@ -181,8 +181,8 @@ class Avatar:
|
||||
return False
|
||||
action_name, _ = pair
|
||||
action = self.create_action(action_name)
|
||||
# 动作的 is_doable 定义为 @property
|
||||
return bool(getattr(action, "is_doable", True))
|
||||
doable = action.is_doable
|
||||
return doable
|
||||
|
||||
async def act(self) -> List[Event]:
|
||||
"""
|
||||
|
||||
@@ -7,7 +7,6 @@ from src.classes.action import DefineAction, ActualActionMixin, LLMAction
|
||||
from src.classes.event import Event
|
||||
from src.utils.llm import get_prompt_and_call_llm
|
||||
from src.utils.config import CONFIG
|
||||
from src.classes.battle import decide_battle
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from src.classes.avatar import Avatar
|
||||
@@ -207,29 +206,4 @@ class MoveAwayFromRegion(DefineAction, ActualActionMixin):
|
||||
return Event(self.world.month_stamp, f"{self.avatar.name} 离开 {region}")
|
||||
@property
|
||||
def is_doable(self) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
class Battle(DefineAction, ActualActionMixin):
|
||||
COMMENT = "与目标进行对战,判定胜负"
|
||||
DOABLES_REQUIREMENTS = "任何时候都可以执行"
|
||||
PARAMS = {"avatar_name": "AvatarName"}
|
||||
def _execute(self, avatar_name: str) -> None:
|
||||
target = None
|
||||
for v in self.world.avatar_manager.avatars.values():
|
||||
if v.name == avatar_name:
|
||||
target = v
|
||||
break
|
||||
if target is None:
|
||||
return
|
||||
winner, loser, _ = decide_battle(self.avatar, target)
|
||||
# 简化:失败者HP小额扣减
|
||||
if hasattr(loser, "hp"):
|
||||
loser.hp.reduce(10)
|
||||
def is_finished(self, avatar_name: str) -> bool:
|
||||
return True
|
||||
def get_event(self, avatar_name: str) -> Event:
|
||||
return Event(self.world.month_stamp, f"{self.avatar.name} 与 {avatar_name} 进行对战")
|
||||
@property
|
||||
def is_doable(self) -> bool:
|
||||
return True
|
||||
return True
|
||||
Reference in New Issue
Block a user