-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogic.py
78 lines (70 loc) · 2.64 KB
/
logic.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
70
71
72
73
74
75
76
77
78
#!/usr/bin/python3
#Random laser and feelings character generator
#Laser and Feelings is copyright John Harper (http://onesevendesign.com/) and is licensed under a CC BY-NCSA 3.0 license
#Program is Copyright Jeff Demers under the MIT License
#PACKAGES
import random
import string
import sys
from locale import Locale
class Logic:
#METHODS
@staticmethod
def OpeningSpiel():
return Locale.text()["openingSpiel"]
@staticmethod
def NumberOfHeroesText():
return Locale.text()["numberOfHeroes"]
@staticmethod
def GetHeroes(numHeroes):
styles = Locale.text()["hero"]["styles"]
roles = Locale.text()["hero"]["roles"]
numbers = [2,3,4,5]
goals = Locale.text()["hero"]["goals"]
arHeroes = []
for x in range(numHeroes):
#only allows this role once
role = random.choice(roles)
roles.remove(role)
name = Logic.GetName()
style = random.choice(styles)
number = random.choice(numbers)
lof = Locale.text()[("lasers" if number > 3 else "feelings")]
lofRating = f'{Locale.text()["high"]} ' if number == 2 or number == 5 else ""
goal = random.choice(goals)
arHeroes.append(f'{name} ({number}, {lofRating}{lof}) {style} {role}, {Locale.text()["goal"]}: {goal}')
return arHeroes
@staticmethod
def GetShip():
strengths = Locale.text()["ship"]["strengths"]
weaknesses = Locale.text()["ship"]["weaknesses"]
ar = []
i = 0
while i < 2:
choice = random.choice(strengths)
strengths.remove(choice)
ar.append(choice)
i+=1
ar.append(random.choice(weaknesses))
return ar
@staticmethod
def GetThreat():
adversary = random.choice(Locale.text()["threat"]["adversary"])
wantsTo = random.choice(Locale.text()["threat"]["wantsTo"])
the = random.choice(Locale.text()["threat"]["the"])
whichWill = random.choice(Locale.text()["threat"]["whichWill"])
return f'{adversary} wants to {wantsTo} the {the} which will {whichWill}'
@staticmethod
def GetNamePart(length):
VOWELS = "aeiou"
CONSONANTS = "".join(set(string.ascii_lowercase) - set(VOWELS))
word = ""
for i in range(length):
if i % 2 == 0:
word += random.choice(CONSONANTS)
else:
word += random.choice(VOWELS)
return word.capitalize()
@staticmethod
def GetName():
return Logic.GetNamePart(random.randint(3,6)) + ' ' + Logic.GetNamePart(random.randint(4,10))