예제 #1
0
 def die(self):
     self.species = Species.dead
     self.energy = 0
     self.visible = True
     self.last_login = timezone.now() 
     self.img_number = randint(1, returnCount('dead')/2)
     self.save()
def bannerSelect(current):
    """Returns a randomly selected banner image from collection of banners.
    Used in bruce_banner block."""
    bannerCount = returnCount('banners')
    selection = randint(1, bannerCount)
    while selection == current:
        selection = randint(1, bannerCount)
    return selection
def bgSelect(current):
    """Returns next background image from collection of backgrounds.
    Used in background-style.html."""
    bgCount = returnCount('backgrounds')
    if current > bgCount:
        return randint(1, bgCount)
    selection = current + 1
    if selection > bgCount:
        selection = 1
    return selection
def assignImages(profile):
    """Selects and assigns a random image number to Profile object based on species type."""
    imgCount = returnCount(profile.speciesReadable)
    profile.img_number = randint(1, imgCount/2)
    profile.save()