Gotta Code them All
  • Welcome!
  • Introduction
  • 💭Chapter 1: The Basics
    • Games are made out of Data
  • 👨‍💻Route 1: Choose your Starter
    • Species Service
    • Setup
    • Adding Data and Types
    • Reading Files
    • Use What We Learned
  • 🏆Route 1 Side Quest: In-memory Caching [TBD]
  • 💡Route 2: Generating Pokemon [WIP]
  • 💡Route 2 Side Quest: Create an Interactive CLI [TBD]
  • To be continued...
Powered by GitBook
On this page
  1. Route 1: Choose your Starter

Use What We Learned

Try this yourself! Let me know what you came up with!

Do the same thing we did for the pokemon-service, but with moves, which are the attacks that Pokemon use in battle!

Here are the following files that you'll add to a moves directory inside the data directory.

I'd put my move-service directory right next to the species-service and call my file file.ts again to communicate to future-you that this is the service that is reading from files.

Here is the data I'd put in the data/moves directory. We'll add more detail later, but for now, let's just add this.

Don't forget to add an interface in your types file!

// ./data/moves/1.json
{
  "name": "Pound"
}

// ./data/moves/22.json
{
  "name": "Vine Whip"
}

// ./data/moves/33.json
{
  "name": "Tackle"
}

// ./data/moves/39.json
{
  "name": "Tail Whip"
}

// ./data/moves/45.json
{
  "name": "Growl"
}

// ./data/moves/52.json
{
  "name": "Ember"
}

// ./data/moves/145.json
{
  "name": "Bubble"
}

This will set us up for our next Main Quest which is generating Pokemon using Species Data! Don't miss it!

PreviousReading FilesNextRoute 1 Side Quest: In-memory Caching [TBD]

Last updated 2 years ago

👨‍💻