jeffmdemers / DccMonsters

0 stars 0 forks source link

Consider an API or documenting the existing one #39

Closed henesy closed 10 months ago

henesy commented 11 months ago

Mentioned in the GG Discord.

Currently the flow would be something like as follows, as far as I can tell.

Get all(?) the monsters in the db

-> GET dccmonsters.com/monster/GetMainDatatable?skip=0&take=25&requireTotalCount=true&sort=[{"selector":"name","desc":false}]&_=1695350260667 <- JSON body in the form

type AutoGenerated struct {
    Data []struct {
        ID           int    `json:"id"`
        Name         string `json:"name"`
        Size         string `json:"size"`
        Type         string `json:"type"`
        Descriptor   string `json:"descriptor"`
        Initiative   int    `json:"initiative"`
        ArmorClass   int    `json:"armorClass"`
        HitDice      string `json:"hitDice"`
        HitDieOne    int    `json:"hitDieOne"`
        HitDieTwo    int    `json:"hitDieTwo"`
        ActionDice   string `json:"actionDice"`
        ActionDieOne int    `json:"actionDieOne"`
        ActionDieTwo int    `json:"actionDieTwo"`
        Alignment    string `json:"alignment"`
        Favorited    bool   `json:"favorited"`
    } `json:"data"`
    TotalCount int `json:"totalCount"`
}

Get a set of monsters by key word (probably) in this case 'bat'

-> GET dccmonsters.com/monster/GetMainDatatable?skip=0&take=25&requireTotalCount=true&sort=[{"selector":"name","desc":false}]&filter=["name","contains","bat"]&_=1695350262519 <- JSON body in the form same as the 'get all', but this time it will have fewer entries:

type AutoGenerated struct {
    Data []struct {
        ID           int    `json:"id"`
        Name         string `json:"name"`
        Size         string `json:"size"`
        Type         string `json:"type"`
        Descriptor   string `json:"descriptor"`
        Initiative   int    `json:"initiative"`
        ArmorClass   int    `json:"armorClass"`
        HitDice      string `json:"hitDice"`
        HitDieOne    int    `json:"hitDieOne"`
        HitDieTwo    int    `json:"hitDieTwo"`
        ActionDice   string `json:"actionDice"`
        ActionDieOne int    `json:"actionDieOne"`
        ActionDieTwo int    `json:"actionDieTwo"`
        Alignment    string `json:"alignment"`
        Favorited    bool   `json:"favorited"`
    } `json:"data"`
    TotalCount int `json:"totalCount"`
}

Get the specific monster by serial index, including detail stats in DCC form(?)

-> GET dccmonsters.com/monster/GetMonster/574 <- JSON body in the form

type AutoGenerated struct {
    SrdLink      string `json:"srdLink"`
    DndMonsterID any    `json:"dndMonsterId"`
    User         any    `json:"user"`
    DndMonster   struct {
        ID               int    `json:"id"`
        Family           string `json:"family"`
        Name             any    `json:"name"`
        AltName          any    `json:"altName"`
        Size             string `json:"size"`
        Type             string `json:"type"`
        Descriptor       any    `json:"descriptor"`
        HitDice          string `json:"hit_Dice"`
        Initiative       string `json:"initiative"`
        Speed            string `json:"speed"`
        ArmorClass       string `json:"armor_Class"`
        BaseAttack       string `json:"base_Attack"`
        Grapple          string `json:"grapple"`
        Attack           string `json:"attack"`
        FullAttack       string `json:"full_Attack"`
        Space            string `json:"space"`
        Reach            string `json:"reach"`
        SpecialAttacks   string `json:"special_Attacks"`
        SpecialQualities string `json:"special_Qualities"`
        Saves            string `json:"saves"`
        Abilities        string `json:"abilities"`
        Skills           string `json:"skills"`
        BonusFeats       any    `json:"bonus_Feats"`
        Feats            string `json:"feats"`
        EpicFeats        any    `json:"epic_Feats"`
        Environment      string `json:"environment"`
        Organization     string `json:"organization"`
        ChallengeRating  string `json:"challenge_Rating"`
        Treasure         string `json:"treasure"`
        Alignment        string `json:"alignment"`
        Advancement      string `json:"advancement"`
        LevelAdjustment  string `json:"level_Adjustment"`
        SpecialAbilities any    `json:"special_Abilities"`
        StatBlock        any    `json:"stat_Block"`
        FullText         any    `json:"full_Text"`
        Reference        string `json:"reference"`
        DccMonster       any    `json:"dccMonster"`
    } `json:"dndMonster"`
    VariantMonsters   []any     `json:"variantMonsters"`
    UsersStarred      any       `json:"usersStarred"`
    Name              string    `json:"name"`
    Size              string    `json:"size"`
    Type              string    `json:"type"`
    Descriptor        string    `json:"descriptor"`
    Initiative        int       `json:"initiative"`
    ArmorClass        int       `json:"armorClass"`
    HitDice           string    `json:"hitDice"`
    HitDieOne         int       `json:"hitDieOne"`
    HitDieTwo         int       `json:"hitDieTwo"`
    HitPoints         int       `json:"hitPoints"`
    Move              string    `json:"move"`
    Attack            string    `json:"attack"`
    AttackBonus       int       `json:"attackBonus"`
    ActionDice        string    `json:"actionDice"`
    ActionDieOne      int       `json:"actionDieOne"`
    ActionDieTwo      int       `json:"actionDieTwo"`
    Fortitude         int       `json:"fortitude"`
    Reflex            int       `json:"reflex"`
    Will              int       `json:"will"`
    Alignment         string    `json:"alignment"`
    Strength          int       `json:"strength"`
    StrengthBonus     int       `json:"strengthBonus"`
    Agility           int       `json:"agility"`
    AgilityBonus      int       `json:"agilityBonus"`
    Stamina           int       `json:"stamina"`
    StaminaBonus      int       `json:"staminaBonus"`
    Personality       int       `json:"personality"`
    PersonalityBonus  int       `json:"personalityBonus"`
    SpecialProperties string    `json:"specialProperties"`
    ID                int       `json:"id"`
    CreatedOn         time.Time `json:"createdOn"`
}

This alone is probably enough to get by for programming a discord bot against

Is the DCC to/from 3.5 stats all done in JS? I didn't look closely and the API looks like it returns the DCC stats

Thanks for making this!

jeffmdemers commented 10 months ago

Sounds like you were able to get this working with the current api hooks. I am unlikely to open this up publicly, but I also won't leave you hanging.

I'm not going to document it all, but if I decide to close it off I'll supply you with an api key so you can keep making your awesome bot.