update treasure to weapon and auxiliary

This commit is contained in:
bridge
2025-11-13 01:34:09 +08:00
parent e760ba107d
commit 125d7891e5
16 changed files with 132 additions and 132 deletions

View File

@@ -32,6 +32,7 @@ from .help_mortals import HelpMortals
from .devour_mortals import DevourMortals
from .self_heal import SelfHeal
from .catch import Catch
from .nurture_weapon import NurtureWeapon
# 注册到 ActionRegistry标注是否为实际可执行动作
register_action(actual=False)(Action)
@@ -60,6 +61,7 @@ register_action(actual=True)(HelpMortals)
register_action(actual=True)(DevourMortals)
register_action(actual=True)(SelfHeal)
register_action(actual=True)(Catch)
register_action(actual=True)(NurtureWeapon)
# Talk 已移动到 mutual_action 模块,在那里注册
__all__ = [

View File

@@ -35,6 +35,14 @@ class Battle(InstantAction):
# 应用双方伤害
loser.hp.reduce(loser_damage)
winner.hp.reduce(winner_damage)
# 增加双方兵器熟练度(战斗经验)
import random
proficiency_gain = random.uniform(1.0, 3.0)
self.avatar.increase_weapon_proficiency(proficiency_gain)
if target is not None:
target.increase_weapon_proficiency(proficiency_gain)
self._last_result = (winner.name, loser.name, loser_damage, winner_damage)
def can_start(self, avatar_name: str | None = None) -> tuple[bool, str]:

View File

@@ -0,0 +1,46 @@
from __future__ import annotations
from src.classes.action import TimedAction
from src.classes.event import Event
import random
class NurtureWeapon(TimedAction):
"""
温养兵器:花时间温养兵器,可以较多增加熟练度
"""
COMMENT = "温养兵器,增加兵器熟练度"
DOABLES_REQUIREMENTS = "任何时候都可以执行"
PARAMS = {}
duration_months = 3
def _execute(self) -> None:
# 温养兵器增加较多熟练度5-10
proficiency_gain = random.uniform(5.0, 10.0)
self.avatar.increase_weapon_proficiency(proficiency_gain)
def can_start(self) -> tuple[bool, str]:
# 任何时候都可以温养兵器
return (True, "")
def start(self) -> Event:
weapon_name = self.avatar.weapon.name if self.avatar.weapon else "兵器"
return Event(
self.world.month_stamp,
f"{self.avatar.name} 开始温养{weapon_name}",
related_avatars=[self.avatar.id]
)
def finish(self) -> list[Event]:
weapon_name = self.avatar.weapon.name if self.avatar.weapon else "兵器"
proficiency = self.avatar.weapon_proficiency
return [
Event(
self.world.month_stamp,
f"{self.avatar.name} 完成温养{weapon_name},熟练度提升至{proficiency:.1f}%",
related_avatars=[self.avatar.id]
)
]