unifyReward

package
v0.0.0-...-15bed1d Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetCoinFunc

func SetCoinFunc(coin int) func(claim *RewardClaim)

func SetExpFunc

func SetExpFunc(exp int) func(claim *RewardClaim)

func SetNugetFunc

func SetNugetFunc(nugget int) func(claim *RewardClaim)

Types

type RewardCenter

type RewardCenter interface {
	RewardToken(ctx context.Context, module rewardClaimType, eventType int,
		opts ...func(claim *RewardClaim)) (string, error) // new reward token
	ParseToken(ctx context.Context, token string) (
		claim *jwtService.RewardClaim[RewardClaim],
		invalidToken func() error,
		err error,
	) // parse reward token & invalidToken
	AddCurrency(ctx context.Context, db *gorm.DB, eventType int, itemID int,
		rewards map[int]int) (totalValueMap map[int]int, err error) // 加金币,元宝,经验
	ClaimReward(ctx context.Context, token string) (reward, rewardTotal map[int]int,
		err error) // 领奖,金币、元宝、经验
}

func NewRewardCenter

func NewRewardCenter(ctx context.Context) RewardCenter

type RewardClaim

type RewardClaim struct {
	UserID    string          // userid 不能领别人的奖励
	Module    rewardClaimType `json:"module"` //
	EventType int
	ItemID    int
	Reward    map[int]int `json:"reward"` // coin,nugget,exp
}

func (RewardClaim) Type

func (c RewardClaim) Type() (owner string, module int)

func (RewardClaim) Valid

func (c RewardClaim) Valid() error

type SetRewardFunc

type SetRewardFunc func(int) func(claim *RewardClaim)

Jump to

Keyboard shortcuts

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