Skip to content

rosegaelle/rpyg

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rpyg

Python role playing game framework.

Components

Each game will be an instance of the game class initialzed with a game object definition.

Game Engine

Create a new game:

from rpyg import Rpyg

run_game = Rpyg(**game)
run_game.start()

Game Cartridge

Defines the game and an options object.

Game Object

greeting - string

name - string

frames - collection of frame objects

Frame Object

intro - string

actions - collection of action objects

moves - collection of move objects

end - boolean - indicates that this frame is the end of the game

Action Object

result - string - success message

required - string - item name - item required to be in user inventory to fulfill action. If the user does not have this item, a message will be displayed.

frame - string - frame name - destination that a successful action will advance to

Example Game

game = {
    'greeting': 'Welcome!',
    'name': 'Hiking the AT',
    'frames': {
        'entry': {
            'intro': 'A stream is to the north and mountains are on the horizon. What direction do you want to go? ',
            'actions': {
                'open_door': {
                    'result': 'The door is locked'
                },
                'unlock_door': {
                    'result': 'The door is locked'
                }
            },
            'moves': {
                'south': 'foothills',
                'north': 'dead_end'
            }
        },
        'dead_end': {
            'intro': 'You have reached a dead end',
            'actions': {
                'open_door': {
                    'result': 'The door is locked'
                },
                'unlock_door': {
                    'result': 'The door is locked'
                }
            },
            'moves': {
                'south': 'mountains',
                'north': 'house'
            }
        },
        'house': {
            'intro': 'You are in front of a house! Where would you like to go?',
            'actions': {
                'unlock_door': {
                    'frame': 'inside_house',
                    'required': 'key',
                    'result': 'You have unlocked the door!'
                }
            },
            'moves': {
                'south': 'mountains',
                'north': 'house'
            }
        },
        'inside_house': {
            'intro': 'You are inside the house!',
            'actions': {
                'celebrate': {
                    'frame': 'end',
                    'result': 'YAY its amazing!'
                }
            },
            'moves': {}
        },
        'mountains': {
            'intro': 'You are in the mountains. There is a key at your feet.',
            'actions': {
                'pick_up_key': {
                    'frame': 'mountains_no_key',
                    'item': 'key',
                    'result': 'You have the key!'
                }
            },
            'moves': {
                'south': 'dead_end',
                'north': 'house'
            }
        },
        'mountains_no_key': {
            'intro': 'You are in the mountains.',
            'actions': {},
            'moves': {
                'south': 'dead_end',
                'north': 'house'
            }
        },
        'end': {
            'end': True
        }
    }
}

Example Game

CLI

From project root for CLI version of game:

python3 example/cdt.py

Jupyter notebook

From the examples directory run jupyter-notebook (installation instructions) and open the example notebook cdt-jupyter-notebook.ipynb.

Tests (WIP)

python -m unittest

Documentation with pydoc

pydoc3 rpyg

References

Python Unit Testing – Structuring Your Project

Text to ASCII Art Generator

Modules and Packages

setup.py

About

Python port of console-game rpg engine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 53.7%
  • Jupyter Notebook 46.3%