Start adding classes

This commit is contained in:
ko 2025-04-15 21:50:10 -04:00
parent 56396889c5
commit 2ad5415cbf
4 changed files with 99 additions and 0 deletions

36
WebApp/Character.py Normal file
View file

@ -0,0 +1,36 @@
from Skill import Skill
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 = "" #This should probably be a list of class items
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

10
WebApp/DicePool.py Normal file
View file

@ -0,0 +1,10 @@
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()

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)

47
WebApp/Skill.py Normal file
View file

@ -0,0 +1,47 @@
import DicePool
from Die import Die
from enum import Enum
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):
return self.SkillDice.roll()
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()