Mercurial > parpg-source
diff gamescenecontroller.py @ 104:c9afad46091b
Added actions for lockable components (Open, Close, Lock and Unlock).
author | KarstenBock@gmx.net |
---|---|
date | Fri, 30 Sep 2011 14:05:16 +0200 |
parents | 824f3068ef2a |
children | 100a39fa64a2 |
line wrap: on
line diff
--- a/gamescenecontroller.py Fri Sep 30 14:04:29 2011 +0200 +++ b/gamescenecontroller.py Fri Sep 30 14:05:16 2011 +0200 @@ -28,9 +28,10 @@ from controllerbase import ControllerBase from parpg.gui.hud import Hud from parpg.gui import drag_drop_data as data_drag -from objects.action import ChangeMapAction, ExamineAction, OpenBoxAction, \ - UnlockBoxAction, LockBoxAction, TalkAction, \ - PickUpAction, DropItemAction +from objects.action import (ChangeMapAction, ExamineAction, TalkAction, + OpenAction, CloseAction, UnlockAction, LockAction, + PickUpAction, DropItemAction, + ) from parpg.world import World @@ -465,18 +466,26 @@ obj.change_map.target_position)]) if obj.lockable: - actions.append(["Open", "Open", - player.fifeagent.behaviour.approach, - [obj_pos.x, obj_pos.y], - OpenBoxAction(self, obj)]) - actions.append(["Unlock", "Unlock", - player.fifeagent.behaviour.approach, - [obj_pos.x, obj_pos.y], - UnlockBoxAction(self, obj)]) - actions.append(["Lock", "Lock", - player.fifeagent.behaviour.approach, - [obj_pos.x, obj_pos.y], - LockBoxAction(self, obj)]) + if obj.lockable.closed: + actions.append(["Open", "Open", + player.fifeagent.behaviour.approach, + [obj_pos.x, obj_pos.y], + OpenAction(self, obj)]) + else: + actions.append(["Close", "Close", + player.fifeagent.behaviour.approach, + [obj_pos.x, obj_pos.y], + CloseAction(self, obj)]) + if obj.lockable.locked: + actions.append(["Unlock", "Unlock", + player.fifeagent.behaviour.approach, + [obj_pos.x, obj_pos.y], + UnlockAction(self, obj)]) + else: + actions.append(["Lock", "Lock", + player.fifeagent.behaviour.approach, + [obj_pos.x, obj_pos.y], + LockAction(self, obj)]) if obj.containable: actions.append(["Pick Up", "Pick Up", player.fifeagent.behaviour.approach,