From 96bf425fc2701cb5ffc077b1f0cb0caea5a03c96 Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Fri, 26 Jul 2024 07:15:42 +0000 Subject: [PATCH 01/51] first test --- main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 08234d16..adcb9cbe 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,5 @@ # Import statements - +def main(): + print("test") if __name__ == "__main__": - pass + main() From b2e077ba5a7b3ca33e6d946f8a5fadfe575f8183 Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Fri, 26 Jul 2024 07:23:01 +0000 Subject: [PATCH 02/51] name --- README.md | 8 ++++---- class.py | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 class.py diff --git a/README.md b/README.md index 7ce48508..4c43d0b4 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ ## Members -- Member 1 -- Member 2 -- Member 3 -- Member 4 +- Matthew +- Jianlin +- Jin Xu +- Pannnnnnnnnnawit diff --git a/class.py b/class.py new file mode 100644 index 00000000..9a14d2b5 --- /dev/null +++ b/class.py @@ -0,0 +1,2 @@ +class Enemy: + def __init__(self, ) \ No newline at end of file From ef0edc7eb8300c037eb13cde1c15242c41bf646f Mon Sep 17 00:00:00 2001 From: Chenjinxuu <160599422+Chenjinxuu@users.noreply.github.com> Date: Fri, 26 Jul 2024 07:23:59 +0000 Subject: [PATCH 03/51] --- main.py | 4 ++- rng.py | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 rng.py diff --git a/main.py b/main.py index 08234d16..03f2c687 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,6 @@ -# Import statements + + + if __name__ == "__main__": pass diff --git a/rng.py b/rng.py new file mode 100644 index 00000000..a70c6ee5 --- /dev/null +++ b/rng.py @@ -0,0 +1,103 @@ +# Import statements +# import time +import math +import random +import time +from colorama import Fore, Back, Style +def rng_generator(): + x = random.randint(1,1000000) + return x +def rng_game(): + x = rng_generator() + if x > 500000: + return f"{Style.RESET_ALL}Common (1 in 2)" + elif 500000 >= x > 250000: + return f"{Fore.GREEN}{Style.NORMAL}Uncommon (1 in 4)" + elif 250000 >= x > 125000: + return f"{Fore.BLUE}{Style.NORMAL}Rare (1 in 8)" + elif 125000 >= x > 62500: + return f"{Fore.BLUE}{Style.BRIGHT}Super Rare! (1 in 16)" + elif 62500 >= x > 31250: + return f"{Fore.MAGENTA}{Style.NORMAL}Epic! (1 in 32)" + elif 31250 >= x > 15625: + return f"{Fore.YELLOW}{Style.NORMAL}Lengendary! (1 in 64)" + elif 15625 >= x > 5625: + return f"{Fore.RED}{Style.NORMAL}Mythic!! (1 in 100)" + elif 5625 >= x > 625: + return f"{Fore.WHITE}{Style.BRIGHT}Marvellous!! (1 in 200)" + elif 625 >= x > 125: + return f"{Fore.WHITE}{Style.DIM}Secret!! (1 in 2000)" + elif 125 >= x > 25: + return f"{Fore.BLACK}{Style.BRIGHT}UNBELIVABLE!!! (1 in 10000)" + elif 25 >= x > 1: + return f"{Fore.GREEN}{Style.BRIGHT}INCOMPREHENSIBLE!!!! (1 in 40000)" + elif x == 1: + return f"{Fore.YELLOW}{Style.BRIGHT}JACKPOT!!!!!!! (1 in 1000000)" +def loading_percentage(): + percentage = 0 + while percentage < 100: + x = random.randint(1, 10) + percentage = percentage + x + if percentage > 100: + percentage = 100 + print(f"Loading... ({percentage}% done)", end = "\r") + time.sleep(0.5) + time.sleep(1) + print("Complete!!") +def proceeding(): + loading = [".","..","..."] + for i in range(21): + n = i%3 + print(f"Proceeding to the main game{loading[n]} ", end = "\r") + time.sleep(0.25) + progress_bar = ["[]","[]","[]","[]","[]","[]","[]","[]","[]","[]","[]",] + for i in range(len(progress_bar)): + progress_bar[i] = "֍ " + print("Internalizing" + " " + "".join(progress_bar), end = "\r") + time.sleep(0.5) + print("\r") + print("Done!") + +def roll_animation(): + roll_list = [f"{Style.RESET_ALL}Common (1 in 2) ", + f"{Fore.GREEN}{Style.NORMAL}Uncommon (1 in 4) ", + f"{Fore.BLUE}{Style.NORMAL}Rare (1 in 8) ", + f"{Fore.MAGENTA}{Style.NORMAL}Epic! (1 in 32) ", + f"{Fore.YELLOW}{Style.NORMAL}Lengendary! (1 in 64) ", + f"{Fore.RED}{Style.NORMAL}Mythic!! (1 in 100) ", + f"{Fore.WHITE}{Style.DIM}Secret!! (1 in 2000) ", + f"{Fore.BLACK}{Style.BRIGHT}UNBELIVABLE!!! (1 in 10000) ", + f"{Fore.GREEN}{Style.BRIGHT}INCOMPREHENSIBLE!!!! (1 in 40000) ", + f"{Fore.YELLOW}{Style.BRIGHT}JACKPOT!!!!!!! (1 in 1000000) " + ] +loading_percentage() +time.sleep(1) +proceeding() +time.sleep(1) +print("Welcome to RNG v0.2! ") +time.sleep(1) +print("Bare-boned gameplay.") +time.sleep(1) +while True: + mode = input("Type 1 or 2 for a different experience:") + if mode == "1": + num = input("Type in an integer:") + if num.isdigit(): + for i in range(int(num)): + print(rng_game()) + restart = input("Continue? (Yes/No/Inventory):").lower() + if restart == "no": + print("Thanks for playing!") + pass + elif restart == "yes": + continue + else: + continue + elif mode == "2": + num = input("Type in an integer:") + if num.isdigit(): + for i in range(int(num)): + pass + else: + continue + break \ No newline at end of file From 226033c255a83c34bef52fb09f92e9361bcf23d1 Mon Sep 17 00:00:00 2001 From: Chenjinxuu <160599422+Chenjinxuu@users.noreply.github.com> Date: Fri, 26 Jul 2024 07:29:03 +0000 Subject: [PATCH 04/51] Rng part is ready sols rng --- main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/main.py b/main.py index adcb9cbe..0bf864b3 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,6 @@ # Import statements def main(): print("test") + print("a Ok") if __name__ == "__main__": main() From 450d5ffdce30b67b39f748915aac2d23d62aca8c Mon Sep 17 00:00:00 2001 From: Chenjinxuu <160599422+Chenjinxuu@users.noreply.github.com> Date: Fri, 26 Jul 2024 07:31:19 +0000 Subject: [PATCH 05/51] it is actually ready now --- class.py | 2 -- main.py | 6 ++-- rng.py | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+), 4 deletions(-) delete mode 100644 class.py create mode 100644 rng.py diff --git a/class.py b/class.py deleted file mode 100644 index 9a14d2b5..00000000 --- a/class.py +++ /dev/null @@ -1,2 +0,0 @@ -class Enemy: - def __init__(self, ) \ No newline at end of file diff --git a/main.py b/main.py index 0bf864b3..9dcba8ea 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,8 @@ # Import statements +import rng + +#main game loop def main(): - print("test") - print("a Ok") + rng.rng_game() if __name__ == "__main__": main() diff --git a/rng.py b/rng.py new file mode 100644 index 00000000..a70c6ee5 --- /dev/null +++ b/rng.py @@ -0,0 +1,103 @@ +# Import statements +# import time +import math +import random +import time +from colorama import Fore, Back, Style +def rng_generator(): + x = random.randint(1,1000000) + return x +def rng_game(): + x = rng_generator() + if x > 500000: + return f"{Style.RESET_ALL}Common (1 in 2)" + elif 500000 >= x > 250000: + return f"{Fore.GREEN}{Style.NORMAL}Uncommon (1 in 4)" + elif 250000 >= x > 125000: + return f"{Fore.BLUE}{Style.NORMAL}Rare (1 in 8)" + elif 125000 >= x > 62500: + return f"{Fore.BLUE}{Style.BRIGHT}Super Rare! (1 in 16)" + elif 62500 >= x > 31250: + return f"{Fore.MAGENTA}{Style.NORMAL}Epic! (1 in 32)" + elif 31250 >= x > 15625: + return f"{Fore.YELLOW}{Style.NORMAL}Lengendary! (1 in 64)" + elif 15625 >= x > 5625: + return f"{Fore.RED}{Style.NORMAL}Mythic!! (1 in 100)" + elif 5625 >= x > 625: + return f"{Fore.WHITE}{Style.BRIGHT}Marvellous!! (1 in 200)" + elif 625 >= x > 125: + return f"{Fore.WHITE}{Style.DIM}Secret!! (1 in 2000)" + elif 125 >= x > 25: + return f"{Fore.BLACK}{Style.BRIGHT}UNBELIVABLE!!! (1 in 10000)" + elif 25 >= x > 1: + return f"{Fore.GREEN}{Style.BRIGHT}INCOMPREHENSIBLE!!!! (1 in 40000)" + elif x == 1: + return f"{Fore.YELLOW}{Style.BRIGHT}JACKPOT!!!!!!! (1 in 1000000)" +def loading_percentage(): + percentage = 0 + while percentage < 100: + x = random.randint(1, 10) + percentage = percentage + x + if percentage > 100: + percentage = 100 + print(f"Loading... ({percentage}% done)", end = "\r") + time.sleep(0.5) + time.sleep(1) + print("Complete!!") +def proceeding(): + loading = [".","..","..."] + for i in range(21): + n = i%3 + print(f"Proceeding to the main game{loading[n]} ", end = "\r") + time.sleep(0.25) + progress_bar = ["[]","[]","[]","[]","[]","[]","[]","[]","[]","[]","[]",] + for i in range(len(progress_bar)): + progress_bar[i] = "֍ " + print("Internalizing" + " " + "".join(progress_bar), end = "\r") + time.sleep(0.5) + print("\r") + print("Done!") + +def roll_animation(): + roll_list = [f"{Style.RESET_ALL}Common (1 in 2) ", + f"{Fore.GREEN}{Style.NORMAL}Uncommon (1 in 4) ", + f"{Fore.BLUE}{Style.NORMAL}Rare (1 in 8) ", + f"{Fore.MAGENTA}{Style.NORMAL}Epic! (1 in 32) ", + f"{Fore.YELLOW}{Style.NORMAL}Lengendary! (1 in 64) ", + f"{Fore.RED}{Style.NORMAL}Mythic!! (1 in 100) ", + f"{Fore.WHITE}{Style.DIM}Secret!! (1 in 2000) ", + f"{Fore.BLACK}{Style.BRIGHT}UNBELIVABLE!!! (1 in 10000) ", + f"{Fore.GREEN}{Style.BRIGHT}INCOMPREHENSIBLE!!!! (1 in 40000) ", + f"{Fore.YELLOW}{Style.BRIGHT}JACKPOT!!!!!!! (1 in 1000000) " + ] +loading_percentage() +time.sleep(1) +proceeding() +time.sleep(1) +print("Welcome to RNG v0.2! ") +time.sleep(1) +print("Bare-boned gameplay.") +time.sleep(1) +while True: + mode = input("Type 1 or 2 for a different experience:") + if mode == "1": + num = input("Type in an integer:") + if num.isdigit(): + for i in range(int(num)): + print(rng_game()) + restart = input("Continue? (Yes/No/Inventory):").lower() + if restart == "no": + print("Thanks for playing!") + pass + elif restart == "yes": + continue + else: + continue + elif mode == "2": + num = input("Type in an integer:") + if num.isdigit(): + for i in range(int(num)): + pass + else: + continue + break \ No newline at end of file From 705423f1607208708b8339d5bc5edb695d14024c Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Fri, 26 Jul 2024 07:47:13 +0000 Subject: [PATCH 06/51] player + object + class in dictionary concept --- classes.py | 16 ++++++++++++++++ main.py | 10 +++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 classes.py diff --git a/classes.py b/classes.py new file mode 100644 index 00000000..581b8e83 --- /dev/null +++ b/classes.py @@ -0,0 +1,16 @@ +class Player: + def __init__(self, name): + self.name = name + self.health = 10 + self.defense = 0 + self.attack = 1 + self.dodge = 0.05 #5% + self.speed = 1 + self.crit_chance = 0.05 + self.crit_dmg = 2 #200% + + +class Object: + def __init__(self, amount, desc): + self.amount = amount + self.desc = desc diff --git a/main.py b/main.py index adcb9cbe..06ec8c69 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,13 @@ # Import statements +import classes def main(): - print("test") + object = classes.Object(3, "ee") + object2 = classes.Object(4, "dd") + dict = {} + dict[1] = object + dict[2] = object2 + print(dict) + for i in dict.values(): + print(i.item) if __name__ == "__main__": main() From 726236771c1e18b3d78555f973f61c574d7d677c Mon Sep 17 00:00:00 2001 From: GohJianLin <160487674+GohJianLin@users.noreply.github.com> Date: Fri, 26 Jul 2024 08:04:31 +0000 Subject: [PATCH 07/51] commit --- classes.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 classes.py diff --git a/classes.py b/classes.py new file mode 100644 index 00000000..a2650a1a --- /dev/null +++ b/classes.py @@ -0,0 +1,34 @@ +class Gears: + def __init__(self): + self.helmet = (None) + self.chestplate = (None) + self.leggings = (None) + self.boots = (None) + self.accessories = (None) + pass +class Backpack: #store, display, check, destroy + def __init__(self, slots): + self.items = {} + self.backpack_size = slots + + def store(self, item): + if item in self.items: + self.items[item] += number + print(f'{item} * {number} has been stored') + return + if len(self.items) >= self.backpack_size: + print("Backpack is full!") + return + self.items[item] = number + print(f'{item} * {number} has been stored.') + return + + def display(self): + lst = [] + for item in self.items: + lst.append(item) + disp = ', '.join(lst) + return disp + + def check(self, item): + pass \ No newline at end of file From 69b0f3548b38f14afdceebcae9799740e433ad98 Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Fri, 26 Jul 2024 08:04:32 +0000 Subject: [PATCH 08/51] tewst --- class.py | 2 -- classes.py | 21 +++++++++++++++------ main.py | 20 ++++++++++++-------- 3 files changed, 27 insertions(+), 16 deletions(-) delete mode 100644 class.py diff --git a/class.py b/class.py deleted file mode 100644 index 9a14d2b5..00000000 --- a/class.py +++ /dev/null @@ -1,2 +0,0 @@ -class Enemy: - def __init__(self, ) \ No newline at end of file diff --git a/classes.py b/classes.py index 581b8e83..7ec6d36b 100644 --- a/classes.py +++ b/classes.py @@ -1,6 +1,6 @@ class Player: def __init__(self, name): - self.name = name + self.name = str(name) self.health = 10 self.defense = 0 self.attack = 1 @@ -8,9 +8,18 @@ def __init__(self, name): self.speed = 1 self.crit_chance = 0.05 self.crit_dmg = 2 #200% - + + def __repr__(self): + return f"Name: {self.name}" + + +class Backpack -class Object: - def __init__(self, amount, desc): - self.amount = amount - self.desc = desc +class Enemy: + def __init__(self, type): + if type == "Brute": + self.health, self.attack, self.defense = 10, 2, 1 + else: + self.health, self.attack, self.defense = 5, 1, 0 + def attack(self, player_obj): + pass diff --git a/main.py b/main.py index 06ec8c69..0b23239a 100644 --- a/main.py +++ b/main.py @@ -1,13 +1,17 @@ # Import statements -import classes +import time, classes def main(): - object = classes.Object(3, "ee") - object2 = classes.Object(4, "dd") + print("Intro") + player = classes.Player(str(input("What is your name?"))) + print(player) + # object = classes.Object(3, "ee") + # object2 = classes.Object(4, "dd") dict = {} - dict[1] = object - dict[2] = object2 - print(dict) - for i in dict.values(): - print(i.item) + print(dict[2]) + # dict[1] = object + # dict[2] = object2 + # print(dict) + # for i in dict.values(): + # print(i.item) if __name__ == "__main__": main() From 8d103f4ba847c86e2c4d2e7b2bc03956b4f6ba35 Mon Sep 17 00:00:00 2001 From: Chenjinxuu <160599422+Chenjinxuu@users.noreply.github.com> Date: Fri, 26 Jul 2024 08:05:08 +0000 Subject: [PATCH 09/51] Class weapon attack, crit and rarity are done, Some more weapons idea would be appreciated, and we need to combine the classes togethjer. --- Weapon.py | 30 ++++++++++++++++++++++++++++++ main.py | 10 +++++----- 2 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 Weapon.py diff --git a/Weapon.py b/Weapon.py new file mode 100644 index 00000000..47bd1a5e --- /dev/null +++ b/Weapon.py @@ -0,0 +1,30 @@ +import random +class Weapon: + def __init__(self, data: list): + self.attack = data[0] + self.critc = data[1] + self.rarity = data[2] + self.passive = data[3] + def __repr__(self): + return f"Att:{self.attack} Crit:{self.critc}% Rarity:{self.rarity}" + + def crit(self): + x = random.randint(1, 100) + if x <= self.critc: + return True + return False + + def combat(self): + crit = 1 #if there is no crit does not change + if self.crit(): + crit = 2 # double the damage when it crits + print(f"You dealt {self.attack * crit} damage to the enemy.") + + + +Wooden_sword = Weapon([3,5, "Common", False], ) +Stone_sword = Weapon([5, 5, "Common", False]) +Iron_sword = Weapon([8, 10, "Uncommon", False]) +Steel_sword = Weapon([12, 8, "Uncommon", False]) +Fire_blade = Weapon([10, 5, "Rare", True]) +#fire blade does half of the damage dealt to the enemy, last 2 turns diff --git a/main.py b/main.py index 9dcba8ea..989c6bc8 100644 --- a/main.py +++ b/main.py @@ -1,8 +1,8 @@ # Import statements -import rng - +import random +import Weapon #main game loop -def main(): - rng.rng_game() +print(Weapon.Wooden_sword.__repr__()) +Weapon.Wooden_sword.combat() if __name__ == "__main__": - main() + pass From 08b7aede9a571fe643877ff9d5a01526876b6b6f Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Fri, 26 Jul 2024 08:08:51 +0000 Subject: [PATCH 10/51] object class --- classes.py | 5 ++++- main.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/classes.py b/classes.py index 7ec6d36b..305ac58e 100644 --- a/classes.py +++ b/classes.py @@ -13,7 +13,10 @@ def __repr__(self): return f"Name: {self.name}" -class Backpack +class Object: + def __init__(self, num, desc): + self.num = num + self.desc = desc class Enemy: def __init__(self, type): diff --git a/main.py b/main.py index 0b23239a..ce28a064 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,7 @@ def main(): # object = classes.Object(3, "ee") # object2 = classes.Object(4, "dd") dict = {} - print(dict[2]) + # dict[1] = object # dict[2] = object2 # print(dict) From f3c3359dc194fdbc2851411cc00c2e4a24aa7aa2 Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Fri, 26 Jul 2024 08:25:26 +0000 Subject: [PATCH 11/51] last commit --- classes.py | 2 +- main.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/classes.py b/classes.py index 305ac58e..e7fa68d2 100644 --- a/classes.py +++ b/classes.py @@ -17,7 +17,7 @@ class Object: def __init__(self, num, desc): self.num = num self.desc = desc - + class Enemy: def __init__(self, type): if type == "Brute": diff --git a/main.py b/main.py index ce28a064..f4ca461b 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,9 @@ def main(): # object = classes.Object(3, "ee") # object2 = classes.Object(4, "dd") dict = {} - + dict[1] = player + print(dict) + print(dict[1].attack) # dict[1] = object # dict[2] = object2 # print(dict) From 1b53c4ff87ff4c75648bb9d3e054e79e77e80f51 Mon Sep 17 00:00:00 2001 From: Chenjinxuu <160599422+Chenjinxuu@users.noreply.github.com> Date: Fri, 26 Jul 2024 08:25:32 +0000 Subject: [PATCH 12/51] part of the intro is done --- main.py | 43 +++++++++++++++++++++++++++++-------------- rng.py | 13 +++---------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/main.py b/main.py index c60ba04f..74e2a9fc 100644 --- a/main.py +++ b/main.py @@ -1,20 +1,35 @@ # Import statements import time, classes +import rng def main(): - - print("Intro") - player = classes.Player(str(input("What is your name?"))) - print(player) - # object = classes.Object(3, "ee") - # object2 = classes.Object(4, "dd") - dict = {} - print(dict[2]) - # dict[1] = object - # dict[2] = object2 - # print(dict) - # for i in dict.values(): - # print(i.item) + yes = True + while True: + print("Intro") + time.sleep(1) + print("Myserious voice: 'I don't care! I seriously DON'T CARE! I have locked you up in my dungeon and you will never ever have the slightest of slimmer of hope in having the ability to even attempt to escape from this hell Ho of mine!") + time.sleep(5) + print("You wake up, dazed, who are you again?") + player = classes.Player(str(input("What is your name?"))) + while yes: + confirm = input(f"Are you sure your name is {player}?(y/n):") + if confirm == "y": + yes = False + elif confirm == "n": + player = classes.Player(str(input("What is your name?"))) + else: + print("Anser the question please") + + + # object = classes.Object(3, "ee") + # object2 = classes.Object(4, "dd") + dict = {} + print(dict[2]) + # dict[1] = object + # dict[2] = object2 + # print(dict) + # for i in dict.values(): + # print(i.item) if __name__ == "__main__": - main() + rng.rng_game() diff --git a/rng.py b/rng.py index a70c6ee5..72e5216c 100644 --- a/rng.py +++ b/rng.py @@ -85,19 +85,12 @@ def roll_animation(): if num.isdigit(): for i in range(int(num)): print(rng_game()) - restart = input("Continue? (Yes/No/Inventory):").lower() + restart = input("Continue? (Yes/No):").lower() if restart == "no": print("Thanks for playing!") pass elif restart == "yes": continue - else: - continue - elif mode == "2": - num = input("Type in an integer:") - if num.isdigit(): - for i in range(int(num)): - pass - else: - continue + else: + continue break \ No newline at end of file From 12742e13d8f02891eb19995c2174af0dbf4ed8c8 Mon Sep 17 00:00:00 2001 From: GohJianLin <160487674+GohJianLin@users.noreply.github.com> Date: Fri, 26 Jul 2024 08:25:51 +0000 Subject: [PATCH 13/51] bag. Store and display --- classes.py | 16 +++++++--------- main.py | 3 ++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/classes.py b/classes.py index 02ab7f33..db385014 100644 --- a/classes.py +++ b/classes.py @@ -12,22 +12,20 @@ def __init__(self, slots): self.items = {} self.backpack_size = slots - def store(self, item): - if item in self.items: - self.items[item] += number - print(f'{item} * {number} has been stored') + def store(self, name, object): + if name in self.items: + self.items[name].num += object.num + print(f'{name} * {object.num} has been stored') return if len(self.items) >= self.backpack_size: print("Backpack is full!") return - self.items[item] = number - print(f'{item} * {number} has been stored.') + self.items[name] = object + print(f'{name} * {object.num} has been stored.') return def display(self): - lst = [] - for item in self.items: - lst.append(item) + lst = [i for i in self.items.keys()] disp = ', '.join(lst) return disp diff --git a/main.py b/main.py index 0b23239a..f27c7c91 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,8 @@ def main(): # object = classes.Object(3, "ee") # object2 = classes.Object(4, "dd") dict = {} - print(dict[2]) + backpack = Backpack(10) + backpack.store # dict[1] = object # dict[2] = object2 # print(dict) From 64425073bd51dbb7f6fd6cbc8c1a77b872a0fd0f Mon Sep 17 00:00:00 2001 From: Chenjinxuu <160599422+Chenjinxuu@users.noreply.github.com> Date: Fri, 26 Jul 2024 08:26:18 +0000 Subject: [PATCH 14/51] intro is done --- rng.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rng.py b/rng.py index a70c6ee5..083765a2 100644 --- a/rng.py +++ b/rng.py @@ -56,7 +56,7 @@ def proceeding(): print("Internalizing" + " " + "".join(progress_bar), end = "\r") time.sleep(0.5) print("\r") - print("Done!") + print(" Done!") def roll_animation(): roll_list = [f"{Style.RESET_ALL}Common (1 in 2) ", From ce69d0071c1f84449a3c23ab111c0bddab79b667 Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Thu, 1 Aug 2024 06:37:00 +0000 Subject: [PATCH 15/51] test --- classes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes.py b/classes.py index e7fa68d2..2a73af19 100644 --- a/classes.py +++ b/classes.py @@ -8,7 +8,7 @@ def __init__(self, name): self.speed = 1 self.crit_chance = 0.05 self.crit_dmg = 2 #200% - + def __repr__(self): return f"Name: {self.name}" From 9e7b8d17872f1caef78e0b60dfc0299e7d9853e0 Mon Sep 17 00:00:00 2001 From: GohJianLin <160487674+GohJianLin@users.noreply.github.com> Date: Thu, 1 Aug 2024 06:52:19 +0000 Subject: [PATCH 16/51] made some updates --- classes.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/classes.py b/classes.py index db385014..925152cc 100644 --- a/classes.py +++ b/classes.py @@ -1,4 +1,3 @@ - class Gears: def __init__(self): self.helmet = (None) @@ -7,6 +6,7 @@ def __init__(self): self.boots = (None) self.accessories = (None) pass + class Backpack: #store, display, check, destroy def __init__(self, slots): self.items = {} @@ -17,6 +17,7 @@ def store(self, name, object): self.items[name].num += object.num print(f'{name} * {object.num} has been stored') return + if len(self.items) >= self.backpack_size: print("Backpack is full!") return @@ -54,6 +55,7 @@ def __init__(self, type): self.health, self.attack, self.defense = 10, 2, 1 else: self.health, self.attack, self.defense = 5, 1, 0 + def attack(self, player_obj): pass From 3a40f566c2ee5b6bb82a2545afe410544d1b23bc Mon Sep 17 00:00:00 2001 From: Chenjinxuu <160599422+Chenjinxuu@users.noreply.github.com> Date: Thu, 1 Aug 2024 07:01:10 +0000 Subject: [PATCH 17/51] Most of the Weapons are ready --- Weapon.py | 31 ++++++++++++++++++++++--------- main.py | 4 ++-- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Weapon.py b/Weapon.py index 47bd1a5e..599e093e 100644 --- a/Weapon.py +++ b/Weapon.py @@ -1,12 +1,12 @@ import random + class Weapon: def __init__(self, data: list): self.attack = data[0] self.critc = data[1] - self.rarity = data[2] - self.passive = data[3] + def __repr__(self): - return f"Att:{self.attack} Crit:{self.critc}% Rarity:{self.rarity}" + return f"Att:{self.attack} Crit:{self.critc}%" def crit(self): x = random.randint(1, 100) @@ -21,10 +21,23 @@ def combat(self): print(f"You dealt {self.attack * crit} damage to the enemy.") - -Wooden_sword = Weapon([3,5, "Common", False], ) -Stone_sword = Weapon([5, 5, "Common", False]) -Iron_sword = Weapon([8, 10, "Uncommon", False]) -Steel_sword = Weapon([12, 8, "Uncommon", False]) -Fire_blade = Weapon([10, 5, "Rare", True]) + #format att, critc +Wooden_sword = Weapon([3, 5], ) +Stone_sword = Weapon([5, 5]) +Iron_sword = Weapon([8, 10]) + +Steel_sword = Weapon([12, 8]) + +Fire_blade = Weapon([20, 5]) +Ice_blade = Weapon([12, 50]) + +Diamond_sword = Weapon([25, 12]) + +Soul_stealer = Weapon([5, 5]) #steal the attack of enemy and add it to weapon's attack. + + #fire blade does half of the damage dealt to the enemy, last 2 turns + + +#dev weapon +Ulti_blade = Weapon([100000000000000, 0]) diff --git a/main.py b/main.py index 989c6bc8..5e75b1bf 100644 --- a/main.py +++ b/main.py @@ -2,7 +2,7 @@ import random import Weapon #main game loop -print(Weapon.Wooden_sword.__repr__()) -Weapon.Wooden_sword.combat() +print(Weapon.Ulti_blade.__repr__()) +Weapon.Ulti_blade.combat() if __name__ == "__main__": pass From 5ca5c7ccadb953b979df6df832f41f847c81446a Mon Sep 17 00:00:00 2001 From: GohJianLin <160487674+GohJianLin@users.noreply.github.com> Date: Thu, 1 Aug 2024 07:04:03 +0000 Subject: [PATCH 18/51] changed some names --- Enemy.py | 9 +++++++++ classes.py => player.py | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 Enemy.py rename classes.py => player.py (82%) diff --git a/Enemy.py b/Enemy.py new file mode 100644 index 00000000..88172553 --- /dev/null +++ b/Enemy.py @@ -0,0 +1,9 @@ +class Enemy: + def __init__(self, type): + if type == "Brute": + self.health, self.attack, self.defense = 10, 2, 1 + else: + self.health, self.attack, self.defense = 5, 1, 0 + + def fight(self, player_obj): + pass diff --git a/classes.py b/player.py similarity index 82% rename from classes.py rename to player.py index 925152cc..8cc6fb24 100644 --- a/classes.py +++ b/player.py @@ -49,13 +49,4 @@ def __repr__(self): -class Enemy: - def __init__(self, type): - if type == "Brute": - self.health, self.attack, self.defense = 10, 2, 1 - else: - self.health, self.attack, self.defense = 5, 1, 0 - - def attack(self, player_obj): - pass From d5da271b7bd75acf4a1c4d203a2da7f7d4f6ce70 Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Thu, 1 Aug 2024 07:04:12 +0000 Subject: [PATCH 19/51] test --- classes.py | 5 +++-- main.py | 13 +------------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/classes.py b/classes.py index 2a73af19..30034a8b 100644 --- a/classes.py +++ b/classes.py @@ -24,5 +24,6 @@ def __init__(self, type): self.health, self.attack, self.defense = 10, 2, 1 else: self.health, self.attack, self.defense = 5, 1, 0 - def attack(self, player_obj): - pass + def attack(self, object): + object.health -= self.attack + diff --git a/main.py b/main.py index f4ca461b..884a08a0 100644 --- a/main.py +++ b/main.py @@ -2,18 +2,7 @@ import time, classes def main(): print("Intro") - player = classes.Player(str(input("What is your name?"))) + player = classes.Player(str(input("What is your name? "))) print(player) - # object = classes.Object(3, "ee") - # object2 = classes.Object(4, "dd") - dict = {} - dict[1] = player - print(dict) - print(dict[1].attack) - # dict[1] = object - # dict[2] = object2 - # print(dict) - # for i in dict.values(): - # print(i.item) if __name__ == "__main__": main() From 365e0d8838b09aa06c23dc3d89116d0b551d6a28 Mon Sep 17 00:00:00 2001 From: GohJianLin <160487674+GohJianLin@users.noreply.github.com> Date: Thu, 1 Aug 2024 07:08:11 +0000 Subject: [PATCH 20/51] they say i need to commit --- player.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/player.py b/player.py index 8cc6fb24..f7d9e86d 100644 --- a/player.py +++ b/player.py @@ -27,7 +27,7 @@ def store(self, name, object): def display(self): lst = [i for i in self.items.keys()] - disp = ', '.join(lst) + disp = ', '.join(lst) #all items in backpack return disp def check(self, item): @@ -45,8 +45,4 @@ def __init__(self, name): self.crit_dmg = 2 #200% def __repr__(self): - return f"Name: {self.name}" - - - - + return f"Name: {self.name}" \ No newline at end of file From af820ed8992930a631447a97c4d53bdb06fdc999 Mon Sep 17 00:00:00 2001 From: GohJianLin <160487674+GohJianLin@users.noreply.github.com> Date: Thu, 1 Aug 2024 07:21:54 +0000 Subject: [PATCH 21/51] updated --- player.py | 1 - 1 file changed, 1 deletion(-) diff --git a/player.py b/player.py index f7d9e86d..68079f18 100644 --- a/player.py +++ b/player.py @@ -5,7 +5,6 @@ def __init__(self): self.leggings = (None) self.boots = (None) self.accessories = (None) - pass class Backpack: #store, display, check, destroy def __init__(self, slots): From 41189fe1be9acb0433f74b23594cbd1820a4c478 Mon Sep 17 00:00:00 2001 From: Chenjinxuu <160599422+Chenjinxuu@users.noreply.github.com> Date: Thu, 1 Aug 2024 07:24:49 +0000 Subject: [PATCH 22/51] Matthew is forcing me --- Intro.py | 2 ++ Weapon.py | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 Intro.py diff --git a/Intro.py b/Intro.py new file mode 100644 index 00000000..58092d1a --- /dev/null +++ b/Intro.py @@ -0,0 +1,2 @@ +def Intro(): + intro_text = "" \ No newline at end of file diff --git a/Weapon.py b/Weapon.py index 599e093e..1a28b9a8 100644 --- a/Weapon.py +++ b/Weapon.py @@ -14,11 +14,13 @@ def crit(self): return True return False - def combat(self): + def combat(self, enemy): crit = 1 #if there is no crit does not change if self.crit(): - crit = 2 # double the damage when it crits - print(f"You dealt {self.attack * crit} damage to the enemy.") + crit = 2 # double the damage when it crits + enemy.health -= self.attack * crit + print(f"You dealt {self.attack * crit} damage to the {enemy}.") + print(f"{enemy} current health:{enemy.health}") #format att, critc From d52bf8d656ceb6f9e05d62f856209c002a2f511f Mon Sep 17 00:00:00 2001 From: Chenjinxuu <160599422+Chenjinxuu@users.noreply.github.com> Date: Thu, 1 Aug 2024 07:27:39 +0000 Subject: [PATCH 23/51] thing --- Weapon.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Weapon.py b/Weapon.py index 1a28b9a8..f95a5c5a 100644 --- a/Weapon.py +++ b/Weapon.py @@ -21,6 +21,9 @@ def combat(self, enemy): enemy.health -= self.attack * crit print(f"You dealt {self.attack * crit} damage to the {enemy}.") print(f"{enemy} current health:{enemy.health}") + if enemy.health <= 0: + enemy.health = 0 + print(f"{enemy} fainted.") #format att, critc From 869a5a26a43845d1fa5897558ea82ee102e8197b Mon Sep 17 00:00:00 2001 From: GohJianLin <160487674+GohJianLin@users.noreply.github.com> Date: Fri, 2 Aug 2024 07:10:57 +0000 Subject: [PATCH 24/51] Finished backpack --- Enemy.py | 9 ------ player.py => character.py | 65 ++++++++++++++++++++------------------- 2 files changed, 34 insertions(+), 40 deletions(-) delete mode 100644 Enemy.py rename player.py => character.py (66%) diff --git a/Enemy.py b/Enemy.py deleted file mode 100644 index 88172553..00000000 --- a/Enemy.py +++ /dev/null @@ -1,9 +0,0 @@ -class Enemy: - def __init__(self, type): - if type == "Brute": - self.health, self.attack, self.defense = 10, 2, 1 - else: - self.health, self.attack, self.defense = 5, 1, 0 - - def fight(self, player_obj): - pass diff --git a/player.py b/character.py similarity index 66% rename from player.py rename to character.py index e38bce29..dcc0e0de 100644 --- a/player.py +++ b/character.py @@ -1,55 +1,58 @@ -class Gears: - def __init__(self): +class Player: + def __init__(self, name, slots): + self.name = str(name) + self.health = 10 + self.defense = 0 + self.attack = 1 + self.dodge = 0.05 #5% + self.speed = 1 + self.crit_chance = 0.05 + self.crit_dmg = 2 #200% + #Backpack + self.items = {} + self.backpack_size = slots + #Gears self.helmet = (None) self.chestplate = (None) self.leggings = (None) self.boots = (None) self.accessories = (None) -class Backpack: #store, display, check, destroy - def __init__(self, slots): - self.items = {} - self.backpack_size = slots - + def __repr__(self): + return f"Name: {self.name}" + #Backpack def store(self, name, object): - if name in self.items: + if name in self.items: #same type items stack self.items[name].num += object.num print(f'{name} * {object.num} has been stored') return - - if len(self.items) >= self.backpack_size: + + if len(self.items) >= self.backpack_size: #backback full print("Backpack is full!") return - self.items[name] = object + + self.items[name] = object #normal store with sufficient space print(f'{name} * {object.num} has been stored.') return - + def display(self): lst = [i for i in self.items.keys()] disp = ', '.join(lst) #all items in backpack return disp def check(self, item): - pass - -class Player: - def __init__(self, name): - self.name = str(name) - self.health = 10 - self.defense = 0 - self.attack = 1 - self.dodge = 0.05 #5% - self.speed = 1 - self.crit_chance = 0.05 - self.crit_dmg = 2 #200% - - def __repr__(self): - return f"Name: {self.name}" - -class Backpack: - pass + if item in self.items.keys(): + print(f'Name: {item}') + print(f'Amount:{self.items[item].num}') + print(f'Description:{self.items[item].desc}')t + return + print('Item not in Backpack') + return + #Gears + def equip(self, gear): + if gear not in self.items: + print('You don't have that gear!') - class Object: def __init__(self, num, desc): self.num = num From ce85d49103821a219e354f73e1aef2f0b94a2b5c Mon Sep 17 00:00:00 2001 From: Chenjinxuu <160599422+Chenjinxuu@users.noreply.github.com> Date: Fri, 2 Aug 2024 07:19:18 +0000 Subject: [PATCH 25/51] Matthew is still not diamond yet -Weapons are basically done -Added basic ideas for potion --- Weapon.py | 48 --------------------------------- classes.py | 12 +++++---- item.py | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ main.py | 12 ++++++--- 4 files changed, 94 insertions(+), 56 deletions(-) delete mode 100644 Weapon.py create mode 100644 item.py diff --git a/Weapon.py b/Weapon.py deleted file mode 100644 index f95a5c5a..00000000 --- a/Weapon.py +++ /dev/null @@ -1,48 +0,0 @@ -import random - -class Weapon: - def __init__(self, data: list): - self.attack = data[0] - self.critc = data[1] - - def __repr__(self): - return f"Att:{self.attack} Crit:{self.critc}%" - - def crit(self): - x = random.randint(1, 100) - if x <= self.critc: - return True - return False - - def combat(self, enemy): - crit = 1 #if there is no crit does not change - if self.crit(): - crit = 2 # double the damage when it crits - enemy.health -= self.attack * crit - print(f"You dealt {self.attack * crit} damage to the {enemy}.") - print(f"{enemy} current health:{enemy.health}") - if enemy.health <= 0: - enemy.health = 0 - print(f"{enemy} fainted.") - - - #format att, critc -Wooden_sword = Weapon([3, 5], ) -Stone_sword = Weapon([5, 5]) -Iron_sword = Weapon([8, 10]) - -Steel_sword = Weapon([12, 8]) - -Fire_blade = Weapon([20, 5]) -Ice_blade = Weapon([12, 50]) - -Diamond_sword = Weapon([25, 12]) - -Soul_stealer = Weapon([5, 5]) #steal the attack of enemy and add it to weapon's attack. - - -#fire blade does half of the damage dealt to the enemy, last 2 turns - - -#dev weapon -Ulti_blade = Weapon([100000000000000, 0]) diff --git a/classes.py b/classes.py index 159d93cb..2449d212 100644 --- a/classes.py +++ b/classes.py @@ -5,7 +5,7 @@ def __init__(self): self.leggings = (None) self.boots = (None) self.accessories = (None) - pass + class Backpack: #store, display, check, destroy def __init__(self, slots): @@ -39,10 +39,7 @@ def __init__(self, name): self.health = 10 self.defense = 0 self.attack = 1 - self.dodge = 0.05 #5% self.speed = 1 - self.crit_chance = 0.05 - self.crit_dmg = 2 #200% def __repr__(self): return f"Name: {self.name}" @@ -60,6 +57,11 @@ def __init__(self, num, desc): class Enemy: def __init__(self, type): if type == "Brute": + self.name = "Brute" self.health, self.attack, self.defense = 10, 2, 1 + elif type == "Armored Gorilla": + self.name = "Armored Gorilla" + self.health, self.attack, self.defense = 10, 0, 1000 else: - self.health, self.attack, self.defense = 5, 1, 0 \ No newline at end of file + self.health, self.attack, self.defense = 5, 1, 0 +Goblin = Enemy("Brute") diff --git a/item.py b/item.py new file mode 100644 index 00000000..01784b2c --- /dev/null +++ b/item.py @@ -0,0 +1,78 @@ +import random + +class Weapon: + def __init__(self, data: list): + self.attack = data[0] + self.critc = data[1] + self.name = data[2] + + def __repr__(self): + return f"Att:{self.attack} Crit:{self.critc}% Name:{self.name}" + + def crit(self): + x = random.randint(1, 100) + if x <= self.critc: + return True + return False + + def combat(self, enemy, Player): + crit = 1 #if there is no crit does not change + if self.crit(): + crit = 2 # double the damage when it crits + damage = (self.attack + Player.attack - enemy.defense) * crit + if damage < 0: + damage = 1 + enemy.health -= damage + print(f"You dealt {damage} damage to the {enemy.name}.") + print(f"{enemy.name} current health:{enemy.health}") + if enemy.health <= 0: + enemy.health = 0 + print(f"{enemy} fainted.") + + +#Weapon list +#format att, critc +Wooden_sword = Weapon([3, 5, "Wooden Sword"]) +Stone_sword = Weapon([5, 5, "Stone Sword"]) +Iron_sword = Weapon([8, 10, "Iron Sword"]) + +Steel_sword = Weapon([12, 8, "Steel Sword"]) + +Fire_blade = Weapon([20, 5, "Fire Blade"]) +Ice_blade = Weapon([12, 50, "Ice Blade"]) + +Diamond_sword = Weapon([25, 12, "Diamond Sword"]) +Forty_metre_long_sword = Weapon([40, 40, "40m-long-sword"]) + +Soul_stealer = Weapon( + [5, 5, "Soul Stealer"]) #steal the attack of enemy and add it to weapon's attack. + +#fire blade does half of the damage dealt to the enemy, last 2 turns + +#dev weapon +Ulti_blade = Weapon([100000000000000, 0, "Ulti-Blade"]) + + + +class Potions: + def __init__(self, data): + self.desc = data[0] + self.buff = data[1] + + def __repr__(self): + return self.desc + + def potion_buff(self, player): + pass + +#Potion list +lesser_healing_potion = Potions(["Heals 2 hp to the player", 2]) +normal_healing_potion = ["Heals 5 hp to the player", 5] +greater_healing_potion = ["Heals 10 hp to the player ", 10] +supreme_healing_potion = ["Heals 20 hp to the player", 20] + +strength_potion = Potions(["Add 10 att to the player's strength stats", 10]) +speed_potion = Potions(["Add 5 speed to the player's speed stats", 5]) +almond_potion = Potions(["Add 2 to each of the player's stat"]) + +bleach = Potions(["Kills you instantly, toddler approved!", -9999999999999]) \ No newline at end of file diff --git a/main.py b/main.py index 43c7e27f..0fc4436c 100644 --- a/main.py +++ b/main.py @@ -1,10 +1,11 @@ # Import statements import random -import Weapon +import item +import classes #main game loop -import time, classes +import time import rng intro_text = "Myserious voice: 'I don't care! I seriously DON'T CARE! I have locked you up in my dungeon and you will never ever have the slightest of slimmer of hope in having the ability to even attempt to escape from this hell Ho of mine!" @@ -28,4 +29,9 @@ def main(): if __name__ == "__main__": - main() + Brute = classes.Enemy("Armored Gorilla") + print(Brute.health) + stats = item.Wooden_sword.__repr__() + print(stats) + item.Wooden_sword.combat(Brute) + From 59f67bee62d5a3ecd497a5b5258af6616527afef Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Fri, 2 Aug 2024 07:32:35 +0000 Subject: [PATCH 26/51] test --- Intro.py | 2 -- character.py | 4 ++-- intro.py | 19 +++++++++++++++++++ main.py | 22 ++-------------------- 4 files changed, 23 insertions(+), 24 deletions(-) delete mode 100644 Intro.py create mode 100644 intro.py diff --git a/Intro.py b/Intro.py deleted file mode 100644 index 58092d1a..00000000 --- a/Intro.py +++ /dev/null @@ -1,2 +0,0 @@ -def Intro(): - intro_text = "" \ No newline at end of file diff --git a/character.py b/character.py index dcc0e0de..1d4d5aa9 100644 --- a/character.py +++ b/character.py @@ -44,14 +44,14 @@ def check(self, item): if item in self.items.keys(): print(f'Name: {item}') print(f'Amount:{self.items[item].num}') - print(f'Description:{self.items[item].desc}')t + print(f'Description:{self.items[item].desc}') return print('Item not in Backpack') return #Gears def equip(self, gear): if gear not in self.items: - print('You don't have that gear!') + print("You don't have that gear!") class Object: def __init__(self, num, desc): diff --git a/intro.py b/intro.py new file mode 100644 index 00000000..c3b46cab --- /dev/null +++ b/intro.py @@ -0,0 +1,19 @@ +import time, character +def intro(): + yes = True + while True: + print("Intro") + time.sleep(1) + print("Myserious voice: 'I don't care! I seriously DON'T CARE! I have locked you up in my dungeon and you will never ever have the slightest of slimmer of hope in having the ability to even attempt to escape from this hell Ho of mine!") + time.sleep(5) + print("You wake up, dazed, who are you again?") + player = character.Player(str(input("What is your name?")), 5) + while yes: + confirm = input(f"Are you sure your name is {player}?(y/n):") + if confirm == "y": + yes = False + elif confirm == "n": + player = classes.Player(str(input("What is your name?"))) + else: + print("Answer the question please") + diff --git a/main.py b/main.py index 43c7e27f..ff914b81 100644 --- a/main.py +++ b/main.py @@ -4,28 +4,10 @@ import Weapon #main game loop -import time, classes +import time, character, intro import rng -intro_text = "Myserious voice: 'I don't care! I seriously DON'T CARE! I have locked you up in my dungeon and you will never ever have the slightest of slimmer of hope in having the ability to even attempt to escape from this hell Ho of mine!" def main(): - yes = True - while True: - print("Intro") - time.sleep(1) - print(intro_text) - time.sleep(5) - print("You wake up, dazed, who are you again?") - player = classes.Player(str(input("What is your name?"))) - while yes: - confirm = input(f"Are you sure your name is {player}?(y/n):") - if confirm == "y": - yes = False - elif confirm == "n": - player = classes.Player(str(input("What is your name?"))) - else: - print("Answer the question please") - - + intro.intro() if __name__ == "__main__": main() From 8dad1a955b8885e14385b71cd18ca7ec1910a4fb Mon Sep 17 00:00:00 2001 From: GohJianLin <160487674+GohJianLin@users.noreply.github.com> Date: Fri, 2 Aug 2024 07:35:00 +0000 Subject: [PATCH 27/51] Partially finished Gear --- character.py | 68 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/character.py b/character.py index dcc0e0de..6a4f8072 100644 --- a/character.py +++ b/character.py @@ -12,53 +12,69 @@ def __init__(self, name, slots): self.items = {} self.backpack_size = slots #Gears - self.helmet = (None) - self.chestplate = (None) - self.leggings = (None) - self.boots = (None) - self.accessories = (None) + self.gears = {'Helmet': None, 'Chestplate': None, 'Leggings': None, 'Boots': None, 'Weapons': None, 'Accessories': None} def __repr__(self): return f"Name: {self.name}" + #Backpack - def store(self, name, object): + def store(self, item):#item is an object + name = item.name if name in self.items: #same type items stack - self.items[name].num += object.num - print(f'{name} * {object.num} has been stored') - return + self.items[name].num += item.num + print(f'{name} * {item.num} has been stored') + return True if len(self.items) >= self.backpack_size: #backback full print("Backpack is full!") - return + return False - self.items[name] = object #normal store with sufficient space - print(f'{name} * {object.num} has been stored.') - return + self.items[name] = item #normal store with sufficient space + print(f'{name} * {item.num} has been stored.') + return True def display(self): lst = [i for i in self.items.keys()] disp = ', '.join(lst) #all items in backpack return disp - def check(self, item): - if item in self.items.keys(): - print(f'Name: {item}') - print(f'Amount:{self.items[item].num}') - print(f'Description:{self.items[item].desc}')t - return + def check(self, item_name): + if item_name in self.items.keys(): + print(f'Name: {item_name}') + print(f'Amount:{self.items[item_name].num}') + print(f'Description:{self.items[item_name].desc}') + return True print('Item not in Backpack') - return + return False + #Gears - def equip(self, gear): - if gear not in self.items: - print('You don't have that gear!') + def equip(self, gear: 'Item'): + if gear.name not in self.items: + print("You don't have that gear!") + return False + #if that section is full, say you have it on + pass + + def unequip(self, section): + if self.gears[section] is None: + print('Nothing is equipped there.') + return False + + if self.store(self.gears[section]) is False: + print(f'Backpack Full! {section} cannot be unequipped!') + return False + + self.store(self.gears[section]) + self.gears[section] = None + print(f'{self.gears[section].name} unequipped') + return True -class Object: - def __init__(self, num, desc): +class Item: + def __init__(self, num, desc, name): + self.name = name self.num = num self.desc = desc - class Enemy: def __init__(self, type): if type == "Brute": From 40683b6bba0174a8a65eeb6140e30398f9b3abda Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Fri, 2 Aug 2024 08:25:26 +0000 Subject: [PATCH 28/51] INVENTory fixed jian lin thing no stack!!! --- character.py | 83 ++++++++++++++++++++-------------------------------- game.py | 53 +++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 52 deletions(-) create mode 100644 game.py diff --git a/character.py b/character.py index 42e1e563..e9aea91a 100644 --- a/character.py +++ b/character.py @@ -1,38 +1,3 @@ -class Gears: - def __init__(self): - self.helmet = (None) - self.chestplate = (None) - self.leggings = (None) - self.boots = (None) - self.accessories = (None) - - -class Backpack: #store, display, check, destroy - def __init__(self, slots): - self.items = {} - self.backpack_size = slots - - def store(self, name, object): - if name in self.items: - self.items[name].num += object.num - print(f'{name} * {object.num} has been stored') - return - - if len(self.items) >= self.backpack_size: - print("Backpack is full!") - return - self.items[name] = object - print(f'{name} * {object.num} has been stored.') - return - - def display(self): - lst = [i for i in self.items.keys()] - disp = ', '.join(lst) - return disp - - def check(self, item): - pass - class Player: def __init__(self, name, slots): self.name = str(name) @@ -40,23 +5,30 @@ def __init__(self, name, slots): self.defense = 0 self.attack = 1 self.speed = 1 - + self.items = {} + self.backpack_size = slots + def __repr__(self): return f"Name: {self.name}" - #Backpack - def store(self, name, object): - if name in self.items: #same type items stack - self.items[name].num += object.num - print(f'{name} * {object.num} has been stored') - return - if len(self.items) >= self.backpack_size: #backback full - print("Backpack is full!") - return + def backpack_isFull(self): + total = 0 + for item in self.items.values(): + total += item.num + print(total) + return total >= self.backpack_size + + def store(self, object): + if not self.backpack_isFull: + if object.name in self.items: #item present + self.items[object.name].num += object.num + print(f'{object.num} {object.name} has been stored') + else: #new item + self.items[object.name] = object + print(f'{object.num} {object.name} has been stored.') + else: + print("Unable to store. Backpack is full.") - self.items[name] = object #normal store with sufficient space - print(f'{name} * {object.num} has been stored.') - return def display(self): lst = [i for i in self.items.keys()] @@ -75,11 +47,12 @@ def check(self, item): def equip(self, gear): if gear not in self.items: print("You don't have that gear!") - + class Object: - def __init__(self, num, desc): + def __init__(self, name, num, description): + self.name = name self.num = num - self.desc = desc + self.description = description class Enemy: @@ -92,4 +65,10 @@ def __init__(self, type): self.health, self.attack, self.defense = 10, 0, 1000 else: self.health, self.attack, self.defense = 5, 1, 0 -Goblin = Enemy("Brute") + + + +player = Player("NaMe", 20) +object1 = Object("Object1", 7, "Object1 desc") +player.store(object1) +print(player.backpack_isFull()) diff --git a/game.py b/game.py new file mode 100644 index 00000000..e745b265 --- /dev/null +++ b/game.py @@ -0,0 +1,53 @@ +from random import randint +class Game: + def __init__(self, name): + self.n = 10 + self.e = 5 + self.x = 0, self.y = 0 + self.enemies = {} + map = [['.'for i in range(10)]] + player = Player(name) + def printmap(self): + for i in range(self.n): + print(''.join(map[i])) + + def random_map(): + for i in range(5): + co = (randint(0, self.n-1), randint(0, self.n-1)) + if co in dic: + i-=1 + continue + self.enemies[co] = True + + def play(): + self.random_map() + while (self.x!=self.n-1 and self.y!=self.n-1): + move = input() + if move=='w' and self.x > 0: + self.x-=1 + elif move=='a' and self.y > 0: + self.y+=1 + elif move=='s' and self.x < self.n: + self.x-=1 + elif move=='d' and self.y < self.n: + self.y-=1 + else: + print("Invalid Move!") + continue + self.printmap() + if ((self.x, self.y) in self.enemies): + print("The ememy has been summoned!") + if self.fight(self.enemies[(self.x, self.y)]): + self.lose() + return + self.win() + return + + + def fight(self, enemy): + return False + + def win(self): + print("You have arrived safely. Well done!") + def lose(self): + print("Game over") From 229ff3f9fdb0abe9a73ca72015dfe0b91d767c0f Mon Sep 17 00:00:00 2001 From: GohJianLin <160487674+GohJianLin@users.noreply.github.com> Date: Wed, 7 Aug 2024 01:08:28 +0000 Subject: [PATCH 29/51] added true and false --- character.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/character.py b/character.py index d8870cba..e1f6836e 100644 --- a/character.py +++ b/character.py @@ -40,8 +40,6 @@ def __init__(self, name, slots): self.defense = 0 self.attack = 1 self.speed = 1 - self.crit_chance = 0.05 - self.crit_dmg = 2 #200% #Backpack self.items = {} self.backpack_size = slots @@ -72,8 +70,7 @@ def display(self): lst = [i for i in self.items.keys()] disp = ', '.join(lst) #all items in backpack return disp - - + def check(self, item_name): if item_name in self.items.keys(): print(f'Name: {item_name}') @@ -122,4 +119,4 @@ def __init__(self, type): self.health, self.attack, self.defense = 10, 0, 1000 else: self.health, self.attack, self.defense = 5, 1, 0 -Goblin = Enemy("Brute") +Goblin = Enemy("Brute") \ No newline at end of file From 36888d0cafb887a1eb9ecb1b73b0119a3218143d Mon Sep 17 00:00:00 2001 From: GohJianLin <160487674+GohJianLin@users.noreply.github.com> Date: Wed, 7 Aug 2024 01:21:29 +0000 Subject: [PATCH 30/51] changes --- character.py | 5 ----- item.py | 9 ++++++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/character.py b/character.py index e1f6836e..3e57ef2c 100644 --- a/character.py +++ b/character.py @@ -103,11 +103,6 @@ def unequip(self, section): print(f'{self.gears[section].name} unequipped') return True -class Item: - def __init__(self, num, desc, name): - self.name = name - self.num = num - self.desc = desc class Enemy: def __init__(self, type): diff --git a/item.py b/item.py index 01784b2c..f41cb261 100644 --- a/item.py +++ b/item.py @@ -75,4 +75,11 @@ def potion_buff(self, player): speed_potion = Potions(["Add 5 speed to the player's speed stats", 5]) almond_potion = Potions(["Add 2 to each of the player's stat"]) -bleach = Potions(["Kills you instantly, toddler approved!", -9999999999999]) \ No newline at end of file +bleach = Potions(["Kills you instantly, toddler approved!", -9999999999999]) + +class Item: + def __init__(self, num, desc, name, weight): + self.name = name + self.num = num + self.desc = desc + self.weight = weight \ No newline at end of file From 2b9ad1e038810e2dcf4e145434c69595c31c5c75 Mon Sep 17 00:00:00 2001 From: Chenjinxuu <160599422+Chenjinxuu@users.noreply.github.com> Date: Wed, 7 Aug 2024 01:22:31 +0000 Subject: [PATCH 31/51] Potion implementation is complete yay --- character.py | 15 +++++++++------ item.py | 38 ++++++++++++++++++++++++++++---------- main.py | 46 ++++++++++++++++++++++------------------------ 3 files changed, 59 insertions(+), 40 deletions(-) diff --git a/character.py b/character.py index d8351d1b..c52200eb 100644 --- a/character.py +++ b/character.py @@ -5,7 +5,7 @@ def __init__(self): self.leggings = (None) self.boots = (None) self.accessories = (None) - + class Backpack: #store, display, check, destroy def __init__(self, slots): @@ -36,16 +36,19 @@ def check(self, item): class Player: def __init__(self, name, slots): self.name = str(name) - self.health = 10 + self.max_health = 10 + self.current_health = 10 self.defense = 0 self.attack = 1 self.speed = 1 + self.items = {} + self.backpack_size = slots def __repr__(self): return f"Name: {self.name}" #Backpack def store(self, name, object): - if name in self.items: #same type items stack + if self.name in self.items: #same type items stack self.items[name].num += object.num print(f'{name} * {object.num} has been stored') return @@ -67,14 +70,14 @@ def check(self, item): if item in self.items.keys(): print(f'Name: {item}') print(f'Amount:{self.items[item].num}') - print(f'Description:{self.items[item].desc}')t + print(f'Description:{self.items[item].desc}') return print('Item not in Backpack') return #Gears def equip(self, gear): if gear not in self.items: - print('You don't have that gear!') + print("You don't have that gear!") class Object: def __init__(self, num, desc): @@ -92,4 +95,4 @@ def __init__(self, type): self.health, self.attack, self.defense = 10, 0, 1000 else: self.health, self.attack, self.defense = 5, 1, 0 -Goblin = Enemy("Brute") + diff --git a/item.py b/item.py index 01784b2c..be3fa7b5 100644 --- a/item.py +++ b/item.py @@ -2,7 +2,7 @@ class Weapon: def __init__(self, data: list): - self.attack = data[0] + self.attack = data[0] self.critc = data[1] self.name = data[2] @@ -28,6 +28,7 @@ def combat(self, enemy, Player): if enemy.health <= 0: enemy.health = 0 print(f"{enemy} fainted.") + #Weapon list @@ -36,7 +37,9 @@ def combat(self, enemy, Player): Stone_sword = Weapon([5, 5, "Stone Sword"]) Iron_sword = Weapon([8, 10, "Iron Sword"]) + Steel_sword = Weapon([12, 8, "Steel Sword"]) +Sword_of_baguette = Weapon([8, 28, "Bagutte Sword?"]) Fire_blade = Weapon([20, 5, "Fire Blade"]) Ice_blade = Weapon([12, 50, "Ice Blade"]) @@ -58,21 +61,36 @@ class Potions: def __init__(self, data): self.desc = data[0] self.buff = data[1] + self.type = data[2] def __repr__(self): return self.desc def potion_buff(self, player): - pass + if self.type == "healing": + player.health += self.buff + + elif self.type == "attack": + player.attack += self.buff + + elif self.type == "speed": + player.speed += self.buff + + elif self.type == "all-in-one": + player.health += self.buff + player.attack += self.buff + player.speed += self.buff + player.defense += self.buff + #Potion list -lesser_healing_potion = Potions(["Heals 2 hp to the player", 2]) -normal_healing_potion = ["Heals 5 hp to the player", 5] -greater_healing_potion = ["Heals 10 hp to the player ", 10] -supreme_healing_potion = ["Heals 20 hp to the player", 20] +lesser_healing_potion = Potions(["Heals 2 hp to the player", 2, "healing"]) +normal_healing_potion = ["Heals 5 hp to the player", 5, "healing"] +greater_healing_potion = ["Heals 10 hp to the player ", 10, "healing"] +supreme_healing_potion = ["Heals 20 hp to the player", 20, "healing"] -strength_potion = Potions(["Add 10 att to the player's strength stats", 10]) -speed_potion = Potions(["Add 5 speed to the player's speed stats", 5]) -almond_potion = Potions(["Add 2 to each of the player's stat"]) +strength_potion = Potions(["Add 10 att to the player's strength stats", 10, "attack"]) +speed_potion = Potions(["Add 5 speed to the player's speed stats", 5, "speed"]) +almond_potion = Potions(["Add 2 to each of the player's stat", 2, "all-in-one"]) -bleach = Potions(["Kills you instantly, toddler approved!", -9999999999999]) \ No newline at end of file +bleach = Potions(["Kills you instantly, toddler approved!", -9999999999999, "health"]) \ No newline at end of file diff --git a/main.py b/main.py index 0fc4436c..fc0c7ebd 100644 --- a/main.py +++ b/main.py @@ -2,36 +2,34 @@ # Import statements import random import item -import classes +import character + #main game loop import time import rng intro_text = "Myserious voice: 'I don't care! I seriously DON'T CARE! I have locked you up in my dungeon and you will never ever have the slightest of slimmer of hope in having the ability to even attempt to escape from this hell Ho of mine!" -def main(): - yes = True - while True: - print("Intro") - time.sleep(1) - print(intro_text) - time.sleep(5) - print("You wake up, dazed, who are you again?") - player = classes.Player(str(input("What is your name?"))) - while yes: - confirm = input(f"Are you sure your name is {player}?(y/n):") - if confirm == "y": - yes = False - elif confirm == "n": - player = classes.Player(str(input("What is your name?"))) - else: - print("Answer the question please") - +# def main(): +# yes = True +# while True: +# print("Intro") +# time.sleep(1) +# print(intro_text) +# time.sleep(5) +# print("You wake up, dazed, who are you again?") +# player = classes.Player(str(input("What is your name?"))) +# while yes: +# confirm = input(f"Are you sure your name is {player}?(y/n):") +# if confirm == "y": +# yes = False +# elif confirm == "n": +# player = .Player(str(input("What is your name?"))) +# else: +# print("Answer the question please") + if __name__ == "__main__": - Brute = classes.Enemy("Armored Gorilla") - print(Brute.health) - stats = item.Wooden_sword.__repr__() - print(stats) - item.Wooden_sword.combat(Brute) + hero = character.Player("Matthew", 10) + print(hero.health) From dbeb73b0c6e88f331b45268fbe0780da85ab573d Mon Sep 17 00:00:00 2001 From: GohJianLin <160487674+GohJianLin@users.noreply.github.com> Date: Wed, 7 Aug 2024 01:59:27 +0000 Subject: [PATCH 32/51] added weight partially --- character.py | 50 ++++++++++++++++++++++++++++++-------------------- item.py | 4 ++-- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/character.py b/character.py index 34fe250c..684dbf5c 100644 --- a/character.py +++ b/character.py @@ -1,5 +1,6 @@ +from item import Item class Player: - def __init__(self, name, slots): + def __init__(self, name, max_load): self.name = str(name) self.health = 10 self.defense = 0 @@ -7,7 +8,9 @@ def __init__(self, name, slots): self.speed = 1 self.items = {} - self.backpack_size = slots + self.mload = max_load + + self.gears = {'helm': None, 'chest': None, 'legs': None, 'boots': None, 'accessories': None} def __repr__(self): return f"Name: {self.name}" @@ -15,18 +18,38 @@ def __repr__(self): def backpack_isFull(self): total = 0 for item in self.items.values(): - total += item.num + total += item.weight print(total) - return total >= self.backpack_size + return total >= self.mload def store(self, object): if not self.backpack_isFull: if object.name in self.items: #item present self.items[object.name].num += object.num + + total = 0 + for item in self.items.values(): + total += item.weight + if total > self.mload: + print("That's too much for your bag to handle!") + self.items[object.name].num -= object.num + return + print(f'{object.num} {object.name} has been stored') + else: #new item self.items[object.name] = object - print(f'{object.num} {object.name} has been stored.') + + total = 0 + for item in self.items.values(): + total += item.weight + if total > self.mload: + print("That's too much for your bag to handle!") + del self.items[object.name] + return + + print(f'{object.num} {object.name} has been stored.')t + else: print("Unable to store. Backpack is full.") @@ -46,19 +69,7 @@ def check(self, item): return print('Item not in Backpack') return - #Gears - def equip(self, gear): - if gear not in self.items: - print("You don't have that gear!") - -class Object: - def __init__(self, name, num, description): - self.name = name - self.num = num - self.description = description - - #Gears def equip(self, gear: 'Item'): if gear.name not in self.items: @@ -74,8 +85,7 @@ def unequip(self, section): if self.store(self.gears[section]) is False: print(f'Backpack Full! {section} cannot be unequipped!') - return False - + return False self.store(self.gears[section]) self.gears[section] = None print(f'{self.gears[section].name} unequipped') @@ -97,7 +107,7 @@ def __init__(self, type): player = Player("NaMe", 20) -object1 = Object("Object1", 7, "Object1 desc") +object1 = Item("Object1", 7, "Object1 desc", 10) player.store(object1) print(player.backpack_isFull()) diff --git a/item.py b/item.py index f41cb261..76461312 100644 --- a/item.py +++ b/item.py @@ -78,8 +78,8 @@ def potion_buff(self, player): bleach = Potions(["Kills you instantly, toddler approved!", -9999999999999]) class Item: - def __init__(self, num, desc, name, weight): + def __init__(self, num, desc, name, spec_weight): self.name = name self.num = num self.desc = desc - self.weight = weight \ No newline at end of file + self.weight = spec_weight * num \ No newline at end of file From 4176111a27ced89c78539facb7be7899bb7e2207 Mon Sep 17 00:00:00 2001 From: GohJianLin <160487674+GohJianLin@users.noreply.github.com> Date: Fri, 9 Aug 2024 07:03:21 +0000 Subject: [PATCH 33/51] Added some equip unequip, added gear class --- character.py | 45 ++++++++++++++++++++++++++++++++------------- item.py | 21 ++++++++++++++------- 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/character.py b/character.py index 684dbf5c..55d2e5f7 100644 --- a/character.py +++ b/character.py @@ -1,4 +1,7 @@ from item import Item +from item import Gear +from typing import Any, Dict + class Player: def __init__(self, name, max_load): self.name = str(name) @@ -10,7 +13,14 @@ def __init__(self, name, max_load): self.items = {} self.mload = max_load - self.gears = {'helm': None, 'chest': None, 'legs': None, 'boots': None, 'accessories': None} + self.gears: Dict[str, Any]= { + 'helm': None, + 'chest': None, + 'leg': None, + 'boots': None, + 'accessory': None, + 'weapon': None + } def __repr__(self): return f"Name: {self.name}" @@ -27,15 +37,16 @@ def store(self, object): if object.name in self.items: #item present self.items[object.name].num += object.num - total = 0 + weight = 0 for item in self.items.values(): - total += item.weight - if total > self.mload: + weight += item.weight + if weight > self.mload: print("That's too much for your bag to handle!") - self.items[object.name].num -= object.num - return + self.items[object.name].num -= object.num #Take back item + return False print(f'{object.num} {object.name} has been stored') + return True else: #new item self.items[object.name] = object @@ -46,12 +57,14 @@ def store(self, object): if total > self.mload: print("That's too much for your bag to handle!") del self.items[object.name] - return + return False - print(f'{object.num} {object.name} has been stored.')t + print(f'{object.num} {object.name} has been stored.') + return True else: print("Unable to store. Backpack is full.") + return False @@ -66,17 +79,23 @@ def check(self, item): print(f'Name: {item}') print(f'Amount:{self.items[item].num}') print(f'Description:{self.items[item].desc}') - return + return True print('Item not in Backpack') - return + return False #Gears - def equip(self, gear: 'Item'): + def equip(self, gear: 'Gear'): if gear.name not in self.items: print("You don't have that gear!") return False #if that section is full, say you have it on - pass + if self.gears[gear.section] is not None: + print(f'You already have a {gear.section} equipped.') + return False + #else, equip that gear + self.gears[gear.section] = gear + print(f'{gear.name} is equipped') + return True def unequip(self, section): if self.gears[section] is None: @@ -86,12 +105,12 @@ def unequip(self, section): if self.store(self.gears[section]) is False: print(f'Backpack Full! {section} cannot be unequipped!') return False + self.store(self.gears[section]) self.gears[section] = None print(f'{self.gears[section].name} unequipped') return True - class Enemy: def __init__(self, type): if type == "Brute": diff --git a/item.py b/item.py index 76461312..91f5372c 100644 --- a/item.py +++ b/item.py @@ -1,7 +1,20 @@ import random -class Weapon: +class Item: + def __init__(self, data: list):# name, desc, num, spec_weight + self.name = data[0] + self.desc = data[1] + self.num = data[2] + self.weight = data[3] * self.num + +class Gear(Item): + def __init__(self, section, data: list): + super().__init__(data) + self.section = section + +class Weapon(Gear): def __init__(self, data: list): + self.section = 'weapon' self.attack = data[0] self.critc = data[1] self.name = data[2] @@ -77,9 +90,3 @@ def potion_buff(self, player): bleach = Potions(["Kills you instantly, toddler approved!", -9999999999999]) -class Item: - def __init__(self, num, desc, name, spec_weight): - self.name = name - self.num = num - self.desc = desc - self.weight = spec_weight * num \ No newline at end of file From 6098dcf0fe998bd8e0d1e011ed2129ea4332f11e Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Thu, 15 Aug 2024 06:44:21 +0000 Subject: [PATCH 34/51] game --- character.py | 22 ++++++++-------------- game.py | 43 ++++++++++++++++++++++++++++++------------- item.py | 2 +- main.py | 9 ++++----- 4 files changed, 43 insertions(+), 33 deletions(-) diff --git a/character.py b/character.py index e9aea91a..23c9d2ba 100644 --- a/character.py +++ b/character.py @@ -56,19 +56,13 @@ def __init__(self, name, num, description): class Enemy: - def __init__(self, type): - if type == "Brute": - self.name = "Brute" - self.health, self.attack, self.defense = 10, 2, 1 - elif type == "Armored Gorilla": - self.name = "Armored Gorilla" - self.health, self.attack, self.defense = 10, 0, 1000 - else: - self.health, self.attack, self.defense = 5, 1, 0 - + def __init__(self): + pass + def __repr__(self): + return "E" -player = Player("NaMe", 20) -object1 = Object("Object1", 7, "Object1 desc") -player.store(object1) -print(player.backpack_isFull()) +# player = Player("NaMe", 20) +# object1 = Object("Object1", 7, "Object1 desc") +# player.store(object1) +# print(player.backpack_isFull()) diff --git a/game.py b/game.py index e745b265..37826108 100644 --- a/game.py +++ b/game.py @@ -1,35 +1,50 @@ from random import randint +import character class Game: def __init__(self, name): - self.n = 10 + self.n = 6 self.e = 5 - self.x = 0, self.y = 0 + self.x, self.y = 0, 0 + self.past_x, self.past_y = 0, 0 self.enemies = {} - map = [['.'for i in range(10)]] - player = Player(name) + self.map = [['.' for i in range(self.n)] for i in range(self.n)] + player = character.Player(name, 10) + def printmap(self): + print(self.map) for i in range(self.n): - print(''.join(map[i])) + output = "" + for j in range(self.n): + # output += self.map[i][j] + print(self.map[i][j]) + #doesnt work, need to join str and class tgt another way WIP + pass - def random_map(): - for i in range(5): + def random_map(self): + #enemies + for i in range(6): + enemy = character.Enemy() co = (randint(0, self.n-1), randint(0, self.n-1)) - if co in dic: - i-=1 - continue - self.enemies[co] = True + if not co in self.enemies.keys(): + self.enemies[co] = True + for i in self.enemies: + self.map[i[0]][i[1]] = enemy - def play(): + def play(self): self.random_map() while (self.x!=self.n-1 and self.y!=self.n-1): move = input() if move=='w' and self.x > 0: + self.past_x, self.past_y = self.x, self.y self.x-=1 elif move=='a' and self.y > 0: + self.past_x, self.past_y = self.x, self.y self.y+=1 elif move=='s' and self.x < self.n: + self.past_x, self.past_y = self.x, self.y self.x-=1 elif move=='d' and self.y < self.n: + self.past_x, self.past_y = self.x, self.y self.y-=1 else: print("Invalid Move!") @@ -42,12 +57,14 @@ def play(): return self.win() return - + def update_position(self): + self.map[self.y][self.x], self.map[self.past_y][self.past_x] = "P", "X" def fight(self, enemy): return False def win(self): print("You have arrived safely. Well done!") + def lose(self): print("Game over") diff --git a/item.py b/item.py index 01784b2c..6009ee8e 100644 --- a/item.py +++ b/item.py @@ -73,6 +73,6 @@ def potion_buff(self, player): strength_potion = Potions(["Add 10 att to the player's strength stats", 10]) speed_potion = Potions(["Add 5 speed to the player's speed stats", 5]) -almond_potion = Potions(["Add 2 to each of the player's stat"]) +almond_potion = Potions(["Add 2 to each of the player's stat", -0]) bleach = Potions(["Kills you instantly, toddler approved!", -9999999999999]) \ No newline at end of file diff --git a/main.py b/main.py index 7475788c..4df17ebb 100644 --- a/main.py +++ b/main.py @@ -1,15 +1,14 @@ # Import statements -import random -import item -import classes #main game loop -import time, character, intro +import time, character, intro, game import rng def main(): - intro.intro() + Board = game.Game("Jian Lin") + Board.random_map() + Board.printmap() if __name__ == "__main__": main() From 5db18cb46ab0c9c881b38b08915bc9bcbe9da91a Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Thu, 15 Aug 2024 07:29:58 +0000 Subject: [PATCH 35/51] movement game working --- character.py | 9 +++--- game.py | 81 ++++++++++++++++++++++++---------------------------- main.py | 4 +++ 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/character.py b/character.py index 283eafd4..861b4603 100644 --- a/character.py +++ b/character.py @@ -3,15 +3,16 @@ from typing import Any, Dict class Player: - def __init__(self, name, max_load): + def __init__(self, name): self.name = str(name) self.health = 10 self.defense = 0 self.attack = 1 self.speed = 1 - + self.coords = (0, 0) + self.last_move = (0, 0) self.items = {} - self.mload = max_load + self.mload = 10 self.gears: Dict[str, Any]= { 'helm': None, @@ -23,7 +24,7 @@ def __init__(self, name, max_load): } def __repr__(self): - return f"Name: {self.name}" + return "P" def backpack_isFull(self): total = 0 diff --git a/game.py b/game.py index 37826108..e25157bd 100644 --- a/game.py +++ b/game.py @@ -1,64 +1,59 @@ from random import randint -import character +import character, colorama class Game: def __init__(self, name): - self.n = 6 - self.e = 5 - self.x, self.y = 0, 0 - self.past_x, self.past_y = 0, 0 + self.n = 5 + self.e = 12 self.enemies = {} self.map = [['.' for i in range(self.n)] for i in range(self.n)] - player = character.Player(name, 10) + self.player = character.Player(name) def printmap(self): - print(self.map) for i in range(self.n): output = "" for j in range(self.n): - # output += self.map[i][j] - print(self.map[i][j]) - #doesnt work, need to join str and class tgt another way WIP - pass + output += str(self.map[i][j]) + print(output) + print("\n") - def random_map(self): + def random_map(self): #randomise events in map #enemies - for i in range(6): - enemy = character.Enemy() - co = (randint(0, self.n-1), randint(0, self.n-1)) - if not co in self.enemies.keys(): - self.enemies[co] = True + self.map[0][0] = self.player + for i in range(self.e): + while True: + coords = (randint(0, self.n-1), randint(0, self.n-1)) + if self.map[coords[0]][coords[1]] == "." and not coords in self.enemies.keys(): + self.enemies[coords] = True + break for i in self.enemies: - self.map[i[0]][i[1]] = enemy + self.map[i[0]][i[1]] = character.Enemy() def play(self): - self.random_map() - while (self.x!=self.n-1 and self.y!=self.n-1): - move = input() - if move=='w' and self.x > 0: - self.past_x, self.past_y = self.x, self.y - self.x-=1 - elif move=='a' and self.y > 0: - self.past_x, self.past_y = self.x, self.y - self.y+=1 - elif move=='s' and self.x < self.n: - self.past_x, self.past_y = self.x, self.y - self.x-=1 - elif move=='d' and self.y < self.n: - self.past_x, self.past_y = self.x, self.y - self.y-=1 + while True: #check doesnt work fix this shit + move = input("Enter move: ") + if move=='w' and self.player.coords[0] > 0: + self.player.last_move = self.player.coords + self.player.coords =(self.player.coords[0] - 1, self.player.coords[1]) + break + elif move=='a' and self.player.coords[1] > 0: + self.player.last_move = self.player.coords + self.player.coords =(self.player.coords[0], self.player.coords[1] - 1) + break + elif move=='s' and self.player.coords[0] < self.n: + self.player.last_move = self.player.coords + self.player.coords =(self.player.coords[0] + 1, self.player.coords[1]) + break + elif move=='d' and self.player.coords[1] < self.n: + self.player.last_move = self.player.coords + self.player.coords =(self.player.coords[0], self.player.coords[1] + 1) + break else: print("Invalid Move!") - continue - self.printmap() - if ((self.x, self.y) in self.enemies): - print("The ememy has been summoned!") - if self.fight(self.enemies[(self.x, self.y)]): - self.lose() - return - self.win() - return + + def update_position(self): - self.map[self.y][self.x], self.map[self.past_y][self.past_x] = "P", "X" + self.map[self.player.coords[0]][self.player.coords[1]] = self.player + self.map[self.player.last_move[0]][self.player.last_move[1]] = "X" def fight(self, enemy): return False diff --git a/main.py b/main.py index 4df17ebb..e5e0afbf 100644 --- a/main.py +++ b/main.py @@ -9,6 +9,10 @@ def main(): Board = game.Game("Jian Lin") Board.random_map() Board.printmap() + while True: + Board.play() + Board.update_position() + Board.printmap() if __name__ == "__main__": main() From 6d364aef6b678853575a912571a8f913392c6f71 Mon Sep 17 00:00:00 2001 From: GohJianLin <160487674+GohJianLin@users.noreply.github.com> Date: Thu, 15 Aug 2024 07:32:11 +0000 Subject: [PATCH 36/51] done stuff( stuff) --- character.py | 55 +++++++++++++++++++++++++++++++++++------------ item.py | 60 +++++++++++++++++++++++----------------------------- 2 files changed, 67 insertions(+), 48 deletions(-) diff --git a/character.py b/character.py index 55d2e5f7..6c2f065b 100644 --- a/character.py +++ b/character.py @@ -1,6 +1,7 @@ from item import Item from item import Gear from typing import Any, Dict +from item import Weapon class Player: def __init__(self, name, max_load): @@ -18,7 +19,6 @@ def __init__(self, name, max_load): 'chest': None, 'leg': None, 'boots': None, - 'accessory': None, 'weapon': None } @@ -42,6 +42,7 @@ def store(self, object): weight += item.weight if weight > self.mload: print("That's too much for your bag to handle!") + self.items[object.name].num -= object.num #Take back item return False @@ -110,23 +111,49 @@ def unequip(self, section): self.gears[section] = None print(f'{self.gears[section].name} unequipped') return True + + def combat(self, enemy: "Enemy"): + crit = 1 #if there is no crit does not change + + if self.gears["weapon"].crit(): + crit = 2 # double the damage when it crits + + damage = (self.gears['weapon'].attack + self.attack - enemy.defense) * crit + + if damage < 0: + damage = 1 + + enemy.health -= damage + print(f"You dealt {damage} damage to the {enemy.name}.") + + print(f"{enemy.name} current health:{enemy.health}") + + if enemy.health <= 0: + enemy.health = 0 + print(f"{enemy} fainted.") + + class Enemy: - def __init__(self, type): - if type == "Brute": - self.name = "Brute" - self.health, self.attack, self.defense = 10, 2, 1 - elif type == "Armored Gorilla": - self.name = "Armored Gorilla" - self.health, self.attack, self.defense = 10, 0, 1000 - else: - self.health, self.attack, self.defense = 5, 1, 0 + def __init__(self, data: list): #name, health, defense, attack, speed + self.name = data[0] + self.health = data[1] + self.defense = data[2] + self.attack = data[3] + self.speed = data[4] + + def combat(self, player: "Player"): + damage = (self.attack - player.defense) #enemy doesn't crit + if damage < 0: + damage = 1 + player.health -= damage #lose health + print(f"You received {damage} damage from the {self.name}.")#print damage to player -player = Player("NaMe", 20) -object1 = Item("Object1", 7, "Object1 desc", 10) -player.store(object1) -print(player.backpack_isFull()) + print(f"{player.name} current health:{player.health}") #print hp left + if player.health <= 0: + player.health = 0 + print("You fainted. Skill Issue.") diff --git a/item.py b/item.py index 91f5372c..329ffc5b 100644 --- a/item.py +++ b/item.py @@ -1,23 +1,29 @@ import random class Item: - def __init__(self, data: list):# name, desc, num, spec_weight + def __init__(self, data: list):# name, num, desc, spec_weight self.name = data[0] - self.desc = data[1] - self.num = data[2] + self.num = data[1] + self.desc = data[2] self.weight = data[3] * self.num + -class Gear(Item): - def __init__(self, section, data: list): - super().__init__(data) +class Gear: + def __init__(self, section, data: list):#name, num, defense, spec_weight self.section = section + self.name = data[0] + self.num = data[1] + self.defense = data[2] + self.weight = data[3] * self.num -class Weapon(Gear): - def __init__(self, data: list): +class Weapon: + def __init__(self, data: list):#attack, critc, name, num, spec_weight self.section = 'weapon' self.attack = data[0] self.critc = data[1] self.name = data[2] + self.num = data[3] + self.weight = data[4] * self.num def __repr__(self): return f"Att:{self.attack} Crit:{self.critc}% Name:{self.name}" @@ -28,44 +34,30 @@ def crit(self): return True return False - def combat(self, enemy, Player): - crit = 1 #if there is no crit does not change - if self.crit(): - crit = 2 # double the damage when it crits - damage = (self.attack + Player.attack - enemy.defense) * crit - if damage < 0: - damage = 1 - enemy.health -= damage - print(f"You dealt {damage} damage to the {enemy.name}.") - print(f"{enemy.name} current health:{enemy.health}") - if enemy.health <= 0: - enemy.health = 0 - print(f"{enemy} fainted.") - #Weapon list #format att, critc -Wooden_sword = Weapon([3, 5, "Wooden Sword"]) -Stone_sword = Weapon([5, 5, "Stone Sword"]) -Iron_sword = Weapon([8, 10, "Iron Sword"]) +wooden_sword = Weapon([3, 5, "Wooden Sword", 1, 2]) +stone_sword = Weapon([5, 5, "Stone Sword", 1, 3]) +iron_sword = Weapon([8, 10, "Iron Sword", 1, 4]) -Steel_sword = Weapon([12, 8, "Steel Sword"]) +steel_sword = Weapon([12, 8, "Steel Sword", 1, 5]) -Fire_blade = Weapon([20, 5, "Fire Blade"]) -Ice_blade = Weapon([12, 50, "Ice Blade"]) +fire_blade = Weapon([20, 5, "Fire Blade", 1, 0]) +ice_blade = Weapon([12, 50, "Ice Blade", 1, 2]) -Diamond_sword = Weapon([25, 12, "Diamond Sword"]) -Forty_metre_long_sword = Weapon([40, 40, "40m-long-sword"]) +diamond_sword = Weapon([25, 12, "Diamond Sword", 1, 2]) +forty_metre_long_sword = Weapon([40, 40, "40m-long-sword", 1, 40]) -Soul_stealer = Weapon( - [5, 5, "Soul Stealer"]) #steal the attack of enemy and add it to weapon's attack. +soul_stealer = Weapon( + [5, 5, "Soul Stealer", 1, 2]) #steal the attack of enemy and add it to weapon's attack. #fire blade does half of the damage dealt to the enemy, last 2 turns #dev weapon -Ulti_blade = Weapon([100000000000000, 0, "Ulti-Blade"]) - +ulti_blade = Weapon([100000000000000, 0, "Ulti-Blade", 1, 0]) +#Armors class Potions: def __init__(self, data): From 04a3cf55c867f5d96ec2d7bb6e03dfca877b3c04 Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Fri, 16 Aug 2024 06:47:24 +0000 Subject: [PATCH 37/51] event queue --- character.py | 1 + game.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/character.py b/character.py index 861b4603..f961584e 100644 --- a/character.py +++ b/character.py @@ -11,6 +11,7 @@ def __init__(self, name): self.speed = 1 self.coords = (0, 0) self.last_move = (0, 0) + self.event_queue = "" self.items = {} self.mload = 10 diff --git a/game.py b/game.py index e25157bd..48698dfc 100644 --- a/game.py +++ b/game.py @@ -1,5 +1,5 @@ from random import randint -import character, colorama +import character class Game: def __init__(self, name): self.n = 5 @@ -32,31 +32,36 @@ def play(self): while True: #check doesnt work fix this shit move = input("Enter move: ") if move=='w' and self.player.coords[0] > 0: + self.player.event_queue = self.map[self.player.coords[0] - 1][self.player.coords[1]] self.player.last_move = self.player.coords self.player.coords =(self.player.coords[0] - 1, self.player.coords[1]) break elif move=='a' and self.player.coords[1] > 0: + self.player.event_queue = self.map[self.player.coords[0]][self.player.coords[1] - 1] self.player.last_move = self.player.coords self.player.coords =(self.player.coords[0], self.player.coords[1] - 1) break elif move=='s' and self.player.coords[0] < self.n: + self.player.event_queue = self.map[self.player.coords[0] + 1][self.player.coords[1]] self.player.last_move = self.player.coords self.player.coords =(self.player.coords[0] + 1, self.player.coords[1]) break elif move=='d' and self.player.coords[1] < self.n: + self.player.event_queue = self.map[self.player.coords[0]][self.player.coords[1] + 1] self.player.last_move = self.player.coords self.player.coords =(self.player.coords[0], self.player.coords[1] + 1) break else: print("Invalid Move!") + print(f"\nCurrent Event:{self.player.event_queue}", type(self.player.event_queue)) def update_position(self): self.map[self.player.coords[0]][self.player.coords[1]] = self.player self.map[self.player.last_move[0]][self.player.last_move[1]] = "X" - def fight(self, enemy): - return False + def check_event(self): + pass def win(self): print("You have arrived safely. Well done!") From 6494c4c09f860b662d73582d7cb436f0c9049afe Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Fri, 16 Aug 2024 07:21:15 +0000 Subject: [PATCH 38/51] shit combat --- character.py | 26 ++++++++++++++++++++------ game.py | 39 ++++++++++++++++++++++++++++----------- main.py | 1 + 3 files changed, 49 insertions(+), 17 deletions(-) diff --git a/character.py b/character.py index 6fa670af..21f4149a 100644 --- a/character.py +++ b/character.py @@ -1,7 +1,9 @@ -from item import Item -from item import Gear +# from item import Item +# from item import Gear from typing import Any, Dict -from item import Weapon +# from item import Weapon +import item +import time class Player: def __init__(self, name): @@ -21,7 +23,7 @@ def __init__(self, name): 'chest': None, 'leg': None, 'boots': None, - 'weapon': None + 'weapon': item.wooden_sword } def __repr__(self): @@ -87,7 +89,7 @@ def check(self, item): return False #Gears - def equip(self, gear: 'Gear'): + def equip(self, gear: 'Armor'): if gear.name not in self.items: print("You don't have that gear!") return False @@ -115,6 +117,8 @@ def unequip(self, section): return True def combat(self, enemy: "Enemy"): + print("\n") + time.sleep(0.5) crit = 1 #if there is no crit does not change if self.gears["weapon"].crit(): @@ -134,6 +138,9 @@ def combat(self, enemy: "Enemy"): if enemy.health <= 0: enemy.health = 0 print(f"{enemy} fainted.") + return True + else: + return False class Enemy: @@ -144,8 +151,12 @@ def __init__(self, data: list): #name, health, defense, attack, speed self.attack = data[3] self.speed = data[4] - + def __repr__(self): + return "E" + def combat(self, player: "Player"): + print("\n") + time.sleep(0.5) damage = (self.attack - player.defense) #enemy doesn't crit @@ -162,3 +173,6 @@ def combat(self, player: "Player"): if player.health <= 0: player.health = 0 print("You fainted. Skill Issue.") + return True + else: + return False diff --git a/game.py b/game.py index 48698dfc..ec08c4ca 100644 --- a/game.py +++ b/game.py @@ -15,6 +15,7 @@ def printmap(self): output += str(self.map[i][j]) print(output) print("\n") + print(f"Current Event:{self.player.event_queue}", type(self.player.event_queue)) def random_map(self): #randomise events in map #enemies @@ -26,10 +27,10 @@ def random_map(self): #randomise events in map self.enemies[coords] = True break for i in self.enemies: - self.map[i[0]][i[1]] = character.Enemy() + self.map[i[0]][i[1]] = character.Enemy(["Enemy", 100, 1, 1, 1]) #enter value next time def play(self): - while True: #check doesnt work fix this shit + while True: move = input("Enter move: ") if move=='w' and self.player.coords[0] > 0: self.player.event_queue = self.map[self.player.coords[0] - 1][self.player.coords[1]] @@ -41,19 +42,20 @@ def play(self): self.player.last_move = self.player.coords self.player.coords =(self.player.coords[0], self.player.coords[1] - 1) break - elif move=='s' and self.player.coords[0] < self.n: + elif move=='s' and self.player.coords[0] < self.n - 1: self.player.event_queue = self.map[self.player.coords[0] + 1][self.player.coords[1]] self.player.last_move = self.player.coords self.player.coords =(self.player.coords[0] + 1, self.player.coords[1]) break - elif move=='d' and self.player.coords[1] < self.n: + elif move=='d' and self.player.coords[1] < self.n - 1: self.player.event_queue = self.map[self.player.coords[0]][self.player.coords[1] + 1] self.player.last_move = self.player.coords self.player.coords =(self.player.coords[0], self.player.coords[1] + 1) break + elif not move in ["w", "a", "s", "d"]: + print("Invalid move") else: - print("Invalid Move!") - print(f"\nCurrent Event:{self.player.event_queue}", type(self.player.event_queue)) + print("You've reached the end of the room") def update_position(self): @@ -61,10 +63,25 @@ def update_position(self): self.map[self.player.last_move[0]][self.player.last_move[1]] = "X" def check_event(self): - pass + if isinstance(self.player.event_queue, character.Enemy): + print("You have encountered an enemy.") + self.event_fight(self.player, self.player.event_queue) + else: + print("nothing") - def win(self): - print("You have arrived safely. Well done!") + def event_fight(self, player, enemy): + result = False + turn_order = [player, enemy] + if player.speed >= enemy.speed: + i = 0 + else: + i = 1 + while not result: + result = turn_order[i].combat(turn_order[i - 1]) #if i = 0 i.e. player, i - 1 will become -1 which points to enemy as intended + if i == 1: + i = 0 + else: + i += 1 + + - def lose(self): - print("Game over") diff --git a/main.py b/main.py index e5e0afbf..742887a7 100644 --- a/main.py +++ b/main.py @@ -13,6 +13,7 @@ def main(): Board.play() Board.update_position() Board.printmap() + Board.check_event() if __name__ == "__main__": main() From dcca20ff75fb9dbc4dc4bb2e4ee5180c730c292c Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Fri, 16 Aug 2024 07:41:58 +0000 Subject: [PATCH 39/51] boss implemented --- character.py | 35 ++++++++++++++++++++++++++++++++++- game.py | 22 +++++++++++++++++++--- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/character.py b/character.py index 21f4149a..ef6f2006 100644 --- a/character.py +++ b/character.py @@ -138,6 +138,8 @@ def combat(self, enemy: "Enemy"): if enemy.health <= 0: enemy.health = 0 print(f"{enemy} fainted.") + if isinstance(enemy, Boss): + return -888 return True else: return False @@ -173,6 +175,37 @@ def combat(self, player: "Player"): if player.health <= 0: player.health = 0 print("You fainted. Skill Issue.") - return True + return -1 + else: + return False + +class Boss(Enemy): + def __init__(self, data): + super().__init__(data) + + def __repr__(self): + return "B" + + def combat(self, player: "Player"): + print("\n") + time.sleep(0.5) + damage = (self.attack - player.defense) #enemy doesn't crit + + + if damage < 0: + damage = 1 + + player.health -= damage #lose health + + print(f"You received {damage} damage from the {self.name}.")#print damage to player + + + print(f"{player.name} current health:{player.health}") #print hp left + + if player.health <= 0: + player.health = 0 + print("You fainted. Skill Issue.") + return -666 else: return False + \ No newline at end of file diff --git a/game.py b/game.py index ec08c4ca..2e6d2ab9 100644 --- a/game.py +++ b/game.py @@ -1,5 +1,5 @@ from random import randint -import character +import character, sys class Game: def __init__(self, name): self.n = 5 @@ -18,8 +18,15 @@ def printmap(self): print(f"Current Event:{self.player.event_queue}", type(self.player.event_queue)) def random_map(self): #randomise events in map - #enemies + #player spawn self.map[0][0] = self.player + #boss spawn + while True: + coords = (randint(0, self.n-1), randint(0, self.n-1)) + if self.map[coords[0]][coords[1]] == ".": + self.map[coords[0]][coords[1]] = character.Boss(["Overlord", 1, 5, 3, 1]) + break + #enemies spawn for i in range(self.e): while True: coords = (randint(0, self.n-1), randint(0, self.n-1)) @@ -27,7 +34,7 @@ def random_map(self): #randomise events in map self.enemies[coords] = True break for i in self.enemies: - self.map[i[0]][i[1]] = character.Enemy(["Enemy", 100, 1, 1, 1]) #enter value next time + self.map[i[0]][i[1]] = character.Enemy(["Enemy", 5, 1, 1, 1]) #enter value next time def play(self): while True: @@ -82,6 +89,15 @@ def event_fight(self, player, enemy): i = 0 else: i += 1 + if result == -1: + sys.exit() + elif result == -666: + print("The final boss has killed you...") + sys.exit() + elif result == -888: + print("You have defeated the final boss") + sys.exit() + From ec70d45407b5ec95745ee9f32d445035f2824de0 Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Fri, 16 Aug 2024 07:56:21 +0000 Subject: [PATCH 40/51] update --- game.py | 4 ++-- main.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/game.py b/game.py index 2e6d2ab9..fcc27add 100644 --- a/game.py +++ b/game.py @@ -36,7 +36,7 @@ def random_map(self): #randomise events in map for i in self.enemies: self.map[i[0]][i[1]] = character.Enemy(["Enemy", 5, 1, 1, 1]) #enter value next time - def play(self): + def player_input(self): while True: move = input("Enter move: ") if move=='w' and self.player.coords[0] > 0: @@ -62,7 +62,7 @@ def play(self): elif not move in ["w", "a", "s", "d"]: print("Invalid move") else: - print("You've reached the end of the room") + print("You've reached the end of the dungeon") def update_position(self): diff --git a/main.py b/main.py index 742887a7..00d3a8af 100644 --- a/main.py +++ b/main.py @@ -10,7 +10,7 @@ def main(): Board.random_map() Board.printmap() while True: - Board.play() + Board.player_input() Board.update_position() Board.printmap() Board.check_event() From 3c96c05d0afeef92651d978e17377938ce144a28 Mon Sep 17 00:00:00 2001 From: GohJianLin <160487674+GohJianLin@users.noreply.github.com> Date: Fri, 16 Aug 2024 08:00:22 +0000 Subject: [PATCH 41/51] coommiitt --- character.py | 26 +++++++++++++------------- item.py | 25 ++++++++++++++++++------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/character.py b/character.py index 28ee16a4..15832070 100644 --- a/character.py +++ b/character.py @@ -1,12 +1,10 @@ -from item import Item -from item import Gear +import item from typing import Any, Dict -from item import Weapon class Player: def __init__(self, name): self.name = str(name) - self.health = 10 + self.health = [10,10] self.defense = 0 self.attack = 1 self.speed = 1 @@ -28,8 +26,8 @@ def __repr__(self): def backpack_isFull(self): total = 0 - for item in self.items.values(): - total += item.weight + for itm in self.items.values(): + total += itm.weight print(total) return total >= self.mload @@ -76,7 +74,7 @@ def display(self): return disp - def check(self, item): + def check(self, object): if item in self.items.keys(): print(f'Name: {item}') print(f'Amount:{self.items[item].num}') @@ -86,14 +84,16 @@ def check(self, item): return False #Gears - def equip(self, gear: 'Gear'): + def equip(self, gear):#gear is type armor if gear.name not in self.items: print("You don't have that gear!") return False #if that section is full, say you have it on + if self.gears[gear.section] is not None: print(f'You already have a {gear.section} equipped.') return False + #else, equip that gear self.gears[gear.section] = gear print(f'{gear.name} is equipped') @@ -121,7 +121,7 @@ def combat(self, enemy: "Enemy"): damage = (self.gears['weapon'].attack + self.attack - enemy.defense) * crit - if damage < 0: + if damage <= 0: damage = 1 enemy.health -= damage @@ -145,19 +145,19 @@ def __init__(self, data: list): #name, health, defense, attack, speed def combat(self, player: "Player"): - damage = (self.attack - player.defense) #enemy doesn't crit + damage = (int(self.attack) - int(player.defense)) #enemy doesn't crit if damage < 0: damage = 1 - player.health -= damage #lose health + player.health[0] -= damage #lose health print(f"You received {damage} damage from the {self.name}.")#print damage to player print(f"{player.name} current health:{player.health}") #print hp left - if player.health <= 0: - player.health = 0 + if player.health[0] <= 0: + player.health[0] = 0 print("You fainted. Skill Issue.") diff --git a/item.py b/item.py index 566b658d..da864a0f 100644 --- a/item.py +++ b/item.py @@ -8,12 +8,12 @@ def __init__(self, data: list):# name, num, desc, spec_weight self.weight = data[3] * self.num -class Gear: - def __init__(self, section, data: list):#name, num, defense, spec_weight - self.section = section +class Armor: + def __init__(self, section, data: list):#name, defense, num, spec_weight + self.section = section #helm, chest, leg, boots self.name = data[0] - self.num = data[1] - self.defense = data[2] + self.defense = data[1] + self.num = data[2] self.weight = data[3] * self.num class Weapon: @@ -50,14 +50,25 @@ def crit(self): forty_metre_long_sword = Weapon([40, 40, "40m-long-sword", 1, 40]) soul_stealer = Weapon( - [5, 5, "Soul Stealer", 1, 2]) #steal the attack of enemy and add it to weapon's attack. + [5, 5, "Soul Stealer", 1, 0]) #steal the attack of enemy and add it to weapon's attack. #fire blade does half of the damage dealt to the enemy, last 2 turns #dev weapon ulti_blade = Weapon([100000000000000, 0, "Ulti-Blade", 1, 0]) -#Armors +#Armors #wood 1, iron 2, diamond 3 +#helm, boots 1, legs 2, chest 3 + +iron_helmet = Armor('helm', ['iron_helmet', 2, 1, 10]) +iron_chestplate = Armor('chest', ['iron_chestplate', 6, 1, 16]) +iron_leggings = Armor('leg', ['iron_leggings', 4, 1, 14]) +iron_boots = Armor('boots', ['iron_boots', 2, 1, 8]) + +diamond_helmet = Armor('helm', ['diamond_helmet', 3, 1, 5]) +diamond_chestplate = Armor('chest', ['diamond_chestplate', 9, 1, 8]) +diamond_leggings = Armor('leg', ['diamond_leggings', 6, 1, 7]) +diamond_boots = Armor('boots', ['diamond_boots', 3, 1, 4]) class Potions: def __init__(self, data): From e0feb58b028d1b36ae6c8f5099fd9968277ac216 Mon Sep 17 00:00:00 2001 From: Chenjinxuu <160599422+Chenjinxuu@users.noreply.github.com> Date: Wed, 21 Aug 2024 01:03:37 +0000 Subject: [PATCH 42/51] nothing nil --- character.py | 9 +-------- main.py | 1 - 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/character.py b/character.py index c7e57714..a99a5747 100644 --- a/character.py +++ b/character.py @@ -175,7 +175,7 @@ def __init__(self, type): self.health, self.attack, self.defense = 10, 2, 1 elif type == "Armored Gorilla": self.name = "Armored Gorilla" - self.health, self.attack, self.defense = 10, 0, 1000 + self.health, self.attack, self.defense = 10, 1, 1000 elif type == "Slime": self.health, self.attack, self.defense = 5, 1, 0 @@ -184,12 +184,5 @@ def __init__(self, type): -player = Player("NaMe", 20) -object1 = Item("Object1", 7, "Object1 desc", 10) -player.store(object1) -print(player.backpack_isFull()) - - - diff --git a/main.py b/main.py index c9d7a989..5ad439d8 100644 --- a/main.py +++ b/main.py @@ -39,4 +39,3 @@ def main(): if __name__ == "__main__": pass - From ec7f26cd64d7c1da5a20b291bd49b1e9551104a7 Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Wed, 21 Aug 2024 01:10:17 +0000 Subject: [PATCH 43/51] test --- character.py | 2 +- main.py | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/character.py b/character.py index ef6f2006..0ae0c4b2 100644 --- a/character.py +++ b/character.py @@ -18,7 +18,7 @@ def __init__(self, name): self.items = {} self.mload = 10 - self.gears: Dict[str, Any]= { + self.gears = { 'helm': None, 'chest': None, 'leg': None, diff --git a/main.py b/main.py index 00d3a8af..9abd1226 100644 --- a/main.py +++ b/main.py @@ -6,14 +6,17 @@ import rng def main(): - Board = game.Game("Jian Lin") - Board.random_map() - Board.printmap() - while True: - Board.player_input() - Board.update_position() - Board.printmap() - Board.check_event() + # Board = game.Game("Jian Lin") + # Board.random_map() + # Board.printmap() + # while True: + # Board.player_input() + # Board.update_position() + # Board.printmap() + # Board.check_event() + player = character.Player("Test") + print(player.gears) + print(player.store) if __name__ == "__main__": main() From 6300e7961403b3ceb6b1e1a625efff15ffb86833 Mon Sep 17 00:00:00 2001 From: Chenjinxuu <160599422+Chenjinxuu@users.noreply.github.com> Date: Wed, 21 Aug 2024 01:12:54 +0000 Subject: [PATCH 44/51] nothing --- main.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 629c17e2..126c38e3 100644 --- a/main.py +++ b/main.py @@ -1,12 +1,9 @@ - # Import statements import random import item import character - - import time, character, intro, game import rng @@ -28,6 +25,7 @@ # else: # print("Answer the question please") + def main(): Board = game.Game("Jian Lin") Board.random_map() @@ -38,5 +36,6 @@ def main(): Board.printmap() Board.check_event() + if __name__ == "__main__": pass From b08a8aeb74945c04ec63b6855ff6c472c9a62405 Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Wed, 21 Aug 2024 01:29:51 +0000 Subject: [PATCH 45/51] fixed backpack --- character.py | 16 +++++++--------- main.py | 10 ++++++++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/character.py b/character.py index c1ca48f6..5d6bea36 100644 --- a/character.py +++ b/character.py @@ -30,11 +30,10 @@ def backpack_isFull(self): total = 0 for itm in self.items.values(): total += itm.weight - print(total) return total >= self.mload def store(self, object): - if not self.backpack_isFull: + if not self.backpack_isFull(): if object.name in self.items: #item present self.items[object.name].num += object.num @@ -66,7 +65,6 @@ def store(self, object): else: print("Unable to store. Backpack is full.") - return False @@ -106,14 +104,14 @@ def unequip(self, section): print('Nothing is equipped there.') return False - if self.store(self.gears[section]) is False: + if self.backpack_isFull(): print(f'Backpack Full! {section} cannot be unequipped!') return False - - self.store(self.gears[section]) - self.gears[section] = None - print(f'{self.gears[section].name} unequipped') - return True + else: + self.store(self.gears[section]) + print(f'{self.gears[section].name} unequipped') + self.gears[section] = None + return True def combat(self, enemy: "Enemy"): print("\n") diff --git a/main.py b/main.py index 9abd1226..456cdb75 100644 --- a/main.py +++ b/main.py @@ -2,7 +2,7 @@ # Import statements #main game loop -import time, character, intro, game +import time, character, intro, game, item import rng def main(): @@ -16,7 +16,13 @@ def main(): # Board.check_event() player = character.Player("Test") print(player.gears) - print(player.store) + print(player.items) + print(not player.backpack_isFull()) + player.store(item.stone_sword) + print(player.items) + player.unequip("weapon") + print(player.items) + if __name__ == "__main__": main() From 0944c138ff1a2510770830ebfb8aab6a69928aec Mon Sep 17 00:00:00 2001 From: Chenjinxuu <160599422+Chenjinxuu@users.noreply.github.com> Date: Wed, 21 Aug 2024 01:40:08 +0000 Subject: [PATCH 46/51] nothing --- item.py | 6 +++--- main.py | 17 ----------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/item.py b/item.py index 6b9aa508..fadf3e7e 100644 --- a/item.py +++ b/item.py @@ -142,9 +142,9 @@ def potion_buff(self, player): #Potion list lesser_healing_potion = Potions(["Heals 2 hp to the player", 2, "healing", "lesser healing potion"]) -normal_healing_potion = ["Heals 5 hp to the player", 5, "healing", "normal healing potion"] -greater_healing_potion = ["Heals 10 hp to the player ", 10, "healing", "greater healing potion"] -supreme_healing_potion = ["Heals 20 hp to the player", 20, "healing", "supreme healing potion"] +normal_healing_potion = Potions(["Heals 5 hp to the player", 5, "healing", "normal healing potion"]) +greater_healing_potion = Potions(["Heals 10 hp to the player ", 10, "healing", "greater healing potion"]) +supreme_healing_potion = Potions(["Heals 20 hp to the player", 20, "healing", "supreme healing potion"]) strength_potion = Potions(["Add 10 att to the player's strength stats", 10, "attack", "strength potion"]) diff --git a/main.py b/main.py index 05eb617b..bd36a140 100644 --- a/main.py +++ b/main.py @@ -7,23 +7,6 @@ import time, character, intro, game import rng -# def main(): -# yes = True -# while True: -# print("Intro") -# time.sleep(1) -# print(intro_text) -# time.sleep(5) -# print("You wake up, dazed, who are you again?") -# player = classes.Player(str(input("What is your name?"))) -# while yes: -# confirm = input(f"Are you sure your name is {player}?(y/n):") -# if confirm == "y": -# yes = False -# elif confirm == "n": -# player = .Player(str(input("What is your name?"))) -# else: -# print("Answer the question please") def main(): From ed2cad3f49536e3143d39601088affc24c5cf11c Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Wed, 21 Aug 2024 01:47:07 +0000 Subject: [PATCH 47/51] shit --- main.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/main.py b/main.py index 456cdb75..1eb84068 100644 --- a/main.py +++ b/main.py @@ -6,22 +6,15 @@ import rng def main(): - # Board = game.Game("Jian Lin") - # Board.random_map() - # Board.printmap() - # while True: - # Board.player_input() - # Board.update_position() - # Board.printmap() - # Board.check_event() - player = character.Player("Test") - print(player.gears) - print(player.items) - print(not player.backpack_isFull()) - player.store(item.stone_sword) - print(player.items) - player.unequip("weapon") - print(player.items) + Board = game.Game("Jian Lin") + Board.random_map() + Board.printmap() + while True: + Board.player_input() + Board.update_position() + Board.printmap() + Board.check_event() + if __name__ == "__main__": main() From e448748f8bdabf21fcdd56d5a8f02f38e7f2cf22 Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Wed, 21 Aug 2024 01:55:27 +0000 Subject: [PATCH 48/51] fix all the damn bugs --- character.py | 128 ++++++++++----------------------------------------- game.py | 15 ++---- intro.py | 4 +- item.py | 83 +++++---------------------------- main.py | 8 +--- 5 files changed, 41 insertions(+), 197 deletions(-) diff --git a/character.py b/character.py index f9602604..417131da 100644 --- a/character.py +++ b/character.py @@ -1,57 +1,10 @@ - - -class Gears: - def __init__(self): - self.helmet = (None) - self.chestplate = (None) - self.leggings = (None) - self.boots = (None) - self.accessories = (None) - - -class Backpack: #store, display, check, destroy - def __init__(self, slots): - self.items = {} - self.backpack_size = slots - - def store(self, name, object): - if name in self.items: - self.items[name].num += object.num - print(f'{name} * {object.num} has been stored') - return - - if len(self.items) >= self.backpack_size: - print("Backpack is full!") - return - self.items[name] = object - print(f'{name} * {object.num} has been stored.') - return - - def display(self): - lst = [i for i in self.items.keys()] - disp = ', '.join(lst) - return disp - - def check(self, item): - pass - - -from item import Item -from item import Armor - - from typing import Any, Dict - import item import time - class Player: def __init__(self, name): self.name = str(name) - - self.max_health = 10 - self.current_health = 10 self.health = [10,10] self.defense = 0 self.attack = 1 @@ -70,12 +23,8 @@ def __init__(self, name): 'weapon': item.wooden_sword } - def __repr__(self): - return f"Name: {self.name}" - - - + return "P" def backpack_isFull(self): total = 0 @@ -83,29 +32,26 @@ def backpack_isFull(self): total += itm.weight return total >= self.mload - - - def store(self, object): if not self.backpack_isFull(): if object.name in self.items: #item present self.items[object.name].num += object.num - + weight = 0 for item in self.items.values(): weight += item.weight if weight > self.mload: print("That's too much for your bag to handle!") - + self.items[object.name].num -= object.num #Take back item return False - + print(f'{object.num} {object.name} has been stored') return True - + else: #new item self.items[object.name] = object - + total = 0 for item in self.items.values(): total += item.weight @@ -113,18 +59,15 @@ def store(self, object): print("That's too much for your bag to handle!") del self.items[object.name] return False - - print(f'{object.num} {object.name} has been stored.') - + print(f'{object.num} {object.name} has been stored.') + return True - return True else: print("Unable to store. Backpack is full.") - def display(self): lst = [i for i in self.items.keys()] disp = ', '.join(lst) #all items in backpack @@ -146,29 +89,21 @@ def equip(self, gear):#gear is type armor print("You don't have that gear!") return False #if that section is full, say you have it on - + if self.gears[gear.section] is not None: print(f'You already have a {gear.section} equipped.') return False - + #else, equip that gear self.gears[gear.section] = gear print(f'{gear.name} is equipped') return True - -class Object: - def __init__(self, name, num, description): - self.name = name - self.num = num - self.description = description - - def unequip(self, section): if self.gears[section] is None: print('Nothing is equipped there.') return False - + if self.backpack_isFull(): print(f'Backpack Full! {section} cannot be unequipped!') return False @@ -182,21 +117,21 @@ def combat(self, enemy: "Enemy"): print("\n") time.sleep(0.5) crit = 1 #if there is no crit does not change - + if self.gears["weapon"].crit(): crit = 2 # double the damage when it crits - + damage = (self.gears['weapon'].attack + self.attack - enemy.defense) * crit - + if damage <= 0: damage = 1 - + enemy.health -= damage - + print(f"You dealt {damage} damage to the {enemy.name}.") - + print(f"{enemy.name} current health:{enemy.health}") - + if enemy.health <= 0: enemy.health = 0 print(f"{enemy} fainted.") @@ -208,21 +143,6 @@ def combat(self, enemy: "Enemy"): class Enemy: - def __init__(self, type): - if type == "Brute": - self.name = "Brute" - self.health, self.attack, self.defense = 10, 2, 1 - elif type == "Armored Gorilla": - self.name = "Armored Gorilla" - self.health, self.attack, self.defense = 10, 1, 1000 - elif type == "Slime": - self.health, self.attack, self.defense = 5, 1, 0 - - - - - - def __init__(self, data: list): #name, health, defense, attack, speed self.name = data[0] self.health = data[1] @@ -232,7 +152,7 @@ def __init__(self, data: list): #name, health, defense, attack, speed def __repr__(self): return "E" - + def combat(self, player: "Player"): print("\n") @@ -244,6 +164,7 @@ def combat(self, player: "Player"): damage = 1 player.health[0] -= damage #lose health + print(f"You received {damage} damage from the {self.name}.")#print damage to player @@ -259,7 +180,7 @@ def combat(self, player: "Player"): class Boss(Enemy): def __init__(self, data): super().__init__(data) - + def __repr__(self): return "B" @@ -272,17 +193,16 @@ def combat(self, player: "Player"): if damage < 0: damage = 1 - player.health[0] -= damage #lose health + player.health -= damage #lose health print(f"You received {damage} damage from the {self.name}.")#print damage to player print(f"{player.name} current health:{player.health}") #print hp left - if player.health[0] <= 0: - player.health[0] = 0 + if player.health <= 0: + player.health = 0 print("You fainted. Skill Issue.") return -666 else: return False - \ No newline at end of file diff --git a/game.py b/game.py index e4d6c7b8..90982a48 100644 --- a/game.py +++ b/game.py @@ -1,18 +1,13 @@ from random import randint - -import character - import character, sys - class Game: def __init__(self, name): - self.n = 5 self.e = 12 self.enemies = {} self.map = [['.' for i in range(self.n)] for i in range(self.n)] self.player = character.Player(name) - + def printmap(self): for i in range(self.n): output = "" @@ -68,8 +63,8 @@ def player_input(self): print("Invalid move") else: print("You've reached the end of the dungeon") - - + + def update_position(self): self.map[self.player.coords[0]][self.player.coords[1]] = self.player self.map[self.player.last_move[0]][self.player.last_move[1]] = "X" @@ -102,7 +97,3 @@ def event_fight(self, player, enemy): elif result == -888: print("You have defeated the final boss") sys.exit() - - - - diff --git a/intro.py b/intro.py index 65c75459..1d5571f1 100644 --- a/intro.py +++ b/intro.py @@ -14,5 +14,5 @@ def intro(): yes = False elif confirm == "n": player = classes.Player(str(input("What is your name?"))) - - + else: + print("Answer the question please") \ No newline at end of file diff --git a/item.py b/item.py index fadf3e7e..0afb9cc1 100644 --- a/item.py +++ b/item.py @@ -6,7 +6,7 @@ def __init__(self, data: list):# name, num, desc, spec_weight self.num = data[1] self.desc = data[2] self.weight = data[3] * self.num - + class Armor: def __init__(self, section, data: list):#name, defense, num, spec_weight @@ -15,30 +15,9 @@ def __init__(self, section, data: list):#name, defense, num, spec_weight self.defense = data[1] self.num = data[2] self.weight = data[3] * self.num -wooden_helmet = Armor("helm", ["Wooden helmet", 1, 1, 1]) -wooden_chestplate = Armor("chest", ["Wooden chestplate", 3, 1, 2]) -wooden_leggings = Armor("leg", ["Wooden leggings", 2, 1, 1]) -wooden_boots = Armor("boots", ["Wooden boots", 1, 1, 1]) - -iron_helmet = Armor("helm", ["Wooden helmet", 2, 1, 1]) -iron_chestplate = Armor("chest", ["Wooden chestplate", 6, 1, 2]) -iron_leggings = Armor("leg", ["Wooden leggings", 4, 1, 1]) -iron_boots = Armor("boots", ["Wooden boots", 2, 1, 1]) - -diamond_helmet = Armor("helm", ["Diamond helmet", 3, 1, 1]) -diamond_chestplate = Armor("chest", ["Diamond chestplate", 9, 1, 2]) -diamond_leggings = Armor("leg", ["Diamond leggings", 6, 1, 1]) -diamond_boots = Armor("boots", ["Diamond boots", 3, 1, 1]) - - - - - - class Weapon: def __init__(self, data: list):#attack, critc, name, num, spec_weight - self.section = 'weapon' self.attack = data[0] self.critc = data[1] @@ -46,7 +25,6 @@ def __init__(self, data: list):#attack, critc, name, num, spec_weight self.num = data[3] self.weight = data[4] * self.num - def __repr__(self): return f"Att:{self.attack} Crit:{self.critc}% Name:{self.name}" @@ -56,21 +34,6 @@ def crit(self): return True return False - def combat(self, enemy, Player): - crit = 1 #if there is no crit does not change - if self.crit(): - crit = 2 # double the damage when it crits - damage = (self.attack + Player.attack - enemy.defense) * crit - if damage < 0: - damage = 1 - enemy.health -= damage - print(f"You dealt {damage} damage to the {enemy.name}.") - print(f"{enemy.name} current health:{enemy.health}") - if enemy.health <= 0: - enemy.health = 0 - print(f"{enemy} fainted.") - - #Weapon list #format att, critc @@ -78,12 +41,7 @@ def combat(self, enemy, Player): stone_sword = Weapon([5, 5, "Stone Sword", 1, 3]) iron_sword = Weapon([8, 10, "Iron Sword", 1, 4]) - - steel_sword = Weapon([12, 8, "Steel Sword", 1, 5]) -sword_of_baguette = Weapon([8, 28, "Bagutte Sword?", 1, 1]) - - fire_blade = Weapon([20, 5, "Fire Blade", 1, 0]) ice_blade = Weapon([12, 50, "Ice Blade", 1, 2]) @@ -116,40 +74,21 @@ class Potions: def __init__(self, data): self.desc = data[0] self.buff = data[1] - self.type = data[2] - self.name = data[3] - self.num = 1 - + def __repr__(self): return self.desc def potion_buff(self, player): - if self.type == "healing": - player.health += self.buff - - elif self.type == "attack": - player.attack += self.buff - - elif self.type == "speed": - player.speed += self.buff - - elif self.type == "all-in-one": - player.health += self.buff - player.attack += self.buff - player.speed += self.buff - player.defense += self.buff - + pass #Potion list -lesser_healing_potion = Potions(["Heals 2 hp to the player", 2, "healing", "lesser healing potion"]) -normal_healing_potion = Potions(["Heals 5 hp to the player", 5, "healing", "normal healing potion"]) -greater_healing_potion = Potions(["Heals 10 hp to the player ", 10, "healing", "greater healing potion"]) -supreme_healing_potion = Potions(["Heals 20 hp to the player", 20, "healing", "supreme healing potion"]) - - -strength_potion = Potions(["Add 10 att to the player's strength stats", 10, "attack", "strength potion"]) -speed_potion = Potions(["Add 5 speed to the player's speed stats", 5, "speed", "speed potion"]) -almond_potion = Potions(["Add 2 to each of the player's stat", 2, "all-in-one", "almond potion"]) -bleach = Potions(["Kills you instantly, toddler approved!", -9999999999999, "health", "Bleach ninety-year war", -9999999999999]) +lesser_healing_potion = Potions(["Heals 2 hp to the player", 2]) +normal_healing_potion = ["Heals 5 hp to the player", 5] +greater_healing_potion = ["Heals 10 hp to the player ", 10] +supreme_healing_potion = ["Heals 20 hp to the player", 20] +strength_potion = Potions(["Add 10 att to the player's strength stats", 10]) +speed_potion = Potions(["Add 5 speed to the player's speed stats", 5]) +almond_potion = Potions(["Add 2 to each of the player's stat", -0]) +bleach = Potions(["Kills you instantly, toddler approved!", -9999999999999]) \ No newline at end of file diff --git a/main.py b/main.py index 899ecf23..cf78f3c4 100644 --- a/main.py +++ b/main.py @@ -1,14 +1,9 @@ # Import statements - -import random -import item -import character +#main game loop import time, character, intro, game, item import rng - - def main(): Board = game.Game("Jian Lin") Board.random_map() @@ -19,6 +14,5 @@ def main(): Board.printmap() Board.check_event() - if __name__ == "__main__": main() From 906c507e804f641f0672193c16cd496f9d294cab Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Wed, 21 Aug 2024 08:22:34 +0000 Subject: [PATCH 49/51] added loot table, multiple commands, fixed layout and bugs --- character.py | 46 +++++++++++++++++++++----------- game.py | 75 +++++++++++++++++++++++++++++++++++++--------------- item.py | 33 ++++++++++++++++------- 3 files changed, 107 insertions(+), 47 deletions(-) diff --git a/character.py b/character.py index 417131da..a4265e11 100644 --- a/character.py +++ b/character.py @@ -5,16 +5,16 @@ class Player: def __init__(self, name): self.name = str(name) - self.health = [10,10] + self.health = 10 + self.max_health = self.health self.defense = 0 self.attack = 1 self.speed = 1 self.coords = (0, 0) - self.last_move = (0, 0) - self.event_queue = "" + self.last_move = (0, 0) #tracks the player's position last turn + self.event_queue = None #stores the event that the player is moving to (e.g. enemy fight) self.items = {} - self.mload = 10 - + self.mload = 10000000000000000000000 #fuck it who cares self.gears = { 'helm': None, 'chest': None, @@ -46,7 +46,7 @@ def store(self, object): self.items[object.name].num -= object.num #Take back item return False - print(f'{object.num} {object.name} has been stored') + print(f'1 {object.name} has been stored') return True else: #new item @@ -68,12 +68,18 @@ def store(self, object): - def display(self): - lst = [i for i in self.items.keys()] - disp = ', '.join(lst) #all items in backpack - return disp - + def display_inv(self): + print("-----\nInventory\n") + for i in self.items.keys(): + print(i, self.items[i].num) + print("-----\n") + def display_gears(self): + print("-----\nGears\n") + for i in self.gears.keys(): + print(f"{i}: {self.gears[i]}") + print("-----\n") + def check(self, object): if item in self.items.keys(): print(f'Name: {item}') @@ -83,8 +89,15 @@ def check(self, object): print('Item not in Backpack') return False + def trash(self, object): + if object.name not in self.items: + print("Invalid object entered") + else: + self.items[object.name].num -= 1 + if self.items[object.name].num <= 0: + del self.items[object.name] #Gears - def equip(self, gear):#gear is type armor + def equip(self, gear): #accepts object class if gear.name not in self.items: print("You don't have that gear!") return False @@ -97,9 +110,10 @@ def equip(self, gear):#gear is type armor #else, equip that gear self.gears[gear.section] = gear print(f'{gear.name} is equipped') + self.trash(self.gears[gear.section]) return True - def unequip(self, section): + def unequip(self, section): #accepts string of equipment type if self.gears[section] is None: print('Nothing is equipped there.') return False @@ -163,15 +177,15 @@ def combat(self, player: "Player"): if damage < 0: damage = 1 - player.health[0] -= damage #lose health + player.health -= damage #lose health print(f"You received {damage} damage from the {self.name}.")#print damage to player print(f"{player.name} current health:{player.health}") #print hp left - if player.health[0] <= 0: - player.health[0] = 0 + if player.health <= 0: + player.health = 0 print("You fainted. Skill Issue.") return -1 else: diff --git a/game.py b/game.py index 90982a48..46548fe7 100644 --- a/game.py +++ b/game.py @@ -1,10 +1,9 @@ -from random import randint -import character, sys +import random +import character, sys, item class Game: def __init__(self, name): - self.n = 5 - self.e = 12 - self.enemies = {} + self.n = 5 #length of sides of grid + self.e = 12 #num of enemies self.map = [['.' for i in range(self.n)] for i in range(self.n)] self.player = character.Player(name) @@ -12,7 +11,7 @@ def printmap(self): for i in range(self.n): output = "" for j in range(self.n): - output += str(self.map[i][j]) + output += str(self.map[i][j])+" " print(output) print("\n") print(f"Current Event:{self.player.event_queue}", type(self.player.event_queue)) @@ -22,24 +21,55 @@ def random_map(self): #randomise events in map self.map[0][0] = self.player #boss spawn while True: - coords = (randint(0, self.n-1), randint(0, self.n-1)) + coords = (random.randint(0, self.n-1), random.randint(0, self.n-1)) if self.map[coords[0]][coords[1]] == ".": - self.map[coords[0]][coords[1]] = character.Boss(["Overlord", 1, 5, 3, 1]) + self.map[coords[0]][coords[1]] = character.Boss(["Overlord", 50, 3, 5, 0.5]) #change values as needed break #enemies spawn for i in range(self.e): while True: - coords = (randint(0, self.n-1), randint(0, self.n-1)) - if self.map[coords[0]][coords[1]] == "." and not coords in self.enemies.keys(): - self.enemies[coords] = True + coords = (random.randint(0, self.n-1), random.randint(0, self.n-1)) + if self.map[coords[0]][coords[1]] == ".": + self.map[coords[0]][coords[1]] = character.Enemy(["Enemy", random.randint(3, 10), random.randint(1, 2), random.randint(1, 3), 1]) break - for i in self.enemies: - self.map[i[0]][i[1]] = character.Enemy(["Enemy", 5, 1, 1, 1]) #enter value next time + def help_cmds(self): + return "-----\nMovement\n\n'w'\n'a'\n's'\n'd'\n-----\nActions\n\n'trash' (remove item from inventory)\n'equip'\n'unequip'\n-----\nInfo\n\n'inventory'\n'gears'" + def player_input(self): while True: - move = input("Enter move: ") - if move=='w' and self.player.coords[0] > 0: + move = input("Enter move or 'help' to view all commands: ") + if move=="help": + print(self.help_cmds()) + elif move=="inventory": + self.player.display_inv() + elif move=="gears": + self.player.display_gears() + elif move=="equip": + if len(self.player.items.keys()) > 0: + self.player.display_inv() + move2=input("Enter what to equip: ") + while not move2 in self.player.items.keys(): + move2=input("Enter valid item: ") + self.player.equip(self.player.items[move2]) + else: + print("got nothing to equip lah") + elif move=="unequip": + self.player.display_gears() + move2=input("Enter what section to unequip (e.g. helm, chest etc AND NOT THE NAME OF THE ITEM): ") + while not move2 in ["helm", "chest", "legs", "boots", "weapon"]: + move2=input("Enter valid section: ") + self.player.unequip(move2) + elif move=="trash": + if len(self.player.items.keys()) > 0: + self.player.display_inv() + move2=input("Enter what to trash: ") + while not move2 in self.player.items.keys(): + move2=input("Enter valid item: ") + self.player.trash(self.player.items[move2]) + else: + print("got nothing to trash lah") + elif move=='w' and self.player.coords[0] > 0: self.player.event_queue = self.map[self.player.coords[0] - 1][self.player.coords[1]] self.player.last_move = self.player.coords self.player.coords =(self.player.coords[0] - 1, self.player.coords[1]) @@ -59,10 +89,8 @@ def player_input(self): self.player.last_move = self.player.coords self.player.coords =(self.player.coords[0], self.player.coords[1] + 1) break - elif not move in ["w", "a", "s", "d"]: - print("Invalid move") else: - print("You've reached the end of the dungeon") + print("Invalid move") def update_position(self): @@ -89,11 +117,16 @@ def event_fight(self, player, enemy): i = 0 else: i += 1 - if result == -1: + if result == -1: #defeat against normal enemy sys.exit() - elif result == -666: + elif result == -666: #defeat against boss print("The final boss has killed you...") sys.exit() - elif result == -888: + elif result == -888: #win against boss print("You have defeated the final boss") sys.exit() + elif result == True: #win against normal enemy + self.player.health = self.player.max_health + reward = random.choice(item.loot_table) + print(f"You have obtained {reward}") + self.player.store(reward) diff --git a/item.py b/item.py index 0afb9cc1..cafe0d96 100644 --- a/item.py +++ b/item.py @@ -16,6 +16,13 @@ def __init__(self, section, data: list):#name, defense, num, spec_weight self.num = data[2] self.weight = data[3] * self.num + def __repr__(self): + return f"{self.name}" + + def get_stats(self): + return f"Item Description\n-----\nName: {self.name}\nDefense: {self.defense}\nItem Stack: {self.num}\nTotal Weight: {self.weight}\n-----" + + class Weapon: def __init__(self, data: list):#attack, critc, name, num, spec_weight self.section = 'weapon' @@ -26,7 +33,10 @@ def __init__(self, data: list):#attack, critc, name, num, spec_weight self.weight = data[4] * self.num def __repr__(self): - return f"Att:{self.attack} Crit:{self.critc}% Name:{self.name}" + return f"{self.name}" + + def get_stats(self): + return f"Item Description\n-----\nName: {self.name}\nAttack: {self.attack}\nCrit Chance: {self.critc}\nItem Stack: {self.num}\nTotal Weight: {self.weight}\n-----" def crit(self): x = random.randint(1, 100) @@ -34,6 +44,7 @@ def crit(self): return True return False + #Weapon list #format att, critc @@ -60,15 +71,15 @@ def crit(self): #Armors #wood 1, iron 2, diamond 3 #helm, boots 1, legs 2, chest 3 -iron_helmet = Armor('helm', ['iron_helmet', 2, 1, 10]) -iron_chestplate = Armor('chest', ['iron_chestplate', 6, 1, 16]) -iron_leggings = Armor('leg', ['iron_leggings', 4, 1, 14]) -iron_boots = Armor('boots', ['iron_boots', 2, 1, 8]) +iron_helmet = Armor('helm', ['Iron Helmet', 2, 1, 10]) +iron_chestplate = Armor('chest', ['Iron Chestplate', 6, 1, 16]) +iron_leggings = Armor('leg', ['Iron Leggings', 4, 1, 14]) +iron_boots = Armor('boots', ['Iron Boots', 2, 1, 8]) -diamond_helmet = Armor('helm', ['diamond_helmet', 3, 1, 5]) -diamond_chestplate = Armor('chest', ['diamond_chestplate', 9, 1, 8]) -diamond_leggings = Armor('leg', ['diamond_leggings', 6, 1, 7]) -diamond_boots = Armor('boots', ['diamond_boots', 3, 1, 4]) +diamond_helmet = Armor('helm', ['Diamond Helmet', 3, 1, 5]) +diamond_chestplate = Armor('chest', ['Diamond Chestplate', 9, 1, 8]) +diamond_leggings = Armor('leg', ['Diamond Leggings', 6, 1, 7]) +diamond_boots = Armor('boots', ['Diamond Boots', 3, 1, 4]) class Potions: def __init__(self, data): @@ -91,4 +102,6 @@ def potion_buff(self, player): speed_potion = Potions(["Add 5 speed to the player's speed stats", 5]) almond_potion = Potions(["Add 2 to each of the player's stat", -0]) -bleach = Potions(["Kills you instantly, toddler approved!", -9999999999999]) \ No newline at end of file +bleach = Potions(["Kills you instantly, toddler approved!", -9999999999999]) + +loot_table = [wooden_sword, stone_sword, iron_sword, steel_sword, fire_blade, ice_blade, diamond_sword, forty_metre_long_sword, iron_helmet, iron_chestplate, iron_leggings, iron_boots, diamond_helmet, diamond_chestplate, diamond_leggings, diamond_boots] \ No newline at end of file From 0610fca122efb056ac9e71c0f81d0b4b5069e741 Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Wed, 21 Aug 2024 08:28:28 +0000 Subject: [PATCH 50/51] spacing in text --- game.py | 5 ++++- intro.py | 38 ++++++++++++++++++++------------------ main.py | 7 +++++++ 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/game.py b/game.py index 46548fe7..8c07e581 100644 --- a/game.py +++ b/game.py @@ -8,13 +8,15 @@ def __init__(self, name): self.player = character.Player(name) def printmap(self): + print("\n-----\nMap\n\n") for i in range(self.n): output = "" for j in range(self.n): output += str(self.map[i][j])+" " print(output) - print("\n") print(f"Current Event:{self.player.event_queue}", type(self.player.event_queue)) + print("-----\n") + def random_map(self): #randomise events in map #player spawn @@ -126,6 +128,7 @@ def event_fight(self, player, enemy): print("You have defeated the final boss") sys.exit() elif result == True: #win against normal enemy + print("\n") self.player.health = self.player.max_health reward = random.choice(item.loot_table) print(f"You have obtained {reward}") diff --git a/intro.py b/intro.py index 1d5571f1..0377c715 100644 --- a/intro.py +++ b/intro.py @@ -1,18 +1,20 @@ -import time, character -def intro(): - yes = True - while True: - print("Intro") - time.sleep(1) - print("Myserious voice: 'I don't care! I seriously DON'T CARE! I have locked you up in my dungeon and you will never ever have the slightest of slimmer of hope in having the ability to even attempt to escape from this hell Ho of mine!") - time.sleep(5) - print("You wake up, dazed, who are you again?") - player = character.Player(str(input("What is your name?")), 5) - while yes: - confirm = input(f"Are you sure your name is {player}?(y/n):") - if confirm == "y": - yes = False - elif confirm == "n": - player = classes.Player(str(input("What is your name?"))) - else: - print("Answer the question please") \ No newline at end of file +#fuck it dont use this lol + +# import time, character +# def intro(): +# yes = True +# while True: +# print("Intro") +# time.sleep(1) +# print("Myserious voice: 'I don't care! I seriously DON'T CARE! I have locked you up in my dungeon and you will never ever have the slightest of slimmer of hope in having the ability to even attempt to escape from this hell Ho of mine!") +# time.sleep(2) +# print("You wake up, dazed, who are you again?") +# name = input("What is your name?") +# while yes: +# confirm = input(f"Are you sure your name is {player}?(y/n):") +# if confirm == "y": +# yes = False +# elif confirm == "n": +# player = classes.Player(str(input("What is your name?"))) +# else: +# print("Answer the question please") \ No newline at end of file diff --git a/main.py b/main.py index cf78f3c4..f86be5de 100644 --- a/main.py +++ b/main.py @@ -5,6 +5,13 @@ import rng def main(): + print("Myserious voice: 'I don't care! I seriously DON'T CARE! I have locked you up in my dungeon and you will never ever have the slightest of slimmer of hope in having the ability to even attempt to escape from this hell of mine!") + time.sleep(2) + print("You wake up, dazed, who are you again?") + name = input("\nWhat is your name?") + time.sleep(1) + print("\nwell, i dont care what your name is") + time.sleep(2) Board = game.Game("Jian Lin") Board.random_map() Board.printmap() From 4712d47645c7a6165d167a513929553d6552d98e Mon Sep 17 00:00:00 2001 From: Matthew <96619454+LichasX@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:39:49 +0000 Subject: [PATCH 51/51] fixed unequip bug which adds duplicates items --- character.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/character.py b/character.py index a4265e11..4401b39b 100644 --- a/character.py +++ b/character.py @@ -35,14 +35,12 @@ def backpack_isFull(self): def store(self, object): if not self.backpack_isFull(): if object.name in self.items: #item present - self.items[object.name].num += object.num - + self.items[object.name].num += 1 weight = 0 for item in self.items.values(): weight += item.weight if weight > self.mload: print("That's too much for your bag to handle!") - self.items[object.name].num -= object.num #Take back item return False