import random
class Miniature:
def __init__(self, name, transportable):
self.name = name
self.cost = 20
self.dice_types = ['d0', 'd4', 'd6', 'd8', 'd10', 'd12']
self.actions = 1
self.actions_max = 5
self.action_cost = 5
self.move = 3
self.move_max = 15
self.move_cost = 2
self.melee = 1
self.melee_max = len(self.dice_types)
self.melee_cost = 1
self.shoot = 0
self.shoot_max = len(self.dice_types)
self.shoot_cost = 3
self.area_shoot = 0
self.area_power = 0
self.area_cost = 3
self.area_max = 10
self.power = 0
self.power_max = len(self.dice_types)
self.power_cost = 2
self.defense = 1
self.defense_max = len(self.dice_types)
self.defense_cost = 3
self.health = 1
self.health_max = 10
self.health_cost = 5
self.transportable = transportable
self.transport_cost = 1
self.transport_max = 15
self.sneak_cost = 4
self.sneak_max = 1
self.fly_cost = 5
self.fly_max = 1
self.abilities = {'fly': 0, 'sneak': 0, 'transport': 0}
def print_data(self):
print('Name:, ' + str(self.name))
print('Cost:, ' + str(self.cost))
print('Actions:, ' + str(self.actions) + ',Upgrade Cost:, ' +
str((self.actions * self.action_cost)))
print('Move:, ' + str(self.move) + ',Upgrade Cost:, ' + str((self.move *
self.move_cost)))
print('Melee:, ' + str(self.dice_types[self.melee]) + ',Upgrade Cost:, ' +
str((self.melee * self.melee_cost)))
print('Shoot:, ' + str(self.dice_types[self.shoot]) + ',Upgrade Cost:, ' +
str(self.shoot * self.shoot_cost))
print('Area Shoot:, ' + str(self.area_shoot) + ',Upgrade Cost:, ' +
str(self.area_shoot * self.area_cost))
print('Power:, ' + str(self.dice_types[self.power]) + ',Upgrade Cost:, ' +
str(self.power * self.power_cost))
print('Area Power:, ' + str(self.area_power) + ',Upgrade Cost:, ' +
str(self.area_power * self.area_cost))
print('Defense:, ' + str(self.dice_types[self.defense]) + ',Upgrade Cost:,
'+ str((self.defense * self.defense_cost)))
print('Health:, ' + str(self.health) + ',Upgrade Cost:, ' + str((self.health
* self.health_cost)))
print('Abilities Transport:, ' + str(self.abilities['transport']) +
',Upgrade Cost:, ' + str(self.abilities['transport'] * self.transport_cost))
print('Abilities Sneak:, ' + str(self.abilities['sneak']) + ',Upgrade Cost:,
' + str(self.abilities['sneak'] * self.sneak_cost))
print('Abilities Fly:, ' + str(self.abilities['fly']) + ',Upgrade Cost:, ' +
str(self.abilities['fly'] * self.fly_cost))
def choose_upgrades(self, cost):
random.seed()
choice = 0
count = 0
cost_initial = cost
while cost > 0:
choice = random.randint(1, 12)
if choice == 1 or (self.actions < self.actions_max and cost >=
self.action_cost):
self.actions += 1
cost -= self.action_cost
if choice == 2 or (self.move < self.move_max and cost >=
self.move_cost):
self.move += 1
cost -= self.move_cost
if choice == 3 or (self.melee < self.melee_max and cost >=
self.melee_cost):
self.melee += 1
cost -= self.melee_cost
if choice == 4 or (self.shoot < self.shoot_max and cost >=
self.shoot_cost):
self.shoot += 1
cost -= self.shoot_cost
if choice == 5 or (self.shoot >= 1 and self.area_max and cost >=
self.area_cost):
self.area_shoot += 1
cost -= self.area_cost
if choice == 6 or (self.power >= 1 and self.area_max and cost >=
self.area_cost):
self.area_power += 1
cost -= self.area_cost
if choice == 7 or (self.power < self.power_max and cost >=
self.power_cost):
self.power += 1
cost -= self.power_cost
if choice == 8 or (self.defense < self.defense_max and cost >=
self.defense_cost):
self.defense += 1
cost -= self.defense_cost
if choice == 9 or (self.health < self.health_max and cost >=
self.health_cost):
self.health += 1
cost -= self.health_cost
if choice == 10 or (self.abilities['transport'] < self.transport_max and
cost >= self.transport_cost and self.transportable == True):
self.abilities['transport'] += 1
cost -= self.transport_cost
if choice == 11 or (self.abilities['sneak'] < self.sneak_max and cost >=
self.sneak_cost):
self.abilities['sneak'] = 1
cost -= self.sneak_cost
if choice == 12 or (self.abilities['fly'] < self.sneak_max and cost
>=self.fly_cost):
self.abilities['fly'] = 1
cost -= self.fly_cost
self.cost += cost_initial
return self.cost
def main():
army_cost = 1000
final_army_cost = 0
additional_cost_range = [5, 20]
name = 0
transportable = True
while army_cost > 0:
name += 1
mini_cost = random.randint(additional_cost_range[0],
additional_cost_range[1])
mini = Miniature(str(name), transportable)
if (mini_cost + 20) > army_cost:
mini_cost = army_cost - 20
overall_cost = mini.choose_upgrades(mini_cost)
mini.print_data()
print('\n\n')
army_cost -= overall_cost
final_army_cost += overall_cost
print (final_army_cost)
if __name__ == '__main__':
main()