Modelling for a Pokémon-like game

Hello! Sorry if this seems like a very novice question, I’m just starting out.

I’m pretty lost on how to model the data for a Pokémon-like game that I’m making to teach myself MongoDB and some javascript, that would run as a Discord Bot. My idea for it looks like the following:

Tracking Stamina per user is easy. However, I have no idea how to approach the russian doll design that I’ll need for monsters, and all of the different monsters that someone may have. Should I use maps? Arrays? I’m lost.

Thanks in advance.

Welcome to the community @Alexander_B! :sparkles:

Assuming this is like Pokémon I think you’d actually probably want to store a monster’s level and XP with the user to avoid you having to look up a user, getting an array of monsters and then having to look up each monster’s data with additional queries.

If this was Pokémon, I’d probably model it like this:

{
  "trainer": "Naomi",
  "party": [
    { "name": "Bulbasaur", "type": "grass", "level": 3, "xp": 80},
    { "name": "Ivysaur", "type": "grass", "level": 18, "xp": 200},
    ...
  ]
  "storage": [
    ...
  ]
}

And then for monsters if there is a general list of monsters maybe have a collection that has entries with general information about the monster such as:

{"pkdx_id":1,"national_id":1,"name":"Bulbasaur","__v":3,"image_url":"http://pokeapi.co/media/img/1.png","description":"Bulbasaur can be seen napping in bright sunlight. There is a seed on its back. By soaking up the sun's rays, the seed grows progressively larger.  Bulbasaur can be seen napping in bright sunlight. There is a seed on its back. By soaking up the sun's rays, the seed grows progressively larger.","art_url":"http://assets22.pokemon.com/assets/cms2/img/pokedex/full/001.png","types":["poison","grass"],"evolutions":[{"level":16,"method":"level_up","to":"Ivysaur"}]}

It sort of depends on how you end up querying the data, maybe the user data should contain a bit more information for each monster but you’ll probably work that out fairly quickly when you start writing the queries :). If you tell me a bit more about how the game is supposed to work and how you might need to query the data I can help.

2 Likes

Wow, thank you so much for the quick and awesome reply @Naomi_Pentrel !

I’ve gone and made my schemas around that, and it looks like this now:

const mongoose = require(‘mongoose’);

const playerSchema = mongoose.Schema({
_id: mongoose.Schema.Types.ObjectId,
userID: String,
userStamina: Number,
monsterParty: [monsterSchema],
monsterStorage: [monsterSchema]
});

const monsterSchema = mongoose.Schema({
_id: mongoose.Schema.Types.ObjectId,
monsterSpecies: String,
level: Number,
xp: Number,
happiness: Number,
});

module.exports = mongoose.model(‘Users’, playerSchema, ‘users’);
module.exports = mongoose.model(‘Monster’, monsterSchema, ‘monsters’);

As for how the game works, the basics is this:

The game runs on the Discord chat service as a bot, and is intended to be played a few times a day in short bursts - Stamina is intended for this purpose, and all actions (fight a random trainer or fight a random monster) costs Stamina, which recharges by a certain amount each hour.

Fights are resolved immediately once started, there are no turns or further player interaction there. You press the button to fight and you then win or lose. Same with monsters, except you get the choice to catch them if you win.

I would like to eventually add a store and the ability to buy items to care for your monsters and items to catch new ones, later down the line once I’m more acquainted with everything.

About the general list monster collection, how would I approach making something like that? I was going to just code that into the bot’s javascripts, so that I don’t have to ask the database about it. But with that aside, I would actually like to learn how to do what you mention because I’d like to learn more of course! So, would it be just one “pokedexEntry” schema, which I then fill with information, yes? When in the code should I fill it in with the information?

1 Like

I think it will depend on how many different kinds of monsters you have whether that makes sense. If it’s a small number storing it with the bot makes sense. But if it’s many different ones or if you may want to change them without you wanting to update the bot then putting it in the database may make sense :slight_smile:

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.