Skip to content

SimonaPiz/Redux-Road-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Redux Road - Game

An adventure game using Redux to implement reducers, state and actions.

Table of Contents

General Information

In this project I build an adventure game using reducers, state, and actions.

Rules

  1. Start - The player begins on day 0 at kilometer 0 with 100 units of supplies.
  2. Gather - A player may gather supplies, which takes them a day and doesn’t cover any distance.
  3. Travel - A player may travel for any number of days, which costs 20 supplies for each day but adds 10 kilometers each day.
  4. Tipped Wagon - If a player drives off-road or across deep rivers, the wagon may tip! You’ll need to spend some supplies and a day to fix it.

Project's Tasks

  • The state will represent, well, the state of the game. It contains:
    • the player’s inventory,
    • distance travelled, and
    • time on the road.
  • Each event in the game is represented as an action. Players can:
    • gather supplies,
    • travel,
    • and, if they play risky, sometimes tip over the wagon carrying their supplies.

Tasks

  • define the starting point of our game, the initialWagonState.
  • define a reducer that will manage the state of the game, like any Redux reducer, with state and action. Add a switch statment for every states.

Play the game

  • Call the reducer with different states and action types:
    • 1 day - Travel
    • 2 day - Gather
    • 3 day - Tipped wagon
    • 4 day - Long Travel (3 days)
  • Print to the console

Extra Features

  • Currently, the player can continue traveling even if their supplies are negative! Fix this in the travel case. If there are not sufficient supplies to travel the given number of days, return the current state.
  • Add a cash property, beginning with 200 for the initial state
  • Add a 'sell' case: Players can give away 20 supplies to gain 5 cash
  • Add a 'buy'case: Players can gain 25 supplies at the cost of 15 cash
  • Add a 'theft' case: Outlaws steal half of the player’s cash

Technologies Used

  • Node.js - version 18
  • JavaScript

Screenshots

anteprima-redux-road

Usage

Run with Node.js to see the example journey

$ cd [repo-directory]
$ node redux-road.js

Acknowledgements

This project comes from the Codecademy's Front-End Engineer course.

About

An adventure game using Redux to implement reducers, state and actions.

Topics

Resources

Stars

Watchers

Forks