Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix storage personalizer inventory check #21

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
### Changed
- Use "omitempty" in marshaler settings with data definition structs.

### Fixed
- Fixed unrecognized Inventory system type in storage personalizer.

## [1.9.0] - 2024-02-04
### Added
- New option "max_repeat_rolls" to set how many duplicate rows of rolled rewards can occur.
Expand Down Expand Up @@ -151,7 +154,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
- Add ChannelMessageAck message to proto definition.

### Fixed
- Expose server functions for reward and roll in Hiro.
- Expose server functions for reward and roll in Hiro.

## [1.0.3] - 2023-08-10
### Added
Expand Down
14 changes: 14 additions & 0 deletions personalizer_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
storagePersonalizerKeyAchievements = "achievements"
storagePersonalizerKeyEconomy = "economy"
storagePersonalizerKeyEnergy = "energy"
storagePersonalizerKeyInventory = "inventory"
storagePersonalizerKeyEventLeaderboards = "event_leaderboards"
storagePersonalizerKeyIncentives = "incentives"
storagePersonalizerKeyLeaderboards = "leaderboards"
Expand Down Expand Up @@ -63,6 +64,7 @@ type storagePersonalizerUploadRequest struct {
Achievements *AchievementsConfig `json:"achievements"`
Economy *EconomyConfig `json:"economy"`
Energy *EnergyConfig `json:"energy"`
Inventory *InventoryConfig `json:"inventory"`
EventLeaderboard *EventLeaderboardsConfig `json:"event_leaderboards"`
Incentives *IncentivesConfig `json:"incentives"`
Leaderboards *LeaderboardConfig `json:"leaderboards"`
Expand Down Expand Up @@ -141,6 +143,16 @@ func rpcStoragePersonalizerUpload(initializer runtime.Initializer, p *StoragePer
writes = append(writes, write)
}

if req.Inventory != nil {
write, err := p.newStorageWrite(req.Inventory, storagePersonalizerKeyInventory)
if err != nil {
logger.WithField("error", err.Error()).Error("Error creating inventory storage object.")
return "", ErrInternal
}

writes = append(writes, write)
}

if req.EventLeaderboard != nil {
write, err := p.newStorageWrite(req.EventLeaderboard, storagePersonalizerKeyEventLeaderboards)
if err != nil {
Expand Down Expand Up @@ -257,6 +269,8 @@ func (p *StoragePersonalizer) GetValue(ctx context.Context, logger runtime.Logge
readOp = &runtime.StorageRead{Collection: p.collection, Key: storagePersonalizerKeyEconomy}
case SystemTypeEnergy:
readOp = &runtime.StorageRead{Collection: p.collection, Key: storagePersonalizerKeyEnergy}
case SystemTypeInventory:
readOp = &runtime.StorageRead{Collection: p.collection, Key: storagePersonalizerKeyInventory}
case SystemTypeEventLeaderboards:
readOp = &runtime.StorageRead{Collection: p.collection, Key: storagePersonalizerKeyEventLeaderboards}
case SystemTypeIncentives:
Expand Down
Loading