gaming

package
v0.0.0-...-b84af7b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IncreaseUserCoins

func IncreaseUserCoins(d Deps, id bson.ObjectId, coins int) error

IncreaseUserCoins for given id.

func IncreaseUserSwords

func IncreaseUserSwords(d Deps, id bson.ObjectId, swords int) error

IncreaseUserSwords for given id.

func IncreaseUserTribute

func IncreaseUserTribute(d Deps, id bson.ObjectId, tribute int) error

IncreaseUserTribute for given id.

Types

type BadgeModel

type BadgeModel struct {
	Id            bson.ObjectId `bson:"_id,omitempty" json:"id,omitempty"`
	Type          string        `bson:"type" json:"type"`
	TypeLabel     string        `bson:"type_label" json:"type_label"`
	Slug          string        `bson:"slug" json:"slug"`
	Name          string        `bson:"name" json:"name"`
	Description   string        `bson:"description" json:"description"`
	Coins         int           `bson:"coins,omitempty" json:"coins,omitempty"`
	RequiredBadge bson.ObjectId `bson:"required_badge,omitempty" json:"required_badge,omitempty"`
	RequiredLevel int           `bson:"required_level,omitempty" json:"required_level,omitempty"`
	Avaliable     bool          `bson:"available" json:"available"`
}

type Deps

type Deps interface {
	Mgo() *mgo.Database
	GamingConfig() *model.GamingRules
}

type Module

type Module struct {
	User   *user.Module                 `inject:""`
	Feed   *feed.FeedModule             `inject:""`
	Config *config.Config               `inject:""`
	Errors *exceptions.ExceptionsModule `inject:""`
	Rules  Rules
}

func Boot

func Boot(file string) *Module

func (*Module) Get

func (self *Module) Get(usr interface{}) *User

Get user gaming struct

func (*Module) GetRankingBy

func (self *Module) GetRankingBy(sort string) []RankingModel

func (*Module) GetRules

func (self *Module) GetRules() Rules

Get gamification model with badges

func (*Module) Post

func (self *Module) Post(post interface{}) *Post

Get post gaming struct

func (*Module) ResetGeneralRanking

func (self *Module) ResetGeneralRanking()

type Post

type Post struct {
	// contains filtered or unexported fields
}

func (*Post) Review

func (self *Post) Review()

Review gaming facts of a post

type RankByBadges

type RankByBadges []RankingModel

func (RankByBadges) Len

func (a RankByBadges) Len() int

func (RankByBadges) Less

func (a RankByBadges) Less(i, j int) bool

func (RankByBadges) Swap

func (a RankByBadges) Swap(i, j int)

type RankByCoins

type RankByCoins []RankingModel

func (RankByCoins) Len

func (a RankByCoins) Len() int

func (RankByCoins) Less

func (a RankByCoins) Less(i, j int) bool

func (RankByCoins) Swap

func (a RankByCoins) Swap(i, j int)

type RankBySwords

type RankBySwords []RankingModel

func (RankBySwords) Len

func (a RankBySwords) Len() int

func (RankBySwords) Less

func (a RankBySwords) Less(i, j int) bool

func (RankBySwords) Swap

func (a RankBySwords) Swap(i, j int)

type RankPosition

type RankPosition struct {
	Id    string
	Value int
}

type RankPositions

type RankPositions []RankPosition

func (RankPositions) Len

func (a RankPositions) Len() int

func (RankPositions) Less

func (a RankPositions) Less(i, j int) bool

func (RankPositions) Swap

func (a RankPositions) Swap(i, j int)

type RankingModel

type RankingModel struct {
	Id       bson.ObjectId        `bson:"_id,omitempty" json:"id,omitempty"`
	UserId   bson.ObjectId        `bson:"user_id" json:"user_id"`
	Badges   int                  `bson:"badges" json:"badges"`
	Swords   int                  `bson:"swords" json:"swords"`
	Coins    int                  `bson:"coins" json:"coins"`
	Position RankingPositionModel `bson:"position" json:"position"`
	Before   RankingPositionModel `bson:"before" json:"before"`
	User     RankingUserModel     `bson:"-" json:"user,omitempty"`
	Created  time.Time            `bson:"created_at" json:"created_at"`
}

type RankingPositionModel

type RankingPositionModel struct {
	Wealth int `bson:"wealth" json:"wealth"`
	Swords int `bson:"swords" json:"swords"`
	Badges int `bson:"badges" json:"badges"`
}

type RankingUserModel

type RankingUserModel struct {
	Id       bson.ObjectId          `bson:"_id,omitempty" json:"id"`
	UserName string                 `bson:"username" json:"username"`
	Image    string                 `bson:"image" json:"image,omitempty"`
	Gaming   map[string]interface{} `bson:"gaming" json:"gaming,omitempty"`
}

type RuleModel

type RuleModel struct {
	Level   int    `json:"level"`
	Name    string `json:"name"`
	Start   int    `json:"swords_start"`
	End     int    `json:"swords_end"`
	Tribute int    `json:"tribute"`
	Shit    int    `json:"shit"`
	Coins   int    `json:"coins"`
}

type Rules

type Rules struct {
	Updated time.Time    `json:"updated_at"`
	Rules   []RuleModel  `json:"rules"`
	Badges  []BadgeModel `json:"badges,omitempty"`
}

type User

type User struct {
	// contains filtered or unexported fields
}

func (*User) AcquireBadge

func (self *User) AcquireBadge(id bson.ObjectId, validation bool) error

func (*User) Coins

func (self *User) Coins(how_many int)

Increases or decreases user coins

func (*User) DailyLogin

func (self *User) DailyLogin()

Does the daily login logic for the user

func (*User) Shit

func (self *User) Shit(how_many int)

Increases or decreases user shit

func (*User) Swords

func (self *User) Swords(how_many int)

Increases or decreases user swords

func (*User) SyncToLevel

func (self *User) SyncToLevel(reset bool)

Sync user gamification relevant facts

func (*User) Tribute

func (self *User) Tribute(how_many int)

Increases or decreases user tribute

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL