Documentation
¶
Overview ¶
Package schema defines database and JSON schema as structs, as well as functions for creating and using these structs
Package schema defines database and JSON schema as structs, as well as functions for creating and using these structs ¶
Package schema defines database and JSON schema as structs, as well as functions for creating and using these structs ¶
Package schema defines database and JSON schema as structs, as well as functions for creating and using these structs ¶
Package schema defines database and JSON schema as structs, as well as functions for creating and using these structs ¶
Package schema defines database and JSON schema as structs, as well as functions for creating and using these structs ¶
Package schema defines database and JSON schema as structs, as well as functions for creating and using these structs ¶
Package schema defines database and JSON schema as structs, as well as functions for creating and using these structs ¶
Package schema defines database and JSON schema as structs, as well as functions for creating and using these structs ¶
Package schema defines database and JSON schema as structs, as well as functions for creating and using these structs ¶
Package schema defines database and JSON schema as structs, as well as functions for creating and using these structs ¶
Package schema defines database and JSON schema as structs, as well as functions for creating and using these structs
Index ¶
- Variables
- func CheckForExistingUser(token string, udb rdb.Database) (bool, error)
- func DoesGolemArchetypeMatch(golem Golem, archetype string) bool
- func DoesGolemStatusMatch(golem Golem, status string) bool
- func FindIndexOfGolemWithSymbol(golems []Golem, symbol string) (bool, int)
- func IsStatusAllowedForArchetype(archetype string, newStatus string) (bool, error)
- func Locale_get_all_from_db(wdb rdb.Database) (map[string]Locale, error)
- func Locale_get_json_from_db(wdb rdb.Database, path string) ([]byte, error)
- func Locale_save_all_to_db(wdb rdb.Database, locales map[string]Locale) error
- func Locale_save_to_db(wdb rdb.Database, locale Locale) error
- func Locale_unmarshal_all_json(locale_json []byte) (map[string]Locale, error)
- func Region_get_all_from_db(wdb rdb.Database) (map[string]Region, error)
- func Region_get_json_from_db(wdb rdb.Database, path string) ([]byte, error)
- func Region_save_all_to_db(wdb rdb.Database, regions map[string]Region) error
- func Region_save_to_db(wdb rdb.Database, region Region) error
- func Region_unmarshal_all_json(region_json []byte) (map[string]Region, error)
- func ResourceNode_get_all_from_db(wdb rdb.Database) (map[string]ResourceNode, error)
- func ResourceNode_get_json_from_db(wdb rdb.Database, path string) ([]byte, error)
- func ResourceNode_save_all_to_db(wdb rdb.Database, resourcenodes map[string]ResourceNode) error
- func ResourceNode_save_to_db(wdb rdb.Database, resourcenode ResourceNode) error
- func ResourceNode_unmarshal_all_json(resourcenode_json []byte) (map[string]ResourceNode, error)
- func Resource_get_all_from_db(wdb rdb.Database) (map[string]Resource, error)
- func Resource_get_json_from_db(wdb rdb.Database, path string) ([]byte, error)
- func Resource_save_all_to_db(wdb rdb.Database, resources map[string]Resource) error
- func Resource_save_to_db(wdb rdb.Database, resource Resource) error
- func Resource_unmarshal_all_json(resource_json []byte) (map[string]Resource, error)
- func Route_get_all_from_db(wdb rdb.Database) (map[string]Route, error)
- func Route_get_json_from_db(wdb rdb.Database, path string) ([]byte, error)
- func Route_save_all_to_db(wdb rdb.Database, routes map[string]Route) error
- func Route_save_to_db(wdb rdb.Database, route Route) error
- func Route_unmarshal_all_json(route_json []byte) (map[string]Route, error)
- func Test_locale_initialized(wdb rdb.Database, locale map[string]Locale)
- func Test_region_initialized(wdb rdb.Database, region map[string]Region)
- func Test_resource_initialized(wdb rdb.Database, resource map[string]Resource)
- func Test_resourcenode_initialized(wdb rdb.Database, resourcenode map[string]ResourceNode)
- func Test_route_initialized(wdb rdb.Database, route map[string]Route)
- func Test_world_initialized(wdb rdb.Database, world World)
- func World_get_json_from_db(wdb rdb.Database, path string) ([]byte, error)
- func World_save_to_db(wdb rdb.Database, world World) error
- type AchievementMetric
- type ActiveUsersMetric
- type DropTable
- type Golem
- type GolemArchetype
- type GolemStatus
- type GolemStatusUpdateBody
- type GolemTravelInfo
- type HasSymbol
- type InventoryResource
- type Leaderboard
- type LeaderboardDescriptionResponse
- type LeaderboardEntry
- type Locale
- type LocationInventory
- type ManaDetails
- type Metric
- type PublicUserInfo
- type Region
- type Resource
- type ResourceNode
- type Ritual
- type Route
- type Thing
- type UniqueUsersMetric
- type User
- type UserCallTimestamp
- type UsersByAchievementMetric
- type UsersMetricEndpointResponse
- type World
- type WorldSummaryResponse
Constants ¶
This section is empty.
Variables ¶
var GolemArchetypes = map[string]GolemArchetype{ "invoker": {Name: "Invoker", Abbreviation: "INV", AllowedStatuses: []string{"idle", "invoking"}, }, "harvester": {Name: "Harvester", Abbreviation: "HRV", AllowedStatuses: []string{"idle", "traveling", "harvesting"}, }, "courier": {Name: "Courier", Abbreviation: "COR", AllowedStatuses: []string{"idle", "traveling"}, }, "artisan": {Name: "Artisan", Abbreviation: "ART", AllowedStatuses: []string{"idle", "traveling"}, }, "merchant": {Name: "Merchant", Abbreviation: "MRC", AllowedStatuses: []string{"idle", "traveling"}, }, }
var GolemStatuses = map[string]GolemStatus{ "idle": {Name: "Idle", IsBlocking: false}, "harvesting": {Name: "Harvesting", IsBlocking: false}, "traveling": {Name: "Traveling", IsBlocking: true}, "invoking": {Name: "Invoking", IsBlocking: true}, }
var Leaderboards = map[string]Leaderboard{ "coin-leaders": {Thing: Thing{HasSymbol: HasSymbol{Symbol: "coin-leaders"}, Name: "Coin Leaders", Description: "Top 10 Users by Coins"}, Users: make([]LeaderboardEntry, 0)}, "golem-leaders": {Thing: Thing{HasSymbol: HasSymbol{Symbol: "golem-leaders"}, Name: "Golem Leaders", Description: "Top 10 Users by Golem Count"}, Users: make([]LeaderboardEntry, 0)}, "achievement-leaders": {Thing: Thing{HasSymbol: HasSymbol{Symbol: "achievement-leaders"}, Name: "Achievement Leaders", Description: "Top 10 Users by Achievements Completed"}, Users: make([]LeaderboardEntry, 0)}, }
var Rituals = map[string]Ritual{ "summon-invoker": NewRitual("Summon Invoker", "summon-invoker", "Spend mana to summon a new invoker, who can be used to help generate even more mana.", 600), "summon-harvester": NewRitual("Summon Harvester", "summon-harvester", "Spend mana to summon a new harvester, who can be used to gather resources from nodes in the world.", 600), }
ritual info map
Functions ¶
func CheckForExistingUser ¶
Check DB for existing user with given token and return bool for if exists, and error if error encountered
func DoesGolemArchetypeMatch ¶
func DoesGolemStatusMatch ¶
func Locale_get_all_from_db ¶
Gets all locales from DB
func Locale_get_json_from_db ¶
Get json from db based on path
func Locale_save_all_to_db ¶
Attempt to save all locales, returns error or nil
func Locale_save_to_db ¶
Attempt to save locale, returns error or nil
func Locale_unmarshal_all_json ¶
Unmarshals all locales from json byte array
func Region_get_all_from_db ¶
Gets all regions from DB
func Region_get_json_from_db ¶
Get json from db based on path
func Region_save_all_to_db ¶
Attempt to save all regions, returns error or nil
func Region_save_to_db ¶
Attempt to save region, returns error or nil
func Region_unmarshal_all_json ¶
Unmarshals all regions from json byte array
func ResourceNode_get_all_from_db ¶
func ResourceNode_get_all_from_db(wdb rdb.Database) (map[string]ResourceNode, error)
Gets all resourcenodes from DB
func ResourceNode_get_json_from_db ¶
Get json from db based on path
func ResourceNode_save_all_to_db ¶
func ResourceNode_save_all_to_db(wdb rdb.Database, resourcenodes map[string]ResourceNode) error
Attempt to save all resourcenodes, returns error or nil
func ResourceNode_save_to_db ¶
func ResourceNode_save_to_db(wdb rdb.Database, resourcenode ResourceNode) error
Attempt to save resourcenode, returns error or nil
func ResourceNode_unmarshal_all_json ¶
func ResourceNode_unmarshal_all_json(resourcenode_json []byte) (map[string]ResourceNode, error)
Unmarshals all resourcenodes from json byte array
func Resource_get_all_from_db ¶
Gets all resources from DB
func Resource_get_json_from_db ¶
Get json from db based on path
func Resource_save_all_to_db ¶
Attempt to save all resources, returns error or nil
func Resource_save_to_db ¶
Attempt to save resource, returns error or nil
func Resource_unmarshal_all_json ¶
Unmarshals all resources from json byte array
func Route_get_all_from_db ¶
Gets all routes from DB
func Route_get_json_from_db ¶
Get json from db based on path
func Route_save_all_to_db ¶
Attempt to save all routes, returns error or nil
func Route_save_to_db ¶
Attempt to save route, returns error or nil
func Route_unmarshal_all_json ¶
Unmarshals all routes from json byte array
func Test_locale_initialized ¶
Test: Get locale from db and compare with json
func Test_region_initialized ¶
Test: Get region from db and compare with json
func Test_resource_initialized ¶
Test: Get resource from db and compare with json
func Test_resourcenode_initialized ¶
func Test_resourcenode_initialized(wdb rdb.Database, resourcenode map[string]ResourceNode)
Test: Get resourcenode from db and compare with json
func Test_route_initialized ¶
Test: Get route from db and compare with json
func Test_world_initialized ¶
Test: Get world from db and compare with json
func World_get_json_from_db ¶
Types ¶
type AchievementMetric ¶
type ActiveUsersMetric ¶
type ActiveUsersMetric struct { Metric UserActivity []UserCallTimestamp `json:"user-activity" binding:"required"` //usernames }
Active Users
type DropTable ¶
type DropTable struct { ResourceSymbol string `json:"resource_symbol" binding:"required"` Rarity float64 `json:"rarity" binding:"required"` HarvestAmount int `json:"harvest_amount" binding:"required"` }
Defines droptables
type Golem ¶
type Golem struct { HasSymbol Archetype string `json:"archetype" binding:"required"` LocationSymbol string `json:"location_symbol" binding:"required"` Status string `json:"status" binding:"required"` Capacity float64 `json:"capacity" binding:"required"` TravelInfo GolemTravelInfo `json:"travel_info" binding:"required"` }
Defines a user which has Name, Symbol, Description
func FilterGolemListByStatus ¶
type GolemArchetype ¶
type GolemArchetype struct { Name string `json:"name" binding:"required"` Abbreviation string `json:"abbreviation" binding:"required"` AllowedStatuses []string `json:"allowed-statuses" binding:"required"` }
golem archetypes and abbreviations map
type GolemStatus ¶
type GolemStatus struct { Name string `json:"name" binding:"required"` IsBlocking bool `json:"is-blocking" binding:"required"` }
golem statuses map
type GolemStatusUpdateBody ¶
type GolemStatusUpdateBody struct { NewStatus string `json:"new_status" binding:"required"` Instructions interface{} `json:"instructions" binding:"required"` }
Defines the structure for golem status update requests Instructions expects an object/map with different keys depending on newStatus
type GolemTravelInfo ¶
type GolemTravelInfo struct { ArrivalTime int64 `json:"arrival_time" binding:"required"` OriginSymbol string `json:"origin_symbol" binding:"required"` DestinationSymbol string `json:"destination_symbol" binding:"required"` RouteDanger int `json:"route_danger" binding:"required"` }
Defines relevant info for golems while traveling
type InventoryResource ¶
Defines resource in an inventory, used in udb, not json/wdb
type Leaderboard ¶
type Leaderboard struct { Thing Users []LeaderboardEntry `json:"users" binding:"required"` }
type LeaderboardDescriptionResponse ¶
type LeaderboardDescriptionResponse struct { Symbol string `json:"symbol" binding:"required"` Name string `json:"name" binding:"required"` Description string `json:"description" binding:"required"` }
func GetLeaderboardDescriptionResponses ¶
func GetLeaderboardDescriptionResponses(boards []Leaderboard) []LeaderboardDescriptionResponse
type LeaderboardEntry ¶
type LeaderboardEntry struct { Rank int `json:"rank" binding:"required"` PublicUserInfo }
type Locale ¶
type Locale struct { Thing ResourceNodeSymbols []string `json:"resource_node_symbols" binding:"required"` RouteSymbols []string `json:"route_symbols" binding:"required"` }
Defines the characteristics of Locales (e.g. cities, forests, etc.)
func Locale_get_from_db ¶
Get the locale specified by path from db
func Locale_unmarshal_json ¶
Unmarshals locale from json byte array
type LocationInventory ¶
type LocationInventory struct { LocationSymbol string `json:"location-symbol" binding:"required"` Contents []Resource `json:"contents" binding:"required"` }
Defines the schema for LocationInventories - lists of items owned by the player at a certain location
type ManaDetails ¶
type ManaDetails struct { Mana float64 `json:"mana" binding:"required"` ManaCap float64 `json:"mana-cap" binding:"required"` ManaRegen float64 `json:"mana-regen" binding:"required"` LastManaTick int64 `json:"last-mana-tick" binding:"required"` }
Defines the schema for ManaDetails - a struct containing information on mana for players
type PublicUserInfo ¶
type PublicUserInfo struct { Username string `json:"username" binding:"required"` Title string `json:"title" binding:"required"` Coins uint64 `json:"coins" binding:"required"` UserSince int64 `json:"user-since" binding:"required"` }
Defines the public User info for the /users/{username} endpoint
type Region ¶
type Region struct { Thing BorderRegionSymbols []string `json:"border_region_symbols" binding:"required"` LocaleSymbols []string `json:"locale_symbols" binding:"required"` }
func Region_get_from_db ¶
Get the region specified by path from db
func Region_unmarshal_json ¶
Unmarshals region from json byte array
type Resource ¶
type Resource struct { Thing CapacityPerUnit float64 `json:"capacity_per_unit" binding:"required"` }
Defines generic resource type
func Resource_get_from_db ¶
Get the resource specified by path from db
func Resource_unmarshal_json ¶
Unmarshals resource from json byte array
type ResourceNode ¶
type ResourceNode struct { Thing HarvestTime int `json:"harvest_time" binding:"required"` DropTables []DropTable `json:"drop_tables" binding:"required"` }
Defines harvestable resource node
func ResourceNode_get_from_db ¶
func ResourceNode_get_from_db(wdb rdb.Database, path string) (ResourceNode, error)
Get the resourcenode specified by path from db
func ResourceNode_unmarshal_json ¶
func ResourceNode_unmarshal_json(resourcenode_json []byte) (ResourceNode, error)
Unmarshals resourcenode from json byte array
type Route ¶
type Route struct { Thing DangerLevel int `json:"danger_level" binding:"required"` TravelTime int `json:"travel_time" binding:"required"` Cost int `json:"cost" binding:"required"` }
Defines the characteristics of Routes between locales TravelTime in seconds
func Route_get_from_db ¶
Get the route specified by path from db
func Route_unmarshal_json ¶
Unmarshals route from json byte array
type Thing ¶
type Thing struct { HasSymbol Name string `json:"name" binding:"required"` Description string `json:"description" binding:"required"` }
Defines a 'Thing' which has Name, Symbol, Description
type UniqueUsersMetric ¶
type UniqueUsersMetric struct { Metric Usernames []string `json:"usernames" binding:"required"` //usernames }
Unique Users
type User ¶
type User struct { Token string `json:"token" binding:"required"` PublicUserInfo ManaDetails Golems []Golem `json:"golems" binding:"required"` Inventory []LocationInventory `json:"inventory" binding:"required"` KnownRituals []string `json:"known-rituals" binding:"required"` }
Defines a user which has Name, Symbol, Description
func GetUserFromDB ¶
Get user from DB, bool is user found
type UserCallTimestamp ¶
type UsersByAchievementMetric ¶
type UsersByAchievementMetric struct { Metric UsersByAchievement []AchievementMetric `json:"users-by-achievement" binding:"required"` }
Users by Achievement
type UsersMetricEndpointResponse ¶
type UsersMetricEndpointResponse struct { UniqueUsers []string `json:"unique-users" binding:"required"` ActiveUsers []string `json:"active-users" binding:"required"` UsersByAchievement []AchievementMetric `json:"users-by-achievement" binding:"required"` }
type World ¶
func World_unmarshal_json ¶
Unmarshals world from json byte array
type WorldSummaryResponse ¶
type WorldSummaryResponse struct { World World `json:"world" binding:"required"` Regions map[string]Region `json:"regions" binding:"required"` Locales map[string]Locale `json:"locales" binding:"required"` Routes map[string]Route `json:"routes" binding:"required"` Resources map[string]Resource `json:"resources" binding:"required"` ResourceNodes map[string]ResourceNode `json:"resource_nodes" binding:"required"` }