Beispiel #1
0
 def injectCharacters(self,investors):
    
    #print investors
    for investor in investors:
       
       # create character for the map
       char = Character()
       spawnPos = choice(self.spawnPositions) #random spawnign position
       char.x = spawnPos[0]
       char.y = spawnPos[1]
       char.setType(self.mapPlayerToSprite(investor.sprite))
       char.setName(investor.name)
       
       if investor.type == 'player':
          char.x = self.mainSpawnPos[0]
          char.y = self.mainSpawnPos[1]
          self.mainChar = char
          
       self.characters.append(char)
    
    # when creating the map, insert all the current total capital
    # to the characters, this is needed before the model thread
    # gets access to the characters
    for ch in self.characters:
       
       from gamemodels.models           import Investor
       from logic.portfolioManipulation import calcCurrentPortfolioWorth
       
       inv           = Investor.objects.get(name=ch.name)
       investorStock = calcCurrentPortfolioWorth(inv)
       totalCapital  = investorStock + inv.cash
    
       ch.setTempTotalCapital(totalCapital)
Beispiel #2
0
 def injectMainCharacter(self,investor):
    char = Character()
    char.x = 13*32+16
    char.y = 17*32+16
    char.startpoint = (3,10)
    char.setType(self.mapPlayerToSprite(investor.sprite))
    char.setName(investor.name)
    self.characters.append(char)
    self.mainChar = char
    
    # when creating the map, insert the current total
    # capital to the character this is needed before 
    # the model thread gets access to the characters
    from gamemodels.models           import Investor
    from logic.portfolioManipulation import calcCurrentPortfolioWorth
       
    inv           = Investor.objects.get(name=char.name)
    investorStock = calcCurrentPortfolioWorth(inv)
    totalCapital  = investorStock + inv.cash
    
    char.setTempTotalCapital(totalCapital)