From 4e2a927bb4813aac0e320018b51b1322706ce572 Mon Sep 17 00:00:00 2001 From: BattleJenkins Date: Tue, 4 Apr 2017 17:53:06 -0700 Subject: [PATCH] Properly implemented joining a fight in progress Some of the code for joining a fight in progress was imported from my project, The World of Cool Battles, but was not implemented completely. The turn handler script now properly puts a reference to itself in the current fight's room, and joining a combat in progress that one isn't already a part of now works properly. --- evennia/contrib/turnbattle.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/evennia/contrib/turnbattle.py b/evennia/contrib/turnbattle.py index 18b0a204c9..74e94edfcd 100644 --- a/evennia/contrib/turnbattle.py +++ b/evennia/contrib/turnbattle.py @@ -204,6 +204,7 @@ def combat_cleanup(character): for attr in character.attributes.all(): if attr.key[:7] == "combat_": # If the attribute name starts with 'combat_'... character.attributes.remove(key=attr.key) # ...then delete it! + character.location.db.Combat_TurnHandler = None # Remove reference to turn handler in location def is_in_combat(character): """ @@ -648,6 +649,9 @@ class TurnHandler(DefaultScript): # Initialize each fighter for combat for fighter in self.db.fighters: self.initialize_for_combat(fighter) + + # Add a reference to this script to the room + self.obj.db.Combat_TurnHandler = self # Roll initiative and sort the list of fighters depending on who rolls highest to determine turn order. # The initiative roll is determined by the roll_init function and can be customized easily.