Skip to content

Commit 1e01788

Browse files
authored
Merge pull request #12 from neph1/combat_hot_fix
fixing broken combat
2 parents 863b035 + 8c6b893 commit 1e01788

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

tale/base.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,19 +1361,11 @@ def start_attack(self, victim: 'Living') -> None:
13611361
attacker_msg = "You attack %s! %s" % (victim_name, result)
13621362
victim.tell(victim_msg, evoke=True, max_length=False)
13631363

1364-
1365-
if isinstance(self, 'tale.player.Player'):
1366-
attacker_name += "as 'You'"
1367-
if isinstance(victim, 'tale.player.Player'):
1368-
victim_name += "as 'You'"
1369-
1370-
combat_prompt = mud_context.driver.llm_util.combat_prompt.format(attacker=attacker_name,
1371-
victim=victim_name,
1372-
attacker_weapon=self.wielding.name,
1373-
victim_weapon=victim.wielding.name,
1374-
attacker_msg=attacker_msg,
1375-
location=self.location.title,
1376-
location_description=self.location.short_description)
1364+
combat_prompt = mud_context.driver.prepare_combat_prompt(attacker=self,
1365+
victim=victim,
1366+
location_title = self.location.title,
1367+
location_description = self.location.short_description,
1368+
attacker_msg = attacker_msg)
13771369
victim.location.tell(room_msg,
13781370
exclude_living=victim,
13791371
specific_targets={self},

tale/driver.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ def _process_player_command(self, cmd: str, conn: player.PlayerConnection) -> No
603603
# the player command ended but signaled that an async dialog should be initiated
604604
topic_async_dialogs.send((conn, x.dialog))
605605

606-
def go_through_exit(self, player: player.Player, direction: str, evoke: bool=True) -> None:
606+
def go_through_exit(self, player: player.Player, direction: str, evoke: bool=False) -> None:
607607
xt = player.location.exits[direction]
608608
xt.allow_passage(player)
609609
if not xt.target.built:
@@ -818,3 +818,25 @@ def uptime(self) -> Tuple[int, int, int]:
818818
hours, seconds = divmod(uptime.total_seconds(), 3600)
819819
minutes, seconds = divmod(seconds, 60)
820820
return int(hours), int(minutes), int(seconds)
821+
822+
def prepare_combat_prompt(self,
823+
attacker: LivingNpc,
824+
victim: LivingNpc,
825+
location_title: str,
826+
location_description: str,
827+
attacker_msg: str):
828+
attacker_name = lang.capital(attacker.title)
829+
victim_name = lang.capital(victim.title)
830+
831+
if isinstance(attacker, player.Player):
832+
attacker_name += "as 'You'"
833+
if isinstance(victim, player.Player):
834+
victim_name += "as 'You'"
835+
836+
return self.llm_util.combat_prompt.format(attacker=attacker_name,
837+
victim=victim_name,
838+
attacker_weapon=attacker.wielding.name,
839+
victim_weapon=victim.wielding.name,
840+
attacker_msg=attacker_msg,
841+
location=location_title,
842+
location_description=location_description)

0 commit comments

Comments
 (0)