63 lines
1.7 KiB
Go
Raw Normal View History

2019-06-03 09:32:43 +00:00
package arn
// Register a list of supported anime relation types.
func init() {
DataLists["anime-relation-types"] = []*Option{
{"prequel", HumanReadableAnimeRelation("prequel")},
{"sequel", HumanReadableAnimeRelation("sequel")},
{"alternative version", "Alternative version"},
{"alternative setting", "Alternative setting"},
{"side story", HumanReadableAnimeRelation("side story")},
{"parent story", HumanReadableAnimeRelation("parent story")},
{"full story", HumanReadableAnimeRelation("full story")},
{"spinoff", HumanReadableAnimeRelation("spinoff")},
{"summary", HumanReadableAnimeRelation("summary")},
{"other", HumanReadableAnimeRelation("other")},
}
}
2019-09-10 00:49:51 +00:00
// AnimeRelation represents a relation to another anime.
2019-06-03 09:32:43 +00:00
type AnimeRelation struct {
2019-06-07 01:50:38 +00:00
AnimeID AnimeID `json:"animeId" editable:"true"`
2019-06-07 01:51:04 +00:00
Type string `json:"type" editable:"true" datalist:"anime-relation-types"`
2019-06-03 09:32:43 +00:00
}
// Anime ...
func (relation *AnimeRelation) Anime() *Anime {
anime, _ := GetAnime(relation.AnimeID)
return anime
}
// HumanReadableType ...
func (relation *AnimeRelation) HumanReadableType() string {
return HumanReadableAnimeRelation(relation.Type)
}
// HumanReadableAnimeRelation ...
func HumanReadableAnimeRelation(relationName string) string {
switch relationName {
case "prequel":
return "Prequel"
case "sequel":
return "Sequel"
case "alternative version":
return "Alternative"
case "alternative setting":
return "Alternative"
case "side story":
return "Side story"
case "parent story":
return "Parent story"
case "full story":
return "Full story"
case "spinoff":
return "Spin-off"
case "summary":
return "Summary"
case "other":
return "Other"
}
return relationName
}