Skip to content

An RPG time-traveling game built to run as a Ruby CLI app. Journey through space and time with CloudR45 the AI agent assisting you along the way.

Notifications You must be signed in to change notification settings

aaronzomback/TimeTravelerGame

Repository files navigation

Time-Traveler

evie-s-kBzQNk9AgOg-unsplash 1

About

Join your travel agent CloudR45 and journey backwards and forwards through the depths of space and time for encounters with historical figures such as Genghis Khan and Napoleon. Who knows? maybe all of the information from history really can be contained in a tiny CLI app written in Ruby after all.

Structure & Design Principles

Separation of concerns

Keeping the SRP (single-responsibility-principle) in mind, it was important to separate the concerns when building the structure of the game. The stucture can be divided into 3 classes:

  1. Game Engine
  2. Game Node
  3. TimeTraveler

Making it readable

Refactoring to DSL (Domain Specific Language). The beauty of Ruby.

For example, instead of:

if input == option_drink_19th_century
  p game_over_frozen
  input = prompt.yes?("Would you like to play again?")
    if input == true
      self.run
    else
      abort "Goodbye, come back again soon!" 
    end
elsif input == option_jump_19th_century ...

We can do this:

    GameNode.new do
     display WELCOME_MSG_TEXT
       option "yes" do
         display CENTURY_SELECTION_TEXT
           option "13th" do
             display CENTURY_13TH_TEXT
               option "jump" do ...

Extensibility and Reusability

"Plug and play" ... the Game Engine and Game Node classes serve as the respective motor and elements that make the game run, while the TimeTraveler class is simply the written storyboard and pathways that make the game unique. This allows for TimeTraveler to be easily swapped out for other games if desired.

Decision Tree

A tree like structure seemed to be a practical solution to structure the data. Each node represents a text display and options, which based on the players' choices, will lead them further down the levels of the tree along the different pathways.

TimeTraveler Decision Tree 1 (2)

Running and Setup

The CLI application is built on ruby 2.7.0. To run, make sure you have ruby installed and run the following commands to setup:

In root run bundle install and then ruby play.rb to start the game.

Testing

In root run rspec to run tests. If you'd also like to see the descriptions of each test as they execute run rspec --format doc.

About

An RPG time-traveling game built to run as a Ruby CLI app. Journey through space and time with CloudR45 the AI agent assisting you along the way.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages