Skip to content

Commit d49d72b

Browse files
authored
Add new gameplay system to provide player rewards based on win streaks. (#63)
1 parent 99ffbf0 commit d49d72b

10 files changed

+3009
-1513
lines changed

Diff for: base.go

+11
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ type Hiro interface {
9898
GetProgressionSystem() ProgressionSystem
9999
GetIncentivesSystem() IncentivesSystem
100100
GetAuctionsSystem() AuctionsSystem
101+
GetStreaksSystem() StreaksSystem
101102
}
102103

103104
// The SystemType identifies each of the gameplay systems.
@@ -119,6 +120,7 @@ const (
119120
SystemTypeProgression
120121
SystemTypeIncentives
121122
SystemTypeAuctions
123+
SystemTypeStreaks
122124
)
123125

124126
// Init initializes a Hiro type with the configurations provided.
@@ -345,6 +347,15 @@ func WithAuctionsSystem(configFile string, register bool) SystemConfig {
345347
}
346348
}
347349

350+
// WithStreaksSystem configures a StreaksSystem type and optionally registers its RPCs with the game server.
351+
func WithStreaksSystem(configFile string, register bool) SystemConfig {
352+
return &systemConfig{
353+
systemType: SystemTypeStreaks,
354+
configFile: configFile,
355+
register: register,
356+
}
357+
}
358+
348359
// UnregisterRpc clears the implementation of one or more RPCs registered in Nakama by Hiro gameplay systems with a
349360
// no-op version (http response 404). This is useful to remove individual RPCs which you do not want to be callable by
350361
// game clients:

Diff for: definitions/17-Hiro-Streaks.json

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"streaks": {
3+
"wins": {
4+
"name": "Consecutive Wins",
5+
"description": "Number of consecutive wins, without any losses.",
6+
"count": 0,
7+
"max_count": 9,
8+
"max_count_current_reset": 3,
9+
"idle_count_decay_reset": 9,
10+
"reset_cronexpr": "0 0 * * *",
11+
"rewards": [
12+
{
13+
"count_min": 3,
14+
"count_max": 3,
15+
"reward": {
16+
"guaranteed": {
17+
"currencies": {
18+
"coins": {
19+
"min": 10
20+
}
21+
}
22+
}
23+
}
24+
},
25+
{
26+
"count_min": 6,
27+
"count_max": 6,
28+
"reward": {
29+
"guaranteed": {
30+
"currencies": {
31+
"coins": {
32+
"min": 30
33+
}
34+
}
35+
}
36+
}
37+
},
38+
{
39+
"count_min": 9,
40+
"count_max": 9,
41+
"reward": {
42+
"guaranteed": {
43+
"currencies": {
44+
"coins": {
45+
"min": 100
46+
}
47+
}
48+
}
49+
}
50+
}
51+
]
52+
}
53+
}
54+
}

Diff for: event_leaderboards.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,4 @@ type EventLeaderboardsSystem interface {
8787
DebugRandomScores(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID, eventLeaderboardID string, scoreMin, scoreMax, subscoreMin, subscoreMax int64, operator *int) (eventLeaderboard *EventLeaderboard, err error)
8888
}
8989

90-
type OnEventLeaderboardCohortSelection func(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, storageIndex string, eventID string, config *EventLeaderboardsConfigLeaderboard, userID string, tier int, matchmakerProperties map[string]interface{}) (cohortID string, cohortUserIDs []string, err error)
90+
type OnEventLeaderboardCohortSelection func(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, storageIndex string, eventID string, config *EventLeaderboardsConfigLeaderboard, userID string, tier int, matchmakerProperties map[string]interface{}) (cohortID string, cohortUserIDs []string, forceNewCohort bool, err error)

0 commit comments

Comments
 (0)