comparison gamescenecontroller.py @ 57:ba85e5aff370

Removed the pos value from the fifeagent component. getItemActions of Gamescenecontroller gets the position by calling a method of the behaviour.
author KarstenBock@gmx.net
date Fri, 09 Sep 2011 15:30:23 +0200
parents 7b9f6e3513d4
children 28561412c7e7
comparison
equal deleted inserted replaced
56:3f6299f975fe 57:ba85e5aff370
18 18
19 from datetime import datetime 19 from datetime import datetime
20 import random 20 import random
21 import glob 21 import glob
22 import os 22 import os
23 import logging
23 24
24 from fife import fife 25 from fife import fife
25 from fife import extensions 26 from fife import extensions
26 27
27 from controllerbase import ControllerBase 28 from controllerbase import ControllerBase
35 if False: 36 if False:
36 from gamesceneview import GameSceneView 37 from gamesceneview import GameSceneView
37 from gamemodel import GameModel 38 from gamemodel import GameModel
38 from parpg import PARPGApplication 39 from parpg import PARPGApplication
39 40
40 import logging
41 41
42 logger = logging.getLogger('gamescenecontroller') 42 logger = logging.getLogger('gamescenecontroller')
43 43
44 class GameSceneController(ControllerBase): 44 class GameSceneController(ControllerBase):
45 ''' 45 '''
426 @return: List of text and callbacks""" 426 @return: List of text and callbacks"""
427 actions = [] 427 actions = []
428 obj = self.model.game_state.\ 428 obj = self.model.game_state.\
429 getObjectById(obj_id, 429 getObjectById(obj_id,
430 self.model.game_state.current_map_name) 430 self.model.game_state.current_map_name)
431 obj_pos = obj.fifeagent.behaviour.getLocation().getLayerCoordinates()
431 player = self.model.game_state.getObjectById("PlayerCharacter") 432 player = self.model.game_state.getObjectById("PlayerCharacter")
432 is_player = obj.fifeagent.identifier == player.fifeagent.identifier 433 is_player = obj.fifeagent.identifier == player.fifeagent.identifier
434
433 435
434 #TODO: Check all actions to be compatible with the grease components 436 #TODO: Check all actions to be compatible with the grease components
435 if obj is not None: 437 if obj is not None:
436 if obj.dialogue and not is_player: 438 if obj.dialogue and not is_player:
437 actions.append(["Talk", "Talk", self.initTalk, obj]) 439 actions.append(["Talk", "Talk", self.initTalk, obj])
438 if obj.characterstats and not is_player: 440 if obj.characterstats and not is_player:
439 actions.append(["Attack", "Attack", self.nullFunc, obj]) 441 actions.append(["Attack", "Attack", self.nullFunc, obj])
440 if obj.description: 442 if obj.description:
441 actions.append(["Examine", "Examine", 443 actions.append(["Examine", "Examine",
442 player.fifeagent.behaviour.approach, 444 player.fifeagent.behaviour.approach,
443 [obj.fifeagent.pos.x, obj.fifeagent.pos.y], 445 [obj_pos.x, obj_pos.y],
444 ExamineAction(self, 446 ExamineAction(self,
445 obj_id, obj.description.view_name, 447 obj_id, obj.description.view_name,
446 obj.description.desc)]) 448 obj.description.desc)])
447 #WORKAROUND: To get rid of exception in gamescenecontroller 449 #WORKAROUND: To get rid of exception in gamescenecontroller
448 if obj.change_map: 450 if obj.change_map:
449 actions.append(["Change Map", "Change Map", 451 actions.append(["Change Map", "Change Map",
450 player.fifeagent.behaviour.approach, 452 player.fifeagent.behaviour.approach,
451 [obj.fifeagent.pos.x, obj.fifeagent.pos.y], 453 [obj_pos.x, obj_pos.y],
452 ChangeMapAction(self, obj.target_map_name, 454 ChangeMapAction(self, obj.target_map_name,
453 obj.target_pos)]) 455 obj.target_pos)])
454 456
455 if obj.lockable: 457 if obj.lockable:
456 actions.append(["Open", "Open", 458 actions.append(["Open", "Open",
457 player.fifeagent.behaviour.approach, 459 player.fifeagent.behaviour.approach,
458 [obj.fifeagent.pos.x, obj.fifeagent.pos.y], 460 [obj_pos.x, obj_pos.y],
459 OpenBoxAction(self, obj)]) 461 OpenBoxAction(self, obj)])
460 actions.append(["Unlock", "Unlock", 462 actions.append(["Unlock", "Unlock",
461 player.fifeagent.behaviour.approach, 463 player.fifeagent.behaviour.approach,
462 [obj.fifeagent.pos.x, obj.fifeagent.pos.y], 464 [obj_pos.x, obj_pos.y],
463 UnlockBoxAction(self, obj)]) 465 UnlockBoxAction(self, obj)])
464 actions.append(["Lock", "Lock", 466 actions.append(["Lock", "Lock",
465 player.fifeagent.behaviour.approach, 467 player.fifeagent.behaviour.approach,
466 [obj.fifeagent.pos.x, obj.fifeagent.pos.y], 468 [obj_pos.x, obj_pos.y],
467 LockBoxAction(self, obj)]) 469 LockBoxAction(self, obj)])
468 if obj.containable: 470 if obj.containable:
469 actions.append(["Pick Up", "Pick Up", 471 actions.append(["Pick Up", "Pick Up",
470 player.fifeagent.behaviour.approach, 472 player.fifeagent.behaviour.approach,
471 [obj.fifeagent.pos.x, obj.fifeagent.pos.y], 473 [obj_pos.x, obj_pos.y],
472 PickUpAction(self, obj)]) 474 PickUpAction(self, obj)])
473 475
474 return actions 476 return actions
475 477
476 def saveGame(self, *args, **kwargs): 478 def saveGame(self, *args, **kwargs):