mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Merge pull request #3394 from jaborsh/main
Fixing Replace Legacy Time of Day Markup
This commit is contained in:
commit
014696b80a
1 changed files with 9 additions and 9 deletions
|
|
@ -47,6 +47,7 @@ from collections import deque
|
|||
|
||||
from django.conf import settings
|
||||
from django.db.models import Q
|
||||
|
||||
from evennia import (
|
||||
CmdSet,
|
||||
DefaultRoom,
|
||||
|
|
@ -432,16 +433,16 @@ class ExtendedRoom(DefaultRoom):
|
|||
|
||||
"""
|
||||
desc = desc or ""
|
||||
time_of_day = self.get_time_of_day()
|
||||
current_time_of_day = self.get_time_of_day()
|
||||
|
||||
# regexes for in-desc replacements (gets cached)
|
||||
if not hasattr(self, "legacy_timeofday_regex_map"):
|
||||
timeslots = deque()
|
||||
for time_of_day in self.times_of_day:
|
||||
for tod in self.times_of_day:
|
||||
timeslots.append(
|
||||
(
|
||||
time_of_day,
|
||||
re.compile(rf"<{time_of_day}>(.*?)</{time_of_day}>", re.IGNORECASE),
|
||||
tod,
|
||||
re.compile(rf"<{tod}>(.*?)</{tod}>", re.IGNORECASE),
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -453,11 +454,10 @@ class ExtendedRoom(DefaultRoom):
|
|||
timeslots.rotate(-1)
|
||||
|
||||
# do the replacement
|
||||
regextuple = self.legacy_timeofday_regex_map[time_of_day]
|
||||
desc = regextuple[0].sub(r"\1", desc)
|
||||
desc = regextuple[1].sub("", desc)
|
||||
desc = regextuple[2].sub("", desc)
|
||||
return regextuple[3].sub("", desc)
|
||||
regextuple = self.legacy_timeofday_regex_map[current_time_of_day]
|
||||
for regex in regextuple:
|
||||
desc = regex.sub(r"\1" if regex == regextuple[0] else "", desc)
|
||||
return desc
|
||||
|
||||
def get_display_desc(self, looker, **kwargs):
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue