update treasure to weapon and auxiliary

This commit is contained in:
bridge
2025-11-13 01:54:46 +08:00
parent 125d7891e5
commit 3d60df4dbf
7 changed files with 183 additions and 22 deletions

View File

@@ -17,9 +17,33 @@ class NurtureWeapon(TimedAction):
duration_months = 3
def _execute(self) -> None:
from src.classes.equipment_grade import EquipmentGrade
from src.classes.weapon import get_treasure_weapon
# 温养兵器增加较多熟练度5-10
proficiency_gain = random.uniform(5.0, 10.0)
self.avatar.increase_weapon_proficiency(proficiency_gain)
# 如果是普通兵器有5%概率升级为宝物
if self.avatar.weapon and self.avatar.weapon.grade == EquipmentGrade.COMMON:
if random.random() < 0.05:
treasure_weapon = get_treasure_weapon(self.avatar.weapon.weapon_type)
if treasure_weapon:
import copy
old_weapon_name = self.avatar.weapon.name
old_proficiency = self.avatar.weapon_proficiency
# 深拷贝宝物兵器并更换(会重新计算长期效果)
new_weapon = copy.deepcopy(treasure_weapon)
self.avatar.change_weapon(new_weapon)
# 恢复熟练度change_weapon 会归零,需要手动恢复)
self.avatar.weapon_proficiency = old_proficiency
# 记录升华事件
from src.classes.event import Event
self.avatar.world.add_event(Event(
self.avatar.world.month_stamp,
f"{self.avatar.name} 温养{old_weapon_name}时,兵器灵性大增,升华为{treasure_weapon.name}",
related_avatars=[self.avatar.id]
))
def can_start(self) -> tuple[bool, str]:
# 任何时候都可以温养兵器
@@ -36,6 +60,7 @@ class NurtureWeapon(TimedAction):
def finish(self) -> list[Event]:
weapon_name = self.avatar.weapon.name if self.avatar.weapon else "兵器"
proficiency = self.avatar.weapon_proficiency
# 注意升华事件已经在_execute中添加这里只添加完成事件
return [
Event(
self.world.month_stamp,