Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
Release v0.1.0 (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonymousX86 authored Nov 18, 2023
1 parent 5efb764 commit 5947fd9
Show file tree
Hide file tree
Showing 14 changed files with 526 additions and 0 deletions.
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11.6
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Run FTE",
"type": "python",
"request": "launch",
"module": "FTE",
"console": "integratedTerminal",
"envFile": "${workspaceFolder}/.env",
"justMyCode": true
}
]
}
Empty file added FTE/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions FTE/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
from os import getenv

from FTE.chapters import chapter_one
from FTE.menus import main_menu


if __name__ == '__main__':
if not bool(getenv('DEBUG', False)):
main_menu()
chapter_one()
2 changes: 2 additions & 0 deletions FTE/chapters/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from .one import chapter_one
82 changes: 82 additions & 0 deletions FTE/chapters/one.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# -*- coding: utf-8 -*-
from time import sleep

from rich.text import Text

from FTE.characters import Character, Standing
from FTE.console import console
from FTE.locations import Location
from FTE.settings import DEBUG
from FTE.utils import slow_print, slower_print, story
from FTE.world import World

def chapter_one() -> None:
bridge = Location('Bridge')
capsules = Location('Capsules')
engine_deck = Location('Engine Deck')
quarters = Location('Quarters')

roommate = Character('Hevy', quarters, poke='Good to see you.', standing=Standing.GOOD)
capitan = Character('Rex', bridge, poke='Yes sergant? Oh, wait.')
pilot = Character('Mixiu', bridge, poke='What the fuck do you want?')
engineer = Character('Tech', engine_deck, poke='We should invest in twin ion engines.')

world = World(
all_locations=(bridge, capsules, engine_deck, quarters),
all_characters=(roommate, capitan, pilot, engineer),
starting_location=quarters
)

console.clear()
console.rule('Chapter I')
console.print(3 * '\n')
for line in [
'Year: 3015',
'Ship: Epsilon IV',
'Mission: Who cares?'
]:
slow_print(line, end='')
slower_print('...')
sleep(1.0 if DEBUG else 3.0)

console.clear()
console.rule('Chapter I')
story([
'You wake up in your bed, someone is trying to talk to you, '
'but you\'re too sleepy to understand.',
Text.assemble('You recognize them. I\'s your roommate - ', roommate.display_name, '.'),
'He\'s shaking you and after a while you can finally understand him...'
])
expect = ('no', 'yes')
res = roommate.dialogue('Hey! Man! Are you dead already?')
while res not in expect:
res = roommate.dialogue('...')
char_res = 'Unfortunately no' if res == 'yes' else 'That\'s great'
roommate.monologue(f'{char_res}, now wake up and get a move on, of we\'re screwed.')
roommate.action('Throws you your clothes.')
roommate.monologue('Aight, you ready?')
roommate.action('Claps to you.')
roommate.monologue(Text.assemble(
'We either go to ',
capsules.display_name,
' or to ',
engine_deck.display_name,
', I don\'t trust our engineers tho.'
))
expect = (capsules, engine_deck)
roommate.poke = 'There\'s no time, let\'s go!'
while res != capsules and res != engine_deck:
res = None
while res is None:
res = world.interaction()
if not isinstance(res, Location):
res = None
if res == capsules:
world.character_enters(roommate)
roommate.monologue('This ship sucks either way...')
else:
engineer.monologue('Hey! What are you doing here?')
world.character_enters(roommate)
roommate.monologue('Don\'t worry, we\'re here to help.')

story('...more coming soon!')
75 changes: 75 additions & 0 deletions FTE/characters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# -*- coding: utf-8 -*-
from enum import IntEnum
from time import sleep

from rich.style import Style
from rich.text import Text

from FTE.console import console
from FTE.locations import Location
from FTE.settings import DEBUG


class Standing(IntEnum):
GOOD = 10
NEUTRAL = 0
BAD = -10


class Character:
def __init__(
self,
name: str,
location: Location,
*,
poke: str = None,
standing: Standing = None,
known: bool = True
) -> None:
self.name: str = name
self.location: Location = location
self.poke: str = poke or ''
self.standing: Standing = standing or Standing.NEUTRAL
self.known: bool = known

def __eq__(self, other) -> True:
if isinstance(other, Character):
return self.name == other.name
return False

@property
def display_name(self) -> Text:
return Text.assemble(
self.name if self.known else '???',
style=Style(
bold=True,
color=standing_color(self.standing)
)
)

@property
def pokable(self) -> bool:
return bool(self.poke)

def monologue(self, text: str | Text) -> None:
console.print(Text.assemble('[ ', self.display_name, ' ] ', '"', text, '"'))
sleep(0.0 if DEBUG else 1.5)

def dialogue(self, text: str | Text) -> str:
self.monologue(text)
return console.input('> ').lower()

def action(self, text: str | Text) -> None:
console.print(Text.assemble(
'[ ', self.display_name, ' ] ',
Text.assemble('*', text, '*', style=Style(italic=True))
))
sleep(0.0 if DEBUG else 1.5)


def standing_color(standing: Standing) -> str:
if standing >= Standing.GOOD:
return 'green4'
if standing <= Standing.BAD:
return 'red3'
return 'sky_blue3'
4 changes: 4 additions & 0 deletions FTE/console.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- coding: utf-8 -*-
from rich.console import Console

console = Console(highlight=False)
29 changes: 29 additions & 0 deletions FTE/locations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
from rich.style import Style
from rich.text import Text


class Location:
def __init__(
self,
name: str,
*,
known: bool = True
) -> None:
self.name: str = name
self.known: bool = known

@property
def display_name(self) -> Text:
return Text.assemble(
self.name if self.known else '???',
style=Style(
bold=True,
color='magenta'
)
)

def __eq__(self, other) -> bool:
if isinstance(other, Location):
return self.name == other.name
return False
34 changes: 34 additions & 0 deletions FTE/menus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
from rich.style import Style

from time import sleep

from FTE.console import console

def main_menu() -> None:
while True:
console.clear()
console.rule('Main menu')
console.print('''
_____ ____ __ __ ______ __ __ ___ ___ ____ ____ ____ ____ ___ _____
| || || | | | || | | / _] / _]| \ / || || \ / _]/ ___/
| __| | | | | | | || | | / [_ / [_ | _ || __| | | | _ | / [_( \_
| |_ | | |_ _| |_| |_|| _ || _] | _]| | || | | | | | | || _]\__ |
| _] | | | | | | | | || [_ | [_ | | || |_ | | | | | || [_ / \ |
| | | | | | | | | | | || | | || | || | | | | | || |\ |
|__| |____||__|__| |__| |__|__||_____| |_____||__|__||___,_||____||__|__||_____| \___|
''',
justify='center',
style=Style(
bold=True
))
console.print('1. Let\'s fix them!')
console.print('2. Maybe later...')
console.print('')
choice = console.input('Your choice? ')
if choice == '1':
break
elif choice == '2':
console.print(':wave: Goodbye!')
sleep(3.0)
exit()
5 changes: 5 additions & 0 deletions FTE/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
from os import getenv


DEBUG: bool = bool(getenv('DEBUG', False))
35 changes: 35 additions & 0 deletions FTE/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
from time import sleep

from rich.text import Text

from FTE.console import console
from FTE.settings import DEBUG


def print_with_interval(text: str, interval: float, end: str = '\n') -> None:
for char in text:
if not DEBUG:
sleep(interval)
console.print(char, end='')
if not DEBUG:
sleep(interval)
console.print('', end=end)


def slow_print(text: str, end: str = '\n') -> None:
print_with_interval(text, 0.1, end)


def slower_print(text: str, end: str = '\n') -> None:
print_with_interval(text, 0.5, end)


def story(text: str | Text | list[str | Text]) -> None:
if isinstance(text, list):
for seg in text:
console.print(seg)
if not DEBUG:
sleep(5.0)
else:
console.print(text)
Loading

0 comments on commit 5947fd9

Please sign in to comment.