import numpy as np import pandas as pd import math import sys import os print(os.getcwd()) # Ctrl-Alt-N to run code in VSCode rarity = {'Legendary': '', 'Epic': '', 'Rare': '', 'Uncommon': '', 'Common': '', 'Quest': '', 'Grove Staff': '<#f558b4>', 'Admin Staff': ''} rarity_sub = {'Legendary': '', 'Epic': '', 'Rare': '', 'Uncommon': '', 'Common': '', 'Quest': '', 'Grove Staff': '<#f50a93>', 'Admin Staff': ''} # Replace filename with whatever the downloaded entry form sheet is called filename = 'ItemEntry.csv' df = pd.DataFrame() df = pd.read_csv(filename) df.drop_duplicates(subset=['Item Name', 'Item Lore', 'What Crate is this Item meant for?']) # New header line df.columns = ['timestamp', 'rarity', 'name', 'lore', 'itemtype', 'ARROW_DAMAGE', 'ARROW_FIRE', 'ARROW_INFINITE', 'ARROW_KNOCKBACK', 'BINDING_CURSE', 'CHANNELING', 'DAMAGE_ALL', 'DAMAGE_ARTHROPODS', 'DAMAGE_UNDEAD', 'DEPTH_STRIDER', 'DIG_SPEED', 'DURABILITY', 'FIRE_ASPECT', 'FROST_WALKER', 'IMPALING', 'KNOCKBACK', 'LOOT_BONUS_BLOCKS', 'LOOT_BONUS_MOBS', 'LOYALTY', 'LUCK', 'LURE', 'MENDING', 'MULTISHOT', 'OXYGEN', 'PIERCING', 'PROTECTION_ENVIRONMENTAL', 'PROTECTION_EXPLOSIONS', 'PROTECTION_FALL', 'PROTECTION_FIRE', 'PROTECTION_PROJECTILE', 'QUICK_CHARGE', 'RIPTIDE', 'SILK_TOUCH', 'SOUL_SPEED', 'SWEEPING_EDGE', 'SWIFT_SNEAK', 'THORNS', 'VANISHING_CURSE', 'WATER_WORKER', 'crate', 'seasonal', 'seasonaltype', 'amount', 'trim', 'trimtype', 'trimmat'] df = df.replace(np.nan, '') print(df) daily = df[df["crate"] == "Daily Crate"] weekly = df[df["crate"] == "Weekly Crate"] quest = df[df["crate"] == "Quest Crate"] enchant_map = {'ARROW_DAMAGE': 'power', 'ARROW_FIRE': 'flame', 'ARROW_INFINITE': 'infinity', 'ARROW_KNOCKBACK': 'punch', 'BINDING_CURSE': 'binding_curse', 'CHANNELING': 'channeling', 'DAMAGE_ALL': 'sharpness', 'DAMAGE_ARTHROPODS': 'bane_of_arthropods', 'DAMAGE_UNDEAD': 'smite', 'DEPTH_STRIDER': 'depth_strider', 'DIG_SPEED': 'efficiency', 'DURABILITY': 'unbreaking', 'FIRE_ASPECT': 'fire_aspect', 'FROST_WALKER': 'frost_walker', 'IMPALING': 'impaling', 'KNOCKBACK': 'knockback', 'LOOT_BONUS_BLOCKS': 'fortune', 'LOOT_BONUS_MOBS': 'looting', 'LOYALTY': 'loyalty', 'LUCK': 'luck_of_the_sea', 'LURE': 'lure', 'MENDING': 'mending', 'MULTISHOT': 'multishot', 'OXYGEN': 'respiration', 'PIERCING': 'piercing', 'PROTECTION_ENVIRONMENTAL': 'protection', 'PROTECTION_EXPLOSIONS': 'blast_protection', 'PROTECTION_FALL': 'feather_falling', 'PROTECTION_FIRE': 'fire_protection', 'PROTECTION_PROJECTILE': 'projectile_protection', 'QUICK_CHARGE': 'quick_charge', 'RIPTIDE': 'riptide', 'SILK_TOUCH': 'silk_touch', 'SOUL_SPEED': 'soul_speed', 'SWEEPING_EDGE': 'sweeping_edge', 'SWIFT_SNEAK': 'swift_sneak', 'THORNS': 'thorns', 'VANISHING_CURSE': 'vanishing_curse', 'WATER_WORKER': 'aqua_affinity' } old_names = ['ARROW_DAMAGE', 'ARROW_FIRE', 'ARROW_INFINITE', 'ARROW_KNOCKBACK', 'BINDING_CURSE', 'CHANNELING', 'DAMAGE_ALL', 'DAMAGE_ARTHROPODS', 'DAMAGE_UNDEAD', 'DEPTH_STRIDER', 'DIG_SPEED', 'DURABILITY', 'FIRE_ASPECT', 'FROST_WALKER', 'IMPALING', 'KNOCKBACK', 'LOOT_BONUS_BLOCKS', 'LOOT_BONUS_MOBS', 'LOYALTY', 'LUCK', 'LURE', 'MENDING', 'MULTISHOT', 'OXYGEN', 'PIERCING', 'PROTECTION_ENVIRONMENTAL', 'PROTECTION_EXPLOSIONS', 'PROTECTION_FALL', 'PROTECTION_FIRE', 'PROTECTION_PROJECTILE', 'QUICK_CHARGE', 'RIPTIDE', 'SILK_TOUCH', 'SOUL_SPEED', 'SWEEPING_EDGE', 'SWIFT_SNEAK', 'THORNS', 'VANISHING_CURSE', 'WATER_WORKER'] # Write Header (Daily Crate) with open('tdvc.yml', 'w') as f: f.write("Crate:\n CrateType: CSGO\n CrateName: 'Daily Vote Crate'\n Preview-Name: 'Daily Vote Crate Preview'\n StartingKeys: 0\n InGUI: false\n Slot: 13\n OpeningBroadCast: False\n BroadCast: '* %Player% is opening a Daily Vote Crate! (/vote)'\n Item: 'CHEST'\n Glowing: false\n Name: 'Daily Vote Crate'\n Lore:\n - 'This crate contains strange objects.'\n - 'You have %Keys% keys to open this crate with.'\n - '(!) Right click to view rewards.'\n") f.write(" PhysicalKey:\n Name: 'Daily Vote Crate Key'\n DisplayLore:\n - 'Vote on 5 sites every day!'\n - 'Unlock this crate at spawn.'\n Item: 'tripwire_hook'\n Glowing: True\n Prizes:\n") # Prizes for index, row in daily.iterrows(): f.write(" " + str(index + 1) + ":\n") if row['name'] == '': f.write(" DisplayName: ''\n") else: f.write(" DisplayName: '" + str(rarity[row['rarity']]) + row['name'].replace("'", "''") + "'\n") f.write(" DisplayItem: '" + row['itemtype'].lower() + "'\n") if row['trim'] == 'Yes': f.write(" DisplayTrim:\n Material: '" + row['trimmat'] + "'\n Pattern: '" + row['trimtype'] + "'\n") if row['name'] == '': f.write(" DisplayAmount: " + str(int(row['amount'])) + "\n DisplayLore:\n - '" + str(rarity_sub[row['rarity']]) + "Win some " + row['itemtype'].replace("_", " ").title().lower() + "'\n") else: f.write(" DisplayAmount: " + str(int(row['amount'])) + "\n DisplayLore:\n - '" + str(rarity_sub[row['rarity']]) + "Win the " + row['name'].replace("'", "''") + "'\n") f.write(" MaxRange: 75\n Chance: 1\n Firework: false\n Glowing: false\n Player: ''\n Unbreakable: false\n Items:\n - 'Item:" + row['itemtype'].lower() + ", Amount:" + str(int(row['amount']))) if row['trim'] == 'Yes': f.write(", Trim-Material:" + row['trimmat'] + ", Trim-Pattern:" + row['trimtype']) if row['name'] == '': f.write("") else: f.write(", Name:" + str(rarity[row['rarity']]) + row['name'].replace("'", "''") + ", Lore:") if row['name'] == '': f.write("") else: if "," in row['lore']: f.write("MANUAL LORE PLEASE") else: f.write(str(rarity_sub[row['rarity']]) + row['lore'].replace("'", "''")) idx = pd.IndexSlice enchants = row[old_names] enchants.replace('', np.nan, inplace=True) enchants = enchants.apply(pd.to_numeric, errors='ignore', downcast='integer') enchants.dropna(how='all', inplace=True) enchants = enchants.rename(index=enchant_map) for label, content in enchants.items(): f.write(", " + label + ":" + str(int(content))) f.write( "'\n BlackListed-Permissions: {}\n Alternative-Prize:\n Toggle: false\n Messages: {}\n Commands: {}\n Items: {}\n") # Write Header (Weekly Crate) with open('twvc.yml', 'w') as f: f.write("Crate:\n CrateType: CSGO\n CrateName: 'Weekly Vote Crate'\n Preview-Name: 'Weekly Vote Crate Preview'\n StartingKeys: 0\n InGUI: false\n Slot: 15\n OpeningBroadCast: False\n BroadCast: '* %Player% is opening a Weekly Vote Crate! (/vote)'\n Item: 'CHEST'\n Glowing: false\n Name: 'Weekly Vote Crate'\n DisplayLore:\n - 'Vote 36 times in a week gets a key.'\n - 'You have %Keys% keys to open this crate with.'\n - '(!) Right click to view rewards.'\n") f.write(" PhysicalKey:\n Name: 'Weekly Vote Crate Key'\n DisplayLore:\n - 'Vote 36 times in a week gets a key.'\n - 'Unlock this crate at spawn.'\n Item: 'tripwire_hook'\n Glowing: True\n Prizes:\n") # Prizes for index, row in weekly.iterrows(): f.write(" " + str(index + 1) + ":\n") if row['name'] == '': f.write(" DisplayName: ''\n") else: f.write(" DisplayName: '" + str(rarity[row['rarity']]) + row['name'].replace("'", "''") + "'\n") f.write(" DisplayItem: '" + row['itemtype'].lower() + "'\n") if row['trim'] == 'Yes': f.write(" DisplayTrim:\n Material: '" + row['trimmat'] + "'\n Pattern: '" + row['trimtype'] + "'\n") if row['name'] == '': f.write(" DisplayAmount: " + str(int(row['amount'])) + "\n DisplayLore:\n - '" + str(rarity_sub[row['rarity']]) + "Win some " + row['itemtype'].replace("_", " ").title().lower() + "'\n") else: f.write(" DisplayAmount: " + str(int(row['amount'])) + "\n DisplayLore:\n - '" + str(rarity_sub[row['rarity']]) + "Win the " + row['name'].replace("'", "''") + "'\n") f.write(" MaxRange: 75\n Chance: 1\n Firework: false\n Glowing: false\n Player: ''\n Unbreakable: false\n Items:\n - 'Item:" + row['itemtype'].lower() + ", Amount:" + str(int(row['amount']))) if row['trim'] == 'Yes': f.write(", Trim-Material:" + row['trimmat'] + ", Trim-Pattern:" + row['trimtype']) if row['name'] == '': f.write("") else: f.write(", Name:" + str(rarity[row['rarity']]) + row['name'].replace("'", "''") + ", Lore:") if row['name'] == '': f.write("") else: if "," in row['lore']: f.write("MANUAL LORE PLEASE") else: f.write(str(rarity_sub[row['rarity']]) + row['lore'].replace("'", "''")) idx = pd.IndexSlice enchants = row[old_names] enchants.replace('', np.nan, inplace=True) enchants = enchants.apply(pd.to_numeric, errors='ignore', downcast='integer') enchants.dropna(how='all', inplace=True) enchants = enchants.rename(index=enchant_map) for label, content in enchants.iteritems(): f.write(", " + label + ":" + str(int(content))) f.write( "'\n BlackListed-Permissions: {}\n Alternative-Prize:\n Toggle: false\n Messages: {}\n Commands: {}\n Items: {}\n") # Write Header (Quest Crate) with open('tqvc.yml', 'w') as f: f.write( "Crate:\n CrateType: CSGO\n CrateName: 'Quest Crate'\n Preview-Name: 'Quest Crate Preview'\n StartingKeys: 0\n InGUI: false\n Slot: 13\n OpeningBroadCast: False\n BroadCast: '* %Player% is opening a Quest Crate! (/vote)'\n Item: 'CHEST'\n Glowing: false\n Name: 'Quest Crate'\n DisplayLore:\n - 'This crate contains strange objects.'\n - 'You have %Keys% keys to open this crate with.'\n - '(!) Right click to view rewards.'\n") f.write( " PhysicalKey:\n Name: 'Quest Crate Key'\n Lore:\n - 'Complete a daily quest from Scruff!'\n - 'Unlock this crate at spawn.'\n Item: 'tripwire_hook'\n Glowing: True\n Prizes:\n") # Prizes for index, row in quest.iterrows(): f.write(" " + str(index + 1) + ":\n") if row['name'] == '': f.write(" DisplayName: ''\n") else: f.write(" DisplayName: '" + str(rarity[row['rarity']]) + row['name'].replace("'", "''") + "'\n") f.write(" DisplayItem: '" + row['itemtype'].lower() + "'\n") if row['trim'] == 'Yes': f.write(" DisplayTrim:\n Material: '" + row['trimmat'] + "'\n Pattern: '" + row['trimtype'] + "'\n") if row['name'] == '': f.write(" DisplayAmount: " + str(int(row['amount'])) + "\n DisplayLore:\n - '" + str(rarity_sub[row['rarity']]) + "Win some " + row['itemtype'].replace("_", " ").title().lower() + "'\n") else: f.write(" DisplayAmount: " + str(int(row['amount'])) + "\n DisplayLore:\n - '" + str(rarity_sub[row['rarity']]) + "Win the " + row['name'].replace("'", "''") + "'\n") f.write(" MaxRange: 75\n Chance: 1\n Firework: false\n Glowing: false\n Player: ''\n Unbreakable: false\n Items:\n - 'Item:" + row['itemtype'].lower() + ", Amount:" + str(int(row['amount']))) if row['trim'] == 'Yes': f.write(", Trim-Material:" + row['trimmat'] + ", Trim-Pattern:" + row['trimtype']) if row['name'] == '': f.write("") else: f.write(", Name:" + str(rarity[row['rarity']]) + row['name'].replace("'", "''") + ", Lore:") if row['name'] == '': f.write("") else: if "," in row['lore']: f.write("MANUAL LORE PLEASE") else: f.write(str(rarity_sub[row['rarity']]) + row['lore'].replace("'", "''")) idx = pd.IndexSlice enchants = row[old_names] enchants.replace('', np.nan, inplace=True) enchants = enchants.apply(pd.to_numeric, errors='ignore', downcast='integer') enchants.dropna(how='all', inplace=True) enchants = enchants.rename(index=enchant_map) for label, content in enchants.items(): f.write(", " + label + ":" + str(int(content))) f.write( "'\n BlackListed-Permissions: {}\n Alternative-Prize:\n Toggle: false\n Messages: {}\n Commands: {}\n Items: {}\n")