-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d2a9d51
commit c5f7270
Showing
11 changed files
with
10,768 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Publish package | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build: | ||
name: Publish package | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: '0' | ||
- name: Set up Python 3.7 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.7' | ||
- name: Install dependencies | ||
run: | | ||
pip install poetry poetry-dynamic-versioning | ||
- name: Publish package on pypi | ||
run: | | ||
poetry build | ||
poetry publish -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,6 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# Poetry | ||
poetry.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,35 @@ | ||
# my-termo | ||
# my-termo | ||
|
||
![termo](termo.gif) | ||
|
||
This is a simple Termo application in command line style. This app run a Linux crontab task every day to get a new word. Type termo in your terminal to guess the daily word πππ | ||
|
||
## Install β¨ | ||
To install termo command line type this | ||
```shell | ||
pip install my-termo | ||
``` | ||
|
||
## Development Instructions βοΈ | ||
|
||
Follow the below instructions to collaborate or run in development mode | ||
|
||
### Dependencies π§ | ||
* `poetry` | ||
* `python` | ||
|
||
### Running π | ||
|
||
To install type this command | ||
```shell | ||
poetry install | ||
``` | ||
|
||
Run termo | ||
```shell | ||
termo | ||
``` | ||
|
||
## Collaborate πππ | ||
|
||
Send issues or insights. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = '0.1.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import os | ||
|
||
from my_termo.raffle import raffle_word | ||
|
||
|
||
COLORS = { | ||
'yellow': 'π¨', | ||
'green': 'π©', | ||
'black': 'β¬' | ||
} | ||
|
||
|
||
def clear(): | ||
"""This function clear console""" | ||
os.system('cls' if os.name=='nt' else 'clear') | ||
|
||
|
||
def show_instructions(): | ||
"""This function print a help text to teach how to play""" | ||
print(""" | ||
Termo is a game to guess a word of the day. | ||
Colors help: | ||
- π©: This color is showned when the letter exist in the word and the position is correctly too. | ||
- π¨: This color is showned when the letter exist in the word bot the position is not correctly. | ||
- β¬: This color is showned when the letter does not exist in the word. | ||
You have 6 attempts. | ||
If you get the word right, TERMO will show the historic of attempts. | ||
""") | ||
input('Type any key to back...') | ||
clear() | ||
|
||
|
||
|
||
def bold(message: str): | ||
return f'\033[1m{message}\033[0m' | ||
|
||
|
||
def termo(): | ||
"""The TERMO game. Type help any moment to show instructions | ||
>>> termo | ||
Welcome to TERMO Command Line π | ||
(type "help" any moment to show instructions) | ||
Type a word: | ||
... | ||
""" | ||
|
||
daily_word = raffle_word() | ||
attempts = 6 | ||
count = 0 | ||
message = '' | ||
final_message = '' | ||
|
||
try: | ||
print('Welcome to TERMO Command Line π') | ||
print('(type "help" any moment to show instructions)\n') | ||
|
||
while count < attempts: | ||
while len(word := input("Type a word: ")) != 5: | ||
if word == 'help': | ||
show_instructions() | ||
else: | ||
print('Only words with 5 letters!') | ||
|
||
for i, letter in enumerate(word): | ||
if letter in daily_word and word[i] == daily_word[i]: | ||
message += COLORS.get('green') | ||
elif letter in daily_word: | ||
message += COLORS.get('yellow') | ||
else: | ||
message += COLORS.get('black') | ||
|
||
final_message += f'{message}\n{" ".join(list(word))}\n' | ||
clear() | ||
print(final_message) | ||
message = '' | ||
count += 1 | ||
|
||
if word == daily_word: | ||
clear() | ||
print(f'\tThe word is {bold(daily_word)}') | ||
print(f'\nThank you for playing my termo π₯³π\n{final_message}') | ||
exit() | ||
print('Sorry π Try again later.') | ||
|
||
except KeyboardInterrupt: | ||
print("\nBye ππ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import json | ||
import random | ||
from datetime import datetime | ||
from pathlib import Path | ||
|
||
|
||
def raffle_word() -> str: | ||
"""This function raffle one word of the words set.""" | ||
with open(Path(__file__).parent / 'words.json') as f: | ||
random.seed(datetime.today().date().toordinal()) | ||
return random.choice(json.load(f)) |
Oops, something went wrong.