diff --git a/Server.py b/Server.py index 5db374f..223372a 100644 --- a/Server.py +++ b/Server.py @@ -23,7 +23,7 @@ class Server: def __init__( self ): # Initializing the simulation - self.world = World( 1 ) + self.world = World( 2 ) def run( self ): print '\033[32mInfo\033[0m Starting world thread...' reactor.callInThread( self.world.run ) diff --git a/gameEngine/Brain.py b/gameEngine/Brain.py index 5dad0e2..8d8a1ad 100644 --- a/gameEngine/Brain.py +++ b/gameEngine/Brain.py @@ -23,32 +23,52 @@ def __init__( self, character ): 'food': 'eatSnack', 'water': 'drink', 'urination': 'use', - 'hygiene': 'shower' + 'hygiene': 'shower', 'fun': 'watch', 'social': 'talk' } self.activitiesMedium = { 'sleep': 'rest', 'food': 'cook', 'water': 'drink', 'urination': 'use', - 'hygiene': 'shower' + 'hygiene': 'shower', 'fun': 'watch', 'social': 'talk' } self.activitiesLow = { 'sleep': 'sleep', 'food': 'cook', 'water': 'drink', 'urination': 'use', - 'hygiene': 'shower' + 'hygiene': 'shower', 'fun': 'watch', 'social': 'talk' } + self.activityTimes = { 'rest': 900, + 'sleep': 28800, + 'eatSnack': 300, + 'cook': 900, + 'drink': 60, + 'use': 450, + 'shower': 1800, + 'watch': 1800, + 'talk': 300 } + self.activityInteractiveTypes = { 'rest': 'Bed', + 'sleep': 'Bed', + 'eatSnack': 'Refrigerator', + 'cook': 'Cooker', + 'drink': 'Refrigerator', + 'use': 'Toilet', + 'shower': 'Shower', + 'watch': 'TvSet', + 'talk': 'Character' } + self.activity = None + self.activityTimer = 0 + self.activityInteractive = None def getLowestNeed( self ): # Returns the lowest need including its value as a tuple. lowestNeed = (None, 1000) for need in self.character.needs.keys(): try: - if( self.character.needs[need] < lowestNeed(1) ): - lowestNeed(0) = need - lowestNeed(1) = self.character.needs[need] + if( self.character.needs[need] < lowestNeed[1] ): + lowestNeed = ( need, self.character.needs[need] ) except: print '\033[31mError\033[0m Character: %i\tNeed %s does not exist.' % ( self.character.id, need ) return lowestNeed @@ -58,24 +78,50 @@ def getHighestNeed( self ): highestNeed = (None, 0) for need in self.character.needs.keys(): try: - if( self.character.needs[need] > highestNeed(1) ): - highestNeed(0) = need - highestNeed(1) = self.character.needs[need] + if( self.character.needs[need] > highestNeed[1] ): + highestNeed = ( need, self.character.needs[need] ) except: print '\033[31mError\033[0m Character: %i\tNeed %s does not exist.' % ( self.character.id, need ) return highestNeed def getNextActivity( self ): # Get the next activity to satisfy the lowest need. - if( self.getLowestNeed()(1) <= 750 ): # 3/4, High - return self.activitiesHigh[ self.getLowestNeed()(0) ] - elif( self.getLowestNeed()(1) <= 500 ): # 1/2, Medium - return self.activitiesMedium[ self.getLowestNeed()(0) ] - elif( self.getLowestNeed()(1) <= 250 ): # 1/4, Low - return self.activitiesLow[ self.getLowestNeed()(0) ] + if( self.getLowestNeed()[1] <= 250 ): # 1/4, Low + self.activity = self.activitiesLow[ self.getLowestNeed()[0] ] + self.activityTimer = self.activityTimes[ self.activity ] + if( self.activityInteractiveTypes[ self.activity ] == 'Character' ): + self.activityInteractive = self.getCharacterById( 1 ) + else: + self.activityInteractive = self.getObjectByType( self.activityInteractiveTypes[ self.activity ] ) + return self.activitiesLow[ self.getLowestNeed()[0] ] + elif( self.getLowestNeed()[1] <= 500 ): # 1/2, Medium + self.activity = self.activitiesMedium[ self.getLowestNeed()[0] ] + self.activityTimer = self.activityTimes[ self.activity ] + if( self.activityInteractiveTypes[ self.activity ] == 'Character' ): + self.activityInteractive = self.getCharacterById( 1 ) + else: + self.activityInteractive = self.getObjectByType( self.activityInteractiveTypes[ self.activity ] ) + return self.activitiesMedium[ self.getLowestNeed()[0] ] + elif( self.getLowestNeed()[1] <= 750 ): # 3/4, High + self.activity = self.activitiesHigh[ self.getLowestNeed()[0] ] + self.activityTimer = self.activityTimes[ self.activity ] + if( self.activityInteractiveTypes[ self.activity ] == 'Character' ): + self.activityInteractive = self.getCharacterById( 1 ) + else: + self.activityInteractive = self.getObjectByType( self.activityInteractiveTypes[ self.activity ] ) + return self.activitiesHigh[ self.getLowestNeed()[0] ] else: + self.activity = None + self.activityTimer = 0 + self.activityInteractive = None return None + def getCharacterById( self, id ): + # Searches for a character in the world by id and returns it. + for character in self.character.world.characters: + if( character.id == id ): + return character + def getObjectById( self, id ): # Searches for an object in the world by id and returns it. for object in self.character.world.objects: @@ -90,19 +136,22 @@ def getObjectByType( self, type ): def isInRange( self, characterOrObject, radiusType ): # Checks if a character or object is in range by utilization of a bounding box and returns True if the object is in range. - # X axis - if( self.character.pos[ 0 ] >= characterOrObject.pos[ 0 ] - characterOrObject.radii[ radiusType ] - self.character.pos[ 0 ] <= characterOrObject.pos[ 0 ] + characterOrObject.radii[ radiusType ] ): - # Y axis - if( self.character.pos[ 1 ] >= characterOrObject.pos[ 1 ] - characterOrObject.radii[ radiusType ] - self.character.pos[ 1 ] <= characterOrObject.pos[ 1 ] + characterOrObject.radii[ radiusType ] ): - # Z axis - if( self.character.pos[ 2 ] >= characterOrObject.pos[ 2 ] - characterOrObject.radii[ radiusType ] - self.character.pos[ 2 ] <= characterOrObject.pos[ 2 ] + characterOrObject.radii[ radiusType ] ): - return True + try: + # X axis + if( self.character.pos[ 0 ] >= characterOrObject.pos[ 0 ] - characterOrObject.radii[ radiusType ] and + self.character.pos[ 0 ] <= characterOrObject.pos[ 0 ] + characterOrObject.radii[ radiusType ] ): + # Y axis + if( self.character.pos[ 1 ] >= characterOrObject.pos[ 1 ] - characterOrObject.radii[ radiusType ] and + self.character.pos[ 1 ] <= characterOrObject.pos[ 1 ] + characterOrObject.radii[ radiusType ] ): + # Z axis + if( self.character.pos[ 2 ] >= characterOrObject.pos[ 2 ] - characterOrObject.radii[ radiusType ] and + self.character.pos[ 2 ] <= characterOrObject.pos[ 2 ] + characterOrObject.radii[ radiusType ] ): + return True + else: + return False else: return False else: return False - else: + except: return False diff --git a/gameEngine/Character.py b/gameEngine/Character.py index c42232e..89a357b 100644 --- a/gameEngine/Character.py +++ b/gameEngine/Character.py @@ -24,30 +24,23 @@ def __init__( self, id, world, gender ): self.id = id # Unique integer number to identify a character. self.pos = [ 0, 0, 0 ] # A characters current position. self.destination = [ 0, 0, 0 ] # A characters destination for movement. + self.radii = { 'talk': 1 } if( gender.lower() == 'random' ): # A characters gender. self.gender = choice( ( 'male', 'female' ) ) # else: # self.gender = gender # - - self.activity = None # A characters activity. - self.activityTimer = 0 # How much game seconds are left for an activity. - self.activityInteractive = None # The character or object to interact with. - - # to-do: use the new brain class for ai - self.activityRadiusOn = 0 - self.activityRadiusNextTo = 1 - self.activityRadiusNear = 2 - + # The brain which provides attributes and methodes for the ai of a character. self.brain = Brain( self ) # near the character or object. - self.needs = { 'sleep': 500, # The chracters needs. - 'food': 500, # - 'water': 500, # - 'hygiene': 500, # - 'fun': 1000, # - 'social': 1000 } # + self.needs = { 'sleep': 500, # The chracters needs. + 'food': 500, # + 'water': 500, # + 'urination': 500, # + 'hygiene': 500, # + 'fun': 500, # + 'social': 500 } # def teleportTo( self, x, y, z ): print 'DEBUG: Character %i teleports to X: %i Y: %i Z: %i.' % ( self.id, x, y, z ) @@ -79,42 +72,7 @@ def move( self ): self.pos[ 2 ] += 1 elif( self.pos[ 2 ] > self.destination[ 2 ] ): self.pos[ 2 ] -= 1 - - def isInRange( self, characterOrObject, type ): - if( type == 'On' ): - if( characterOrObject.pos[ 0 ] >= self.pos[ 0 ] - self.activityRadiusOn and characterOrObject.pos[0] <= self.pos[ 0 ] + self.activityRadiusOn ): - if( characterOrObject.pos[ 1 ] >= self.pos[ 1 ] - self.activityRadiusOn and characterOrObject.pos[ 1 ] <= self.pos[ 1 ] + self.activityRadiusOn ): - if( characterOrObject.pos[ 2 ] >= self.pos[ 2 ] - self.activityRadiusOn and characterOrObject.pos[ 2 ] <= self.pos[ 2 ] + self.activityRadiusOn ): - return True - else: - return False - else: - return False - else: - return False - if( type == 'NextTo' ): - if( characterOrObject.pos[ 0 ] >= self.pos[ 0 ] - self.activityRadiusNextTo and characterOrObject.pos[0] <= self.pos[ 0 ] + self.activityRadiusNextTo ): - if( characterOrObject.pos[ 1 ] >= self.pos[ 1 ] - self.activityRadiusNextTo and characterOrObject.pos[ 1 ] <= self.pos[ 1 ] + self.activityRadiusNextTo ): - if( characterOrObject.pos[ 2 ] >= self.pos[ 2 ] - self.activityRadiusNextTo and characterOrObject.pos[ 2 ] <= self.pos[ 2 ] + self.activityRadiusNextTo ): - return True - else: - return False - else: - return False - else: - return False - if( type == 'Near' ): - if( characterOrObject.pos[ 0 ] >= self.pos[ 0 ] - self.activityRadiusNear and characterOrObject.pos[0] <= self.pos[ 0 ] + self.activityRadiusNear ): - if( characterOrObject.pos[ 1 ] >= self.pos[ 1 ] - self.activityRadiusNear and characterOrObject.pos[ 1 ] <= self.pos[ 1 ] + self.activityRadiusNear ): - if( characterOrObject.pos[ 2 ] >= self.pos[ 2 ] - self.activityRadiusNear and characterOrObject.pos[ 2 ] <= self.pos[ 2 ] + self.activityRadiusNear ): - return True - else: - return False - else: - return False - else: - return False - + def increaseNeed( self, needName, needValue ): try: if( self.needs[needName] < 1000 ): @@ -126,166 +84,42 @@ def increaseNeed( self, needName, needValue ): def decreaseNeeds( self ): try: - if( self.activity != 'rest' and self.activity != 'sleep' ): + if( self.brain.activity != 'rest' and self.brain.activity != 'sleep' ): self.needs['sleep'] -= 0.011574074 - if( self.activity != 'cook' ): + if( self.brain.activity != 'cook' ): self.needs['food'] -= 0.003858025 - if( self.activity != 'drink' ): + if( self.brain.activity != 'drink' ): self.needs['water'] -= 0.011574074 - if( self.activity != 'shower' ): + if( self.brain.activity != 'use' ): + self.needs['urination'] -= 0.069444444 + if( self.brain.activity != 'shower' ): self.needs['hygiene'] -= 0.005787037 - if( self.activity != 'watch' ): - self.needs['fun'] -= 1 - # if( self.activity != 'chat' ): - # self.needs['social'] -= 1 + if( self.brain.activity != 'watch' ): + self.needs['fun'] -= 0.034722222 + if( self.brain.activity != 'chat' ): + self.needs['social'] -= 0.011574074 except: pass def processActivity( self ): # Process the activity of a character. - - if( self.activityTimer > 0 ): # Character has active activity. - print 'Character is doing activity. Timer is not zero.' - objectFound = False - for object in self.world.objects: # Search for the object to interact with. - if( object.id == self.activityInteractive ): # Object found in the wolrd's object list. - objectFound = True - - if( self.activity == 'rest' ): - radiusType = 'On' - elif( self.activity == 'sleep' ): - radiusType = 'On' - elif( self.activity == 'eatSnack' ): - radiusType = 'NextTo' - elif( self.activity == 'cook' ): - radiusType = 'NextTo' - elif( self.activity == 'drink' ): - radiusType = 'NextTo' - elif( self.activity == 'shower' ): - radiusType = 'On' - elif( self.activity == 'watch' ): - radiusType = 'Near' - else: - radiusType = 'Near' - - if( self.isInRange( object, radiusType ) ): # Checks if the object is in range of the character. - print 'Object found to interact with and is in range (%s). Object id is %i/%i.' % ( radiusType, self.activityInteractive, object.id ) - print 'Character interacts with the object of type %s.' % ( object.type ) - exec 'object.%s( self )' % ( self.activity ) # Calls the methode of an world object which # modify a character attribute. - self.activityTimer -= 1 - - else: - print 'Object found to interact with but is not in range (%s). Object id is %i/%i.' % ( radiusType, self.activityInteractive, object.id ) - self.goTo( object.pos[0], object.pos[1], object.pos[2] ) - self.move() - if( objectFound == False ): # Object not found in the world's object list. - print 'Object not found to interact. Object id is %s/%i.' % ( self.activityInteractive, object.id ) - self.activity = None - self.activityTimer = 0 - self.activityInteractive = None - else: # Character is free for a new activity. - print 'Character is thinking about the next activity. Timer is zero.' - # Getting the lowest need - lowestNeedName = '' - lowestNeedValue = 1000 - for needName in self.needs.keys(): - if( self.needs.get( needName ) < lowestNeedValue ): - lowestNeedName = needName - lowestNeedValue = self.needs.get( needName ) - - print '\033[32mInfo\033[0m Lowest need: %s (%i)' % ( lowestNeedName, lowestNeedValue ) - - # Searching for an character or object to raise the need - # if( lowestNeedName == 'fun' or lowestNeedName == 'social' ): - # for character in self.world.characters: - # self.needs[lowestNeedName] = 1000 - # # if( character. ): - if( lowestNeedName == 'sleep' ): - if( lowestNeedValue < 833.333333333 ): # The sleep need is not below the minimal limit. - for object in self.world.objects: # Search for the object to interact with. - if( object.type == 'Bed' ): # Object of type bed found in the wolrd's object list. - if( lowestNeedValue > 208.333333333 ): # The sleep need is not below the critcal limit. - self.activity = 'rest' - self.activityTimer = 900 # 15 game minutes - self.activityInteractive = object.id - else: # The sleep need is below the critcal limit. - self.activity = 'sleep' - self.activityTimer = 28800 # 8 game hours - self.activityInteractive = object.id - if( self.isInRange( object, 'On' ) == False ): - self.goTo( object.pos[0], object.pos[1], object.pos[2] ) - self.move() - else: # The lowest need is not below the minimal limit. - self.activity = 'beHappy' # Reset the activity to a standard beHappy activity. - self.activityTimer = 1 # Reset the timer to 1. - self.activityInteractive = None # Reset the interactive to None. - elif( lowestNeedName == 'food' ): - if( lowestNeedValue < 833.333333333 ): # The food need is not below the minimal limit. - for object in self.world.objects: # Search for the object to interact with. - if( object.type == 'Refrigerator' ): # Object of type refrigerator found in the wolrd's object list. - if( lowestNeedValue > 833.333333333 ): # The food need is not below the critcal limit. - self.activity = 'eatSnack' - self.activityTimer = 300 # 5 game minutes. - self.activityInteractive = object.id - if( self.isInRange( object, 'NextTo' ) == False ): - self.goTo( object.pos[0], object.pos[1], object.pos[2] ) - self.move() - elif( object.type == 'Cooker' ): # Object of type cooker found in the wolrd's object list. - if( lowestNeedValue > 0 ): # The food need is below the critcal limit. - self.activity = 'cook' - self.activityTimer = 900 # 15 game minutes. - self.activityInteractive = object.id - if( self.isInRange( object, 'NextTo' ) == False ): - self.goTo( object.pos[0], object.pos[1], object.pos[2] ) - self.move() - else: # The lowest need is not below the minimal limit. - self.activity = 'beHappy' # Reset the activity to a standard beHappy activity. - self.activityTimer = 1 # Reset the timer to 1. - self.activityInteractive = None # Reset the interactive to None. - elif( lowestNeedName == 'water' ): - if( lowestNeedValue < 833.333333333 ): # The water need is not below the minimal limit. - for object in self.world.objects: - if( object.type == 'Refrigerator' ): - self.activity = 'drink' - self.activityTimer = 60 # 1 game minute. - self.activityInteractive = object.id - if( self.isInRange( object, 'NextTo' ) == False ): - self.goTo( object.pos[0], object.pos[1], object.pos[2] ) - self.move() - else: # The lowest need is not below the minimal limit. - self.activity = 'beHappy' # Reset the activity to a standard beHappy activity. - self.activityTimer = 1 # Reset the timer to 1. - self.activityInteractive = None # Reset the interactive to None. - elif( lowestNeedName == 'hygiene' ): - if( lowestNeedValue < 833.333333333 ): # The hygiene need is not below the minimal limit. - for object in self.world.objects: - if( object.type == 'Shower' ): - self.activity = 'shower' - self.activityTimer = 1800 # 30 game minutes. - self.activityInteractive = object.id - if( self.isInRange( object, 'On' ) == False ): - self.goTo( object.pos[0], object.pos[1], object.pos[2] ) - self.move() - else: # The lowest need is not below the minimal limit. - self.activity = 'beHappy' # Reset the activity to a standard beHappy activity. - self.activityTimer = 1 # Reset the timer to 1. - self.activityInteractive = None # Reset the interactive to None. - elif( lowestNeedName == 'fun' ): - if( lowestNeedValue < 833.333333333 ): - for object in self.world.objects: - if( object.type == 'TvSet' ): - self.activity = 'watch' - self.activityTimer = 1800 # 30 game minutes. - self.activityInteractive = object.id - if( self.isInRange( object, 'On' ) == False ): - # If the character is not in range set the new destination and move to it. - self.goTo( object.pos[0], object.pos[1], object.pos[2] ) - self.move() - else: # The lowest need is not below the minimal limit. - self.activity = 'beHappy' # Reset the activity to a standard beHappy activity. - self.activityTimer = 1 # Reset the timer to 1. - self.activityInteractive = None # Reset the interactive to None. - else: # There is no lowest need. Should never happen. - self.activity = 'beHappy' # Reset the activity to a standard beHappy activity. - self.activityTimer = 1 # Reset the timer to 1. - self.activityInteractive = None # Reset the interactive to None. + if( self.brain.activityTimer > 0 ): + try: + if( self.brain.isInRange( self.brain.activityInteractive, self.brain.activity ) ): + # print '\033[32mInfo\033[0m Character %i: Character or object with id %i is in range.' % ( self.id, self.brain.activityInteractive.id ) + # print '\033[32mInfo\033[0m Character %i interacts with the object of type %s.' % ( self.id, self.brain.activityInteractive.type ) + exec 'self.brain.activityInteractive.%s( self )' % ( self.brain.activity ) # modify a character attribute. + self.brain.activityTimer -= 1 + else: + # print '\033[32mInfo\033[0m Character %i: Character or object with id %i is in range.' % ( self.id, self.brain.activityInteractive.id ) + self.goTo( self.brain.activityInteractive.pos[0], self.brain.activityInteractive.pos[1], self.brain.activityInteractive.pos[2] ) + self.move() + except: + print '\033[31mError\033[0m Character %i: Interactive does not exist.' % ( self.id ) + else: + self.brain.getNextActivity() + + def talk( self, opposite): + # The opposite talks to this character. + # print 'DEBUG: %s.%s is called.' % ( __name__, dir( self ) ) + opposite.increaseNeed( 'social', 0.277777778 ) diff --git a/gameEngine/World.py b/gameEngine/World.py index b0dcc89..17aa3e7 100644 --- a/gameEngine/World.py +++ b/gameEngine/World.py @@ -25,12 +25,12 @@ from objects.Bed import Bed from objects.Cooker import Cooker from objects.Refrigerator import Refrigerator +from objects.Toilet import Toilet from objects.Shower import Shower +from objects.TvSet import TvSet class World: def __init__( self, amountOfCharacters ): - - # Basic infrastructure self.configParser = ConfigParser() @@ -55,7 +55,7 @@ def __init__( self, amountOfCharacters ): self.ticksPerSecond = self.configParser.get( 'time', 'ticksPerSecond' ) # Ticks per second self.gameSecondsPerTick = self.configParser.get( 'time', 'gameSecondsPerTick' ) # The amount of game seconds passing each tick else: - self.ticksPerSecond = 1 + self.ticksPerSecond = 1.50 self.gameSecondsPerTick = 1 # Physics data @@ -75,7 +75,9 @@ def __init__( self, amountOfCharacters ): self.objects.insert( 0, Bed( 0, -7, -7, 0 ) ) self.objects.insert( 1, Cooker( 1, 1, 1, 0 ) ) self.objects.insert( 2, Refrigerator( 2, 5, 5, 0 ) ) - self.objects.insert( 3, Shower( 3, 7, 3, 0 ) ) + self.objects.insert( 3, Toilet( 3, 10, 10, 0 ) ) + self.objects.insert( 4, Shower( 4, 7, 3, 0 ) ) + self.objects.insert( 5, TvSet( 5, 10, -2, 0 ) ) def processTime( self ): # Process the game time. @@ -134,12 +136,16 @@ def run( self ): # self.processGravity() print '\033[32mInfo\033[0m World\tGame date: %i-%i-%i\tGame time: %i:%i:%i' % ( self.gameYear, self.gameMonth, self.gameDay, self.gameHour, self.gameMinute, self.gameSecond ) for character in self.characters: - print '\033[32mInfo\033[0m Character %i, %s' % ( character.id, character.gender ) - print '\033[32mInfo\033[0m Pos: %i %i %i\tDestination: %i %i %i' % ( character.pos[0], character.pos[1], character.pos[2], character.destination[0], character.destination[1], character.destination[2] ) - print '\033[32mInfo\033[0m Sleep: %i\t\tFood: %i\tWater: %i' % ( character.needs['sleep'], character.needs['food'], character.needs['water'] ) - print '\033[32mInfo\033[0m Hygiene: %i\tFun: %i\tSocial: %i' % ( character.needs['hygiene'], character.needs['fun'], character.needs['social'] ) - print '\033[32mInfo\033[0m Activity: %s (%i game seconds left)' % ( character.activity, character.activityTimer ) character.decreaseNeeds() character.processActivity() + print '\033[32mInfo\033[0m Character %i, %s:' % ( character.id, character.gender ) + print '\033[32mInfo\033[0m Pos: %i %i %i\tDestination: %i %i %i' % ( character.pos[ 0 ], character.pos[ 1 ], character.pos[ 2 ], character.destination[ 0 ], character.destination[ 1 ], character.destination[ 2 ] ) + print '\033[32mInfo\033[0m Sleep: %i\tFood: %i\tWater: %i\tUrination: %i' % ( character.needs[ 'sleep' ], character.needs[ 'food' ], character.needs[ 'water' ], character.needs[ 'urination' ] ) + print '\033[32mInfo\033[0m Hygiene: %i\tFun: %i\tSocial: %i' % ( character.needs[ 'hygiene' ], character.needs[ 'fun' ], character.needs[ 'social' ] ) + print '\033[32mInfo\033[0m Activity: %s (%i game seconds left)' % ( character.brain.activity, character.brain.activityTimer ) + try: + print '\033[32mInfo\033[0m Interactive: %i\tType: %s' % ( character.brain.activityInteractive.id, character.brain.activityInteractiveTypes[ character.brain.activity ] ) + except: + print '\033[31mError\033[0m Character %i: Interactive does not exist.' % ( character.id ) sleep( 1 / self.ticksPerSecond ) diff --git a/objects/Bed.py b/objects/Bed.py index 73de612..6b8c95e 100644 --- a/objects/Bed.py +++ b/objects/Bed.py @@ -22,14 +22,16 @@ def __init__( self, id, x, y, z ): self.id = id self.type = 'Bed' self.pos = [ x, y, z ] + self.radii = { 'rest': 0, + 'sleep': 0 } self.isInUse = False def rest( self, user ): # The user rests on the bed. - print 'DEBUG: %s.%s is called.' % ( __name__, dir( self ) ) + # print 'DEBUG: %s.%s is called.' % ( __name__, dir( self ) ) user.increaseNeed( 'sleep', 0.008680555 ) def sleep( self, user ): # The user sleeps on the bed. - print 'DEBUG: %s.%s is called.' % ( __name__, dir( self ) ) + # print 'DEBUG: %s.%s is called.' % ( __name__, dir( self ) ) user.increaseNeed( 'sleep', 0.034722222 ) diff --git a/objects/Cooker.py b/objects/Cooker.py index b151e06..25a6d45 100644 --- a/objects/Cooker.py +++ b/objects/Cooker.py @@ -22,9 +22,10 @@ def __init__( self, id, x, y, z ): self.id = id self.type = 'Cooker' self.pos = [ x, y, z ] + self.radii = { 'cook': 1 } self.isInUse = False def cook( self, user ): # The user cooks on the cooker and eats. - print 'DEBUG: %s.%s is called.' % ( __name__, dir( self ) ) + # print 'DEBUG: %s.%s is called.' % ( __name__, dir( self ) ) user.increaseNeed( 'food', 0.37037037 ) diff --git a/objects/Refrigerator.py b/objects/Refrigerator.py index c61e522..7f3dd4b 100644 --- a/objects/Refrigerator.py +++ b/objects/Refrigerator.py @@ -22,14 +22,16 @@ def __init__( self, id, x, y, z ): self.id = id self.type = 'Refrigerator' self.pos = [ x, y, z ] + self.radii = { 'drink': 1, + 'eatSnack': 1 } self.isInUse = False def drink( self, user ): # The user drinks somthing. - print 'DEBUG: %s.%s is called.' % ( __name__, dir( self ) ) + # print 'DEBUG: %s.%s is called.' % ( __name__, dir( self ) ) user.increaseNeed( 'water', 1.388888889 ) def eatSnack( self, user ): # The user eats a snack. - print 'DEBUG: %s.%s is called.' % ( __name__, dir( self ) ) + # print 'DEBUG: %s.%s is called.' % ( __name__, dir( self ) ) user.increaseNeed( 'food', 0.555555556 ) diff --git a/objects/Shower.py b/objects/Shower.py index cf7f20a..6558b1c 100644 --- a/objects/Shower.py +++ b/objects/Shower.py @@ -22,9 +22,10 @@ def __init__( self, id, x, y, z ): self.id = id self.type = 'Shower' self.pos = [ x, y, z ] + self.radii = { 'shower': 0 } self.isInUse = False def shower( self, user ): # The user takes a shower. - print 'DEBUG: %s.%s is called.' % ( __name__, dir( self ) ) + # print 'DEBUG: %s.%s is called.' % ( __name__, dir( self ) ) user.increaseNeed( 'hygiene', 0.555555556 ) diff --git a/objects/Toilet.py b/objects/Toilet.py new file mode 100644 index 0000000..15e2896 --- /dev/null +++ b/objects/Toilet.py @@ -0,0 +1,31 @@ +#!/usr/bin/python +#*** encoding:utf-8 *** + +# This file is part of La Vida +# Copyright (C) 2011 Florian R. A. Angermeier +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. + +import gameEngine +from gameEngine.Object import Object + +class Toilet( Object ): + def __init__( self, id, x, y, z ): + self.id = id + self.type = 'Toilet' + self.pos = [ x, y, z ] + self.radii = { 'use': 0 } + self.isInUse = False + + def use( self, user ): + # The user uses the toilet. + # print 'DEBUG: %s.%s is called.' % ( __name__, dir( self ) ) + user.increaseNeed( 'urination', 2.222222222 ) diff --git a/objects/TvSet.py b/objects/TvSet.py index dbd26c5..d7b998f 100644 --- a/objects/TvSet.py +++ b/objects/TvSet.py @@ -22,9 +22,10 @@ def __init__( self, id, x, y, z ): self.id = id self.type = 'TvSet' self.pos = [ x, y, z ] + self.radii = { 'watch': 2 } self.isInUse = False def watch( self, user ): # The user watches TV. - print 'DEBUG: %s.%s is called.' % ( __name__, dir( self ) ) - user.increaseNeed( 'hygiene', 0.555555556 ) + # print 'DEBUG: %s.%s is called.' % ( __name__, dir( self ) ) + user.increaseNeed( 'fun', 0.555555556 )