예제 #1
0
    def __init__(self):
        self.tweet = ''
        cur_formats = Format.objects.filter(start_date__lte=datetime.today(), end_date__gte=datetime.today()).order_by('format')
        self.cur_format = random.choice(cur_formats)

        for counter in range(0, 1):
            spreds = []
            spred = SearchPredicate()
            spred.term = 'format'
            spred.value = self.cur_format.id
            spreds.append(spred)
            sd = SortDirective()
            sd.term = 'cardrating'
            sd.direction = sd.DESC
            sd.crs_format_id = self.cur_format.id
            spreds.append(sd)
            card_list = Card.playables.search(spreds)

            rand_index = 5 + int(random.random() * 90)
            comp_index = int(random.random() * 10) - 5 + rand_index
            if comp_index == rand_index:
                comp_index = comp_index + 1

            self.first_card = card_list[rand_index]
            self.comp_card = card_list[comp_index]
예제 #2
0
    def __init__(self):
        cur_formats = Format.objects.filter(
            formatname='Modern',
            start_date__lte=datetime.today(),
            end_date__gte=datetime.today()).order_by('format')
        format_count = len(list(cur_formats))
        format_index = int(random.random() * format_count)
        self.cur_format = cur_formats[format_index]

        mm2_card_names = ["Sundering Vitae",
                          "Darksteel Citadel",
                          "Wayfarer's Bauble",
                          "Tumble Magnet",
                          "Sphere of the Suns",
                          "Skyreach Manta",
                          "Sickleslicer",
                          "Runed Servitor",
                          "Precursor Golem",
                          "Myr Enforcer",
                          "Long-Forgotten Gohei",
                          "Lodestone Myr",
                          "Evolving Wilds",
                          "Lodestone Golem",
                          "Kitesail",
                          "Wrecking Ball",
                          "Gust-Skimmer",
                          "Vengeful Rebirth",
                          "Glint Hawk Idol",
                          "Frogmite",
                          "Sigil Blessing",
                          "Flayer Husk",
                          "Expedition Map",
                          "Shrewd Hatchling",
                          "Everflowing Chalice",
                          "Selesnya Guildmage",
                          "Darksteel Axe",
                          "Savage Twister",
                          "Culling Dais",
                          "Restless Apparition",
                          "Copper Carapace",
                          "Plaxcaster Frogling",
                          "Pillory of the Sleepless",
                          "Chimeric Mass",
                          "Necrogenesis",
                          "Cathodion",
                          "Lorescale Coatl",
                          "Hearthfire Hobgoblin",
                          "Glassdust Hulk",
                          "Blinding Souleater",
                          "Ethercaste Knight",
                          "Electrolyze",
                          "Alloy Myr",
                          "Drooling Groodion",
                          "Ulamog's Crusher",
                          "Waking Nightmare",
                          "Wings of Velis Vel",
                          "Vampire Outcasts",
                          "Water Servant",
                          "Dimir Guildmage",
                          "Vigean Graftmage",
                          "Boros Swiftblade",
                          "Spread the Sickness",
                          "Vapor Snag",
                          "Ashenmoor Gouger",
                          "Agony Warp",
                          "Sign in Blood",
                          "Thrummingbird",
                          "Sickle Ripper",
                          "Thoughtcast",
                          "Shrivel",
                          "Tezzeret's Gambit",
                          "Scuttling Death",
                          "Telling Time",
                          "Scavenger Drake",
                          "Reassembling Skeleton",
                          "Wolfbriar Elemental",
                          "Vines of Vastwood",
                          "Surrakar Spellblade",
                          "Puppeteer Clique",
                          "Tukatongue Thallid",
                          "Stoic Rebuttal",
                          "Plagued Rusalka",
                          "Steady Progress",
                          "Thrive",
                          "Sylvan Bounty",
                          "Midnight Banshee",
                          "Somber Hoverguard",
                          "Simic Initiate",
                          "Repeal",
                          "Scute Mob",
                          "Qumulox",
                          "Instill Infection",
                          "Scatter the Seeds",
                          "Novijen Sages",
                          "Grim Affliction",
                          "Root-Kin Ally",
                          "Rampant Growth",
                          "Narcolepsy",
                          "Ghostly Changeling",
                          "Plummet",
                          "Mana Leak",
                          "Pelakka Wurm",
                          "Duskhunter Bat",
                          "Inexorable Tide",
                          "Overwhelming Stampede",
                          "Devouring Greed",
                          "Deathmark",
                          "Overwhelm",
                          "Helium Squirter",
                          "Death Denied",
                          "Mutagenic Growth",
                          "Guile",
                          "Matca Rioters",
                          "Flashfreeze",
                          "Kavu Primarch",
                          "Daggerclaw Imp",
                          "Bone Splinters",
                          "Faerie Mechanist",
                          "Karplusan Strider",
                          "Cloud Elemental",
                          "Gnarlid Pack",
                          "Cytoplast Root-Kin",
                          "Commune with Nature",
                          "Argent Sphinx",
                          "Terashi's Grasp",
                          "Air Servant",
                          "Taj-Nar Swordsmith",
                          "Bestial Menace",
                          "Æthersnipe",
                          "Sunspear Shikari",
                          "Aquastrand Spider",
                          "Sunlance",
                          "Algae Gharial",
                          "Spectral Procession",
                          "Wrap in Flames",
                          "Worldheart Phoenix",
                          "Skyhunter Skirmisher",
                          "Viashino Slaughtermaster",
                          "Raise the Alarm",
                          "Tribal Flames",
                          "Otherworldly Journey",
                          "Thunderblust",
                          "Spitebellows",
                          "Oblivion Ring",
                          "Spikeshot Elder",
                          "Myrsmith",
                          "Soulbright Flamekin",
                          "Smokebraider",
                          "Smash to Smithereens",
                          "Skarrgan Firebird",
                          "Moonlit Strider",
                          "Inner-Flame Igniter",
                          "Incandescent Soulstoke",
                          "Hellkite Charger",
                          "Mighty Leap",
                          "Gut Shot",
                          "Kor Duelist",
                          "Gorehorn Minotaurs",
                          "Goblin War Paint",
                          "Kami of Ancient Law",
                          "Fiery Fall",
                          "Fortify",
                          "Dragonsoul Knight",
                          "Combust",
                          "Court Homunculus",
                          "Burst Lightning",
                          "Conclave Phalanx",
                          "Brute Force",
                          "Celestial Purge",
                          "Bloodshot Trainee",
                          "Battlegrace Angel",
                          "Blood Ogre",
                          "Arrest",
                          "Blades of Velis Vel",
                          "Apostle's Blessing",
                          "Banefire",
                          "Ant Queen",
                          "Nobilis of War",
                          "Niv-Mizzet, the Firemind",
                          "Mirror Entity",
                          "Wilt-Leaf Liege",
                          "Elesh Norn, Grand Cenobite",
                          "Comet Storm",
                          "Sunforger",
                          "Simic Growth Chamber",
                          "Orzhov Basilica",
                          "Mortarpod",
                          "Dread Drone",
                          "Izzet Boilerworks",
                          "Golgari Rot Farm",
                          "Selesnya Sanctuary",
                          "Rakdos Carnarium",
                          "Boros Garrison",
                          "Gruul Turf",
                          "Mystic Snake",
                          "Dimir Aqueduct",
                          "Azorius Chancery",
                          "Necroskitter",
                          "Remand",
                          "Tezzeret the Seeker",
                          "Mulldrifter",
                          "Kiki-Jiki, Mirror Breaker",
                          "Scion of the Wild",
                          "Nest Invader",
                          "Ghost Council of Orzhova",
                          "Nameless Inversion",
                          "Thief of Hope",
                          "Waxmane Baku",
                          "Hikari, Twilight Guardian",
                          "Wildfire",
                          "Blinkmoth Nexus",
                          "Creakwood Liege",
                          "Horde of Notions",
                          "Indomitable Archangel",
                          "Surgical Extraction",
                          "Dispatch",
                          "Leyline of Sanctity",
                          "Etched Oracle",
                          "Ulamog, the Infinite Gyre",
                          "Etched Monstrosity",
                          "Kozilek's Predator",
                          "All Suns' Dawn",
                          "Eye of Ugin",
                          "Eldrazi Temple",
                          "Shadowmage Infiltrator",
                          "Artisan of Kozilek",
                          "Hurkyl's Recall",
                          "Apocalypse Hydra",
                          "Iona, Shield of Emeria",
                          "All Is Dust",
                          "Fulminator Mage",
                          "Lightning Bolt",
                          "Bitterblossom",
                          "Swans of Bryn Argoll",
                          "Kozilek, Butcher of Truth",
                          "Mirran Crusader",
                          "Primeval Titan",
                          "Cranial Plating",
                          "Rusted Relic",
                          "Bloodthrone Vampire",
                          "Endrek Sahr, Master Breeder",
                          "Dismember",
                          "Stormblood Berserker",
                          "Vampire Lacerator",
                          "Goblin Fireslinger",
                          "Daybreak Coronet",
                          "Spellskite",
                          "Noble Hierarch",
                          "Cryptic Command",
                          "Profane Command",
                          "Mox Opal",
                          "Splinter Twin",
                          "Dark Confidant",
                          "Vendilion Clique",
                          "Karn Liberated",
                          "Tarmogoyf",
                          "Emrakul, the Aeons Torn",
                          "Etched Champion"]

        spreds = []
        spred = SearchPredicate()
        spred.term = 'format'
        spred.value = self.cur_format.id
        spreds.append(spred)
        spred_n = SearchPredicate()
        spred_n.term = 'name'
        spred_n.value = random.choice(mm2_card_names)
        spreds.append(spred_n)
        sd = SortDirective()
        sd.term = 'cardrating'
        sd.direction = sd.DESC
        sd.crs_format_id = self.cur_format.id
        spreds.append(sd)
        card_list = Card.playables.search(spreds)

        self.first_card = card_list[0]
        fc_cr = CardRating.objects.filter(physicalcard=self.first_card.basecard.physicalcard, format=self.cur_format, test__id=1).first()
        #sys.stderr.write("first card is {}\n".format(self.first_card.basecard.name))
        #sys.stderr.write("first card rating sigma {}, mu {} \n".format(fc_cr.sigma, fc_cr.mu))

        spreds2 = []
        spred = SearchPredicate()
        spred.term = 'format'
        spred.value = self.cur_format.id
        spreds2.append(spred)

        spred_u = SearchPredicate()
        spred_u.term = 'cardrating'
        spred_u.operator = SearchPredicate.LESS_THAN
        spred_u.value = 20.0 * (fc_cr.mu + (1.0 * fc_cr.sigma))
        spreds2.append(spred_u)

        spred_l = SearchPredicate()
        spred_l.term = 'cardrating'
        spred_l.operator = SearchPredicate.GREATER_THAN
        spred_l.value = 20.0 * (fc_cr.mu - (1.0 * fc_cr.sigma))
        spreds2.append(spred_l)

        spred_n = SearchPredicate()
        spred_n.term = 'name'
        spred_n.negative = True
        spred_n.value = self.first_card.basecard.name
        spreds2.append(spred_n)
        #sys.stderr.write("spreds2 is {}\n".format(str(spreds2)))
        for sp in spreds2:
            #sys.stderr.write("spreds2: {} {} {}\n".format(sp.term, sp.operator, sp.value))
            pass
        card_list2 = Card.playables.search(spreds2)
        act_list = list()
        for cccc in card_list2:
            #sys.stderr.write("cccc is {}\n".format(cccc.basecard.filing_name))
            act_list.append(cccc)
        self.comp_card = random.choice(act_list)
예제 #3
0
    def __init__(self):
        cur_formats = Format.objects.filter(
            formatname='Origins',
            start_date__lte=datetime.today(),
            end_date__gte=datetime.today()).order_by('format')
        format_count = len(list(cur_formats))
        format_index = int(random.random() * format_count)
        self.cur_format = cur_formats[format_index]

        #ori_cards = Card.objects.filter(expansionset_id=187)
        #ori_card_names = [x.basecard.name for x in ori_cards]

        spreds = []
        spred = SearchPredicate()
        spred.term = 'format'
        spred.value = self.cur_format.id
        spreds.append(spred)
        #spred_n = SearchPredicate()
        #spred_n.term = 'name'
        #spred_n.value = random.choice(ori_card_names)
        # spreds.append(spred_n)
        sd = SortDirective()
        sd.term = 'cardrating'
        sd.direction = sd.DESC
        sd.crs_format_id = self.cur_format.id
        spreds.append(sd)
        card_list = Card.playables.search(spreds)

        self.first_card = card_list[0]
        fc_cr = CardRating.objects.filter(physicalcard=self.first_card.basecard.physicalcard, format=self.cur_format, test__id=1).first()
        #sys.stderr.write("first card is {}\n".format(self.first_card.basecard.name))
        #sys.stderr.write("first card rating sigma {}, mu {} \n".format(fc_cr.sigma, fc_cr.mu))

        spreds2 = []
        spred = SearchPredicate()
        spred.term = 'format'
        spred.value = self.cur_format.id
        spreds2.append(spred)

        spred_u = SearchPredicate()
        spred_u.term = 'cardrating'
        spred_u.operator = SearchPredicate.LESS_THAN
        spred_u.value = 20.0 * (fc_cr.mu + (1.0 * fc_cr.sigma))
        spreds2.append(spred_u)

        spred_l = SearchPredicate()
        spred_l.term = 'cardrating'
        spred_l.operator = SearchPredicate.GREATER_THAN
        spred_l.value = 20.0 * (fc_cr.mu - (1.0 * fc_cr.sigma))
        spreds2.append(spred_l)

        spred_n = SearchPredicate()
        spred_n.term = 'name'
        spred_n.negative = True
        spred_n.value = self.first_card.basecard.name
        spreds2.append(spred_n)
        #sys.stderr.write("spreds2 is {}\n".format(str(spreds2)))
        for sp in spreds2:
            #sys.stderr.write("spreds2: {} {} {}\n".format(sp.term, sp.operator, sp.value))
            pass
        card_list2 = Card.playables.search(spreds2)
        act_list = list()
        for cccc in card_list2:
            #sys.stderr.write("cccc is {}\n".format(cccc.basecard.filing_name))
            act_list.append(cccc)
        self.comp_card = random.choice(act_list)