Made all types implement Identifiable
This commit is contained in:
parent
8bfb1e0b4d
commit
85bd1441a6
@ -62,6 +62,11 @@ func (inventory *Inventory) SwapSlots(a, b int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetID returns the ID.
|
||||||
|
func (inventory *Inventory) GetID() string {
|
||||||
|
return inventory.UserID
|
||||||
|
}
|
||||||
|
|
||||||
// NewInventory creates a new inventory with the default number of slots.
|
// NewInventory creates a new inventory with the default number of slots.
|
||||||
func NewInventory(userID UserID) *Inventory {
|
func NewInventory(userID UserID) *Inventory {
|
||||||
inventory := &Inventory{
|
inventory := &Inventory{
|
||||||
|
@ -7,6 +7,11 @@ import (
|
|||||||
"github.com/aerogo/api"
|
"github.com/aerogo/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Force interface implementations
|
||||||
|
var (
|
||||||
|
_ Identifiable = (*Inventory)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
func init() {
|
func init() {
|
||||||
API.RegisterActions("Inventory", []*api.Action{
|
API.RegisterActions("Inventory", []*api.Action{
|
||||||
|
@ -5,3 +5,8 @@ type NickToUser struct {
|
|||||||
Nick string `json:"nick" primary:"true"`
|
Nick string `json:"nick" primary:"true"`
|
||||||
UserID UserID `json:"userId"`
|
UserID UserID `json:"userId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetID returns the primary key which is the nickname.
|
||||||
|
func (mapping *NickToUser) GetID() string {
|
||||||
|
return mapping.Nick
|
||||||
|
}
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package arn
|
package arn
|
||||||
|
|
||||||
|
// Force interface implementations
|
||||||
|
var (
|
||||||
|
_ Identifiable = (*ShopItem)(nil)
|
||||||
|
)
|
||||||
|
|
||||||
// Save saves the item in the database.
|
// Save saves the item in the database.
|
||||||
func (item *ShopItem) Save() {
|
func (item *ShopItem) Save() {
|
||||||
DB.Set("ShopItem", item.ID, item)
|
DB.Set("ShopItem", item.ID, item)
|
||||||
|
Loading…
Reference in New Issue
Block a user