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
from random import randint
from functions import startGame, typingPrint, typingInput
@@ -20,6 +16,7 @@ class Player:
self.race = race
self.job = job
# Health
self.hitDie = randint(1, 6)
self.currentHP = 100
self.maxHP = 100
# Levels
@@ -65,10 +62,6 @@ class Player:
},
}
# @property
# def dexMod(self):
# return self.mods["Dexterity"]
def getModifier(self):
self.mods["Strength"] = -5 + self.stats["Strength"] // 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["Charisma"] = -5 + self.stats["Charisma"] // 2
def set_stats(self):
if self.race == "elf":
self.stats["Dexterity"] += 2
self.stats["Intelligence"] += 2
elif self.race == "human":
self.stats["Strength"] += 2
self.stats["Constitution"] += 2
elif self.race == "dwarf":
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
def set_stats_race(self):
if self.race.lower() == "human":
print("Human")
self.stats["Strength"] += 1,
self.stats["Dexterity"] += 1,
self.stats["Constitution"] += 1,
self.stats["Intelligence"] += 1,
self.stats["Wisdom"] += 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):
"""Prints a display of the user's current statistics."""
typingPrint("Your current stats are:\n", time)
@@ -105,6 +117,7 @@ class Player:
typingPrint(f'Dexterity: {self.stats["Dexterity"]}\n', time)
typingPrint(f'Constitution: {self.stats["Constitution"]}\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)
def current_equip(self):
@@ -116,50 +129,18 @@ class Player:
def new_char(self):
"""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()
print(' ')
self.set_stats_race()
self.set_stats_job()
self.getModifier()
self.current_stats()
print(' ')
time.sleep(2)
time.sleep(1)
self.current_equip()
print(' ')
# current_inventory()
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):
"""Print out current/max HP"""
print(f'You have {self.currentHP}/{self.maxHP} HP.')
@@ -172,53 +153,44 @@ class Player:
self.currentHP -= damage
return damage
def dicerolls(self):
"""Rolling 4d6 to get stat value for PC"""
rolls = []
# roll 4d6
for roll in range(4):
r = randint(1, 6)
rolls.append(r)
# Drop the lowest number and then add to single value
del rolls[rolls.index(min(rolls))]
val = sum(rolls)
return str(val)
def allocation(self):
# Display rolls and instructions
rolls = []
stats = []
attributes = ["Strength", "Dexterity", "Constitution", "Intelligence", "Wisdom", "Charisma"]
for _ in range(6):
stats.append((Player.dicerolls(self)))
while len(stats) != 6:
# roll 4d6
for roll in range(4):
r = randint(1, 6)
rolls.append(r)
# Drop the lowest number and then add to single value
del rolls[rolls.index(min(rolls))]
val = sum(rolls)
stats.append(str(val))
rolls = []
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"
"Type 'Finish' when you think you're ready to view your allocation before replacing or continuing.\n")
"For example, '10 strength' will assign the stat 10 to your strength, if you have a 10 showing.\n")
print("Please select a stat and an attribute")
print("Your rolled stats are:\n" + ', '.join(stats) + "\n")
print("Your attributes are:\n" + ', '.join(attributes) + "\n")
# Allocate
while len(stats) != 0:
input_text = input("> ").title()
input_text = input(">> ").title()
words = input_text.split()
print(words[0], words[1], len(stats))
if words[0] in stats and words[1] in attributes:
self.stats[words[1]] += int(words[0])
stats.remove(words[0])
attributes.remove(words[1])
if len(stats) == 0:
print("")
break
print("The remaining options are:\n")
print(stats)
print(attributes)
elif words[0] in ["fin", "end", "finish", "cont", "continue"]:
print(self.stats)
break
print(', '.join(stats))
print(', '.join(attributes))
else:
print("Error")
break
print("Error. Input was not recognised. Please try again with 'Number' + 'Attribute'.")
continue
class Scene(object):
@@ -371,35 +343,24 @@ tornRags = Armor(
dmgRes="None",
magical=False
)
# user = Player(*startGame())
user = Player("Jamie", "Male", 29, "Elf", "Mage")
class Begin(Scene):
name = "Welcome to Kanjin"
descrip = "Chocolate"
descTrue = "You return to the cave entrance."
descFalse = "You are standing at the entryway to a cave."
has_visited = True
name = "Kanjin - An RPG Text Adventure"
with open('EntryDescrip.txt') as d:
desc = d.read()
def enter(self):
typingPrint(f'\n===================\n', time)
typingPrint(f'{Begin.name}', time)
typingPrint(f'\n===================\n', time)
if self.has_visited:
typingPrint(f'\n{self.descTrue}\n'
f'\n', time)
else:
typingPrint(f'===========\n{self.descFalse}\n', time)
Begin.has_visited = True
# print("")
# typingPrint(f'{Begin.name}', time)
# print("")
# typingPrint(f'\n{self.desc}\n'
# f'\n', time)
# user = Player(*startGame())
user.new_char()
action = "begin"
if action == "begin":
typingPrint("result", time)
return "pod"
return "tutorial"
class CaveEntrance(Scene):
@@ -487,10 +448,11 @@ class A1(Scene):
# pass
class EscapePod(Scene):
name = "Escape Pod"
with open('pod.txt') as d:
descrip = d.read()
class Tutorial(Scene):
name = "Tutorial Level"
descrip = ("There are certain commands that will be available almost anytime you are able to type,\n"
"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):
print(f'\n===========\n'
@@ -521,7 +483,7 @@ class Map(object):
'A1': A1(),
# 'death': Death(),
# 'bridge': TheBridge(),
'pod': EscapePod(),
'Tutorial': Tutorial(),
"begin": Begin()
}