Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
Added dictionaries, functions, main and classes files.
  • Loading branch information
trwstin authored Feb 11, 2021
1 parent 71a82cb commit f3bb543
Show file tree
Hide file tree
Showing 4 changed files with 293 additions and 0 deletions.
69 changes: 69 additions & 0 deletions classes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import random
from dictionaries import *

class Artifact:
def __init__(self, name, slot, mainStat, subStat):
self.name = name
self.slot = slot
self.mainStat = mainStat
self.mainStatValue = 0
self.subStat = subStat
self.enhances = 0

def enhance_counter(self):
self.enhances += 4

def upgrade_mainStat(self):
for mainStat in mainStat_upgrades.keys():
if self.mainStat == mainStat:
index = round(self.enhances/4)
mainStatValue = mainStat_upgrades.get(self.mainStat).split(',')[index]
self.mainStatValue = '{:,.2f}'.format(mainStatValue)

def add_stat(self):
statList = [*substats_dict.keys()]
currentStat = [i.split(':')[0] for i in self.subStat]
newStat = random.choice([i for i in statList if i not in currentStat])
newStatValue = random.choice(substats_dict.get(newStat).split(','))

self.subStat.append(newStat + ': ' + newStatValue)
self.enhance_counter()
self.upgrade_mainStat()
print(f"\nYour artifact has been enhanced with a new substat, {newStat}!\n"
f"{self.subStat}")

def upgrade_stat(self):
index = 0
upgradedStat = random.choice(self.subStat).split(':')[0]
upgradedValue = random.choice(substats_dict.get(upgradedStat).split(','))

for stat in self.subStat:
statName = stat.split(':')[0]
if upgradedStat == statName:
oldStatValue = stat.split(': ')[1]
newStatValue = round(float(oldStatValue.replace('%', ''))
+ float(upgradedValue.replace('%', '')), 1)
enhancement = statName + ': ' + str(newStatValue).replace('.0', '')
if '%' in statName:
enhancement += '%'
self.subStat.insert(index, enhancement)
self.subStat.pop(index + 1)
index += 1

self.enhance_counter()
self.upgrade_mainStat()
print(f"\nYour artifact\'s {upgradedStat} has been successfully enhanced!\n"
f"{self.subStat}")

def enhance(self):
if self.enhances >= 20:
print("\nThis artifact has reached the maximum number of enhancements.")
elif len(self.subStat) == 3:
self.add_stat()
elif self.enhances < 20:
self.upgrade_stat()

def __repr__(self):
return f'A +{self.enhances} {self.name} {self.slot}, ' \
f'with {self.mainStat} Main Stat value of {self.mainStatValue}' \
f'and the following Sub Stats: {self.subStat}'
45 changes: 45 additions & 0 deletions dictionaries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
artifact_types = ['Flower', 'Feather', 'Timepiece', 'Goblet', 'Circlet']

artifact_sets = {'1': 'Thundering Fury,Thundersoother',
'2': 'Viridescent Venerer,Maiden\'s Beloved',
'3': 'Archaic Petra,Retracing Bolide',
'4': 'Crimson Witch of Flames,Lavawalker',
'5': 'Noblesse Oblige,Bloodstained Chivalry',
'6': 'Blizzard Strayer,Heart of Depth'}

mainstat_dict = {'Flower': 'HP',
'Feather': 'ATK',
'Timepiece': 'HP%,DEF%,ATK%,Elemental Mastery,Energy Recharge %',
'Goblet': 'HP%,DEF%,ATK%,Elemental Mastery,Physical Damage %'
'Hydro Damage %,Cryo Damage %,Pyro Damage %,Electro Damage %,Geo Damage %,Anemo Damage %',
'Circlet': 'HP%,DEF%,ATK%,Elemental Mastery,'
'Crit Rate %,Crit Damage %,Healing Bonus %'}

substats_dict = {"ATK": "14,16,18,19",
"ATK%": "4.1,4.7,5.3,5.8",
"HP": "209,239,269,299",
"HP%": "4.1,4.7,5.3,5.8",
"DEF": "16,19,21,23",
'DEF%': "5.1,5.8,6.6,7.3",
'CDMG': "5.4,6.2,7,7.8",
'CR': "2.7,3.1,3.5,3.9",
'ER': "4.5,5.2,5.8,6.5",
'EM': "16,19,21,23"}

mainStat_upgrades = {'HP': '717,1530,2342,3155,3967,4780',
'ATK': '47,100,152,205,258,311',
'HP%': '7.0,14.9,22.8,30.8,38.7,46.6',
'ATK%': '7.0,14.9,22.8,30.8,38.7,46.6',
'DEF%': '8.7,18.6,28.6,38.5,48.4,58.3',
'Physical Damage %': '8.7,18.6,28.6,38.5,48.4,58.3',
'Elemental Mastery': '28,60,91,123,155,187',
'Energy Recharge %': '7.8,16.6,25.4,34.2,43.0,51.8',
'Crit Rate %': '4.7,10.0,15.4,20.7,26.0,31.1',
'Crit Damage %': '9.3,19.9,30.5,41.1,51.6,62.2',
'Healing Bonus %': '5.4,11.5,17.6,23.7,29.8,34.4',
'Cryo Damage %': '7.0,14.9,22.8,30.8,38.7,46.6',
'Pyro Damage %': '7.0,14.9,22.8,30.8,38.7,46.6',
'Electro Damage %': '7.0,14.9,22.8,30.8,38.7,46.6',
'Anemo Damage %': '7.0,14.9,22.8,30.8,38.7,46.6',
'Hydro Damage %': '7.0,14.9,22.8,30.8,38.7,46.6',
'Geo Damage %': '7.0,14.9,22.8,30.8,38.7,46.6'}
175 changes: 175 additions & 0 deletions functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
import random
from classes import Artifact
from dictionaries import *

global inventory
inventory = {}


# convert numStats list to int
def listToInt(num):
s = ''.join(map(str, num))
return int(s)


# options menu
def menu():
print('\n---------- ARTIFACT SIMULATOR (SCUFFED) ----------\n'
'| 1. FARM ARTIFACTS |\n'
'| 2. ENHANCE ARTIFACTS |\n'
'| 3. VIEW INVENTORY |\n'
'| 4. EXIT SIMULATOR |\n'
'--------------------------------------------------\n')

while True:
try:
option = int(input('Select an option: '))
except (ValueError, TypeError, KeyError, IndexError):
print('\nPlease enter a valid option.\n')
else:
if option in range(1, 5):
if option == 1:
farm_artifact()
elif option == 2:
enhance_artifact()
elif option == 3:
view_artifacts()
menu()
else:
exit()
else:
print('\nPlease enter a valid option.\n')


# roll artifact set, type
def artifact_roll(domain):
sets = artifact_sets.get(domain).split(',')
artifact_set = random.choice(sets)
artifact_type = random.choice(artifact_types)
return [artifact_set, artifact_type]


# roll mainstat
def mainstat_roll(artifactType):
possible_main = mainstat_dict.get(artifactType).split(',')
return random.choice(possible_main)


# roll 4 substats
def substats_roll():
roll_list = []
numStats = random.choices([3, 4], [0.8, 0.2])
noOfStats = listToInt(numStats)
stats_rolled = random.sample([*substats_dict.keys()], int(noOfStats))

for stat in stats_rolled:
roll_values = substats_dict.get(stat).split(',')
value = random.choice(roll_values)
roll = stat + ": " + value
roll_list.append(roll)

return roll_list


# generates the artifact for the respective domain
def artifact_gen(domain):
artifact_index = len(inventory) + 1
artifactPiece = artifact_roll(str(domain))
mainStat = mainstat_roll(artifactPiece[1])
subStats = substats_roll()
artifact = Artifact(artifactPiece[0], artifactPiece[1], mainStat, subStats)

inventory[str(artifact_index)] = artifact

print('\n' + artifact.name +
"\nSlot: " + str(artifact.slot) +
"\nMain Stat: " + str(artifact.mainStat))
print(*[i for i in artifact.subStat], sep='\n')
continue_farm(domain)

# prompts to continue farming
def continue_farm(domain):
artifact_index = len(inventory) + 1
try:
print('\n=========== OPTIONS ===========: '
'\n1. Continue Farming this Domain'
'\n2. Farm Another Domain'
'\n3. Return to Menu')
continueFarm = str(input("\nSelect an Option: "))
except (ValueError, TypeError, KeyError, IndexError):
print('\nPlease enter a valid option.\n')
else:
if continueFarm == '1':
artifact_index += 1
artifact_gen(domain)
elif continueFarm == '2':
farm_artifact()
else:
print('\nYou have exited the domain!')
menu()


# consolidated function for artifacts farming
def farm_artifact():
while True:
print('\nAvailable Artifact Domains:\n'
'1. Midsummer Courtyard (TF, TS)\n'
'2. Valley of Remembrance (VV, MB)\n'
'3. Domain of Guyun (AP, RB)\n'
'4. Hidden Palace of Zhou Formula (CW, LW)\n'
'5. Clear Pool and Mountain Cavern (NO, BsC)\n'
'6. Peak of Vindagnyr (BS, HoD)\n')

try:
domain = int(input("Which domain no. would you like to farm?: "))
except (ValueError, TypeError, KeyError, IndexError):
print('\nPlease enter a valid option.\n')
else:
if domain in range(1, 7):
artifact_gen(domain)
continue_farm(domain)
else:
print('\nPlease enter a valid option.\n')


# view artifact inventory
def view_artifacts():
if bool(inventory) == False:
print('\nYour inventory is empty!')
else:
index = 1
for artifact in inventory.values():
print(str(index) + '. ' + str(artifact))
index += 1


# enhance selected artifact
def enhance_artifact():
view_artifacts()

while True:
try:
select_artifact = int(input('\nSelect which artifact you wish to enhance: '))
except (ValueError, TypeError, KeyError, IndexError):
print('\nPlease enter a valid option.\n')
else:
for key in inventory:
if str(select_artifact) == key:
artifact = inventory.get(key)
while True:
artifact.enhance()
print('\n=========== OPTIONS ===========: '
'\n1. Continue Enhancing this Artifact'
'\n2. Enhance Another Artifact'
'\n3. Return to Menu')
try:
continueEnhance = int(input('\nSelect an option: '))
except (ValueError, TypeError, KeyError, IndexError):
print('\nPlease enter a valid option.\n')
else:
if int(continueEnhance) == 1:
continue
elif int(continueEnhance) == 2:
enhance_artifact()
else:
menu()
4 changes: 4 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from functions import *

if __name__ == '__main__':
menu()

0 comments on commit f3bb543

Please sign in to comment.