Skip to content

Commit

Permalink
initialize termo
Browse files Browse the repository at this point in the history
  • Loading branch information
GussSoares committed Feb 14, 2022
1 parent d2a9d51 commit c5f7270
Show file tree
Hide file tree
Showing 11 changed files with 10,768 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .github/workflows/publish-package-on-release.yaml
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 }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/

# Poetry
poetry.lock
36 changes: 35 additions & 1 deletion README.md
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.
1 change: 1 addition & 0 deletions my_termo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.1.0'
89 changes: 89 additions & 0 deletions my_termo/main.py
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 πŸ˜ŠπŸ‘‹")
11 changes: 11 additions & 0 deletions my_termo/raffle.py
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))
Loading

0 comments on commit c5f7270

Please sign in to comment.