Update Kanjin-Engine

This commit is contained in:
KansaiGaijin
2022-01-27 21:08:21 +13:00
committed by GitHub
parent 3d2b0fea3a
commit b20b521cb0

View File

@@ -1,5 +1,5 @@
import time import time
from functions import startGame, wait, parse, process_command from functions import startGame, wait, parse, get_instructions, query_equip
from random import randint from random import randint
from enum import Enum, auto from enum import Enum, auto
@@ -132,7 +132,7 @@ class Player:
if key == "equipped" and value == False: if key == "equipped" and value == False:
values = item_value.values() values = item_value.values()
values_list = list(values) values_list = list(values)
count_value = {values_list[0]} count_value = values_list[0]
print(f'{item_key.name} x {count_value}\n' print(f'{item_key.name} x {count_value}\n'
f' {item_key.description}\n') f' {item_key.description}\n')
@@ -273,13 +273,11 @@ class DamageMod(Enum):
class Item: class Item:
"""The base class for all items""" """The base class for all items"""
def __init__(self): def __init__(self, name, description, value, magical):
self.name = "" self.name = name
self.description = "Not much to look at." self.description = description
self.use_description = "Nothing happens." self.value = value
self.aliases = [] self.magical = magical
self.value = ""
self.magical = None
def __repr__(self): def __repr__(self):
return f"{self.name}\n=====\n{self.description}\nValue: {self.value}\n" return f"{self.name}\n=====\n{self.description}\nValue: {self.value}\n"
@@ -288,26 +286,28 @@ class Item:
class Money(Item): class Money(Item):
"""The currency item used in the world of Kanjin""" """The currency item used in the world of Kanjin"""
def __init__(self): def __init__(self, name, amt, magical):
super().__init__() self.name = name
self.name = "" self.amt = amt
self.description = f"A small round coin made of {self.name.lower()} " \ self.magical = magical
f"with the imperial city logo stamped on the face." super().__init__(name=self.name,
self.amt = "" description=f"A small round coin made of {self.name.lower()} "
self.magical = None f"with the imperial city logo stamped on the face.",
value=self.amt,
magical=self.magical)
class Weapon(Item): class Weapon(Item):
"""The base class for all weapons""" """The base class for all weapons"""
def __init__(self): def __init__(self, name, description, value, damage1H, damage2H, dmgType, dmgMod, versatile, thrown, magical):
super().__init__() self.damage1H = damage1H
self.damage1H = None self.damage2H = damage2H
self.damage2H = None self.dmgType = dmgType
self.dmgType = None self.dmgMod = dmgMod
self.dmgMod = None self.versatile = versatile
self.versatile = None self.thrown = thrown
self.thrown = None super().__init__(name, description, value, magical)
def __repr__(self): def __repr__(self):
return f"{self.name}\n=====\n{self.description}\nValue: {self.value}" \ return f"{self.name}\n=====\n{self.description}\nValue: {self.value}" \
@@ -319,12 +319,12 @@ class Weapon(Item):
class Armor(Item): class Armor(Item):
"""The base class for all armor""" """The base class for all armor"""
def __init__(self): def __init__(self, name, description, value, grade, ac, disadvantage, dmgRes, magical):
self.grade = None self.grade = grade
self.ac = None self.ac = ac
self.stealthDis = None self.stealthDis = disadvantage
self.dmgRes = None self.dmgRes = dmgRes
super().__init__() super().__init__(name, description, value, magical)
def __repr__(self): def __repr__(self):
if self.stealthDis: if self.stealthDis:
@@ -335,44 +335,65 @@ class Armor(Item):
f"AC: {self.ac}\nDisadvantage on Stealth checks: {self.stealthDis}\nMagical: {self.magical}" f"AC: {self.ac}\nDisadvantage on Stealth checks: {self.stealthDis}\nMagical: {self.magical}"
def process_command(command, object1):
# output = "Press enter to begin"
# if command:
# output = "Command not understood"
if command == "help":
output = get_instructions()
elif command == "inventory":
output = user.current_inventory()
elif command == "equipment":
response = query_equip()
if response == "view":
output = user.current_equip()
elif response == "change":
output = "Sorry that feature isn't ready yet."
elif command == "examine":
if object1 is not None:
output = object1.descrip
else:
output = "Unable to examine that."
elif command == "take":
if object1 is not None:
output = user.add_inventory(object1)
else:
output = "Unable to take that."
elif command == "error":
output = "Command not recognised."
return output
# Different types of coins # Different types of coins
GP1 = Money() GP1 = Money("Gold", 1, False)
GP1.name = "Gold" SP1 = Money("Silver", 1, False)
GP1.amt = 1 CP1 = Money("Copper", 1, False)
GP1.magical = False
SP1 = Money()
SP1.name = "Silver"
SP1.amt = 1
SP1.magical = False
CP1 = Money()
CP1.name = "Copper"
CP1.amt = 1
CP1.magical = False
# starting equip # starting equip
rock = Weapon() rock = Weapon(
rock.name = "Rock" name="Rock",
rock.description = "A fist-sized rock, suitable for bludgeoning." description="A fist-sized rock, suitable for bludgeoning.",
rock.value = "No value" value="No value",
rock.damage1H = randint(1, 6) damage1H=randint(1, 6),
rock.damage2H = 0 damage2H=0,
rock.dmgType = DamageType.CRUSHING dmgType=DamageType.CRUSHING,
rock.dmgMod = DamageMod.STRENGTH dmgMod=DamageMod.STRENGTH,
rock.vers = False versatile=False,
rock.thrown = True thrown=True,
rock.magical = False magical=False
)
tornRags = Armor() tornRags = Armor(
tornRags.name = "Torn Rags" name="Torn Rags",
tornRags.description = "A ripped and worn-out outfit." description="A ripped and worn-out outfit.",
tornRags.value = 0 value=0,
tornRags.grade = "Light" grade="Light",
tornRags.ac = 0 ac=0,
tornRags.disadvantage = True disadvantage=True,
tornRags.dmgRes = "None" dmgRes="None",
tornRags.magical = False magical=False
)
user = Player("Jamie", "Male", 29, "Elf", "Mage") user = Player("Jamie", "Male", 29, "Elf", "Mage")
@@ -492,7 +513,7 @@ class Tutorial(Scene):
descrip = ("There are certain commands that will be available almost anytime you are able to type,\n" 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" "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" "You can also view your stats including your current and max hp.\n"
"Give it a go starting with 'Check inventory', 'Check equipment', and 'View stats'." "Give it a go starting with 'Check inventory', 'Check equipment', and 'View stats'.\n"
"See what else you can do, then enter 'continue' to move to the next step.") "See what else you can do, then enter 'continue' to move to the next step.")
def enter(self): def enter(self):
@@ -500,11 +521,12 @@ class Tutorial(Scene):
f'{self.name}' f'{self.name}'
f'\n===========\n' f'\n===========\n'
f'{self.descrip}') f'{self.descrip}')
action = input(">> ") action = input(">> ").lower()
if action != "continue": while action != "continue":
pass process_command(*parse(action))
else: action = input(">> ")
process_command(*parse(action))() if action == "continue":
return "begin"
# if action == "shoot!": # if action == "shoot!":
# print("result") # print("result")