support no options
This commit is contained in:
parent
4b10f01036
commit
f80d087ac4
|
@ -113,7 +113,7 @@ class RollTable:
|
|||
freqs = random.choices(options, weights=weights, k=self.die)
|
||||
values = []
|
||||
for option in freqs:
|
||||
choice = random.choice(ds.data[option])
|
||||
choice = random.choice(ds.data[option]) if ds.data[option] else ''
|
||||
if hasattr(choice, 'keys'):
|
||||
c = [option]
|
||||
for (k, v) in choice.items():
|
||||
|
|
|
@ -82,6 +82,16 @@ B3:
|
|||
- B choice 3
|
||||
"""
|
||||
|
||||
fixture_no_options = """
|
||||
metadata:
|
||||
headers:
|
||||
- headerA
|
||||
- headerB
|
||||
B1:
|
||||
B2:
|
||||
B3:
|
||||
"""
|
||||
|
||||
|
||||
def test_combined_tables():
|
||||
combined = tables.RollTable([fixture_combined_A, fixture_combined_B], die=6)
|
||||
|
@ -125,5 +135,5 @@ def test_no_descriptions():
|
|||
|
||||
|
||||
def test_yaml():
|
||||
t = tables.RollTable([fixture_metadata + fixture_source])
|
||||
t = tables.RollTable([fixture_no_options])
|
||||
print(t.as_yaml)
|
||||
|
|
Loading…
Reference in New Issue
Block a user