Henry spricht wieder.

Boxsack ist benutzbar.
This commit is contained in:
Olli Graf
2022-06-20 18:00:34 +02:00
parent e1bf16aa96
commit 740833541b
5 changed files with 94 additions and 14 deletions

View File

@@ -1,10 +1,61 @@
import logging
import FileReader
class HilfeModul():
def isBlank(self,str):
if str != None and len(str.strip()) == 0:
return True
return False
def __init__(self, world):
self.world = world
def readTxt(self, datei):
logging.debug(f'öffne Hilfedatei {datei}')
reader = FileReader.FileReader(datei)
lines = reader.lines()
reader = None
# reader.close()
return lines
def hilfe(self, command):
generalHelp = True
if not self.isBlank(command):
helptxt = self.findHilfetext(command)
logging.debug(f'Hilfetext: {helptxt}')
if helptxt != None:
lines = self.readTxt(helptxt)
logging.debug(f'lines: {lines}')
self.world.printHilfe(lines)
generalHelp = False
if generalHelp:
if command == 'befehle':
self.world.printBefehle()
else:
self.world.printText('hilfe')
def findHilfetext(self, command):
logging.debug(f'suche Hilfetext zu {command}')
for cmdid in range(0,len(self.world.befehle)):
if str(cmdid) in self.world.befehle:
befehl = self.world.befehle[str(cmdid)]
logging.debug(f'cmdid= {cmdid}')
# logging.debug(f'vergleiche {befehl.name.lower()} mit {command.lower()}')
if befehl.name.lower() == command.lower():
logging.debug(f'gefundener Befehl: {befehl.name}')
return f'ascii/hilfe/cmd-{befehl.key}.txt'
return None