Compare commits

...

2 commits

Author SHA1 Message Date
ko b484122d49 Start to add armor, items. 2025-04-19 20:54:54 -04:00
ko 2ad5415cbf Start adding classes 2025-04-15 21:50:10 -04:00
6 changed files with 138 additions and 0 deletions

15
WebApp/Armor.py Normal file
View file

@ -0,0 +1,15 @@
from enum import Enum
from Item import Item
class ArmorLocation(Enum):
head = 0,
left_arm = 1
torso = 2
right_arm = 3
left_leg = 4
right_leg = 5
class Armor(Item):
def __init__(self, name:str, description:str, location : ArmorLocation):
self.BodyPart = location
Item.__init__(name, description)

51
WebApp/Character.py Normal file
View file

@ -0,0 +1,51 @@
from Skill import Skill
from Item import Item
from DicePool import DicePool
class Character:
def __init__(self, max_hp: int):
self.Body = Skill("Body")
self.Mental = Skill("Mental")
self.Profound = Skill("Profound")
self.Aura = Skill("Aura")
self.Setting = Skill("Setting")
self.NaturalVisualDescription = ""
self.WithBelongsVisualDescription = ""
self.Personality = ""
self.Ideals = ""
self.Bonds = ""
self.Flaws = ""
self.Inventory = list[Item]()
self.Backstory = ""
self.Armor = ""
self.LegalTender = 0
self.MaxHp = 0
self.CurrentHp = 0
def spend_money(self, amount_to_spend : int ) -> bool:
if amount_to_spend <= 0:
return False
elif self.LegalTender >= amount_to_spend:
self.LegalTender -= amount_to_spend
return True
else:
return False
def earn_money(self, amount_earned: int) -> bool:
if amount_earned <= 0:
return False
else:
self.LegalTender += amount_earned
return True
def action(self, primary_skill: Skill, secondary_skill: Skill = None) ->:
action_pool = DicePool()
primary_skill.use(action_pool)
if seondary_skill is not None:
secondary_skill.use(action_pool)
action_pool.roll()
action_pool.clear()
except:

15
WebApp/DicePool.py Normal file
View file

@ -0,0 +1,15 @@
import Die
class DicePool:
def __init__(self):
self.pool = list[Die]()
def add_to_pool(self, die : Die):
self.pool.append(die)
def remove_from_pool(self, die : Die):
self.pool.remove(die)
def clear_pool(self):
self.pool.clear()
def roll(self) -> int:
result:int = 0
for die in self.Pool:
result = result + die.roll()
return result

6
WebApp/Die.py Normal file
View file

@ -0,0 +1,6 @@
from random import randint
class Die:
def __init__(self, diemax: int):
self.Max = diemax
def roll(self):
return randint(1, self.Max)

4
WebApp/Item.py Normal file
View file

@ -0,0 +1,4 @@
class Item:
def __init__(self, name: str, description: str):
self.Name = name
self.description = description

47
WebApp/Skill.py Normal file
View file

@ -0,0 +1,47 @@
import DicePool
from Die import Die
from enum import Enum
from DicePool import DicePool
class Skill:
class ProficiencyLevel(Enum):
novice = 0
studied = 1
proficient = 2
advanced = 3
expert = 4
legendary = 5
def __init__(self, name):
self.Proficiency = self.ProficiencyLevel.novice
self.SubSkills = list[Skill]()
self.Name = name
self.SkillDice = Die(4)
self.ProficiencyPool = list[Die]()
self.ProficiencyPool.append(Die(1))
def use(self, pool : DicePool):
pool.add_to_pool(self.SkillDice)
def upgrade_skill(self):
num_pass = 0
if len(self.ProficiencyPool)>0:
for die in self.ProficiencyPool:
if die.roll() < die.Max:
return
if self.Proficiency == self.ProficiencyLevel.novice:
# Because novice is the only D1 available, clear dice pool
# before adding to pool
self.Proficiency = self.ProficiencyLevel.studied
self.ProficiencyPool.clear()
self.ProficiencyPool.append(Die(20))
elif self.Proficiency == self.ProficiencyLevel.studied:
self.Proficiency = self.ProficiencyLevel.proficient
self.ProficiencyPool.append(Die(20))
elif self.Proficiency == self.ProficiencyLevel.proficient:
self.Proficiency = self.ProficiencyLevel.advanced
self.ProficiencyPool.append(Die(20))
elif self.Proficiency == self.ProficiencyLevel.advanced:
self.Proficiency = self.ProficiencyLevel.expert
self.ProficiencyPool.append(Die(20))
elif self.Proficiency == self.ProficiencyLevel.expert:
self.Proficiency = self.ProficiencyLevel.legendary
self.ProficiencyPool.clear()
for skill in self.SubSkills:
skill.upgrade_skill()