|
|
@ -18,6 +18,14 @@ def get_character(): |
|
|
|
|
|
|
|
|
|
|
|
return chosen['id'], chosen['name'], chosen['file_id'], chosen['rarity'] |
|
|
|
return chosen['id'], chosen['name'], chosen['file_id'], chosen['rarity'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_float(val): |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
float(val) |
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
except ValueError: |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: See issue #3, separate command parsing from game logic. |
|
|
|
# TODO: See issue #3, separate command parsing from game logic. |
|
|
|
def gacha_response(command,full_user, arguments,note_obj): |
|
|
|
def gacha_response(command,full_user, arguments,note_obj): |
|
|
|
'''Parses a given command with arguments, processes the game state and |
|
|
|
'''Parses a given command with arguments, processes the game state and |
|
|
@ -34,7 +42,7 @@ def gacha_response(command,full_user, arguments,note_obj): |
|
|
|
|
|
|
|
|
|
|
|
add_pull(user_id,character_id) |
|
|
|
add_pull(user_id,character_id) |
|
|
|
stars = '⭐️' * rarity |
|
|
|
stars = '⭐️' * rarity |
|
|
|
return([f"@{full_user} 🎲 Congrats! You rolled **{character_name}** she's {stars} stars! She's all yours now~ 💖✨",[file_id]]) |
|
|
|
return([f"@{full_user} 🎲 Congrats! You rolled {stars} **{character_name}**\nShe's all yours now~ 💖✨",[file_id]]) |
|
|
|
|
|
|
|
|
|
|
|
if command == "create": |
|
|
|
if command == "create": |
|
|
|
# Example call from bot logic |
|
|
|
# Example call from bot logic |
|
|
@ -42,6 +50,15 @@ def gacha_response(command,full_user, arguments,note_obj): |
|
|
|
if not image_url: |
|
|
|
if not image_url: |
|
|
|
return "You need an image to create a character, dumbass." |
|
|
|
return "You need an image to create a character, dumbass." |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(arguments) != 3: |
|
|
|
|
|
|
|
return "Please specify the following attributes in order: name, rarity, drop weighting" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not (arguments[1].isnumeric() and 1 <= int(arguments[1]) <= 5): |
|
|
|
|
|
|
|
return f"Invalid rarity: '{arguments[1]}' must be a number between 1 and 5" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not (is_float(arguments[2]) and 0.0 < float(arguments[2]) <= 1.0): |
|
|
|
|
|
|
|
return f"Invalid drop weight: '{arguments[2]}' must be a decimal value between 0.0 and 1.0" |
|
|
|
|
|
|
|
|
|
|
|
character_id, file_id = add_character( |
|
|
|
character_id, file_id = add_character( |
|
|
|
name=arguments[0], |
|
|
|
name=arguments[0], |
|
|
|
rarity=int(arguments[1]), |
|
|
|
rarity=int(arguments[1]), |
|
|
|