adding armor

This commit is contained in:
Zachary Watts
2026-04-19 14:18:38 -04:00
parent feacb20551
commit 206a229895

79
main.py
View File

@@ -21,16 +21,19 @@ weapons = [
# Player Character Classes
class Adventurer:
def __init__(self, attributes={}) -> None:
def __init__(self, level=1, attributes={}) -> None:
# using a get() method to pull an attribute else use a default value, https://python-academy.org/en/handbook/get
self.player_class = None
self.level = level
self.strength = attributes.get('strength', roll_dice(3,6))
self.intelligence = attributes.get('intelligence', roll_dice(3,6))
self.wisdom = attributes.get('wisdom', roll_dice(3,6))
self.dexterity = attributes.get('dexterity', roll_dice(3,6))
self.constitution = attributes.get('constitution', roll_dice(3,6))
self.charisma = attributes.get('charisma', roll_dice(3,6))
self.player_class = None
self.level = 1
self.hp = 1
self.torches = roll_dice(1,6)
self.rations = roll_dice(1,6)
self.equipment = [ 'backpack', 'tinderbox', 'waterskin' ]
self.weapons = []
self.armor = []
@@ -40,9 +43,18 @@ class Adventurer:
def character_sheet(self):
sheet = []
sheet.append('{0: <20}'.format(f"| Class {self.player_class}"))
attrs = self.get_attributes()
sheet += ['{0: <20}'.format(f"| {key} {val} ") for key, val in attrs.items()]
sheet.append('{0: <26}'.format(f"| {self.player_class.title()} - Level {self.level}"))
for key, val in self.get_attributes().items():
key_string = "| " + '{0:12}'.format(f"{key}").capitalize() + f" {val}"
sheet += ['{0: <26}'.format(key_string)]
sheet.append('| ----------------------- ')
sheet.append('{0: <26}'.format(f"| HP: {self.hp} AC: {self.ac}"))
sheet.append('{0: <26}'.format(f"| Torches: {self.torches}"))
sheet.append('{0: <26}'.format(f"| Rations: {self.rations}"))
sheet.append('{0: <26}'.format(f"| Armor: {self.armor}"))
sheet.append('{0: <26}'.format(f"| Weapons:"))
sheet.append('{0: <26}'.format(f"| {self.weapons[0]}"))
sheet.append('{0: <26}'.format(f"| {self.weapons[1]}"))
return sheet
def get_attributes(self):
@@ -62,58 +74,79 @@ class Adventurer:
class Fighter(Adventurer):
prime_requisite = "strength"
requirements = None
def __init__(self, attributes={}) -> None:
Adventurer.__init__(self, attributes)
def __init__(self, level, attributes={}) -> None:
Adventurer.__init__(self, level, attributes)
self.player_class = "fighter"
self.hp = roll_dice(self.level, 8)
self.armor = random.choice(list(armor.keys()))
self.ac = armor[self.armor]
self.weapons = [ "sword", "dagger" ]
class MagicUser(Adventurer):
prime_requisite = "intelligence"
requirements = None
def __init__(self, attributes={}) -> None:
Adventurer.__init__(self, attributes)
self.player_class = "magic-user"
def __init__(self, level, attributes={}) -> None:
Adventurer.__init__(self, level, attributes)
self.player_class = "magic user"
self.hp = roll_dice(self.level, 4)
self.armor = random.choice(list(armor.keys()))
self.ac = armor[self.armor]
self.weapons = [ "sword", "dagger" ]
class Cleric(Adventurer):
prime_requisite = "wisdom"
requirements = None
def __init__(self, attributes={}) -> None:
Adventurer.__init__(self, attributes)
def __init__(self, level, attributes={}) -> None:
Adventurer.__init__(self, level, attributes)
self.player_class = "cleric"
self.hp = roll_dice(self.level, 6)
self.armor = random.choice(list(armor.keys()))
self.ac = armor[self.armor]
self.weapons = [ "sword", "dagger" ]
class Thief(Adventurer):
prime_requisite = "dexterity"
requirements = None
def __init__(self, attributes={}) -> None:
Adventurer.__init__(self, attributes)
def __init__(self, level, attributes={}) -> None:
Adventurer.__init__(self, level, attributes)
self.player_class = "thief"
self.hp = roll_dice(self.level, 4)
self.armor = random.choice(list(armor.keys()))
self.ac = armor[self.armor]
self.weapons = [ "sword", "dagger" ]
class Dwarf(Adventurer):
prime_requisite = "strength"
requirements = {'constitution' : 9 }
def __init__(self, attributes={}) -> None:
Adventurer.__init__(self, attributes)
def __init__(self, level, attributes={}) -> None:
Adventurer.__init__(self, level, attributes)
self.player_class = "dwarf"
self.hp = roll_dice(self.level, 8)
self.armor = random.choice(list(armor.keys()))
self.ac = armor[self.armor]
self.weapons = [ "sword", "dagger" ]
class Elf(Adventurer):
prime_requisite = "intellgence"
requirements = {'intelligence' : 9 }
def __init__(self, attributes={}) -> None:
Adventurer.__init__(self, attributes)
def __init__(self, level, attributes={}) -> None:
Adventurer.__init__(self, level, attributes)
self.player_class = "elf"
self.hp = roll_dice(self.level, 6)
self.armor = random.choice(list(armor.keys()))
self.ac = armor[self.armor]
self.weapons = [ "sword", "dagger" ]
class Halfling(Adventurer):
prime_requisite = "dexterity"
requirements = {'constitution' : 9, 'dexterity' : 9 }
def __init__(self, attributes={}) -> None:
Adventurer.__init__(self, attributes)
def __init__(self, level, attributes={}) -> None:
Adventurer.__init__(self, level, attributes)
self.player_class = "halfling"
self.hp = roll_dice(self.level, 6)
self.armor = random.choice(list(armor.keys()))
self.ac = armor[self.armor]
self.weapons = [ "sword", "dagger" ]
# Player Class Selector
class ClassSelector():
@@ -165,14 +198,14 @@ class PartyGenerator():
while new_player.player_class not in self.adventurer_types:
attempts += 1
selected_class = ClassSelector(new_player).selection()
new_player = selected_class(new_player.get_attributes())
new_player = selected_class(new_player.level, new_player.get_attributes())
# i couldnt randomly generate a scenario where a character couldn't be added, but it seems possible, so this is the hard cut off
if (new_player.player_class not in self.adventurer_types) or (attempts > 10):
self.adventurers.append(new_player)
self.adventurer_types.append(new_player.player_class)
def get_character_sheets(self):
for i in range(7):
for i in range(15):
for j in range(len(self.adventurers)):
adv = self.adventurers[j]
print(adv.character_sheet()[i],end='')