Example #1
0
 def useItem(self, item, game, battle=False):
     if item == None:
         return 0
     if hasattr(item, "__iter__"):
         item = item[0]
     if item.getType() in const.GAMEITEMS:
         game.textMessage(item.execute(self))
         game.Ticker.tick(60)
         return
     if item.getType() == const.CERTIFICATE:
         if item.certNum == const.SAVECERT:
             if game.saveGame("ransack0.sav"):
                 game.textMessage("Game Saved")
             else:
                 game.textMessage("File Error o_O")
         elif item.certNum == const.RETURNCERT:
             game.portalMove(*item.loc)
         self.takeItem(item)
         return
     if item.getName() == "parchment":
         mySpell = spell.Spell(item.spellNum)
         d = self.castSpell(mySpell, game, battle, True)
         if d != False:
             self.takeItem(item)
             game.Ticker.tick(mySpell.cost)
         return d
     item.execute(self)
     self.takeItem(item)
     if item.type in itemScr.foodItems:
         self.hunger = max(0, self.hunger - itemScr.foodValue[item.type])
     game.Ticker.tick(60)
Example #2
0
 def useItem(self, item, game, battle=False):
     if item == None:
         return 0
     if hasattr(item, "__iter__"):
         item = item[0]
     if item.getType() in const.GAMEITEMS:
         game.textMessage(item.execute(self))
         game.Ticker.tick(60)
         return
     if item.getType() == const.CERTIFICATE:
         if item.certNum == const.SAVECERT:
             if game.saveGame('ransack0.sav'):
                 game.textMessage('Game Saved')
             else:
                 game.textMessage('File Error o_O')
         elif item.certNum == const.RETURNCERT:
             game.portalMove(*item.loc)
         self.takeItem(item)
         return
     if item.getName() == 'parchment':
         mySpell = spell.Spell(item.spellNum)
         d = self.castSpell(mySpell, game, battle, True)
         if d != False:
             self.takeItem(item)
             game.Ticker.tick(mySpell.cost)
         return d
     item.execute(self)
     self.takeItem(item)
     if item.type in itemScr.foodItems:
         self.hunger = max(0, self.hunger - itemScr.foodValue[item.type])
     game.Ticker.tick(60)
Example #3
0
 def getDescText(self, item, font, size, form="single"):
     if hasattr(item, "__iter__"):
         item = item[0]
     if item.getName() in ["item", "spell", "certificate", "gameitem"]:
         return text.Text(item.getDesc(), font, size, colors.white, colors.gold, False, 36)
     elif item.getName() == "spellbook" or item.getName() == "parchment":
         return text.Text(item.getDesc(), font, size, colors.white, colors.gold, False, 36)
     elif item.getName() == "armor" or item.getName() == "weapon":
         dT = text.Text(item.getDesc(), font, size, colors.white, colors.gold, False, 36)
         sT = text.Text(item.getStats(), font, int(ceil(size * 0.75)), colors.white, colors.gold, False, 36)
         if form == "single":
             wT = pygame.Surface((int(ceil(dT.get_width() * 1.1)) + sT.get_width(), dT.get_height()))
             wT.fill(colors.gold)
             wT.blit(dT, (0, 0))
             wT.blit(sT, (int(ceil(dT.get_width() * 1.1)), (wT.get_height() / 2) - (sT.get_height() / 2)))
         elif form == "double":
             wT = pygame.Surface((max(dT.get_width(), sT.get_width()), dT.get_height() + sT.get_height()))
             wT.fill(colors.gold)
             wT.blit(dT, (0, 0))
             wT.blit(sT, (0, dT.get_height()))
         return wT