Skip to content

Commit

Permalink
Merge branch 'main' into luke/inventory-instance-id
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Gehorsam committed Oct 27, 2023
2 parents 6ecf658 + 0f37aeb commit 98d9ff8
Show file tree
Hide file tree
Showing 7 changed files with 2,774 additions and 2,364 deletions.
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,47 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
## [Unreleased]


## [1.7.0] - 2023-10-24
### Added
- New error type "ErrItemsNotConsumable" for Inventory items which are not consumable.

### Changed
- Energies "Grant" now returns a player's updated energies.
- "Get" will return an empty state for an Event Leaderboard when a player has never had a previous cohort.
- Add "locked" field to the storage engine index used with Event Leaderboard cohort generation.
- (Unity) Improve "InventorySystem" to use observer pattern.

### Fixed
- (Unity) Use "PurchaseFailureDescription.reason" with Unity IAP package for error messages.
- Sender claim uses the newer internal operation in Incentives system.
- Do not shadow parent Reward when it is created to be granted in Achievements system.
- (Unity) Use an async pattern in "IStoreListener.ProcessPurchase" with Unity IAP package.

## [1.6.0] - 2023-10-15
### Added
- Add fields for "is_active", "can_claim", and "can_roll" for simpler client code with Event Leaderboards.
- (Unity) Add "IncentivesSystem".
- New "max_overflow" field to the data definition for Energies.

### Changed
- (Unity) Allow both "IEconomyListStoreItem" and "IEconomyLocalizedStoreItem" to be used in purchase flows.

### Fixed
- Use Inventory after the Progression purchase has been applied to calculate the latest Progression deltas.
- Energy counts granted as an Economy Reward are kept as overflow.
- Fix panic in progression precondition comparison.
- Batch economy changes which resolve to items removed are now marked correctly.
- (Unity) Serialize the input for Inventory update items request correctly to JSON.
- Fix to progression deltas computations.

## [1.5.0] - 2023-10-04
### Added
- Add server interface for the Incentives gameplay system.
- Cohort selection in Event Leaderboards can now be overridden with a custom function.

### Changed
- "Get" in the Progression gameplay system now returns a delta of Progression Nodes who's state has changed if a previous graph is passed to it.

## [1.4.0] - 2023-09-14
### Added
- New function to "Roll" a new cohort with an Event Leaderboard in an active phase.
Expand Down
1 change: 1 addition & 0 deletions economy.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var (
ErrEconomyClaimedDonation = runtime.NewError("donation already claimed", 3) // INVALID_ARGUMENT

ErrInventoryNotInitialized = runtime.NewError("inventory not initialized for batch", 13)
ErrItemsNotConsumable = runtime.NewError("items not consumable", 13)
ErrItemsInsufficient = runtime.NewError("insufficient items", 13)
ErrCurrencyInsufficient = runtime.NewError("insufficient currency", 13)
)
Expand Down
3 changes: 2 additions & 1 deletion energy.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type EnergyConfig struct {
type EnergyConfigEnergy struct {
StartCount int32 `json:"start_count"`
MaxCount int32 `json:"max_count"`
MaxOverfill int32 `json:"max_overfill"`
RefillCount int32 `json:"refill_count"`
RefillTimeSec int64 `json:"refill_time_sec"`
Implicit bool `json:"implicit"`
Expand All @@ -48,7 +49,7 @@ type EnergySystem interface {
Spend(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID string, amounts map[string]int32) (map[string]*Energy, *Reward, error)

// Grant will add the amounts to each energy (while applying any energy modifiers) for a user by ID.
Grant(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID string, amounts map[string]int32, modifiers []*RewardEnergyModifier) (*runtime.StorageWrite, error)
Grant(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID string, amounts map[string]int32, modifiers []*RewardEnergyModifier) (map[string]*Energy, error)

// SetOnSpendReward sets a custom reward function which will run after an energy reward's value has been rolled.
SetOnSpendReward(fn OnReward[*EnergyConfigEnergy])
Expand Down
10 changes: 8 additions & 2 deletions event_leaderboards.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type EventLeaderboardsConfigLeaderboard struct {
}

type EventLeaderboardsConfigLeaderboardRewardTier struct {
Name string `json:"name"`
RankMax int `json:"rank_max"`
RankMin int `json:"rank_min"`
Reward *EconomyConfigReward `json:"reward"`
Expand All @@ -61,10 +62,10 @@ type EventLeaderboardsSystem interface {
System

// GetEventLeaderboard returns a specified event leaderboard's cohort for the user.
GetEventLeaderboard(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID, username, eventLeaderboardID string) (*EventLeaderboard, error)
GetEventLeaderboard(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID, eventLeaderboardID string) (*EventLeaderboard, error)

// RollEventLeaderboard places the user into a new cohort for the specified event leaderboard if possible.
RollEventLeaderboard(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID, username, eventLeaderboardID string) (*EventLeaderboard, error)
RollEventLeaderboard(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID, eventLeaderboardID string) (*EventLeaderboard, error)

// UpdateEventLeaderboard updates the user's score in the specified event leaderboard, and returns the user's updated cohort information.
UpdateEventLeaderboard(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID, username, eventLeaderboardID string, score, subscore int64) (*EventLeaderboard, error)
Expand All @@ -74,4 +75,9 @@ type EventLeaderboardsSystem interface {

// SetOnEventLeaderboardsReward sets a custom reward function which will run after an event leaderboard's reward is rolled.
SetOnEventLeaderboardsReward(fn OnReward[*EventLeaderboardsConfigLeaderboard])

// SetOnEventLeaderboardCohortSelection sets a custom function that can replace the cohort or opponent selection feature of event leaderboards.
SetOnEventLeaderboardCohortSelection(fn OnEventLeaderboardCohortSelection)
}

type OnEventLeaderboardCohortSelection func(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, eventID string, config *EventLeaderboardsConfigLeaderboard, userID string, tier int) (cohortID string, cohortUserIDs []string, err error)
Loading

0 comments on commit 98d9ff8

Please sign in to comment.