YATTRS/WebApp/Skill.py
2025-04-15 21:50:10 -04:00

48 lines
1.9 KiB
Python

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()