mirror of
https://github.com/Threnklyn/dungeon-sheets.git
synced 2026-06-05 20:38:26 +02:00
added HP roller to GUI
This commit is contained in:
@@ -0,0 +1,106 @@
|
|||||||
|
"""This file describes the heroic adventurer Ben.
|
||||||
|
|
||||||
|
It's used primarily for saving characters from create-character,
|
||||||
|
where there will be many missing sections.
|
||||||
|
|
||||||
|
Modify this file as you level up and then re-generate the character
|
||||||
|
sheet by running ``makesheets`` from the command line.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
dungeonsheets_version = "0.9.4"
|
||||||
|
|
||||||
|
name = "Ben"
|
||||||
|
player_name = "Ben"
|
||||||
|
|
||||||
|
# Be sure to list Primary class first
|
||||||
|
classes = ['Cleric', 'Barbarian'] # ex: ['Wizard'] or ['Rogue', 'Fighter']
|
||||||
|
levels = [5, 10] # ex: [10] or [3, 2]
|
||||||
|
subclasses = ["Light Domain", "Path of the Battlerager"] # ex: ['Necromacy'] or ['Thief', None]
|
||||||
|
background = "Criminal"
|
||||||
|
race = "High Elf"
|
||||||
|
alignment = "Chaotic good"
|
||||||
|
|
||||||
|
xp = 0
|
||||||
|
hp_max = 100
|
||||||
|
inspiration = 0 # integer inspiration value
|
||||||
|
|
||||||
|
# Ability Scores
|
||||||
|
strength = 10
|
||||||
|
dexterity = 12
|
||||||
|
constitution = 18
|
||||||
|
intelligence = 11
|
||||||
|
wisdom = 10
|
||||||
|
charisma = 10
|
||||||
|
|
||||||
|
# Select what skills you're proficient with
|
||||||
|
# ex: skill_proficiencies = ('athletics', 'acrobatics', 'arcana')
|
||||||
|
skill_proficiencies = ('insight', 'medicine', 'deception', 'stealth', 'perception')
|
||||||
|
|
||||||
|
# Any skills you have "expertise" (Bard/Rogue) in
|
||||||
|
skill_expertise = ()
|
||||||
|
|
||||||
|
# Named features / feats that aren't part of your classes, race, or background.
|
||||||
|
# Also include Eldritch Invocations and features you make multiple selection of
|
||||||
|
# (like Maneuvers for Fighter, Metamagic for Sorcerors, Trick Shots for
|
||||||
|
# Gunslinger, etc.)
|
||||||
|
# Example:
|
||||||
|
# features = ('Tavern Brawler',) # take the optional Feat from PHB
|
||||||
|
features = ()
|
||||||
|
|
||||||
|
# If selecting among multiple feature options: ex Fighting Style
|
||||||
|
# Example (Fighting Style):
|
||||||
|
# feature_choices = ('Archery',)
|
||||||
|
feature_choices = ()
|
||||||
|
|
||||||
|
# Weapons/other proficiencies not given by class/race/background
|
||||||
|
weapon_proficiencies = () # ex: ('shortsword', 'quarterstaff')
|
||||||
|
_proficiencies_text = () # ex: ("thieves' tools",)
|
||||||
|
|
||||||
|
# Proficiencies and languages
|
||||||
|
languages = """Common, Elvish, [choose one]"""
|
||||||
|
|
||||||
|
# Inventory
|
||||||
|
# TODO: Get yourself some money
|
||||||
|
cp = 0
|
||||||
|
sp = 0
|
||||||
|
ep = 0
|
||||||
|
gp = 0
|
||||||
|
pp = 0
|
||||||
|
|
||||||
|
# TODO: Put your equipped weapons and armor here
|
||||||
|
weapons = ["Greatclub"] # Example: ('shortsword', 'longsword')
|
||||||
|
magic_items = () # Example: ('ring of protection',)
|
||||||
|
armor = "Padded Armor" # Eg "leather armor"
|
||||||
|
shield = "None" # Eg "shield"
|
||||||
|
|
||||||
|
equipment = """TODO: list the equipment and magic items your character carries"""
|
||||||
|
|
||||||
|
attacks_and_spellcasting = """TODO: Describe how your character usually attacks
|
||||||
|
or uses spells."""
|
||||||
|
|
||||||
|
# List of known spells
|
||||||
|
# Example: spells_prepared = ('magic missile', 'mage armor')
|
||||||
|
spells_prepared = () # Todo: Learn some spells
|
||||||
|
|
||||||
|
# Which spells have not been prepared
|
||||||
|
__spells_unprepared = ()
|
||||||
|
|
||||||
|
# all spells known
|
||||||
|
spells = spells_prepared + __spells_unprepared
|
||||||
|
|
||||||
|
# Wild shapes for Druid
|
||||||
|
wild_shapes = () # Ex: ('ape', 'wolf', 'ankylosaurus')
|
||||||
|
|
||||||
|
# Backstory
|
||||||
|
# Describe your backstory here
|
||||||
|
personality_traits = """TODO: Describe how your character behaves, interacts with others"""
|
||||||
|
|
||||||
|
ideals = """TODO: Describe what values your character believes in."""
|
||||||
|
|
||||||
|
bonds = """TODO: Describe your character's commitments or ongoing quests."""
|
||||||
|
|
||||||
|
flaws = """TODO: Describe your character's interesting flaws."""
|
||||||
|
|
||||||
|
features_and_traits = """TODO: Describe other features and abilities your
|
||||||
|
character has."""
|
||||||
@@ -7,6 +7,7 @@ import logging
|
|||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
import numpy as np
|
||||||
import os
|
import os
|
||||||
from random import randint
|
from random import randint
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -91,7 +92,44 @@ class App(npyscreen.NPSAppManaged):
|
|||||||
log.debug("Creating PDF")
|
log.debug("Creating PDF")
|
||||||
self.character.to_pdf(filename)
|
self.character.to_pdf(filename)
|
||||||
subprocess.call(['makesheets', filename])
|
subprocess.call(['makesheets', filename])
|
||||||
|
|
||||||
|
def update_max_hp_roll(self):
|
||||||
|
abil = self.getForm("ABILITIES")
|
||||||
|
# Update max HP based on the class
|
||||||
|
hit_dice = [dice.read_dice_str(d)
|
||||||
|
for d in self.character.hit_dice.split(' + ')]
|
||||||
|
const = int((int(abil.constitution.value) - 10)/2)
|
||||||
|
hp_max = f"{hit_dice[0].faces + self.character.level*const}"
|
||||||
|
hds = {}
|
||||||
|
for i, hd in enumerate(hit_dice):
|
||||||
|
num = hd.num
|
||||||
|
if i == 0:
|
||||||
|
num -= 1
|
||||||
|
if hd.faces not in hds:
|
||||||
|
hds[hd.faces] = 0
|
||||||
|
hds[hd.faces] += num
|
||||||
|
for faces, num in hds.items():
|
||||||
|
hp_max += f' + {num}d{faces}'
|
||||||
|
abil.hp_roll_text.value = "Enter (or roll) your Max HP: " + hp_max
|
||||||
|
abil.display()
|
||||||
|
|
||||||
|
def reroll_max_hp(self):
|
||||||
|
abil = self.getForm("ABILITIES")
|
||||||
|
# Update max HP based on the class
|
||||||
|
hit_dice = [dice.read_dice_str(d)
|
||||||
|
for d in self.character.hit_dice.split(' + ')]
|
||||||
|
const = int((int(abil.constitution.value) - 10)/2)
|
||||||
|
# Assume first hd given is from primary class
|
||||||
|
hp_max = hit_dice[0].faces + const
|
||||||
|
for i, hd in enumerate(hit_dice):
|
||||||
|
num = hd.num
|
||||||
|
if i == 0:
|
||||||
|
num -= 1
|
||||||
|
for d in range(num):
|
||||||
|
hp_max += np.random.randint(low=1, high=hd.faces+1) + const
|
||||||
|
abil.hp_max.value = str(hp_max)
|
||||||
|
abil.display()
|
||||||
|
|
||||||
def set_default_hp_max(self):
|
def set_default_hp_max(self):
|
||||||
abil = self.getForm("ABILITIES")
|
abil = self.getForm("ABILITIES")
|
||||||
# Update max HP based on the class
|
# Update max HP based on the class
|
||||||
@@ -99,12 +137,16 @@ class App(npyscreen.NPSAppManaged):
|
|||||||
for d in self.character.hit_dice.split(' + ')]
|
for d in self.character.hit_dice.split(' + ')]
|
||||||
const = int((int(abil.constitution.value) - 10)/2)
|
const = int((int(abil.constitution.value) - 10)/2)
|
||||||
# Assume first hd given is from primary class
|
# Assume first hd given is from primary class
|
||||||
hp_max = math.floor(hit_dice[0].faces/2) + const
|
hp_max = hit_dice[0].faces + const
|
||||||
for hd in hit_dice:
|
for i, hd in enumerate(hit_dice):
|
||||||
for d in range(hd.num):
|
num = hd.num
|
||||||
|
if i == 0:
|
||||||
|
num -= 1
|
||||||
|
for d in range(num):
|
||||||
hp_max += math.ceil(hd.faces/2) + const
|
hp_max += math.ceil(hd.faces/2) + const
|
||||||
log.debug("Updating max hp: %d", hp_max)
|
log.debug("Updating max hp: %d", hp_max)
|
||||||
abil.hp_max.value = str(hp_max)
|
abil.hp_max.value = str(hp_max)
|
||||||
|
abil.display()
|
||||||
|
|
||||||
def onStart(self):
|
def onStart(self):
|
||||||
self.character = character.Character()
|
self.character = character.Character()
|
||||||
@@ -401,6 +443,10 @@ class AbilityScoreForm(LinkedListForm):
|
|||||||
self.score_options.update()
|
self.score_options.update()
|
||||||
self.default_button.value = True
|
self.default_button.value = True
|
||||||
self.default_button.update()
|
self.default_button.update()
|
||||||
|
|
||||||
|
def reroll_hp(self, widget=None):
|
||||||
|
self.parentApp.reroll_max_hp()
|
||||||
|
self.parentApp.update_max_hp_roll()
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
self.roll_text = self.add(npyscreen.FixedText, editable=False,
|
self.roll_text = self.add(npyscreen.FixedText, editable=False,
|
||||||
@@ -436,7 +482,13 @@ class AbilityScoreForm(LinkedListForm):
|
|||||||
name=name,
|
name=name,
|
||||||
begin_entry_at=24, value='10')
|
begin_entry_at=24, value='10')
|
||||||
setattr(self, attr, new_fld)
|
setattr(self, attr, new_fld)
|
||||||
|
self.hp_roll_text = self.add(npyscreen.FixedText, editable=False,
|
||||||
|
value="")
|
||||||
|
self.hp_reroll_buttom = self.add(npyscreen.MiniButtonPress,
|
||||||
|
name="Reroll Max HP",
|
||||||
|
when_pressed_function=self.reroll_hp)
|
||||||
self.hp_max = self.add(npyscreen.TitleText, name="Max HP:")
|
self.hp_max = self.add(npyscreen.TitleText, name="Max HP:")
|
||||||
|
self.parentApp.update_max_hp_roll()
|
||||||
self.parentApp.set_default_hp_max()
|
self.parentApp.set_default_hp_max()
|
||||||
|
|
||||||
def on_ok(self):
|
def on_ok(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user