GraphQL API and utilities for the rpdata project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

54 lines
1.3 KiB

package models
// Character is a common data model representing an RP character or NPC.
type Character struct {
ID string `json:"id" bson:"_id"`
Nicks []string `json:"nicks" bson:"nicks"`
Name string `json:"name" bson:"name"`
ShortName string `json:"shortName" bson:"shortName"`
Author string `json:"author" bson:"author"`
Description string `json:"description" bson:"description"`
}
// Nick gets the character's nick.
func (character *Character) Nick() *string {
if len(character.Nicks[0]) == 0 {
return nil
}
return &character.Nicks[0]
}
// HasNick gets whether the character has the nick.
func (character *Character) HasNick(nick string) bool {
for i := range character.Nicks {
if nick == character.Nicks[i] {
return true
}
}
return false
}
// IsChangeObject is an interface implementation to identify it as a valid
// ChangeObject in GQL.
func (*Character) IsChangeObject() {
panic("this method is a dummy, and so is its caller")
}
// CharacterFilter is a filter for character listing.
type CharacterFilter struct {
IDs []string
Nicks []string
Names []string
Author *string
Search *string
Limit int
}
// CharacterUpdate is an update for characters.
type CharacterUpdate struct {
Name *string
ShortName *string
Description *string
}