diff --git a/main.py b/old version/main.py similarity index 97% rename from main.py rename to old version/main.py index 7a1348b..5c6bbf8 100644 --- a/main.py +++ b/old version/main.py @@ -1,188 +1,188 @@ -import random -import os -import re -# import termcolor -import time -from starwalkers.func import roll, got_let_int, get_int_ship, get_d_sym, get_cost - -# from termcolor import colored, cprint - -print("WELCOME TO STARWALKERS!") -time.sleep(0.8) -print("Version: 0.2") -# 10-20=1 21-70=2 71-120=3 121-200=4 201-259=5 - -let_list = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", - "V", "W", "X", "Y", "Z"] -summ_w = len(let_list) -summ_all = int() -a = int() -for i in range(summ_w): - b = let_list[i] - a = i + 1 - summ_all += a - # print(b, summ_all) -ran = int() -fi = -1 -# print(summ_all) -# priti = str() -# infi = 0 -# while priti != "A-9999": -# priti = roll() -# infi += 1 -# print(infi) -# zina = input() -clear = lambda: os.system('cls') -money = 30 -user_case = 0 -ship_list = [] -name = str(input("Enter your name: ")) -name_txt = name + ".txt" -try: - filename = open(name_txt, "r") - file_cont = filename.readlines() - lines = len(filename.readlines()) - money = int(re.sub(r"[\n]", "", file_cont[0])) - user_case = int(re.sub(r"[\n]", "", file_cont[1])) - for j in range(len(file_cont) - 2): - ship_list.append(re.sub(r"[\n]", "", file_cont[j + 2])) - filename.close() - print("Lines:", lines) -except FileNotFoundError: - filename = open(name_txt, "w") - filename.write("30\n") - filename.write("0") - filename.close() - print("Registered:", name) - - -def save(): - filename = open(name_txt, "w") - filename.write(str(money) + "\n") - filename.write(str(user_case)) - for k in range(len(ship_list)): - filename.write("\n" + ship_list[k - 1]) - filename.close() - - -clear() - -while True: - print("You have " + str(money) + "$ and " + str(user_case) + " cases.") - user_input = input("Menu:\n1. Case menu\n2. Collection\n3. Fight\n4. Exit\n>>> ") - if user_input == "1": - clear() - user_input2 = input("What do you want to do with cases?\n1. Buy\n2. Open\n3. Close\n>>> ") - if user_input2 == "1": - clear() - user_input3 = int(input("How much? (10$/case)")) - if money >= 10 * user_input3: - money -= 10 * user_input3 - user_case += user_input3 - clear() - print("Thanks for buying", user_input3, "cases.") - save() - input_enter = input("Press ENTER to continue... ") - else: - print("Not enough money, bro.") - input_enter = input("Press ENTER to continue... ") - if user_input2 == "2": - if user_case >= 1 and len(ship_list) < 10: - user_case -= 1 - gotter = roll() - ship_list.append(gotter) - # print(ship_list) - clear() - gotter_letter, gotter_int = gotter.split("-") - cost = (got_let_int(gotter_letter) * int(gotter_int)) // 1000 - print("You got:", gotter + "! It costs: " + str(cost) + ", and its rank: " + get_d_sym(cost) + "!") - save() - input_enter = input("Press ENTER to continue... ") - elif len(ship_list) == 10: - clear() - print("You have too many ships. Sell one and you can open cases again.") - input_enter = input("Press ENTER to continue... ") - if user_input == "2": - clear() - print("Your collection of ships:") - for zzz in range(len(ship_list)): - time.sleep(0.1) - print(str(zzz + 1) + ") " + str(ship_list[zzz]) + " " + get_d_sym(get_cost(ship_list[zzz]))) - coll_input = input("Type nothing to exit or type '1' to open Sell Menu") - if coll_input == "1": - coll_input1 = int(input("Write a number of ship that you want to sell: ")) - s_cost = get_cost(ship_list[coll_input1 - 1]) // 2 - s_name = ship_list[coll_input1 - 1] - ship_list.pop(coll_input1 - 1) - money += s_cost - save() - print("Your ship " + str(s_name) + " was sold and you got " + str(s_cost) + "$!") - input_enter = input("Press ENTER to continue... ") - if user_input == "3": - clear() - enemy_rand = random.randint(1, 3) - enemy_list = [] - for en_i in range(enemy_rand): - roll_en = roll() - enemy_list.append(roll_en) - while len(enemy_list) != 0 and len(ship_list) != 0: - clear() - print("Your enemies:") - for en_i1 in range(len(enemy_list)): - print(str(en_i1 + 1) + ". " + enemy_list[en_i1 - 1]) - time.sleep(0.8) - print( - "You will be fighting with: " + str(enemy_list[0]) + " " + str(get_d_sym(get_cost(str(enemy_list[0]))))) - print("Choose your ship to attack:") - for i_non in range(len(ship_list)): - print(str(i_non + 1) + ") " + ship_list[i_non] + " " + str(get_d_sym(get_cost(ship_list[i_non])))) - t_user_input = input(">>> ") - player_cost = 0 - enemy_cost = 0 - try: - user_input = int(t_user_input) - except ValueError: - print("You've written wrong number. Try again.") - # user_input = 123456 - input_enter = input("Press ENTER to continue... ") - if isinstance(user_input, int): - if len(ship_list) >= user_input > 0: - player_ship = ship_list[user_input - 1] - player_let, player_int = player_ship.split("-") - ship_list.pop(user_input - 1) - player_cost = get_cost(player_ship) - - enemy_ship = enemy_list[0] - enemy_cost = get_cost(enemy_ship) - elif user_input == 0: - print("You left the battlefield") - enemy_list.clear() - input_enter = input("Press ENTER to continue... ") - else: - print("You do not have ship with choosed number.") - input_enter = input("Press ENTER to continue... ") - if player_cost != 0 and enemy_cost != 0: - if player_cost > enemy_cost: - print("You won and got: " + str(enemy_cost // 2) + "$!") - damage = random.randint(0, 30) - time_player_int = int(player_int) - fin_player_int = time_player_int - damage - player_int = get_int_ship(fin_player_int) - new_ship = str(player_let) + str(player_int) - ship_list.append(new_ship) - print("Your ship has taken " + str(damage) + " damage. Now it is " + str(new_ship) + ".") - money += enemy_cost // 2 - enemy_list.pop(0) - save() - input_enter = input("Press ENTER to continue... ") - - else: - print("You've lost your ship! Be careful next time!)") - save() - input_enter = input("Press ENTER to continue... ") - else: - print() - if user_input == "4": - break - else: - clear() +import random +import os +import re +# import termcolor +import time +from starwalkers.func import roll, got_let_int, get_int_ship, get_d_sym, get_cost + +# from termcolor import colored, cprint + +print("WELCOME TO STARWALKERS!") +time.sleep(0.8) +print("Version: 0.2") +# 10-20=1 21-70=2 71-120=3 121-200=4 201-259=5 + +let_list = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", + "V", "W", "X", "Y", "Z"] +summ_w = len(let_list) +summ_all = int() +a = int() +for i in range(summ_w): + b = let_list[i] + a = i + 1 + summ_all += a + # print(b, summ_all) +ran = int() +fi = -1 +# print(summ_all) +# priti = str() +# infi = 0 +# while priti != "A-9999": +# priti = roll() +# infi += 1 +# print(infi) +# zina = input() +clear = lambda: os.system('cls') +money = 30 +user_case = 0 +ship_list = [] +name = str(input("Enter your name: ")) +name_txt = name + ".txt" +try: + filename = open(name_txt, "r") + file_cont = filename.readlines() + lines = len(filename.readlines()) + money = int(re.sub(r"[\n]", "", file_cont[0])) + user_case = int(re.sub(r"[\n]", "", file_cont[1])) + for j in range(len(file_cont) - 2): + ship_list.append(re.sub(r"[\n]", "", file_cont[j + 2])) + filename.close() + print("Lines:", lines) +except FileNotFoundError: + filename = open(name_txt, "w") + filename.write("30\n") + filename.write("0") + filename.close() + print("Registered:", name) + + +def save(): + filename = open(name_txt, "w") + filename.write(str(money) + "\n") + filename.write(str(user_case)) + for k in range(len(ship_list)): + filename.write("\n" + ship_list[k - 1]) + filename.close() + + +clear() + +while True: + print("You have " + str(money) + "$ and " + str(user_case) + " cases.") + user_input = input("Menu:\n1. Case menu\n2. Collection\n3. Fight\n4. Exit\n>>> ") + if user_input == "1": + clear() + user_input2 = input("What do you want to do with cases?\n1. Buy\n2. Open\n3. Close\n>>> ") + if user_input2 == "1": + clear() + user_input3 = int(input("How much? (10$/case)")) + if money >= 10 * user_input3: + money -= 10 * user_input3 + user_case += user_input3 + clear() + print("Thanks for buying", user_input3, "cases.") + save() + input_enter = input("Press ENTER to continue... ") + else: + print("Not enough money, bro.") + input_enter = input("Press ENTER to continue... ") + if user_input2 == "2": + if user_case >= 1 and len(ship_list) < 10: + user_case -= 1 + gotter = roll() + ship_list.append(gotter) + # print(ship_list) + clear() + gotter_letter, gotter_int = gotter.split("-") + cost = (got_let_int(gotter_letter) * int(gotter_int)) // 1000 + print("You got:", gotter + "! It costs: " + str(cost) + ", and its rank: " + get_d_sym(cost) + "!") + save() + input_enter = input("Press ENTER to continue... ") + elif len(ship_list) == 10: + clear() + print("You have too many ships. Sell one and you can open cases again.") + input_enter = input("Press ENTER to continue... ") + if user_input == "2": + clear() + print("Your collection of ships:") + for zzz in range(len(ship_list)): + time.sleep(0.1) + print(str(zzz + 1) + ") " + str(ship_list[zzz]) + " " + get_d_sym(get_cost(ship_list[zzz]))) + coll_input = input("Type nothing to exit or type '1' to open Sell Menu") + if coll_input == "1": + coll_input1 = int(input("Write a number of ship that you want to sell: ")) + s_cost = get_cost(ship_list[coll_input1 - 1]) // 2 + s_name = ship_list[coll_input1 - 1] + ship_list.pop(coll_input1 - 1) + money += s_cost + save() + print("Your ship " + str(s_name) + " was sold and you got " + str(s_cost) + "$!") + input_enter = input("Press ENTER to continue... ") + if user_input == "3": + clear() + enemy_rand = random.randint(1, 3) + enemy_list = [] + for en_i in range(enemy_rand): + roll_en = roll() + enemy_list.append(roll_en) + while len(enemy_list) != 0 and len(ship_list) != 0: + clear() + print("Your enemies:") + for en_i1 in range(len(enemy_list)): + print(str(en_i1 + 1) + ". " + enemy_list[en_i1 - 1]) + time.sleep(0.8) + print( + "You will be fighting with: " + str(enemy_list[0]) + " " + str(get_d_sym(get_cost(str(enemy_list[0]))))) + print("Choose your ship to attack:") + for i_non in range(len(ship_list)): + print(str(i_non + 1) + ") " + ship_list[i_non] + " " + str(get_d_sym(get_cost(ship_list[i_non])))) + t_user_input = input(">>> ") + player_cost = 0 + enemy_cost = 0 + try: + user_input = int(t_user_input) + except ValueError: + print("You've written wrong number. Try again.") + # user_input = 123456 + input_enter = input("Press ENTER to continue... ") + if isinstance(user_input, int): + if len(ship_list) >= user_input > 0: + player_ship = ship_list[user_input - 1] + player_let, player_int = player_ship.split("-") + ship_list.pop(user_input - 1) + player_cost = get_cost(player_ship) + + enemy_ship = enemy_list[0] + enemy_cost = get_cost(enemy_ship) + elif user_input == 0: + print("You left the battlefield") + enemy_list.clear() + input_enter = input("Press ENTER to continue... ") + else: + print("You do not have ship with choosed number.") + input_enter = input("Press ENTER to continue... ") + if player_cost != 0 and enemy_cost != 0: + if player_cost > enemy_cost: + print("You won and got: " + str(enemy_cost // 2) + "$!") + damage = random.randint(0, 30) + time_player_int = int(player_int) + fin_player_int = time_player_int - damage + player_int = get_int_ship(fin_player_int) + new_ship = str(player_let) + str(player_int) + ship_list.append(new_ship) + print("Your ship has taken " + str(damage) + " damage. Now it is " + str(new_ship) + ".") + money += enemy_cost // 2 + enemy_list.pop(0) + save() + input_enter = input("Press ENTER to continue... ") + + else: + print("You've lost your ship! Be careful next time!)") + save() + input_enter = input("Press ENTER to continue... ") + else: + print() + if user_input == "4": + break + else: + clear() diff --git a/telegram_bot (not maintened)/Probabilities.xlsx b/old version/telegram_bot (not maintened)/Probabilities.xlsx similarity index 100% rename from telegram_bot (not maintened)/Probabilities.xlsx rename to old version/telegram_bot (not maintened)/Probabilities.xlsx diff --git a/telegram_bot (not maintened)/README_for_telegram_bot.md b/old version/telegram_bot (not maintened)/README_for_telegram_bot.md similarity index 100% rename from telegram_bot (not maintened)/README_for_telegram_bot.md rename to old version/telegram_bot (not maintened)/README_for_telegram_bot.md diff --git a/telegram_bot (not maintened)/requirements.txt b/old version/telegram_bot (not maintened)/requirements.txt similarity index 100% rename from telegram_bot (not maintened)/requirements.txt rename to old version/telegram_bot (not maintened)/requirements.txt diff --git a/telegram_bot (not maintened)/starwalkers/func.py b/old version/telegram_bot (not maintened)/starwalkers/func.py similarity index 100% rename from telegram_bot (not maintened)/starwalkers/func.py rename to old version/telegram_bot (not maintened)/starwalkers/func.py diff --git a/telegram_bot (not maintened)/starwalkers/keyboard.py b/old version/telegram_bot (not maintened)/starwalkers/keyboard.py similarity index 100% rename from telegram_bot (not maintened)/starwalkers/keyboard.py rename to old version/telegram_bot (not maintened)/starwalkers/keyboard.py diff --git a/telegram_bot (not maintened)/starwalkers/language/eng.py b/old version/telegram_bot (not maintened)/starwalkers/language/eng.py similarity index 100% rename from telegram_bot (not maintened)/starwalkers/language/eng.py rename to old version/telegram_bot (not maintened)/starwalkers/language/eng.py diff --git a/telegram_bot (not maintened)/starwalkers/language/fr.py b/old version/telegram_bot (not maintened)/starwalkers/language/fr.py similarity index 100% rename from telegram_bot (not maintened)/starwalkers/language/fr.py rename to old version/telegram_bot (not maintened)/starwalkers/language/fr.py diff --git a/telegram_bot (not maintened)/starwalkers/language/ru.py b/old version/telegram_bot (not maintened)/starwalkers/language/ru.py similarity index 100% rename from telegram_bot (not maintened)/starwalkers/language/ru.py rename to old version/telegram_bot (not maintened)/starwalkers/language/ru.py diff --git a/telegram_bot (not maintened)/starwalkers/probabilities_letter_player.json b/old version/telegram_bot (not maintened)/starwalkers/probabilities_letter_player.json similarity index 100% rename from telegram_bot (not maintened)/starwalkers/probabilities_letter_player.json rename to old version/telegram_bot (not maintened)/starwalkers/probabilities_letter_player.json diff --git a/telegram_bot (not maintened)/starwalkers/probabilities_number_player.json b/old version/telegram_bot (not maintened)/starwalkers/probabilities_number_player.json similarity index 100% rename from telegram_bot (not maintened)/starwalkers/probabilities_number_player.json rename to old version/telegram_bot (not maintened)/starwalkers/probabilities_number_player.json diff --git a/telegram_bot (not maintened)/starwalkers/settings.json b/old version/telegram_bot (not maintened)/starwalkers/settings.json similarity index 100% rename from telegram_bot (not maintened)/starwalkers/settings.json rename to old version/telegram_bot (not maintened)/starwalkers/settings.json diff --git a/telegram_bot (not maintened)/starwalkers/tree/branch.py b/old version/telegram_bot (not maintened)/starwalkers/tree/branch.py similarity index 100% rename from telegram_bot (not maintened)/starwalkers/tree/branch.py rename to old version/telegram_bot (not maintened)/starwalkers/tree/branch.py diff --git a/telegram_bot (not maintened)/starwalkers/tree/leaf.py b/old version/telegram_bot (not maintened)/starwalkers/tree/leaf.py similarity index 100% rename from telegram_bot (not maintened)/starwalkers/tree/leaf.py rename to old version/telegram_bot (not maintened)/starwalkers/tree/leaf.py diff --git a/telegram_bot (not maintened)/starwalkers/tree/query.py b/old version/telegram_bot (not maintened)/starwalkers/tree/query.py similarity index 100% rename from telegram_bot (not maintened)/starwalkers/tree/query.py rename to old version/telegram_bot (not maintened)/starwalkers/tree/query.py diff --git a/telegram_bot (not maintened)/starwalkers/tree/trunk.py b/old version/telegram_bot (not maintened)/starwalkers/tree/trunk.py similarity index 100% rename from telegram_bot (not maintened)/starwalkers/tree/trunk.py rename to old version/telegram_bot (not maintened)/starwalkers/tree/trunk.py diff --git a/telegram_bot (not maintened)/starwalkers/user_manager.py b/old version/telegram_bot (not maintened)/starwalkers/user_manager.py similarity index 100% rename from telegram_bot (not maintened)/starwalkers/user_manager.py rename to old version/telegram_bot (not maintened)/starwalkers/user_manager.py diff --git a/telegram_bot (not maintened)/starwalkers_telebot.py b/old version/telegram_bot (not maintened)/starwalkers_telebot.py similarity index 100% rename from telegram_bot (not maintened)/starwalkers_telebot.py rename to old version/telegram_bot (not maintened)/starwalkers_telebot.py diff --git a/starwalkers_streamlit.py b/starwalkers_streamlit.py index 5611a70..9fb54e3 100644 --- a/starwalkers_streamlit.py +++ b/starwalkers_streamlit.py @@ -219,37 +219,6 @@ def display_stars(grade): with col1.container(border=True): df, value_list = ID_card.ID_card(st.session_state.username) - # id_card.header(f"🧑🏽‍🚀 Captain {st.session_state.username}'s ID Card {display_stars(st.session_state.grade)}") - # - # id_card.subheader("Resources") - # colres1, colres2, colres3 = id_card.columns(3, gap="small") - # colres1.metric(f"💲 Money", f"{st.session_state.money}$") - # colres2.metric(f"💵 Money earned", f"{st.session_state.money_win}$") - # colres3.metric(f"🏷️ Money spent", f"{st.session_state.money_spent}$") - # - # id_card.subheader("Space Fleet") - # with id_card.expander(f"🚀 Space fleet capacity: {st.session_state.fleet_size} ships", expanded=True): - # if st.session_state.ship_list: - # for ship in json.loads(st.session_state.ship_list): - # ship_data.append( - # {"Ship": ship, "Value": get_d_sym(get_cost(ship)).replace('$', '💲'), "Sell": get_cost(ship)}) - # if get_d_sym(get_cost(ship)) not in value_list: - # value_list.append(get_d_sym(get_cost(ship))) - # if ship_data: - # df = pd.DataFrame(ship_data).sort_values(by="Sell", ascending=False) - # styled_df = df.style.set_table_styles( - # [ - # {'selector': 'th', 'props': [('max-width', '150px')]}, - # {'selector': 'td', 'props': [('max-width', '150px')]} - # ] - # ).set_properties(**{'text-align': 'left'}) - # st.dataframe(styled_df, use_container_width=True, hide_index=True) - # - # id_card.subheader("Battles") - # colbattle1, colbattle2, colbattle3 = id_card.columns(3, gap="small") - # colbattle1.metric(f"🏆 Win", f"{st.session_state.win}") - # colbattle2.metric(f"💥 Loose", f"{st.session_state.loose}") - # colbattle3.metric(f"⚖️ Win/Loss Ratio", f"{st.session_state.ratio_WL}") except Exception as e: col1.error(f"Problem with ID card: {e}") logging.exception(f"Error: {e}") diff --git a/telegram_bot (not maintened)/SECRETS.json b/telegram_bot (not maintened)/SECRETS.json deleted file mode 100644 index 1420460..0000000 --- a/telegram_bot (not maintened)/SECRETS.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id_owner": YOUR_ID, - "token": "YOUR-BOT-TOKEN" -} \ No newline at end of file diff --git a/telegram_bot (not maintened)/user/1377074018.json b/telegram_bot (not maintened)/user/1377074018.json deleted file mode 100644 index bfde35f..0000000 --- a/telegram_bot (not maintened)/user/1377074018.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "ID_player": 1377074018, - "money": 5.5, - "user_case": 0, - "ship_list": [ - "T-4147", - "P-4204", - "Z-1237", - "W-297", - "U-889", - "X-3756", - "N-3561", - "X-8489" - ], - "enemy_list": [ - "S-3591", - "W-1489" - ], - "username": "Julien", - "language": "ENG", - "fleet_size": 10, - "godmode": "OFF", - "win": 1, - "ratio_WL": 1.0, - "loose": 1, - "money_win": 22, - "money_spent": 116.5, - "case_purchased": 10, - "case_open": 10 -} \ No newline at end of file diff --git a/telegram_bot (not maintened)/user/6475751570.json b/telegram_bot (not maintened)/user/6475751570.json deleted file mode 100644 index 94ea918..0000000 --- a/telegram_bot (not maintened)/user/6475751570.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "ID_player": "6475751570", - "money": 492.5, - "user_case": 0, - "ship_list": [], - "enemy_list": [], - "username": "Test", - "language": "FR", - "fleet_size": 10, - "godmode": "OFF", - "win": 0, - "ratio_WL": 0, - "loose": 0, - "money_win": 342.5, - "money_spent": 0, - "case_purchased": 0, - "case_open": 0 -} \ No newline at end of file diff --git a/telegram_bot (not maintened)/user/db_id_username.json b/telegram_bot (not maintened)/user/db_id_username.json deleted file mode 100644 index 81fa943..0000000 --- a/telegram_bot (not maintened)/user/db_id_username.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "1377074018": "Julien", - "6475751570": "Test" -} \ No newline at end of file