Example #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)
Example #3
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)
Example #4
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()
Example #6
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()
Example #7
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()