def setupCells(self): self.figureOutStackTypes() self.computeCellSize() suitsAdded = [] for Z in range(self.gridZ): for X in range(len(self.listOfItemLists[Z])): cardId = self.listOfItemLists[Z][X] cardValue = cardId - InventoryType.begin_Cards cardName = PlayingCardGlobals.getCardName(cardValue) suit = PlayingCardGlobals.getSuit(cardValue, fromOffset=0) rank = PlayingCardGlobals.getRank(cardValue, fromOffset=0) if suit not in suitsAdded: suitsAdded.append(suit) if self.seperatorOn: self.seperatorCount += 1 bottomCard = 0 if rank == 0: bottomCard = 1 cardCell = self.getCell(bottomCard=bottomCard) cardCell.setPos(self.findGridPos(suit, rank)) self.cardDict[cardId] = cardCell self.placeCardItem(cardId) self.accept('seachestOpened', self.updateBufferedCards)
def __init__(self, manager, cardId, itemTuple, imageScaleFactor = 1.0, showMax = 0): amount = itemTuple[3] InventoryUIItem.InventoryUIItem.__init__(self, manager, itemTuple, imageScaleFactor = imageScaleFactor) self.initialiseoptions(InventoryUICardItem) self['relief'] = None gui = loader.loadModel('models/gui/suit_icons') if not amount: self['image'] = gui.find('**/PC_back_standard_dark') else: self['geom'] = gui.find('**/pir_t_gui_frm_goldCircle') self['geom_pos'] = (0.050000000000000003, 0, 0.050000000000000003) self['geom_scale'] = 0.0625 suit = PlayingCardGlobals.getSuit(itemTuple[1], fromOffset = 0) rank = PlayingCardGlobals.getRank(itemTuple[1], fromOffset = 0) style = PlayingCardGlobals.Styles[0] self['image'] = PlayingCardGlobals.getImage(style, suit, rank) self.textScale = 1.5 self.showMax = showMax self.itemType = ITEM_STACK self.amount = None self.localStore = 0 self.cardId = cardId if amount == None: self.localStore = 1 self.updateAmount() self.accept('inventoryQuantity-%s-%s' % (localAvatar.getInventory().doId, stackId), self.cardDirty) else: self.amount = amount self.updateAmountText() self.textOffset = 0.34999999999999998
def setupCells(self): self.figureOutStackTypes() self.computeCellSize() suitsAdded = [] for Z in range(self.gridZ): for X in range(len(self.listOfItemLists[Z])): cardId = self.listOfItemLists[Z][X] cardValue = cardId - InventoryType.begin_Cards cardName = PlayingCardGlobals.getCardName(cardValue) suit = PlayingCardGlobals.getSuit(cardValue, fromOffset = 0) rank = PlayingCardGlobals.getRank(cardValue, fromOffset = 0) if suit not in suitsAdded: suitsAdded.append(suit) if self.seperatorOn: self.seperatorCount += 1 bottomCard = 0 if rank == 0: bottomCard = 1 cardCell = self.getCell(bottomCard = bottomCard) cardCell.setPos(self.findGridPos(suit, rank)) self.cardDict[cardId] = cardCell self.placeCardItem(cardId) self.accept('seachestOpened', self.updateBufferedCards)
def cellClick(self, cell, mouseAction = MOUSE_CLICK, task = None): if mouseAction == MOUSE_PRESS and cell.inventoryItem: cardValue = cell.inventoryItem.itemTuple[1] suit = PlayingCardGlobals.getSuit(cardValue, fromOffset = 0) rank = PlayingCardGlobals.getRank(cardValue, fromOffset = 0) messenger.send('cardPicked', [ suit, rank])
def __init__(self, manager, cardId, itemTuple, imageScaleFactor=1.0, showMax=0): amount = itemTuple[3] InventoryUIItem.InventoryUIItem.__init__( self, manager, itemTuple, imageScaleFactor=imageScaleFactor) self.initialiseoptions(InventoryUICardItem) self['relief'] = None gui = loader.loadModel('models/gui/suit_icons') if not amount: self['image'] = gui.find('**/PC_back_standard_dark') else: self['geom'] = gui.find('**/pir_t_gui_frm_goldCircle') self['geom_pos'] = (0.05, 0, 0.05) self['geom_scale'] = 0.0625 suit = PlayingCardGlobals.getSuit(itemTuple[1], fromOffset=0) rank = PlayingCardGlobals.getRank(itemTuple[1], fromOffset=0) style = PlayingCardGlobals.Styles[0] self['image'] = PlayingCardGlobals.getImage(style, suit, rank) self.textScale = 1.5 self.showMax = showMax self.itemType = ITEM_STACK self.amount = None self.localStore = 0 self.cardId = cardId if amount == None: self.localStore = 1 self.updateAmount() self.accept( 'inventoryQuantity-%s-%s' % (localAvatar.getInventory().doId, stackId), self.cardDirty) else: self.amount = amount self.updateAmountText() self.textOffset = 0.35 return
def createSplitDisplay(self, seat, allHands, parent): self.deleteSplitDisplay(parent) handArray = allHands[seat] total_hands = len(handArray) if total_hands > 1: current_hand_index = self.table.getCurrentHandIndex(seat, allHands) x_increment = 0.24 x_size = (total_hands - 1) * x_increment x = -x_size * 0.5 y = -0.16 card_y = -0.05 for h in range(total_hands): hand = handArray[h] value = PlayingCardGlobals.getBlackjackHandValue(hand) scale = 0.375 length = len(hand) card_x_increment = 0.06 left = card_x_increment * scale * length * -0.5 for i in range(length): card = PlayingCard.PlayingCardNodePath( 'standard', PlayingCardGlobals.Unknown) card.reparentTo(parent) card.setPos(x + left + i * (card_x_increment * scale), 0, card_y) card.setScale(scale) card.setValue(hand[i]) card.turnUp() card.show() parent.cardArray.append(card) if h == current_hand_index: color = 1.0 card.setColor(color, color, color, 1.0) else: color = 0.6 card.setColor(color, color, color, 1.0) label = DirectLabel(parent=parent, relief=None, text='', text_align=TextNode.ACenter, text_scale=0.04, pos=(x, 0.0, y), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1)) label['text'] = str(value) label.show() parent.labelArray.append(label) x += x_increment return
def setEvent(self, seatIndex, action): guiIndex = self.getGuiIndex(seatIndex) panel = self.playerStatusPanels[guiIndex] actionText = PlayingCardGlobals.getBlackjackActionText(action) if len(action) >= 2: if action[0] == PlayingCardGlobals.Bid and action[1] == 0: actionText = ' ' if seatIndex == self.table.localAvatarSeat: if action[0] == PlayingCardGlobals.Bid: if action[1] == 0: self.bid = False else: self.bid = True panel.displayAction(actionText, self.table, seatIndex) if seatIndex == self.table.localAvatarSeat: time = 0.0 if action[0] == PlayingCardGlobals.AskForBid: time = PlayingCardGlobals.BidTimeout self.disableAllPlayButtons() self.normalButton(self.bidButton) self.bidSlider.show() self.splitCardsArray = [] self.swapCard = False self.bid = False if action[0] == PlayingCardGlobals.AskCard: time = PlayingCardGlobals.AskCardTimeout self.updatePlayButtions() if action[0] == PlayingCardGlobals.Stay: self.disableAllPlayButtons() if action[0] == PlayingCardGlobals.DoubleDown: self.disableAllPlayButtons() if action[0] == PlayingCardGlobals.Split: time = PlayingCardGlobals.AskCardTimeout self.disableAllPlayButtons() if time > 0.0: self.startTimer(time)
def figureOutStackTypes(self): suitDict = {} for cardId in self.itemList: suit = PlayingCardGlobals.getSuit(cardId, fromOffset=1) if not suitDict.has_key(suit): suitDict[suit] = [] suitDict[suit].append(cardId) self.listOfItemLists = [] for key in suitDict: itemList = suitDict[key] while len(itemList) > self.maxCountX: frontList = itemList[:self.maxCountX] backList = itemList[self.maxCountX:] self.listOfItemLists.append(frontList) itemList = backList self.listOfItemLists.append(itemList)
def figureOutStackTypes(self): suitDict = { } for cardId in self.itemList: suit = PlayingCardGlobals.getSuit(cardId, fromOffset = 1) if not suitDict.has_key(suit): suitDict[suit] = [] suitDict[suit].append(cardId) self.listOfItemLists = [] for key in suitDict: itemList = suitDict[key] while len(itemList) > self.maxCountX: frontList = itemList[:self.maxCountX] backList = itemList[self.maxCountX:] self.listOfItemLists.append(frontList) itemList = backList self.listOfItemLists.append(itemList)
def createSplitDisplay(self, seat, allHands, parent): self.deleteSplitDisplay(parent) handArray = allHands[seat] total_hands = len(handArray) if total_hands > 1: current_hand_index = self.table.getCurrentHandIndex(seat, allHands) x_increment = 0.23999999999999999 x_size = (total_hands - 1) * x_increment x = -x_size * 0.5 y = -0.16 card_y = -0.050000000000000003 for h in range(total_hands): hand = handArray[h] value = PlayingCardGlobals.getBlackjackHandValue(hand) scale = 0.375 length = len(hand) card_x_increment = 0.059999999999999998 left = card_x_increment * scale * length * -0.5 for i in range(length): card = PlayingCard.PlayingCardNodePath('standard', PlayingCardGlobals.Unknown) card.reparentTo(parent) card.setPos(x + left + i * card_x_increment * scale, 0, card_y) card.setScale(scale) card.setValue(hand[i]) card.turnUp() card.show() parent.cardArray.append(card) if h == current_hand_index: color = 1.0 card.setColor(color, color, color, 1.0) continue color = 0.59999999999999998 card.setColor(color, color, color, 1.0) label = DirectLabel(parent = parent, relief = None, text = '', text_align = TextNode.ACenter, text_scale = 0.040000000000000001, pos = (x, 0.0, y), text_fg = (1, 1, 1, 1), text_shadow = (0, 0, 0, 1)) label['text'] = str(value) label.show() parent.labelArray.append(label) x += x_increment
def setIcon(self): if self.circle: self.circle.destroy() self.circle = None if self.icon: self.icon.destroy() self.icon = None if self.icon2: self.icon2.destroy() self.icon2 = None icon = self['icon'] if icon: (category, detail) = icon imagePos = (0.10000000000000001, 0, -0.080000000000000002) extraArgs = [] if category == 'gold': image = StackMessage.CoinTex imageScale = 0.27000000000000002 command = localAvatar.guiMgr.showCollectionMain elif category == 'skills': image = StackMessage.SkillTex imageScale = 0.27000000000000002 command = localAvatar.guiMgr.showSkillPage elif category == 'reputation': repId = detail if repId == InventoryType.OverallRep: model = StackMessage.TopLevel imageScale = 0.089999999999999997 elif repId == InventoryType.SailingRep: model = StackMessage.SkillIcons imageScale = 0.12 else: model = StackMessage.WeaponIcons imageScale = 0.12 asset = ReputationGlobals.RepIcons.get(repId) image = model.find('**/%s' % asset) command = localAvatar.guiMgr.showSkillPage elif category == 'card': suit = PlayingCardGlobals.getSuit(detail) rank = PlayingCardGlobals.getRank(detail) image = PlayingCardGlobals.getImage('standard', suit, rank) imageScale = 0.20000000000000001 command = localAvatar.guiMgr.showCollectionMain elif category == 'collect': name = CollectionMap.Assets[detail] image = StackMessage.TreasureGui.find('**/%s*' % name) imageScale = 0.34999999999999998 command = localAvatar.guiMgr.showCollectionMain elif category == 'quests': image = StackMessage.QuestTex imageScale = 0.17999999999999999 command = localAvatar.guiMgr.showQuestPanel elif category == 'crew': image = StackMessage.CrewTex imageScale = 0.10000000000000001 command = localAvatar.guiMgr.socialPanel.show elif category == 'friends': image = StackMessage.FriendTex imageScale = (0.059999999999999998, 0, 0.070000000000000007) command = localAvatar.guiMgr.socialPanel.show elif category == 'guild': image = StackMessage.GuildTex imageScale = 0.080000000000000002 command = localAvatar.guiMgr.socialPanel.show elif category == 'lookout': image = StackMessage.LookoutTex imageScale = 0.17999999999999999 command = localAvatar.guiMgr.showLookoutPanel elif category == 'weapon': image = StackMessage.WeaponTex imageScale = 0.12 command = localAvatar.guiMgr.showWeaponPanel elif category == 'loot': if detail == ItemId.CARGO_CRATE: image = StackMessage.CrateTex elif detail == ItemId.CARGO_CHEST: image = StackMessage.ChestTex elif detail == ItemId.CARGO_SKCHEST: image = StackMessage.RoyalChestTex elif detail == ItemId.GOLD: pass imageScale = 0.34999999999999998 command = localAvatar.guiMgr.showShipPanel elif category == 'admin': image = StackMessage.AdminTex imageScale = 0.29999999999999999 command = None elif category == 'hat': image = StackMessage.HatTex imageScale = 0.16 imagePos = (0.10000000000000001, 0, -0.12) command = localAvatar.guiMgr.showNonPayer extraArgs = [ 'Restricted_Message_Stack_Panel', 10] elif category == 'tattoo': image = StackMessage.TattooTex imageScale = 0.12 imagePos = (0.10000000000000001, 0, -0.10000000000000001) command = localAvatar.guiMgr.showNonPayer extraArgs = [ None, 10] elif category == 'pork': image = StackMessage.PorkChunkTex imageScale = 0.10000000000000001 imagePos = (0.10000000000000001, 0, -0.080000000000000002) command = localAvatar.guiMgr.showNonPayer elif category == 'ship': image = StackMessage.ShipTex imageScale = 0.17999999999999999 command = None elif category == 'jolly': image = StackMessage.JollyTex imageScale = 0.12 command = None self.circle = DirectButton(parent = self, relief = None, image = StackMessage.CircleTex, image_scale = 0.5, pos = imagePos, command = command, extraArgs = extraArgs) if category == 'friends': self.icon = OnscreenImage(parent = self.circle, image = image, scale = imageScale, pos = (0.028000000000000001, 0, 0)) self.icon2 = OnscreenImage(parent = self.circle, image = image, scale = imageScale, pos = (-0.028000000000000001, 0, 0)) else: self.icon = OnscreenImage(parent = self.circle, image = image, scale = imageScale)
def getName(self): return PlayingCardGlobals.getCardName(self.itemTuple[1])
def setTableState(self, hands, allHands): for panel in self.playerStatusPanels: for card in panel.hand: card.hide() panel.handNameLabel.hide() panel.splitLabel.hide() panel.handsLabel.hide() self.hands = hands for i in range(len(hands)): newHand = hands[i] guiIndex = self.getGuiIndex(i) panel = self.playerStatusPanels[guiIndex] hand = panel.hand handNameLabel = panel.handNameLabel splitLabel = panel.splitLabel handsLabel = panel.handsLabel for card, newValue in zip(hand, newHand): card.show() card.setValue(newValue) if newValue == PlayingCardGlobals.Unknown: card.turnDown() else: card.turnUp() self.centerCards(panel, newHand) if newHand and PlayingCardGlobals.Unknown not in newHand: handValue = PlayingCardGlobals.getBlackjackHandValue(newHand) if handValue == 21 and len(newHand) == 2: handArray = allHands[i] total_hands = len(handArray) if total_hands <= 1: handNameLabel['text'] = PLocalizer.BlackjackHand else: handNameLabel['text'] = str(handValue) elif handValue > 21: handNameLabel[ 'text'] = PLocalizer.BlackjackBusted % handValue else: handNameLabel['text'] = str(handValue) handNameLabel.show() if i == self.table.localAvatarSeat: handArray = allHands[i] total_hands = len(handArray) if total_hands > 1: current_hand_index = self.table.getCurrentHandIndex( i, allHands) splitLabel['text'] = PLocalizer.BlackjackHandofHand % ( current_hand_index + 1, total_hands) splitLabel.show() hands_text = '' for h in range(current_hand_index): hands_text = hands_text + str( PlayingCardGlobals.getBlackjackHandValue( handArray[h])) + ' ' handsLabel.show() self.createSplitDisplay(i, allHands, handsLabel) self.canSplit = False self.canDoubleDown = False if newHand[0] in self.splitCardsArray: self.splitCardsArray.remove(newHand[0]) if handValue >= 21: self.disableAllPlayButtons() else: self.updateSplitAndDoubleDown(newHand)
def showLoot(self, plunder=[], gold=0, collect=0, card=0, cloth=0, color=0, jewel=None, tattoo=None, weapon=None, bounty=0): for loot in self.loot: loot.destroy() del loot self.loot = [] gender = localAvatar.style.getGender() self.show() self.setAlphaScale(1.0) treasure = [] for itemId in self.icons.iterkeys(): count = 0 for item in plunder: if item == itemId: count += 1 continue if count > 0: treasure.append([itemId, count]) continue plunder = treasure if gold: plunder.append([ItemId.GOLD, gold]) LootPopupPanel.lootSfx.play() if bounty: plunder.append([ItemId.BOUNTY, bounty]) LootPopupPanel.lootSfx.play() if collect: plunder.append([ItemId.COLLECT, collect]) LootPopupPanel.lootSfx.play() if card: plunder.append([ItemId.CARD, card]) LootPopupPanel.lootSfx.play() if cloth: plunder.append([ItemId.CLOTHING, (cloth, color)]) LootPopupPanel.lootSfx.play() if jewel is not None: plunder.append([ItemId.QUEST_DROP_JEWEL, jewel]) LootPopupPanel.lootSfx.play() if tattoo is not None: plunder.append([ItemId.QUEST_DROP_TATTOO, tattoo]) LootPopupPanel.lootSfx.play() if weapon is not None: plunder.append([ItemId.QUEST_DROP_WEAPON, weapon]) LootPopupPanel.lootSfx.play() for item in plunder: (itemType, quantity) = item if itemType == ItemId.COLLECT: itemId = quantity howRare = CollectionMap.Collection_Rarity.get(itemId, 0) rarityText = PLocalizer.CollectionRarities.get(howRare) value = CollectionValues.get(howRare, 0) itemName = PLocalizer.Collections[itemId] howManyDoIHave = localAvatar.getInventory().getStackQuantity( itemId) howManyINeed = CollectionMap.Collection_Needed.get(itemId, 1) if howManyDoIHave < howManyINeed: textInfo = PLocalizer.CollectionPopupNewText % ( itemName, rarityText, value) else: textInfo = PLocalizer.CollectionPopupDuplicateText % ( itemName, rarityText, value) pic_name = CollectionMap.Assets[itemId] lootIcon = LootPopupPanel.TreasureGui.find('**/%s*' % pic_name) iconScale = 0.34999999999999998 elif itemType == ItemId.CLOTHING: (clothingId, colorId) = quantity if clothingId in ClothingGlobals.quest_items: textInfo = PLocalizer.getItemName(clothingId) else: textInfo = PLocalizer.TailorColorStrings.get(colorId) textInfo = textInfo + ' ' + ClothingGlobals.getClothingTypeName( ItemGlobals.getType(clothingId)) clothingType = ItemGlobals.getType(clothingId) iconScale = 0.13 if clothingType == 0: lootIcon = LootPopupPanel.TailorGui.find( '**/icon_shop_tailor_hat') elif clothingType == 1: lootIcon = loader.loadModel('models/gui/char_gui').find( '**/chargui_cloth') iconScale = 0.29999999999999999 elif clothingType == 2: lootIcon = LootPopupPanel.TailorGui.find( '**/icon_shop_tailor_vest') elif clothingType == 3: lootIcon = LootPopupPanel.TailorGui.find( '**/icon_shop_tailor_coat') elif clothingType == 4: lootIcon = LootPopupPanel.TailorGui.find( '**/icon_shop_tailor_pants') elif clothingType == 5: lootIcon = LootPopupPanel.TailorGui.find( '**/icon_shop_tailor_belt') elif clothingType == 6: lootIcon = LootPopupPanel.TailorGui.find( '**/icon_shop_tailor_sock') else: lootIcon = LootPopupPanel.TailorGui.find( '**/icon_shop_tailor_booths') elif itemType == ItemId.CARD: textInfo = PLocalizer.InventoryTypeNames.get(quantity) pic_name = '' lootIcon = PlayingCardGlobals.getImage( 'standard', PlayingCardGlobals.getSuit(quantity), PlayingCardGlobals.getRank(quantity)) iconScale = 0.20000000000000001 elif itemType == ItemId.GOLD: textInfo = PLocalizer.LootGold % str(quantity) potionPercent = PotionGlobals.getGoldBoostEffectPercent( localAvatar) potionGold = 0 textInfo = PLocalizer.LootGold % str(quantity) if base.cr.newsManager: if base.cr.newsManager.getHoliday( HolidayGlobals.DOUBLEGOLDHOLIDAYPAID ) or Freebooter.getPaidStatus(base.localAvatar.getDoId( )) or base.cr.newsManager.getHoliday( HolidayGlobals.DOUBLEGOLDHOLIDAY): textInfo = PLocalizer.LootGold % str( quantity / 2) + '\n + ' + PLocalizer.LootGoldDouble % str( quantity / 2) if potionGold > 0: textInfo += '\n + ' + PLocalizer.LootGoldPotionBoost % str( potionGold) lootIcon = self.icons.get(itemType)[0] iconScale = 0.27000000000000002 elif itemType == ItemId.BOUNTY: textInfo = PLocalizer.LootBounty % str(quantity) lootIcon = self.icons.get(itemType)[0] iconScale = 0.27000000000000002 elif itemType == ItemId.CARGO_CRATE: if quantity == 1: textInfo = PLocalizer.CargoCrate % quantity else: textInfo = PLocalizer.CargoCrateP % quantity lootIcon = self.icons.get(itemType)[0] iconScale = 0.089999999999999997 elif itemType == ItemId.CARGO_CHEST: if quantity == 1: textInfo = PLocalizer.CargoChest % quantity else: textInfo = PLocalizer.CargoChestP % quantity lootIcon = self.icons.get(itemType)[0] iconScale = 0.089999999999999997 elif itemType == ItemId.CARGO_SKCHEST: if quantity == 1: textInfo = PLocalizer.CargoSkChest % quantity else: textInfo = PLocalizer.CargoSkChestP % quantity lootIcon = self.icons.get(itemType)[0] iconScale = 0.089999999999999997 elif itemType == ItemId.CARGO_LOOTSAC: if quantity == 1: textInfo = PLocalizer.LootSac % quantity else: textInfo = PLocalizer.LootSacP % quantity lootIcon = self.icons.get(itemType)[0] iconScale = 0.089999999999999997 elif itemType == ItemId.CARGO_LOOTCHEST: if quantity == 1: textInfo = PLocalizer.LootChest % quantity else: textInfo = PLocalizer.LootChestP % quantity lootIcon = self.icons.get(itemType)[0] iconScale = 0.089999999999999997 elif itemType == ItemId.CARGO_LOOTSKCHEST: if quantity == 1: textInfo = PLocalizer.LootSkChest % quantity else: textInfo = PLocalizer.LootSkChestP % quantity lootIcon = self.icons.get(itemType)[0] iconScale = 0.089999999999999997 elif itemType == ItemId.CARGO_SHIPUPGRADECHEST: if quantity == 1: textInfo = PLocalizer.LootUpgradeChest % quantity else: textInfo = PLocalizer.LootUpgradeChestP % quantity lootIcon = self.icons.get(itemType)[0] iconScale = 0.089999999999999997 elif itemType == ItemId.CARGO_SHIPUPGRADESKCHEST: if quantity == 1: textInfo = PLocalizer.LootRareUpgradeChest % quantity else: textInfo = PLocalizer.LootRareUpgradeChestP % quantity lootIcon = self.icons.get(itemType)[0] iconScale = 0.089999999999999997 elif itemType == ItemId.QUEST_DROP_JEWEL: textInfo = None type = None lootIcon = None iconScale = 1.0 type = ItemGlobals.getType(quantity) textInfo = PLocalizer.getItemName(quantity) if type == ItemGlobals.BROW: lootIcon = LootPopupPanel.JewelerIconsB.find( '**/icon_shop_tailor_brow') iconScale = (-0.14000000000000001, 0.14000000000000001, 0.14000000000000001) elif type == ItemGlobals.EAR: lootIcon = LootPopupPanel.JewelerIconsA.find( '**/chargui_ears') iconScale = (-0.34999999999999998, 0.34999999999999998, 0.34999999999999998) elif type == ItemGlobals.NOSE: lootIcon = LootPopupPanel.JewelerIconsA.find( '**/chargui_nose') iconScale = (0.34999999999999998, 0.34999999999999998, 0.34999999999999998) elif type == ItemGlobals.MOUTH: lootIcon = LootPopupPanel.JewelerIconsA.find( '**/chargui_mouth') iconScale = (0.32500000000000001, 0.32500000000000001, 0.32500000000000001) elif type == ItemGlobals.HAND: lootIcon = LootPopupPanel.JewelerIconsB.find( '**/icon_shop_tailor_hand') iconScale = (0.125, 0.125, 0.125) else: lootIcon = None elif itemType == ItemId.QUEST_DROP_TATTOO: textInfo = None type = None lootIcon = None iconScale = 1.0 type = ItemGlobals.getType(quantity) textInfo = PLocalizer.getItemName(quantity) if type == ItemGlobals.CHEST: lootIcon = LootPopupPanel.TattooIcons.find( '**/icon_shop_tailor_chest_male') iconScale = 0.10000000000000001 elif type == ItemGlobals.ARM: lootIcon = LootPopupPanel.TattooIcons.find( '**/icon_shop_tailor_arm') iconScale = 0.10000000000000001 elif type == ItemGlobals.FACE: lootIcon = LootPopupPanel.TattooIcons.find( '**/icon_shop_tailor_face_male') iconScale = 0.10000000000000001 else: lootIcon = None elif itemType == ItemId.QUEST_DROP_WEAPON: weaponId = quantity iconScale = 0.10000000000000001 textInfo = None lootIcon = None iconName = getItemIcons(weaponId) if iconName is not None: lootIcon = LootPopupPanel.WeaponIcons.find('**/' + iconName) textInfo = PLocalizer.InventoryTypeNames.get(weaponId) entry = DirectFrame(parent=self, relief=None, geom=lootIcon, geom_scale=iconScale, text=textInfo, text_scale=PiratesGuiGlobals.TextScaleSmall, text_align=TextNode.ALeft, text_fg=PiratesGuiGlobals.TextFG0, text_pos=(0.070000000000000007, 0.01), text_font=PiratesGlobals.getInterfaceFont()) entry.setTransparency(1) self.loot.append(entry) self.repackPanels()
def cellClick(self, cell, mouseAction=MOUSE_CLICK, task=None): if mouseAction == MOUSE_PRESS and cell.inventoryItem: cardValue = cell.inventoryItem.itemTuple[1] suit = PlayingCardGlobals.getSuit(cardValue, fromOffset=0) rank = PlayingCardGlobals.getRank(cardValue, fromOffset=0) messenger.send('cardPicked', [suit, rank])
def setTableState(self, hands, allHands): for panel in self.playerStatusPanels: for card in panel.hand: card.hide() panel.handNameLabel.hide() panel.splitLabel.hide() panel.handsLabel.hide() self.hands = hands for i in range(len(hands)): newHand = hands[i] guiIndex = self.getGuiIndex(i) panel = self.playerStatusPanels[guiIndex] hand = panel.hand handNameLabel = panel.handNameLabel splitLabel = panel.splitLabel handsLabel = panel.handsLabel for (card, newValue) in zip(hand, newHand): card.show() card.setValue(newValue) if newValue == PlayingCardGlobals.Unknown: card.turnDown() continue card.turnUp() self.centerCards(panel, newHand) if newHand and PlayingCardGlobals.Unknown not in newHand: handValue = PlayingCardGlobals.getBlackjackHandValue(newHand) if handValue == 21 and len(newHand) == 2: handArray = allHands[i] total_hands = len(handArray) if total_hands <= 1: handNameLabel['text'] = PLocalizer.BlackjackHand else: handNameLabel['text'] = str(handValue) elif handValue > 21: handNameLabel['text'] = PLocalizer.BlackjackBusted % handValue else: handNameLabel['text'] = str(handValue) handNameLabel.show() if i == self.table.localAvatarSeat: handArray = allHands[i] total_hands = len(handArray) if total_hands > 1: current_hand_index = self.table.getCurrentHandIndex(i, allHands) splitLabel['text'] = PLocalizer.BlackjackHandofHand % (current_hand_index + 1, total_hands) splitLabel.show() hands_text = '' for h in range(current_hand_index): hands_text = hands_text + str(PlayingCardGlobals.getBlackjackHandValue(handArray[h])) + ' ' handsLabel.show() self.createSplitDisplay(i, allHands, handsLabel) self.canSplit = False self.canDoubleDown = False if newHand[0] in self.splitCardsArray: self.splitCardsArray.remove(newHand[0]) if handValue >= 21: self.disableAllPlayButtons() else: self.updateSplitAndDoubleDown(newHand) i == self.table.localAvatarSeat
def showLoot(self, plunder = [], gold = 0, collect = 0, card = 0, cloth = 0, color = 0, jewel = None, tattoo = None, weapon = None, bounty = 0): for loot in self.loot: loot.destroy() del loot self.loot = [] gender = localAvatar.style.getGender() self.show() self.setAlphaScale(1.0) treasure = [] for itemId in self.icons.iterkeys(): count = 0 for item in plunder: if item == itemId: count += 1 continue if count > 0: treasure.append([ itemId, count]) continue plunder = treasure if gold: plunder.append([ ItemId.GOLD, gold]) LootPopupPanel.lootSfx.play() if bounty: plunder.append([ ItemId.BOUNTY, bounty]) LootPopupPanel.lootSfx.play() if collect: plunder.append([ ItemId.COLLECT, collect]) LootPopupPanel.lootSfx.play() if card: plunder.append([ ItemId.CARD, card]) LootPopupPanel.lootSfx.play() if cloth: plunder.append([ ItemId.CLOTHING, (cloth, color)]) LootPopupPanel.lootSfx.play() if jewel is not None: plunder.append([ ItemId.QUEST_DROP_JEWEL, jewel]) LootPopupPanel.lootSfx.play() if tattoo is not None: plunder.append([ ItemId.QUEST_DROP_TATTOO, tattoo]) LootPopupPanel.lootSfx.play() if weapon is not None: plunder.append([ ItemId.QUEST_DROP_WEAPON, weapon]) LootPopupPanel.lootSfx.play() for item in plunder: (itemType, quantity) = item if itemType == ItemId.COLLECT: itemId = quantity howRare = CollectionMap.Collection_Rarity.get(itemId, 0) rarityText = PLocalizer.CollectionRarities.get(howRare) value = CollectionValues.get(howRare, 0) itemName = PLocalizer.Collections[itemId] howManyDoIHave = localAvatar.getInventory().getStackQuantity(itemId) howManyINeed = CollectionMap.Collection_Needed.get(itemId, 1) if howManyDoIHave < howManyINeed: textInfo = PLocalizer.CollectionPopupNewText % (itemName, rarityText, value) else: textInfo = PLocalizer.CollectionPopupDuplicateText % (itemName, rarityText, value) pic_name = CollectionMap.Assets[itemId] lootIcon = LootPopupPanel.TreasureGui.find('**/%s*' % pic_name) iconScale = 0.34999999999999998 elif itemType == ItemId.CLOTHING: (clothingId, colorId) = quantity if clothingId in ClothingGlobals.quest_items: textInfo = PLocalizer.getItemName(clothingId) else: textInfo = PLocalizer.TailorColorStrings.get(colorId) textInfo = textInfo + ' ' + ClothingGlobals.getClothingTypeName(ItemGlobals.getType(clothingId)) clothingType = ItemGlobals.getType(clothingId) iconScale = 0.13 if clothingType == 0: lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_hat') elif clothingType == 1: lootIcon = loader.loadModel('models/gui/char_gui').find('**/chargui_cloth') iconScale = 0.29999999999999999 elif clothingType == 2: lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_vest') elif clothingType == 3: lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_coat') elif clothingType == 4: lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_pants') elif clothingType == 5: lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_belt') elif clothingType == 6: lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_sock') else: lootIcon = LootPopupPanel.TailorGui.find('**/icon_shop_tailor_booths') elif itemType == ItemId.CARD: textInfo = PLocalizer.InventoryTypeNames.get(quantity) pic_name = '' lootIcon = PlayingCardGlobals.getImage('standard', PlayingCardGlobals.getSuit(quantity), PlayingCardGlobals.getRank(quantity)) iconScale = 0.20000000000000001 elif itemType == ItemId.GOLD: textInfo = PLocalizer.LootGold % str(quantity) potionPercent = PotionGlobals.getGoldBoostEffectPercent(localAvatar) potionGold = 0 textInfo = PLocalizer.LootGold % str(quantity) if base.cr.newsManager: if base.cr.newsManager.getHoliday(HolidayGlobals.DOUBLEGOLDHOLIDAYPAID) or Freebooter.getPaidStatus(base.localAvatar.getDoId()) or base.cr.newsManager.getHoliday(HolidayGlobals.DOUBLEGOLDHOLIDAY): textInfo = PLocalizer.LootGold % str(quantity / 2) + '\n + ' + PLocalizer.LootGoldDouble % str(quantity / 2) if potionGold > 0: textInfo += '\n + ' + PLocalizer.LootGoldPotionBoost % str(potionGold) lootIcon = self.icons.get(itemType)[0] iconScale = 0.27000000000000002 elif itemType == ItemId.BOUNTY: textInfo = PLocalizer.LootBounty % str(quantity) lootIcon = self.icons.get(itemType)[0] iconScale = 0.27000000000000002 elif itemType == ItemId.CARGO_CRATE: if quantity == 1: textInfo = PLocalizer.CargoCrate % quantity else: textInfo = PLocalizer.CargoCrateP % quantity lootIcon = self.icons.get(itemType)[0] iconScale = 0.089999999999999997 elif itemType == ItemId.CARGO_CHEST: if quantity == 1: textInfo = PLocalizer.CargoChest % quantity else: textInfo = PLocalizer.CargoChestP % quantity lootIcon = self.icons.get(itemType)[0] iconScale = 0.089999999999999997 elif itemType == ItemId.CARGO_SKCHEST: if quantity == 1: textInfo = PLocalizer.CargoSkChest % quantity else: textInfo = PLocalizer.CargoSkChestP % quantity lootIcon = self.icons.get(itemType)[0] iconScale = 0.089999999999999997 elif itemType == ItemId.CARGO_LOOTSAC: if quantity == 1: textInfo = PLocalizer.LootSac % quantity else: textInfo = PLocalizer.LootSacP % quantity lootIcon = self.icons.get(itemType)[0] iconScale = 0.089999999999999997 elif itemType == ItemId.CARGO_LOOTCHEST: if quantity == 1: textInfo = PLocalizer.LootChest % quantity else: textInfo = PLocalizer.LootChestP % quantity lootIcon = self.icons.get(itemType)[0] iconScale = 0.089999999999999997 elif itemType == ItemId.CARGO_LOOTSKCHEST: if quantity == 1: textInfo = PLocalizer.LootSkChest % quantity else: textInfo = PLocalizer.LootSkChestP % quantity lootIcon = self.icons.get(itemType)[0] iconScale = 0.089999999999999997 elif itemType == ItemId.QUEST_DROP_JEWEL: textInfo = None type = None lootIcon = None iconScale = 1.0 type = ItemGlobals.getType(quantity) textInfo = PLocalizer.getItemName(quantity) if type == ItemGlobals.BROW: lootIcon = LootPopupPanel.JewelerIconsB.find('**/icon_shop_tailor_brow') iconScale = (-0.14000000000000001, 0.14000000000000001, 0.14000000000000001) elif type == ItemGlobals.EAR: lootIcon = LootPopupPanel.JewelerIconsA.find('**/chargui_ears') iconScale = (-0.34999999999999998, 0.34999999999999998, 0.34999999999999998) elif type == ItemGlobals.NOSE: lootIcon = LootPopupPanel.JewelerIconsA.find('**/chargui_nose') iconScale = (0.34999999999999998, 0.34999999999999998, 0.34999999999999998) elif type == ItemGlobals.MOUTH: lootIcon = LootPopupPanel.JewelerIconsA.find('**/chargui_mouth') iconScale = (0.32500000000000001, 0.32500000000000001, 0.32500000000000001) elif type == ItemGlobals.LHAND: lootIcon = LootPopupPanel.JewelerIconsB.find('**/icon_shop_tailor_hand') iconScale = (0.125, 0.125, 0.125) else: lootIcon = None elif itemType == ItemId.QUEST_DROP_TATTOO: textInfo = None type = None lootIcon = None iconScale = 1.0 type = ItemGlobals.getType(quantity) textInfo = PLocalizer.getItemName(quantity) if type == ItemGlobals.CHEST: lootIcon = LootPopupPanel.TattooIcons.find('**/icon_shop_tailor_chest_male') iconScale = 0.10000000000000001 elif type == ItemGlobals.ARM: lootIcon = LootPopupPanel.TattooIcons.find('**/icon_shop_tailor_arm') iconScale = 0.10000000000000001 elif type == ItemGlobals.FACE: lootIcon = LootPopupPanel.TattooIcons.find('**/icon_shop_tailor_face_male') iconScale = 0.10000000000000001 else: lootIcon = None elif itemType == ItemId.QUEST_DROP_WEAPON: weaponId = quantity iconScale = 0.10000000000000001 textInfo = None lootIcon = None iconName = getItemIcons(weaponId) if iconName is not None: lootIcon = LootPopupPanel.WeaponIcons.find('**/' + iconName) textInfo = PLocalizer.InventoryTypeNames.get(weaponId) entry = DirectFrame(parent = self, relief = None, geom = lootIcon, geom_scale = iconScale, text = textInfo, text_scale = PiratesGuiGlobals.TextScaleSmall, text_align = TextNode.ALeft, text_fg = PiratesGuiGlobals.TextFG0, text_pos = (0.070000000000000007, 0.01), text_font = PiratesGlobals.getInterfaceFont()) entry.setTransparency(1) self.loot.append(entry) self.repackPanels()