def press(self): if (self.nameOfProfession.text == "" or self.description.text == "" or self.availableFor.text == "" or self.primaryStatistics.text == "" or self.secondaryStatistics.text == "" or self.equipment.text == "" or self.weapon.text == "" or self.armor.text == ""): Popup.display_error('Please fill all of the blank spots') elif (len(self.primaryStatistics.text) != 16 or len(self.secondaryStatistics.text) != 16): Popup.display_error('Wrong format in one of the boxes') else: data = { 'name': self.nameOfProfession.text, 'description': self.description.text, 'availableFor': self.availableFor.text, 'primaryStatistics': self.primaryStatistics.text, 'secondaryStatistics': self.secondaryStatistics.text, 'equipment': self.equipment.text, 'weapon': self.weapon.text, 'armor': self.armor.text } Handler.push_data(data, 'Professions') self.clearInputBoxes()
def set_data(data, name, child: str): try: db.child(child.capitalize()).child(name.capitalize()).set(data) return True except: Popup.display_error("Something went wrong") return False
def push_data(data, child: str): try: db.child(child.capitalize()).push(data) return True except: Popup.display_error("Something went wrong") return False
def get_data(child: str): items = [] try: database = db.child(child.capitalize()).get() for entity in database.each(): items.append(entity.val()) except: Popup.display_error("Something went wrong") return items
def press(self): if self.nameOfSex.text == "": Popup.display_error('Please fill all of the blank spots') else: data = {'name': self.nameOfSex.text} Handler.push_data(data, 'Sex') self.clearInputBoxes()
def filledCorrectly(self): for entity in self.form(): if entity.text == '' \ or entity.text == 'Gender' \ or entity.text == 'Race' \ or entity.text == 'Star sign': Popup.display_info("Please fill all input boxes") return False else: pass return True
def update_data(data, name: str, child: str): try: database = db.child(child.capitalize()).get() for entity in database.each(): if (entity.val()['name'] == name.lower()): db.child(child.capitalize()).child(entity.key()).update(data) return True return False except: Popup.display_error("Something went wrong") return False
def delete_data(item, child: str): try: database = db.child(child.capitalize()).get() for entity in database.each(): if item == entity.val(): print("BOOM") db.child(child.capitalize()).child(entity.key()).remove() return True return False except: Popup.display_error("Something went wrong") return False
def press(self): if (self.nameOfStarSign.text == "" or self.description.text == ""): Popup.display_error('Please fill all of the blank spots') else: data = { 'name': self.nameOfStarSign.text, 'description': self.description.text } Handler.push_data(data, 'StarSigns') self.clearInputBoxes()
def login(self, email, password): try: self.user = auth.sign_in_with_email_and_password(email, password) Popup.display_info("You have successfully signed in!") return True except requests.HTTPError as e: error_json = e.args[1] error = json.loads(error_json)['error']['message'] if error == "INVALID_EMAIL": Popup.display_error("Invalid email input") if error == "MISSING_PASSWORD": Popup.display_error("Please input a password") if error == "INVALID_PASSWORD": Popup.display_error("Invalid password input") return False
def press(self): if (self.nameOfRace.text == "" or self.description.text == "" or self.primaryStatistics.text == "" or self.secondaryStatistics.text == "" or self.fpRoll.text == "" or self.wRoll.text == ""): Popup.display_error('Please fill all of the blank spots') elif (len(self.primaryStatistics.text) != 16 or len(self.secondaryStatistics.text) != 16 or len(self.wRoll.text) != 8 or len(self.fpRoll.text) != 3): Popup.display_error('Wrong format in one of the boxes') else: data = { 'name': self.nameOfRace.text, 'description': self.description.text, 'primaryStatistics': self.primaryStatistics.text, 'secondaryStatistics': self.secondaryStatistics.text, 'wRoll': self.wRoll.text, 'fpRoll': self.fpRoll.text } Handler.push_data(data, 'Races') self.clearInputBoxes()
def press(self): if self.filledCorrectly(): data = { 'name': self.manager.screens[3].nameOfCharacter.text, 'age': self.manager.screens[3].age.text, 'weight': self.manager.screens[3].weight.text, 'eye_colour': self.manager.screens[3].eyeColour.text, 'hair_colour': self.manager.screens[3].hairColour.text, 'race': self.manager.screens[3].race.text, 'origin': self.manager.screens[3].origin.text, 'sex': self.manager.screens[3].sex.text, 'star_sign': self.manager.screens[3].starSign.text, 'primary_statistics': self.manager.screens[4].primary_statistics, 'secondary_statistics': self.manager.screens[4].secondary_statistics, 'profession': self.profession.text, 'equipment': self.equipment.text, 'weapon': self.weapon.text, 'armor': self.armor.text } if self.manager.account.user == None: data["userUID"] = "" Popup.display_info("Character created successfully!") else: data["userUID"] = self.manager.account.getUID() Popup.display_info("Character created successfully!\n" "You can now download it in your\n" "account management screen!") Handler.push_data(data, 'Character') self.manager.screens[3].clearBoxes() self.manager.screens[4].clearBoxes() self.clearBoxes() self.manager.transition.direction = "up" self.manager.current = "Main" else: Popup.display_info('Please choose a desired profession')
def register(self, email, password, password_confirm): try: if password == password_confirm: auth.create_user_with_email_and_password(email, password) Popup.display_info( "Registration was successful! You can try to log in now") return True else: Popup.display_error("Invalid password confirmation") return False except requests.HTTPError as e: error_json = e.args[1] error = json.loads(error_json)['error']['message'] if error == "EMAIL_EXISTS": Popup.display_error("Email already exist") if error == "INVALID_EMAIL": Popup.display_error("Invalid email input") if error == "MISSING_PASSWORD": Popup.display_error("Please input a password") if error == "WEAK_PASSWORD : Password should be at least 6 characters": Popup.display_error("Your password is too weak") if error == "INVALID_PASSWORD": Popup.display_error("Invalid password input") return False
def downloadChar(self, entity, *args): self.manager.creatorpdf.createPDF(entity) Popup.display_info( "Character has been\ndownloaded as pdf\nin to your program\nlocation" )
def deleteChar(self, entity, *args): Handler.delete_data(entity, "Character") Popup.display_info("Character has been deleted") self.refresh()
def filledCorrectly(self): if (self.primary_statistics == "" or self.secondary_statistics == ""): Popup.display_info("Please roll for your character statistics") return False else: return True