cc_config_creator/config_creator_v2.py
Teriuihi 208f039554 Update rarity names, item names, and enchantments mapping
Rarity and item names in the code have been updated to the new names crazy crates needs. Enchantments are now mapped from the old names to the new ones. Additionally we switched from & color codes to minimessage colors.
2024-07-05 18:14:27 +02:00

221 lines
14 KiB
Python

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': '<gold>', 'Epic': '<light_purple>',
'Rare': '<dark_aqua>', 'Uncommon': '<green>', 'Common': '<white>', 'Quest': '<red>', 'Grove Staff': '<#f558b4>', 'Admin Staff': '<dark_red>'}
rarity_sub = {'Legendary': '<red>', 'Epic': '<dark_purple>',
'Rare': '<blue>', 'Uncommon': '<dark_green>', 'Common': '<gray>', 'Quest': '<gray>', 'Grove Staff': '<#f50a93>', 'Admin Staff': '<red>'}
# 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: '<yellow><b>Daily Vote Crate'\n Preview-Name: '<yellow><b>Daily Vote Crate Preview'\n StartingKeys: 0\n InGUI: false\n Slot: 13\n OpeningBroadCast: False\n BroadCast: '<yellow>* %Player% <yellow>is opening a <gold>Daily Vote Crate<yellow>! (/vote)'\n Item: 'CHEST'\n Glowing: false\n Name: '<yellow>Daily Vote Crate'\n Lore:\n - '<gray>This crate contains strange objects.'\n - '<gray>You have <gold>%Keys% keys <gray>to open this crate with.'\n - '<gray><b>(<yellow><b>!<gray><b>) Right click to view rewards.'\n")
f.write(" PhysicalKey:\n Name: '<red>Daily Vote Crate Key'\n DisplayLore:\n - '<gray>Vote on 5 sites every day!'\n - '<gray>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: '<aqua><b>Weekly Vote Crate'\n Preview-Name: '<aqua><b>Weekly Vote Crate Preview'\n StartingKeys: 0\n InGUI: false\n Slot: 15\n OpeningBroadCast: False\n BroadCast: '<dark_aqua>* %Player% <dark_aqua>is opening a <aqua>Weekly Vote Crate<dark_aqua>! (/vote)'\n Item: 'CHEST'\n Glowing: false\n Name: '<aqua>Weekly Vote Crate'\n DisplayLore:\n - '<gray>Vote 36 times in a week gets a key.'\n - '<gray>You have <aqua>%Keys% keys <gray>to open this crate with.'\n - '<gray><b>(<aqua><b>!<gray><b>) Right click to view rewards.'\n")
f.write(" PhysicalKey:\n Name: '<red>Weekly Vote Crate Key'\n DisplayLore:\n - '<gray>Vote 36 times in a week gets a key.'\n - '<gray>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: '<yellow><b>Quest Crate'\n Preview-Name: '<yellow><b>Quest Crate Preview'\n StartingKeys: 0\n InGUI: false\n Slot: 13\n OpeningBroadCast: False\n BroadCast: '<yellow>* %Player% <yellow>is opening a <gold>Quest Crate<yellow>! (/vote)'\n Item: 'CHEST'\n Glowing: false\n Name: '<yellow>Quest Crate'\n DisplayLore:\n - '<gray>This crate contains strange objects.'\n - '<gray>You have <gold>%Keys% keys <gray>to open this crate with.'\n - '<gray><b>(<yellow><b>!<gray><b>) Right click to view rewards.'\n")
f.write(
" PhysicalKey:\n Name: '<red>Quest Crate Key'\n Lore:\n - '<gray>Complete a daily quest from Scruff!'\n - '<gray>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")