Solution
Swapnil answered on
Oct 22 2021
94227/armor.csv
Scales of the Greater Basilisk,300,30,0
Dragon Wing Tabard,400,20,20
Tunic of the Cyclops King,500,0,40
Dragon Scale Armor,800,40,40
Titan`s Cuirass,1000,-20,100
94227/helmet.csv
Crown of the Supreme Magi,500,40,0
Hellstorm Helmet,600,50,0
Crown of Dragontooth,800,40,40
Thunder Helmet,1000,100,-20
Helm of Heavenly Enlightenment,2400,120,120
94227/Hero_Monopoly.py
import random
import time
import sys
import csv
def hero_search(name, heros):
for hero in heros:
if hero.name == name:
return hero
else:
return None
def roll_dice(dice_number):
i = 1
dice_sum = 0
input("
Enter any to rolling dices.")
print('Rolling dices......')
time.sleep(0.5)
while i <= dice_number:
dice = random.randint(1, 6)
print('Dice {} is {}.'.format(i, dice))
dice_sum += dice
i += 1
return dice_sum
class getoutofloop(Exception):
pass
class BoardGame:
def __init__(self, num_player=4):
self.heros = []
self.board = []
self.size = num_player
self.round = 1
def round_check(self):
hero_next_round = []
if self.size >= 2:
for hero in self.heros:
if hero.gold < 0 and len(hero.castle) > 0:
hero.pay_debt()
for hero in self.heros:
if hero.gold <= 0 and len(hero.castle) < 1:
print("Hero " + hero.name + " owns no gold or castles, he is defeated!\n")
time.sleep(0.5)
self.size -= 1
else:
hero_next_round.append(hero)
self.heros = hero_next_round
if self.size == 1:
print("Hero " + self.heros[0].name + " conquered the land!!!\n")
time.sleep(1)
print("The End.\n")
time.sleep(0.5)
while True:
isexityes = input("
Please input exit to quit\n")
time.sleep(0.5)
if isexityes.lower() == "exit":
sys.exit()
else:
continue
else:
isexitadyes = input("
Continue? Enter exit to quit, other key to continue.\n")
time.sleep(0.5)
if isexitadyes.lower() == "exit":
sys.exit()
def round_step(self):
print(" [\n@XXXX[{::::::::::::::::::::::::::::::::::::>\n [\n")
time.sleep(0.5)
print("Round " + str(self.round) + "\n")
time.sleep(1)
self.round += 1
for hero in self.heros:
print(hero.name + ", it is your turn.\n")
time.sleep(0.5)
print("Cu
ently, you have " + str(hero.gold) + " gold, " + str(hero.army) + " army, " + str(
len(hero.castle)) + " castles.\n")
print("Your hero status is, Attack -- {} Defense -- {}.\n".format(hero.attack, hero.defense))
print("Equipment: ", end="")
for equip in hero.equips:
print(equip.name, end=", ")
print("\n")
time.sleep(0.5)
hero.move_forward()
space = hero.block_check(
self.board)
print(space)
time.sleep(0.5)
if type(space) == Castle:
hero.act_castle(space, self.heros)
elif type(space) == Arena:
hero.act_arena()
elif type(space) == Monolith:
hero.act_monolith(space)
elif type(space) == Market:
hero.act_market(space)
print("--------------------------------------------\n")
time.sleep(1)
for hero in self.heros:
if hero.castle:
for castle in hero.castle:
hero.gold += castle.production
hero.army += castle.production
else:
continue
print("Heros received supply from their castles.\n")
time.sleep(2)
class Building:
def __init__(self, name, location):
self.name = name
self.location = location
class Castle(Building):
def __init__(self, name, location, price):
super().__init__(name, location)
self.level = 1
self.price = price
self.up_fee = 0.6
self.up_ratio = 2
self.owner = None
self.army = price
self.production = int(price / 20)
def __str__(self):
return "Here is a Level " + str(self.level) + " Castle " + self.name + ".\n(Price: " + str(
self.price) + " Army : " + str(self.army) + " Gold Supply: " + str(
self.production) + " Army Supply: " + str(self.production) + ")"
class Arena(Building):
def __init__(self, name, location):
super().__init__(name, location)
def __str__(self):
return "Here is Arena " + self.name + ".\n"
class Monolith(Building):
def __init__(self, name, location, next_location):
super().__init__(name, location)
self.next_location = next_location
def __str__(self):
return "Here is a Monolith " + self.name + ".\n"
class Market(Building):
def __init__(self, name, location):
super().__init__(name, location)
self.equips_stk = []
def __str__(self):
return "Here is " + self.name + " Market.\n"
class Equipment:
def __init__(self, name, price, att_add, def_add):
self.name = name
self.price = price
self.att_add = att_add
...