Refactor Action as data class
Action is now a frozen data class. All properties of Action now have type hints, and __slots__ are used for properties without default values (that is, name).
This commit is contained in:
parent
79dd51c1c2
commit
21ea715dd1
|
@ -1,68 +1,72 @@
|
||||||
__all__ = ['Action']
|
__all__ = ['Action']
|
||||||
__author__ = "Jeremy Saklad"
|
__author__ = "Jeremy Saklad"
|
||||||
|
|
||||||
|
from dataclasses import dataclass, field
|
||||||
|
|
||||||
|
@dataclass(frozen=True)
|
||||||
class Action:
|
class Action:
|
||||||
"""An action that affects a skeleton's qualities."""
|
"""An action that affects a skeleton's qualities."""
|
||||||
|
|
||||||
def __init__(self, name, cost, torso_style = None, value = 0, skulls_needed = 0, limbs_needed = 0, tails_needed = 0, skulls = 0, arms = 0, legs = 0, tails = 0, wings = 0, fins = 0, tentacles = 0, amalgamy = 0, antiquity = 0, menace = 0, implausibility = 0, counter_church = 0, exhaustion = 0):
|
__slots__ = '__dict__', 'name'
|
||||||
self.name = name
|
|
||||||
|
name: str
|
||||||
|
|
||||||
# Cost in pennies of using this action, including the value of the actions spent
|
# Cost in pennies of using this action, including the value of the actions spent
|
||||||
self.cost = cost
|
cost: float = field(metadata={'unit': 'pennies'})
|
||||||
|
|
||||||
# Skeleton: Torso Style
|
# Skeleton: Torso Style
|
||||||
self.torso_style = torso_style
|
torso_style: int = None
|
||||||
|
|
||||||
# Approximate Value of Your Skeleton in Pennies
|
# Approximate Value of Your Skeleton in Pennies
|
||||||
self.value = value
|
value: int = field(default=0, metadata={'unit': 'pennies'})
|
||||||
|
|
||||||
# Skeleton: Skulls Needed
|
# Skeleton: Skulls Needed
|
||||||
self.skulls_needed = skulls_needed
|
skulls_needed: int = 0
|
||||||
|
|
||||||
# Skeleton: Limbs Needed
|
# Skeleton: Limbs Needed
|
||||||
self.limbs_needed = limbs_needed
|
limbs_needed: int = 0
|
||||||
|
|
||||||
# Skeleton: Tails Needed
|
# Skeleton: Tails Needed
|
||||||
self.tails_needed = tails_needed
|
tails_needed: int = 0
|
||||||
|
|
||||||
# Skeleton: Skulls
|
# Skeleton: Skulls
|
||||||
self.skulls = skulls
|
skulls: int = 0
|
||||||
|
|
||||||
# Skeleton: Arms
|
# Skeleton: Arms
|
||||||
self.arms = arms
|
arms: int = 0
|
||||||
|
|
||||||
# Skeleton: Legs
|
# Skeleton: Legs
|
||||||
self.legs = legs
|
legs: int = 0
|
||||||
|
|
||||||
# Skeleton: Tails
|
# Skeleton: Tails
|
||||||
self.tails = tails
|
tails: int = 0
|
||||||
|
|
||||||
# Skeleton: Wings
|
# Skeleton: Wings
|
||||||
self.wings = wings
|
wings: int = 0
|
||||||
|
|
||||||
# Skeleton: Fins
|
# Skeleton: Fins
|
||||||
self.fins = fins
|
fins: int = 0
|
||||||
|
|
||||||
# Skeleton: Tentacles
|
# Skeleton: Tentacles
|
||||||
self.tentacles = tentacles
|
tentacles: int = 0
|
||||||
|
|
||||||
# Skeleton: Amalgamy
|
# Skeleton: Amalgamy
|
||||||
self.amalgamy = amalgamy
|
amalgamy: int = 0
|
||||||
|
|
||||||
# Skeleton: Antiquity
|
# Skeleton: Antiquity
|
||||||
self.antiquity = antiquity
|
antiquity: int = 0
|
||||||
|
|
||||||
# Skeleton: Menace
|
# Skeleton: Menace
|
||||||
self.menace = menace
|
menace: int = 0
|
||||||
|
|
||||||
# Skeleton: Self-Evident Implausibility
|
# Skeleton: Self-Evident Implausibility
|
||||||
self.implausibility = implausibility
|
implausibility: int = 0
|
||||||
|
|
||||||
# Skeleton: Support for a Counter-church Theology
|
# Skeleton: Support for a Counter-church Theology
|
||||||
self.counter_church = counter_church
|
counter_church: int = 0
|
||||||
|
|
||||||
# Bone Market Exhaustion
|
# Bone Market Exhaustion
|
||||||
self.exhaustion = exhaustion
|
exhaustion: int = 0
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.name)
|
return str(self.name)
|
||||||
|
|
Loading…
Reference in New Issue