Giter Site home page Giter Site logo

dnd5e-api-rails's Introduction

D&D 5e API

This project started because a friend and I were trying to build a character creator in Rails for 5th Edition. With the amount of data required we decided to try and split the project into three parts. The API which you will see here, a gem wrapper library for the API that can be included on any Ruby project, and then the character creator itself.

This is still under development so excuse the mess of code.

dnd5e-api-rails's People

Contributors

brennanholtzclaw avatar breynolds-dev avatar firedrow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dnd5e-api-rails's Issues

normalizing database and route names

Need to make that capitalization and spacing does not effect hour our database lookups happen.

Right now database searches are case sensitive, need to find a way to normalize these

Also make sure our deslug method for database lookups from our routes is ok

rework race entries for route handling and additional phb data

Need to adjust all of our subrace options to have a top level object that is returned

/v1/races/elf

would return a object with the most basic stats every elf would have. This would also have a fully populated subrace collection of all of the different options an elf would have.

then a route like:

/v1/races/dark-elf

would give you all the information that the dark elf has PLUS all of the information it inherits from the elf race.

Show inherent users on different traits

For /languages for example there should be a connection in the database letting us easily know which races automatically know that language (before the bonus languages picked at character creation)
So /languages/elven would have a line like
"{native_speakers: elves, gandalf}

Just an enhancement that popped in my head when looking at our current responses

missing Aarakocra race & associated information

While changing over to a different racial ability bonus setup we found that we were missing the Aarakocra race. Should be easy to add using our existing structure for races. There are several other associated models that need information added as well.

Languages:

  • Aarakocra
  • Auran

Traits:

  • Flight
  • Talons

create a classes route

We need either a route and basic model that routes and serializes our classes, or a table that all of our classes can belong to for some associations.

Rename Joins Tables to be more descriptive

Need to look at renaming the joins tables to read something more descriptive.

JoinsLanguage would become RacialLanguage
JoinsSkill would become RacialSkill
JoinsTrait would become RacialTrait

... and so on. Need to work on maintaining this style of naming for the rest of our joins tables

create spell models, migrations and serializations

Using a JSON file that we found, we should be able to integrate spells into our database without too much trouble. We need to add a migration to match the JSON file format and then it should be a matter of importing them.

create_table :spells, do |t|
  t.string :name, null: false
  t.string :description, default: ''
  t.string :page_reference, default: ''
  t.string :range, default: 'Self'
  t.string :components, default: ''
  t.string :material, default: ''
  t.string :ritual, default: ''
  t.string :duration, default: ''
  t.boolean :concentration, default: false
  t.string :casting_time, default: '1 action'
  t.string :level, default: 'Cantrip'
  t.string :school, default: ''
  t.string :classes, default: ''
  # Below are all entries that relate to different subclass options
  t.string :archetype, default: ''
  t.string :circles, default: ''
  t.string :patron, default: ''
  t.string :domains, default: ''
  t.string :oath, default: ''
end

This will also need to include a few different joins tables to connect our spell models to the races for racial spells, as well as to our class models for various class/subclass combos.

On top of that, if there are feats or traits that grant spells we might need to look into some sort of joins tables or something to bring that data into those resources when we are sending the API data back to the user. Something like associated_spells perhaps?

add ability models, routes, controllers and tests

Originally this was going to be some adjustments using ruby objects to just send that back to the user. Now I think we need to change it up and make a Stats table that includes six entries with a few joins tables that link things together.

/v1/abilities/strength

would return something like this

{
  "id": 1,
  "name": "Strength",
  "description": "Your strength is your characters physical prowess ... more text here",
  "associated_skills": [
    {
      "name": "Athletics",
      "url": "http://5e-api.com/v1/skills/athletics"
    }
  ],
  "links": {
    "self": "http://5e-api.com/v1/abilities/strength",
    "skills": {
      "athletics": "http://5e-api.com/v1/skills/athletics"
    }
  }
}

adding page references to all api data

After looking through some other basic JSON data types, one thing that caught my eye was a reference number for book and page. By including something like that it would give players the option to find the information in their own PHB's that they own.

This option would also be useful for something like an Alexa Integration which could allow someone to ask Alexa what page can I find Barbarians or something close to that.

fix ajax request on index.html

clicking submit doesn't do anything, should submit the ajax request, then change the content inside of the pre tags to whatever it is we just grabbed

fix routing issues with invalid subclasses

you can enter the route /v1/classes/barbarian/rager/2 and get an object to come back to you because we don't care about the subclass at that point.

This should return a 404 error if our subclass does not match any of the classes subclass options. Need to write a quick method that checks the subclass entry against a valid list of subclasses pulled from our database or hard coded.

valid_subclass?(subclass)
  Classes::Barbarian.all.map{|b| b.subclass}.uniq.include?(subclass)
end

or something along those lines, we might be able to call just self.all.map without prefixing it with our Barbarian class, but further testing will be required

capistrano deployment

setup our deployment gems with capistrano and get it merged into master so we can have a live version available on our domain

racial stat bonuses should be refactored into associated objects

Instead of using a comma delimited string to insert our racial bonuses into the race stats we can now use joins tables to attach abilities to the classes. On top of that we can include only the important attributes instead of including the entire array of stats.

t.integer :race_id, null: false
t.integer :ability_id, null: false
t.integer :bonus, null: false

This will force our table to always have data, as well as creating those associations to be used behind the scenes.

namespacing classes

look into how to correctly namespace not only the routes, but the controllers and classes to help clean up our directory structure and overall layout of the program

There is a basic route in there now to namespace the classes, however it doesn't seem to work correctly with just resources so we've had to explicitly define all the routes inside, we are not adding any code lines nor are we going to allow post/patch/delete requests so this shouldn't be an issue

slugify routes

Need to be able to slufigy routes for our class, subclass and race models so far.

This allows us to use this in the future s well

Offload website content to it's own repo

I have been working in Angular to create a new website, now we need to look at offloading all of our website information from this repo since it is no longer needed and will not be updated any further

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.