Beispiel #1
0
def test_equality():
    item0 = models.Item(0)
    assert item0 == item0

    item1 = models.Item(1)
    assert item0 != item1

    item1_copy = models.Item(1)
    assert item1 == item1_copy
Beispiel #2
0
def test_champion_specific():
    champion_specific = [
        ('Gangplank', "Death's Daughter"),
        ('Gangplank', 'Fire at Will'),
        ('Gangplank', 'Raise Morale'),
        ('Kalista', 'The Black Spear'),
        ('Viktor', 'Prototype Hex Core'),
        ('Viktor', 'The Hex Core mk-1'),
        ('Viktor', 'The Hex Core mk-2'),
        ('Viktor', 'Perfect Hex Core'),
    ]

    for c, n in champion_specific:
        assert models.Item(0, name=n).champion == c

    normalItem = models.Item(0, name='Boots of Swiftness')
    assert not normalItem.champion
Beispiel #3
0
def run():
    args = docopt.docopt(__doc__, version='0.3.2', argv=sys.argv[1:])

    if args['datascience']:
        return data_science.run(args['<name>'])

    if args['info']:
        if args['--champ']:
            name = args['--champ'].lower()
            champ = api.get_champ(name)[0]
            champ = models.Champion(champ['id'], champ['key'], champ['name'])
            champ.dump()
        elif args['--item']:
            name = args['--item'].lower()
            item = api.get_item(name)[0]
            item = models.Item(item['id'], item['name'])
            item.dump()

        return

    if args['isg']:
        if args['--write']:
            path = args['--path']
            if not path:
                path = output.get_base_dir()

            print('> writing item sets to {}'.format(path))
            champ_dir = output.build_path(path)

        name = None
        if args['--champ']:
            name = args['--champ'].lower()

        champs = api.get_champ(name)
        items = groups.all_()
        for c in sorted(champs, key=lambda x: x['name']):
            champ = models.Champion(c['id'], c['key'], c['name'])
            sources.champion_gg(champ)
            for role in champ.roles:
                item_set = isg.item_set(champ, role, items)
                if args['--write']:
                    # TODO: concurrent:
                    # with concurrent.futures.ProcessPoolExecutor() as exec:
                    #     results = exec.map(main, isg.get_all_champions())
                    # for result in results:
                    #     print('\033[92mok:\033[00m', result.name)
                    data_set = isg.encode.item_set(*item_set)
                    output.to_file(champ_dir, champ, role, data_set)
                    continue

                output.to_screen(champ, role, item_set)

            if args['--write']:
                print('\033[92mok:\033[00m', champ.name)
Beispiel #4
0
def dorans():
    return [
        models.Item('1054', "Doran's Shield"),
        models.Item('1055', "Doran's Blade"),
        models.Item('1056', "Doran's Ring"),
        models.Item('1083', 'Cull'),
        models.Item('2051', "Guardian's Horn"),
        models.Item('3112', "Guardian's Orb"),
        models.Item('3184', "Guardian's Hammer"),
    ]
Beispiel #5
0
def boots():
    return [
        # models.Item('1001', 'Boots of Speed'),
        models.Item('3006', "Berserker's Greaves"),
        models.Item('3009', 'Boots of Swiftness'),
        models.Item('3020', "Sorcerer's Shoes"),
        models.Item('3047', 'Ninja Tabi'),
        models.Item('3111', 'Mercury Treads'),
        models.Item('3117', 'Boots of Mobility'),
        models.Item('3158', 'Ionian Boots of Lucidity'),
    ]
Beispiel #6
0
def champion_gg(champ):
    BUILD = '.col-md-7 .build-wrapper a img'
    ROLES = '.champion-profile ul li a h3'
    STARTS = '.col-md-5 .build-wrapper a img'

    url = 'http://champion.gg/champion/{}'.format(champ.key)
    resp = requests.get(url)
    soup = bs4.BeautifulSoup(resp.text, 'html.parser')

    champ.roles = common.dedup(
        champ.roles +
        [models.Role(x.text.strip()) for x in soup.select(ROLES)])

    for role in champ.roles:
        url = 'http://champion.gg/champion/{}/{}'.format(champ.key, role.name)
        resp = requests.get(url)
        soup = bs4.BeautifulSoup(resp.text, 'html.parser')

        champ.builds[role] += [
            models.Item(x['data-id']) for x in soup.select(BUILD)
        ]
        champ.starts[role] += [
            models.Item(x['data-id']) for x in soup.select(STARTS)
        ]
Beispiel #7
0
    def __init__(self, game_minutes=30):
        self.times = list(range(game_minutes * 60 + 1))

        self._adc_farm_rate = 0.85  # ADC gets n% of farm
        self._ranged_support = True
        self._support_farm_rate = 0.7  # Support hits relic shield at n% speed
        self._support_item_lag = 50  # Amount of extra gold when upgrading
        self._support_poke_rate = 0.75  # Support pokes at n% speed

        self.map = models.Map(11)  # SR
        self.lane = models.Lane('bot')

        self.other_items = 50  # pot
        self.item_blue = models.Item(3303)
        self.item_blue_upgrade = models.Item(3098)
        self.item_green = models.Item(3302)
        self.item_green_upgrade = models.Item(3097)
        self.item_yellow = models.Item(3301)
        self.item_yellow_upgrade = models.Item(3096)

        self._passive_gold = []
        self._blue = []
        self._green = []
        self._yellow = []

        self.line_blue = None
        self.line_green = None
        self.line_yellow = None

        import matplotlib.pyplot as plot
        self.plot = plot
        self.axes = None

        self.update_passive_gold()
        self.update_blue()
        self.update_green()
        self.update_yellow()
Beispiel #8
0
def enchantments():
    return [
        models.Item('1400', 'Enchantment: Warrior'),
        models.Item('1401', 'Enchantment: Cinderhulk'),
        models.Item('1402', 'Enchantment: Runic Echoes'),
        models.Item('1408', 'Enchantment: Warrior'),
        models.Item('1409', 'Enchantment: Cinderhulk'),
        models.Item('1410', 'Enchantment: Runic Echoes'),
        models.Item('1412', 'Enchantment: Warrior'),
        models.Item('1413', 'Enchantment: Cinderhulk'),
        models.Item('1414', 'Enchantment: Runic Echoes'),
        models.Item('1416', 'Enchantment: Bloodrazer'),
        models.Item('1418', 'Enchantment: Bloodrazer'),
        models.Item('1419', 'Enchantment: Bloodrazer'),
        models.Item('3671', 'Enchantment: Warrior'),
        models.Item('3672', 'Enchantment: Cinderhulk'),
        models.Item('3673', 'Enchantment: Runic Echoes'),
        models.Item('3675', 'Enchantment: Bloodrazor'),
    ]
Beispiel #9
0
def all_():
    return [models.Item(x['id'], x['name']) for x in api.get_item()]
Beispiel #10
0
def consumables():
    return [
        models.Item('2003', 'Health Potion'),
        # models.Item('2009', 'Total Biscuit of Rejuvenation'),
        # models.Item('2010', 'Total Biscuit of Rejuvenation'),
        models.Item('2055', 'Control Ward'),
        models.Item('2031', 'Refillable Potion'),
        # models.Item('2032', "Hunter's Potion"),
        # models.Item('2033', 'Corrupting Potion'),
        models.Item('2043', 'Vision Ward'),
        models.Item('2047', "Oracle's Extract"),
        # models.Item('2050', "Explorer's Ward"),  # removed in S4
        models.Item('3340', 'Warding Trinket'),
        models.Item('3341', 'Sweeping Lens'),
        models.Item('3363', 'Farsight Alteration'),
        models.Item('3364', 'Oracle Alteration'),
        models.Item('2138', 'Elixir of Iron'),
        models.Item('2139', 'Elixir of Sorcery'),
        models.Item('2140', 'Elixir of Wrath'),
    ]
Beispiel #11
0
def biscuits():
    return [
        models.Item('2009', 'Total Biscuit of Rejuvenation'),
        models.Item('2010', 'Total Biscuit of Rejuvenation'),
    ]
Beispiel #12
0
def test_repr():
    assert str(models.Item(99, name='Testing Helm')) == '[99 - Testing Helm]'