Character Creation Update

CC is almost complete, need to create a magic system, then should be all done.
This commit is contained in:
KansaiGaijin
2022-01-15 20:19:07 +13:00
committed by GitHub
parent d051d815be
commit 2c32d67bdc

View File

@@ -1,7 +1,3 @@
# This file contains all classes for player, objects, and scenes.
# All interactable items will also be created here.
# The game engine can be found at the bottom.
import time import time
from random import randint from random import randint
from functions import startGame, typingPrint, typingInput from functions import startGame, typingPrint, typingInput
@@ -20,6 +16,7 @@ class Player:
self.race = race self.race = race
self.job = job self.job = job
# Health # Health
self.hitDie = randint(1, 6)
self.currentHP = 100 self.currentHP = 100
self.maxHP = 100 self.maxHP = 100
# Levels # Levels
@@ -65,10 +62,6 @@ class Player:
}, },
} }
# @property
# def dexMod(self):
# return self.mods["Dexterity"]
def getModifier(self): def getModifier(self):
self.mods["Strength"] = -5 + self.stats["Strength"] // 2 self.mods["Strength"] = -5 + self.stats["Strength"] // 2
self.mods["Dexterity"] = -5 + self.stats["Dexterity"] // 2 self.mods["Dexterity"] = -5 + self.stats["Dexterity"] // 2
@@ -77,26 +70,45 @@ class Player:
self.mods["Wisdom"] = -5 + self.stats["Wisdom"] // 2 self.mods["Wisdom"] = -5 + self.stats["Wisdom"] // 2
self.mods["Charisma"] = -5 + self.stats["Charisma"] // 2 self.mods["Charisma"] = -5 + self.stats["Charisma"] // 2
def set_stats(self): def set_stats_race(self):
if self.race == "elf": if self.race.lower() == "human":
self.stats["Dexterity"] += 2 print("Human")
self.stats["Intelligence"] += 2 self.stats["Strength"] += 1,
elif self.race == "human": self.stats["Dexterity"] += 1,
self.stats["Strength"] += 2 self.stats["Constitution"] += 1,
self.stats["Constitution"] += 2 self.stats["Intelligence"] += 1,
elif self.race == "dwarf": self.stats["Wisdom"] += 1,
self.stats["Constitution"] += 2
self.stats["Strength"] += 2
elif self.job == "warrior":
self.stats["Strength"] += 2
self.stats["Constitution"] += 1
elif self.job == "ranger":
self.stats["Dexterity"] += 2
self.stats["Charisma"] += 1
elif self.job == "mage":
self.stats["Intelligence"] += 2
self.stats["Charisma"] += 1 self.stats["Charisma"] += 1
elif self.race.lower() == "elf":
print("Elf")
self.stats["Dexterity"] += 2
self.stats["Intelligence"] += 1
elif self.race.lower() == "dwarf":
print("Dwarf")
self.stats["Constitution"] += 2
self.stats["Wisdom"] += 1
def set_stats_job(self):
if self.job.lower() == "warrior":
print("Warrior")
self.hitDie = randint(1, 12)
self.maxHP = (12 + self.mods["Constitution"])
self.currentHP = (12 + self.mods["Constitution"])
elif self.job.lower() == "ranger":
print("Ranger")
self.hitDie = randint(1, 10)
self.maxHP = (10 + self.mods["Constitution"])
self.currentHP = (10 + self.mods["Constitution"])
elif self.job.lower() == "mage":
print("Mage")
self.hitDie = randint(1, 8)
self.maxHP = (8 + self.mods["Constitution"])
self.currentHP = (8 + self.mods["Constitution"])
def current_stats(self): def current_stats(self):
"""Prints a display of the user's current statistics.""" """Prints a display of the user's current statistics."""
typingPrint("Your current stats are:\n", time) typingPrint("Your current stats are:\n", time)
@@ -105,6 +117,7 @@ class Player:
typingPrint(f'Dexterity: {self.stats["Dexterity"]}\n', time) typingPrint(f'Dexterity: {self.stats["Dexterity"]}\n', time)
typingPrint(f'Constitution: {self.stats["Constitution"]}\n', time) typingPrint(f'Constitution: {self.stats["Constitution"]}\n', time)
typingPrint(f'Intelligence: {self.stats["Intelligence"]}\n', time) typingPrint(f'Intelligence: {self.stats["Intelligence"]}\n', time)
typingPrint(f'Wisdom: {self.stats["Wisdom"]}\n', time)
typingPrint(f'Charisma: {self.stats["Charisma"]}\n', time) typingPrint(f'Charisma: {self.stats["Charisma"]}\n', time)
def current_equip(self): def current_equip(self):
@@ -116,50 +129,18 @@ class Player:
def new_char(self): def new_char(self):
"""Outputs final stats, armour, and inventory""" """Outputs final stats, armour, and inventory"""
# typingPrint("We will now generate random stats for your character.\n", time)
# typingPrint("Adjusting for your race and class bonuses.\n", time)
# print(' ')
# time.sleep(2)
self.dicerolls()
self.allocation() self.allocation()
print(' ') self.set_stats_race()
self.set_stats_job()
self.getModifier() self.getModifier()
self.current_stats() self.current_stats()
print(' ') print(' ')
time.sleep(2) time.sleep(1)
self.current_equip() self.current_equip()
print(' ') print(' ')
# current_inventory() # current_inventory()
print(' ') print(' ')
def rollStats(self):
"""Rolls stats 4d6kh3"""
# Roll stats
typingPrint("Rolling for Strength...\n", time)
self.dice_rolls("Strength")
typingPrint(f'Strength: {self.stats["Strength"]}\n', time)
time.sleep(1)
typingPrint("Rolling for Dexterity...\n", time)
self.dice_rolls("Dexterity")
typingPrint(f'Dexterity: {self.stats["Dexterity"]}\n', time)
time.sleep(1)
typingPrint("Rolling for Constitution...\n", time)
self.dice_rolls("Constitution")
typingPrint(f'Constitution: {self.stats["Constitution"]}\n', time)
time.sleep(1)
typingPrint("Rolling for Intelligence...\n", time)
self.dice_rolls("Intelligence")
typingPrint(f'Intelligence: {self.stats["Intelligence"]}\n', time)
time.sleep(1)
typingPrint("Rolling for Wisdom...\n", time)
self.dice_rolls("Wisdom")
typingPrint(f'Wisdom: {self.stats["Wisdom"]}\n', time)
time.sleep(1)
typingPrint("Rolling for Charisma...\n", time)
self.dice_rolls("Charisma")
typingPrint(f'Charisma: {self.stats["Charisma"]}\n', time)
time.sleep(1)
def health_check(self): def health_check(self):
"""Print out current/max HP""" """Print out current/max HP"""
print(f'You have {self.currentHP}/{self.maxHP} HP.') print(f'You have {self.currentHP}/{self.maxHP} HP.')
@@ -172,9 +153,11 @@ class Player:
self.currentHP -= damage self.currentHP -= damage
return damage return damage
def dicerolls(self): def allocation(self):
"""Rolling 4d6 to get stat value for PC"""
rolls = [] rolls = []
stats = []
attributes = ["Strength", "Dexterity", "Constitution", "Intelligence", "Wisdom", "Charisma"]
while len(stats) != 6:
# roll 4d6 # roll 4d6
for roll in range(4): for roll in range(4):
r = randint(1, 6) r = randint(1, 6)
@@ -182,43 +165,32 @@ class Player:
# Drop the lowest number and then add to single value # Drop the lowest number and then add to single value
del rolls[rolls.index(min(rolls))] del rolls[rolls.index(min(rolls))]
val = sum(rolls) val = sum(rolls)
return str(val) stats.append(str(val))
rolls = []
def allocation(self):
# Display rolls and instructions
stats = []
attributes = ["Strength", "Dexterity", "Constitution", "Intelligence", "Wisdom", "Charisma"]
for _ in range(6):
stats.append((Player.dicerolls(self)))
print("Please assign a stat to a selected attribute by entering the number then the attribute.\n" print("Please assign a stat to a selected attribute by entering the number then the attribute.\n"
"For example, '10 strength' will assign the stat 10 to your strength, if you have a 10 showing.\n" "For example, '10 strength' will assign the stat 10 to your strength, if you have a 10 showing.\n")
"Type 'Finish' when you think you're ready to view your allocation before replacing or continuing.\n")
print("Please select a stat and an attribute") print("Please select a stat and an attribute")
print("Your rolled stats are:\n" + ', '.join(stats) + "\n") print("Your rolled stats are:\n" + ', '.join(stats) + "\n")
print("Your attributes are:\n" + ', '.join(attributes) + "\n") print("Your attributes are:\n" + ', '.join(attributes) + "\n")
# Allocate # Allocate
while len(stats) != 0: while len(stats) != 0:
input_text = input("> ").title() input_text = input(">> ").title()
words = input_text.split() words = input_text.split()
print(words[0], words[1], len(stats))
if words[0] in stats and words[1] in attributes: if words[0] in stats and words[1] in attributes:
self.stats[words[1]] += int(words[0]) self.stats[words[1]] += int(words[0])
stats.remove(words[0]) stats.remove(words[0])
attributes.remove(words[1]) attributes.remove(words[1])
if len(stats) == 0:
print("")
break
print("The remaining options are:\n") print("The remaining options are:\n")
print(stats) print(', '.join(stats))
print(attributes) print(', '.join(attributes))
elif words[0] in ["fin", "end", "finish", "cont", "continue"]:
print(self.stats)
break
else: else:
print("Error") print("Error. Input was not recognised. Please try again with 'Number' + 'Attribute'.")
break continue
class Scene(object): class Scene(object):
@@ -371,35 +343,24 @@ tornRags = Armor(
dmgRes="None", dmgRes="None",
magical=False magical=False
) )
# user = Player(*startGame())
user = Player("Jamie", "Male", 29, "Elf", "Mage") user = Player("Jamie", "Male", 29, "Elf", "Mage")
class Begin(Scene): class Begin(Scene):
name = "Welcome to Kanjin" name = "Kanjin - An RPG Text Adventure"
descrip = "Chocolate" with open('EntryDescrip.txt') as d:
descTrue = "You return to the cave entrance." desc = d.read()
descFalse = "You are standing at the entryway to a cave."
has_visited = True
def enter(self): def enter(self):
typingPrint(f'\n===================\n', time) # print("")
typingPrint(f'{Begin.name}', time) # typingPrint(f'{Begin.name}', time)
typingPrint(f'\n===================\n', time) # print("")
if self.has_visited: # typingPrint(f'\n{self.desc}\n'
typingPrint(f'\n{self.descTrue}\n' # f'\n', time)
f'\n', time) # user = Player(*startGame())
else:
typingPrint(f'===========\n{self.descFalse}\n', time)
Begin.has_visited = True
user.new_char() user.new_char()
return "tutorial"
action = "begin"
if action == "begin":
typingPrint("result", time)
return "pod"
class CaveEntrance(Scene): class CaveEntrance(Scene):
@@ -487,10 +448,11 @@ class A1(Scene):
# pass # pass
class EscapePod(Scene): class Tutorial(Scene):
name = "Escape Pod" name = "Tutorial Level"
with open('pod.txt') as d: descrip = ("There are certain commands that will be available almost anytime you are able to type,\n"
descrip = d.read() "such as viewing your inventory, checking your equipped items, and also changing them.\n"
"You can also view your stats including your current and max hp.\n")
def enter(self): def enter(self):
print(f'\n===========\n' print(f'\n===========\n'
@@ -521,7 +483,7 @@ class Map(object):
'A1': A1(), 'A1': A1(),
# 'death': Death(), # 'death': Death(),
# 'bridge': TheBridge(), # 'bridge': TheBridge(),
'pod': EscapePod(), 'Tutorial': Tutorial(),
"begin": Begin() "begin": Begin()
} }