home
·
contact
·
privacy
projects
/
plomrogue2
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Record ideas for optimizing Dijkstra mapping.
[plomrogue2]
/
plomrogue
/
things.py
diff --git
a/plomrogue/things.py
b/plomrogue/things.py
index 9edfa68ca85871557aeb396075c37ed68475011d..895f5ce98938515e84670aa89b05694b01c6fbac 100644
(file)
--- a/
plomrogue/things.py
+++ b/
plomrogue/things.py
@@
-1,4
+1,4
@@
-from plomrogue.errors import GameError
+from plomrogue.errors import GameError
, PlayError
from plomrogue.mapping import YX
from plomrogue.mapping import YX
@@
-285,26
+285,20
@@
class ThingAnimate(Thing):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
- self.next_task
s = [
]
- self.
set_task('WAIT')
+ self.next_task
= [None
]
+ self.
task = None
self._fov = None
self._fov = None
- def set_task(self, task_name, args=()):
- task_class = self.game.tasks[task_name]
- self.task = task_class(self, args)
- self.task.check() # will throw GameError if necessary
-
def set_next_task(self, task_name, args=()):
task_class = self.game.tasks[task_name]
def set_next_task(self, task_name, args=()):
task_class = self.game.tasks[task_name]
- self.next_task
s +
= [task_class(self, args)]
+ self.next_task
= [task_class(self, args)]
def get_next_task(self):
def get_next_task(self):
- if len(self.next_tasks) > 0:
- task = self.next_tasks.pop(0)
+ if self.next_task[0]:
+ task = self.next_task[0]
+ self.next_task = [None]
task.check()
return task
task.check()
return task
- else:
- return None
def proceed(self):
self.drunk -= 1
def proceed(self):
self.drunk -= 1
@@
-313,6
+307,7
@@
class ThingAnimate(Thing):
if self.game.sessions[c_id]['thing_id'] == self.id_:
self.game.io.send('DEFAULT_COLORS', c_id)
self.game.io.send('CHAT "You sober up."', c_id)
if self.game.sessions[c_id]['thing_id'] == self.id_:
self.game.io.send('DEFAULT_COLORS', c_id)
self.game.io.send('CHAT "You sober up."', c_id)
+ break
self.game.changed = True
self._fov = None
if self.task is None:
self.game.changed = True
self._fov = None
if self.task is None:
@@
-320,12
+315,12
@@
class ThingAnimate(Thing):
return
try:
self.task.check()
return
try:
self.task.check()
- except
GameError
as e:
+ except
(PlayError, GameError)
as e:
self.task = None
raise e
self.task.todo -= 1
if self.task.todo <= 0:
self.task = None
raise e
self.task.todo -= 1
if self.task.todo <= 0:
- self.
_last_task_result = self.
task.do()
+ self.task.do()
self.game.changed = True
self.task = self.get_next_task()
self.game.changed = True
self.task = self.get_next_task()