Documentation ¶
Index ¶
- Constants
- func Graph(db *gorp.DbMap, scenar *Scenario) (interface{}, error)
- type Card
- func CreateCard(db *gorp.DbMap, scenar *Scenario, num uint, desc string, front *CardFace, ...) (*Card, error)
- func GetElementCards(db *gorp.DbMap, scenar *Scenario) ([]*Card, error)
- func ListCards(db *gorp.DbMap, scenar *Scenario) ([]*Card, error)
- func LoadCardFromID(db *gorp.DbMap, scenar *Scenario, ID int64) (*Card, error)
- func (c *Card) CreateCardIcon(db *gorp.DbMap, ico *Icon, FrontBack bool, X, Y, SizeX, SizeY uint, ...) (*CardIcon, error)
- func (c *Card) Delete(db *gorp.DbMap) error
- func (c *Card) ListCardIcons(db *gorp.DbMap, SkillTest *SkillTest, StateTokenLink *StateTokenLink) ([]*CardIcon, error)
- func (c *Card) LoadCardIconFromID(db *gorp.DbMap, ID int64) (*CardIcon, error)
- func (c *Card) Update(db *gorp.DbMap, num uint, desc string, front *CardFace, back *CardFace) error
- type CardFace
- type CardGraph
- type CardIcon
- type Element
- type ElementLink
- func CreateElementLink(db *gorp.DbMap, card *Card, elem *Element, GivesUses bool) (*ElementLink, error)
- func ListElementLinks(db *gorp.DbMap, scenar *Scenario, card *Card, elem *Element) ([]*ElementLink, error)
- func LoadElementLinkFromID(db *gorp.DbMap, scenar *Scenario, ID int64) (*ElementLink, error)
- type Icon
- func CreateIcon(db *gorp.DbMap, scenar *Scenario, ShortName string, URL string) (*Icon, error)
- func ListIcons(db *gorp.DbMap, scenar *Scenario) ([]*Icon, error)
- func LoadBaseIconFromShortName(db *gorp.DbMap, ShortName string) (*Icon, error)
- func LoadIconFromID(db *gorp.DbMap, scenar *Scenario, ID int64) (*Icon, error)
- type LocGraph
- type Location
- func (loc *Location) CreateLocationCard(db *gorp.DbMap, scenar *Scenario, letter string) (*LocationCard, error)
- func (loc *Location) Delete(db *gorp.DbMap) error
- func (loc *Location) GetCards(db *gorp.DbMap) ([]*Card, error)
- func (loc *Location) ListLocationCards(db *gorp.DbMap) ([]*LocationCard, error)
- func (loc *Location) LoadLocationCardFromID(db *gorp.DbMap, ID int64) (*LocationCard, error)
- func (loc *Location) Update(db *gorp.DbMap, Name string, Hidden bool, Notes string) error
- func (loc *Location) Valid() error
- type LocationCard
- type LocationLink
- type Scenario
- type SkillTest
- type Stat
- type StateToken
- type StateTokenLink
- func CreateStateTokenLink(db *gorp.DbMap, card *Card, tk *StateToken, UnlocksUnlocked bool) (*StateTokenLink, error)
- func ListStateTokenLinks(db *gorp.DbMap, scenar *Scenario, card *Card, tk *StateToken) ([]*StateTokenLink, error)
- func LoadStateTokenLinkFromID(db *gorp.DbMap, scenar *Scenario, ID int64) (*StateTokenLink, error)
- type TextField
- type User
Constants ¶
const ( MAX_SHIELDS = 50 // Arbitrarily large MAX_X_COORD = 300 // TODO fix MAX_Y_COORD = 300 // TODO fix DEFAULT_SIZE_X = 20 DEFAULT_SIZE_Y = 20 AnnotationTypeSquare = 1 AnnotationTypeCircle = 2 )
const ( // Const names to be retrievable from model code NORMAL_SHIELD_ICON = "normal_shield" SKULL_SHIELD_ICON = "skull_shield" HEART_SHIELD_ICON = "heart_shield" UT_SHIELD_ICON = "ut_shield" SPECIAL_SHIELD_ICON = "special_shield" )
const ( SALT_LEN = 32 PASSWORD_MIN_LEN = 8 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Card ¶
type Card struct { ID int64 `json:"id" db:"id"` IDScenario int64 `json:"-" db:"id_scenario"` Number uint `json:"number" db:"number"` Description string `json:"description" db:"description"` Front *CardFace `json:"front" db:"front"` Back *CardFace `json:"back" db:"back"` }
Type card is the basic building block for other game objects. It is a generic representation of a card.
func CreateCard ¶
func CreateCard(db *gorp.DbMap, scenar *Scenario, num uint, desc string, front *CardFace, back *CardFace) (*Card, error)
Create a card.
func GetElementCards ¶
Returns all card objects that belong to elements.
func LoadCardFromID ¶
Load a card by ID. Optionally filtered by scenario.
func (*Card) CreateCardIcon ¶
func (c *Card) CreateCardIcon(db *gorp.DbMap, ico *Icon, FrontBack bool, X, Y, SizeX, SizeY uint, Annotation string, AnnotationType int, SkillTest *SkillTest, StateTokenLink *StateTokenLink) (*CardIcon, error)
Create a CardIcon object.
func (*Card) ListCardIcons ¶
func (c *Card) ListCardIcons(db *gorp.DbMap, SkillTest *SkillTest, StateTokenLink *StateTokenLink) ([]*CardIcon, error)
List all CardIcon objects linked to this card, with filters.
func (*Card) LoadCardIconFromID ¶
Load one CardIcon object linked to this card, by ID.
type CardFace ¶
type CardFace struct { TextAreaSize int `json:"text_area_size"` TextFields []TextField `json:"text_fields"` }
CardFace describes the Front or Back non-image components of a card. It is stored as JSON to allow flexibility / evolution in the definition.
type CardGraph ¶
type CardGraph struct { ID int64 `json:"id"` Description string `json:"description"` Reveals []int64 `json:"reveals,omitempty"` UnlockStateTokens []int64 `json:"unlocks_state_tokens,omitempty"` IsUnlockedStateTokens []int64 `json:"is_unlocked_state_tokens,omitempty"` SkillTests []int64 `json:"skill_tests,omitempty"` }
type CardIcon ¶
type CardIcon struct { ID int64 `json:"id" db:"id"` IDCard int64 `json:"id_card" db:"id_card"` FrontBack bool `json:"front_back" db:"front_back"` IDIcon int64 `json:"id_icon" db:"id_icon"` X uint `json:"x" db:"x"` Y uint `json:"y" db:"y"` SizeX uint `json:"size_x" db:"size_x"` SizeY uint `json:"size_y" db:"size_y"` Annotation string `json:"annotation" db:"annotation"` AnnotationType int `json:"annotation_type" db:"annotation_type"` IDSkillTest *int64 `json:"-" db:"id_skilltest"` IDStateTokenLink *int64 `json:"-" db:"id_statetokenlink"` }
CardIcon represents a single graphical icon on the Front or the Back of a Card. It is linked to a Card, and to a collection of Icon graphical elements. It has coordinates/size properties, and optional annotations (small circle or square) to add e.g. a Stat value for a character or a number above a Shield. It also has foreign keys to the SkillTest/StateTokenLink that it originated from, so that it can be retrieved for update when the SkillTest/StateTokenLink is updated, and can be automatically deleted through CASCADE.
type Element ¶
type Element struct { ID int64 `json:"-" db:"id"` IDScenario int64 `json:"-" db:"id_scenario"` Number int `json:"number" db:"number"` Description string `json:"description" db:"description"` Notes string `json:"notes" db:"notes"` IDCard int64 `json:"id_card" db:"id_card"` }
func CreateElement ¶
func CreateElement(db *gorp.DbMap, scenar *Scenario, Number int, Description string) (*Element, error)
Create a new element.
func ListElements ¶
List elements, optionally filtered by scenario.
func LoadElementFromID ¶
Load element by ID. Optional scenario filter.
type ElementLink ¶
type ElementLink struct { ID int64 `json:"id" db:"id"` IDScenario int64 `json:"id_scenario" db:"id_scenario"` IDElement int64 `json:"id_element" db:"id_element"` IDCard int64 `json:"id_card" db:"id_card"` GivesUses bool `json:"gives_uses" db:"gives_uses"` }
func CreateElementLink ¶
func CreateElementLink(db *gorp.DbMap, card *Card, elem *Element, GivesUses bool) (*ElementLink, error)
Create a link between an element and a card.
func ListElementLinks ¶
func ListElementLinks(db *gorp.DbMap, scenar *Scenario, card *Card, elem *Element) ([]*ElementLink, error)
List element links, with filters.
func LoadElementLinkFromID ¶
Load an element link by id, with optional scenario filter.
type Icon ¶
type Icon struct { ID int64 `json:"id" db:"id"` IDScenario *int64 `json:"id_scenario" db:"id_scenario"` ShortName string `json:"short_name" db:"short_name"` URL string `json:"url" db:"url"` }
func CreateIcon ¶
Create an icon
func LoadBaseIconFromShortName ¶
Used to load base game objects, e.g. shield icons. These need to be referenced by a const name for conveniency. This enforces id_scenario IS NULL (i.e. base game objects) on returned rows.
func LoadIconFromID ¶
Load an icon from ID. If scenar parameter is non-nil it acts as a filter: only rows with id_scenario NULL or stricly equal will be returned.
type Location ¶
type Location struct { ID int64 `json:"id" db:"id"` IDScenario int64 `json:"-" db:"id_scenario"` Name string `json:"name" db:"name"` Hidden bool `json:"hidden" db:"hidden"` Notes string `json:"notes" db:"notes"` }
Location represents a location the players can visit. It is composed of several cards.
func CreateLocation ¶
Create a location.
func ListLocations ¶
List locations, with filters.
func LoadLocationFromID ¶
Load a Location from ID. Optionally filtered by scenario.
func (*Location) CreateLocationCard ¶
func (loc *Location) CreateLocationCard(db *gorp.DbMap, scenar *Scenario, letter string) (*LocationCard, error)
Create a link between a card and a location.
func (*Location) ListLocationCards ¶
func (loc *Location) ListLocationCards(db *gorp.DbMap) ([]*LocationCard, error)
List a location's cards.
func (*Location) LoadLocationCardFromID ¶
Load a location card,
type LocationCard ¶
type LocationCard struct { ID int64 `json:"id" db:"id"` IDLocation int64 `json:"-" db:"id_location"` IDCard int64 `json:"id_card" db:"id_card"` Letter string `json:"letter" db:"letter"` }
LocationCard represents the cards contained in a location. Decoupled from Location to allow things like multiple "A" locations
func (*LocationCard) Delete ¶
func (lc *LocationCard) Delete(db *gorp.DbMap) error
Delete a location card.
func (*LocationCard) Update ¶
func (lc *LocationCard) Update(db *gorp.DbMap, letter string) error
Update a location card.
func (*LocationCard) Valid ¶
func (lc *LocationCard) Valid() error
Verify that a LocationCard is valid before creating/updating it.
type LocationLink ¶
type LocationLink struct { ID int64 `json:"id" db:"id"` IDScenario int64 `json:"-" db:"id_scenario"` IDCard int64 `json:"id_card" db:"id_card"` IDLocation int64 `json:"id_location" db:"id_location"` }
LocationLink represents a link between a card and a Location. The card REVEALS the location.
func CreateLocationLink ¶
Create a link between a card and a location.
func ListLocationLinks ¶
func ListLocationLinks(db *gorp.DbMap, scenar *Scenario, card *Card, loc *Location) ([]*LocationLink, error)
List location links, with filters.
func LoadLocationLinkFromID ¶
Loads a location link by ID. Optionally filtered by scenario.
type Scenario ¶
type Scenario struct { ID int64 `json:"id" db:"id"` Name string `json:"name" db:"name"` IDAuthor int64 `json:"-" db:"id_author"` }
Scenario is the highest-level object. All other game objects belong to a scenario. A scenario belongs to a user (author).
func CreateScenario ¶
Create a scenario.
func ListScenarios ¶
List scenarios, optionally filtered by author.
func LoadScenarioFromID ¶
Load a scenario by id, optionally filtered by author.
type SkillTest ¶
type SkillTest struct { ID int64 `json:"id" db:"id"` IDScenario int64 `json:"-" db:"id_scenario"` IDCard int64 `json:"id_card" db:"id_card"` IDStat int64 `json:"id_stat" db:"id_stat"` NormalShields uint `json:"normal_shields" db:"normal_shields"` SkullShields uint `json:"skull_shields" db:"skull_shields"` HeartShields uint `json:"heart_shields" db:"heart_shields"` UTShields uint `json:"ut_shields" db:"ut_shields"` SpecialShields uint `json:"special_shields" db:"special_shields"` }
SkillTest represents a statistic skill-test required by a Card. It links the Card and the Stat for easy querying/navigation, and allows easy declaration of test difficulty by declaring each number of shields. The code managing SkillTest objects will create CardIcon objects for the skill-test statistic and for each kind of non-zero Shield, and link them to the Card. That way, the user only has to create a SkillTest to have all the necessary graphical elements added to a Card, which can then be edited individually.
func CreateSkillTest ¶
func CreateSkillTest(db *gorp.DbMap, card *Card, linkedStat *Stat, NormalShields, SkullShields, HeartShields, UTShields, SpecialShields uint) (*SkillTest, error)
Create a skill test. This will also create CardIcon objects on the Front of the Card, for the statistic itself and each of the present shields.
func ListSkillTests ¶
List skill tests with filters.
func LoadSkillTestFromID ¶
Load a skill test, by ID. Optionally filtered by scenario.
func (*SkillTest) Update ¶
func (st *SkillTest) Update(db *gorp.DbMap, card *Card, linkedStat *Stat, NormalShields, SkullShields, HeartShields, UTShields, SpecialShields uint) error
Update a skill test linked to a card. This will also create CardIcon objects on the Front of the Card, for the statistic itself and each of the present shields. The card parameter CANNOT overwrite the card associated with the SkillTest, it is permanent. It is passed only to be able to retrieve the associated CardIcon objects.
type Stat ¶
type Stat struct { ID int64 `json:"id" db:"id"` IDScenario int64 `json:"-" db:"id_scenario"` Name string `json:"name" db:"name"` Description string `json:"description" db:"description"` IDIcon int64 `json:"id_icon" db:"id_icon"` }
func CreateStat ¶
func CreateStat(db *gorp.DbMap, scenar *Scenario, ico *Icon, name string, description string) (*Stat, error)
Create a stat object.
func LoadStatFromID ¶
Load stat by id, optionally filtered by scenario.
type StateToken ¶
type StateToken struct { ID int64 `json:"id" db:"id"` ShortName string `json:"short_name" db:"short_name"` IDIcon int64 `json:"id_icon" db:"id_icon"` }
StateToken represents base game tokens with different icons that maintain game state (e.g. unlock access to cards) These are bootstrapped in DB, only need Load functions.
func ListStateTokens ¶
func ListStateTokens(db *gorp.DbMap) ([]*StateToken, error)
List all state tokens
func LoadStateTokenFromID ¶
func LoadStateTokenFromID(db *gorp.DbMap, ID int64) (*StateToken, error)
Loads a state token by ID
type StateTokenLink ¶
type StateTokenLink struct { ID int64 `json:"id" db:"id"` IDScenario int64 `json:"-" db:"id_scenario"` IDCard int64 `json:"id_card" db:"id_card"` IDStateToken int64 `json:"id_state_token" db:"id_state_token"` UnlocksUnlocked bool `json:"unlocks_unlocked" db:"unlocks_unlocked"` }
StateTokenLink represents a Card -> StateToken relation. It is uni-directional but can be configured using the UnlocksUnlocked parameter. This lets the user express relations such as:
Card X (unlocks) -> StateToken Y (unlocks) -> Card Z
A CardIcon object containing the StateToken icon will be added to the Front of any Card that "unlocks" it, and to the back of any Card that is "unlocked" by it.
func CreateStateTokenLink ¶
func CreateStateTokenLink(db *gorp.DbMap, card *Card, tk *StateToken, UnlocksUnlocked bool) (*StateTokenLink, error)
Create a link between a card and a state token. This will also create a CardIcon object representing the state token on either the front or the back of the card (depending on if it unlocks / is unlocked).
func ListStateTokenLinks ¶
func ListStateTokenLinks(db *gorp.DbMap, scenar *Scenario, card *Card, tk *StateToken) ([]*StateTokenLink, error)
List state token links, with filters.
func LoadStateTokenLinkFromID ¶
Loads a state token link by ID. Optionally filtered by scenario.
func (*StateTokenLink) Delete ¶
func (cl *StateTokenLink) Delete(db *gorp.DbMap) error
Delete a state token link.
func (*StateTokenLink) Update ¶
func (cl *StateTokenLink) Update(db *gorp.DbMap, card *Card, tk *StateToken, UnlocksUnlocked bool) error
TODO delete? Update a state token link. This will also create a CardIcon object representing the state token on either the front or the back of the card (depending on if it unlocks / is unlocked). The card parameter CANNOT overwrite the card associated with the StateTokenLink, it is permanent. It is passed only to be able to retrieve the associated CardIcon object.
type TextField ¶
TextField describes a single field of text on a card. For now, it just has spacial coordinates. Later, this will evolve to contain more flexibility (box_size x/y, font, font_size, opacity, color, ...)
type User ¶
type User struct { ID int64 `json:"-" db:"id"` Email string `json:"email" db:"email"` PasswordHash string `json:"-" db:"password_hash"` PasswordSalt string `json:"-" db:"password_salt"` // contains filtered or unexported fields }
func CreateUser ¶
Create a user.
func LoadUserFromEmail ¶
Load a user by email.
func (*User) PasswordEquals ¶
Check if the user's password matches the plain parameter.