clean repo
This commit is contained in:
parent
7556fb57c5
commit
47797bd9fe
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Alexander Popov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -1,24 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
__author__ = 'Alexander Popov'
|
||||
__version__ = '1.0.0'
|
||||
__license__ = 'MIT'
|
||||
|
||||
usQwertyKeyboard = 'abcdefghijklmnopqrstuvwxyz'.upper()
|
||||
|
||||
def genKeys(alphabet):
|
||||
keys = list()
|
||||
|
||||
for letter in alphabet:
|
||||
keys.append(
|
||||
'<button id="{l}" onclick="offChar(\'{l}\')">{l}</button>'
|
||||
.format(l=letter))
|
||||
|
||||
return(keys)
|
||||
|
||||
if __name__ == '__main__':
|
||||
with open('keys.html', 'w+', encoding='utf-8') as f:
|
||||
keyboard = genKeys(usQwertyKeyboard)
|
||||
|
||||
for item in keyboard:
|
||||
f.write(item)
|
BIN
docs/screen.png
BIN
docs/screen.png
Binary file not shown.
Before Width: | Height: | Size: 3.6 KiB |
62
hgman.py
62
hgman.py
@ -1,62 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import random
|
||||
|
||||
__author__ = 'Alexander Popov'
|
||||
__version__ = '1.0.0'
|
||||
__license__ = 'MIT'
|
||||
|
||||
wordsDb = list()
|
||||
|
||||
# for count, line in enumerate(sys.stdin):
|
||||
# if not line in wordsDb:
|
||||
# wordsDb.append(line.rstrip())
|
||||
with open('words.txt', 'r', encoding='utf-8') as f:
|
||||
for count, line in enumerate(f.readlines()):
|
||||
if line not in wordsDb:
|
||||
wordsDb.append(line.rstrip())
|
||||
|
||||
|
||||
class Player:
|
||||
def __init__(self, gameWord):
|
||||
self.Health = 6
|
||||
self.Word = '-' * len(gameWord)
|
||||
|
||||
def answer(self, newWords=None):
|
||||
if newWords:
|
||||
self.Word = newWords
|
||||
return(self.Word)
|
||||
|
||||
def lives(self):
|
||||
return(self.Health)
|
||||
|
||||
def crap(self):
|
||||
self.Health -= 1
|
||||
pass
|
||||
|
||||
gameWord = random.choice(wordsDb)
|
||||
Gamer = Player(gameWord)
|
||||
|
||||
while Gamer.answer() != gameWord:
|
||||
if Gamer.lives() < 0:
|
||||
print('You are dead')
|
||||
break
|
||||
|
||||
print('%d : %s' % (Gamer.lives(), Gamer.answer(),))
|
||||
|
||||
offWord = input()
|
||||
|
||||
wordIndex = [index for index, char in enumerate(gameWord)
|
||||
if char == offWord]
|
||||
|
||||
if len(wordIndex) != 0:
|
||||
for index in wordIndex:
|
||||
aaa = list(Gamer.answer())
|
||||
aaa[index] = offWord
|
||||
Gamer.answer("".join(aaa))
|
||||
else:
|
||||
Gamer.crap()
|
||||
|
||||
if not Gamer.lives() < 0:
|
||||
print('Won!')
|
Loading…
Reference in New Issue
Block a user