Added shelter and things needed for it (incomplete)
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -188,3 +188,6 @@ cython_debug/
|
|||||||
# Built Visual Studio Code Extensions
|
# Built Visual Studio Code Extensions
|
||||||
*.vsix
|
*.vsix
|
||||||
|
|
||||||
|
|
||||||
|
# Whiskerbound specific stuff
|
||||||
|
*.kitten
|
||||||
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"files.exclude": {
|
"files.exclude": {
|
||||||
".gitignore": true,
|
".gitignore": false,
|
||||||
"LICENSE": true,
|
"LICENSE": false,
|
||||||
"README.md": true,
|
"README.md": false,
|
||||||
".vscode/": true
|
".vscode/": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
game.py
4
game.py
@@ -1,7 +1,7 @@
|
|||||||
from data.cat import Cat
|
from data.cat import Cat
|
||||||
from systems.ui import clear, title
|
from systems.ui import clear, title
|
||||||
from systems.world import shelter
|
from systems.world import shelter
|
||||||
import questionary
|
import systems.ui as ui
|
||||||
|
|
||||||
|
|
||||||
class Game:
|
class Game:
|
||||||
@@ -19,7 +19,7 @@ class Game:
|
|||||||
def run(self):
|
def run(self):
|
||||||
title()
|
title()
|
||||||
print("Welcome to Whiskerbound!")
|
print("Welcome to Whiskerbound!")
|
||||||
choice = questionary.select("", choices=["New Game", "Quit"]).ask()
|
choice = ui.select("", choices=["New Game", "Quit"])
|
||||||
|
|
||||||
if choice == "New Game":
|
if choice == "New Game":
|
||||||
self.new_game()
|
self.new_game()
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import questionary
|
||||||
|
|
||||||
|
|
||||||
def clear():
|
def clear():
|
||||||
@@ -8,3 +9,23 @@ def clear():
|
|||||||
def title():
|
def title():
|
||||||
clear()
|
clear()
|
||||||
print("=== Whiskerbound ===\n")
|
print("=== Whiskerbound ===\n")
|
||||||
|
|
||||||
|
|
||||||
|
STYLE = questionary.Style(
|
||||||
|
[
|
||||||
|
("selected", "fg:cyan bold"),
|
||||||
|
("pointer", "fg:cyan bold"),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def select(message, choices):
|
||||||
|
return questionary.select(message, choices=choices, style=STYLE).ask()
|
||||||
|
|
||||||
|
|
||||||
|
def text(message, default=""):
|
||||||
|
return questionary.text(message, default=default, style=STYLE).ask()
|
||||||
|
|
||||||
|
|
||||||
|
def confirm(message, default=True):
|
||||||
|
return questionary.confirm(message, default=default, style=STYLE).ask()
|
||||||
|
|||||||
@@ -1,7 +1,26 @@
|
|||||||
from data.cat import Cat
|
from data.cat import Cat
|
||||||
|
import systems.ui as ui
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def check_cat_name(name):
|
||||||
|
name = name.strip()
|
||||||
|
if not name:
|
||||||
|
return "Please choose a name:"
|
||||||
|
if len(name) > 4 or len(name) < 20:
|
||||||
|
return "Please choose a name greater than 4 charecters and less than 20:"
|
||||||
|
if re.search(r"[^a-zA-Z \-']", name):
|
||||||
|
return "Please only use letters, spaces, hyphens and apostrophes:"
|
||||||
|
return "Ok"
|
||||||
|
|
||||||
|
|
||||||
def shelter():
|
def shelter():
|
||||||
# TODO: make
|
# TODO: make
|
||||||
name = input("Name your cat: ")
|
name = ui.text("Welcome to the shelter! Please choose a name for your cat:")
|
||||||
|
while True:
|
||||||
|
check_result = check_cat_name(name)
|
||||||
|
if check_result != "Ok":
|
||||||
|
name = ui.text(check_result)
|
||||||
|
else:
|
||||||
|
break
|
||||||
return Cat(name)
|
return Cat(name)
|
||||||
|
|||||||
Reference in New Issue
Block a user