kamranahmedse / walkers

A console based fan fiction RPG for The Walking Dead TV Series

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Walkers

A console based fan fiction RPG for The Walking Dead

Build Status Scrutinizer Code Quality Code Coverage

Walkers is a rough fan-fiction console based RPG for The Walking Dead built in PHP and can be used for educational purposes on OOP and how to write clean and extensible code.

Requires PHP >= 7

Setup

Clone the repository and install the dependencies

composer install

Running the tests

./vendor/bin/phpunit tests

How to play

Run the below command to start the game and then follow the steps stated below

php index.php

Step 1 - Choose the player

On the first screen, player will be presented with the option to choose player

Players List

For the current release, each of the players have different healths. It was planned to give different abilities to each of the players (as you might be able to guess from the player class names i.e. GunnerRick, NinjaMichone, RunnerGlenn etc) but was plucked out of this release.

Step 2 - Let the game begin

After choosing the player of your liking; the game begins

Choose Door

On the top, player is shown a not-so-uplifting message and then the HUD showing the current progress including experience, health and the level that the player is on. Then the player is asked to chose a door, where some of doors are empty and some of them have randomly placed walkers in them.

If the chosen door had walker in it, Walker gets to grab a bite of player while decreasing the health depending upon the walker. Player is returned back to same level with the same choice. Walker are shuffled again in different doors

Walker Door

If the chosen door was empty, player is rewarded with experience and is advanced to next level

Empty Door

The process keeps repeating unless, one of the below happens

i. Save and Exit

Player chooses to save game and exit.

Save and Exit

In which case, player will be asked if they want to resume the game or start a new game when the game is run the next time.

Game data is stored in /storage/game-data.wd in encrypted-but-not-so-super-encrypted manner.

Resume Game?

If the user chooses to restore game; it will begin from the last state (i.e. same level, health and experience). If not, it will begin from the first level.

ii. Exit

Player chooses to exit game.

iii. Player Dies

Player gets bitten by zombies again and again to the point that health becomes zero.

iv. Game is Completed

Final level is reached.

Further Details

  • /config directory in the root contains any configuration and map files.
  • /src is where all the magic happens
  • /src/Console contains the contracts and implementations for console component to be used for logging and getting inputs. Currently having the implementation for Symfony's console component
  • /src/Exceptions Any exceptions to be thrown
  • /src/Player has the contracts and implementations for Player. Also houses sample implementations for some Walking Dead Characters
  • /src/Walker houses the contracts and implementation for Walkers having sample implementation for some walkers.
  • /src/Storage has everything relevant to storage. Currently there is JSON file storage support.
  • /src/Game.php houses the game loop and acts as the controller for game.
  • /src/Map.php has all the map specific details.
  • /src/Runner.php Runner (A symfony command) that initiates the game loop.
  • /storage contains any storage related data
  • /tests of-course contain the test cases.
  • /index.php is the file that bootstraps the game

Extending

  • Adding or modifying levels Head to the map file at config/map.php and follow the instructions at the top to add new level or modify the existing levels. To add a new level all you have to do is add it to the levels array in the map. A sample level may look like below: For further details. Also please check the docs in config/map.php.
[
    'doorCount'        => 3,    // Doors on this level
    'players'          => [     // Array of allowed players (if first level) or players to be unlocked (on any other levels [TODO]) 
        'Rick - The Father' => GunnerRick::class,
        'Carl - The Kid'    => KidCarl::class,
    ],
    'walkers'          => [     // Array of walkers that will be put in random doors
        OneLegged::class,
    ],
    'experiencePoints' => 10,   // Experience points added on successful completion of level
],
  • Changing the Console component For now it relies upon the Symfony's console component. In order to extend, all you have to do is just implement the interface KamranAhmed\Walkers\Console\Interfaces\ConsoleInterface and pass the instance of it while initializing Game.
  • Adding New Players You can introduce new players in the game just by implementing the KamranAhmed\Walkers\Player\Interfaces\Player interface. You might want to extend the KamranAhmed\Walkers\Player\Abstracts\BasePlayer class for some basic functionality.
  • Changing Storage Method Currently there is JsonStorage but you can easily replace it with database or anything else by implementing \KamranAhmed\Walkers\Storage\Interfaces\GameStorage and injecting that while initializing the game.
  • Adding New Walkers You can add new walkers by implementing the \KamranAhmed\Walkers\Walker\Interfaces\Walker interface and start using them. Plus, if you would want to modify the bite behavior, just override the eat method in the base walker class and implement your own in the walker.

License

MIT © Kamran Ahmed

About

A console based fan fiction RPG for The Walking Dead TV Series


Languages

Language:PHP 100.0%