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

  1. package models
  2. // Character is a common data model representing an RP character or NPC.
  3. type Character struct {
  4. ID string `json:"id" bson:"_id"`
  5. Nicks []string `json:"nicks" bson:"nicks"`
  6. Name string `json:"name" bson:"name"`
  7. ShortName string `json:"shortName" bson:"shortName"`
  8. Author string `json:"author" bson:"author"`
  9. Description string `json:"description" bson:"description"`
  10. }
  11. // Nick gets the character's nick.
  12. func (character *Character) Nick() *string {
  13. if len(character.Nicks[0]) == 0 {
  14. return nil
  15. }
  16. return &character.Nicks[0]
  17. }
  18. // HasNick gets whether the character has the nick.
  19. func (character *Character) HasNick(nick string) bool {
  20. for i := range character.Nicks {
  21. if nick == character.Nicks[i] {
  22. return true
  23. }
  24. }
  25. return false
  26. }
  27. // IsChangeObject is an interface implementation to identify it as a valid
  28. // ChangeObject in GQL.
  29. func (*Character) IsChangeObject() {
  30. panic("this method is a dummy, and so is its caller")
  31. }
  32. // CharacterFilter is a filter for character listing.
  33. type CharacterFilter struct {
  34. IDs []string
  35. Nicks []string
  36. Names []string
  37. Author *string
  38. Search *string
  39. Limit int
  40. }
  41. // CharacterUpdate is an update for characters.
  42. type CharacterUpdate struct {
  43. Name *string
  44. ShortName *string
  45. Description *string
  46. }