X-Git-Url: https://harishankar.org/repos/?p=butaba-adventures.git;a=blobdiff_plain;f=npcs.py;h=12db0b1be0d4f1d3979158a9e30d93d788acba7e;hp=ae781da196fcc3dd8e01ab20da7a1bd55406ed64;hb=00470eddc34eeaab26209197d9e92995fbf12498;hpb=4d50728c1454554fef2ad4841345d0c28101702d diff --git a/npcs.py b/npcs.py index ae781da..12db0b1 100644 --- a/npcs.py +++ b/npcs.py @@ -6,20 +6,40 @@ import os.path class NPC: # initalize the NPC - def __init__ (self, charname, row, col, image=None, portrait=None, dialogue_set=set(), - currentdialog=0, is_dead=False): + def __init__ (self, charname, row, col, imageleft, imageright, imagefront, + imageback, portrait, position, movement_area=(0,0,0,0), movement_speed = 10, + dialogues=[], currentdialog=0, is_dead=False): # name of the character self.charname = charname # row and column to appear (in level) self.row = row self.col = col - # image to represent on level - self.image = image + # initial row and col - to track the movement area + self.initrow = row + self.initcol = col + # images to represent on level + self.imageleft = imageleft + self.imageright = imageright + self.imagefront = imagefront + self.imageback = imageback + # portrait on dialogues self.portrait = portrait + + # movement area limits (left, right top, and bottom) in which the NPC can + # move around in the level randomly. + self.leftlimit, self.rightlimit, self.toplimit, self.bottomlimit = movement_area + + # chance of movement (speed) - that is chance of movement in a turn out of 500 -lower + # the value lower the speed + self.movement_speed = movement_speed + + # position of the character + self.position = position + # dialogue set for NPC # each dialogue in the set is a path to an XML file containing the dialogue - self.dialogue_set = dialogue_set + self.dialogues = dialogues # index of the current dialogue which will be initiated with the main # character self.currentdialog = currentdialog @@ -29,6 +49,16 @@ class NPC: # Bulisa is Butaba's friend class Bulisa (NPC): - def __init__ (self, row, col, image, portrait, dialogue_set=set(), currentdialog=0): - NPC.__init__ (self, "Bulisa", row, col, image, portrait, dialogue_set, currentdialog) + def __init__ (self, row, col, imageleft, imageright, imagefront, + imageback, portrait, position, movement_area=(0,0,0,0), + dialogues=[], currentdialog=0): + NPC.__init__ (self, "Bulisa", row, col, imageleft, imageright, imagefront, + imageback, portrait, position, movement_area, 20, dialogues, currentdialog) + +class Mayor (NPC): + def __init__ (self, row, col, imageleft, imageright, imagefront, + imageback, portrait, position, movement_area=(0,0,0,0), + dialogues=[], currentdialog=0): + NPC.__init__ (self, "Mayor", row, col, imageleft, imageright, imagefront, + imageback, portrait, position, movement_area, 15, dialogues, currentdialog)