def init_page():
    check_visit()
    pages = ['Table', 'Config']  # , 'About', 'Changelog']
    for c, page in enumerate(pages):
        doc['buttons'] <= BUTTON(
            page,
            data_id=page,
            Class=f'page{" current_tab" if not c else ""}',
            Id=f'b_{page}')
        if c:
            doc['pages'] <= SECTION(Id=page)
            doc[page].style.display = 'none'
    init_options()
    init_table()
    #	init_about()
    #	init_change()
    doc["loading"].style.display = "none"

    # Make it so navigation buttons work
    @bind('.page', 'click')
    def change_page(ev):
        val = ev.target['data-id']
        # currently unable to create an event to trigger the template
        if val == 'Table':
            doc.getElementById('nav_target').click()
        doc[val].style.display = 'block'
        doc[f'b_{val}'].attrs['class'] = 'current_tab page'
        idx = pages.index(val)
        for i in pages[:idx] + pages[idx + 1:]:
            doc[i].style.display = 'none'
            doc[f'b_{i}'].attrs['class'] = 'page'
예제 #2
0
def init_page():
	create_league_list()
	create_base_list()
	pages = ['Main', 'Weights', 'Flags', 'About', 'Changelog']
	for c, page in enumerate(pages):
		doc['buttons'] <= BUTTON(page, data_id=page, Class=f'page{" current_tab" if not c else ""}', Id=f'b_{page}')
		doc['pages'] <= SECTION(Id=page)
		if c:
			doc[page].style.display = 'none'

	data = [('includeDelve', 'Include Precursor Emblem mods'), ('NoSearingImplicitMods', 'Ignore Searing Exarch only Implicit Mods'), ('NoTangledImplicitMods', 'Ignore Eater of Worlds only Implicit Mods'), ('NoSynthImplicitMods', 'Ignore Synth only Implicit Mods'), ('NoCorruptImplicitMods', 'Ignore Corruption only Implicit Mods'), ('NoImplicitMods', 'Ignore All Implicit Mods including corrupt and synth'), ('PseudoMods', 'Use PseudoMods in Search'), ('IgnoreCastSpeed', 'Set Cast Speed Weight to 0'), ('IgnoreAttackSpeed', 'Set Attack Speed Weight to 0')]  # ('NoCraftedMods', 'Ignore Crafted Mods'),
	t = make_table(data, 1, 'ignore')
	doc['searchflags'] <= STRONG('Options:') + ' choices that affect type of returned mods' + BR() + t + BR()

	init_about()
	init_flags()
	init_change()

	doc["query"].style.display = "none"
	doc["notice"].style.display = "none"
	doc["414by"].style.display = "none"
	b_generate = BUTTON("Generate Query")
	b_generate.bind("click", generate_query)
	doc["generate"] <= b_generate
	process_querystring()
	init_main()
	doc["loading"].style.display = "none"

	# Make it so navigation buttons work
	@bind('.page', 'click')
	def change_page(ev):
		val = ev.target['data-id']
		if val == 'Main':
			init_main()
		doc[val].style.display = 'block'
		doc[f'b_{val}'].attrs['class'] = 'current_tab page'
		idx = pages.index(val)
		for i in pages[:idx] + pages[idx+1:]:
			doc[i].style.display = 'none'
			doc[f'b_{i}'].attrs['class'] = 'page'
예제 #3
0
def init_information():
	order_index = [x[1] for x in ingame_order]
	data = {k: set() for k in order_index}
	char_data = {}
	# iterate all the characters and add items they need to data
	for character in characters:
		char_data[character] = set()
		for field in characters[character]:
			# keys with subkeys
			if field in ['ascension', 'talent']:
				for key in characters[character][field]:
					val = characters[character][field][key]
					if val in data:
						data[val].add(character)
						char_data[character].add(val)
			else:
				val = characters[character][field]
				if val in data:
					data[val].add(character)
					char_data[character].add(val)
	trav_data = {}
	# do the same thing for traveler talents
	for tal_group in traveler:
		trav_data[tal_group] = set()
		for row in traveler[tal_group]:
			for field in row:
				trav_data[tal_group].add(row[field])
	for t_char in traveler_talent:
		char_data[t_char] = set()
		for talent in traveler_talent[t_char]:
			for item in trav_data[talent]:
				data[item].add(t_char)
				char_data[t_char].add(item)
	# create a table with the character->item dictionary we just built
	t_chars = TABLE(TR(TH(strings["character"]) + TH(strings["item_s"])), Class='borders body')
	for char in sorted(char_data):
		item_set = {}
		for item in char_data[char]:
			if item in strings:
				i_idx = order_index.index(item)
				if isinstance(strings[item], list):
					c = len(strings[item]) - 1
					item_set[i_idx] = [f"{item}_{c}", strings[item][c]]
				else:
					item_set[i_idx] = [item, strings[item]]
		i = (IMG(src=f"img/{item_set[x][0]}.png", alt=item_set[x][1], title=item_set[x][1], loading="lazy") for x in sorted(item_set))
		c = IMG(src=f"img/{char}.png", alt=strings[char], title=strings[char], loading="lazy")
		t_chars <= TR(TD(c) + TD(i))
	# create a table with the item->character dictionary we just built
	t_items = TABLE(TR(TH(strings["item_s"]) + TH(strings["character_s"])), Class='borders body')
	for typ, item in ingame_order:
		if item in data:
			if data[item]:  # only show items used by a character
				if isinstance(strings[item], list):
					i = (IMG(src=f"img/{item}_{c}.png", alt=strings[item][c], title=strings[item][c], loading="lazy") for c in range(len(strings[item])))
				else:
					i = IMG(src=f"img/{item}.png", alt=strings[item], title=strings[item], loading="lazy")
				c = (IMG(src=f"img/{x}.png", alt=strings[x], title=strings[x], loading="lazy") for x in sorted(data[item]))
				t_items <= TR(TD(i) + TD(c))

	doc['information'] <= SECTION(P(strings['character_mats']) + t_chars + BR()+ BR() + t_items, Class='grind')
예제 #4
0
def update_character():
    char_tracker = {}
    for val in grind_table_state['total']:
        grind_table_state['total'][val] = 0
    for char in grind_table_state['checked']:
        update_per_character(char, char_tracker)

    # Get a list of all chosen artifacts so we know what to farm
    for elt in doc.get(selector=f'.saved_arti'):
        char = elt.id.split('-')[1]
        if char in grind_table_state['checked'] and char in grind_table_state[
                'arti_check']:
            add_value_set(char_tracker,
                          elt.id.split('-')[-1],
                          elt.id.split('-')[1])

    # adjust xp totals to units of their base type.
    grind_table_state['total']['mora'] += grind_table_state['total'][
        'xp'] // 5 + grind_table_state['total']['wep_xp'] // 10
    grind_table_state['total']['xp'] = round(
        grind_table_state['total']['xp'] / 20000, 2)
    grind_table_state['total']['wep_xp'] = round(
        grind_table_state['total']['wep_xp'] / 10000, 2)

    # Build up and display farm table
    data = {
        'any': {
            0: {},
            20: {},
            40: {},
            60: {}
        },
        'mon': {},
        'tue': {},
        'wed': {},
        'thu': {},
        'fri': {},
        'sat': {},
        'sun': {},
    }
    resin = {
        'stormterror': 60,
        'wolf_of_the_north': 60,
        'golden_house': 60,
        'azhdaha': 60,
        '60_boss': 60,
        '40_boss': 40,
        'anemo_hypostasis': 40,
        'cryo_regisvine': 40,
        'cryo_hypostasis': 40,
        'electro_hypostasis': 40,
        'geo_hypostasis': 40,
        'oceanid': 40,
        'pyro_regisvine': 40,
        'primo_geovishap': 40,
        'maguu_kenki': 40,
        'pyro_hypostasis': 40,
        'perpetual_mechanical_array': 40,
        'clear_pool_and_mountain_cavern': 20,
        'domain_of_guyun': 20,
        'hidden_palace_of_zhou_formula': 20,
        'midsummer_courtyard': 20,
        'valley_of_remembrance': 20,
        'peak_of_vindagnyr': 20,
        'court_of_flowing_sand': 20,
        'violet_court': 20,
        'momiji_dyed_court': 20,
        'ridge_watch': 20,
        'xp_leyline': 20,
        'mora_leyline': 20
    }
    arti_keys = [('arti', x) for x in char_tracker if x not in ingame_order]
    for section, item in [('base', 'xp'), ('base', 'wep_xp'),
                          ('base', 'mora')] + ingame_order + arti_keys:
        if item in char_tracker:
            for day in farming_data[item]['when']:
                for loc in farming_data[item]['where']:
                    if day == 'any':
                        cost = 0 if loc not in resin else resin[loc]
                        if loc not in data[day][cost]:
                            data[day][cost][loc] = []
                        data[day][cost][loc].append(item)
                    else:
                        if loc not in data[day]:
                            data[day][loc] = []
                        data[day][loc].append(item)

    d = SECTION(Class='grind')
    for day in ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']:
        d <= H2([strings[day]])
        t = TABLE(TR(
            TH(strings["location"]) + TH(strings["item_s"]) +
            TH(strings["character_s"])),
                  Class='borders body')
        empty = True
        for loc in sorted(data[day]):
            char_set = set()
            item_set = {}
            for x in data[day][loc]:
                if isinstance(strings[x], str) and grind_table_state['total'][
                        x] - grind_table_state['user'][x] > 0:
                    char_set.update(char_tracker[x])
                    item_set[x] = {
                        'text':
                        strings[x],
                        'count':
                        readable_number(grind_table_state['total'][x] -
                                        grind_table_state['user'][x])
                    }
                else:
                    for i in range(len(strings[x])):
                        if grind_table_state['total'][
                                f"{x}_{i}"] - grind_table_state['user'][
                                    f"{x}_{i}"] > 0:
                            char_set.update(char_tracker[x])
                            item_set[f"{x}_{i}"] = {
                                'text':
                                strings[x][i],
                                'count':
                                readable_number(
                                    grind_table_state['total'][f"{x}_{i}"] -
                                    grind_table_state['user'][f"{x}_{i}"])
                            }
            if item_set:
                empty = False
                v = (DIV(IMG(src=f"img/{x}.png",
                             alt=item_set[x]['text'],
                             title=item_set[x]['text'],
                             loading="lazy") +
                         DIV(item_set[x]['count'], Class='bottom-right'),
                         Class='container') for x in item_set)
                c = (IMG(src=f"img/{x}.png",
                         alt=strings[x],
                         title=strings[x],
                         loading="lazy") for x in sorted(char_set))
                t <= TR(TD(strings[loc], Class="location") + TD(v) + TD(c))
        if empty:
            t <= TR(
                TD(strings['nothing'], Class="location") +
                TD(strings['nothing']) + TD(strings['nothing']))
        d <= t
    if any([data['any'][x] for x in [0, 20, 40, 60]]):
        d <= H2([strings['any']])
        for cost in [0, 20, 40, 60]:
            if data['any'][cost]:
                d <= H3(f"{cost} {strings['resin']}")
                t = TABLE(TR(
                    TH(strings["location"]) + TH(strings["item_s"]) +
                    TH(strings["character_s"])),
                          Class='borders body')
                for loc in sorted(data['any'][cost]):
                    char_set = set()
                    item_set = {}
                    for x in data['any'][cost][loc]:
                        if isinstance(strings[x], str):
                            if x in grind_table_state['total']:
                                if 'xp' == x:
                                    val = int(grind_table_state['total'][x] -
                                              grind_table_state['user'][x] -
                                              grind_table_state['user']
                                              [f"{x}_sub_1"] / 4 -
                                              grind_table_state['user']
                                              [f"{x}_sub_0"] / 20 + .5)
                                elif 'wep_xp' == x:
                                    val = int(grind_table_state['total'][x] -
                                              grind_table_state['user'][x] -
                                              grind_table_state['user']
                                              [f"{x}_sub_1"] / 5 -
                                              grind_table_state['user']
                                              [f"{x}_sub_0"] / 25 + .5)
                                else:
                                    val = grind_table_state['total'][
                                        x] - grind_table_state['user'][x]

                                if val > 0:
                                    if x in ['xp', 'wep_xp', 'mora'
                                             ] and len(char_tracker[x]) > 5:
                                        char_set.add('many')
                                    else:
                                        char_set.update(char_tracker[x])
                                    item_set[x] = {
                                        'text': strings[x],
                                        'count': readable_number(val)
                                    }
                            else:
                                char_set.update(char_tracker[x])
                                item_set[x] = {'text': strings[x], 'count': ''}
                        else:
                            for i in range(len(strings[x])):
                                if grind_table_state['total'][
                                        f"{x}_{i}"] - grind_table_state[
                                            'user'][f"{x}_{i}"] > 0:
                                    char_set.update(char_tracker[x])
                                    item_set[f"{x}_{i}"] = {
                                        'text':
                                        strings[x][i],
                                        'count':
                                        readable_number(
                                            grind_table_state['total']
                                            [f"{x}_{i}"] -
                                            grind_table_state['user']
                                            [f"{x}_{i}"])
                                    }
                    if item_set:
                        v = (DIV(
                            IMG(src=f"img/{x}.png",
                                alt=item_set[x]['text'],
                                title=item_set[x]['text'],
                                loading="lazy") +
                            DIV(item_set[x]['count'], Class='bottom-right'),
                            Class='container') for x in item_set)
                        c = (IMG(src=f"img/{x}.png",
                                 alt=strings[x],
                                 title=strings[x],
                                 loading="lazy") for x in sorted(char_set))
                        t <= TR(
                            TD(strings[loc], Class="location") + TD(v) + TD(c))
                d <= t

    doc['daily'].text = ''
    doc['daily'] <= d