-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtvw_charcreation.py
132 lines (117 loc) · 4.67 KB
/
tvw_charcreation.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
"""
Creating a custom module DND_tvw with the functions needed for the game.
Separate functions for:
- choosing character from predefined list/dict while loop
- giving name to the character while loop
- learning details about the character + read file
- saving the friend if else function
- choosing a way while(if else)
- short way riddle (like password func), 2 guesses while / or incorporate hangman style riddle
- long way swimming if else (difficulty class of the river)
- initiative roll - separates for user and enemy?
- attack roll - separates for user and enemy?
- game function - while loop untill end
Should all of these functions be in different modules for better overview?
"""
# Function for choosing a character:
# short description, saving the choice
from simple_colors import *
from tvw_charimage import display_image, dwarf_img, elf_img, wizzard_img
import copy
original_characters = {
"first" : {
"race" : "dwarf",
"class" : "fighter",
"hit points" : 15,
"armor_class" : 12,
"weapon" : "battle axe",
"initiative bonus" : 2,
"attack bonus" : 3,
"damage" : 2,
"athletics" : 1
},
"second" : {
"race" : "elf",
"class" : "ranger",
"hit points" : 13,
"armor_class" : 10,
"weapon" : "long bow",
"initiative bonus" : 3,
"attack bonus" : 3,
"damage" : 2,
"athletics" : 3
},
"third" : {
"race" : "human",
"class" : "wizzard",
"hit points" : 12,
"armor_class" : 11,
"weapon" : "fire ball",
"initiative bonus" : 4,
"attack bonus" : 2,
"damage" : 4,
"athletics" : 2
}
}
characters = copy.deepcopy(original_characters)
def choose_character(characters):
choices = ["first", "second", "third", "1", "2", "3"]
#print("Please choose a character from the following list: ") #remove the printing statements from the functions
for char_num, char_inf in characters.items():
description = (
f"{char_num.capitalize()} option is a {char_inf['race']} {char_inf['class']} "
f"with {char_inf['hit points']} hit points and an armor class of {char_inf['armor_class']}. "
f"They wield a {char_inf['weapon']} with an attack bonus of {char_inf['attack bonus']} and "
f"deal {char_inf['damage']} damage. Their initiative bonus is {char_inf['initiative bonus']} and "
f"they have an athletics skill of {char_inf['athletics']}."
)
print(description)
print()
while True:
char_choice = str(input("To choose a character, please write 1) first, 2) second or 3) third, accordingly: ")).lower()
if char_choice in choices:
if char_choice == "1":
return "first"
elif char_choice == "2":
return "second"
elif char_choice == "3":
return "third"
else:
return char_choice
else:
print("This is not an option.")
# Function for naming the character:
# naming the character, giving a detailed description of the character?
def name_character():
while True:
name = input("Please give a name to your character: ").capitalize()
if name.isalpha():
print(f"Greetings, {name}!")
print()
return name
else:
print("Please enter a name that contains only letters and no spaces.")
# Function for detailed description:
def descr_character(char_choice, character_name):
print(yellow(f"{" Character's description ":*^40}"))
if char_choice == "first":
with open("dwarf.txt", encoding='utf-8') as descr_file:
caption_text = descr_file.read().replace("\n", " ")
display_image(dwarf_img, character_name, caption_text)
return character_name, caption_text
elif char_choice == "second":
with open("elf.txt", encoding='utf-8') as descr_file:
caption_text = descr_file.read().replace("\n", " ")
display_image(elf_img, character_name, caption_text)
return character_name, caption_text
else:
with open("human.txt", encoding='utf-8') as descr_file:
caption_text = descr_file.read().replace("\n", " ")
display_image(wizzard_img, character_name, caption_text)
return character_name, caption_text
# include the intro to the game in this module
def game_intro():
print(yellow(f"{" Welcome ":*^40}"))
with open("intro.txt", encoding='utf-8') as intro_file: # starting the game with a short intro about it
content = intro_file.read().replace("\n", " ")
return content