terraform { required_providers { aws = { source = "hashicorp/aws" version = "5.42.0" } } } provider "aws" { # Configuration options region = "us-east-1" }
terraform { required_providers { aws = { source = "hashicorp/aws" version = "5.42.0" } } } provider "aws" { # Configuration options region = "us-east-1" }
<p><span id="docs-internal-guid-b2dfb759-7fff-95c0-55f4-a389659e72db"> <p style="text-align: center;" dir="ltr"><a href="https://fubar.com/help.php"><span><span><img src="https://lh7-us.googleusercontent.com/AS_6ErgLyAZjO-cyJJusu2OXmo9Uc78P-2VV1KdhsOHvCF_4709z4Ndjm_NjzeY92DYfA4cSqTWIxfL-I6S-WtVc6UZuvLsByhuHWVnoRw34PISliFGTrazcoD7E0cYv0o67mUqzLGUNaGxTc0Qluuo" alt="" width="167" height="29" /></span></span></a><a href="https://fubar.com/bible.php"><span><span><img src="https://lh7-us.googleusercontent.com/7VYukQZVgvTWczLF6IX42CS31wgjCeQ-AIVtKPhQ6bSQPAAKRnMsl9Kyn7ACOZ9LUtdMcaX75dgQNAJgJBVkUhUG6e3g_B9_gSk66x1GaINmEBPYDA-taaZryvgcMqgsmO6i6oK_q8Zm3RkAbVZrWjM" alt="" width="123" height="29" /></span></span></a><a href="https://www.fubar.com/tos.php"><span><span><img src="https://lh7-us.googleusercontent.com/zvPg--LpxDfbbruKbhy9NvaOo7jN5Z79P9LsT467si5JRw2A2cX69NUa012Yedv6jZIGspw7DfF-lwO28FrWQ_GHACuzNnwRCsQ7uFY_aM21xeiSMBEJvhFcVYLDCdYbMDQU6cwX-PdBQnn38FnxBto" alt="" width="118" height="29" /></span></span></a><span><span><img src="https://lh7-us.googleusercontent.com/R1-CexrNv6-1VWqnPe5eEmYkz2KJmMz0WUCQjdHC8v1nsKK0RrtlcfkXrc5MHS0BquyCKdIgq957pKCtdc8RUUPEbfZfU2yZelEhQKsXk96LQVIvORiV39Z4KBfqn8y-ImCFOHJGO6T9_EAiX73tst0" alt="" width="133" height="29" /></span></span><a href="http://www.fubar.com/emotes.php"><span><span><img src="https://lh7-us.googleusercontent.com/1EbUT6D5e67f2G1LooAWr0Y_gMCh42VMKArtKqjKWOC8oZdrX6XmBNNf_OJhKqV9t3oRInOY6CioKVE_1m0xTeTpakamgA8zdSgbn5AqPuSHSu3alcGNcxR-l6lephRN7olNBhifn31ZUblw0ecdS_U" alt="" width="140" height="29" /></span></span></a><a href="https://fubar.com/bling.php?sent=1"><span><span><img src="https://lh7-us.googleusercontent.com/cLLESvDim8BLI6riyLKF_Wyqq4NbuC2wV29lrfq9fNIHk5788qm_AfIqq1QxDJg4pmp-E2_f-0LfvzenYd9Q6zRn2GyRAVr4Ttb8KkfON8xwL_HyoUxfAkJN4RJ4uTFk0zkU9gF__p-40jFpkhhCc-k" alt="" width="157" height="29" /></span></span></a><a href="http://fubar.com/marriage.php"><span><span><img src="https://lh7-us.googleusercontent.com/--Y5gdWGEvFN9vLuzw8XJ4aguq-5haohE1M626iGXmuRTtVw2LchNYf-W0NLRVFO7877Jt98eI5NbRy5M9e05MEO2mKdwNnKq-2pmumSd3zwIbBzrWmm6oyu7vB-Io87MhnxYmNyjYaH1nZLmHhiMYU" alt="" width="115" height="29" /></span></span></a><a href="https://fubarswag.myspreadshop.com/"><span><span><img src="https://lh7-us.googleusercontent.com/afwJ4ZVl7H8v-ZhiunHWT5y3DckLdxmfA5DQcCXYkxQzngd11Xnh3CxLo-YVqyCDg2Cxmee_gPZZausdFQlC6cBvXowdkFEbaNyPg63oMmf7fUayu0bhZ0aP9lqY9qjUzD4wPd0BbiY27Fr_NMF4yCY" alt="" width="126" height="29" /></span></span></a><a href="https://fubar.com/vip.php"><span><span><img src="https://lh7-us.googleusercontent.com/QZ2OcjIYSmjzTLYTG3pycapeeNCO3ybGbaZFGetiwMFCZY5EfbaV9ybJD3LiYkG6M5Eqq1K5JF1rcse9Utm0KD4Nm6O8S2e86GaqIBkk20YlLSQvrMAnWZDxQgcoqkIsC9ocNGPjC_x0ecyYOgZusj0" alt="" width="98" height="29" /></span></span></a><a href="https://fubar.com/quick-like-polish-list/b373141"><span><span><img src="https://lh7-us.googleusercontent.com/XHWZmdYJdCrmraq0l09WsCGutvgReRZMLngyw9f7l4NOcCdU2uEHjrcEFpB_NbF0_pROdgsVK4eaWJrOv0qODJb4mcgPetQ9hQ0f9VFoEXCW7hAUjR0uFg_rZX5VeIsx7vZ1Dih_bKL0Yd-AS0h-jkI" alt="" width="195" height="29" /></span></span></a><a href="https://fubar.com/help-blogs/b361314-1318694"><span><span><img src="https://lh7-us.googleusercontent.com/HASoCfybVQLD3CUnVuD2ZDhrHy-y0MXlS8W-f0eo4gDOOxGstLG8uMpyuDyyCAZsUz9Nj7JsoDtVQs2nOb2apV20mi0lWO1zxX33Z_netYjOmSyMD48ISZXd-Qo2ntloX6gjC_T02sR6qBQXkINfeck" alt="" width="170" height="29" /></span></span></a><a href="https://fubar.com/blogs.php?u=22"><span><span><img src="https://lh7-us.googleusercontent.com/sosnogzSd52Q-Shgz4oEVXV04COAAb8dUTrjBoCtxXsePmGoyOJRbb3joVu9n1kzGF0Kv1MkElN74OdArwo1arpcVZ2CcueKRFfiHiiuSTLnV-tt246ydtX6WbbXl6E3TzT1Xl37g213fF_G-nlqI5c" alt="" width="150" height="29" /></span></span></a><a href="https://fubar.com/lounge/support"><span><span><img src="https://lh7-us.googleusercontent.com/6bM3PRvSAfry8L40lqpI5h0r2H2JW77wzBrCgYPki3ntb8afITOkiiiDW4NDIpGTZom3OS9kwkdIkXQkFrIifFMKQtqrKamOi0P1W_pPgGz1qcE_PFVIM7EPy58tnvNN3bXP05nr2q-qhyG0UMARGeE" alt="" width="197" height="29" /></span></span></a></p> </span></p>
<p><span id="docs-internal-guid-c063cc90-7fff-c052-f69f-c65bde1a5198"> <p style="text-align: center;" dir="ltr"><a href="https://fubar.com/help.php"><span><span><img src="https://lh7-us.googleusercontent.com/eoIKjq8Lj5vGXYr23C603edvGjuizwVU3dhnsRjpnXq5ZPahYaDBeJ4gvpa0wB4vBOaZEa90yjFwAZ6jFKOai3lEULc7mNK7yg8i4GF8x6MAFTb7nVigVrCBrXmleKcakTvrMAMfbKx4v2o0dRy46_4" alt="" width="171" height="31" /></span></span></a><a href="http://www.fubar.com/bible.php"><span><span><img src="https://lh7-us.googleusercontent.com/Sa1oMFB8nR3hoVf8TQjPPOYvGcc45ilQy6FIEJGHcW2eAIJ3hY0JunNmNTGvYZHV3PrdKZ284lVTdxvua4bpDgOFFtw7R2Ik0jYmUYmeDamg1J7I1H-XYNOkGdDaIbqnQK0sGmaMznJBLpNtvYreyS4" alt="" width="124" height="31" /></span></span></a><a href="http://www.fubar.com/emotes.php"><span><span><img src="https://lh7-us.googleusercontent.com/jpBeqNHNVeyb6KOH2-grCsV1HxSH1S3nas6NWlBOvvIvL4zrvs8Wh-e8D3Hr7T4T3yXQ9OR4eAzR0l3ipy5bAUxlyydaKdVjVf2ZBAirh8IDZJIoYQwhXArfI5I5k-osqVX_qkzr2cODSfRCacMiuno" alt="" width="139" height="31" /></span></span></a><a href="http://fubar.com/blast_list.php"><span><span><img src="https://lh7-us.googleusercontent.com/4DKP_aQccqU9boUV1AfD9n9P8m1JMOkDMild_FeS_S_ZJeZOHvzTgwQdE74pryagiJzC5I0wNPMcKcGK4OhWif4CmuYuXdhh5Kng49gjtWaounHg9pMTLNz1iVWJrzfiQ0y20R_RvqKiFqDLF0iBHxw" alt="" width="136" height="31" /></span></span></a><a href="https://fubar.com/blogs.php?u=22"><span><span><img src="https://lh7-us.googleusercontent.com/sFpB4jDty-47vvlFYp0331mBeBfEJScVvQwClFGfJITalCL3M3Y_qg3gSlK9EKYlrrtwqrnujtL98Z_eZ_JC3TsZzEunVq34OTMjsCTGZFC6snL5_w4iOMw9eEfEpmUOP833d4NNiy7zDkmL64Aakhg" alt="" width="148" height="31" /></span></span></a><a href="https://fubar.com/quick-like-polish-list/b373141"><span><span><img src="https://lh7-us.googleusercontent.com/HxZOuTXtQg4aaPsXNnCUKtdUq3XoRYS0jDKBWXEKf2GsxSFCKZRCdClVc0SJHsG5tHqoY8hXTkBUt0PYmTV2sqBnHNtn1ODh9x49oyhWCmlFd6B9GwS01oNu0_EFJYL1gc4XQ9wa2MB-qruNCjh71pU" alt="" width="193" height="31" /></span></span></a><a href="https://fubar.com/help-blogs/b361314-1318694"><span><span><img src="https://lh7-us.googleusercontent.com/JmCFewX5mvobxPVLjXuF2fPZsiVHPq6ZRwVhjUm2_BHban3LtviKsAMYsOvFe4B5N5FzgA_FkVkw6YvOZrYrb02B6axfntOYz38TxXPX2vT46IH3NIbBlHoeHC89x0RwY1bo5PEwHNCUAqTOkxezLPs" alt="" width="170" height="31" /></span></span></a><a href="https://fubar.com/bling.php?sent=1"><span><span><img src="https://lh7-us.googleusercontent.com/XFavoQjj9JND-PeSPLZFjuyNM3LCgZFXZQdU8C8vCXA1RrT3YE842GViZgbzd2YMOYVeCTX_MjxySoSTWhYbQncPQu-nkSOW0dPgkECujCMeL_wV0_vVGP2Nt3fhfzmAklb0I0fdmDDiN-mDxbe6gco" alt="" width="153" height="31" /></span></span></a><a href="http://fubar.com/marriage.php"><span><span><img src="https://lh7-us.googleusercontent.com/22zHjcoLhGl_sHimgLyyX-GdbILDnmFZrBNw2oCCiNusItGB-uRaH9hnpYgNbYg2Ur6F9hV0GoAw1b-jW2i4rLBoEl8pCxoUYGGkAM20ArHUbvEwwiwwbxh4iqiiVM7nvuWOwxpBieyZSpEeE-5kQhE" alt="" width="112" height="31" /></span></span></a><a href="https://fubar.com/vip.php"><span><span><img src="https://lh7-us.googleusercontent.com/OvJdmvNrB1BmGOWFnDDIgAbxu3XPhqRhsMsQEPfJ4MjpZOPjAGKrOXBOKdZyBBmfwKx8KT7wzqW2t-7giDZ_vkpwqkNW6ye35WH7Aj3fN9MkJbwacevvkgzvg5ifWNffoMrBmUbnu3GUcZL3nFDJO18" alt="" width="97" height="31" /></span></span></a><a href="https://shop.spreadshirt.com/fubarswag"><span><span><img src="https://lh7-us.googleusercontent.com/86mBNobTJHjKTT0V22Q4KFOXLnUaqIG1lraAXkzNMyLWZ1UxFogkgektlsVbUaA_RnK14xQ_Rzia8M7iNgGI5ltEw2FQDxR8EiRAKv6radwQlG9AXAUfLwIgyvbWpPiKii_zytxf8P4iSHAGnxsHsnQ" alt="" width="125" height="31" /></span></span></a><a href="https://www.fubar.com/tos.php"><span><span><img src="https://lh7-us.googleusercontent.com/QBjLrz2Rvx1stYPQIJozGlupNI-otWGnSokByObd2LOK_jM3pqWDkUP0YCiXvgM29K4JqVsSJ1CW3_F1S-7mpJilFfTJ5pc39vLhiLw2yUPoMTPQj5ESWiXzIb4RMKgTGJp3nsyAcSZLcqTpqBA9w2E" alt="" width="122" height="31" /></span></span></a><a href="https://fubar.com/lounge/support"><span><span><img src="https://lh7-us.googleusercontent.com/Bu8JXCpfUccduNZTZpqAcmPhZu0VQCJXJM2G_dJJ6NkaMJQxl-e7DLKZwKXhdvAa597708Q4jMsEtecFRc-wQSwTZxxkERo6J5Fx1dJM0DJ7LCoTjjieJRkD3enrDwBkM8IFZse3fyU1ei5ie0EoN9c" alt="" width="195" height="31" /></span></span></a></p> </span></p>
<p><span id="docs-internal-guid-e7a2c036-7fff-ede2-9112-77f8a244da27"> <p style="text-align: center;" dir="ltr"><a href="http://www.fubar.com/tos.php"><span><span><img src="https://lh7-us.googleusercontent.com/4RirJqOPJvJ7EdZy_SexPV9MOGqsXBDYV1mwesdJKl8Ze6n4Bl2nWNnWO8PXJDjXjXC5u1tr8u4zB99Ctt0TaM1mQhnDYuLsr1u_yQOA_7V-KemDuKSGNwPVTtMd9RuvR2tqWrN6i4DlbucEG-HfO-s" alt="" width="125" height="37" /></span></span></a><a href="https://fubarswag.myspreadshop.com/"><span><span><img src="https://lh7-us.googleusercontent.com/RRywQ3rLCK7G_4PTLAz2nM6pC8uz_5cQGmVSqOs6opp8J19sfA4QumvzkMtMFf7qH5p8AQQ2FlmgHTGs7Zf4M_tXIJXQA9satGe8ghq8B_iSLqDrwWzdWA8m-ntGuT4Iqr_RhwW6_viGNFXfYgr9130" alt="" width="125" height="37" /></span></span></a><a href="https://fubar.com/vip.php"><span><span><img src="https://lh7-us.googleusercontent.com/zbR3bC1TevfMrv7AY_qKd9MLXfZ_KWUCyON8aIOWu8TtNyipcCVD9DSn9NwR_8HSod7eP9nk1dhGbcPGi80RwuwDZFqJpnQHM1UuFdettaTa2hc6qcmB2OCUZ3ODQjeBfqZCe93qxUjOWRO3U4ze8-Q" alt="" width="103" height="37" /></span></span></a><a href="http://fubar.com/marriage.php"><span><span><img src="https://lh7-us.googleusercontent.com/spmTuK0_jOKnKGPGkk8M_j4PO7oGMM1OtWpzN2IlfIAy4GMzr679_BRglunlvBzncHrfwb0MBuPvB7IUG369fRxi4BXFiORXZSbnn_YZDarAvX_qUtCES7nYYiX3g5j6UfqeoM6PBH_b82q4emaaTJ8" alt="" width="118" height="37" /></span></span></a><a href="https://fubar.com/bling.php?sent=1"><span><span><img src="https://lh7-us.googleusercontent.com/6NQ2e7ibtvUkvsEwjX27My4qUgHK5aIXbeOSB5nyDeYuffZiF7FrsJ1k1tCJ1457hOeOd6zXRIvEU0OzDr3CT1-_HvyFFG0yvHOl0Y5dcul3Y04ya1TLJaa_J6Mg45fUf4eZFG5fSR5e5fOrOjenHAQ" alt="" width="131" height="37" /></span></span></a><a href="https://fubar.com/help-blogs/b361314-1318694"><span><span><img src="https://lh7-us.googleusercontent.com/WNjhT7srwLjoFtQvh3LrbTLK2fIp8zDwfsEevhMFx5Ec6YkBKo-4b3SUeUPh0hnBnm9E1f_aOwxKmRNdtvf-3l4kVkpqyFEZE7P9gIwCryu95xy3Jfb3E6RxtCimWy2PfpHYPHDi179LeIQsh2F_-9o" alt="" width="161" height="37" /></span></span></a><a href="https://fubar.com/quick-like-polish-list/b373141"><span><span><img src="https://lh7-us.googleusercontent.com/MrJYWY4WUDa-T0yiHxT81NzKoUWRpZ76kERJGgj47mLED9T050M_DqNSmjAlQ1MYrWiefwvUzVihSfVrJ2ot_ahldLho-ixNHNrfl4CkMFfIwnaXIlWgkJ0kIGJbRgHMhFsu_R-_OoVpFmCisyYZ3CU" alt="" width="181" height="37" /></span></span></a><a href="https://fubar.com/blogs.php?u=22"><span><span><img src="https://lh7-us.googleusercontent.com/bChBtxk6d9nC3BEXlMzvtgRuBu6siJjCICiU0Hct_FEKkZNl4TWAtmdqsF5zDyiNWSv8UfQhM7Ro_XsEdpZVMz-Ri0m4R1s60sH-Kurkutud8QDM-mEX4Xl_PlrV1SVi1d4sHVefrlFhWMHQIdc8pls" alt="" width="157" height="37" /></span></span></a><a href="https://fubar.com/lounge/support"><span><span><img src="https://lh7-us.googleusercontent.com/83kwO-pC849VWYH0G4pD7oQu1cWC-OLGXFSOYJeiPp98aJ1RFFC9Mq1noJ7PAwMq3fIc3iA23vOfT1Hj4_ZbqnAcufqqmB1eXVt3COtLnAqpcgzRf-5rkeqNvxSJH1zG0aFnv3FMAVCYcoDVMe6ITAs" alt="" width="174" height="35" /></span></span></a><a href="http://fubar.com/blast_list.php"><span><span><img src="https://lh7-us.googleusercontent.com/pEsGFlKNo8kKNNLlYhfcrqFNguYMIDcKskwbT51G5bZx6AZKUAI2rdBehgh5qIiK9xdkiwO3MG0L5jYwKQNHc8nh3JpBfU5L3HOSL9PMEL7UkQooCheE0pphAoQZjoNK5olGdqHGJWtK3C-GxLeC7OY" alt="" width="143" height="37" /></span></span></a><a href="http://www.fubar.com/emotes.php"><span><span><img src="https://lh7-us.googleusercontent.com/0C6MFFMtR4m8qKZONkwWpqMX8YE5wmRAf-TQLeuV7gX7SDs-NV18C-CIF1A3m-l3DleHQ1gqTILjQ9hkBloiS4gvutZK6oH6ic8pS6irih1TjxxsrfxfzcLr236YaC-GsmF0ZxiNMREtDKFkR3C6GuU" alt="" width="140" height="37" /></span></span></a><a href="https://fubar.com/bible.php"><span><span><img src="https://lh7-us.googleusercontent.com/Zr-aHl3LM-BOE02tnt0qAWs5oYGmhL0dNie06gkAQaH14GA7pMG2gWXOc2ujiuyGjZLMfV64F5Dj5bvDVyeDQqGScqt__n9ZGXcdohAaifGOEI027eGIylaFL27qLkvD2ovSRg9vsPXWsBNfk23ojGY" alt="" width="134" height="37" /></span></span></a></p> </span></p>
import random import os import time class Character: def __init__(self, name, hp, attack): self.name = name self.hp = hp self.max_hp = hp self.attack = attack self.curses = 0 self.burned = False self.critical = False self.piercing = False def is_alive(self): return self.hp > 0 def take_damage(self, damage): self.hp -= damage self.hp = max(0, self.hp) def attack_enemy(self, enemy): damage = random.randint(1, self.attack) print(f"{self.name} attacks {enemy.name} for {damage} damage!") enemy.take_damage(damage) if random.random() < 0.25: # 25% chance to apply debuffs enemy.inflict_debuff() def apply_curse(self): if self.curses < 5: self.curses += 1 print(f"{self.name} is cursed! Curse level: {self.curses}") else: print("Curse maxed out!") def remove_curse(self): if self.curses > 0: self.curses -= 1 print(f"{self.name} removes a curse. Curse level: {self.curses}") else: print("No curses to remove.") def inflict_debuff(self): debuffs = ["Burned", "Critical", "Piercing"] debuff = random.choice(debuffs) if debuff == "Burned": if not self.burned: self.burned = True print(f"{self.name} is burned!") else: print(f"{self.name} is already burned!") elif debuff == "Critical": if not self.critical: self.critical = True print(f"{self.name} receives a critical hit!") else: print(f"{self.name} is already under the effect of a critical hit!") elif debuff == "Piercing": if not self.piercing: self.piercing = True print(f"{self.name} ignores defenses!") else: print(f"{self.name} is already ignoring defenses!") def display_health_bar(self): bar_length = 20 filled_length = int(round(bar_length * self.hp / self.max_hp)) curses_display = "^" * self.curses bar = '♥' * filled_length + '-' * (bar_length - filled_length) print(f"{self.name} Hearts: [{bar}] {self.hp}/{self.max_hp} {curses_display}") class Enemy(Character): def __init__(self, name, hp, attack): super().__init__(name, hp, attack) def attack_enemy(self, player): damage = random.randint(1, self.attack) print(f"{self.name} attacks {player.name} for {damage} damage!") if random.random() < 0.25: # 25% chance to apply debuffs player.inflict_debuff() player.take_damage(damage) class Boss(Character): def __init__(self, name, hp, attack): super().__init__(name, hp, attack) def display_health_bar(self): bar_length = 20 filled_length = int(round(bar_length * self.hp / self.max_hp)) bar = '♥' * filled_length + '-' * (bar_length - filled_length) print(f"{self.name} Hearts: [{bar}] {self.hp}/{self.max_hp}") def attack_enemy(self, player): damage = random.randint(1, self.attack) print(f"{self.name} attacks {player.name} for {damage} damage!") if random.random() < 0.25: # 25% chance to apply debuffs player.inflict_debuff() player.take_damage(damage) import os import time def battle(player, enemy): print(f"A wild {enemy.name} appears!") while player.is_alive() and enemy.is_alive(): os.system('clear') # Clear the screen player.display_health_bar() enemy.display_health_bar() print("\nYour Turn") print("1. Attack") choice = input("Enter your choice: ") if choice == "1": player.attack_enemy(enemy) if not enemy.is_alive(): print(f"{enemy.name} has been defeated!") player.inventory.append(f"{enemy.name}'s loot") gold_dropped = 0 # Calculate gold dropped based on enemy type if isinstance(enemy, Boss): gold_dropped = random.randint(150, 400) else: gold_chance = random.random() if gold_chance < 0.7: gold_dropped = random.randint(15, 15) elif gold_chance < 0.9: gold_dropped = random.randint(20, 20) else: gold_dropped = random.randint(25, 25) player.gold += gold_dropped print(f"{enemy.name} dropped {gold_dropped} gold!") time.sleep(2) # Wait for 2 seconds to display the loot message os.system('clear') # Clear the screen after loot message break else: time.sleep(1) # Wait for 1 second before clearing the screen else: print("Invalid choice. Try again.") # Enemy's turn if enemy.is_alive(): os.system('clear') # Clear the screen before enemy's turn print("\nEnemy Turn") enemy.attack_enemy(player) time.sleep(1) # Wait for 1 second before clearing the screen os.system('clear') # Clear the screen after enemy's attack if player.burned: print(f"{player.name} is burned!") player.burned = False # Remove the burned debuff after displaying it elif player.critical: print(f"{player.name} is under the effect of a critical hit!") player.critical = False # Remove the critical debuff after displaying it elif player.piercing: print(f"{player.name} ignores defenses!") player.piercing = False # Remove the piercing debuff after displaying it if player.is_alive(): print("You win!") if not player.is_alive(): print("Game over!") time.sleep(2) # Wait for 2 seconds before clearing the screen os.system('clear') # Clear the screen after game over print(""" ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣠⡀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣤⠀⠀⠀⢀⣴⣿⡶⠀⣾⣿⣿⡿⠟⠛⠁ ⠀⠀⠀⠀⠀⠀⣀⣀⣄⣀⠀⠀⠀⠀⣶⣶⣦⠀⠀⠀⠀⣼⣿⣿⡇⠀⣠⣿⣿⣿⠇⣸⣿⣿⣧⣤⠀⠀⠀ ⠀⠀⢀⣴⣾⣿⡿⠿⠿⠿⠇⠀⠀⣸⣿⣿⣿⡆⠀⠀⢰⣿⣿⣿⣷⣼⣿⣿⣿⡿⢀⣿⣿⡿⠟⠛⠁⠀⠀ ⠀⣴⣿⡿⠋⠁⠀⠀⠀⠀⠀⠀⢠⣿⣿⣹⣿⣿⣿⣿⣿⣿⡏⢻⣿⣿⢿⣿⣿⠃⣼⣿⣯⣤⣴⣶⣿⡤⠀ ⣼⣿⠏⠀⣀⣠⣤⣶⣾⣷⠄⣰⣿⣿⡿⠿⠻⣿⣯⣸⣿⡿⠀⠀⠀⠁⣾⣿⡏⢠⣿⣿⠿⠛⠋⠉⠀⠀⠀ ⣿⣿⠲⢿⣿⣿⣿⣿⡿⠋⢰⣿⣿⠋⠀⠀⠀⢻⣿⣿⣿⠇⠀⠀⠀⠀⠙⠛⠀⠀⠉⠁⠀⠀⠀⠀⠀⠀⠀ ⠹⢿⣷⣶⣿⣿⠿⠋⠀⠀⠈⠙⠃⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠈⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣤⣴⣶⣦⣤⡀⠀ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡀⠀⠀⠀⠀⠀⠀⠀⣠⡇⢰⣶⣶⣾⡿⠷⣿⣿⣿⡟⠛⣉⣿⣿⣿⠆ ⠀⠀⠀⠀⠀⠀⢀⣤⣶⣿⣿⡎⣿⣿⣦⠀⠀⠀⢀⣤⣾⠟⢀⣿⣿⡟⣁⠀⠀⣸⣿⣿⣤⣾⣿⡿⠛⠁⠀ ⠀⠀⠀⠀⣠⣾⣿⡿⠛⠉⢿⣦⠘⣿⣿⡆⠀⢠⣾⣿⠋⠀⣼⣿⣿⣿⠿⠷⢠⣿⣿⣿⠿⢻⣿⣧⠀⠀⠀ ⠀⠀⠀⣴⣿⣿⠋⠀⠀⠀⢸⣿⣇⢹⣿⣷⣰⣿⣿⠃⠀⢠⣿⣿⢃⣀⣤⣤⣾⣿⡟⠀⠀⠀⢻⣿⣆⠀⠀ ⠀⠀⠀⣿⣿⡇⠀⠀⢀⣴⣿⣿⡟⠀⣿⣿⣿⣿⠃⠀⠀⣾⣿⣿⡿⠿⠛⢛⣿⡟⠀⠀⠀⠀⠀⠻⠿⠀⠀ ⠀⠀⠀⠹⣿⣿⣶⣾⣿⣿⣿⠟⠁⠀⠸⢿⣿⠇⠀⠀⠀⠛⠛⠁⠀⠀⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠀⠀⠀⠈⠙⠛⠛⠛⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ """) exit() # Exit the game after displaying the game over message import platform class Player(Character): def __init__(self, name): super().__init__(name, hp=100, attack=10) self.inventory = [] self.stunned = False # Initialize stunned attribute self.defense = 5 self.resistance = 0 self.gold = 0 # Initialize gold currency self.experience = 0 self.level = 15 self.exp_required = 100 # Initial experience required to level up self.max_hp_increase_per_level = 30 self.attack_increase_per_level = 0.004 # 0.4% self.defense_increase_per_level = 0.005 # 0.5% self.resistance_increase_per_level = 0.0015 # 0.15% def gain_experience(self, amount): self.experience += amount while self.experience >= self.exp_required: self.level_up() def level_up(self): self.level += 1 self.experience -= self.exp_required self.exp_required += 50 # Increase experience required for next level self.max_hp += self.max_hp_increase_per_level # Increase maximum health upon leveling up self.hp = self.max_hp # Heal player to full health upon leveling up self.attack = int(self.attack * (1 + self.attack_increase_per_level)) # Increase attack power upon leveling up self.defense = int(self.defense * (1 + self.defense_increase_per_level)) # Increase defense upon leveling up self.resistance = int(self.resistance * (1 + self.resistance_increase_per_level)) # Increase resistance upon leveling up print(f"Congratulations! You've reached level {self.level}!") def display_stats(self): print(f"Character Name: {self.name}") print(f"Level: {self.level}") print(f"Experience: {self.experience}/{self.exp_required}") print(f"Health: {self.hp}/{self.max_hp}") print(f"Attack: {self.attack}") print(f"Defense: {self.defense} ({self.defense * 0.2}%)") print(f"Resistance: {self.resistance} ({self.resistance * 0.2}%)") print(f"Curses: {self.curses}") if self.burned: print("Burned!") if self.critical: print("Critical!") if self.piercing: print("Piercing!") print(f"Gold: {self.gold}") while True: print("\nPlayer Menu:") print("1. Back to Game") print("2. Shop") print("3. Inventory") choice = input("Enter your choice: ") if choice == "1": os.system('clear') # Clear the screen after choosing to go back to the game break elif choice == "2": print("Welcome to the Shop!") # Implement shop functionality here elif choice == "3": print("Inventory:") for item in self.inventory: print(item) print("End of Inventory") else: print("Invalid choice. Please enter a valid option.") import os def main(): while True: print("\nWelcome to BeaVenture!") print("1. Start") print("2. Exit") choice = input("Enter your choice: ") if choice == "1": os.system('clear') # Clear the screen after pressing "Start" player_name = input("Enter your character's name: ") os.system('clear') # Clear the screen after entering the player's name player = Player(player_name) print(f"\nWelcome, {player.name}!") player.display_stats() while True: print("How do you want to start?") print("\n1. Continue") print("2. Back") choice = input("Enter your choice: ") if choice == "1": enemies = [ Enemy("Goblin", 50, 5), Enemy("Orc", 70, 10), Enemy("Dragon", 100, 20), Enemy("Skeleton", 40, 7), Enemy("Witch", 60, 12), Boss("Red Leaf", 300, 40), # Boss enemy type starts here Boss("Lubricant", 500, 60), Boss("The OverSeer", 700, 80), Boss("The Insight", 1000, 100), Boss("Surgeragon", 1500, 150) # Last boss enemy ] while player.is_alive(): enemy = random.choice(enemies) if isinstance(enemy, Boss): # Check if the enemy is a boss print("Doomed!") print("The Boss Is1 Approaching!") battle(player, enemy) if input("Do you want to play again? (yes/no): ").lower() != "yes": break break elif choice == "2": break else: print("Invalid choice. Please enter 1 or 2.") elif choice == "2": print("Exiting the game. Goodbye!") break else: print("Invalid choice. Please enter 1 or 2.") if __name__ == "__main__": main()
import os import time import sys class Player: def __init__(self, name, difficulty): self.name = name self.difficulty = difficulty self.attack = 10 self.defense = 5 self.dodge = 2 self.speed = 3 self.gold = 100 self.diamonds = 0 self.experience = 0 self.level = 1 self.exp_required = 100 self.exp_multiplier = 0.75 # 75% increase for experience requirement per level self.inventory = { # Initialize inventory "Weapons": [], "Armors": [], "Shields": [], "Footwear": [], "Usable Items": [] # Add Usable Items category } self.equipped_items = { # Initialize equipped items "Weapons": None, "Armors": None, "Shields": None, "Footwear": None } self.max_inventory_slots = 30 self.cleared_chapters = ["The Cave of Loir"] # Chapter 1 is unlocked by default self.chapter_stages = { "The Cave of Loir": ["⚔️"] + ["X"] * 9, # First stage unlocked "The Forest Of Azure": ["X"] * 10, # Locked "The Cursed Lake": ["X"] * 10, # Locked "The Baptisted Temple": ["X"] * 10, # Locked "Dungeon": ["X"] * 10, # Locked "Dragon Lair": ["X"] * 10 # Locked } # Existing methods... def visit_inventory(self): while True: os.system('cls' if os.name == 'nt' else 'clear') print("Inventory:") print("=" * 40) print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.display_items("Weapons") elif choice == "2": self.display_items("Armors") elif choice == "3": self.display_items("Shields") elif choice == "4": self.display_items("Footwear") elif choice == "5": self.display_items("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_items(self, item_type): while True: os.system('cls' if os.name == 'nt' else 'clear') print(f"{item_type}:") print("=" * 40) if self.inventory[item_type]: for idx, item in enumerate(self.inventory[item_type], 1): print(f"{idx}. {item['name']}: {item['description']}") print("0. Back to Inventory Menu") print("Enter the number to equip the item or 0 to go back.") choice = input("") if choice == "0": break # Break out of the inner loop to return to the previous menu elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]): self.equip_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) else: print("No items in this category.") print("Press < to go back") choice = input("") if choice == "<": break # Break out of the inner loop to return to the previous menu def equip_item(self, item_type, index): item = self.inventory[item_type].pop(index) if item_type in ["Weapons", "Armors", "Shields", "Footwear"]: self.remove_equipped_item(item_type) # Remove any previously equipped item of the same type self.equipped_items[item_type] = item # Equip the new item self.update_stats() # Update player stats with the new equipment print(f"{item['name']} equipped.") time.sleep(1) else: # Handle equipping usable items pass self.visit_inventory() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def update_stats(self): # Reset base stats self.attack = 10 self.defense = 5 self.dodge = 2 self.speed = 3 # Add bonuses from equipped items for item_type, item in self.equipped_items.items(): if item: self.attack += item.get('attack', 0) self.defense += item.get('defense', 0) self.dodge += item.get('dodge', 0) self.speed += item.get('speed', 0) def display_status(self): os.system('cls' if os.name == 'nt' else 'clear') print("Player Status:\n") print("="*40) print(f"Name: {self.get_name_display()}") print(f"Difficulty: {self.get_difficulty_display()}") print("-"*40) print("Stats:") print(f"HP :❤️{self.attack}") print(f"Defense :🛡️{self.defense}") print(f"Attack :⚔️{self.attack}") print(f"Dodge :🤺{self.dodge}") print(f"Speed :🏃{self.speed}") print("-"*40) print(f"Level: {self.level}") print(f"Experience: {self.experience}/{self.exp_required}") print("-"*40) print(f"Gold: {self.gold} 💰") print(f"Diamonds: {self.diamonds} 💎") print("="*40) print("Game Options:") print("1. Visit Shop") print("2. Inventory") print("3. Play Game") print("4. Delete this Character") print("5. Add 50 Experience Points") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.visit_shop() elif choice == "2": self.visit_inventory() elif choice == "3": self.play_game() elif choice == "4": return elif choice == "5": self.add_experience(50) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_status() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def get_chapter_name_by_number(self, number): chapters = { "1": "The Cave of Loir", "2": "The Forest Of Azure", "3": "The Cursed Lake", "4": "The Baptisted Temple", "5": "Dungeon", "6": "Dragon Lair" } return chapters.get(number) def play_game(self): while True: clear_screen() print("Select Chapter to Play:") for i, (chapter_name, stages) in enumerate(self.chapter_stages.items(), start=1): if "✔️" in stages: print(f"< ✅ {i} > {chapter_name}") # Display cleared chapters with a checkmark elif "⚔️" in stages: print(f"< {'⚔️'} {i} > {chapter_name}") # Display unlocked chapters with a sword symbol else: print(f"< 🔒 {i} > {chapter_name}") # Display locked chapters with a lock symbol print("< < Back to Player Status") choice = input("Enter the number to select a chapter or < to go back: ") if choice == "<": self.display_status() # Fixed: Go back to player status menu elif choice.isdigit(): chapter_index = int(choice) - 1 if 0 <= chapter_index < len(self.chapter_stages): chapter_name = list(self.chapter_stages.keys())[chapter_index] stages = self.chapter_stages[chapter_name] if "⚔️" in stages: self.play_chapter(chapter_name) elif "✔️" in stages: print("You have already cleared this chapter. Select another chapter to play.") time.sleep(1) else: print("This chapter is locked. Please clear the previous chapters first.") time.sleep(1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) def play_chapter(self, chapter_name): while True: clear_screen() print(f"Chapter: {chapter_name}") print("Stages:") for i, stage in enumerate(self.chapter_stages[chapter_name], start=1): print(f"Stage {i}: {'⚔️' if stage == '⚔️' else '🔒' if stage == 'X' else '✅'}") print("< < Back to Chapter Selection") choice = input("Enter the number to select a stage or < to go back: ") if choice == "<": break elif choice.isdigit(): stage_index = int(choice) - 1 if 0 <= stage_index < len(self.chapter_stages[chapter_name]): if self.chapter_stages[chapter_name][stage_index] == "⚔️": self.play_stage(chapter_name, stage_index) elif self.chapter_stages[chapter_name][stage_index] == "X": print("This stage is locked. Please clear the previous stages first.") time.sleep(2) else: print("You have already cleared this stage.") time.sleep(1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) def play_stage(self, chapter_name, stage_index): clear_screen() print(f"Chapter: {chapter_name}") print(f"Stage: {stage_index + 1}") print("Placeholder for gameplay") # Placeholder for actual gameplay if stage_index < len(self.chapter_stages[chapter_name]) - 1: self.chapter_stages[chapter_name][stage_index + 1] = "⚔️" # Unlock next stage else: self.chapter_stages[chapter_name] = ["✔️"] * 10 # All stages cleared, lock the chapter next_chapter_index = list(self.chapter_stages.keys()).index(chapter_name) + 1 if next_chapter_index < len(self.chapter_stages): next_chapter_name = list(self.chapter_stages.keys())[next_chapter_index] self.chapter_stages[next_chapter_name][0] = "⚔️" # Unlock next chapter print(f"You cleared {chapter_name}! \nNext chapter unlocked: {next_chapter_name}") time.sleep(3) else: print(f"You cleared {chapter_name} and completed all chapters!") time.sleep(3) self.chapter_stages[chapter_name][stage_index] = "✅" # Mark stage as cleared time.sleep(2) def display_locked_message(self, chapter_name): clear_screen() if self.chapter_stages[chapter_name][0] == "✔️": print("You have played for:", self.get_play_time()) else: print("This chapter is locked. Please clear the previous chapters first.") input("Press Enter to go back to the selecting chapter.") def get_play_time(self): return "10 hours 30 minutes" def add_experience(self, amount): self.experience += amount if self.experience >= self.exp_required: self.level_up() self.display_status() def level_up(self): self.level += 1 self.exp_required = int(self.exp_required * (1 + self.exp_multiplier)) # Increase by 75% self.attack += 0.5 self.defense += 0.5 self.dodge += 0.5 self.speed += 0.5 def get_name_display(self): symbol = "" if self.difficulty == "Basic": symbol = "🛡️" elif self.difficulty == "Exemplar": symbol = "⚔️" elif self.difficulty == "Templar": symbol = "☠️" return f"{symbol} {self.name}" def get_difficulty_display(self): return self.difficulty def visit_shop(self): while True: os.system('cls' if os.name == 'nt' else 'clear') print("Welcome to the Shop!") print("=" * 40) print("Shop Sections:") print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select a shop section.") choice = input("") if choice == "1": self.display_shop_section("Weapons") elif choice == "2": self.display_shop_section("Armors") elif choice == "3": self.display_shop_section("Shields") elif choice == "4": self.display_shop_section("Footwear") elif choice == "5": self.display_shop_section("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_shop_section(self, item_type): os.system('cls' if os.name == 'nt' else 'clear') print(f"Shop - {item_type}:") print("=" * 40) if item_type in items_groups: for idx, item in enumerate(items_groups[item_type], 1): print(f"{idx}. {item['name']}: {item['description']} - Cost: {item['cost']} gold") print("0. Back to Shop Sections") print("Enter the number to purchase the item or 0 to go back.") choice = input("") if choice == "0": self.visit_shop() elif choice.isdigit() and 0 < int(choice) <= len(items_groups[item_type]): self.purchase_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_shop_section(item_type) else: print("Invalid shop section.") time.sleep(1) self.visit_shop() def purchase_item(self, item_type, index): item = items_groups[item_type][index] cost = item['cost'] if self.gold >= cost: self.gold -= cost self.inventory[item_type].append(item) print(f"You have purchased {item['name']} for {cost} gold.") time.sleep(1) else: print("Insufficient gold to purchase this item.") time.sleep(1) self.display_shop_section(item_type) items_groups = { "Usable Items": [ {"name": "Small Healing Potion", "description": "+15 hp", "cost": 20}, {"name": "Self Healing Potion", "description": "+20 hp", "cost": 50}, {"name": "Moderated Potion", "description": "+25 hp", "cost": 75}, {"name": "Regen Potion", "description": "+15%", "cost": 100}, {"name": "Hammerhead Crocker", "description": "+7% attack for 7 turns", "cost": 55}, {"name": "Warhammer Crocker", "description": "+15% attack for 7 turns", "cost": 75}, {"name": "Barhog", "description": "+7% Defense for 7 turns", "cost": 45}, {"name": "Warhog", "description": "+15% defense for 7 turns", "cost": 60}, {"name": "Non applicable scroll", "description": "+2 Speed for 7 turns", "cost": 40}, {"name": "Applicable scroll", "description": "+4 speed for 7 turns", "cost": 55}, {"name": "Ransacked Shield", "description": "+12% Dodge chance for 3 turns", "cost": 60}, {"name": "Unbuilded Shield", "description": "+23% Dodge Chance for 5 turns", "cost": 90}, {"name": "Mystic Scroll", "description": "25% chance to negate all debuffs on player for 4 turns", "cost": 60}, {"name": "Mystic Beurau", "description": "50% chance to negate all debuffs on player for 4 turns", "cost": 120}, {"name": "Variant Bs", "description": "Increase all stats up to 25% for 10 turns", "cost": 200}, {"name": "Variant Ex", "description": "Increase all stats up to 50% for 10 turns", "cost": 400}, {"name": "Hide cloak", "description": "40% chance to dodge the battle against enemies when exploring", "cost": 50}, {"name": "Invisible potion", "description": "60% chance to dodge the battle against enemies when exploring", "cost": 75}, {"name": "Exp Moneter", "description": "Give you 20 exp points", "cost": 50}, {"name": "Exp Vitalis", "description": "Give you 50 exp points", "cost": 100}, {"name": "Exp For enhancer", "description": "Give you 100 points", "cost": 150} ], "Weapons": [ {"name": "Stone Sword", "description": "+12 attack", "cost": 150}, {"name": "Copper Sword", "description": "+15 attack", "cost": 275}, {"name": "Sickanum Sword", "description": "+17 attack", "cost": 400}, {"name": "Arivanum Sword", "description": "+23 attack", "cost": 600}, {"name": "Viranium Sword", "description": "+25 attack", "cost": 850}, {"name": "Titanium sword", "description": "+35 attack", "cost": 1250} ], "Armors": [ {"name": "Jungle sets", "description": "+7 Defense", "cost": 90}, {"name": "Byzantine sets", "description": "+12 Defense", "cost": 140}, {"name": "Nikel Sets", "description": "+15 Defense", "cost": 350}, {"name": "Warhead Sets", "description": "+25 Defense", "cost": 560}, {"name": "Titanium Sets", "description": "+40 Defense", "cost": 850} ], "Shields": [ {"name": "Wooden Ob", "description": "+2 dodge", "cost": 80}, {"name": "Long Ob", "description": "+3 dodge, +2 Defense", "cost": 120}, {"name": "Cob Ob", "description": "+5 dodge, +4 Defense", "cost": 300}, {"name": "Knock Ob", "description": "+7 dodge, +5 Defense, +3 Attack", "cost": 550}, {"name": "Neb Ob", "description": "+12 dodge, +7 Defense, +5 Attack", "cost": 760} ], "Footwear": [ {"name": "Jungle Foot", "description": "+3 speeds", "cost": 45}, {"name": "Iron Foot", "description": "+5 Speed", "cost": 75}, {"name": "Metal WarFoot", "description": "+8 Speeds", "cost": 120}, {"name": "Diamond Boots", "description": "+12 Speeds", "cost": 230}, {"name": "Noble Boots", "description": "+19 Speeds", "cost": 450}, {"name": "Lizable Boots", "description": "+25 Speeds", "cost": 700} ] } def create_character(): clear_screen() print("Character Creation") name = input("Enter your character's name: ") clear_screen() print(f"Character Name: {name}\n") while True: print("Select Difficulty:") print("1. Basic 🛡️") print("2. Exemplar ⚔️") print("3. Templar ☠️") difficulty_choice = input("Enter the number to select difficulty: ") if difficulty_choice == "1": difficulty = "Basic" description = "Enemies are powerful in their origins." elif difficulty_choice == "2": difficulty = "Exemplar" description = "Enemies are harder and more immortalized." elif difficulty_choice == "3": difficulty = "Templar" description = "Enemies are evils." else: print("Invalid difficulty choice. Please choose a valid option.") time.sleep(1) clear_screen() continue clear_screen() print("Selected Difficulty:") print(f"Name: {name}") print(f"Difficulty: {difficulty}") print(f"Description: {description}\n") print("1. Confirm") print("2. Back") confirm_choice = input("Enter your choice: ") if confirm_choice == "1": break elif confirm_choice == "2": clear_screen() continue else: print("Invalid choice. Please enter 1 to confirm or 2 to go back.") time.sleep(1) clear_screen() return Player(name, difficulty) def clear_screen(): """Clears the console screen.""" os.system('cls' if os.name == 'nt' else 'clear') def main_menu(): clear_screen() print("BeaVenture\n") print("1. Create Character") print("2. Exit") print("\nEnter the number to select an option.") def main(): while True: main_menu() try: choice = int(input("")) if choice == 1: player = create_character() player.display_status() elif choice == 2: clear_screen() print("Exiting BeaVenture. Goodbye!") time.sleep(2) clear_screen() print("Game Was Ended") input("Press Enter to exit...") clear_screen() break else: print("Invalid option. Please enter a valid number.") time.sleep(2) except ValueError: print("Invalid input. Please enter a number.") if __name__ == "__main__": main()
import os import time import sys class Player: def __init__(self, name, difficulty): self.name = name self.difficulty = difficulty self.attack = 10 self.defense = 5 self.dodge = 2 self.speed = 3 self.gold = 100 self.diamonds = 0 self.experience = 0 self.level = 1 self.exp_required = 100 self.exp_multiplier = 0.75 # 75% increase for experience requirement per level self.inventory = { # Initialize inventory "Weapons": [], "Armors": [], "Shields": [], "Footwear": [], "Usable Items": [] # Add Usable Items category } self.equipped_items = { # Initialize equipped items "Weapons": None, "Armors": None, "Shields": None, "Footwear": None } self.max_inventory_slots = 30 self.cleared_chapters = ["The Cave of Loir"] # Chapter 1 is unlocked by default self.chapter_stages = { "The Cave of Loir": ["⚔️"] + ["X"] * 9, # First stage unlocked "The Forest Of Azure": ["X"] * 10, # Locked "The Cursed Lake": ["X"] * 10, # Locked "The Baptisted Temple": ["X"] * 10, # Locked "Dungeon": ["X"] * 10, # Locked "Dragon Lair": ["X"] * 10 # Locked } # Existing methods... def visit_inventory(self): while True: os.system('cls' if os.name == 'nt' else 'clear') print("Inventory:") print("=" * 40) print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.display_items("Weapons") elif choice == "2": self.display_items("Armors") elif choice == "3": self.display_items("Shields") elif choice == "4": self.display_items("Footwear") elif choice == "5": self.display_items("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_items(self, item_type): while True: os.system('cls' if os.name == 'nt' else 'clear') print(f"{item_type}:") print("=" * 40) if self.inventory[item_type]: for idx, item in enumerate(self.inventory[item_type], 1): print(f"{idx}. {item['name']}: {item['description']}") print("0. Back to Inventory Menu") print("Enter the number to equip the item or 0 to go back.") choice = input("") if choice == "0": break # Break out of the inner loop to return to the previous menu elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]): self.equip_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) else: print("No items in this category.") print("Press < to go back") choice = input("") if choice == "<": break # Break out of the inner loop to return to the previous menu def equip_item(self, item_type, index): item = self.inventory[item_type].pop(index) if item_type in ["Weapons", "Armors", "Shields", "Footwear"]: self.remove_equipped_item(item_type) # Remove any previously equipped item of the same type self.equipped_items[item_type] = item # Equip the new item self.update_stats() # Update player stats with the new equipment print(f"{item['name']} equipped.") time.sleep(1) else: # Handle equipping usable items pass self.visit_inventory() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def update_stats(self): # Reset base stats self.attack = 10 self.defense = 5 self.dodge = 2 self.speed = 3 # Add bonuses from equipped items for item_type, item in self.equipped_items.items(): if item: self.attack += item.get('attack', 0) self.defense += item.get('defense', 0) self.dodge += item.get('dodge', 0) self.speed += item.get('speed', 0) def display_status(self): os.system('cls' if os.name == 'nt' else 'clear') print("Player Status:\n") print("="*40) print(f"Name: {self.get_name_display()}") print(f"Difficulty: {self.get_difficulty_display()}") print("-"*40) print("Stats:") print(f"HP :❤️{self.attack}") print(f"Defense :🛡️{self.defense}") print(f"Attack :⚔️{self.attack}") print(f"Dodge :🤺{self.dodge}") print(f"Speed :🏃{self.speed}") print("-"*40) print(f"Level: {self.level}") print(f"Experience: {self.experience}/{self.exp_required}") print("-"*40) print(f"Gold: {self.gold} 💰") print(f"Diamonds: {self.diamonds} 💎") print("="*40) print("Game Options:") print("1. Visit Shop") print("2. Inventory") print("3. Play Game") print("4. Delete this Character") print("5. Add 50 Experience Points") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.visit_shop() elif choice == "2": self.visit_inventory() elif choice == "3": self.play_game() elif choice == "4": return elif choice == "5": self.add_experience(50) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_status() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def get_chapter_name_by_number(self, number): chapters = { "1": "The Cave of Loir", "2": "The Forest Of Azure", "3": "The Cursed Lake", "4": "The Baptisted Temple", "5": "Dungeon", "6": "Dragon Lair" } return chapters.get(number) def play_game(self): while True: clear_screen() print("Select Chapter to Play:") for i, (chapter_name, stages) in enumerate(self.chapter_stages.items(), start=1): print(f"< {'⚔️' if stages[0] == '⚔️' else '🔒' if stages[0] == 'X' else '✔️'} {i} > {chapter_name}") # Display chapter with appropriate symbol print("< < Back to Player Status") choice = input("Enter the number to select a chapter or < to go back: ") if choice == "<": self.display_status() break elif choice.isdigit(): chapter_index = int(choice) - 1 if 0 <= chapter_index < len(self.chapter_stages): chapter_name = list(self.chapter_stages.keys())[chapter_index] stages = self.chapter_stages[chapter_name] if stages[0] == "⚔️": self.play_chapter(chapter_name) else: print("This chapter is locked. Please clear the previous chapters first.") time.sleep(2) else: print("Invalid option. Please enter a valid number.") time.sleep(1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) def play_chapter(self, chapter_name): while True: clear_screen() print(f"Chapter: {chapter_name}") print("Stages:") for i, stage in enumerate(self.chapter_stages[chapter_name], start=1): print(f"Stage {i}: {'⚔️' if stage == '⚔️' else '🔒' if stage == 'X' else '✅'}") print("< < Back to Chapter Selection") choice = input("Enter the number to select a stage or < to go back: ") if choice == "<": break elif choice.isdigit(): stage_index = int(choice) - 1 if 0 <= stage_index < len(self.chapter_stages[chapter_name]): if self.chapter_stages[chapter_name][stage_index] == "⚔️": self.play_stage(chapter_name, stage_index) elif self.chapter_stages[chapter_name][stage_index] == "X": print("This stage is locked. Please clear the previous stages first.") time.sleep(2) else: print("You have already cleared this stage.") time.sleep(2) else: print("Invalid option. Please enter a valid number.") time.sleep(1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) def play_stage(self, chapter_name, stage_index): clear_screen() print(f"Chapter: {chapter_name}") print(f"Stage: {stage_index + 1}") print("Placeholder for gameplay") # Placeholder for actual gameplay if stage_index < len(self.chapter_stages[chapter_name]) - 1: self.chapter_stages[chapter_name][stage_index + 1] = "⚔️" # Unlock next stage else: print("You cleared all stages in this chapter!") time.sleep(2) self.chapter_stages.pop(chapter_name) # Remove the chapter if self.chapter_stages: # Check if there are more chapters left next_chapter_name = list(self.chapter_stages.keys())[0] self.chapter_stages[next_chapter_name][0] = "⚔️" # Unlock next chapter print(f"Next chapter unlocked: {next_chapter_name}") time.sleep(3) else: print("Congratulations! You cleared all chapters!") time.sleep(3) self.chapter_stages[chapter_name][stage_index] = "✅" # Mark stage as cleared time.sleep(2) def display_locked_message(self): clear_screen() print("This chapter is locked. Please clear the previous chapters first.") input("Press Enter to go back to the selecting chapter.") def add_experience(self, amount): self.experience += amount if self.experience >= self.exp_required: self.level_up() self.display_status() def level_up(self): self.level += 1 self.exp_required = int(self.exp_required * (1 + self.exp_multiplier)) # Increase by 75% self.attack += 0.5 self.defense += 0.5 self.dodge += 0.5 self.speed += 0.5 def get_name_display(self): symbol = "" if self.difficulty == "Basic": symbol = "🛡️" elif self.difficulty == "Exemplar": symbol = "⚔️" elif self.difficulty == "Templar": symbol = "☠️" return f"{symbol} {self.name}" def get_difficulty_display(self): return self.difficulty def visit_shop(self): while True: os.system('cls' if os.name == 'nt' else 'clear') print("Welcome to the Shop!") print("=" * 40) print("Shop Sections:") print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select a shop section.") choice = input("") if choice == "1": self.display_shop_section("Weapons") elif choice == "2": self.display_shop_section("Armors") elif choice == "3": self.display_shop_section("Shields") elif choice == "4": self.display_shop_section("Footwear") elif choice == "5": self.display_shop_section("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_shop_section(self, item_type): os.system('cls' if os.name == 'nt' else 'clear') print(f"Shop - {item_type}:") print("=" * 40) if item_type in items_groups: for idx, item in enumerate(items_groups[item_type], 1): print(f"{idx}. {item['name']}: {item['description']} - Cost: {item['cost']} gold") print("0. Back to Shop Sections") print("Enter the number to purchase the item or 0 to go back.") choice = input("") if choice == "0": self.visit_shop() elif choice.isdigit() and 0 < int(choice) <= len(items_groups[item_type]): self.purchase_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_shop_section(item_type) else: print("Invalid shop section.") time.sleep(1) self.visit_shop() def purchase_item(self, item_type, index): item = items_groups[item_type][index] cost = item['cost'] if self.gold >= cost: self.gold -= cost self.inventory[item_type].append(item) print(f"You have purchased {item['name']} for {cost} gold.") time.sleep(1) else: print("Insufficient gold to purchase this item.") time.sleep(1) self.display_shop_section(item_type) items_groups = { "Usable Items": [ {"name": "Small Healing Potion", "description": "+15 hp", "cost": 20}, {"name": "Self Healing Potion", "description": "+20 hp", "cost": 50}, {"name": "Moderated Potion", "description": "+25 hp", "cost": 75}, {"name": "Regen Potion", "description": "+15%", "cost": 100}, {"name": "Hammerhead Crocker", "description": "+7% attack for 7 turns", "cost": 55}, {"name": "Warhammer Crocker", "description": "+15% attack for 7 turns", "cost": 75}, {"name": "Barhog", "description": "+7% Defense for 7 turns", "cost": 45}, {"name": "Warhog", "description": "+15% defense for 7 turns", "cost": 60}, {"name": "Non applicable scroll", "description": "+2 Speed for 7 turns", "cost": 40}, {"name": "Applicable scroll", "description": "+4 speed for 7 turns", "cost": 55}, {"name": "Ransacked Shield", "description": "+12% Dodge chance for 3 turns", "cost": 60}, {"name": "Unbuilded Shield", "description": "+23% Dodge Chance for 5 turns", "cost": 90}, {"name": "Mystic Scroll", "description": "25% chance to negate all debuffs on player for 4 turns", "cost": 60}, {"name": "Mystic Beurau", "description": "50% chance to negate all debuffs on player for 4 turns", "cost": 120}, {"name": "Variant Bs", "description": "Increase all stats up to 25% for 10 turns", "cost": 200}, {"name": "Variant Ex", "description": "Increase all stats up to 50% for 10 turns", "cost": 400}, {"name": "Hide cloak", "description": "40% chance to dodge the battle against enemies when exploring", "cost": 50}, {"name": "Invisible potion", "description": "60% chance to dodge the battle against enemies when exploring", "cost": 75}, {"name": "Exp Moneter", "description": "Give you 20 exp points", "cost": 50}, {"name": "Exp Vitalis", "description": "Give you 50 exp points", "cost": 100}, {"name": "Exp For enhancer", "description": "Give you 100 points", "cost": 150} ], "Weapons": [ {"name": "Stone Sword", "description": "+12 attack", "cost": 150}, {"name": "Copper Sword", "description": "+15 attack", "cost": 275}, {"name": "Sickanum Sword", "description": "+17 attack", "cost": 400}, {"name": "Arivanum Sword", "description": "+23 attack", "cost": 600}, {"name": "Viranium Sword", "description": "+25 attack", "cost": 850}, {"name": "Titanium sword", "description": "+35 attack", "cost": 1250} ], "Armors": [ {"name": "Jungle sets", "description": "+7 Defense", "cost": 90}, {"name": "Byzantine sets", "description": "+12 Defense", "cost": 140}, {"name": "Nikel Sets", "description": "+15 Defense", "cost": 350}, {"name": "Warhead Sets", "description": "+25 Defense", "cost": 560}, {"name": "Titanium Sets", "description": "+40 Defense", "cost": 850} ], "Shields": [ {"name": "Wooden Ob", "description": "+2 dodge", "cost": 80}, {"name": "Long Ob", "description": "+3 dodge, +2 Defense", "cost": 120}, {"name": "Cob Ob", "description": "+5 dodge, +4 Defense", "cost": 300}, {"name": "Knock Ob", "description": "+7 dodge, +5 Defense, +3 Attack", "cost": 550}, {"name": "Neb Ob", "description": "+12 dodge, +7 Defense, +5 Attack", "cost": 760} ], "Footwear": [ {"name": "Jungle Foot", "description": "+3 speeds", "cost": 45}, {"name": "Iron Foot", "description": "+5 Speed", "cost": 75}, {"name": "Metal WarFoot", "description": "+8 Speeds", "cost": 120}, {"name": "Diamond Boots", "description": "+12 Speeds", "cost": 230}, {"name": "Noble Boots", "description": "+19 Speeds", "cost": 450}, {"name": "Lizable Boots", "description": "+25 Speeds", "cost": 700} ] } def create_character(): clear_screen() print("Character Creation") name = input("Enter your character's name: ") clear_screen() print(f"Character Name: {name}\n") while True: print("Select Difficulty:") print("1. Basic 🛡️") print("2. Exemplar ⚔️") print("3. Templar ☠️") difficulty_choice = input("Enter the number to select difficulty: ") if difficulty_choice == "1": difficulty = "Basic" description = "Enemies are powerful in their origins." elif difficulty_choice == "2": difficulty = "Exemplar" description = "Enemies are harder and more immortalized." elif difficulty_choice == "3": difficulty = "Templar" description = "Enemies are evils." else: print("Invalid difficulty choice. Please choose a valid option.") time.sleep(1) clear_screen() continue clear_screen() print("Selected Difficulty:") print(f"Name: {name}") print(f"Difficulty: {difficulty}") print(f"Description: {description}\n") print("1. Confirm") print("2. Back") confirm_choice = input("Enter your choice: ") if confirm_choice == "1": break elif confirm_choice == "2": clear_screen() continue else: print("Invalid choice. Please enter 1 to confirm or 2 to go back.") time.sleep(1) clear_screen() return Player(name, difficulty) def clear_screen(): """Clears the console screen.""" os.system('cls' if os.name == 'nt' else 'clear') def main_menu(): clear_screen() print("BeaVenture\n") print("1. Create Character") print("2. Exit") print("\nEnter the number to select an option.") def main(): while True: main_menu() try: choice = int(input("")) if choice == 1: player = create_character() player.display_status() elif choice == 2: clear_screen() print("Exiting BeaVenture. Goodbye!") time.sleep(2) clear_screen() print("Game Was Ended") input("Press Enter to exit...") clear_screen() break else: print("Invalid option. Please enter a valid number.") time.sleep(2) except ValueError: print("Invalid input. Please enter a number.") if __name__ == "__main__": main()
import os import time import sys class Player: def __init__(self, name, difficulty): self.name = name self.difficulty = difficulty self.attack = 10 self.defense = 5 self.dodge = 2 self.speed = 3 self.gold = 100 self.diamonds = 0 self.experience = 0 self.level = 1 self.exp_required = 100 self.exp_multiplier = 0.75 # 75% increase for experience requirement per level self.inventory = { # Initialize inventory "Weapons": [], "Armors": [], "Shields": [], "Footwear": [], "Usable Items": [] # Add Usable Items category } self.equipped_items = { # Initialize equipped items "Weapons": None, "Armors": None, "Shields": None, "Footwear": None } self.max_inventory_slots = 30 self.cleared_chapters = ["The Cave of Loir"] # Chapter 1 is unlocked by default self.chapter_stages = { "The Cave of Loir": ["⚔️"] + ["X"] * 9, # First stage unlocked "The Forest Of Azure": ["X"] * 10, # Locked "The Cursed Lake": ["X"] * 10, # Locked "The Baptisted Temple": ["X"] * 10, # Locked "Dungeon": ["X"] * 10, # Locked "Dragon Lair": ["X"] * 10 # Locked } # Existing methods... def visit_inventory(self): while True: os.system('cls' if os.name == 'nt' else 'clear') print("Inventory:") print("=" * 40) print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.display_items("Weapons") elif choice == "2": self.display_items("Armors") elif choice == "3": self.display_items("Shields") elif choice == "4": self.display_items("Footwear") elif choice == "5": self.display_items("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_items(self, item_type): while True: os.system('cls' if os.name == 'nt' else 'clear') print(f"{item_type}:") print("=" * 40) if self.inventory[item_type]: for idx, item in enumerate(self.inventory[item_type], 1): print(f"{idx}. {item['name']}: {item['description']}") print("0. Back to Inventory Menu") print("Enter the number to equip the item or 0 to go back.") choice = input("") if choice == "0": break # Break out of the inner loop to return to the previous menu elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]): self.equip_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) else: print("No items in this category.") print("Press < to go back") choice = input("") if choice == "<": break # Break out of the inner loop to return to the previous menu def equip_item(self, item_type, index): item = self.inventory[item_type].pop(index) if item_type in ["Weapons", "Armors", "Shields", "Footwear"]: self.remove_equipped_item(item_type) # Remove any previously equipped item of the same type self.equipped_items[item_type] = item # Equip the new item self.update_stats() # Update player stats with the new equipment print(f"{item['name']} equipped.") time.sleep(1) else: # Handle equipping usable items pass self.visit_inventory() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def update_stats(self): # Reset base stats self.attack = 10 self.defense = 5 self.dodge = 2 self.speed = 3 # Add bonuses from equipped items for item_type, item in self.equipped_items.items(): if item: self.attack += item.get('attack', 0) self.defense += item.get('defense', 0) self.dodge += item.get('dodge', 0) self.speed += item.get('speed', 0) def display_status(self): os.system('cls' if os.name == 'nt' else 'clear') print("Player Status:\n") print("="*40) print(f"Name: {self.get_name_display()}") print(f"Difficulty: {self.get_difficulty_display()}") print("-"*40) print("Stats:") print(f"HP :❤️{self.attack}") print(f"Defense :🛡️{self.defense}") print(f"Attack :⚔️{self.attack}") print(f"Dodge :🤺{self.dodge}") print(f"Speed :🏃{self.speed}") print("-"*40) print(f"Level: {self.level}") print(f"Experience: {self.experience}/{self.exp_required}") print("-"*40) print(f"Gold: {self.gold} 💰") print(f"Diamonds: {self.diamonds} 💎") print("="*40) print("Game Options:") print("1. Visit Shop") print("2. Inventory") print("3. Play Game") print("4. Delete this Character") print("5. Add 50 Experience Points") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.visit_shop() elif choice == "2": self.visit_inventory() elif choice == "3": self.play_game() elif choice == "4": return elif choice == "5": self.add_experience(50) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_status() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def get_chapter_name_by_number(self, number): chapters = { "1": "The Cave of Loir", "2": "The Forest Of Azure", "3": "The Cursed Lake", "4": "The Baptisted Temple", "5": "Dungeon", "6": "Dragon Lair" } return chapters.get(number) def play_game(self): while True: clear_screen() print("Select Chapter to Play:") for i, (chapter_name, stages) in enumerate(self.chapter_stages.items(), start=1): print(f"< {'⚔️' if stages[0] == '⚔️' else '🔒' if stages[0] == 'X' else '✔️'} {i} > {chapter_name}") # Display chapter with appropriate symbol print("< < Back to Player Status") choice = input("Enter the number to select a chapter or < to go back: ") if choice == "<": self.display_status() break elif choice.isdigit(): chapter_index = int(choice) - 1 if 0 <= chapter_index < len(self.chapter_stages): chapter_name = list(self.chapter_stages.keys())[chapter_index] stages = self.chapter_stages[chapter_name] if stages[0] == "⚔️": self.play_chapter(chapter_name) else: print("This chapter is locked. Please clear the previous chapters first.") time.sleep(2) else: print("Invalid option. Please enter a valid number.") time.sleep(1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) def play_chapter(self, chapter_name): while True: clear_screen() print(f"Chapter: {chapter_name}") print("Stages:") for i, stage in enumerate(self.chapter_stages[chapter_name], start=1): print(f"Stage {i}: {'⚔️' if stage == '⚔️' else '🔒' if stage == 'X' else '✅'}") print("< < Back to Chapter Selection") choice = input("Enter the number to select a stage or < to go back: ") if choice == "<": break elif choice.isdigit(): stage_index = int(choice) - 1 if 0 <= stage_index < len(self.chapter_stages[chapter_name]): if self.chapter_stages[chapter_name][stage_index] == "⚔️": self.play_stage(chapter_name, stage_index) elif self.chapter_stages[chapter_name][stage_index] == "X": print("This stage is locked. Please clear the previous stages first.") time.sleep(2) else: print("You have already cleared this stage.") time.sleep(2) else: print("Invalid option. Please enter a valid number.") time.sleep(1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) def play_stage(self, chapter_name, stage_index): clear_screen() print(f"Chapter: {chapter_name}") print(f"Stage: {stage_index + 1}") print("Placeholder for gameplay") # Placeholder for actual gameplay if stage_index < len(self.chapter_stages[chapter_name]) - 1: self.chapter_stages[chapter_name][stage_index + 1] = "⚔️" # Unlock next stage else: print("You cleared all stages in this chapter!") time.sleep(2) self.chapter_stages.pop(chapter_name) # Remove the chapter if self.chapter_stages: # Check if there are more chapters left next_chapter_name = list(self.chapter_stages.keys())[0] self.chapter_stages[next_chapter_name][0] = "⚔️" # Unlock next chapter print(f"Next chapter unlocked: {next_chapter_name}") time.sleep(3) else: print("Congratulations! You cleared all chapters!") time.sleep(3) self.chapter_stages[chapter_name][stage_index] = "✅" # Mark stage as cleared time.sleep(2) def display_locked_message(self): clear_screen() print("This chapter is locked. Please clear the previous chapters first.") input("Press Enter to go back to the selecting chapter.") def add_experience(self, amount): self.experience += amount if self.experience >= self.exp_required: self.level_up() self.display_status() def level_up(self): self.level += 1 self.exp_required = int(self.exp_required * (1 + self.exp_multiplier)) # Increase by 75% self.attack += 0.5 self.defense += 0.5 self.dodge += 0.5 self.speed += 0.5 def get_name_display(self): symbol = "" if self.difficulty == "Basic": symbol = "🛡️" elif self.difficulty == "Exemplar": symbol = "⚔️" elif self.difficulty == "Templar": symbol = "☠️" return f"{symbol} {self.name}" def get_difficulty_display(self): return self.difficulty def visit_shop(self): while True: os.system('cls' if os.name == 'nt' else 'clear') print("Welcome to the Shop!") print("=" * 40) print("Shop Sections:") print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select a shop section.") choice = input("") if choice == "1": self.display_shop_section("Weapons") elif choice == "2": self.display_shop_section("Armors") elif choice == "3": self.display_shop_section("Shields") elif choice == "4": self.display_shop_section("Footwear") elif choice == "5": self.display_shop_section("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_shop_section(self, item_type): os.system('cls' if os.name == 'nt' else 'clear') print(f"Shop - {item_type}:") print("=" * 40) if item_type in items_groups: for idx, item in enumerate(items_groups[item_type], 1): print(f"{idx}. {item['name']}: {item['description']} - Cost: {item['cost']} gold") print("0. Back to Shop Sections") print("Enter the number to purchase the item or 0 to go back.") choice = input("") if choice == "0": self.visit_shop() elif choice.isdigit() and 0 < int(choice) <= len(items_groups[item_type]): self.purchase_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_shop_section(item_type) else: print("Invalid shop section.") time.sleep(1) self.visit_shop() def purchase_item(self, item_type, index): item = items_groups[item_type][index] cost = item['cost'] if self.gold >= cost: self.gold -= cost self.inventory[item_type].append(item) print(f"You have purchased {item['name']} for {cost} gold.") time.sleep(1) else: print("Insufficient gold to purchase this item.") time.sleep(1) self.display_shop_section(item_type) items_groups = { "Usable Items": [ {"name": "Small Healing Potion", "description": "+15 hp", "cost": 20}, {"name": "Self Healing Potion", "description": "+20 hp", "cost": 50}, {"name": "Moderated Potion", "description": "+25 hp", "cost": 75}, {"name": "Regen Potion", "description": "+15%", "cost": 100}, {"name": "Hammerhead Crocker", "description": "+7% attack for 7 turns", "cost": 55}, {"name": "Warhammer Crocker", "description": "+15% attack for 7 turns", "cost": 75}, {"name": "Barhog", "description": "+7% Defense for 7 turns", "cost": 45}, {"name": "Warhog", "description": "+15% defense for 7 turns", "cost": 60}, {"name": "Non applicable scroll", "description": "+2 Speed for 7 turns", "cost": 40}, {"name": "Applicable scroll", "description": "+4 speed for 7 turns", "cost": 55}, {"name": "Ransacked Shield", "description": "+12% Dodge chance for 3 turns", "cost": 60}, {"name": "Unbuilded Shield", "description": "+23% Dodge Chance for 5 turns", "cost": 90}, {"name": "Mystic Scroll", "description": "25% chance to negate all debuffs on player for 4 turns", "cost": 60}, {"name": "Mystic Beurau", "description": "50% chance to negate all debuffs on player for 4 turns", "cost": 120}, {"name": "Variant Bs", "description": "Increase all stats up to 25% for 10 turns", "cost": 200}, {"name": "Variant Ex", "description": "Increase all stats up to 50% for 10 turns", "cost": 400}, {"name": "Hide cloak", "description": "40% chance to dodge the battle against enemies when exploring", "cost": 50}, {"name": "Invisible potion", "description": "60% chance to dodge the battle against enemies when exploring", "cost": 75}, {"name": "Exp Moneter", "description": "Give you 20 exp points", "cost": 50}, {"name": "Exp Vitalis", "description": "Give you 50 exp points", "cost": 100}, {"name": "Exp For enhancer", "description": "Give you 100 points", "cost": 150} ], "Weapons": [ {"name": "Stone Sword", "description": "+12 attack", "cost": 150}, {"name": "Copper Sword", "description": "+15 attack", "cost": 275}, {"name": "Sickanum Sword", "description": "+17 attack", "cost": 400}, {"name": "Arivanum Sword", "description": "+23 attack", "cost": 600}, {"name": "Viranium Sword", "description": "+25 attack", "cost": 850}, {"name": "Titanium sword", "description": "+35 attack", "cost": 1250} ], "Armors": [ {"name": "Jungle sets", "description": "+7 Defense", "cost": 90}, {"name": "Byzantine sets", "description": "+12 Defense", "cost": 140}, {"name": "Nikel Sets", "description": "+15 Defense", "cost": 350}, {"name": "Warhead Sets", "description": "+25 Defense", "cost": 560}, {"name": "Titanium Sets", "description": "+40 Defense", "cost": 850} ], "Shields": [ {"name": "Wooden Ob", "description": "+2 dodge", "cost": 80}, {"name": "Long Ob", "description": "+3 dodge, +2 Defense", "cost": 120}, {"name": "Cob Ob", "description": "+5 dodge, +4 Defense", "cost": 300}, {"name": "Knock Ob", "description": "+7 dodge, +5 Defense, +3 Attack", "cost": 550}, {"name": "Neb Ob", "description": "+12 dodge, +7 Defense, +5 Attack", "cost": 760} ], "Footwear": [ {"name": "Jungle Foot", "description": "+3 speeds", "cost": 45}, {"name": "Iron Foot", "description": "+5 Speed", "cost": 75}, {"name": "Metal WarFoot", "description": "+8 Speeds", "cost": 120}, {"name": "Diamond Boots", "description": "+12 Speeds", "cost": 230}, {"name": "Noble Boots", "description": "+19 Speeds", "cost": 450}, {"name": "Lizable Boots", "description": "+25 Speeds", "cost": 700} ] } def create_character(): clear_screen() print("Character Creation") name = input("Enter your character's name: ") clear_screen() print(f"Character Name: {name}\n") while True: print("Select Difficulty:") print("1. Basic 🛡️") print("2. Exemplar ⚔️") print("3. Templar ☠️") difficulty_choice = input("Enter the number to select difficulty: ") if difficulty_choice == "1": difficulty = "Basic" description = "Enemies are powerful in their origins." elif difficulty_choice == "2": difficulty = "Exemplar" description = "Enemies are harder and more immortalized." elif difficulty_choice == "3": difficulty = "Templar" description = "Enemies are evils." else: print("Invalid difficulty choice. Please choose a valid option.") time.sleep(1) clear_screen() continue clear_screen() print("Selected Difficulty:") print(f"Name: {name}") print(f"Difficulty: {difficulty}") print(f"Description: {description}\n") print("1. Confirm") print("2. Back") confirm_choice = input("Enter your choice: ") if confirm_choice == "1": break elif confirm_choice == "2": clear_screen() continue else: print("Invalid choice. Please enter 1 to confirm or 2 to go back.") time.sleep(1) clear_screen() return Player(name, difficulty) def clear_screen(): """Clears the console screen.""" os.system('cls' if os.name == 'nt' else 'clear') def main_menu(): clear_screen() print("BeaVenture\n") print("1. Create Character") print("2. Exit") print("\nEnter the number to select an option.") def main(): while True: main_menu() try: choice = int(input("")) if choice == 1: player = create_character() player.display_status() elif choice == 2: clear_screen() print("Exiting BeaVenture. Goodbye!") time.sleep(2) clear_screen() print("Game Was Ended") input("Press Enter to exit...") clear_screen() break else: print("Invalid option. Please enter a valid number.") time.sleep(2) except ValueError: print("Invalid input. Please enter a number.") if __name__ == "__main__": main()
for (int i = 0; i < 100; i++) myString += ...blah...
import os import time import sys class Player: def __init__(self, name, difficulty): self.name = name self.difficulty = difficulty Attack = 0 Defense = 0 Dodge = 0 Speed = 0 self.gold = 10000 self.diamonds = 0 self.experience = 0 self.level = 1 self.exp_required = 100 self.exp_multiplier = 0.75 # 75% increase for experience requirement per level self.inventory = { # Initialize inventory "Weapons" : [], "Armors" : [], "Shields" : [], "Footwear" : [], "Usable Items": [] # Add Usable Items category } self.equipped_items = { # Initialize equipped items "Weapons" : {"name": "Broken Sword", "description": "+10 Damage", "Attack": 10}, "Armors" : {"name": "Broken Armor", "description": "+5 Defense", "Defense": 5}, "Shields" : {"name": "Broken Shield", "description": "+2 Dodge", "Dodge": 2}, "Footwear" : {"name": "Broken Footwear", "description": "+3 Speed", "Speed": 3}, "Accessories" : None, "Bag" : None } self.base_stats = { "HP": 100, "Defense": 0, "Attack": 0, "Dodge": 0, "Speed": 0 } self.max_inventory_slots = 30 self.update_stats() # Update player stats based on equipped items def visit_inventory(self): while True: os.system('cls' if os.name == 'nt' else 'clear') print("Inventory:") print("=" * 40) print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.display_items("Weapons") elif choice == "2": self.display_items("Armors") elif choice == "3": self.display_items("Shields") elif choice == "4": self.display_items("Footwear") elif choice == "5": self.display_items("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_items(self, item_type): while True: os.system('cls' if os.name == 'nt' else 'clear') print(f"{item_type}:") print("=" * 40) if self.inventory[item_type]: for idx, item in enumerate(self.inventory[item_type], 1): print(f"{idx}. {item['name']}: {item['description']}") print("0. Back to Inventory Menu") print("Enter the number to equip the item or 0 to go back.") choice = input("") if choice == "0": break # Break out of the inner loop to return to the previous menu elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]): self.equip_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) else: print("No items in this category.") print("Press < to go back") choice = input("") if choice == "<": break # Break out of the inner loop to return to the previous menu def equip_item(self, item_type, index): if item_type in self.equipped_items: if 0 <= index < len(self.inventory[item_type]): item = self.inventory[item_type].pop(index) if self.equipped_items[item_type]: old_item = self.equipped_items[item_type] self.inventory[item_type].append(old_item) self.equipped_items[item_type] = item self.update_stats() # Update stats after equipping any item print(f"{item['name']} equipped.") time.sleep(1) self.display_equipped_items() # Display equipped items after equipping return # Added to exit the method and prevent further execution else: print("Invalid item index.") time.sleep(1) else: print("Invalid item type.") time.sleep(1) def update_stats(self): # Reset stats to base values for stat in self.base_stats: setattr(self, stat.lower(), self.base_stats[stat]) # Apply bonuses from equipped items equipped = False # Flag to track if any item is equipped for item_type, item in self.equipped_items.items(): if item: equipped = True self.when_equipped(item) # If no items are equipped, set all stats (except HP) to 0 if not equipped: for stat in self.base_stats: if stat != "HP": setattr(self, stat.lower(), 0) def when_equipped(self, item): for stat in item: if stat in self.base_stats: setattr(self, stat.lower(), self.base_stats[stat] + item[stat]) def display_equipped_items(self): os.system('cls' if os.name == 'nt' else 'clear') print("Equipped Items:") print("=" * 40) for item_type, item in self.equipped_items.items(): if item: print(f"{item_type}: {item['name']} - {item['description']}") else: print(f"{item_type}: None") def display_status(self): clear_screen() print("Player Status:") print("=" * 40) print(f"Name: {self.name}") print(f"Difficulty: {self.difficulty}") print("-" * 40) print("Stats:") print(f"HP :❤️{self.base_stats['HP']}") print(f"Defense :🛡️{self.defense}") print(f"Attack :⚔️{self.attack}") print(f"Dodge :🤺{self.dodge}") print(f"Speed :🏃{self.speed}") print("-"*40) print(f"Level: {self.level}") print(f"Experience: {self.experience}/{self.exp_required}") print("-"*40) print(f"Gold: {self.gold} 💰") print(f"Diamonds: {self.diamonds} 💎") print("="*40) print("Game Options:") print("1. Visit Shop") print("2. Inventory") print("3. Equipped Items") print("4. Play Game") print("5. Add 50 Experience Points") print("< Back to Main Menu") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.visit_shop() elif choice == "2": self.visit_inventory() elif choice == "3": self.display_equipped_items() elif choice == "4": self.play_game() elif choice == "5": self.add_experience(50) elif choice == "<": return else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_status() def calculate_stat(self, stat_name): base_stat = getattr(self, stat_name) bonus_stat = sum(item.get(stat_name, 0) for item in self.equipped_items.values() if item) return base_stat + bonus_stat def display_items(self, item_type): os.system('cls' if os.name == 'nt' else 'clear') print(f"{item_type}:") print("=" * 40) if self.inventory[item_type]: for idx, item in enumerate(self.inventory[item_type], 1): if item: # Check if item is not None print(f"{idx}. {item['name']}: {item['description']}") else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.visit_inventory() elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]): self.equip_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_items(item_type) else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.visit_inventory() else: print("Invalid option. Please enter < to go back.") time.sleep(1) self.visit_inventory() def equip_item(self, item_type, index): if item_type in self.equipped_items: if 0 <= index < len(self.inventory[item_type]): item = self.inventory[item_type].pop(index) if self.equipped_items[item_type]: old_item = self.equipped_items[item_type] self.inventory[item_type].append(old_item) self.equipped_items[item_type] = item self.update_stats() # Update stats after equipping any item print(f"{item['name']} equipped.") time.sleep(1) else: print("Invalid item index.") time.sleep(1) else: print("Invalid item type.") time.sleep(1) def apply_item_stats(self, item): if 'Attack' in item: self.attack += item['Attack'] if 'Defense' in item: self.defense += item['Defense'] if 'Dodge' in item: self.dodge += item['Dodge'] if 'Speed' in item: self.speed += item['Speed'] def unequip_item(self, item_type_to_swap): if self.equipped_items[item_type_to_swap]: self.swap_item(item_type_to_swap) else: print("No item equipped.") time.sleep(1) self.display_equipped_items() def unequip_menu(self, item_type_to_swap): os.system('cls' if os.name == 'nt' else 'clear') print(f"Swap {item_type_to_swap}:") print("=" * 40) if self.equipped_items[item_type_to_swap]: equipped_item = self.equipped_items[item_type_to_swap] if 'description' in equipped_item: print(f"1. {equipped_item['name']} - {equipped_item['description']}") else: print(f"1. {equipped_item['name']}") print("Enter 1 to swap or press < to cancel.") choice = input("") if choice == "1": self.swap_item(item_type_to_swap) elif choice == "<": self.display_equipped_items() else: print("Invalid option. Please enter a valid option.") time.sleep(1) self.unequip_menu(item_type_to_swap) else: print(f"No {item_type_to_swap} equipped.") time.sleep(1) self.display_equipped_items() def swap_item(self, item_type_to_swap): os.system('cls' if os.name == 'nt' else 'clear') print(f"Swap {item_type_to_swap}:") print("=" * 40) if self.inventory[item_type_to_swap]: for idx, item in enumerate(self.inventory[item_type_to_swap], 1): if item: # Check if item is not None print(f"{idx}. {item['name']}: {item['description']}") else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.unequip_menu(item_type_to_swap) elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type_to_swap]): self.equip_item(item_type_to_swap, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_equipped_items() # Add this line to return to the "Equipped Items" section else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.unequip_menu(item_type_to_swap) else: print("Invalid option. Please enter < to go back.") time.sleep(1) self.unequip_menu(item_type_to_swap) def display_equipped_items(self): clear_screen() print("Equipped Items:") print("=" * 40) for item_type, item in self.equipped_items.items(): if item: name = item.get('name', 'Unknown') description = item.get('description', 'No description') print(f"{item_type}: {name} - {description}") else: print(f"{item_type}: None") print("\nSwap Items:") print("=" * 40) for i, (item_type, item) in enumerate(self.equipped_items.items(), start=1): if item: name = item.get('name', 'Unknown') description = item.get('description', 'No description') print(f"{i}. {item_type}: {name} - {description}") else: print(f"{i}. {item_type}: None") print("Press < to go back to the player status menu.") choice = input("") if choice == "<": self.display_status() elif choice.isdigit(): index = int(choice) - 1 if 0 <= index < len(self.equipped_items): item_type_to_unequip = list(self.equipped_items.keys())[index] self.unequip_menu(item_type_to_unequip) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_equipped_items() else: print("Invalid option. Please enter a valid option.") time.sleep(1) self.display_equipped_items() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def play_game(self): clear_screen() # Placeholder for play game functionality input("Play game functionality is under construction. Press Enter to return to the player status menu...") self.display_status() def add_experience(self, amount): self.experience += amount if self.experience >= self.exp_required: self.level_up() self.display_status() def level_up(self): self.level += 1 self.experience = 0 self.attack += 0.5 self.defense += 0.5 self.dodge += 0.5 self.speed += 0.5 self.exp_multiplier = 0.25 self.exp_required = int(self.exp_required * (1 + self.exp_multiplier)) # Update exp required with new multiplier def equip_item_level_up(self, item): if 'Attack' in item: self.attack += item['Attack'] if 'Defense' in item: self.defense += item['Defense'] if 'Dodge' in item: self.dodge += item['Dodge'] if 'Speed' in item: self.speed += item['Speed'] def get_name_display(self): symbol = "" if self.difficulty == "Basic": symbol = "🛡️" elif self.difficulty == "Exemplar": symbol = "⚔️" elif self.difficulty == "Templar": symbol = "☠️" return f"{symbol} {self.name}" def get_difficulty_display(self): return self.difficulty def visit_shop(self): clear_screen() while True: os.system('cls' if os.name == 'nt' else 'clear') print("Welcome to the Shop!") print("=" * 40) print("Shop Sections:") print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select a shop section.") choice = input("") if choice == "1": self.display_shop_section("Weapons") elif choice == "2": self.display_shop_section("Armors") elif choice == "3": self.display_shop_section("Shields") elif choice == "4": self.display_shop_section("Footwear") elif choice == "5": self.display_shop_section("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_shop_section(self, item_type): os.system('cls' if os.name == 'nt' else 'clear') print(f"Shop - {item_type}:") print("=" * 40) if item_type in items_groups: for idx, item in enumerate(items_groups[item_type], 1): print(f"{idx}. {item['name']}: {item['description']} - Cost: {item['cost']} gold") print("0. Back to Shop Sections") print("Enter the number to purchase the item or 0 to go back.") choice = input("") if choice == "0": self.visit_shop() elif choice.isdigit() and 0 < int(choice) <= len(items_groups[item_type]): self.purchase_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_shop_section(item_type) else: print("Invalid shop section.") time.sleep(1) self.visit_shop() def purchase_item(self, item_type, index): item = items_groups[item_type][index] cost = item['cost'] if self.gold >= cost: self.gold -= cost self.inventory[item_type].append(item) print(f"You have purchased {item['name']} for {cost} gold.") time.sleep(1) else: print("Insufficient gold to purchase this item.") time.sleep(1) self.display_shop_section(item_type) items_groups = { "Usable Items": [ {"name": "Small Healing Potion", "description": "+15 hp", "cost": 20}, {"name": "Self Healing Potion", "description": "+20 hp", "cost": 50}, {"name": "Moderated Potion", "description": "+25 hp", "cost": 75}, {"name": "Regen Potion", "description": "+15%", "cost": 100}, {"name": "Hammerhead Crocker", "description": "+7% attack for 7 turns", "cost": 55, "Attack": 0.07}, {"name": "Warhammer Crocker", "description": "+15% attack for 7 turns", "cost": 75, "Attack": 0.15}, {"name": "Barhog", "description": "+7% Defense for 7 turns", "cost": 45, "Defense": 0.07}, {"name": "Warhog", "description": "+15% defense for 7 turns", "cost": 60, "Defense": 0.15}, {"name": "Non applicable scroll", "description": "+2 Speed for 7 turns", "cost": 40, "Speed": 2}, {"name": "Applicable scroll", "description": "+4 speed for 7 turns", "cost": 55, "Speed": 4}, {"name": "Ransacked Shield", "description": "+12% Dodge chance for 3 turns", "cost": 60, "Dodge": 0.12}, {"name": "Unbuilded Shield", "description": "+23% Dodge Chance for 5 turns", "cost": 90, "Dodge": 0.23}, {"name": "Mystic Scroll", "description": "25% chance to negate all debuffs on player for 4 turns", "cost": 60}, {"name": "Mystic Beurau", "description": "50% chance to negate all debuffs on player for 4 turns", "cost": 120}, {"name": "Variant Bs", "description": "Increase all stats up to 25% for 10 turns", "cost": 200}, {"name": "Variant Ex", "description": "Increase all stats up to 50% for 10 turns", "cost": 400}, {"name": "Hide cloak", "description": "40% chance to dodge the battle against enemies when exploring", "cost": 50, "Dodge": 0.4}, {"name": "Invisible potion", "description": "60% chance to dodge the battle against enemies when exploring", "cost": 75, "Dodge": 0.6}, {"name": "Exp Moneter", "description": "Give you 20 exp points", "cost": 50}, {"name": "Exp Vitalis", "description": "Give you 50 exp points", "cost": 100}, {"name": "Exp For enhancer", "description": "Give you 100 points", "cost": 150} ], "Weapons": [ {"name": "Stone Sword", "description": "+12 attack", "cost": 150, "Attack": 12}, {"name": "Copper Sword", "description": "+15 attack", "cost": 275, "Attack": 15}, {"name": "Sickanum Sword", "description": "+17 attack", "cost": 400, "Attack": 17}, {"name": "Arivanum Sword", "description": "+23 attack", "cost": 600, "Attack": 23}, {"name": "Viranium Sword", "description": "+25 attack", "cost": 850, "Attack": 25}, {"name": "Titanium sword", "description": "+35 attack", "cost": 1250, "Attack": 35} ], "Armors": [ {"name": "Jungle sets", "description": "+7 Defense", "cost": 90, "Defense": 7}, {"name": "Byzantine sets", "description": "+12 Defense", "cost": 140, "Defense": 12}, {"name": "Nikel Sets", "description": "+15 Defense", "cost": 350, "Defense": 15}, {"name": "Warhead Sets", "description": "+25 Defense", "cost": 560, "Defense": 25}, {"name": "Titanium Sets", "description": "+40 Defense", "cost": 850, "Defense": 40} ], "Shields": [ {"name": "Wooden Ob", "description": "+2 dodge", "cost": 80, "Dodge": 2}, {"name": "Long Ob", "description": "+3 dodge, +2 Defense", "cost": 120, "Dodge": 3, "Defense": 2}, {"name": "Cob Ob", "description": "+5 dodge, +4 Defense", "cost": 300, "Dodge": 5, "Defense": 4}, {"name": "Knock Ob", "description": "+7 dodge, +5 Defense, +3 Attack", "cost": 550, "Dodge": 7, "Defense": 5, "Attack": 3}, {"name": "Neb Ob", "description": "+12 dodge, +7 Defense, +5 Attack", "cost": 760, "Dodge": 12, "Defense": 7, "Attack": 5} ], "Footwear": [ {"name": "Jungle Foot", "description": "+3 speeds", "cost": 45, "Speed": 3}, {"name": "Iron Foot", "description": "+5 Speed", "cost": 75, "Speed": 5}, {"name": "Metal WarFoot", "description": "+8 Speeds", "cost": 120, "Speed": 8}, {"name": "Diamond Boots", "description": "+12 Speeds", "cost": 230, "Speed": 12}, {"name": "Noble Boots", "description": "+19 Speeds", "cost": 450, "Speed": 19}, {"name": "Lizable Boots", "description": "+25 Speeds", "cost": 700, "Speed": 25} ], "Weapons None": [ {"name": "None", "description": "No Weapons Used", "cost" : 0, "Attack": 0} ], "Armors None": [ {"name": "None", "description": "Armors Used", "cost" : 0, "Attack": 0} ], "Shields None": [ {"name": "None", "description": "No Shields Used", "cost" : 0, "Attack": 0} ], "Footwear None": [ {"name": "None", "description": "No Footwears Used", "cost" : 0, "Attack": 0} ], } def create_character(): clear_screen() print("Character Creation") name = input("Enter your character's name: ") clear_screen() print(f"Character Name: {name}\n") while True: print("Select Difficulty:") print("1. Basic 🛡️") print("2. Exemplar ⚔️") print("3. Templar ☠️") difficulty_choice = input("Enter the number to select difficulty: ") if difficulty_choice == "1": difficulty = "Basic" description = "Enemies are powerful in their origins." elif difficulty_choice == "2": difficulty = "Exemplar" description = "Enemies are harder and more immortalized." elif difficulty_choice == "3": difficulty = "Templar" description = "Enemies are evils." else: print("Invalid difficulty choice. Please choose a valid option.") time.sleep(1) clear_screen() continue clear_screen() print("Selected Difficulty:") print(f"Name: {name}") print(f"Difficulty: {difficulty}") print(f"Description: {description}\n") print("1. Confirm") print("2. Back") confirm_choice = input("Enter your choice: ") if confirm_choice == "1": break elif confirm_choice == "2": clear_screen() continue else: print("Invalid choice. Please enter 1 to confirm or 2 to go back.") time.sleep(1) clear_screen() player = Player(name, difficulty) player.equipped_items["Weapons"] = {"name": "Broken Sword", "description": "+10 Damage", "attack": 10} player.equipped_items["Armors"] = {"name": "Broken Armor", "description": "+5 Defense", "defense": 5} player.equipped_items["Shields"] = {"name": "Broken Shield", "description": "+2 Dodge", "dodge": 2} player.equipped_items["Footwear"] = {"name": "Broken Footwear", "description": "+3 Speed", "speed": 3} return Player(name, difficulty) def clear_screen(): """Clears the console screen.""" os.system('cls' if os.name == 'nt' else 'clear') def main_menu(): clear_screen() print("BeaVenture\n") print("1. Create Character") print("2. Exit") print("\nEnter the number to select an option.") def main(): while True: main_menu() try: choice = int(input("")) if choice == 1: player = create_character() player.display_status() elif choice == 2: clear_screen() print("Exiting BeaVenture. Goodbye!") time.sleep(2) clear_screen() print("Game Was Ended") input("Press Enter to exit...") clear_screen() break else: print("Invalid option. Please enter a valid number.") time.sleep(2) except ValueError: print("Invalid input. Please enter a number.") if __name__ == "__main__": main()
import os import time import sys class Player: def __init__(self, name, difficulty): self.name = name self.difficulty = difficulty Attack = 0 Defense = 0 Dodge = 0 Speed = 0 self.gold = 10000 self.diamonds = 0 self.experience = 0 self.level = 1 self.exp_required = 100 self.exp_multiplier = 0.75 # 75% increase for experience requirement per level self.inventory = { # Initialize inventory "Weapons": [], "Armors": [], "Shields": [], "Footwear": [], "Usable Items": [] # Add Usable Items category } self.equipped_items = { # Initialize equipped items "Weapons": {"name": "Broken Sword", "description": "+10 Damage", "Attack": 10}, "Armors": {"name": "Broken Armor", "description": "+5 Defense", "Defense": 5}, "Shields": {"name": "Broken Shield", "description": "+2 Dodge", "Dodge": 2}, "Footwear": {"name": "Broken Footwear", "description": "+3 Speed", "Speed": 3}, "Accessories": None, "Bag": None } self.base_stats = { "HP": 100, "Defense": 0, "Attack": 0, "Dodge": 0, "Speed": 0 } self.max_inventory_slots = 30 self.update_stats() # Update player stats based on equipped items def visit_inventory(self): while True: os.system('cls' if os.name == 'nt' else 'clear') print("Inventory:") print("=" * 40) print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.display_items("Weapons") elif choice == "2": self.display_items("Armors") elif choice == "3": self.display_items("Shields") elif choice == "4": self.display_items("Footwear") elif choice == "5": self.display_items("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_items(self, item_type): while True: os.system('cls' if os.name == 'nt' else 'clear') print(f"{item_type}:") print("=" * 40) if self.inventory[item_type]: for idx, item in enumerate(self.inventory[item_type], 1): print(f"{idx}. {item['name']}: {item['description']}") print("0. Back to Inventory Menu") print("Enter the number to equip the item or 0 to go back.") choice = input("") if choice == "0": break # Break out of the inner loop to return to the previous menu elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]): self.equip_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) else: print("No items in this category.") print("Press < to go back") choice = input("") if choice == "<": break # Break out of the inner loop to return to the previous menu def equip_item(self, item_type, index): if item_type in self.equipped_items: if 0 <= index < len(self.inventory[item_type]): item = self.inventory[item_type].pop(index) if self.equipped_items[item_type]: old_item = self.equipped_items[item_type] self.inventory[item_type].append(old_item) self.equipped_items[item_type] = item self.update_stats() # Update stats after equipping any item print(f"{item['name']} equipped.") time.sleep(1) self.display_equipped_items() # Display equipped items after equipping return # Added to exit the method and prevent further execution else: print("Invalid item index.") time.sleep(1) else: print("Invalid item type.") time.sleep(1) def update_stats(self): # Reset stats to base values for stat in self.base_stats: setattr(self, stat.lower(), self.base_stats[stat]) # Apply bonuses from equipped items equipped = False # Flag to track if any item is equipped for item_type, item in self.equipped_items.items(): if item: equipped = True self.when_equipped(item) # If no items are equipped, set all stats (except HP) to 0 if not equipped: for stat in self.base_stats: if stat != "HP": setattr(self, stat.lower(), 0) def when_equipped(self, item): for stat in item: if stat in self.base_stats: setattr(self, stat.lower(), self.base_stats[stat] + item[stat]) def display_equipped_items(self): os.system('cls' if os.name == 'nt' else 'clear') print("Equipped Items:") print("=" * 40) for item_type, item in self.equipped_items.items(): if item: print(f"{item_type}: {item['name']} - {item['description']}") else: print(f"{item_type}: None") def display_status(self): clear_screen() print("Player Status:") print("=" * 40) print(f"Name: {self.name}") print(f"Difficulty: {self.difficulty}") print("-" * 40) print("Stats:") print(f"HP :❤️{self.base_stats['HP']}") print(f"Defense :🛡️{self.defense}") print(f"Attack :⚔️{self.attack}") print(f"Dodge :🤺{self.dodge}") print(f"Speed :🏃{self.speed}") print("-"*40) print(f"Level: {self.level}") print(f"Experience: {self.experience}/{self.exp_required}") print("-"*40) print(f"Gold: {self.gold} 💰") print(f"Diamonds: {self.diamonds} 💎") print("="*40) print("Game Options:") print("1. Visit Shop") print("2. Inventory") print("3. Equipped Items") print("4. Play Game") print("5. Delete this Character") print("6. Add 50 Experience Points") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.visit_shop() elif choice == "2": self.visit_inventory() elif choice == "3": self.display_equipped_items() elif choice == "4": self.play_game() elif choice == "5": return elif choice == "6": self.add_experience(50) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_status() def calculate_stat(self, stat_name): base_stat = getattr(self, stat_name) bonus_stat = sum(item.get(stat_name, 0) for item in self.equipped_items.values() if item) return base_stat + bonus_stat def display_items(self, item_type): os.system('cls' if os.name == 'nt' else 'clear') print(f"{item_type}:") print("=" * 40) if self.inventory[item_type]: for idx, item in enumerate(self.inventory[item_type], 1): if item: # Check if item is not None print(f"{idx}. {item['name']}: {item['description']}") else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.visit_inventory() elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]): self.equip_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_items(item_type) else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.visit_inventory() else: print("Invalid option. Please enter < to go back.") time.sleep(1) self.visit_inventory() def equip_item(self, item_type, index): if item_type in self.equipped_items: if 0 <= index < len(self.inventory[item_type]): item = self.inventory[item_type].pop(index) if self.equipped_items[item_type]: old_item = self.equipped_items[item_type] self.inventory[item_type].append(old_item) self.equipped_items[item_type] = item self.update_stats() # Update stats after equipping any item print(f"{item['name']} equipped.") time.sleep(1) else: print("Invalid item index.") time.sleep(1) else: print("Invalid item type.") time.sleep(1) def apply_item_stats(self, item): if 'Attack' in item: self.attack += item['Attack'] if 'Defense' in item: self.defense += item['Defense'] if 'Dodge' in item: self.dodge += item['Dodge'] if 'Speed' in item: self.speed += item['Speed'] def unequip_item(self, item_type_to_swap): if self.equipped_items[item_type_to_swap]: self.swap_item(item_type_to_swap) else: print("No item equipped.") time.sleep(1) self.display_equipped_items() def unequip_menu(self, item_type_to_swap): os.system('cls' if os.name == 'nt' else 'clear') print(f"Swap {item_type_to_swap}:") print("=" * 40) if self.equipped_items[item_type_to_swap]: equipped_item = self.equipped_items[item_type_to_swap] if 'description' in equipped_item: print(f"1. {equipped_item['name']} - {equipped_item['description']}") else: print(f"1. {equipped_item['name']}") print("Enter 1 to swap or press < to cancel.") choice = input("") if choice == "1": self.swap_item(item_type_to_swap) elif choice == "<": self.display_equipped_items() else: print("Invalid option. Please enter a valid option.") time.sleep(1) self.unequip_menu(item_type_to_swap) else: print(f"No {item_type_to_swap} equipped.") time.sleep(1) self.display_equipped_items() def swap_item(self, item_type_to_swap): os.system('cls' if os.name == 'nt' else 'clear') print(f"Swap {item_type_to_swap}:") print("=" * 40) if self.inventory[item_type_to_swap]: for idx, item in enumerate(self.inventory[item_type_to_swap], 1): if item: # Check if item is not None print(f"{idx}. {item['name']}: {item['description']}") else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.unequip_menu(item_type_to_swap) elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type_to_swap]): self.equip_item(item_type_to_swap, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_equipped_items() # Add this line to return to the "Equipped Items" section else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.unequip_menu(item_type_to_swap) else: print("Invalid option. Please enter < to go back.") time.sleep(1) self.unequip_menu(item_type_to_swap) def display_equipped_items(self): clear_screen() print("Equipped Items:") print("=" * 40) for item_type, item in self.equipped_items.items(): if item: name = item.get('name', 'Unknown') description = item.get('description', 'No description') print(f"{item_type}: {name} - {description}") else: print(f"{item_type}: None") print("\nUnequip Items:") print("=" * 40) for i, (item_type, item) in enumerate(self.equipped_items.items(), start=1): if item: name = item.get('name', 'Unknown') description = item.get('description', 'No description') print(f"{i}. {item_type}: {name} - {description}") else: print(f"{i}. {item_type}: None") print("Press < to go back to the player status menu.") choice = input("") if choice == "<": self.display_status() elif choice.isdigit(): index = int(choice) - 1 if 0 <= index < len(self.equipped_items): item_type_to_unequip = list(self.equipped_items.keys())[index] self.unequip_menu(item_type_to_unequip) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_equipped_items() else: print("Invalid option. Please enter a valid option.") time.sleep(1) self.display_equipped_items() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def play_game(self): clear_screen() # Placeholder for play game functionality input("Play game functionality is under construction. Press Enter to return to the player status menu...") self.display_status() def add_experience(self, amount): self.experience += amount if self.experience >= self.exp_required: self.level_up() self.display_status() def level_up(self): self.level += 1 self.experience = 0 self.attack += 0.5 self.defense += 0.5 self.dodge += 0.5 self.speed += 0.5 self.exp_multiplier = 0.25 self.exp_required = int(self.exp_required * (1 + self.exp_multiplier)) # Update exp required with new multiplier def equip_item_level_up(self, item): if 'Attack' in item: self.attack += item['Attack'] if 'Defense' in item: self.defense += item['Defense'] if 'Dodge' in item: self.dodge += item['Dodge'] if 'Speed' in item: self.speed += item['Speed'] def get_name_display(self): symbol = "" if self.difficulty == "Basic": symbol = "🛡️" elif self.difficulty == "Exemplar": symbol = "⚔️" elif self.difficulty == "Templar": symbol = "☠️" return f"{symbol} {self.name}" def get_difficulty_display(self): return self.difficulty def visit_shop(self): clear_screen() while True: os.system('cls' if os.name == 'nt' else 'clear') print("Welcome to the Shop!") print("=" * 40) print("Shop Sections:") print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select a shop section.") choice = input("") if choice == "1": self.display_shop_section("Weapons") elif choice == "2": self.display_shop_section("Armors") elif choice == "3": self.display_shop_section("Shields") elif choice == "4": self.display_shop_section("Footwear") elif choice == "5": self.display_shop_section("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_shop_section(self, item_type): os.system('cls' if os.name == 'nt' else 'clear') print(f"Shop - {item_type}:") print("=" * 40) if item_type in items_groups: for idx, item in enumerate(items_groups[item_type], 1): print(f"{idx}. {item['name']}: {item['description']} - Cost: {item['cost']} gold") print("0. Back to Shop Sections") print("Enter the number to purchase the item or 0 to go back.") choice = input("") if choice == "0": self.visit_shop() elif choice.isdigit() and 0 < int(choice) <= len(items_groups[item_type]): self.purchase_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_shop_section(item_type) else: print("Invalid shop section.") time.sleep(1) self.visit_shop() def purchase_item(self, item_type, index): item = items_groups[item_type][index] cost = item['cost'] if self.gold >= cost: self.gold -= cost self.inventory[item_type].append(item) print(f"You have purchased {item['name']} for {cost} gold.") time.sleep(1) else: print("Insufficient gold to purchase this item.") time.sleep(1) self.display_shop_section(item_type) items_groups = { "Usable Items": [ {"name": "Small Healing Potion", "description": "+15 hp", "cost": 20}, {"name": "Self Healing Potion", "description": "+20 hp", "cost": 50}, {"name": "Moderated Potion", "description": "+25 hp", "cost": 75}, {"name": "Regen Potion", "description": "+15%", "cost": 100}, {"name": "Hammerhead Crocker", "description": "+7% attack for 7 turns", "cost": 55, "Attack": 0.07}, {"name": "Warhammer Crocker", "description": "+15% attack for 7 turns", "cost": 75, "Attack": 0.15}, {"name": "Barhog", "description": "+7% Defense for 7 turns", "cost": 45, "Defense": 0.07}, {"name": "Warhog", "description": "+15% defense for 7 turns", "cost": 60, "Defense": 0.15}, {"name": "Non applicable scroll", "description": "+2 Speed for 7 turns", "cost": 40, "Speed": 2}, {"name": "Applicable scroll", "description": "+4 speed for 7 turns", "cost": 55, "Speed": 4}, {"name": "Ransacked Shield", "description": "+12% Dodge chance for 3 turns", "cost": 60, "Dodge": 0.12}, {"name": "Unbuilded Shield", "description": "+23% Dodge Chance for 5 turns", "cost": 90, "Dodge": 0.23}, {"name": "Mystic Scroll", "description": "25% chance to negate all debuffs on player for 4 turns", "cost": 60}, {"name": "Mystic Beurau", "description": "50% chance to negate all debuffs on player for 4 turns", "cost": 120}, {"name": "Variant Bs", "description": "Increase all stats up to 25% for 10 turns", "cost": 200}, {"name": "Variant Ex", "description": "Increase all stats up to 50% for 10 turns", "cost": 400}, {"name": "Hide cloak", "description": "40% chance to dodge the battle against enemies when exploring", "cost": 50, "Dodge": 0.4}, {"name": "Invisible potion", "description": "60% chance to dodge the battle against enemies when exploring", "cost": 75, "Dodge": 0.6}, {"name": "Exp Moneter", "description": "Give you 20 exp points", "cost": 50}, {"name": "Exp Vitalis", "description": "Give you 50 exp points", "cost": 100}, {"name": "Exp For enhancer", "description": "Give you 100 points", "cost": 150} ], "Weapons": [ {"name": "Stone Sword", "description": "+12 attack", "cost": 150, "Attack": 12}, {"name": "Copper Sword", "description": "+15 attack", "cost": 275, "Attack": 15}, {"name": "Sickanum Sword", "description": "+17 attack", "cost": 400, "Attack": 17}, {"name": "Arivanum Sword", "description": "+23 attack", "cost": 600, "Attack": 23}, {"name": "Viranium Sword", "description": "+25 attack", "cost": 850, "Attack": 25}, {"name": "Titanium sword", "description": "+35 attack", "cost": 1250, "Attack": 35} ], "Armors": [ {"name": "Jungle sets", "description": "+7 Defense", "cost": 90, "Defense": 7}, {"name": "Byzantine sets", "description": "+12 Defense", "cost": 140, "Defense": 12}, {"name": "Nikel Sets", "description": "+15 Defense", "cost": 350, "Defense": 15}, {"name": "Warhead Sets", "description": "+25 Defense", "cost": 560, "Defense": 25}, {"name": "Titanium Sets", "description": "+40 Defense", "cost": 850, "Defense": 40} ], "Shields": [ {"name": "Wooden Ob", "description": "+2 dodge", "cost": 80, "Dodge": 2}, {"name": "Long Ob", "description": "+3 dodge, +2 Defense", "cost": 120, "Dodge": 3, "Defense": 2}, {"name": "Cob Ob", "description": "+5 dodge, +4 Defense", "cost": 300, "Dodge": 5, "Defense": 4}, {"name": "Knock Ob", "description": "+7 dodge, +5 Defense, +3 Attack", "cost": 550, "Dodge": 7, "Defense": 5, "Attack": 3}, {"name": "Neb Ob", "description": "+12 dodge, +7 Defense, +5 Attack", "cost": 760, "Dodge": 12, "Defense": 7, "Attack": 5} ], "Footwear": [ {"name": "Jungle Foot", "description": "+3 speeds", "cost": 45, "Speed": 3}, {"name": "Iron Foot", "description": "+5 Speed", "cost": 75, "Speed": 5}, {"name": "Metal WarFoot", "description": "+8 Speeds", "cost": 120, "Speed": 8}, {"name": "Diamond Boots", "description": "+12 Speeds", "cost": 230, "Speed": 12}, {"name": "Noble Boots", "description": "+19 Speeds", "cost": 450, "Speed": 19}, {"name": "Lizable Boots", "description": "+25 Speeds", "cost": 700, "Speed": 25} ], "Weapons None": [ {"name": "None", "description": "No Weapons Used", "cost" : 0, "Attack": 0} ], "Armors None": [ {"name": "None", "description": "Armors Used", "cost" : 0, "Attack": 0} ], "Shields None": [ {"name": "None", "description": "No Shields Used", "cost" : 0, "Attack": 0} ], "Footwear None": [ {"name": "None", "description": "No Footwears Used", "cost" : 0, "Attack": 0} ], } def create_character(): clear_screen() print("Character Creation") name = input("Enter your character's name: ") clear_screen() print(f"Character Name: {name}\n") while True: print("Select Difficulty:") print("1. Basic 🛡️") print("2. Exemplar ⚔️") print("3. Templar ☠️") difficulty_choice = input("Enter the number to select difficulty: ") if difficulty_choice == "1": difficulty = "Basic" description = "Enemies are powerful in their origins." elif difficulty_choice == "2": difficulty = "Exemplar" description = "Enemies are harder and more immortalized." elif difficulty_choice == "3": difficulty = "Templar" description = "Enemies are evils." else: print("Invalid difficulty choice. Please choose a valid option.") time.sleep(1) clear_screen() continue clear_screen() print("Selected Difficulty:") print(f"Name: {name}") print(f"Difficulty: {difficulty}") print(f"Description: {description}\n") print("1. Confirm") print("2. Back") confirm_choice = input("Enter your choice: ") if confirm_choice == "1": break elif confirm_choice == "2": clear_screen() continue else: print("Invalid choice. Please enter 1 to confirm or 2 to go back.") time.sleep(1) clear_screen() player = Player(name, difficulty) player.equipped_items["Weapons"] = {"name": "Broken Sword", "description": "+10 Damage", "attack": 10} player.equipped_items["Armors"] = {"name": "Broken Armor", "description": "+5 Defense", "defense": 5} player.equipped_items["Shields"] = {"name": "Broken Shield", "description": "+2 Dodge", "dodge": 2} player.equipped_items["Footwear"] = {"name": "Broken Footwear", "description": "+3 Speed", "speed": 3} return Player(name, difficulty) def clear_screen(): """Clears the console screen.""" os.system('cls' if os.name == 'nt' else 'clear') def main_menu(): clear_screen() print("BeaVenture\n") print("1. Create Character") print("2. Exit") print("\nEnter the number to select an option.") def main(): while True: main_menu() try: choice = int(input("")) if choice == 1: player = create_character() player.display_status() elif choice == 2: clear_screen() print("Exiting BeaVenture. Goodbye!") time.sleep(2) clear_screen() print("Game Was Ended") input("Press Enter to exit...") clear_screen() break else: print("Invalid option. Please enter a valid number.") time.sleep(2) except ValueError: print("Invalid input. Please enter a number.") if __name__ == "__main__": main()
import os import time import sys class Player: def __init__(self, name, difficulty): self.name = name self.difficulty = difficulty Attack = 0 Defense = 0 Dodge = 0 Speed = 0 self.gold = 10000 self.diamonds = 0 self.experience = 0 self.level = 1 self.exp_required = 100 self.exp_multiplier = 0.75 # 75% increase for experience requirement per level self.inventory = { # Initialize inventory "Weapons": [], "Armors": [], "Shields": [], "Footwear": [], "Usable Items": [] # Add Usable Items category } self.equipped_items = { # Initialize equipped items "Weapons": {"name": "Broken Sword", "description": "+10 Damage", "Attack": 10}, "Armors": {"name": "Broken Armor", "description": "+5 Defense", "Defense": 5}, "Shields": {"name": "Broken Shield", "description": "+2 Dodge", "Dodge": 2}, "Footwear": {"name": "Broken Footwear", "description": "+3 Speed", "Speed": 3}, "Accessories": None, "Bag": None } self.base_stats = { "HP": 100, "Defense": 0, "Attack": 0, "Dodge": 0, "Speed": 0 } self.max_inventory_slots = 30 self.update_stats() # Update player stats based on equipped items def visit_inventory(self): while True: os.system('cls' if os.name == 'nt' else 'clear') print("Inventory:") print("=" * 40) print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.display_items("Weapons") elif choice == "2": self.display_items("Armors") elif choice == "3": self.display_items("Shields") elif choice == "4": self.display_items("Footwear") elif choice == "5": self.display_items("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_items(self, item_type): while True: os.system('cls' if os.name == 'nt' else 'clear') print(f"{item_type}:") print("=" * 40) if self.inventory[item_type]: for idx, item in enumerate(self.inventory[item_type], 1): print(f"{idx}. {item['name']}: {item['description']}") print("0. Back to Inventory Menu") print("Enter the number to equip the item or 0 to go back.") choice = input("") if choice == "0": break # Break out of the inner loop to return to the previous menu elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]): self.equip_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) else: print("No items in this category.") print("Press < to go back") choice = input("") if choice == "<": break # Break out of the inner loop to return to the previous menu def equip_item(self, item_type, index): item = self.inventory[item_type].pop(index) if item_type in ["Weapons", "Armors", "Shields", "Footwear"]: self.remove_equipped_item(item_type) # Remove any previously equipped item of the same type self.equipped_items[item_type] = item # Equip the new item self.update_stats() # Update player stats with the new equipment print(f"{item['name']} equipped.") time.sleep(1) else: # Handle equipping usable items pass self.visit_inventory() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def update_stats(self): # Reset stats to base values for stat in self.base_stats: setattr(self, stat.lower(), self.base_stats[stat]) # Apply bonuses from equipped items equipped = False # Flag to track if any item is equipped for item_type, item in self.equipped_items.items(): if item: equipped = True self.when_equipped(item) # If no items are equipped, set all stats (except HP) to 0 if not equipped: for stat in self.base_stats: if stat != "HP": setattr(self, stat.lower(), 0) def when_equipped(self, item): for stat in item: if stat in self.base_stats: setattr(self, stat.lower(), self.base_stats[stat] + item[stat]) def display_equipped_items(self): os.system('cls' if os.name == 'nt' else 'clear') print("Equipped Items:") print("=" * 40) for item_type, item in self.equipped_items.items(): if item: print(f"{item_type}: {item['name']} - {item['description']}") else: print(f"{item_type}: None") def display_status(self): clear_screen() print("Player Status:") print("=" * 40) print(f"Name: {self.name}") print(f"Difficulty: {self.difficulty}") print("-" * 40) print("Stats:") print(f"HP :❤️{self.base_stats['HP']}") print(f"Defense :🛡️{self.defense}") print(f"Attack :⚔️{self.attack}") print(f"Dodge :🤺{self.dodge}") print(f"Speed :🏃{self.speed}") print("-"*40) print(f"Level: {self.level}") print(f"Experience: {self.experience}/{self.exp_required}") print("-"*40) print(f"Gold: {self.gold} 💰") print(f"Diamonds: {self.diamonds} 💎") print("="*40) print("Game Options:") print("1. Visit Shop") print("2. Inventory") print("3. Equipped Items") print("4. Play Game") print("5. Delete this Character") print("6. Add 50 Experience Points") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.visit_shop() elif choice == "2": self.visit_inventory() elif choice == "3": self.display_equipped_items() elif choice == "4": self.play_game() elif choice == "5": return elif choice == "6": self.add_experience(50) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_status() def calculate_stat(self, stat_name): base_stat = getattr(self, stat_name) bonus_stat = sum(item.get(stat_name, 0) for item in self.equipped_items.values() if item) return base_stat + bonus_stat def display_items(self, item_type): os.system('cls' if os.name == 'nt' else 'clear') print(f"{item_type}:") print("=" * 40) if self.inventory[item_type]: for idx, item in enumerate(self.inventory[item_type], 1): if item: # Check if item is not None print(f"{idx}. {item['name']}: {item['description']}") else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.visit_inventory() elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]): self.equip_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_items(item_type) else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.visit_inventory() else: print("Invalid option. Please enter < to go back.") time.sleep(1) self.visit_inventory() def equip_item(self, item_type, index): if item_type in self.equipped_items: if 0 <= index < len(self.inventory[item_type]): item = self.inventory[item_type].pop(index) if self.equipped_items[item_type]: old_item = self.equipped_items[item_type] self.inventory[item_type].append(old_item) self.equipped_items[item_type] = item self.update_stats() # Update stats after equipping any item print(f"{item['name']} equipped.") time.sleep(1) else: print("Invalid item index.") time.sleep(1) else: print("Invalid item type.") time.sleep(1) def apply_item_stats(self, item): if 'Attack' in item: self.attack += item['Attack'] if 'Defense' in item: self.defense += item['Defense'] if 'Dodge' in item: self.dodge += item['Dodge'] if 'Speed' in item: self.speed += item['Speed'] def unequip_item(self, item_type_to_swap): if self.equipped_items[item_type_to_swap]: self.swap_item(item_type_to_swap) else: print("No item equipped.") time.sleep(1) self.display_equipped_items() def unequip_menu(self, item_type_to_swap): os.system('cls' if os.name == 'nt' else 'clear') print(f"Swap {item_type_to_swap}:") print("=" * 40) if self.equipped_items[item_type_to_swap]: equipped_item = self.equipped_items[item_type_to_swap] if 'description' in equipped_item: print(f"1. {equipped_item['name']} - {equipped_item['description']}") else: print(f"1. {equipped_item['name']}") print("Enter 1 to swap or press < to cancel.") choice = input("") if choice == "1": self.swap_item(item_type_to_swap) elif choice == "<": self.display_equipped_items() else: print("Invalid option. Please enter a valid option.") time.sleep(1) self.unequip_menu(item_type_to_swap) else: print(f"No {item_type_to_swap} equipped.") time.sleep(1) self.display_equipped_items() def swap_item(self, item_type_to_swap): os.system('cls' if os.name == 'nt' else 'clear') print(f"Swap {item_type_to_swap}:") print("=" * 40) if self.inventory[item_type_to_swap]: for idx, item in enumerate(self.inventory[item_type_to_swap], 1): if item: # Check if item is not None print(f"{idx}. {item['name']}: {item['description']}") else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.unequip_menu(item_type_to_swap) elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type_to_swap]): self.equip_item(item_type_to_swap, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.swap_item(item_type_to_swap) else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.unequip_menu(item_type_to_swap) else: print("Invalid option. Please enter < to go back.") time.sleep(1) self.unequip_menu(item_type_to_swap) def display_equipped_items(self): clear_screen() print("Equipped Items:") print("=" * 40) for item_type, item in self.equipped_items.items(): if item: name = item.get('name', 'Unknown') description = item.get('description', 'No description') print(f"{item_type}: {name} - {description}") else: print(f"{item_type}: None") print("\nUnequip Items:") print("=" * 40) for i, (item_type, item) in enumerate(self.equipped_items.items(), start=1): if item: name = item.get('name', 'Unknown') description = item.get('description', 'No description') print(f"{i}. {item_type}: {name} - {description}") else: print(f"{i}. {item_type}: None") print("Press < to go back to the player status menu.") choice = input("") if choice == "<": self.display_status() elif choice.isdigit(): index = int(choice) - 1 if 0 <= index < len(self.equipped_items): item_type_to_unequip = list(self.equipped_items.keys())[index] self.unequip_menu(item_type_to_unequip) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_equipped_items() else: print("Invalid option. Please enter a valid option.") time.sleep(1) self.display_equipped_items() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def play_game(self): clear_screen() # Placeholder for play game functionality input("Play game functionality is under construction. Press Enter to return to the player status menu...") self.display_status() def add_experience(self, amount): self.experience += amount if self.experience >= self.exp_required: self.level_up() self.display_status() def level_up(self): self.level += 1 self.experience = 0 self.attack += 0.5 self.defense += 0.5 self.dodge += 0.5 self.speed += 0.5 self.exp_multiplier = 0.25 self.exp_required = int(self.exp_required * (1 + self.exp_multiplier)) # Update exp required with new multiplier def equip_item_level_up(self, item): if 'Attack' in item: self.attack += item['Attack'] if 'Defense' in item: self.defense += item['Defense'] if 'Dodge' in item: self.dodge += item['Dodge'] if 'Speed' in item: self.speed += item['Speed'] def get_name_display(self): symbol = "" if self.difficulty == "Basic": symbol = "🛡️" elif self.difficulty == "Exemplar": symbol = "⚔️" elif self.difficulty == "Templar": symbol = "☠️" return f"{symbol} {self.name}" def get_difficulty_display(self): return self.difficulty def visit_shop(self): clear_screen() while True: os.system('cls' if os.name == 'nt' else 'clear') print("Welcome to the Shop!") print("=" * 40) print("Shop Sections:") print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select a shop section.") choice = input("") if choice == "1": self.display_shop_section("Weapons") elif choice == "2": self.display_shop_section("Armors") elif choice == "3": self.display_shop_section("Shields") elif choice == "4": self.display_shop_section("Footwear") elif choice == "5": self.display_shop_section("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_shop_section(self, item_type): os.system('cls' if os.name == 'nt' else 'clear') print(f"Shop - {item_type}:") print("=" * 40) if item_type in items_groups: for idx, item in enumerate(items_groups[item_type], 1): print(f"{idx}. {item['name']}: {item['description']} - Cost: {item['cost']} gold") print("0. Back to Shop Sections") print("Enter the number to purchase the item or 0 to go back.") choice = input("") if choice == "0": self.visit_shop() elif choice.isdigit() and 0 < int(choice) <= len(items_groups[item_type]): self.purchase_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_shop_section(item_type) else: print("Invalid shop section.") time.sleep(1) self.visit_shop() def purchase_item(self, item_type, index): item = items_groups[item_type][index] cost = item['cost'] if self.gold >= cost: self.gold -= cost self.inventory[item_type].append(item) print(f"You have purchased {item['name']} for {cost} gold.") time.sleep(1) else: print("Insufficient gold to purchase this item.") time.sleep(1) self.display_shop_section(item_type) items_groups = { "Usable Items": [ {"name": "Small Healing Potion", "description": "+15 hp", "cost": 20}, {"name": "Self Healing Potion", "description": "+20 hp", "cost": 50}, {"name": "Moderated Potion", "description": "+25 hp", "cost": 75}, {"name": "Regen Potion", "description": "+15%", "cost": 100}, {"name": "Hammerhead Crocker", "description": "+7% attack for 7 turns", "cost": 55, "Attack": 0.07}, {"name": "Warhammer Crocker", "description": "+15% attack for 7 turns", "cost": 75, "Attack": 0.15}, {"name": "Barhog", "description": "+7% Defense for 7 turns", "cost": 45, "Defense": 0.07}, {"name": "Warhog", "description": "+15% defense for 7 turns", "cost": 60, "Defense": 0.15}, {"name": "Non applicable scroll", "description": "+2 Speed for 7 turns", "cost": 40, "Speed": 2}, {"name": "Applicable scroll", "description": "+4 speed for 7 turns", "cost": 55, "Speed": 4}, {"name": "Ransacked Shield", "description": "+12% Dodge chance for 3 turns", "cost": 60, "Dodge": 0.12}, {"name": "Unbuilded Shield", "description": "+23% Dodge Chance for 5 turns", "cost": 90, "Dodge": 0.23}, {"name": "Mystic Scroll", "description": "25% chance to negate all debuffs on player for 4 turns", "cost": 60}, {"name": "Mystic Beurau", "description": "50% chance to negate all debuffs on player for 4 turns", "cost": 120}, {"name": "Variant Bs", "description": "Increase all stats up to 25% for 10 turns", "cost": 200}, {"name": "Variant Ex", "description": "Increase all stats up to 50% for 10 turns", "cost": 400}, {"name": "Hide cloak", "description": "40% chance to dodge the battle against enemies when exploring", "cost": 50, "Dodge": 0.4}, {"name": "Invisible potion", "description": "60% chance to dodge the battle against enemies when exploring", "cost": 75, "Dodge": 0.6}, {"name": "Exp Moneter", "description": "Give you 20 exp points", "cost": 50}, {"name": "Exp Vitalis", "description": "Give you 50 exp points", "cost": 100}, {"name": "Exp For enhancer", "description": "Give you 100 points", "cost": 150} ], "Weapons": [ {"name": "Stone Sword", "description": "+12 attack", "cost": 150, "Attack": 12}, {"name": "Copper Sword", "description": "+15 attack", "cost": 275, "Attack": 15}, {"name": "Sickanum Sword", "description": "+17 attack", "cost": 400, "Attack": 17}, {"name": "Arivanum Sword", "description": "+23 attack", "cost": 600, "Attack": 23}, {"name": "Viranium Sword", "description": "+25 attack", "cost": 850, "Attack": 25}, {"name": "Titanium sword", "description": "+35 attack", "cost": 1250, "Attack": 35} ], "Armors": [ {"name": "Jungle sets", "description": "+7 Defense", "cost": 90, "Defense": 7}, {"name": "Byzantine sets", "description": "+12 Defense", "cost": 140, "Defense": 12}, {"name": "Nikel Sets", "description": "+15 Defense", "cost": 350, "Defense": 15}, {"name": "Warhead Sets", "description": "+25 Defense", "cost": 560, "Defense": 25}, {"name": "Titanium Sets", "description": "+40 Defense", "cost": 850, "Defense": 40} ], "Shields": [ {"name": "Wooden Ob", "description": "+2 dodge", "cost": 80, "Dodge": 2}, {"name": "Long Ob", "description": "+3 dodge, +2 Defense", "cost": 120, "Dodge": 3, "Defense": 2}, {"name": "Cob Ob", "description": "+5 dodge, +4 Defense", "cost": 300, "Dodge": 5, "Defense": 4}, {"name": "Knock Ob", "description": "+7 dodge, +5 Defense, +3 Attack", "cost": 550, "Dodge": 7, "Defense": 5, "Attack": 3}, {"name": "Neb Ob", "description": "+12 dodge, +7 Defense, +5 Attack", "cost": 760, "Dodge": 12, "Defense": 7, "Attack": 5} ], "Footwear": [ {"name": "Jungle Foot", "description": "+3 speeds", "cost": 45, "Speed": 3}, {"name": "Iron Foot", "description": "+5 Speed", "cost": 75, "Speed": 5}, {"name": "Metal WarFoot", "description": "+8 Speeds", "cost": 120, "Speed": 8}, {"name": "Diamond Boots", "description": "+12 Speeds", "cost": 230, "Speed": 12}, {"name": "Noble Boots", "description": "+19 Speeds", "cost": 450, "Speed": 19}, {"name": "Lizable Boots", "description": "+25 Speeds", "cost": 700, "Speed": 25} ], "Weapons None": [ {"name": "None", "description": "No Weapons Used", "cost" : 0, "Attack": 0} ], "Armors None": [ {"name": "None", "description": "Armors Used", "cost" : 0, "Attack": 0} ], "Shields None": [ {"name": "None", "description": "No Shields Used", "cost" : 0, "Attack": 0} ], "Footwear None": [ {"name": "None", "description": "No Footwears Used", "cost" : 0, "Attack": 0} ], } def create_character(): clear_screen() print("Character Creation") name = input("Enter your character's name: ") clear_screen() print(f"Character Name: {name}\n") while True: print("Select Difficulty:") print("1. Basic 🛡️") print("2. Exemplar ⚔️") print("3. Templar ☠️") difficulty_choice = input("Enter the number to select difficulty: ") if difficulty_choice == "1": difficulty = "Basic" description = "Enemies are powerful in their origins." elif difficulty_choice == "2": difficulty = "Exemplar" description = "Enemies are harder and more immortalized." elif difficulty_choice == "3": difficulty = "Templar" description = "Enemies are evils." else: print("Invalid difficulty choice. Please choose a valid option.") time.sleep(1) clear_screen() continue clear_screen() print("Selected Difficulty:") print(f"Name: {name}") print(f"Difficulty: {difficulty}") print(f"Description: {description}\n") print("1. Confirm") print("2. Back") confirm_choice = input("Enter your choice: ") if confirm_choice == "1": break elif confirm_choice == "2": clear_screen() continue else: print("Invalid choice. Please enter 1 to confirm or 2 to go back.") time.sleep(1) clear_screen() player = Player(name, difficulty) player.equipped_items["Weapons"] = {"name": "Broken Sword", "description": "+10 Damage", "attack": 10} player.equipped_items["Armors"] = {"name": "Broken Armor", "description": "+5 Defense", "defense": 5} player.equipped_items["Shields"] = {"name": "Broken Shield", "description": "+2 Dodge", "dodge": 2} player.equipped_items["Footwear"] = {"name": "Broken Footwear", "description": "+3 Speed", "speed": 3} return Player(name, difficulty) def clear_screen(): """Clears the console screen.""" os.system('cls' if os.name == 'nt' else 'clear') def main_menu(): clear_screen() print("BeaVenture\n") print("1. Create Character") print("2. Exit") print("\nEnter the number to select an option.") def main(): while True: main_menu() try: choice = int(input("")) if choice == 1: player = create_character() player.display_status() elif choice == 2: clear_screen() print("Exiting BeaVenture. Goodbye!") time.sleep(2) clear_screen() print("Game Was Ended") input("Press Enter to exit...") clear_screen() break else: print("Invalid option. Please enter a valid number.") time.sleep(2) except ValueError: print("Invalid input. Please enter a number.") if __name__ == "__main__": main()
import os import time import sys class Player: def __init__(self, name, difficulty): self.name = name self.difficulty = difficulty self.attack = 0 self.defense = 0 self.dodge = 0 self.speed = 0 self.gold = 0 self.diamonds = 0 self.experience = 0 self.level = 1 self.exp_required = 100 self.exp_multiplier = 0.75 # 75% increase for experience requirement per level self.inventory = { # Initialize inventory "Weapons": [], "Armors": [], "Shields": [], "Footwear": [], "Usable Items": [] # Add Usable Items category } self.equipped_items = { # Initialize equipped items "Weapons": {"name": "Broken Sword", "description": "+10 Damage", "Attack": 10}, "Armors": {"name": "Broken Armor", "description": "+5 Defense", "Defense": 5}, "Shields": {"name": "Broken Shield", "description": "+2 Dodge", "Dodge": 2}, "Footwear": {"name": "Broken Footwear", "description": "+3 Speed", "Speed": 3}, "Accessories": None, "Bag": None } self.base_stats = { "HP": 100, "Defense": 0, "Attack": 0, "Dodge": 0, "Speed": 0 } self.max_inventory_slots = 30 self.update_stats() # Update player stats based on equipped items def visit_inventory(self): while True: os.system('cls' if os.name == 'nt' else 'clear') print("Inventory:") print("=" * 40) print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.display_items("Weapons") elif choice == "2": self.display_items("Armors") elif choice == "3": self.display_items("Shields") elif choice == "4": self.display_items("Footwear") elif choice == "5": self.display_items("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_items(self, item_type): while True: os.system('cls' if os.name == 'nt' else 'clear') print(f"{item_type}:") print("=" * 40) if self.inventory[item_type]: for idx, item in enumerate(self.inventory[item_type], 1): print(f"{idx}. {item['name']}: {item['description']}") print("0. Back to Inventory Menu") print("Enter the number to equip the item or 0 to go back.") choice = input("") if choice == "0": break # Break out of the inner loop to return to the previous menu elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]): self.equip_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) else: print("No items in this category.") print("Press < to go back") choice = input("") if choice == "<": break # Break out of the inner loop to return to the previous menu def equip_item(self, item_type, index): item = self.inventory[item_type].pop(index) if item_type in ["Weapons", "Armors", "Shields", "Footwear"]: self.remove_equipped_item(item_type) # Remove any previously equipped item of the same type self.equipped_items[item_type] = item # Equip the new item self.update_stats() # Update player stats with the new equipment print(f"{item['name']} equipped.") time.sleep(1) else: # Handle equipping usable items pass self.visit_inventory() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def update_stats(self): # Reset stats to base values for stat in self.base_stats: setattr(self, stat.lower(), self.base_stats[stat]) # Apply bonuses from equipped items equipped = False # Flag to track if any item is equipped for item_type, item in self.equipped_items.items(): if item: equipped = True self.when_equipped(item) # If no items are equipped, set all stats (except HP) to 0 if not equipped: for stat in self.base_stats: if stat != "HP": setattr(self, stat.lower(), 0) def when_equipped(self, item): for stat in item: if stat in self.base_stats: setattr(self, stat.lower(), self.base_stats[stat] + item[stat]) def display_equipped_items(self): os.system('cls' if os.name == 'nt' else 'clear') print("Equipped Items:") print("=" * 40) for item_type, item in self.equipped_items.items(): if item: print(f"{item_type}: {item['name']} - {item['description']}") else: print(f"{item_type}: None") def display_status(self): clear_screen() print("Player Status:") print("=" * 40) print(f"Name: {self.name}") print(f"Difficulty: {self.difficulty}") print("-" * 40) print("Stats:") print(f"HP :❤️{self.base_stats['HP']}") print(f"Defense :🛡️{self.defense}") print(f"Attack :⚔️{self.attack}") print(f"Dodge :🤺{self.dodge}") print(f"Speed :🏃{self.speed}") print("-"*40) print(f"Level: {self.level}") print(f"Experience: {self.experience}/{self.exp_required}") print("-"*40) print(f"Gold: {self.gold} 💰") print(f"Diamonds: {self.diamonds} 💎") print("="*40) print("Game Options:") print("1. Visit Shop") print("2. Inventory") print("3. Equipped Items") print("4. Play Game") print("5. Delete this Character") print("6. Add 50 Experience Points") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.visit_shop() elif choice == "2": self.visit_inventory() elif choice == "3": self.display_equipped_items() elif choice == "4": self.play_game() elif choice == "5": return elif choice == "6": self.add_experience(50) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_status() def calculate_stat(self, stat_name): base_stat = getattr(self, stat_name) bonus_stat = sum(item.get(stat_name, 0) for item in self.equipped_items.values() if item) return base_stat + bonus_stat def display_items(self, item_type): os.system('cls' if os.name == 'nt' else 'clear') print(f"{item_type}:") print("=" * 40) if self.inventory[item_type]: for idx, item in enumerate(self.inventory[item_type], 1): if item: # Check if item is not None print(f"{idx}. {item['name']}: {item['description']}") else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.visit_inventory() elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]): self.equip_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_items(item_type) else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.visit_inventory() else: print("Invalid option. Please enter < to go back.") time.sleep(1) self.visit_inventory() def equip_item(self, item_type, index): if item_type in self.equipped_items: if 0 <= index < len(self.inventory[item_type]): item = self.inventory[item_type].pop(index) if self.equipped_items[item_type]: old_item = self.equipped_items[item_type] self.inventory[item_type].append(old_item) self.equipped_items[item_type] = item self.update_stats() # Update stats after equipping any item print(f"{item['name']} equipped.") time.sleep(1) else: print("Invalid item index.") time.sleep(1) else: print("Invalid item type.") time.sleep(1) def apply_item_stats(self, item): if 'Attack' in item: self.attack += item['Attack'] if 'Defense' in item: self.defense += item['Defense'] if 'Dodge' in item: self.dodge += item['Dodge'] if 'Speed' in item: self.speed += item['Speed'] def unequip_item(self, item_type_to_unequip): if self.equipped_items[item_type_to_unequip]: self.inventory[item_type_to_unequip].append(self.equipped_items[item_type_to_unequip]) self.equipped_items[item_type_to_unequip] = None print(f"{item_type_to_unequip}: None") time.sleep(1) self.unequip_menu(item_type_to_unequip) else: print("No item equipped.") time.sleep(1) self.display_equipped_items() def unequip_menu(self, item_type_to_unequip): os.system('cls' if os.name == 'nt' else 'clear') print(f"Unequip {item_type_to_unequip}:") print("=" * 40) if self.equipped_items[item_type_to_unequip]: print(f"1. {self.equipped_items[item_type_to_unequip]['name']} - {self.equipped_items[item_type_to_unequip]['description']}") print("Enter 1 to unequip or press < to cancel.") choice = input("") if choice == "1": self.unequip_item(item_type_to_unequip) elif choice == "<": self.display_equipped_items() else: print("Invalid option. Please enter a valid option.") time.sleep(1) self.unequip_menu(item_type_to_unequip) else: print(f"No {item_type_to_unequip} equipped.") time.sleep(1) self.display_equipped_items() def display_equipped_items(self): clear_screen() print("Equipped Items:") print("=" * 40) for item_type, item in self.equipped_items.items(): if item: print(f"{item_type}: {item['name']} - {item['description']}") else: print(f"{item_type}: None") print("\nUnequip Items:") print("=" * 40) for i, (item_type, item) in enumerate(self.equipped_items.items(), start=1): if item: print(f"{i}. {item_type}: {item['name']} - {item['description']}") else: print(f"{i}. {item_type}: None") print("Press < to go back to the player status menu.") choice = input("") if choice == "<": self.display_status() elif choice.isdigit(): index = int(choice) - 1 if 0 <= index < len(self.equipped_items): item_type_to_unequip = list(self.equipped_items.keys())[index] self.unequip_menu(item_type_to_unequip) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_equipped_items() else: print("Invalid option. Please enter a valid option.") time.sleep(1) self.display_equipped_items() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def play_game(self): clear_screen() # Placeholder for play game functionality input("Play game functionality is under construction. Press Enter to return to the player status menu...") self.display_status() def add_experience(self, amount): self.experience += amount if self.experience >= self.exp_required: self.level_up() self.display_status() def level_up(self): self.level += 1 self.experience = 0 self.attack += 0.5 self.defense += 0.5 self.dodge += 0.5 self.speed += 0.5 self.exp_multiplier = 0.25 self.exp_required = int(self.exp_required * (1 + self.exp_multiplier)) # Update exp required with new multiplier def equip_item_level_up(self, item): if 'Attack' in item: self.attack += item['Attack'] if 'Defense' in item: self.defense += item['Defense'] if 'Dodge' in item: self.dodge += item['Dodge'] if 'Speed' in item: self.speed += item['Speed'] def get_name_display(self): symbol = "" if self.difficulty == "Basic": symbol = "🛡️" elif self.difficulty == "Exemplar": symbol = "⚔️" elif self.difficulty == "Templar": symbol = "☠️" return f"{symbol} {self.name}" def get_difficulty_display(self): return self.difficulty def visit_shop(self): clear_screen() while True: os.system('cls' if os.name == 'nt' else 'clear') print("Welcome to the Shop!") print("=" * 40) print("Shop Sections:") print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select a shop section.") choice = input("") if choice == "1": self.display_shop_section("Weapons") elif choice == "2": self.display_shop_section("Armors") elif choice == "3": self.display_shop_section("Shields") elif choice == "4": self.display_shop_section("Footwear") elif choice == "5": self.display_shop_section("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_shop_section(self, item_type): os.system('cls' if os.name == 'nt' else 'clear') print(f"Shop - {item_type}:") print("=" * 40) if item_type in items_groups: for idx, item in enumerate(items_groups[item_type], 1): print(f"{idx}. {item['name']}: {item['description']} - Cost: {item['cost']} gold") print("0. Back to Shop Sections") print("Enter the number to purchase the item or 0 to go back.") choice = input("") if choice == "0": self.visit_shop() elif choice.isdigit() and 0 < int(choice) <= len(items_groups[item_type]): self.purchase_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_shop_section(item_type) else: print("Invalid shop section.") time.sleep(1) self.visit_shop() def purchase_item(self, item_type, index): item = items_groups[item_type][index] cost = item['cost'] if self.gold >= cost: self.gold -= cost self.inventory[item_type].append(item) print(f"You have purchased {item['name']} for {cost} gold.") time.sleep(1) else: print("Insufficient gold to purchase this item.") time.sleep(1) self.display_shop_section(item_type) items_groups = { "Usable Items": [ {"name": "Small Healing Potion", "description": "+15 hp", "cost": 20}, {"name": "Self Healing Potion", "description": "+20 hp", "cost": 50}, {"name": "Moderated Potion", "description": "+25 hp", "cost": 75}, {"name": "Regen Potion", "description": "+15%", "cost": 100}, {"name": "Hammerhead Crocker", "description": "+7% attack for 7 turns", "cost": 55, "Attack": 0.07}, {"name": "Warhammer Crocker", "description": "+15% attack for 7 turns", "cost": 75, "Attack": 0.15}, {"name": "Barhog", "description": "+7% Defense for 7 turns", "cost": 45, "Defense": 0.07}, {"name": "Warhog", "description": "+15% defense for 7 turns", "cost": 60, "Defense": 0.15}, {"name": "Non applicable scroll", "description": "+2 Speed for 7 turns", "cost": 40, "Speed": 2}, {"name": "Applicable scroll", "description": "+4 speed for 7 turns", "cost": 55, "Speed": 4}, {"name": "Ransacked Shield", "description": "+12% Dodge chance for 3 turns", "cost": 60, "Dodge": 0.12}, {"name": "Unbuilded Shield", "description": "+23% Dodge Chance for 5 turns", "cost": 90, "Dodge": 0.23}, {"name": "Mystic Scroll", "description": "25% chance to negate all debuffs on player for 4 turns", "cost": 60}, {"name": "Mystic Beurau", "description": "50% chance to negate all debuffs on player for 4 turns", "cost": 120}, {"name": "Variant Bs", "description": "Increase all stats up to 25% for 10 turns", "cost": 200}, {"name": "Variant Ex", "description": "Increase all stats up to 50% for 10 turns", "cost": 400}, {"name": "Hide cloak", "description": "40% chance to dodge the battle against enemies when exploring", "cost": 50, "Dodge": 0.4}, {"name": "Invisible potion", "description": "60% chance to dodge the battle against enemies when exploring", "cost": 75, "Dodge": 0.6}, {"name": "Exp Moneter", "description": "Give you 20 exp points", "cost": 50}, {"name": "Exp Vitalis", "description": "Give you 50 exp points", "cost": 100}, {"name": "Exp For enhancer", "description": "Give you 100 points", "cost": 150} ], "Weapons": [ {"name": "Stone Sword", "description": "+12 attack", "cost": 150, "Attack": 12}, {"name": "Copper Sword", "description": "+15 attack", "cost": 275, "Attack": 15}, {"name": "Sickanum Sword", "description": "+17 attack", "cost": 400, "Attack": 17}, {"name": "Arivanum Sword", "description": "+23 attack", "cost": 600, "Attack": 23}, {"name": "Viranium Sword", "description": "+25 attack", "cost": 850, "Attack": 25}, {"name": "Titanium sword", "description": "+35 attack", "cost": 1250, "Attack": 35} ], "Armors": [ {"name": "Jungle sets", "description": "+7 Defense", "cost": 90, "Defense": 7}, {"name": "Byzantine sets", "description": "+12 Defense", "cost": 140, "Defense": 12}, {"name": "Nikel Sets", "description": "+15 Defense", "cost": 350, "Defense": 15}, {"name": "Warhead Sets", "description": "+25 Defense", "cost": 560, "Defense": 25}, {"name": "Titanium Sets", "description": "+40 Defense", "cost": 850, "Defense": 40} ], "Shields": [ {"name": "Wooden Ob", "description": "+2 dodge", "cost": 80, "Dodge": 2}, {"name": "Long Ob", "description": "+3 dodge, +2 Defense", "cost": 120, "Dodge": 3, "Defense": 2}, {"name": "Cob Ob", "description": "+5 dodge, +4 Defense", "cost": 300, "Dodge": 5, "Defense": 4}, {"name": "Knock Ob", "description": "+7 dodge, +5 Defense, +3 Attack", "cost": 550, "Dodge": 7, "Defense": 5, "Attack": 3}, {"name": "Neb Ob", "description": "+12 dodge, +7 Defense, +5 Attack", "cost": 760, "Dodge": 12, "Defense": 7, "Attack": 5} ], "Footwear": [ {"name": "Jungle Foot", "description": "+3 speeds", "cost": 45, "Speed": 3}, {"name": "Iron Foot", "description": "+5 Speed", "cost": 75, "Speed": 5}, {"name": "Metal WarFoot", "description": "+8 Speeds", "cost": 120, "Speed": 8}, {"name": "Diamond Boots", "description": "+12 Speeds", "cost": 230, "Speed": 12}, {"name": "Noble Boots", "description": "+19 Speeds", "cost": 450, "Speed": 19}, {"name": "Lizable Boots", "description": "+25 Speeds", "cost": 700, "Speed": 25} ] } def create_character(): clear_screen() print("Character Creation") name = input("Enter your character's name: ") clear_screen() print(f"Character Name: {name}\n") while True: print("Select Difficulty:") print("1. Basic 🛡️") print("2. Exemplar ⚔️") print("3. Templar ☠️") difficulty_choice = input("Enter the number to select difficulty: ") if difficulty_choice == "1": difficulty = "Basic" description = "Enemies are powerful in their origins." elif difficulty_choice == "2": difficulty = "Exemplar" description = "Enemies are harder and more immortalized." elif difficulty_choice == "3": difficulty = "Templar" description = "Enemies are evils." else: print("Invalid difficulty choice. Please choose a valid option.") time.sleep(1) clear_screen() continue clear_screen() print("Selected Difficulty:") print(f"Name: {name}") print(f"Difficulty: {difficulty}") print(f"Description: {description}\n") print("1. Confirm") print("2. Back") confirm_choice = input("Enter your choice: ") if confirm_choice == "1": break elif confirm_choice == "2": clear_screen() continue else: print("Invalid choice. Please enter 1 to confirm or 2 to go back.") time.sleep(1) clear_screen() player = Player(name, difficulty) player.equipped_items["Weapons"] = {"name": "Broken Sword", "description": "+10 Damage", "attack": 10} player.equipped_items["Armors"] = {"name": "Broken Armor", "description": "+5 Defense", "defense": 5} player.equipped_items["Shields"] = {"name": "Broken Shield", "description": "+2 Dodge", "dodge": 2} player.equipped_items["Footwear"] = {"name": "Broken Footwear", "description": "+3 Speed", "speed": 3} return Player(name, difficulty) def clear_screen(): """Clears the console screen.""" os.system('cls' if os.name == 'nt' else 'clear') def main_menu(): clear_screen() print("BeaVenture\n") print("1. Create Character") print("2. Exit") print("\nEnter the number to select an option.") def main(): while True: main_menu() try: choice = int(input("")) if choice == 1: player = create_character() player.display_status() elif choice == 2: clear_screen() print("Exiting BeaVenture. Goodbye!") time.sleep(2) clear_screen() print("Game Was Ended") input("Press Enter to exit...") clear_screen() break else: print("Invalid option. Please enter a valid number.") time.sleep(2) except ValueError: print("Invalid input. Please enter a number.") if __name__ == "__main__": main()
/*! * Color mode toggler for Bootstrap's docs (https://getbootstrap.com/) * Copyright 2011-2023 The Bootstrap Authors * Licensed under the Creative Commons Attribution 3.0 Unported License. */ (() => { 'use strict'; const storedTheme = localStorage.getItem('theme'); const getPreferredTheme = () => { if (storedTheme) { return storedTheme; } return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'; }; const setTheme = function (theme) { if ( theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches ) { document.documentElement.setAttribute('data-bs-theme', 'dark'); } else { document.documentElement.setAttribute('data-bs-theme', theme); } }; setTheme(getPreferredTheme()); const showActiveTheme = (theme, focus = false) => { const themeSwitcher = document.querySelector('#bd-theme'); if (!themeSwitcher) { return; } const themeSwitcherText = document.querySelector('#bd-theme-text'); const activeThemeIcon = document.querySelector('.theme-icon-active use'); const btnToActive = document.querySelector( `[data-bs-theme-value="${theme}"]` ); const svgOfActiveBtn = btnToActive .querySelector('svg use') .getAttribute('href'); document.querySelectorAll('[data-bs-theme-value]').forEach((element) => { element.classList.remove('active'); element.setAttribute('aria-pressed', 'false'); }); btnToActive.classList.add('active'); btnToActive.setAttribute('aria-pressed', 'true'); activeThemeIcon.setAttribute('href', svgOfActiveBtn); const themeSwitcherLabel = `${themeSwitcherText.textContent} (${btnToActive.dataset.bsThemeValue})`; themeSwitcher.setAttribute('aria-label', themeSwitcherLabel); if (focus) { themeSwitcher.focus(); } }; window .matchMedia('(prefers-color-scheme: dark)') .addEventListener('change', () => { if (storedTheme !== 'light' || storedTheme !== 'dark') { setTheme(getPreferredTheme()); } }); window.addEventListener('DOMContentLoaded', () => { showActiveTheme(getPreferredTheme()); document.querySelectorAll('[data-bs-theme-value]').forEach((toggle) => { toggle.addEventListener('click', () => { const theme = toggle.getAttribute('data-bs-theme-value'); localStorage.setItem('theme', theme); setTheme(theme); showActiveTheme(theme, true); }); }); }); })();
<div id="carouselExampleControls" class="carousel slide" data-bs-ride="carousel"> <div class="carousel-inner"> <div class="carousel-item active"> <img src="..." class="d-block w-100" alt="..."> </div> <div class="carousel-item"> <img src="..." class="d-block w-100" alt="..."> </div> <div class="carousel-item"> <img src="..." class="d-block w-100" alt="..."> </div> </div> <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="prev"> <span class="carousel-control-prev-icon" aria-hidden="true"></span> <span class="visually-hidden">Previous</span> </button> <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="next"> <span class="carousel-control-next-icon" aria-hidden="true"></span> <span class="visually-hidden">Next</span> </button> </div>
<!-- Navbar --> <nav class="navbar navbar-expand-lg bg-light navbar-light"> <!-- Container wrapper --> <div class="container-fluid"> <!-- Navbar brand --> <a class="navbar-brand" href="#">Brand</a> <!-- Toggle button --> <button class="navbar-toggler" type="button" data-mdb-toggle="collapse" data-mdb-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation" > <i class="fas fa-bars"></i> </button> <!-- Collapsible wrapper --> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav me-auto mb-2 mb-lg-0"> <!-- Link --> <li class="nav-item"><a class="nav-link" href="#">Link</a></li> <!-- Dropdown --> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-mdb-toggle="dropdown" aria-expanded="false" > Dropdown </a> <ul class="dropdown-menu" aria-labelledby="navbarDropdown"> <li><a class="dropdown-item" href="#">Action</a></li> <li><a class="dropdown-item" href="#">Another action</a></li> <li><hr class="dropdown-divider" /></li> <li><a class="dropdown-item" href="#">Something else here</a></li> </ul> </li> </ul> <!-- Icons --> <ul class="navbar-nav d-flex flex-row me-1"> <li class="nav-item me-3 me-lg-0"> <a class="nav-link" href="#"><i class="fas fa-shopping-cart"></i></a> </li> <li class="nav-item me-3 me-lg-0"> <a class="nav-link" href="#"><i class="fab fa-twitter"></i></a> </li> </ul> <!-- Search --> <form class="w-auto"> <input type="search" class="form-control" placeholder="Type query" aria-label="Search" /> </form> </div> </div> <!-- Container wrapper --> </nav> <!-- Navbar -->
“I want you to write a [NUMBER]-word [WRITING TYPE] about [THIS SPECIFIC TOPIC] for me, written in a tone that is [DESCRIBE TONE]. The text should be tailored to [SPECIFIC TARGET READER, GIVE CONTEXT]. It should be formatted with [PROVIDE FORMATTING INSTRUCTIONS] Like this: [EXAMPLE FORMAT] The purpose of this text is to [WHAT THE TARGET OUTCOME IS FOR YOU]. For context, I am a [WHAT YOU DO, GIVE CONTEXT] looking to [YOUR GOAL].”
<p>Copyright © <script>document.write(new Date().getFullYear())</script> Your Name All Rights Reserved</p>
curl --request POST \ --url 'https://api.apyhub.com/convert/word-file/pdf-file?output=test-sample.pdf&landscape=false' \ --header 'apy-token: APY0BOODK2plpXgxRjezmBOXqID51DGpFq8QnHJeBQrrzuIBc25UIglN93bbwvnkBWlUia1' \ --header 'content-type: multipart/form-data' \ --form 'file=@"test.doc"'
<div class="text-center"> <img src="..." class="rounded" alt="..."> </div>
/* * This Java source file was generated by the Gradle 'init' task. */ package gradleproject2; import java.io.IOException; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.PDPageContentStream; import org.apache.pdfbox.pdmodel.font.PDType1Font; import org.apache.pdfbox.pdmodel.font.Standard14Fonts; public class App { public String getGreeting() { return "Hello World!"; } public static void main(String[] args) throws IOException { // System.out.println(new App().getGreeting()); //Creating PDF document object PDDocument document = new PDDocument(); for (int i = 0; i < 10; i++) { //Creating a blank page PDPage blankPage = new PDPage(); PDPageContentStream contentStream = new PDPageContentStream(document, blankPage); contentStream.setFont(new PDType1Font(Standard14Fonts.FontName.HELVETICA_BOLD), 12); // Add text to the page contentStream.beginText(); contentStream.newLineAtOffset(100, 700); contentStream.showText("Hello World, how are you !"); contentStream.endText(); //Adding the blank page to the document document.addPage(blankPage); contentStream.close(); } //Saving the document document.save("C:/Users/chachou/Desktop/test java/javageneratepdf.pdf"); System.out.println("PDF created"); //Closing the document document.close(); } }
import os import time import sys class Player: def __init__(self, name, difficulty): self.name = name self.difficulty = difficulty self.attack = 10 self.defense = 5 self.dodge = 2 self.speed = 3 self.gold = 100 self.diamonds = 0 self.experience = 0 self.level = 1 self.exp_required = 100 self.exp_multiplier = 0.75 # 75% increase for experience requirement per level self.inventory = { # Initialize inventory "Weapons": [], "Armors": [], "Shields": [], "Footwear": [], "Usable Items": [] # Add Usable Items category } self.equipped_items = { # Initialize equipped items "Weapons": {"name": "Broken Sword", "description": "+10 Damage", "attack": 10}, "Armors": {"name": "Broken Armor", "description": "+5 Defense", "defense": 5}, "Shields": {"name": "Broken Shield", "description": "+2 Dodge", "dodge": 2}, "Footwear": {"name": "Broken Footwear", "description": "+3 Speed", "speed": 3}, "Accessories": None, "Bag": None } self.base_stats = { "HP": 100, "Defense": 0, "Attack": 0, "Dodge": 0, "Speed": 0 } self.max_inventory_slots = 30 self.update_stats() # Update player stats based on equipped items def visit_inventory(self): while True: os.system('cls' if os.name == 'nt' else 'clear') print("Inventory:") print("=" * 40) print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.display_items("Weapons") elif choice == "2": self.display_items("Armors") elif choice == "3": self.display_items("Shields") elif choice == "4": self.display_items("Footwear") elif choice == "5": self.display_items("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_items(self, item_type): while True: os.system('cls' if os.name == 'nt' else 'clear') print(f"{item_type}:") print("=" * 40) if self.inventory[item_type]: for idx, item in enumerate(self.inventory[item_type], 1): print(f"{idx}. {item['name']}: {item['description']}") print("0. Back to Inventory Menu") print("Enter the number to equip the item or 0 to go back.") choice = input("") if choice == "0": break # Break out of the inner loop to return to the previous menu elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]): self.equip_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) else: print("No items in this category.") print("Press < to go back") choice = input("") if choice == "<": break # Break out of the inner loop to return to the previous menu def equip_item(self, item_type, index): item = self.inventory[item_type].pop(index) if item_type in ["Weapons", "Armors", "Shields", "Footwear"]: self.remove_equipped_item(item_type) # Remove any previously equipped item of the same type self.equipped_items[item_type] = item # Equip the new item self.update_stats() # Update player stats with the new equipment print(f"{item['name']} equipped.") time.sleep(1) else: # Handle equipping usable items pass self.visit_inventory() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def update_stats(self): # Reset stats to base values for stat in self.base_stats: setattr(self, stat.lower(), self.base_stats[stat]) # Add bonuses from equipped items for item_type, item in self.equipped_items.items(): if item: for stat in item: if stat in self.base_stats: setattr(self, stat.lower(), self.base_stats[stat] + item[stat]) def display_equipped_items(self): os.system('cls' if os.name == 'nt' else 'clear') print("Equipped Items:") print("=" * 40) for item_type, item in self.equipped_items.items(): if item: print(f"{item_type}: {item['name']} - {item['description']}") else: print(f"{item_type}: None") # Add option to unequip items print("Press u to unequip.") choice = input("") if choice == "u": self.unequip_menu() elif choice == "<": self.display_status() else: print("Invalid option. Please enter u to unequip or < to go back.") time.sleep(1) self.display_equipped_items() def display_status(self): print("Player Status:") print("=" * 40) print(f"Name: {self.name}") print(f"Difficulty: {self.difficulty}") print("-" * 40) print("Stats:") print(f"HP :❤️{self.base_stats['HP']}") print(f"Defense :🛡️{self.defense}") print(f"Attack :⚔️{self.attack}") print(f"Dodge :🤺{self.dodge}") print(f"Speed :🏃{self.speed}") print("-"*40) print(f"Level: {self.level}") print(f"Experience: {self.experience}/{self.exp_required}") print("-"*40) print(f"Gold: {self.gold} 💰") print(f"Diamonds: {self.diamonds} 💎") print("="*40) print("Game Options:") print("1. Visit Shop") print("2. Inventory") print("3. Equipped Items") # New option to display equipped items print("4. Play Game") print("5. Delete this Character") print("6. Add 50 Experience Points") # New option to add 50 exp print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.visit_shop() elif choice == "2": self.visit_inventory() elif choice == "3": self.display_equipped_items() elif choice == "4": self.play_game() elif choice == "5": return elif choice == "6": # Option to add 50 exp self.add_experience(50) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_status() def calculate_stat(self, stat_name): base_stat = getattr(self, stat_name) bonus_stat = sum(item.get(stat_name, 0) for item in self.equipped_items.values() if item) return base_stat + bonus_stat def display_items(self, item_type): os.system('cls' if os.name == 'nt' else 'clear') print(f"{item_type}:") print("=" * 40) if self.inventory[item_type]: for idx, item in enumerate(self.inventory[item_type], 1): if item: # Check if item is not None print(f"{idx}. {item['name']}: {item['description']}") else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.visit_inventory() elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]): self.equip_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_items(item_type) else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.visit_inventory() else: print("Invalid option. Please enter < to go back.") time.sleep(1) self.visit_inventory() def equip_item(self, item_type, index): if item_type in self.inventory: if 0 <= index < len(self.inventory[item_type]): item = self.inventory[item_type].pop(index) if self.equipped_items[item_type]: old_item = self.equipped_items[item_type] self.inventory[item_type].append(old_item) self.equipped_items[item_type] = item self.update_stats() print(f"{item['name']} equipped.") time.sleep(1) else: print("Invalid item index.") time.sleep(1) else: print("Invalid item type.") time.sleep(1) def unequip_item(self, item_type_to_unequip): if self.equipped_items[item_type_to_unequip]: self.inventory[item_type_to_unequip].append(self.equipped_items[item_type_to_unequip]) self.equipped_items[item_type_to_unequip] = None print(f"{item_type_to_unequip}: None") time.sleep(1) self.unequip_menu(item_type_to_unequip) else: print("No item equipped.") time.sleep(1) self.display_equipped_items() def unequip_menu(self, item_type_to_unequip): os.system('cls' if os.name == 'nt' else 'clear') print(f"Unequip {item_type_to_unequip}:") print("=" * 40) if self.equipped_items[item_type_to_unequip]: print(f"1. {self.equipped_items[item_type_to_unequip]['name']} - {self.equipped_items[item_type_to_unequip]['description']}") print("Enter 1 to unequip or press < to cancel.") choice = input("") if choice == "1": self.unequip_item(item_type_to_unequip) elif choice == "<": self.display_equipped_items() else: print("Invalid option. Please enter a valid option.") time.sleep(1) self.unequip_menu(item_type_to_unequip) else: print(f"No {item_type_to_unequip} equipped.") time.sleep(1) self.display_equipped_items() def display_equipped_items(self): os.system('cls' if os.name == 'nt' else 'clear') print("Equipped Items:") print("=" * 40) for item_type, item in self.equipped_items.items(): if item: print(f"{item_type}: {item['name']} - {item['description']}") else: print(f"{item_type}: None") print("\nUnequip Items:") print("=" * 40) for i, (item_type, item) in enumerate(self.equipped_items.items(), start=1): if item: print(f"{i}. {item_type}: {item['name']} - {item['description']}") else: print(f"{i}. {item_type}: None") print("Press < to go back to the player status menu.") choice = input("") if choice == "<": self.display_status() elif choice.isdigit(): index = int(choice) - 1 if 0 <= index < len(self.equipped_items): item_type_to_unequip = list(self.equipped_items.keys())[index] self.unequip_menu(item_type_to_unequip) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_equipped_items() else: print("Invalid option. Please enter a valid option.") time.sleep(1) self.display_equipped_items() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def play_game(self): # Placeholder for play game functionality input("Play game functionality is under construction. Press Enter to return to the player status menu...") self.display_status() def add_experience(self, amount): self.experience += amount if self.experience >= self.exp_required: self.level_up() self.display_status() def level_up(self): self.level += 1 self.exp_required = int(self.exp_required * (1 + self.exp_multiplier)) # Increase by 75% self.attack += 0.5 self.defense += 0.5 self.dodge += 0.5 self.speed += 0.5 def get_name_display(self): symbol = "" if self.difficulty == "Basic": symbol = "🛡️" elif self.difficulty == "Exemplar": symbol = "⚔️" elif self.difficulty == "Templar": symbol = "☠️" return f"{symbol} {self.name}" def get_difficulty_display(self): return self.difficulty def visit_shop(self): while True: os.system('cls' if os.name == 'nt' else 'clear') print("Welcome to the Shop!") print("=" * 40) print("Shop Sections:") print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select a shop section.") choice = input("") if choice == "1": self.display_shop_section("Weapons") elif choice == "2": self.display_shop_section("Armors") elif choice == "3": self.display_shop_section("Shields") elif choice == "4": self.display_shop_section("Footwear") elif choice == "5": self.display_shop_section("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_shop_section(self, item_type): os.system('cls' if os.name == 'nt' else 'clear') print(f"Shop - {item_type}:") print("=" * 40) if item_type in items_groups: for idx, item in enumerate(items_groups[item_type], 1): print(f"{idx}. {item['name']}: {item['description']} - Cost: {item['cost']} gold") print("0. Back to Shop Sections") print("Enter the number to purchase the item or 0 to go back.") choice = input("") if choice == "0": self.visit_shop() elif choice.isdigit() and 0 < int(choice) <= len(items_groups[item_type]): self.purchase_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_shop_section(item_type) else: print("Invalid shop section.") time.sleep(1) self.visit_shop() def purchase_item(self, item_type, index): item = items_groups[item_type][index] cost = item['cost'] if self.gold >= cost: self.gold -= cost self.inventory[item_type].append(item) print(f"You have purchased {item['name']} for {cost} gold.") time.sleep(1) else: print("Insufficient gold to purchase this item.") time.sleep(1) self.display_shop_section(item_type) items_groups = { "Usable Items": [ {"name": "Small Healing Potion", "description": "+15 hp", "cost": 20}, {"name": "Self Healing Potion", "description": "+20 hp", "cost": 50}, {"name": "Moderated Potion", "description": "+25 hp", "cost": 75}, {"name": "Regen Potion", "description": "+15%", "cost": 100}, {"name": "Hammerhead Crocker", "description": "+7% attack for 7 turns", "cost": 55, "attack_bonus": 0.07}, {"name": "Warhammer Crocker", "description": "+15% attack for 7 turns", "cost": 75, "attack_bonus": 0.15}, {"name": "Barhog", "description": "+7% Defense for 7 turns", "cost": 45, "defense_bonus": 0.07}, {"name": "Warhog", "description": "+15% defense for 7 turns", "cost": 60, "defense_bonus": 0.15}, {"name": "Non applicable scroll", "description": "+2 Speed for 7 turns", "cost": 40, "speed_bonus": 2}, {"name": "Applicable scroll", "description": "+4 speed for 7 turns", "cost": 55, "speed_bonus": 4}, {"name": "Ransacked Shield", "description": "+12% Dodge chance for 3 turns", "cost": 60, "dodge_bonus": 0.12}, {"name": "Unbuilded Shield", "description": "+23% Dodge Chance for 5 turns", "cost": 90, "dodge_bonus": 0.23}, {"name": "Mystic Scroll", "description": "25% chance to negate all debuffs on player for 4 turns", "cost": 60}, {"name": "Mystic Beurau", "description": "50% chance to negate all debuffs on player for 4 turns", "cost": 120}, {"name": "Variant Bs", "description": "Increase all stats up to 25% for 10 turns", "cost": 200}, {"name": "Variant Ex", "description": "Increase all stats up to 50% for 10 turns", "cost": 400}, {"name": "Hide cloak", "description": "40% chance to dodge the battle against enemies when exploring", "cost": 50, "dodge_bonus": 0.4}, {"name": "Invisible potion", "description": "60% chance to dodge the battle against enemies when exploring", "cost": 75, "dodge_bonus": 0.6}, {"name": "Exp Moneter", "description": "Give you 20 exp points", "cost": 50}, {"name": "Exp Vitalis", "description": "Give you 50 exp points", "cost": 100}, {"name": "Exp For enhancer", "description": "Give you 100 points", "cost": 150} ], "Weapons": [ {"name": "Stone Sword", "description": "+12 attack", "cost": 150, "attack_bonus": 12}, {"name": "Copper Sword", "description": "+15 attack", "cost": 275, "attack_bonus": 15}, {"name": "Sickanum Sword", "description": "+17 attack", "cost": 400, "attack_bonus": 17}, {"name": "Arivanum Sword", "description": "+23 attack", "cost": 600, "attack_bonus": 23}, {"name": "Viranium Sword", "description": "+25 attack", "cost": 850, "attack_bonus": 25}, {"name": "Titanium sword", "description": "+35 attack", "cost": 1250, "attack_bonus": 35} ], "Armors": [ {"name": "Jungle sets", "description": "+7 Defense", "cost": 90, "defense_bonus": 7}, {"name": "Byzantine sets", "description": "+12 Defense", "cost": 140, "defense_bonus": 12}, {"name": "Nikel Sets", "description": "+15 Defense", "cost": 350, "defense_bonus": 15}, {"name": "Warhead Sets", "description": "+25 Defense", "cost": 560, "defense_bonus": 25}, {"name": "Titanium Sets", "description": "+40 Defense", "cost": 850, "defense_bonus": 40} ], "Shields": [ {"name": "Wooden Ob", "description": "+2 dodge", "cost": 80, "dodge_bonus": 2}, {"name": "Long Ob", "description": "+3 dodge, +2 Defense", "cost": 120, "dodge_bonus": 3, "defense_bonus": 2}, {"name": "Cob Ob", "description": "+5 dodge, +4 Defense", "cost": 300, "dodge_bonus": 5, "defense_bonus": 4}, {"name": "Knock Ob", "description": "+7 dodge, +5 Defense, +3 Attack", "cost": 550, "dodge_bonus": 7, "defense_bonus": 5, "attack_bonus": 3}, {"name": "Neb Ob", "description": "+12 dodge, +7 Defense, +5 Attack", "cost": 760, "dodge_bonus": 12, "defense_bonus": 7, "attack_bonus": 5} ], "Footwear": [ {"name": "Jungle Foot", "description": "+3 speeds", "cost": 45, "speed_bonus": 3}, {"name": "Iron Foot", "description": "+5 Speed", "cost": 75, "speed_bonus": 5}, {"name": "Metal WarFoot", "description": "+8 Speeds", "cost": 120, "speed_bonus": 8}, {"name": "Diamond Boots", "description": "+12 Speeds", "cost": 230, "speed_bonus": 12}, {"name": "Noble Boots", "description": "+19 Speeds", "cost": 450, "speed_bonus": 19}, {"name": "Lizable Boots", "description": "+25 Speeds", "cost": 700, "speed_bonus": 25} ] } def create_character(): clear_screen() print("Character Creation") name = input("Enter your character's name: ") clear_screen() print(f"Character Name: {name}\n") while True: print("Select Difficulty:") print("1. Basic 🛡️") print("2. Exemplar ⚔️") print("3. Templar ☠️") difficulty_choice = input("Enter the number to select difficulty: ") if difficulty_choice == "1": difficulty = "Basic" description = "Enemies are powerful in their origins." elif difficulty_choice == "2": difficulty = "Exemplar" description = "Enemies are harder and more immortalized." elif difficulty_choice == "3": difficulty = "Templar" description = "Enemies are evils." else: print("Invalid difficulty choice. Please choose a valid option.") time.sleep(1) clear_screen() continue clear_screen() print("Selected Difficulty:") print(f"Name: {name}") print(f"Difficulty: {difficulty}") print(f"Description: {description}\n") print("1. Confirm") print("2. Back") confirm_choice = input("Enter your choice: ") if confirm_choice == "1": break elif confirm_choice == "2": clear_screen() continue else: print("Invalid choice. Please enter 1 to confirm or 2 to go back.") time.sleep(1) clear_screen() player = Player(name, difficulty) player.equipped_items["Weapons"] = {"name": "Broken Sword", "description": "+10 Damage", "attack": 10} player.equipped_items["Armors"] = {"name": "Broken Armor", "description": "+5 Defense", "defense": 5} player.equipped_items["Shields"] = {"name": "Broken Shield", "description": "+2 Dodge", "dodge": 2} player.equipped_items["Footwear"] = {"name": "Broken Footwear", "description": "+3 Speed", "speed": 3} return Player(name, difficulty) def clear_screen(): """Clears the console screen.""" os.system('cls' if os.name == 'nt' else 'clear') def main_menu(): clear_screen() print("BeaVenture\n") print("1. Create Character") print("2. Exit") print("\nEnter the number to select an option.") def main(): while True: main_menu() try: choice = int(input("")) if choice == 1: player = create_character() player.display_status() elif choice == 2: clear_screen() print("Exiting BeaVenture. Goodbye!") time.sleep(2) clear_screen() print("Game Was Ended") input("Press Enter to exit...") clear_screen() break else: print("Invalid option. Please enter a valid number.") time.sleep(2) except ValueError: print("Invalid input. Please enter a number.") if __name__ == "__main__": main()
@All :b :b Dear cả lớp Em là Huyền - Admin của CodeStar Academy. Lời đầu tiên xin cảm ơn mọi ng đã tin tưởng và lựa chọn Codestar để đồng hành trên chặng đường tìm hiểu về K8s. E xin phép gửi lại lớp 1 số Link quan trọng của lớp như sau: 1. Hướng dẫn tạo AWS Account như trong file hướng dẫn, mng tạo Account dần giúp em ạ: https://docs.google.com/document/d/1tGKfLg2v-rLxZdV5pUr1aVUK7InnZLoZ/edit?usp=drive_link&ouid=117593923093139842004&rtpof=true&sd=true 2. Tài liệu khóa học K8s (bao gồm Video record + slide tài liệu được up lên sau mỗi buổi học) https://docs.google.com/spreadsheets/d/1tCRlGgPhBQ1dtiYCGMXWqjJzsjCKZV-LmEcUjq094yA/edit?usp=drive_link /-heart Em cảm ơn.
import os import time import sys class Player: def __init__(self, name, difficulty): self.name = name self.difficulty = difficulty self.gold = 100 self.diamonds = 0 self.experience = 0 self.level = 1 self.exp_required = 100 self.exp_multiplier = 0.75 # 75% increase for experience requirement per level self.inventory = { # Initialize inventory "Weapons": [], "Armors": [], "Shields": [], "Footwear": [], "Usable Items": [] # Add Usable Items category } self.equipped_items = { # Initialize equipped items "Weapons": {"name": "Broken Sword", "description": "+10 Damage", "attack": 10}, "Armors": {"name": "Broken Armor", "description": "+5 Defense", "defense": 5}, "Shields": {"name": "Broken Shield", "description": "+2 Dodge", "dodge": 2}, "Footwear": {"name": "Broken Footwear", "description": "+3 Speed", "speed": 3}, "Accessories": None, "Bag": None } self.base_stats = { "HP": 100, "Defense": 0, "Attack": 0, "Dodge": 0, "Speed": 0 } self.max_inventory_slots = 30 self.update_stats() # Update player stats based on equipped items def visit_inventory(self): while True: os.system('cls' if os.name == 'nt' else 'clear') print("Inventory:") print("=" * 40) print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.display_items("Weapons") elif choice == "2": self.display_items("Armors") elif choice == "3": self.display_items("Shields") elif choice == "4": self.display_items("Footwear") elif choice == "5": self.display_items("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_items(self, item_type): while True: os.system('cls' if os.name == 'nt' else 'clear') print(f"{item_type}:") print("=" * 40) if self.inventory[item_type]: for idx, item in enumerate(self.inventory[item_type], 1): print(f"{idx}. {item['name']}: {item['description']}") print("0. Back to Inventory Menu") print("Enter the number to equip the item or 0 to go back.") choice = input("") if choice == "0": break # Break out of the inner loop to return to the previous menu elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]): self.equip_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) else: print("No items in this category.") print("Press < to go back") choice = input("") if choice == "<": break # Break out of the inner loop to return to the previous menu def equip_item(self, item_type, index): item = self.inventory[item_type].pop(index) if item_type in ["Weapons", "Armors", "Shields", "Footwear"]: self.remove_equipped_item(item_type) # Remove any previously equipped item of the same type self.equipped_items[item_type] = item # Equip the new item self.update_stats() # Update player stats with the new equipment print(f"{item['name']} equipped.") time.sleep(1) else: # Handle equipping usable items pass self.visit_inventory() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def update_stats(self): # Reset stats to base values for stat in self.base_stats: setattr(self, stat.lower(), self.base_stats[stat]) # Add bonuses from equipped items for item_type, item in self.equipped_items.items(): if item: for stat in item: if stat in self.base_stats: setattr(self, stat.lower(), self.base_stats[stat] + item[stat]) def display_equipped_items(self): os.system('cls' if os.name == 'nt' else 'clear') print("Equipped Items:") print("=" * 40) for item_type, item in self.equipped_items.items(): if item: print(f"{item_type}: {item['name']} - {item['description']}") else: print(f"{item_type}: None") # Add option to unequip items print("Press u to unequip.") choice = input("") if choice == "u": self.unequip_menu() elif choice == "<": self.display_status() else: print("Invalid option. Please enter u to unequip or < to go back.") time.sleep(1) self.display_equipped_items() def display_status(self): print("Player Status:") print("=" * 40) print(f"Name: {self.name}") print(f"Difficulty: {self.difficulty}") print("-" * 40) print("Stats:") print(f"HP :❤️{self.base_stats['HP']}") print(f"Defense :🛡️{self.defense}") print(f"Attack :⚔️{self.attack}") print(f"Dodge :🤺{self.dodge}") print(f"Speed :🏃{self.speed}") print("-"*40) print(f"Level: {self.level}") print(f"Experience: {self.experience}/{self.exp_required}") print("-"*40) print(f"Gold: {self.gold} 💰") print(f"Diamonds: {self.diamonds} 💎") print("="*40) print("Game Options:") print("1. Visit Shop") print("2. Inventory") print("3. Equipped Items") # New option to display equipped items print("4. Play Game") print("5. Delete this Character") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.visit_shop() elif choice == "2": self.visit_inventory() elif choice == "3": self.display_equipped_items() # Call the new method to display equipped items elif choice == "4": self.play_game() elif choice == "5": return else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_status() def calculate_stat(self, stat_name): base_stat = getattr(self, stat_name) bonus_stat = sum(item.get(stat_name, 0) for item in self.equipped_items.values() if item) return base_stat + bonus_stat def display_items(self, item_type): os.system('cls' if os.name == 'nt' else 'clear') print(f"{item_type}:") print("=" * 40) if self.inventory[item_type]: for idx, item in enumerate(self.inventory[item_type], 1): if item: # Check if item is not None print(f"{idx}. {item['name']}: {item['description']}") else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.visit_inventory() elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]): self.equip_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_items(item_type) else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.visit_inventory() else: print("Invalid option. Please enter < to go back.") time.sleep(1) self.visit_inventory() def equip_item(self, item_type, index): if item_type in self.inventory: if 0 <= index < len(self.inventory[item_type]): item = self.inventory[item_type].pop(index) if self.equipped_items[item_type]: old_item = self.equipped_items[item_type] self.inventory[item_type].append(old_item) self.equipped_items[item_type] = item self.update_stats() print(f"{item['name']} equipped.") time.sleep(1) else: print("Invalid item index.") time.sleep(1) else: print("Invalid item type.") time.sleep(1) def unequip_item(self, item_type_to_unequip): if self.equipped_items[item_type_to_unequip]: self.inventory[item_type_to_unequip].append(self.equipped_items[item_type_to_unequip]) self.equipped_items[item_type_to_unequip] = None print(f"{item_type_to_unequip}: None") time.sleep(1) self.unequip_menu(item_type_to_unequip) else: print("No item equipped.") time.sleep(1) self.display_equipped_items() def unequip_menu(self, item_type_to_unequip): os.system('cls' if os.name == 'nt' else 'clear') print(f"Unequip {item_type_to_unequip}:") print("=" * 40) if self.equipped_items[item_type_to_unequip]: print(f"1. {self.equipped_items[item_type_to_unequip]['name']} - {self.equipped_items[item_type_to_unequip]['description']}") print("Enter 1 to unequip or press < to cancel.") choice = input("") if choice == "1": self.unequip_item(item_type_to_unequip) elif choice == "<": self.display_equipped_items() else: print("Invalid option. Please enter a valid option.") time.sleep(1) self.unequip_menu(item_type_to_unequip) else: print(f"No {item_type_to_unequip} equipped.") time.sleep(1) self.display_equipped_items() def display_equipped_items(self): os.system('cls' if os.name == 'nt' else 'clear') print("Equipped Items:") print("=" * 40) for item_type, item in self.equipped_items.items(): if item: print(f"{item_type}: {item['name']} - {item['description']}") else: print(f"{item_type}: None") print("\nUnequip Items:") print("=" * 40) for i, (item_type, item) in enumerate(self.equipped_items.items(), start=1): if item: print(f"{i}. {item_type}: {item['name']} - {item['description']}") else: print(f"{i}. {item_type}: None") print("Press < to go back to the player status menu.") choice = input("") if choice == "<": self.display_status() elif choice.isdigit(): index = int(choice) - 1 if 0 <= index < len(self.equipped_items): item_type_to_unequip = list(self.equipped_items.keys())[index] self.unequip_menu(item_type_to_unequip) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_equipped_items() else: print("Invalid option. Please enter a valid option.") time.sleep(1) self.display_equipped_items() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def play_game(self): # Placeholder for play game functionality input("Play game functionality is under construction. Press Enter to return to the player status menu...") self.display_status() def add_experience(self, amount): self.experience += amount if self.experience >= self.exp_required: self.level_up() self.display_status() def level_up(self): self.level += 1 self.exp_required = int(self.exp_required * (1 + self.exp_multiplier)) # Increase by 75% self.attack += 0.5 self.defense += 0.5 self.dodge += 0.5 self.speed += 0.5 def get_name_display(self): symbol = "" if self.difficulty == "Basic": symbol = "🛡️" elif self.difficulty == "Exemplar": symbol = "⚔️" elif self.difficulty == "Templar": symbol = "☠️" return f"{symbol} {self.name}" def get_difficulty_display(self): return self.difficulty def visit_shop(self): while True: os.system('cls' if os.name == 'nt' else 'clear') print("Welcome to the Shop!") print("=" * 40) print("Shop Sections:") print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select a shop section.") choice = input("") if choice == "1": self.display_shop_section("Weapons") elif choice == "2": self.display_shop_section("Armors") elif choice == "3": self.display_shop_section("Shields") elif choice == "4": self.display_shop_section("Footwear") elif choice == "5": self.display_shop_section("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_shop_section(self, item_type): os.system('cls' if os.name == 'nt' else 'clear') print(f"Shop - {item_type}:") print("=" * 40) if item_type in items_groups: for idx, item in enumerate(items_groups[item_type], 1): print(f"{idx}. {item['name']}: {item['description']} - Cost: {item['cost']} gold") print("0. Back to Shop Sections") print("Enter the number to purchase the item or 0 to go back.") choice = input("") if choice == "0": self.visit_shop() elif choice.isdigit() and 0 < int(choice) <= len(items_groups[item_type]): self.purchase_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_shop_section(item_type) else: print("Invalid shop section.") time.sleep(1) self.visit_shop() def purchase_item(self, item_type, index): item = items_groups[item_type][index] cost = item['cost'] if self.gold >= cost: self.gold -= cost self.inventory[item_type].append(item) print(f"You have purchased {item['name']} for {cost} gold.") time.sleep(1) else: print("Insufficient gold to purchase this item.") time.sleep(1) self.display_shop_section(item_type) items_groups = { "Usable Items": [ {"name": "Small Healing Potion", "description": "+15 hp", "cost": 20}, {"name": "Self Healing Potion", "description": "+20 hp", "cost": 50}, {"name": "Moderated Potion", "description": "+25 hp", "cost": 75}, {"name": "Regen Potion", "description": "+15%", "cost": 100}, {"name": "Hammerhead Crocker", "description": "+7% attack for 7 turns", "cost": 55, "attack_bonus": 0.07}, {"name": "Warhammer Crocker", "description": "+15% attack for 7 turns", "cost": 75, "attack_bonus": 0.15}, {"name": "Barhog", "description": "+7% Defense for 7 turns", "cost": 45, "defense_bonus": 0.07}, {"name": "Warhog", "description": "+15% defense for 7 turns", "cost": 60, "defense_bonus": 0.15}, {"name": "Non applicable scroll", "description": "+2 Speed for 7 turns", "cost": 40, "speed_bonus": 2}, {"name": "Applicable scroll", "description": "+4 speed for 7 turns", "cost": 55, "speed_bonus": 4}, {"name": "Ransacked Shield", "description": "+12% Dodge chance for 3 turns", "cost": 60, "dodge_bonus": 0.12}, {"name": "Unbuilded Shield", "description": "+23% Dodge Chance for 5 turns", "cost": 90, "dodge_bonus": 0.23}, {"name": "Mystic Scroll", "description": "25% chance to negate all debuffs on player for 4 turns", "cost": 60}, {"name": "Mystic Beurau", "description": "50% chance to negate all debuffs on player for 4 turns", "cost": 120}, {"name": "Variant Bs", "description": "Increase all stats up to 25% for 10 turns", "cost": 200}, {"name": "Variant Ex", "description": "Increase all stats up to 50% for 10 turns", "cost": 400}, {"name": "Hide cloak", "description": "40% chance to dodge the battle against enemies when exploring", "cost": 50, "dodge_bonus": 0.4}, {"name": "Invisible potion", "description": "60% chance to dodge the battle against enemies when exploring", "cost": 75, "dodge_bonus": 0.6}, {"name": "Exp Moneter", "description": "Give you 20 exp points", "cost": 50}, {"name": "Exp Vitalis", "description": "Give you 50 exp points", "cost": 100}, {"name": "Exp For enhancer", "description": "Give you 100 points", "cost": 150} ], "Weapons": [ {"name": "Stone Sword", "description": "+12 attack", "cost": 150, "attack_bonus": 12}, {"name": "Copper Sword", "description": "+15 attack", "cost": 275, "attack_bonus": 15}, {"name": "Sickanum Sword", "description": "+17 attack", "cost": 400, "attack_bonus": 17}, {"name": "Arivanum Sword", "description": "+23 attack", "cost": 600, "attack_bonus": 23}, {"name": "Viranium Sword", "description": "+25 attack", "cost": 850, "attack_bonus": 25}, {"name": "Titanium sword", "description": "+35 attack", "cost": 1250, "attack_bonus": 35} ], "Armors": [ {"name": "Jungle sets", "description": "+7 Defense", "cost": 90, "defense_bonus": 7}, {"name": "Byzantine sets", "description": "+12 Defense", "cost": 140, "defense_bonus": 12}, {"name": "Nikel Sets", "description": "+15 Defense", "cost": 350, "defense_bonus": 15}, {"name": "Warhead Sets", "description": "+25 Defense", "cost": 560, "defense_bonus": 25}, {"name": "Titanium Sets", "description": "+40 Defense", "cost": 850, "defense_bonus": 40} ], "Shields": [ {"name": "Wooden Ob", "description": "+2 dodge", "cost": 80, "dodge_bonus": 2}, {"name": "Long Ob", "description": "+3 dodge, +2 Defense", "cost": 120, "dodge_bonus": 3, "defense_bonus": 2}, {"name": "Cob Ob", "description": "+5 dodge, +4 Defense", "cost": 300, "dodge_bonus": 5, "defense_bonus": 4}, {"name": "Knock Ob", "description": "+7 dodge, +5 Defense, +3 Attack", "cost": 550, "dodge_bonus": 7, "defense_bonus": 5, "attack_bonus": 3}, {"name": "Neb Ob", "description": "+12 dodge, +7 Defense, +5 Attack", "cost": 760, "dodge_bonus": 12, "defense_bonus": 7, "attack_bonus": 5} ], "Footwear": [ {"name": "Jungle Foot", "description": "+3 speeds", "cost": 45, "speed_bonus": 3}, {"name": "Iron Foot", "description": "+5 Speed", "cost": 75, "speed_bonus": 5}, {"name": "Metal WarFoot", "description": "+8 Speeds", "cost": 120, "speed_bonus": 8}, {"name": "Diamond Boots", "description": "+12 Speeds", "cost": 230, "speed_bonus": 12}, {"name": "Noble Boots", "description": "+19 Speeds", "cost": 450, "speed_bonus": 19}, {"name": "Lizable Boots", "description": "+25 Speeds", "cost": 700, "speed_bonus": 25} ] } def create_character(): clear_screen() print("Character Creation") name = input("Enter your character's name: ") clear_screen() print(f"Character Name: {name}\n") while True: print("Select Difficulty:") print("1. Basic 🛡️") print("2. Exemplar ⚔️") print("3. Templar ☠️") difficulty_choice = input("Enter the number to select difficulty: ") if difficulty_choice == "1": difficulty = "Basic" description = "Enemies are powerful in their origins." elif difficulty_choice == "2": difficulty = "Exemplar" description = "Enemies are harder and more immortalized." elif difficulty_choice == "3": difficulty = "Templar" description = "Enemies are evils." else: print("Invalid difficulty choice. Please choose a valid option.") time.sleep(1) clear_screen() continue clear_screen() print("Selected Difficulty:") print(f"Name: {name}") print(f"Difficulty: {difficulty}") print(f"Description: {description}\n") print("1. Confirm") print("2. Back") confirm_choice = input("Enter your choice: ") if confirm_choice == "1": break elif confirm_choice == "2": clear_screen() continue else: print("Invalid choice. Please enter 1 to confirm or 2 to go back.") time.sleep(1) clear_screen() player = Player(name, difficulty) player.equipped_items["Weapons"] = {"name": "Broken Sword", "description": "+10 Damage", "attack": 10} player.equipped_items["Armors"] = {"name": "Broken Armor", "description": "+5 Defense", "defense": 5} player.equipped_items["Shields"] = {"name": "Broken Shield", "description": "+2 Dodge", "dodge": 2} player.equipped_items["Footwear"] = {"name": "Broken Footwear", "description": "+3 Speed", "speed": 3} return Player(name, difficulty) def clear_screen(): """Clears the console screen.""" os.system('cls' if os.name == 'nt' else 'clear') def main_menu(): clear_screen() print("BeaVenture\n") print("1. Create Character") print("2. Exit") print("\nEnter the number to select an option.") def main(): while True: main_menu() try: choice = int(input("")) if choice == 1: player = create_character() player.display_status() elif choice == 2: clear_screen() print("Exiting BeaVenture. Goodbye!") time.sleep(2) clear_screen() print("Game Was Ended") input("Press Enter to exit...") clear_screen() break else: print("Invalid option. Please enter a valid number.") time.sleep(2) except ValueError: print("Invalid input. Please enter a number.") if __name__ == "__main__": main()
int low=0; int high=0; queue<int>que; vector<long long>V; while(low<N && high<N) { if(A[high]<0) { que.push(A[high]); } if(high-low+1==k) { if(que.size()==0) { V.push_back(0); } else { V.push_back(que.front()); } } else if(high-low+1>k) { while(high-low+1>k) { if(A[low]==que.front()) { que.pop(); } low++; } if(high-low+1==k) { if(que.size()==0) { V.push_back(0); } else { V.push_back(que.front()); } } } high++; } return V;
import os import time import sys class Player: def __init__(self, name, difficulty): self.name = name self.difficulty = difficulty self.attack = 10 self.defense = 5 self.dodge = 2 self.speed = 3 self.gold = 100 self.diamonds = 0 self.experience = 0 self.level = 1 self.exp_required = 100 self.exp_multiplier = 0.75 # 75% increase for experience requirement per level self.inventory = { # Initialize inventory "Weapons": [], "Armors": [], "Shields": [], "Footwear": [], "Usable Items": [] # Add Usable Items category } self.equipped_items = { # Initialize equipped items "Weapons": None, "Armors": None, "Shields": None, "Footwear": None } self.max_inventory_slots = 30 # Existing methods... def visit_inventory(self): while True: os.system('cls' if os.name == 'nt' else 'clear') print("Inventory:") print("=" * 40) print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.display_items("Weapons") elif choice == "2": self.display_items("Armors") elif choice == "3": self.display_items("Shields") elif choice == "4": self.display_items("Footwear") elif choice == "5": self.display_items("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_items(self, item_type): while True: os.system('cls' if os.name == 'nt' else 'clear') print(f"{item_type}:") print("=" * 40) if self.inventory[item_type]: for idx, item in enumerate(self.inventory[item_type], 1): print(f"{idx}. {item['name']}: {item['description']}") print("0. Back to Inventory Menu") print("Enter the number to equip the item or 0 to go back.") choice = input("") if choice == "0": break # Break out of the inner loop to return to the previous menu elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]): self.equip_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) else: print("No items in this category.") print("Press < to go back") choice = input("") if choice == "<": break # Break out of the inner loop to return to the previous menu def equip_item(self, item_type, index): item = self.inventory[item_type].pop(index) if item_type in ["Weapons", "Armors", "Shields", "Footwear"]: self.remove_equipped_item(item_type) # Remove any previously equipped item of the same type self.equipped_items[item_type] = item # Equip the new item self.update_stats() # Update player stats with the new equipment print(f"{item['name']} equipped.") time.sleep(1) else: # Handle equipping usable items pass self.visit_inventory() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def update_stats(self): # Reset base stats self.attack = 10 self.defense = 5 self.dodge = 2 self.speed = 3 # Add bonuses from equipped items for item_type, item in self.equipped_items.items(): if item: self.attack += item.get('attack', 0) self.defense += item.get('defense', 0) self.dodge += item.get('dodge', 0) self.speed += item.get('speed', 0) def display_status(self): os.system('cls' if os.name == 'nt' else 'clear') print("Player Status:\n") print("="*40) print(f"Name: {self.get_name_display()}") print(f"Difficulty: {self.get_difficulty_display()}") print("-"*40) print("Stats:") print(f"HP :❤️{self.calculate_stat('attack')}") print(f"Defense :🛡️{self.calculate_stat('defense')}") print(f"Attack :⚔️{self.calculate_stat('attack')}") print(f"Dodge :🤺{self.calculate_stat('dodge')}") print(f"Speed :🏃{self.calculate_stat('speed')}") print("-"*40) print(f"Level: {self.level}") print(f"Experience: {self.experience}/{self.exp_required}") print("-"*40) print(f"Gold: {self.gold} 💰") print(f"Diamonds: {self.diamonds} 💎") print("="*40) print("Game Options:") print("1. Visit Shop") print("2. Inventory") print("3. Play Game") print("4. Delete this Character") print("\nEnter the number to select an option.") choice = input("") if choice == "1": self.visit_shop() elif choice == "2": self.visit_inventory() elif choice == "3": self.play_game() elif choice == "4": return else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_status() def calculate_stat(self, stat_name): base_stat = getattr(self, stat_name) bonus_stat = sum(item.get(stat_name, 0) for item in self.equipped_items.values() if item) return base_stat + bonus_stat def display_items(self, item_type): os.system('cls' if os.name == 'nt' else 'clear') print(f"{item_type}:") print("=" * 40) if self.inventory[item_type]: for idx, item in enumerate(self.inventory[item_type], 1): print(f"{idx}. {item['name']}: {item['description']}") print("0. Back to Inventory Menu") print("Enter the number to equip the item or 0 to go back.") choice = input("") if choice == "0": self.visit_inventory() elif choice.isdigit() and 0 < int(choice) <= len(self.inventory[item_type]): self.equip_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_items(item_type) else: print("No items in this category.") print("You need to press < to go back.") choice = input("") if choice == "<": self.visit_inventory() else: print("Invalid option. Please enter < to go back.") time.sleep(1) self.visit_inventory() def equip_item(self, item_type, index): item = self.inventory[item_type].pop(index) if item_type in ["Weapons", "Armors", "Shields", "Footwear"]: self.remove_equipped_item(item_type) self.equipped_items[item_type] = item print(f"{item['name']} equipped.") time.sleep(1) else: # Handle equipping usable items pass self.visit_inventory() def remove_equipped_item(self, item_type): if item_type in self.equipped_items: item = self.equipped_items.pop(item_type) self.inventory[item_type].append(item) def play_game(self): # Placeholder for play game functionality input("Play game functionality is under construction. Press Enter to return to the player status menu...") self.display_status() def add_experience(self, amount): self.experience += amount if self.experience >= self.exp_required: self.level_up() self.display_status() def level_up(self): self.level += 1 self.exp_required = int(self.exp_required * (1 + self.exp_multiplier)) # Increase by 75% self.attack += 0.5 self.defense += 0.5 self.dodge += 0.5 self.speed += 0.5 def get_name_display(self): symbol = "" if self.difficulty == "Basic": symbol = "🛡️" elif self.difficulty == "Exemplar": symbol = "⚔️" elif self.difficulty == "Templar": symbol = "☠️" return f"{symbol} {self.name}" def get_difficulty_display(self): return self.difficulty def visit_shop(self): while True: os.system('cls' if os.name == 'nt' else 'clear') print("Welcome to the Shop!") print("=" * 40) print("Shop Sections:") print("1. Weapons") print("2. Armors") print("3. Shields") print("4. Footwear") print("5. Usable Items") print("6. Back to Player Status") print("\nEnter the number to select a shop section.") choice = input("") if choice == "1": self.display_shop_section("Weapons") elif choice == "2": self.display_shop_section("Armors") elif choice == "3": self.display_shop_section("Shields") elif choice == "4": self.display_shop_section("Footwear") elif choice == "5": self.display_shop_section("Usable Items") elif choice == "6": self.display_status() else: print("Invalid option. Please enter a valid number.") time.sleep(1) def display_shop_section(self, item_type): os.system('cls' if os.name == 'nt' else 'clear') print(f"Shop - {item_type}:") print("=" * 40) if item_type in items_groups: for idx, item in enumerate(items_groups[item_type], 1): print(f"{idx}. {item['name']}: {item['description']} - Cost: {item['cost']} gold") print("0. Back to Shop Sections") print("Enter the number to purchase the item or 0 to go back.") choice = input("") if choice == "0": self.visit_shop() elif choice.isdigit() and 0 < int(choice) <= len(items_groups[item_type]): self.purchase_item(item_type, int(choice) - 1) else: print("Invalid option. Please enter a valid number.") time.sleep(1) self.display_shop_section(item_type) else: print("Invalid shop section.") time.sleep(1) self.visit_shop() def purchase_item(self, item_type, index): item = items_groups[item_type][index] cost = item['cost'] if self.gold >= cost: self.gold -= cost self.inventory[item_type].append(item) print(f"You have purchased {item['name']} for {cost} gold.") time.sleep(1) else: print("Insufficient gold to purchase this item.") time.sleep(1) self.display_shop_section(item_type) items_groups = { "Usable Items": [ {"name": "Small Healing Potion", "description": "+15 hp", "cost": 20}, {"name": "Self Healing Potion", "description": "+20 hp", "cost": 50}, {"name": "Moderated Potion", "description": "+25 hp", "cost": 75}, {"name": "Regen Potion", "description": "+15%", "cost": 100}, {"name": "Hammerhead Crocker", "description": "+7% attack for 7 turns", "cost": 55}, {"name": "Warhammer Crocker", "description": "+15% attack for 7 turns", "cost": 75}, {"name": "Barhog", "description": "+7% Defense for 7 turns", "cost": 45}, {"name": "Warhog", "description": "+15% defense for 7 turns", "cost": 60}, {"name": "Non applicable scroll", "description": "+2 Speed for 7 turns", "cost": 40}, {"name": "Applicable scroll", "description": "+4 speed for 7 turns", "cost": 55}, {"name": "Ransacked Shield", "description": "+12% Dodge chance for 3 turns", "cost": 60}, {"name": "Unbuilded Shield", "description": "+23% Dodge Chance for 5 turns", "cost": 90}, {"name": "Mystic Scroll", "description": "25% chance to negate all debuffs on player for 4 turns", "cost": 60}, {"name": "Mystic Beurau", "description": "50% chance to negate all debuffs on player for 4 turns", "cost": 120}, {"name": "Variant Bs", "description": "Increase all stats up to 25% for 10 turns", "cost": 200}, {"name": "Variant Ex", "description": "Increase all stats up to 50% for 10 turns", "cost": 400}, {"name": "Hide cloak", "description": "40% chance to dodge the battle against enemies when exploring", "cost": 50}, {"name": "Invisible potion", "description": "60% chance to dodge the battle against enemies when exploring", "cost": 75}, {"name": "Exp Moneter", "description": "Give you 20 exp points", "cost": 50}, {"name": "Exp Vitalis", "description": "Give you 50 exp points", "cost": 100}, {"name": "Exp For enhancer", "description": "Give you 100 points", "cost": 150} ], "Weapons": [ {"name": "Stone Sword", "description": "+12 attack", "cost": 150}, {"name": "Copper Sword", "description": "+15 attack", "cost": 275}, {"name": "Sickanum Sword", "description": "+17 attack", "cost": 400}, {"name": "Arivanum Sword", "description": "+23 attack", "cost": 600}, {"name": "Viranium Sword", "description": "+25 attack", "cost": 850}, {"name": "Titanium sword", "description": "+35 attack", "cost": 1250} ], "Armors": [ {"name": "Jungle sets", "description": "+7 Defense", "cost": 90}, {"name": "Byzantine sets", "description": "+12 Defense", "cost": 140}, {"name": "Nikel Sets", "description": "+15 Defense", "cost": 350}, {"name": "Warhead Sets", "description": "+25 Defense", "cost": 560}, {"name": "Titanium Sets", "description": "+40 Defense", "cost": 850} ], "Shields": [ {"name": "Wooden Ob", "description": "+2 dodge", "cost": 80}, {"name": "Long Ob", "description": "+3 dodge, +2 Defense", "cost": 120}, {"name": "Cob Ob", "description": "+5 dodge, +4 Defense", "cost": 300}, {"name": "Knock Ob", "description": "+7 dodge, +5 Defense, +3 Attack", "cost": 550}, {"name": "Neb Ob", "description": "+12 dodge, +7 Defense, +5 Attack", "cost": 760} ], "Footwear": [ {"name": "Jungle Foot", "description": "+3 speeds", "cost": 45}, {"name": "Iron Foot", "description": "+5 Speed", "cost": 75}, {"name": "Metal WarFoot", "description": "+8 Speeds", "cost": 120}, {"name": "Diamond Boots", "description": "+12 Speeds", "cost": 230}, {"name": "Noble Boots", "description": "+19 Speeds", "cost": 450}, {"name": "Lizable Boots", "description": "+25 Speeds", "cost": 700} ] } def create_character(): clear_screen() print("Character Creation") name = input("Enter your character's name: ") clear_screen() print(f"Character Name: {name}\n") while True: print("Select Difficulty:") print("1. Basic 🛡️") print("2. Exemplar ⚔️") print("3. Templar ☠️") difficulty_choice = input("Enter the number to select difficulty: ") if difficulty_choice == "1": difficulty = "Basic" description = "Enemies are powerful in their origins." elif difficulty_choice == "2": difficulty = "Exemplar" description = "Enemies are harder and more immortalized." elif difficulty_choice == "3": difficulty = "Templar" description = "Enemies are evils." else: print("Invalid difficulty choice. Please choose a valid option.") time.sleep(1) clear_screen() continue clear_screen() print("Selected Difficulty:") print(f"Name: {name}") print(f"Difficulty: {difficulty}") print(f"Description: {description}\n") print("1. Confirm") print("2. Back") confirm_choice = input("Enter your choice: ") if confirm_choice == "1": break elif confirm_choice == "2": clear_screen() continue else: print("Invalid choice. Please enter 1 to confirm or 2 to go back.") time.sleep(1) clear_screen() return Player(name, difficulty) def clear_screen(): """Clears the console screen.""" os.system('cls' if os.name == 'nt' else 'clear') def main_menu(): clear_screen() print("BeaVenture\n") print("1. Create Character") print("2. Exit") print("\nEnter the number to select an option.") def main(): while True: main_menu() try: choice = int(input("")) if choice == 1: player = create_character() player.display_status() elif choice == 2: clear_screen() print("Exiting BeaVenture. Goodbye!") time.sleep(2) clear_screen() print("Game Was Ended") input("Press Enter to exit...") clear_screen() break else: print("Invalid option. Please enter a valid number.") time.sleep(2) except ValueError: print("Invalid input. Please enter a number.") if __name__ == "__main__": main()
BankAccount.java import java.util.Scanner; public class BankAccount { String name; private double balance; private int depositCount = 0; private int withdrawCount = 0; private String accountType; public void deposit(double amount){ balance += amount; System.out.println(amount + " is successfully Deposited"); depositCount++; if(balance > 100000){ balance = balance + (amount / 100); } } public void setAccountType(String type){ this.accountType = type; } public void withdraw(double amount){ if(balance >= amount){ if(balance - amount < 50000){ System.out.println("Asre you sure you want to withdraw, it would make your balance below 50,000"); System.out.println("Press 1 to continue and 0 to abort"); Scanner input = new Scanner(System.in); int confirm = input.nextInt(); if(confirm != 1){ System.out.println("Withdrawal aborted"); return; } } double withdrawAmount = amount; if(balance < 50000){ withdrawAmount = withdrawAmount + amount * 0.02; withdrawCount++; } balance = balance - withdrawAmount; System.out.println(withdrawAmount + " is successfully withdrawn"); } else{ System.out.println("Insufficient funds"); } } public double getBalance(){ return balance; } public void subscribeSmsAlert(){ if(accountType.equals("STANDARD")){ balance -= 2000; } } public void subscribeDebitCard(){ if(accountType.equals("STANDARD")){ balance -= 5000; } } void transaction(){ System.out.println("Account title: " + name); System.out.println("Total deposit: " + depositCount); System.out.println("Total withdraw: " + withdrawCount); System.out.println("Balance: " + balance); } } ////////////////////////////////////////////////////////////////////////////////////// //BankAccountTest.Java import java.util.Scanner; public class BankAccountTest{ public static void main(String args[]){ BankAccount account = new BankAccount(); Scanner input = new Scanner(System.in); account.name = "Maan"; System.out.println("Enter the account type: "); String accountType = input.nextLine(); account.setAccountType(accountType); System.out.println("Do want to subscribe SMS alerts(Y or N): "); String sms = input.nextLine(); if(sms.equals("Y") || sms.equals("y")){ account.subscribeSmsAlert(); } System.out.println("Do you want to subscribe Debit Card(Y or N): "); String debit = input.nextLine(); if(debit.equals("Y") || debit.equals("y")){ account.subscribeDebitCard(); } int choice; do{ System.out.println("Press 1: To Deposit an amount\nPress 2: To Withdraw an amount\nPress 3: To View the current balance\nPress 4: To Close the program"); choice = input.nextInt(); switch(choice){ case 1: System.out.println("Enter the amount you want to Deposite"); double depositeAmount = input.nextDouble(); account.deposit(depositeAmount); break; case 2: System.out.println("Enter the amount you want to withdraw"); double withdrawAmount = input.nextDouble(); account.withdraw(withdrawAmount); break; case 3: System.out.println("Your current balance is " + account.getBalance()); break; case 4: System.out.println("The program is terminated"); account.transaction(); break; default: System.out.println("Incorrect choice. Please try again!"); break; } }while(choice!=4); } }
SELECT * from strings; ---------+ S | ---------+ coffee | ice tea | latte | tea | [NULL] | ---------+ SELECT * FROM strings WHERE CONTAINS(s, 'te'); ---------+ S | ---------+ ice tea | latte | tea | ---------+
curl --request POST \ --url 'https://api.apyhub.com/convert/rss-file/json?detailed=true' \ --header 'apy-token: APY0BOODK2plpXgxRjezmBOXqID51DGpFq8QnHJeBQrrzuIBc25UIglN93bbwvnkBWlUia1' \ --header 'content-type: multipart/form-data' \ --form 'file=@"test.xml"'
curl --request POST \ --url 'https://api.apyhub.com/convert/word-file/pdf-file?output=test-sample.pdf&landscape=false' \ --header 'apy-token: APY0BOODK2plpXgxRjezmBOXqID51DGpFq8QnHJeBQrrzuIBc25UIglN93bbwvnkBWlUia1' \ --header 'content-type: multipart/form-data' \ --form 'file=@"test.doc"'
curl --request POST \ --url 'https://api.apyhub.com/generate/charts/bar/file?output=sample.png' \ --header 'Content-Type: application/json' \ --header 'apy-token: APY0BOODK2plpXgxRjezmBOXqID51DGpFq8QnHJeBQrrzuIBc25UIglN93bbwvnkBWlUia1' \ --data '{ "title":"Simple Bar Chart", "theme":"Light", "data":[ { "value":10, "label":"label a" }, { "value":20, "label":"label b" }, { "value":80, "label":"label c" }, { "value":50, "label":"label d" }, { "value":70, "label":"label e" }, { "value":25, "label":"label f" }, { "value":60, "label":"label g" } ] }'
curl --request POST \ --url 'https://api.apyhub.com/generate/charts/bar/file?output=sample.png' \ --header 'Content-Type: application/json' \ --header 'apy-token: APY0BOODK2plpXgxRjezmBOXqID51DGpFq8QnHJeBQrrzuIBc25UIglN93bbwvnkBWlUia1' \ --data '{ "title":"Simple Bar Chart", "theme":"Light", "data":[ { "value":10, "label":"label a" }, { "value":20, "label":"label b" }, { "value":80, "label":"label c" }, { "value":50, "label":"label d" }, { "value":70, "label":"label e" }, { "value":25, "label":"label f" }, { "value":60, "label":"label g" } ] }'
curl --request POST \ --url 'https://api.apyhub.com/generate/qr-code/file?output=sample.png' \ --header 'Content-Type: application/json' \ --header 'apy-token: APY0BOODK2plpXgxRjezmBOXqID51DGpFq8QnHJeBQrrzuIBc25UIglN93bbwvnkBWlUia1' \ --data '{ "content": "https://apyhub.com", "logo": "https://apyhub.com/logo.svg", "background_color": "#000000", "foreground_color": ["#e8bf2a", "#e8732a"] }'
[ { "$match": { "partnerShortCode": { "$in": [] } } }, { "$group": { "_id": "$partnerShortCode", "clinics": { "$push": { "clinicName": "$name", "clinicId": "$_id" } } } }, { "$project": { _id:0, "partnerShortCode": "$_id", "clinics": 1 } } ]
<?php require_once 'dc.php'; error_reporting(0); echo "<div class='ris'>"; if ($_SERVER["REQUEST_METHOD"] == "POST") { // reCAPTCHA verify $recaptchaSecretKey = '6Lf7Yw8pAAAAAMS-xv8MsdtMQRHgxQ2V-3ZSndxM'; $recaptchaResponse = $_POST['g-recaptcha-response']; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://www.google.com/recaptcha/api/siteverify"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array( 'secret' => $recaptchaSecretKey, 'response' => $recaptchaResponse ))); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); //end reCAPTCHA if(isset($_POST['remember_me'])) { // Usuario marcó "Recuérdame", establecer cookie para 30 días setcookie('username', $_POST['username'], time() + (86400 * 30), "/"); } else { // Usuario no marcó "Recuérdame", eliminar cookie si existe if(isset($_COOKIE['username'])) { // Establecer el tiempo de expiración en el pasado para eliminarla setcookie('username', '', time() - 3600, "/"); } } // Decodificar la respuesta $responseKeys = json_decode($response, true); if (intval($responseKeys["success"]) !== 1) { // CAPTCHA failed header("Location: user-incorrect.php?ms=3"); exit(); } else { $user = mysqli_real_escape_string($mysqli, $_POST['username']); $pass = $_POST['password']; // Consulta de inicio de sesión $sql = "SELECT user.u_code AS u_code, user.nombre, user.pswr AS password, docentes.cedula AS username, user.level AS nivel FROM user INNER JOIN docentes ON docentes.d_code = user.nombre WHERE docentes.cedula = ?"; $stmt = $mysqli->prepare($sql); $stmt->bind_param("s", $user); $stmt->execute(); $result = $stmt->get_result(); $numregis = $result->num_rows; if ($numregis > 0) { $row = $result->fetch_assoc(); // Verificar PSWD if (password_verify($pass, $row['password'])) { session_start(); $_SESSION['estarted'] = true; $_SESSION['UNI_CODE'] = $row['u_code']; $_SESSION['MM_Username'] = $row['username']; $_SESSION['MM_UserGroup'] = $row['nombre']; $_SESSION['MM_Level'] = $row['nivel']; $_SESSION['u_code']=$row['u_code']; switch ($_SESSION['MM_Level']) { case 1: // ADMINER header("Location: ../noaAdminer/pag0.php"); exit(); case 2: // SECRETARIAS header("Location: ../noaAdmin/index.php"); exit(); case 3: // DOCENTES header("Location: ../noaCV/index.php"); exit(); case 4: // PRACTICAS header("Location: ../pracVIN/index.php"); exit(); case 5: // VINCULACION header("Location: ../noaLogos/navybar/mono/index.php"); exit(); case 6: // INSPECTORES header("Location: ../ASISTOR/index.php"); exit(); case 8: // ALUMNOS header("Location: ../noaAlumnos/index.php"); exit(); case 9: // ADMIN_vinc header("Location: ../noaLogos/navybar/maister\index1.php"); exit(); default: header("Location: ../index.php"); exit(); } } else { header("Location: user-incorrect.php?ms=1"); die(); } } else { header("Location: user-incorrect.php?ms=2"); die(); } $_SESSION['estarted'] = false; } } $mysqli->close(); ?> </div>
handleCodeChange(event) { let codeLength = event.target.value.length; if(codeLength === 6) { const selectedEvent = new CustomEvent("showvalidatebutton", { detail: { codeReceivedFromCustomer: event.target.value, codeSentToCustomer: this.completeCode.toString() } }); this.dispatchEvent(selectedEvent); } else { this.dispatchEvent(new CustomEvent('hidevalidatebutton')); } }
class msRichards { protected public void favClass() { System.out.println("My FAVOURITE Class is..."); } } class course extends msRichards { private String courseName = "ICS4U"; public static void main(String[] args) { course myCourse = new course(); myCourse.favClass(); System.out.println( myCourse.grade + " " + myCourse.courseName + "!"); } } class Main { public static void main(String[] args) { msRichards newCourse = new course(); msRichards firstCourse = new courseICS3U(); msRichards secondCourse = new courseICS4U(); newCourse.favClass(); newCourse.favClass(); newCourse.favClass(); }
<li> <form action="../Connections/kiler.php" method="POST"> <button type="submit" name="logout" style="background: none; border: none; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer;"> Salir </button> </form> </li> <li> <a href="" target="_self"> <form action="../../../Connections/kiler.php" method="POST"> <button type="submit" name="logout" style="background: none; border: none; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer;"> <i class="fa fa-power-off" aria-hidden="true"></i> <span id="salirSpan">Salir</span> </button> </form> </a> </li>
xCardMemNumber is int HRead (Members,hRecNumCurrent) //info(Members.Member_Number) QRY_MembersCardprint.ParamMember_Number = Members.Member_Number //info(QRY_MembersCardprint.ParamMember_Number) HExecuteQuery(QRY_MembersCardprint) //Trace("YResolution = " + iParameter(iYResolution)) iDestination(iViewer) //iParameter(iYResolution, 300) iPrintReport(RPT_Card)
Select the chart duration :
#include <stdio.h> #include<math.h> int main() { int a, b, order; char choice ; printf("Enter : \n A = for arithmetic operations. \n N = for exponents of a number. \n D = for Area/Volume of 2 and 3-Dimentional figures. \n C = for Condition checking(greater/or smaller and for to check Even/or odd . \n: "); scanf("%c", &choice); if (choice == 'A' ) { printf("Enter a numbers a:\n"); scanf("%d", &a); printf("Enter a numbers b:\n"); scanf("%d", &b); printf("Enter 1 for operations from a to b or 2 for operations from b to a: "); scanf("%d", &order); if (order == 1 ) { int sum = a + b; int difference = a - b; int product = a * b; float quotient = (float)a / b; // Cast to float for potential division by 0 printf("Results (a to b):\n"); printf("Sum: %d\n", sum); printf("Difference: %d\n", difference); printf("Product: %d\n", product); printf("Quotient: %.2f\n", quotient); // Format quotient with 2 decimal places } else if (order == 2) { int sum = b + a; int difference = b - a; int product = b * a; float quotient = (float)b / a; // Cast to float for potential division by 0 printf("Results (b to a):\n"); printf("Sum: %d\n", sum); printf("Difference: %d\n", difference); printf("Product: %d\n", product); printf("Quotient: %.2f\n", quotient); // Format quotient with 2 decimal places } else { printf("Invalid order. Please enter 1 or 2 \n"); } } if (choice == 'N' ) { int base, exponent, power = 1; // Initialize power to 1 printf("Enter the base number: "); scanf("%d", &base); printf("Enter the exponent (power): "); scanf("%d", &exponent); // Handle negative exponents (optional) if (exponent < 0) { printf("Error: Exponents cannot be negative.\n"); return 1; // Indicate error } // Calculate the power using a loop for (int i = 1; i <= exponent; ++i) { power *= base; // Multiply power by base in each iteration } printf("%d raised to the power of %d is %d.\n", base, exponent, power); } if ( choice == 'D') { float l , b ,c , h , r , m , n , x , y , f ; char ch ; printf("Enter : A = for finding Area of 2D figures.\n V = for finding Volume of a 3D figures :"); scanf(" %c", &ch); if ( ch == 'A') { char ch; printf(" Enter : \n k = for area of a square . \n R = for area of a Rectangle . \n p = for area of a Parallelogram .\n T = for area of a Trapezium . \n t = for area of a Triangle .\n E = for area of a Equilateral Triangle . \n P = for area of a Pentagone .\n H = for area of a Hexagone. \n O = for area of a Octagone . \n a = for area of a Annulus. \n C = for area of a Circle , \n S = for Sector area of a circle.\n s = for Segment area of a circle. \n e = for area of a Ellipse"); scanf(" %c" , &ch); if ( ch == 'k') { printf(" Enter the side of a square"); scanf(" %f", &l); f = l*l ; printf(" Area of a Square is : %f", f ); } if ( ch == 'R') { printf("Enter the Length of a Rectangle :"); scanf(" %f" , &l); printf(" Enter the Breadth of a Rectangle :"); scanf(" %f" , &b); f = l*b ; printf(" Area of a Rectangle is : %f" , f); } if ( ch == 'p') { printf("Enter the Length of a Parallelogram:"); scanf(" %f" , &l); printf(" Enter the height of a Parallelogram :"); scanf(" %f" , &b); f = l*b ; printf(" Area of a Parallelogram is : %f" , f); } if ( ch == 'T') { printf("Enter First parallel side of a Trapezium :"); scanf(" %f" , &l); printf(" Enter the Second parallel side of a Trapezium :"); scanf(" %f" , &b); printf(" Enter the Height of a Trapezium :"); scanf(" %f", &h ); f = 0.5*(l + b)*h ; printf(" Area of a Trapezium is : %f" , f); } if ( ch == 't') { printf(" Enter the Breadth of a Triangle :"); scanf(" %f ", &b); printf(" Enter the Height of the Triangle :"); scanf(" %f", &h); f = 0.5*(b*h) ; printf(" Area of a Triangle is : %f" , f); } if ( ch == 'E') { printf(" Enter the Side of an Equilateral Triangle :"); scanf(" %f ", &b); f = sqrt(3.0)/4 * b * b; printf(" Area of an Equilateral Triangle is : %f" , f); } if ( ch == 'P') { printf(" Enter the Radius enclosed under the Pentagon :"); scanf(" %f ", &b); f = 5.0/8.0 * b * b * sqrt( 10 + 2*sqrt(5)) ; printf(" Area of a Pentagone is : %f" , f); } if ( ch == 'H') { printf(" Enter the side of a Hexagone :"); scanf(" %f", &b); f = 1.0 * b * b * sqrt( 2 ) ; printf(" Area of a Hexagone is : %f", f); } if ( ch == 'O') { printf("Enter the side of a Octagone :"); scanf(" %f", &b); f = 6.64*b ; printf("Area of a Octagone is : %f", f); } if ( ch == 'C') { printf(" Enter the Radius of a Circle :"); scanf(" %f", &b); f = M_PI * b * b ; printf(" Area of a Circle is : %f", f); } if ( ch == 'a') { printf(" Enter the minor diameter is a CIrcle :"); scanf(" %f", &b); printf(" Enter the major diameter of a Circle :"); scanf(" %f", &l); f = M_PI/4.0 *b*b*l*l ; printf(" Area of a Annulus is : %f" , f); } if ( ch == 'S') { printf(" Enter the radius of a sector :"); scanf(" %f", &b ); printf(" Enter the arc of a sector :"); scanf(" %f" , &l); f = 0.5 * l * b ; printf(" Area of a sector is : %f", f); } if ( ch == 's') { double angle_degrees, sin_value; printf(" Enter the segment radius :"); scanf(" %f", &b); // Prompt user to enter angle in degrees printf("Enter the angle in degrees (0 to 360): "); scanf("%lf", &angle_degrees); // Calculate sine value sin_value = sin(angle_degrees * M_PI / 180.0); // Convert degrees to radians f = 0.5 * ( (angle_degrees * M_PI / 180.0) - sin_value ) *b*b ; } if ( ch == 'e') { printf(" Enter the major axis radius of an Ellipse :"); scanf( " %f " , &b); printf(" Enter the minor axis radius of the Ellipse :");l scanf(" %f", &l); f = M_PI * b * l ; printf(" Area of an Ellipse is : %f", f); } } if ( ch == 'V') { float a , b , c , l , b , h , f , c ; int chh ; printf("Enter: \n"); printf("1 = for finding Volume of a Cube.\n"); printf("2 = for finding Volume of a Cuboid.\n"); printf("3 = for finding Volume of a Parallelepiped.\n"); printf("4 = for finding Volume of a Pyramid.\n"); printf("5 = for finding Volume of a Frustum of Pyramid.\n"); printf("6 = for finding Volume of a Cylinder.\n"); printf("7 = for finding Volume of a Hollow Cylinder.\n"); printf("8 = for finding Volume of a Cone.\n"); printf("9 = for finding Volume of a Frustum of a Cone.\n"); printf("10 = for finding Volume of a Barrel.\n"); printf("11 = for finding Volume of a Sphere.\n"); printf("12 = for finding Volume of a Zone of a Sphere.\n"); printf("13 = for finding Volume of a Segment of a Sphere.\n"); printf("14 = for finding Volume of a Sector of a Sphere.\n"); printf("15 = for finding Volume of a Sphere with Cylinder.\n"); printf("16 = for finding Volume of a Sphere with Two Cones.\n"); printf("17 = for finding Volume of a Sliced Cylinder.\n"); printf("18 = for finding Volume of an Ungulla. \n"); scanf("%d", &chh); if ( chh == 1) { printf(" Enter the Side of the Cube :"); scanf("%f", &a); f = a*a*a ; printf(" Volume is : %f", f); } if ( chh == 2) { printf(" Enter the Length of a Cuboid :"); scanf(" %f", &l); printf(" Enter the Breadth of the Cuboid :"); scanf(" %f", &b); printf(" Enter the Height of a Cuboid :"); scanf(" %f", &h); f = l*b*h ; printf("Volume of a Cuboid : %f", f); } if ( chh == 4) { printf(" Enter the Base Length of a Pyramid :"); scanf(" %f", &l); printf(" Enter the Base Width of a Pyramid :"); scanf(" %f", &b); printf(" Enter the Height of a Pyramid:"); scanf(" %f", &h); f = 1.0/3.0 * (l*b*h) ; printf(" Volume of a Pyramid is : %f " ,f); } if ( chh == 5) { printf(" Enter the Base Length of a Frustum of Pyramid :"); scanf(" %f", &l); printf(" Enter the Base Width of Frustum of Pyramid :"); scanf(" %f", &b); printf(" Enter the smaller Base Length of a Frustum of Pyramid :"); scanf(" %f", &a); printf(" Enter the Smaller Base Width of Frustum of Pyramid :"); scanf(" %f", &c); printf(" Enter the Height of a Pyramid Frustum:"); scanf(" %f", &h); f =1.0/3.0 * h*( l*b*a*c + sqrt( a*b*l*c)) ; printf( " Vloume of a Frustum of Pyramid is : %f", f); } if ( chh == 6) { printf(" Enter the Diameter of a Cylinder : "); scanf(" %f", &l); printf(" Enter the Height of a Cylinder:"); scanf(" %f", &h); f = 1.0/4.0 * M_PI * l*l * h ; printf(" Volume of a Cylinder is : %f ", f); } if ( chh == 7) { printf(" Enter the Bigger Diameter of a Hollow Cylinder : "); scanf(" %f", &l); printf(" Enter the Smaller Diameter of a Hollow Cylinder : "); scanf(" %f", &a); printf(" Enter the Height of a Cylinder:"); scanf(" %f", &h); f = 1.0/4.0 * M_PI * ( l*l - a*a); printf(" Volume of a Hollow Cylinder is : %f ", f); } if ( chh == 8) { printf(" Enter the Radius of a Cone : "); scanf(" %f", &l); printf(" Enter the Height of a Cylinder:"); scanf(" %f", &h); f = 1.0/3.0 * M_PI * l*l*h ; printf("Volume of a cone is : %f", f); } if ( chh == 3) { printf(" Enter the Length of a Parallelepiped:"); scanf(" %f", &l); printf(" Enter the Breadth of the Parallelepiped:"); scanf(" %f", &b); printf(" Enter the Height of a Parallelepiped :"); scanf(" %f", &h); f = l*b*h ; printf("Volume of a Parallelepiped : %f", f); } if ( chh == 9) { printf(" Enter the Larger Diameter of a Frustum of a Cone : "); scanf(" %f", &l); printf(" Enter the Smaller Diameter of a Frustum of a Cone : "); scanf(" %f", &b); printf(" Enter the Height of a Cylinder:"); scanf(" %f", &h); f = h*M_PI * ( l*l + l*b + b*b) * 1.0/12.0 ; printf(" Volume of a Frustum of Cone is : %f", f); } if ( chh == 10) { printf(" Enter the Larger Diameter of a Barrel: "); scanf(" %f", &l); printf(" Enter the Smaller Diameter of a Barrel : "); scanf(" %f", &b); printf(" Enter the Height of a Barrel:"); scanf(" %f", &h); f = M_PI * h * ( 2*l*l + b*b ) * 1.0/ 12.0 ; printf(" Volume of a Barrel is : %f", f); } if ( chh == 11) { printf(" Enter the Diameter of the Sphere :"); scanf("%f", &l); f = M_PI * l*l*l * 1.0/6.0 ; printf(" Volume of a Sphere is : %f", f); } if ( chh == 12) { printf(" Enter the Bigger Radius of Zone of the Sphere :"); scanf("%f", &l); printf(" Enter the Smaller Radius of Zone of the Sphere :"); scanf("%f", &b); printf(" Enter the Height of a Zone of a Sphere:"); scanf(" %f", &h); f = M_PI * h * ( 3*l*l + 3*b*b + h*h); printf("Volume of a Zone of a Sphere is : %f", f); } if ( chh == 13) { printf(" Enter the Diameter of a Segment of a Sphere :"); scanf("%f", &l); printf(" Enter the Height of a Segment of a Sphere :"); scanf("%f", &b); f = M_PI * h * ( 3.0/4.0 * l*l + h*h); printf(" Vomume of a Segment of a Sphere is : %f", f); } if ( chh == 14) { printf(" Enter Radius of a Sector Sphere :"); scanf("%f", &l); printf(" Enter the Height of the Sector of a sphere:"); scanf("%f", &b); f = 2.0/3.0 * M_PI * l*l * b ; printf(" Volume of a sector of a Sphere is : %f", f); } if ( chh == 15) { printf(" Enter the Height of a Sphere with a Cylinder:"); scanf("%f", &l); f = 1.0/6.0 * l*l*l ; printf(" VOlume of a Sphere with a Cylinder is : %f", f); } if ( chh == 16) { printf(" :"); scanf("%f", &l); printf(" Enter the Smaller Radius of Zone of the Sphere :"); scanf("%f", &b); } if ( chh == 17) { printf(" Enter the Diameter of a Sliced Cylinder:"); scanf(" %f ", &l); printf(" Enter the Height of a Sliced Cylinder :"); scanf(" %f ", &b); f = M_PI * 1.0/4.0 * l*l * b ; printf(" Volume of a Sliced Cylinder is : %f", f); } if ( chh == 18) { printf(" Enter Radius of an Ungulla :"); scanf(" %f", &l); printf(" Enter the height of an Ungulla :"); scanf(" %f", &b); f = 2.0/3.0 * l*l * b ; printf(" Volume of an Ungulla :%f", f); } } } if ( choice == 'C' ) { } return 0 ; }
function isPartialMatch(stokenM, tagM) { const minLength = Math.min(stokenM.length, tagM.length); for (let i = 0; i < minLength; i++) { if (stokenM[i] !== tagM[i]) { // If characters don't match, return false return false; } } return true; }
@page @model WebUI.Pages.Shared.ServitörVyModel @{ var swedishTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time"); var nowSwedishTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, swedishTimeZone); } <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Välj Bord</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet"> <link rel="stylesheet" type="text/css" href="css/StyleFoodMenu.css" asp-append-version="true"> <style> .table-button { width: 100%; margin-bottom: 20px; height: 60px; } .iframe-container { width: 100%; border: none; height: 400px; } </style> </head> <div class="container" style="display:flex; flex-direction:column;" > <button class="btn btn-warning" id="offcanvasbutton" style=" color:black;" type="button" data-bs-toggle="offcanvas" data-bs-target="#offcanvasBottom" aria-controls="offcanvasBottom">Toggle bottom offcanvas</button> <div id="accordion"> <div class="card"> <button class="btn btn-warning" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne"> Välj bord </button> <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion"> <div class="card-body"> Välj bord <select id="tableSelect" class="form-control"> @foreach (var table in Model.TablesProp) { <option value="@table.Number">@table.Number</option> } </select> <button class="btn btn-success" id="confirmButton">Bekräfta </button> </div> </div> </div> <div class="card"> <button class="btn btn-warning collapsed" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree"> Beställning </button> <div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordion"> <div class="card-body"> <button class="btn btn-success" id="orderButton">Ny Beställning </button> </div> </div> </div> <div class="card"> <button class="btn btn-warning collapsed" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo"> Välj maträtt </button> <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion"> <div class="card-body"> <div class="row special-list"> @if (Model.Foods != null) { foreach (var food in Model.Foods) { if ((food.PublishDate == null || food.PublishDate <= nowSwedishTime) && (food.RemoveDate == null || food.RemoveDate > nowSwedishTime)) { <div class="col-lg-4 col-md-6 special-grid menu-card" data-food-id="@food.Id" data-food-title="@food.Title" data-food-description="@food.Description" data-food-price="@food.Price" data-food-category="@food.Category" data-food-ingredients="@food.Ingredients"> <div class="gallery-single fix"> @if (!string.IsNullOrEmpty(food.ImagePath)) { <img src="@Url.Content($"~/{food.ImagePath}")" class="img-fluid" alt="Bild av @food.Title"> } <div class="why-text"> @if (User.IsInRole("Admin") || User.IsInRole("Owner")) { <div class="options-menu" style="display:none;"> </div> } <h4>@food.Title</h4> <button class="button btn-success add-to-cart" id="addtocart" data-food-id="@food.Id">Lägg till</button> <h5>@food.Price kr</h5> </div> </div> </div> } } } </div> </div> </div> </div> </div> </div> <title>Offcanvas Button Example</title> <!-- Include Bootstrap CSS --> <div class="offcanvas offcanvas-bottom" tabindex="-1" id="offcanvasBottom" aria-labelledby="offcanvasBottomLabel"> <div class="offcanvas-header"> <h5 class="offcanvas-title" id="offcanvasBottomLabel">Offcanvas bottom</h5> <button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button> </div> <div class="offcanvas-body small" id="ordersContainer"> </div> </div> <button class="btn-btn btn-success" id="confirmorder"> Bekräfta beställning </button> <!-- Include Bootstrap JavaScript (popper.js and bootstrap.js are also required) --> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.11.6/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/5.3.0/js/bootstrap.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> <script> document.getElementById('confirmButton').addEventListener('click', function () { // Get the selected table number var selectedTableNumber = document.getElementById('tableSelect').value; // Do something with the selected table number console.log('Selected table number:', selectedTableNumber); // You can perform further actions here, such as sending the selected table number to the server // using AJAX or submitting a form. }); let orderId; let guest; let waiter; let date; let receit let status let table; //POST Order document.getElementById('orderButton').addEventListener('click', function () { // Prepare the order data const currentDate = new Date(); const orderData = { table:document.getElementById('tableSelect').value }; // Send the order data to the server using Fetch API fetch('/api/Order/', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(orderData) }) .then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); }) .then(data => { // Handle the response data if needed console.log('Order created successfully:', data); console.log('Order Id: ', data.id) console.log('Order Guest: ', data.guest) console.log('Order Table: ', data.table ) console.log('Order WaiterId: ', data.waiterId) console.log('Order Date: ', data.date) console.log('Order ReceitId: ', data.receitId) console.log('Order Status: ', data.status) date = order.date; orderId = data.id; guest = data.guest; table = data.table; waiter = data.waiterId; receit = data.receitId; status = data.status; // You can redirect or show a success message here }) .catch(error => { console.error('There was a problem with your fetch operation:', error); // Handle errors appropriately, e.g., show an error message to the user }); }); //POST OrderItem document.querySelectorAll('.add-to-cart').forEach(item => { item.addEventListener('click', function () { var foodId = $(this).data('food-id'); var data = { FoodId: foodId, Quantity: 1, OrderId: orderId }; fetch('/api/OrderItem/', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); }) .then(data => { // Handle success console.log('Success:', data); }) .catch(error => { // Handle error console.error('Error:', error); }); }); }); //GET OrderItems function fetchOrders() { fetch(`/api/OrderItem/?columnName=orderid&columnValue=${orderId}`) .then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); }) .then(data => { // Work with the JSON data retrieved from the endpoint const ordersContainer = document.getElementById('ordersContainer'); // Clear existing content ordersContainer.innerHTML = ''; // Iterate over the data and append to the container data.forEach(order => { const orderElement = document.createElement('div'); orderElement.textContent = `Quantity: ${order.quantity} FoodId:${order.foodId}, OrderId: ${order.orderId}`; ordersContainer.appendChild(orderElement); }); }) console.log() .catch(error => { console.error('There was a problem with the fetch operation:', error); }); } document.getElementById('confirmorder').addEventListener('click', function () { const itemIdToUpdate = orderId; // Example item ID to update const updatedData = { id : orderId, guest : guest, table : table, waiterId : waiter, date : date, receitId : receit, confirmed : true, status : status // Example updated data for the item // Add other fields as needed }; // Construct the URL targeting the specific item const url = `/api/Order/${itemIdToUpdate}`; // Prepare the request object const requestOptions = { method: 'PUT', // or 'PATCH' depending on the server's API headers: { 'Content-Type': 'application/json', // Specify content type as JSON // Add any other headers if required }, body: JSON.stringify(updatedData), // Convert data to JSON format }; // Send the request fetch(url, requestOptions) .then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); // Parse response JSON if needed }) .then(data => { // Handle successful response (if required) console.log('Item updated successfully:', data); }) .catch(error => { // Handle errors console.error('There was a problem updating the item:', error); }); }); // Attach an event listener to the button const refreshButton = document.getElementById('addtocart'); refreshButton.addEventListener('click', fetchOrders); const refreshButton2 = document.getElementById('offcanvasbutton'); refreshButton2.addEventListener('click', fetchOrders); </script>
Sun Mar 24 2024 03:20:38 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/18561424/using-for-strings-in-a-loop-is-it-bad-practice
Sat Mar 23 2024 21:49:49 GMT+0000 (Coordinated Universal Time) https://www.thiscodeworks.com/dark-light-mode-toggle-javascript-javascript/6512e47034967700139f79ad
Sat Mar 23 2024 21:46:11 GMT+0000 (Coordinated Universal Time) https://www.thiscodeworks.com/bootstrap-4-6-0-the-default-breakpoints-css/64bba96cef21fa0013a53a7d
Sat Mar 23 2024 21:43:32 GMT+0000 (Coordinated Universal Time) https://www.thiscodeworks.com/carousel-bootstrap-v5-2/6366e1c243f3120015119587
Sat Mar 23 2024 21:41:55 GMT+0000 (Coordinated Universal Time) https://www.thiscodeworks.com/150-bootstrap-navbar-examples-free-generator-creator-html/639e04f3a245070015bd15ac
Sat Mar 23 2024 20:54:01 GMT+0000 (Coordinated Universal Time) https://www.thiscodeworks.com/dynamic-copyright-footer/65faf918999e0a001433ac25
Sat Mar 23 2024 20:51:53 GMT+0000 (Coordinated Universal Time) https://www.thiscodeworks.com/doc-to-pdf-conversion-api-data/65fdb54b05080e0014aed7ba
Sat Mar 23 2024 20:32:16 GMT+0000 (Coordinated Universal Time) https://www.thiscodeworks.com/images-bootstrap-center/638e2bcf80f66300158ca522
Sat Mar 23 2024 13:53:29 GMT+0000 (Coordinated Universal Time) https://darkwebmarketbuyer.com/product/red-xanax-bar/
Sat Mar 23 2024 09:51:44 GMT+0000 (Coordinated Universal Time) <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
Sat Mar 23 2024 07:05:44 GMT+0000 (Coordinated Universal Time) https://www.geeksforgeeks.org/problems/first-negative-integer-in-every-window-of-size-k3345/1
Fri Mar 22 2024 18:41:13 GMT+0000 (Coordinated Universal Time) https://darkwebmarketbuyer.com/product/cake-delta-8-510-cartridge-2g/
Fri Mar 22 2024 18:03:52 GMT+0000 (Coordinated Universal Time) https://docs.snowflake.com/en/sql-reference/functions/contains
Fri Mar 22 2024 16:44:48 GMT+0000 (Coordinated Universal Time) https://apyhub.com/utility/converter-rss-json
Fri Mar 22 2024 16:43:55 GMT+0000 (Coordinated Universal Time) https://apyhub.com/utility/converter-doc-pdf
Fri Mar 22 2024 16:42:46 GMT+0000 (Coordinated Universal Time) https://apyhub.com/utility/bar-graph
Fri Mar 22 2024 16:42:45 GMT+0000 (Coordinated Universal Time) https://apyhub.com/utility/bar-graph
Fri Mar 22 2024 16:41:45 GMT+0000 (Coordinated Universal Time) https://apyhub.com/utility/generate-qr-code
Fri Mar 22 2024 16:40:29 GMT+0000 (Coordinated Universal Time) https://apyhub.com/utility/analyse-keywords
Fri Mar 22 2024 16:37:26 GMT+0000 (Coordinated Universal Time) http://34.74.16.180:3000/question#eyJkYXRhc2V0X3F1ZXJ5Ijp7InR5cGUiOiJuYXRpdmUiLCJuYXRpdmUiOnsiY29sbGVjdGlvbiI6ImNsaW5pY3MiLCJxdWVyeSI6IltcclxuICAgIHtcclxuICAgICAgICBcIiRtYXRjaFwiOiB7XHJcbiAgICAgICAgICAgIFwicGFydG5lclNob3J0Q29kZVwiOiB7XHJcbiAgICAgICAgICAgICAgICBcIiRpblwiOiBbXVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfSxcclxuICAgIHtcclxuICAgICAgICBcIiRncm91cFwiOiB7XHJcbiAgICAgICAgICAgIFwiX2lkXCI6IFwiJHBhcnRuZXJTaG9ydENvZGVcIixcclxuICAgICAgICAgICAgXCJjbGluaWNzXCI6IHtcclxuICAgICAgICAgICAgICAgIFwiJHB1c2hcIjoge1xyXG4gICAgICAgICAgICAgICAgICAgIFwiY2xpbmljTmFtZVwiOiBcIiRuYW1lXCIsXHJcbiAgICAgICAgICAgICAgICAgICAgXCJjbGluaWNJZFwiOiBcIiRfaWRcIlxyXG4gICAgICAgICAgICAgICAgfVxyXG4gICAgICAgICAgICB9XHJcbiAgICAgICAgfVxyXG4gICAgfSxcclxuICAgIHtcclxuICAgICAgICBcIiRwcm9qZWN0XCI6IHtcclxuICAgICAgICAgICAgX2lkOjAsXHJcbiAgICAgICAgICAgIFwicGFydG5lclNob3J0Q29kZVwiOiBcIiRfaWRcIixcclxuICAgICAgICAgICAgXCJjbGluaWNzXCI6IDFcclxuICAgICAgICB9XHJcbiAgICB9XHJcbl1cclxuIiwidGVtcGxhdGUtdGFncyI6e319LCJkYXRhYmFzZSI6Mn0sImRpc3BsYXkiOiJ0YWJsZSIsInZpc3VhbGl6YXRpb25fc2V0dGluZ3MiOnt9fQ==
Fri Mar 22 2024 12:09:04 GMT+0000 (Coordinated Universal Time) http://localhost/wordpress-cli/wp-admin/admin.php?page