def getCardsFromImages(self, pathToImages): cards = [] count = 0 minMana = 0 global actualManas for name in sorted(os.listdir(pathToImages)): if name[-4:] == ".png": screenshot = Image.open(pathToImages + name) for i in range(self.screenshotParser.numOfCardsInScreenshot(screenshot)): card = Card(screenshot.crop(self.screenshotParser.cardLocations[i])) cards.append(card) card.cardType = self.screenshotParser.getCardType(card) card.golden = self.screenshotParser.isGolden(card) card.mana = actualManas[count] card.cardImage.save("./temp/" + str(count) + ".bmp", "BMP") count += 1 print "Card " + str(count) return cards
def getCardsFromImages(self, pathToImages): cards = [] count = 0 minMana = 0 global actualManas for name in sorted(os.listdir(pathToImages)): if name[-4:] == ".png": screenshot = Image.open(pathToImages + name) for i in range( self.screenshotParser.numOfCardsInScreenshot( screenshot)): card = Card( screenshot.crop( self.screenshotParser.cardLocations[i])) cards.append(card) card.cardType = self.screenshotParser.getCardType(card) card.golden = self.screenshotParser.isGolden(card) card.mana = actualManas[count] card.cardImage.save("./temp/" + str(count) + ".bmp", "BMP") count += 1 print "Card " + str(count) return cards
def __init__(self, cards, stringDicts=False): if stringDicts: self.cards = [] cards = str(cards) for card in cards.split("\n"): self.cards.append(Card.fromDict(ast.literal_eval(card))) else: self.cards = cards self.gRarities = {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0} self.rarities = {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0} self.classCount = {"Druid" : [0, 0], "Hunter" : [0, 0], "Mage" : [0, 0], "Paladin": [0, 0], "Priest" : [0, 0], "Rogue" : [0, 0], "Shaman" : [0, 0], "Warlock": [0, 0], "Warrior": [0, 0], "Neutral": [0, 0]} self.classDust = {"Druid" : [0, 0], "Hunter" : [0, 0], "Mage" : [0, 0], "Paladin": [0, 0], "Priest" : [0, 0], "Rogue" : [0, 0], "Shaman" : [0, 0], "Warlock": [0, 0], "Warrior": [0, 0], "Neutral": [0, 0]} self.classRarity = {"Druid" : {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Hunter" : {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Mage" : {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Paladin": {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Priest" : {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Rogue" : {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Shaman" : {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Warlock": {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Warrior": {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Neutral": {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}} self.gClassRarity = {"Druid" : {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Hunter" : {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Mage" : {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Paladin": {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Priest" : {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Rogue" : {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Shaman" : {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Warlock": {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Warrior": {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}, "Neutral": {"Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0}} self.disenchantValue = 0 self.enchantValue = 0 self.cardKnowledge = [] self.numCards = len(self.cards) self.goldCards = 0 for card in self.cards: if card.golden: self.goldCards += 1 self.findRarities() self.findDustValues() self.findPotentialCards() for hero in self.listheroes: for rarity in self.listrarities: self.classCount[hero][0] += self.classRarity[hero][rarity] self.classCount[hero][1] += self.gClassRarity[hero][rarity] return
def __init__(self, cards, stringDicts=False): if stringDicts: self.cards = [] cards = str(cards) for card in cards.split("\n"): self.cards.append(Card.fromDict(ast.literal_eval(card))) else: self.cards = cards self.gRarities = { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 } self.rarities = { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 } self.classCount = { "Druid": [0, 0], "Hunter": [0, 0], "Mage": [0, 0], "Paladin": [0, 0], "Priest": [0, 0], "Rogue": [0, 0], "Shaman": [0, 0], "Warlock": [0, 0], "Warrior": [0, 0], "Neutral": [0, 0] } self.classDust = { "Druid": [0, 0], "Hunter": [0, 0], "Mage": [0, 0], "Paladin": [0, 0], "Priest": [0, 0], "Rogue": [0, 0], "Shaman": [0, 0], "Warlock": [0, 0], "Warrior": [0, 0], "Neutral": [0, 0] } self.classRarity = { "Druid": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Hunter": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Mage": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Paladin": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Priest": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Rogue": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Shaman": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Warlock": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Warrior": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Neutral": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 } } self.gClassRarity = { "Druid": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Hunter": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Mage": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Paladin": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Priest": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Rogue": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Shaman": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Warlock": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Warrior": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 }, "Neutral": { "Legendary": 0, "Epic": 0, "Rare": 0, "Common": 0, "Free": 0 } } self.disenchantValue = 0 self.enchantValue = 0 self.cardKnowledge = [] self.numCards = len(self.cards) self.goldCards = 0 for card in self.cards: if card.golden: self.goldCards += 1 self.findRarities() self.findDustValues() self.findPotentialCards() for hero in self.listheroes: for rarity in self.listrarities: self.classCount[hero][0] += self.classRarity[hero][rarity] self.classCount[hero][1] += self.gClassRarity[hero][rarity] return