Update Kanjin-Engine

This commit is contained in:
KansaiGaijin
2022-01-26 17:55:04 +13:00
committed by GitHub
parent 5d7522885f
commit 0f23c5ca61

View File

@@ -1,8 +1,9 @@
import time import time
from functions import startGame
from random import randint from random import randint
from functions import startGame, typingPrint
from enum import Enum, auto from enum import Enum, auto
# pyinstaller --onefile --paths=C:\Users\kasai\PycharmProjects\pythonProject\Kanjin\KanjinEngine.py # pyinstaller --onefile --paths=C:\Users\kasai\PycharmProjects\pythonProject\Kanjin\KanjinEngine.py
@@ -74,7 +75,6 @@ class Player:
def set_stats_race(self): def set_stats_race(self):
if self.race.lower() == "human": if self.race.lower() == "human":
print("Human")
self.stats["Strength"] += 1, self.stats["Strength"] += 1,
self.stats["Dexterity"] += 1, self.stats["Dexterity"] += 1,
self.stats["Constitution"] += 1, self.stats["Constitution"] += 1,
@@ -83,51 +83,46 @@ class Player:
self.stats["Charisma"] += 1 self.stats["Charisma"] += 1
elif self.race.lower() == "elf": elif self.race.lower() == "elf":
print("Elf")
self.stats["Dexterity"] += 2 self.stats["Dexterity"] += 2
self.stats["Intelligence"] += 1 self.stats["Intelligence"] += 1
elif self.race.lower() == "dwarf": elif self.race.lower() == "dwarf":
print("Dwarf")
self.stats["Constitution"] += 2 self.stats["Constitution"] += 2
self.stats["Wisdom"] += 1 self.stats["Wisdom"] += 1
def set_stats_job(self): def set_stats_job(self):
if self.job.lower() == "warrior": if self.job.lower() == "warrior":
print("Warrior")
self.hitDie = randint(1, 12) self.hitDie = randint(1, 12)
self.maxHP = (12 + self.mods["Constitution"]) self.maxHP = (12 + self.mods["Constitution"])
self.currentHP = (12 + self.mods["Constitution"]) self.currentHP = (12 + self.mods["Constitution"])
elif self.job.lower() == "ranger": elif self.job.lower() == "ranger":
print("Ranger")
self.hitDie = randint(1, 10) self.hitDie = randint(1, 10)
self.maxHP = (10 + self.mods["Constitution"]) self.maxHP = (10 + self.mods["Constitution"])
self.currentHP = (10 + self.mods["Constitution"]) self.currentHP = (10 + self.mods["Constitution"])
elif self.job.lower() == "mage": elif self.job.lower() == "mage":
print("Mage")
self.hitDie = randint(1, 8) self.hitDie = randint(1, 8)
self.maxHP = (8 + self.mods["Constitution"]) self.maxHP = (8 + self.mods["Constitution"])
self.currentHP = (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:", time) print("Your current stats are:")
typingPrint(f'Hit Points: {self.currentHP}/{self.maxHP}', time) print(f'Hit Points: {self.currentHP}/{self.maxHP}')
typingPrint(f'Strength: {self.stats["Strength"]}', time) print(f'Strength: {self.stats["Strength"]}')
typingPrint(f'Dexterity: {self.stats["Dexterity"]}', time) print(f'Dexterity: {self.stats["Dexterity"]}')
typingPrint(f'Constitution: {self.stats["Constitution"]}', time) print(f'Constitution: {self.stats["Constitution"]}')
typingPrint(f'Intelligence: {self.stats["Intelligence"]}', time) print(f'Intelligence: {self.stats["Intelligence"]}')
typingPrint(f'Wisdom: {self.stats["Wisdom"]}', time) print(f'Wisdom: {self.stats["Wisdom"]}')
typingPrint(f'Charisma: {self.stats["Charisma"]}', time) print(f'Charisma: {self.stats["Charisma"]}')
def current_equip(self): def current_equip(self):
"""Prints a list of items currently equipped.""" """Prints a list of items currently equipped."""
typingPrint(f"You have equipped:\n {self.armor.name}\n" print(f"You have equipped:\n {self.armor.name}\n"
f" {self.armor.description}" f" {self.armor.description}"
f"\n{self.weapon.name}\n" f"\n{self.weapon.name}\n"
f" {self.weapon.description}\n", time) f" {self.weapon.description}\n")
def new_char(self): def new_char(self):
"""Outputs final stats, armour, and inventory""" """Outputs final stats, armour, and inventory"""
@@ -170,12 +165,11 @@ class Player:
stats.append(str(val)) stats.append(str(val))
rolls = [] rolls = []
typingPrint("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")
time) print("Please select a stat and an attribute.\n\n")
typingPrint("Please select a stat and an attribute.\n\n", time) print("Your rolled stats are:\n" + ', '.join(stats) + "\n\n")
typingPrint("Your rolled stats are:\n" + ', '.join(stats) + "\n\n", time) print("Your attributes are:\n" + ', '.join(attributes) + "\n\n")
typingPrint("Your attributes are:\n" + ', '.join(attributes) + "\n\n", time)
# Allocate # Allocate
while len(stats) != 0: while len(stats) != 0:
@@ -188,11 +182,11 @@ class Player:
if len(stats) == 0: if len(stats) == 0:
print("") print("")
break break
typingPrint("The remaining options are:\n", time) print("The remaining options are:\n")
typingPrint(', '.join(stats), time) print(', '.join(stats))
typingPrint(', '.join(attributes), time) print(', '.join(attributes))
else: else:
typingPrint("Error. Input was not recognised. Please try again with 'Number' + 'Attribute'.", time) print("Error. Input was not recognised. Please try again with 'Number' + 'Attribute'.")
continue continue
@@ -348,8 +342,11 @@ tornRags = Armor(
) )
# user = Player("Jamie", "Male", 29, "Elf", "Mage") # user = Player("Jamie", "Male", 29, "Elf", "Mage")
user = Player(*startGame()) user = Player(*startGame())
# enter() needs to return a map name.
class Begin(Scene): class Begin(Scene):
name = "Kanjin - An RPG Text Adventure" name = "Kanjin - An RPG Text Adventure"
@@ -360,8 +357,13 @@ class Begin(Scene):
"After character creation, type 'Help' to view a list of commands and explanations." "After character creation, type 'Help' to view a list of commands and explanations."
def enter(self): def enter(self):
# user.new_char()
pass print(f'\n===========\n'
f'{self.name}')
print(f'\n===========\n'
f'{self.desc}')
user.new_char()
return "Cave entrance"
class CaveEntrance(Scene): class CaveEntrance(Scene):
@@ -371,12 +373,12 @@ class CaveEntrance(Scene):
has_visited = False has_visited = False
def enter(self): def enter(self):
typingPrint(f'\n===========\n' print(f'\n===========\n'
f'{self.name}', time) f'{self.name}')
if not self.has_visited: if not self.has_visited:
typingPrint(self.descTrue, time) print(self.descTrue)
else: else:
typingPrint(self.descTrue, time) print(self.descTrue)
action = input(">> ") action = input(">> ")