@@ -975,6 +975,8 @@ def __init__(self) -> None:
975975 self .dexterity = 3
976976 self .unarmed_attack = Weapon (UnarmedAttack .FISTS .name , weapon_type = WeaponType .UNARMED )
977977 self .weapon_skills = {} # type: Dict[WeaponType, int] # weapon type -> skill level
978+ self .combat_points = 0 # combat points
979+ self .max_combat_points = 5 # max combat points
978980
979981 def __repr__ (self ):
980982 return "<Stats: %s>" % self .__dict__
@@ -1007,6 +1009,22 @@ def get_weapon_skill(self, weapon_type: WeaponType) -> int:
10071009 def set_weapon_skill (self , weapon_type : WeaponType , value : int ) -> None :
10081010 self .weapon_skills [weapon_type ] = value
10091011
1012+ def replenish_hp (self , amount : int = None ) -> None :
1013+ if amount :
1014+ self .hp += amount
1015+ else :
1016+ self .hp = self .max_hp
1017+ if self .hp > self .max_hp :
1018+ self .hp = self .max_hp
1019+
1020+ def replenish_combat_points (self , amount : int = None ) -> None :
1021+ if amount :
1022+ self .combat_points += amount
1023+ else :
1024+ self .combat_points = self .max_combat_points
1025+ if self .combat_points > self .max_combat_points :
1026+ self .combat_points = self .max_combat_points
1027+
10101028class Living (MudObject ):
10111029 """
10121030 A living entity in the mud world (also known as an NPC).
@@ -1422,6 +1440,10 @@ def locate_item(self, name: str, include_inventory: bool=True, include_location:
14221440
14231441 def start_attack (self , defender : 'Living' , target_body_part : wearable .WearLocation = None ) -> combat .Combat :
14241442 """Starts attacking the given living for one round."""
1443+ if self .stats .combat_points < 1 :
1444+ self .tell ("You are too tired to attack." )
1445+ return
1446+ self .stats .combat_points -= 1
14251447 attacker_name = lang .capital (self .title )
14261448 victim_name = lang .capital (defender .title )
14271449 attackers = [self ]
0 commit comments