Beispiel #1
0
    def completeRecipe(self, recipe, flag):
        if self.air.getAvatarIdFromSender() != self.avId:
            return

        if self.__workingRecipe == -1:
            if not self.recipes.get(recipe):
                msg = 'recipe invalid: %d; self.recipes = %r' % (recipe, self.recipes)
                # self.writeServerEvent('suspicious', self.avId, msg) - first of all, self.writeServerEvent returns an AttributeError, second of all this will happen even when not cheating due to the potion game being f****d and having things stuck in the air
                self.notify.warning(msg)
                return

            self.__workingRecipe = recipe

        elif recipe != self.__workingRecipe:
            msg = 'tried to complete recipe they are not working on: %d (%d)' % (recipe, self.__workingRecipe)
            # self.writeServerEvent('suspicious', self.avId, msg)
            self.notify.warning(msg)
            return

        self.__numIngredientsDone += 1
        if self.__numIngredientsDone >= self.recipes[recipe]:
            print 'recipe done', recipe
            self.air.writeServerEvent('recipe-done', self.avId, recipe)
            self.av.inventory.addReputation(InventoryType.PotionsRep, PotionGlobals.getPotionBuffXP(recipe))
            self.reset()

        self.av.inventory.addReputation(InventoryType.PotionsRep, 25)
    def completeRecipe(self, recipe, flag):
        if self.air.getAvatarIdFromSender() != self.avId:
            return

        if self.__workingRecipe == -1:
            if not self.recipes.get(recipe):
                msg = "recipe invalid: %d; self.recipes = %r" % (recipe, self.recipes)
                # self.writeServerEvent('suspicious', self.avId, msg) - first of all, self.writeServerEvent returns an AttributeError, second of all this will happen even when not cheating due to the potion game being f****d and having things stuck in the air
                self.notify.warning(msg)
                return

            self.__workingRecipe = recipe

        elif recipe != self.__workingRecipe:
            msg = "tried to complete recipe they are not working on: %d (%d)" % (recipe, self.__workingRecipe)
            # self.writeServerEvent('suspicious', self.avId, msg)
            self.notify.warning(msg)
            return

        self.__numIngredientsDone += 1
        if self.__numIngredientsDone >= self.recipes[recipe]:
            print "recipe done", recipe
            self.air.writeServerEvent("recipe-done", self.avId, recipe)
            self.av.inventory.addReputation(InventoryType.PotionsRep, PotionGlobals.getPotionBuffXP(recipe))
            self.reset()

        self.av.inventory.addReputation(InventoryType.PotionsRep, 25)
    def selectRecipe(self, recipe):
        if self.gameFSM.state != 'RecipeSelect':
            return

        itemId = PotionGlobals.potionBuffIdToInventoryTypeId(recipe.potionID)
        inv = localAvatar.getInventory()
        if not inv:
            return

        quantity = inv.getItemQuantity(InventoryType.ItemTypeConsumable,
                                       itemId)
        limit = inv.getItemLimit(InventoryType.ItemTypeConsumable, itemId)
        if quantity >= limit:
            self.cleanUpConfirm()
            self.confirm = PiratesConfirm.PiratesConfirm(
                PLocalizer.PotionGui['MaxedOutTitle'],
                PLocalizer.PotionGui['MaxedOutText'], self.onSelectConfirmed)
            self.confirm.setPos(0.35, 0, -0.17)
            self.confirm.bOk['command'] = self.onSelectConfirmed
            self.confirm.bOk['extraArgs'] = [recipe]
            self.confirm.bNo['command'] = self.onSelectDeclined
            self.closeCurrentDialog = self.cleanUpConfirm
            self.gameBoard.disableInputEvents()
            self.disableButtons()
        else:
            self.gameFSM.request('StartGame', recipe)
Beispiel #4
0
    def getPlayerNotNewFlags(self):
        madeList = []
        inv = localAvatar.getInventory()
        for madeID in InventoryType.HaveMadeList:
            if inv.getStackQuantity(madeID) > 0:
                potionID = PotionGlobals.getPotionForHaveMadeID(madeID)
                if potionID > 0:
                    madeList.append(potionID)

        return madeList
 def getPlayerNotNewFlags(self):
     madeList = []
     inv = localAvatar.getInventory()
     for madeID in InventoryType.HaveMadeList:
         if inv.getStackQuantity(madeID) > 0:
             potionID = PotionGlobals.getPotionForHaveMadeID(madeID)
             if potionID > 0:
                 madeList.append(potionID)
             
         potionID > 0
     
     return madeList
Beispiel #6
0
 def showIngredientXP(self, ingredient):
     if not self.currentRecipe.complete:
         xpAmt = PotionGlobals.getPotionBuffXP(self.currentRecipe.potionID)
         if len(self.currentRecipe.ingredients) > 1:
             xpAmt = int(math.ceil(float(xpAmt) / 2.0 * float(len(self.currentRecipe.ingredients) - 1)))
         
         xpLabel = DirectLabel(parent = aspect2d, relief = None, text = '+ ' + str(xpAmt) + ' ' + PLocalizer.PotionGui['XPLabel'], text_scale = PiratesGuiGlobals.TextScaleTitleMed, text_font = PiratesGlobals.getPirateOutlineFont(), text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 37, pos = (ingredient.getX(aspect2d) + 0.10000000000000001, 0, ingredient.getZ(aspect2d) - 0.050000000000000003), textMayChange = 0)
         xpLabel.setTransparency(True)
         xpLabel.stash()
         return Sequence(Func(xpLabel.unstash), Parallel(LerpPosInterval(xpLabel, duration = 1.5, pos = (ingredient.getX(aspect2d) + 0.10000000000000001, 0.0, ingredient.getZ(aspect2d) + 0.10000000000000001), blendType = 'easeOut'), LerpColorScaleInterval(xpLabel, duration = 1.5, colorScale = (1, 1, 1, 0), blendType = 'easeIn')), Func(xpLabel.removeNode))
     else:
         return Wait(0.10000000000000001)
Beispiel #7
0
 def showIngredientXP(self, ingredient):
     if not self.currentRecipe.complete:
         xpAmt = PotionGlobals.getPotionBuffXP(self.currentRecipe.potionID)
         if len(self.currentRecipe.ingredients) > 1:
             xpAmt = int(math.ceil(float(xpAmt) / 2.0 * float(len(self.currentRecipe.ingredients) - 1)))
         
         xpLabel = DirectLabel(parent = aspect2d, relief = None, text = '+ ' + str(xpAmt) + ' ' + PLocalizer.PotionGui['XPLabel'], text_scale = PiratesGuiGlobals.TextScaleTitleMed, text_font = PiratesGlobals.getPirateOutlineFont(), text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG1, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 37, pos = (ingredient.getX(aspect2d) + 0.10000000000000001, 0, ingredient.getZ(aspect2d) - 0.050000000000000003), textMayChange = 0)
         xpLabel.setTransparency(True)
         xpLabel.stash()
         return Sequence(Func(xpLabel.unstash), Parallel(LerpPosInterval(xpLabel, duration = 1.5, pos = (ingredient.getX(aspect2d) + 0.10000000000000001, 0.0, ingredient.getZ(aspect2d) + 0.10000000000000001), blendType = 'easeOut'), LerpColorScaleInterval(xpLabel, duration = 1.5, colorScale = (1, 1, 1, 0), blendType = 'easeIn')), Func(xpLabel.removeNode))
     else:
         return Wait(0.10000000000000001)
 def show(self):
     if self.potionName is not None:
         self.potionName.removeNode()
     
     if self.potionDesc is not None:
         self.potionDesc.removeNode()
     
     if self.potionXp is not None:
         self.potionXp.removeNode()
     
     if self.potionImg is not None:
         self.potionImg.removeNode()
     
     self.potionName = DirectLabel(parent = self, relief = None, text = self.potionGame.currentRecipe.name, text_scale = PiratesGuiGlobals.TextScaleTitleMed, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 17, pos = (0.75, 0, 0.65000000000000002), textMayChange = 0)
     self.potionDesc = DirectLabel(parent = self, relief = None, text = self.potionGame.currentRecipe.desc, text_scale = PiratesGuiGlobals.TextScaleExtraLarge, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 34, pos = (0.75, 0, 0.22), textMayChange = 0)
     xpAmt = PotionGlobals.getPotionBuffXP(self.potionGame.currentRecipe.potionID)
     xpAmt = int(math.ceil(float(xpAmt) / 2.0))
     xpBonus = self.potionGame.dist.getXpBonus()
     labelTxt = '+ ' + str(xpAmt) + ' ' + PLocalizer.PotionGui['XPLabel']
     if xpBonus:
         xpAmt = xpAmt + xpBonus
         labelTxt = PLocalizer.PotionGui['XPLabelBonus'] % (str(xpAmt), str(xpBonus))
     
     self.potionXp = DirectLabel(parent = self, relief = None, text = labelTxt, text_scale = PiratesGuiGlobals.TextScaleTitleSmall, text_align = TextNode.ACenter, text_fg = PiratesGuiGlobals.TextFG2, text_shadow = PiratesGuiGlobals.TextShadow, text_wordwrap = 17, pos = (0.75, 0, 0.28999999999999998), textMayChange = 0)
     asset = ItemGlobals.getIcon(PotionGlobals.potionBuffIdToInventoryTypeId(self.potionGame.currentRecipe.potionID))
     skillIcons = loader.loadModel('models/textureCards/skillIcons')
     geom = skillIcons.find('**/%s' % asset)
     if geom.isEmpty():
         geom = skillIcons.find('**/base')
     
     geom_scale = 0.23999999999999999
     self.potionImg = DirectFrame(parent = self, geom = geom, geom_scale = geom_scale, pos = (0.75, 0, 0.5), image = None, relief = None)
     self.unstash()
     self.potionGame.closeCurrentDialog = self.cleanUp
     self.potionGame.disableButtons()
     skillIcons.removeNode()
Beispiel #9
0
 def selectRecipe(self, recipe):
     if self.gameFSM.state != 'RecipeSelect':
         return None
     
     itemId = PotionGlobals.potionBuffIdToInventoryTypeId(recipe.potionID)
     inv = localAvatar.getInventory()
     if not inv:
         return None
     
     quantity = inv.getItemQuantity(InventoryType.ItemTypeConsumable, itemId)
     limit = inv.getItemLimit(InventoryType.ItemTypeConsumable, itemId)
     if quantity >= limit:
         self.cleanUpConfirm()
         self.confirm = PiratesConfirm.PiratesConfirm(PLocalizer.PotionGui['MaxedOutTitle'], PLocalizer.PotionGui['MaxedOutText'], self.onSelectConfirmed)
         self.confirm.setPos(0.34999999999999998, 0, -0.17000000000000001)
         self.confirm.bOk['command'] = self.onSelectConfirmed
         self.confirm.bOk['extraArgs'] = [
             recipe]
         self.confirm.bNo['command'] = self.onSelectDeclined
         self.closeCurrentDialog = self.cleanUpConfirm
         self.gameBoard.disableInputEvents()
         self.disableButtons()
     else:
         self.gameFSM.request('StartGame', recipe)
Beispiel #10
0
    def show(self):
        if self.potionName is not None:
            self.potionName.removeNode()

        if self.potionDesc is not None:
            self.potionDesc.removeNode()

        if self.potionXp is not None:
            self.potionXp.removeNode()

        if self.potionImg is not None:
            self.potionImg.removeNode()

        self.potionName = DirectLabel(
            parent=self,
            relief=None,
            text=self.potionGame.currentRecipe.name,
            text_scale=PiratesGuiGlobals.TextScaleTitleMed,
            text_align=TextNode.ACenter,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_wordwrap=17,
            pos=(0.75, 0, 0.65000000000000002),
            textMayChange=0)
        self.potionDesc = DirectLabel(
            parent=self,
            relief=None,
            text=self.potionGame.currentRecipe.desc,
            text_scale=PiratesGuiGlobals.TextScaleExtraLarge,
            text_align=TextNode.ACenter,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_wordwrap=34,
            pos=(0.75, 0, 0.22),
            textMayChange=0)
        xpAmt = PotionGlobals.getPotionBuffXP(
            self.potionGame.currentRecipe.potionID)
        xpAmt = int(math.ceil(float(xpAmt) / 2.0))
        xpBonus = self.potionGame.dist.getXpBonus()
        labelTxt = '+ ' + str(xpAmt) + ' ' + PLocalizer.PotionGui['XPLabel']
        if xpBonus:
            xpAmt = xpAmt + xpBonus
            labelTxt = PLocalizer.PotionGui['XPLabelBonus'] % (str(xpAmt),
                                                               str(xpBonus))

        self.potionXp = DirectLabel(
            parent=self,
            relief=None,
            text=labelTxt,
            text_scale=PiratesGuiGlobals.TextScaleTitleSmall,
            text_align=TextNode.ACenter,
            text_fg=PiratesGuiGlobals.TextFG2,
            text_shadow=PiratesGuiGlobals.TextShadow,
            text_wordwrap=17,
            pos=(0.75, 0, 0.28999999999999998),
            textMayChange=0)
        asset = ItemGlobals.getIcon(
            PotionGlobals.potionBuffIdToInventoryTypeId(
                self.potionGame.currentRecipe.potionID))
        skillIcons = loader.loadModel('models/textureCards/skillIcons')
        geom = skillIcons.find('**/%s' % asset)
        if geom.isEmpty():
            geom = skillIcons.find('**/base')

        geom_scale = 0.23999999999999999
        self.potionImg = DirectFrame(parent=self,
                                     geom=geom,
                                     geom_scale=geom_scale,
                                     pos=(0.75, 0, 0.5),
                                     image=None,
                                     relief=None)
        self.unstash()
        self.potionGame.closeCurrentDialog = self.cleanUp
        self.potionGame.disableButtons()
        skillIcons.removeNode()
    def updateList(self):
        self.recipeList.removeAndDestroyAllItems()
        self.buttons = []
        self.inactiveButtons = []
        playerLevel = self.potionGame.dist.getPlayerPotionLevel()
        notNew_list = self.potionGame.dist.getPlayerNotNewFlags()
        for recipe in self.potionGame.recipes:
            if playerLevel >= recipe.level:
                recipe.enabled = True
            else:
                recipe.enabled = False
            if recipe.enabled:
                recipe.haveMade = recipe.potionID not in notNew_list and False
            else:
                recipe.haveMade = True

        self.potionGame.recipes.sort()
        for recipe in self.potionGame.recipes:
            if recipe.questOnly:
                if localAvatar.getInventory():

                    class brewable(Exception):
                        __module__ = __name__

                    try:
                        for currQuest in localAvatar.getInventory(
                        ).getQuestList():
                            bonusComplete = currQuest.isComplete(bonus=True)
                            primaryComplete = currQuest.isComplete()
                            if not bonusComplete or not primaryComplete:
                                tasks = currQuest.getQuestDNA().getTaskDNAs()
                                for currTask in tasks:
                                    if isinstance(currTask, PotionsTaskDNA):
                                        raise (PotionGlobals.getPotionItemID(
                                            recipe.potionID)
                                               == currTask.potionType
                                               and not primaryComplete or
                                               PotionGlobals.getPotionItemID(
                                                   recipe.potionID)
                                               == currTask.potionTypeBonus and
                                               not bonusComplete) and brewable

                    except brewable:
                        pass
                    else:
                        continue
                if recipe.level - playerLevel > 3:
                    if not recipe.questOnly:
                        continue
                    buttonImage = None
                    recipe.loadIngredients()
                    buttonImageScale = 0.0
                    text = recipe.name
                    helptext = recipe.desc
                    if not recipe.haveMade:
                        if len(recipe.ingredients) > 0:
                            iconText = recipe.questOnly and PLocalizer.PotionGui[
                                'QuestLabel']
                            iconTextColor = PiratesGuiGlobals.TextFG13
                        else:
                            iconText = PLocalizer.PotionGui['NewLabel']
                            iconTextColor = PiratesGuiGlobals.TextFG1
                        guiAssets = loader.loadModel(
                            'models/minigames/pir_m_gui_pot_textureCard')
                        buttonImage = guiAssets.find(
                            '**/pir_t_gui_pot_seal').copyTo(NodePath())
                        buttonImageScale = 0.08
                        buttonText = DirectLabel(
                            parent=buttonImage,
                            relief=None,
                            text=iconText,
                            text_scale=PiratesGuiGlobals.TextScaleLarge /
                            buttonImageScale,
                            text_font=PiratesGlobals.getPirateOutlineFont(),
                            text_align=TextNode.ACenter,
                            text_fg=iconTextColor,
                            text_shadow=PiratesGuiGlobals.TextFG14,
                            hpr=(0, 0, 20),
                            pos=(-0.25, 0, 0),
                            textMayChange=0)
                        guiAssets.removeNode()
                    cmd = ((Freebooter.getPaidStatus(localAvatar.doId)
                            or recipe.isFree) and self).potionGame.selectRecipe
                    buttonGeom = None
                    buttonGeomScale = 1
                    buttonGeomPos = (0, 0, 0)
                    args = None
                else:
                    gui = loader.loadModel('models/gui/toplevel_gui')
                    buttonGeom = gui.find('**/pir_t_gui_gen_key_subscriber')
                    buttonGeomScale = 0.16
                    buttonGeomPos = (-0.05, 0, 0.01)
                    cmd = base.localAvatar.guiMgr.showNonPayer
                    args = ['Restricted_Potion_Crafting_Recipe', 9]
                    gui.removeNode()
                button = recipe.enabled and recipe.available and GuiButton.GuiButton(
                    text=(text, text, text, text),
                    canReposition=True,
                    text_wordwrap=0,
                    image_scale=buttonImageScale,
                    image_pos=(-0.04, 0.0, 0.01),
                    image=(buttonImage, buttonImage, buttonImage, buttonImage),
                    geom=buttonGeom,
                    geom_scale=buttonGeomScale,
                    geom_pos=buttonGeomPos,
                    text0_fg=PotionGlobals.TextColor,
                    text1_fg=PiratesGuiGlobals.TextFG0,
                    text2_fg=PiratesGuiGlobals.TextFG15,
                    text3_fg=PotionGlobals.TextColorDisabled,
                    text_align=TextNode.ALeft,
                    text_shadow=None,
                    text_scale=PiratesGuiGlobals.TextScaleExtraLarge,
                    command=cmd,
                    state=DGG.NORMAL,
                    extraArgs=[recipe])
                button.bind(DGG.ENTER, recipe.showDetails)
                button.bind(DGG.EXIT, recipe.hideDetails)
                if button['image'][0]:
                    button['image_pos'] = (button.getBounds()[1] + 0.075, 0,
                                           0.01)
                self.buttons.append(button)
            else:
                button = GuiButton.GuiButton(
                    text=(text, text, text, text),
                    canReposition=True,
                    text_wordwrap=0,
                    image_scale=buttonImageScale,
                    image_pos=(-0.04, 0.0, 0.01),
                    image=(buttonImage, buttonImage, buttonImage, buttonImage),
                    geom=buttonGeom,
                    geom_scale=buttonGeomScale,
                    geom_pos=buttonGeomPos,
                    text0_fg=PotionGlobals.TextColorDisabled,
                    text1_fg=PotionGlobals.TextColorDisabled,
                    text2_fg=PotionGlobals.TextColorDisabled,
                    text3_fg=PotionGlobals.TextColorDisabled,
                    text_shadow=None,
                    text_scale=PiratesGuiGlobals.TextScaleExtraLarge,
                    text_align=TextNode.ALeft,
                    state=DGG.NORMAL,
                    extraArgs=[recipe])
                button.bind(DGG.ENTER, recipe.showDetails)
                button.bind(DGG.EXIT, recipe.hideDetails)
                if button['image'][0]:
                    button['image_pos'] = (button.getBounds()[1] + 0.075, 0,
                                           0.01)
                self.inactiveButtons.append(button)
            self.recipeList.addItem(button)

        self.recipeList.refresh()
        self.lastIncButtonState = self.recipeList.incButton['state']
        self.lastDecButtonState = self.recipeList.decButton['state']
        self.recipeList.incButton['command'] = self.recipeList.scrollBy
        self.recipeList.incButton['extraArgs'] = [1]
        self.recipeList.decButton['command'] = self.recipeList.scrollBy
        self.recipeList.decButton['extraArgs'] = [-1]
        return
    def updateList(self):
        self.recipeList.removeAndDestroyAllItems()
        self.buttons = []
        self.inactiveButtons = []
        playerLevel = self.potionGame.dist.getPlayerPotionLevel()
        notNew_list = self.potionGame.dist.getPlayerNotNewFlags()
        for recipe in self.potionGame.recipes:
            if playerLevel >= recipe.level:
                recipe.enabled = True
            else:
                recipe.enabled = False
            if recipe.enabled and recipe.potionID not in notNew_list:
                recipe.haveMade = False
                
            recipe.haveMade = True
        
        self.potionGame.recipes.sort()
        for recipe in self.potionGame.recipes:
            if recipe.questOnly and localAvatar.getInventory():
                
                class brewable(Exception):
                    pass

                
                try:
                    for currQuest in localAvatar.getInventory().getQuestList():
                        bonusComplete = currQuest.isComplete(bonus = True)
                        primaryComplete = currQuest.isComplete()
                        if not bonusComplete or not primaryComplete:
                            tasks = currQuest.getQuestDNA().getTaskDNAs()
                            for currTask in tasks:
                                if isinstance(currTask, PotionsTaskDNA):
                                    if (PotionGlobals.getPotionItemID(recipe.potionID) == currTask.potionType or not primaryComplete or PotionGlobals.getPotionItemID(recipe.potionID) == currTask.potionTypeBonus) and not bonusComplete:
                                        raise brewable
                                        
                            
                
                except brewable:
                    pass
                

            
            if recipe.level - playerLevel > 3 and not (recipe.questOnly):
                buttonImage = None
                recipe.loadIngredients()
                buttonImageScale = 0.0
                text = recipe.name
                helptext = recipe.desc
            if not (recipe.haveMade) and len(recipe.ingredients) > 0:
                if recipe.questOnly:
                    iconText = PLocalizer.PotionGui['QuestLabel']
                    iconTextColor = PiratesGuiGlobals.TextFG13
                else:
                    iconText = PLocalizer.PotionGui['NewLabel']
                    iconTextColor = PiratesGuiGlobals.TextFG1
                guiAssets = loader.loadModel('models/minigames/pir_m_gui_pot_textureCard')
                buttonImage = guiAssets.find('**/pir_t_gui_pot_seal').copyTo(NodePath())
                buttonImageScale = 0.080000000000000002
                buttonText = DirectLabel(parent = buttonImage, relief = None, text = iconText, text_scale = PiratesGuiGlobals.TextScaleLarge / buttonImageScale, text_font = PiratesGlobals.getPirateOutlineFont(), text_align = TextNode.ACenter, text_fg = iconTextColor, text_shadow = PiratesGuiGlobals.TextFG14, hpr = (0, 0, 20), pos = (-0.25, 0, 0), textMayChange = 0)
                guiAssets.removeNode()
            
            if Freebooter.getPaidStatus(localAvatar.doId) or recipe.isFree:
                cmd = self.potionGame.selectRecipe
                buttonGeom = None
                buttonGeomScale = 1
                buttonGeomPos = (0, 0, 0)
                args = None
            else:
                gui = loader.loadModel('models/gui/toplevel_gui')
                buttonGeom = gui.find('**/pir_t_gui_gen_key_subscriber')
                buttonGeomScale = 0.16
                buttonGeomPos = (-0.050000000000000003, 0, 0.01)
                cmd = base.localAvatar.guiMgr.showNonPayer
                args = [
                    'Restricted_Potion_Crafting_Recipe',
                    9]
                gui.removeNode()
            if recipe.enabled and recipe.available:
                button = GuiButton.GuiButton(text = (text, text, text, text), canReposition = True, text_wordwrap = 0, image_scale = buttonImageScale, image_pos = (-0.040000000000000001, 0.0, 0.01), image = (buttonImage, buttonImage, buttonImage, buttonImage), geom = buttonGeom, geom_scale = buttonGeomScale, geom_pos = buttonGeomPos, text0_fg = PotionGlobals.TextColor, text1_fg = PiratesGuiGlobals.TextFG0, text2_fg = PiratesGuiGlobals.TextFG15, text3_fg = PotionGlobals.TextColorDisabled, text_align = TextNode.ALeft, text_shadow = None, text_scale = PiratesGuiGlobals.TextScaleExtraLarge, command = cmd, state = DGG.NORMAL, extraArgs = [
                    recipe])
                button.bind(DGG.ENTER, recipe.showDetails)
                button.bind(DGG.EXIT, recipe.hideDetails)
                if button['image'][0]:
                    button['image_pos'] = (button.getBounds()[1] + 0.074999999999999997, 0, 0.01)
                
                self.buttons.append(button)
            else:
                button = GuiButton.GuiButton(text = (text, text, text, text), canReposition = True, text_wordwrap = 0, image_scale = buttonImageScale, image_pos = (-0.040000000000000001, 0.0, 0.01), image = (buttonImage, buttonImage, buttonImage, buttonImage), geom = buttonGeom, geom_scale = buttonGeomScale, geom_pos = buttonGeomPos, text0_fg = PotionGlobals.TextColorDisabled, text1_fg = PotionGlobals.TextColorDisabled, text2_fg = PotionGlobals.TextColorDisabled, text3_fg = PotionGlobals.TextColorDisabled, text_shadow = None, text_scale = PiratesGuiGlobals.TextScaleExtraLarge, text_align = TextNode.ALeft, state = DGG.NORMAL, extraArgs = [
                    recipe])
                button.bind(DGG.ENTER, recipe.showDetails)
                button.bind(DGG.EXIT, recipe.hideDetails)
                if button['image'][0]:
                    button['image_pos'] = (button.getBounds()[1] + 0.074999999999999997, 0, 0.01)
                
                self.inactiveButtons.append(button)
            self.recipeList.addItem(button)
        
        self.recipeList.refresh()
        self.lastIncButtonState = self.recipeList.incButton['state']
        self.lastDecButtonState = self.recipeList.decButton['state']
        self.recipeList.incButton['command'] = self.recipeList.scrollBy
        self.recipeList.incButton['extraArgs'] = [
            1]
        self.recipeList.decButton['command'] = self.recipeList.scrollBy
        self.recipeList.decButton['extraArgs'] = [
            -1]
Beispiel #13
0
    def completeRecipe(self, recipeId, clearNewFlag):
        if not self.__verifySender():
            return

        if self.__workingRecipe == -1:

            if not PotionRecipeData.getPotionData(recipeId):
                self.notify.warning(
                    'Received complete Recipe for an invalid recipe %d!' %
                    recipeId)

                self.air.logPotentialHacker(
                    message='Received complete Recipe for an invalid recipe.',
                    targetAvId=self.avatar.doId,
                    recipeId=recipeId)

                return

            self.__workingRecipe = recipeId

        # Is this still the same recipe?
        elif self.__workingRecipe != recipeId:
            self.notify.warning(
                'Attempted to complete recipe that has not been started!')

            self.air.logPotentialHacker(
                message=
                'Attempted to complete recipe that has not been started!',
                targetAvId=self.avatar.doId,
                recipeId=recipeId)

            return

        self.__numIngredients += 1

        if self.__numIngredients >= PotionRecipeData.getNumIngredients(
                recipeId):

            # Perform disabled potion sanity check
            if PotionRecipeData.getDisabled(recipeId):
                self.notify.warning(
                    '%d completed a disabled potion recipe! (%d)' %
                    (self.avatar.doId, recipeId))

                self.air.logPotentialHacker(
                    message='Attempted to complete a disabled recipe!',
                    targetAvId=self.avatar.doId,
                    recipeId=recipeId)

                self.reset()

                return

            self.notify.debug('%s completed recipe %d!' %
                              (self.avatar.doId, recipeId))

            inventory = self.air.inventoryManager.getInventory(
                self.avatar.doId)
            success = True
            if not inventory:
                self.notify.warning('Failed to get inventory for avatar %d!' %
                                    avatar.doId)

                # Log failure for Game Masters
                self.air.writeServerEvent(
                    'recipe-error',
                    message='Failed to give player potion game rewards.',
                    targetAvId=self.avatar.doId,
                    recipeId=recipeId,
                    rep=rep,
                    potionId=potionId)

                self.reset()

                return

            potionRep = inventory.getPotionsRep() or 1

            # Perform potion level sanity check
            requiredLevel = PotionRecipeData.getPotionData(recipeId)['level']
            if potionRep < requiredLevel:
                self.notify.warning(
                    '%d completed a potion they are not a high enough level for! (%d); Requires %s. Has %s'
                    % (self.avatar.doId, recipeId, requiredLevel, potionRep))

                self.air.logPotentialHacker(
                    message=
                    'Attempted to complete a potion they are not a high enough level for!',
                    targetAvId=self.avatar.doId,
                    recipeId=recipeId,
                    level=potionRep,
                    required=requiredLevel)

                self.reset()

                return

            # Set have made flag
            if clearNewFlag:
                madeType = PotionGlobals.getPotionHaveMadeFlag(recipeId)
                madeCounter = inventory.getStack(
                    madeType)[1] if inventory.getStack(madeType) != None else 0
                madeCounter += 1
                inventory.b_setStack(madeType, madeCounter)

            # Aware XP
            rep = PotionGlobals.getPotionBuffXP(recipeId)
            potionId = PotionGlobals.potionBuffIdToInventoryTypeId(recipeId)
            inventory.setPotionsRep(potionRep + rep)

            #TODO give out potion
            self.notify.warning(
                'TODO: Implement potion rewards; PotionId: %d!' % potionId)

            self.reset()