-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerateSousLesDesLIdee.py
executable file
·77 lines (52 loc) · 2.05 KB
/
generateSousLesDesLIdee.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/python3
# -*- coding: utf-8 -*-
__author__ = "Gabriel Chandesris"
__copyright__ = "CC Gabriel Chandesris (2020)"
__credits__ = ""
__licence__ = "GNU GENERAL PUBLIC LICENSE v3"
__version__ = "1.0.0"
__maintainer__ = "Gabriel Chandesris"
__email__ = "gabywald[at]laposte.net"
__contact__ = "gabywald[at]laposte.net"
__status__ = "Development"
## ## ## ## ## Generate some Ideas from associated resource : "sousLesDesLideeJdR.txt" !
import random
from DiceTable import DiceTable
tables = DiceTable.load()
types = []
## print( tables )
## for table in tables :
## print ( "\t%s\t%s" %( table, tables[ table ] ) )
## for subtable in tables[ table ].subtables :
## print ( "\t\t%s" %( subtable ) )
## ## ## ## ## Retrieves the types of universe of playing / writing
for elt in tables[ "Personnages" ].subtables :
if elt.name not in types:
types.append( elt.name )
for elt in tables[ "Lieux" ].subtables :
if elt.name not in types:
types.append( elt.name )
## print ( types )
## ## ## ## ## Choose randomly
universe = random.choice ( types )
print ( "Choice is '%s'" %( universe ) )
personnaes = tables[ "Personnages" ].getSubTable( universe ).contents
locations = tables[ "Lieux" ].getSubTable( universe ).contents
## print ( personnaes )
## print ( locations )
## print ( tables[ "Interactions" ] )
## for subtable in tables[ "Interactions" ].subtables :
## print ( "\t\t%s" %( subtable ) )
interactions1 = tables[ "Interactions" ].getSubTable( "Entre personnages" ).contents
interactions2 = tables[ "Interactions" ].getSubTable( "Personnages et lieux" ).contents
numberOfResults = random.randint(5, 10)
for i in range(0, numberOfResults) :
result = []
result.append( random.choice( personnaes ) )
if (random.randint(0, 42)%2 == 0) :
result.append( random.choice ( interactions1 ) )
result.append( random.choice ( personnaes ) )
else:
result.append( random.choice ( interactions2 ) )
result.append( random.choice ( locations ) )
print ( " ".join( result ) )