Part 2: Modelling the Data in my Marvel Snap Clone

Building out the tables in ServiceNow for my Marvel Snap clone has been interesting. ย ย 

I started with the most atomic object Iโ€™d need – a Card Definition. ย This needs to house the Cost, Power and Ability data for all the cards that exist in Marvel Snap. ย I found a webpage with a database of Marvel Snap cards (https://marvelsnap.io/) which also had an underlying API. ย I inspected the browser session to see how the page loads and found that the API was pretty easy to understand:

Base URL: https://marvelsnap.io/api/search.php

Query Params:

Type (character or location)

Sort (by field)

Limit (integer)

Offset (for paging, zero indexed).

This returns an array of Cards in a JSON object, so I based my Card Definition on this payload:

“card”: [

{

“id”: 1,

“name”: โ€œAbominationโ€,

“type”: โ€œCharacterโ€,

“cost”: 5,

“power”: 9,

“ability”: null,

“date_added”: “2022-05-20 08:46:03โ€,

“status”: null,

“variants”: โ€œ1_526,1_525,1_524,1_521โ€,

“pretty_url”: “abomination-1โ€,

“method”: “Starter Cardโ€,

“slug”: โ€œAbominationโ€

},

]

From there I started to think about some of the relationships I need – When a card is in play, it gets modified and its status and location changes, so I probably need an โ€œinstanceโ€ of the card to represent whatโ€™s happening to it while in Play – Card Instance record.

The Card Instance exists in the context of a location (In the playerโ€™s deck, in their hand, in the playspace, discarded, etc), so letโ€™s also have a Location Instance to store that during play.

Because weโ€™re tracking things in context of the game thatโ€™s being played, we probably also need a Game Instance to represent that.

In order for a Player to have their own set of cards in their deck to be shuffiled into Card Instances, we should have a container for the Player Deck that contains their preferred deck at that time – a Player Deck record with child Player Deck Cardย records which represent the cards that the player has in their deck. ย Player Decks should belong to a user.

Finally, in order to connect two users attempting to start a game, weโ€™ll need a Matchmaking Queue. ย This lets player one start queueing and allows player two to find an unresolved matchmaking session before the Game Instance is created.

This seems like a solid data structure, and I can sort of visualise it in my head, but I also donโ€™t want to waste time diagramming itโ€ฆ I wondered if ChatGPT could help? ย I asked ChatGPT with Dall-E to diagram it all for me based on the following prompt:

Can you please draw an ERD which shows the following tables: Player Deck Card, Player Deck, Card Definition, Card Instance, Matchmaking Queue, Location instance, Game Instance, Player Session, User

ย 

A Player Deck consists of many Player Deck Cards.

ย A Player Deck Card can be related to a single Card Definition.

Many Player Sessions can be related to a single Game Instance.

Multiple users can be related to a Matchmaking Queue.

A Single Game Instance can be related to a single Matchmaking Queue.

A Player Deck can be related to a single User.

Many Location Instances can be related to a Game Instance

A Card Instance can be related to a single Location Instance

A Card Instance can be related to a single Card Definition

ย 

The results werenโ€™t amazing – typical hallucination representations, and not really good enough for what I want:ย 

Screenshot 2023 11 01 at 16 00 09

Then I got to thinking – ChatGPT is pretty good with code, and thereโ€™s probably some code -> Diagram frameworksโ€ฆ. I found something called Mermaid Live which has a markup language for Diagrams, so I asked ChatGPT to generate that code for me:ย 

Screenshot 2023 11 01 at 16 02 43 2x

And this gave me a pretty reasonable ERD for my little app: ย 

Screenshot 2023 11 01 at 16 03 18

ย 

This is all pretty good! ย Shows how the app works pretty well and helps me to keep my relationships well structured! ย Iโ€™ll need to go through and update the table names to be more correct, but all in al the structure of the app is coming along!


Comments

One response to “Part 2: Modelling the Data in my Marvel Snap Clone”

  1. August Dunnihoo Avatar
    August Dunnihoo

    I’m working to get this game called Pralaya into Servicenow. There are a couple key differences between this game and SN APP. I won’t be working with a deck builder and different player decks so that’ll take some of the complexity out of the design. This game features an island that slowly fills with water. The object is for the players to get points and pay to leave the island before it is covered in water. Because of this players will be acquiring cards throughout the game so I will still need a player deck in a sense but only one game deck. I think that is the big difference between these two designs.

Leave a Reply

Your email address will not be published. Required fields are marked *