gs2-ruby-sdk-ranking 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.buildpath +5 -0
- data/.gitignore +10 -0
- data/.project +17 -0
- data/Gemfile +5 -0
- data/README.md +2 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/gs2-ruby-sdk-ranking.gemspec +26 -0
- data/lib/gs2-ranking.rb +1 -0
- data/lib/gs2/ranking/Client.rb +476 -0
- data/lib/gs2/ranking/version.rb +5 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bbfa860c7c83b5c893153234159bb15d6e6b42e3
|
4
|
+
data.tar.gz: 39d9522ac1faf67e61332c2816ff0bb295f24b8d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b8353b6a52620e4258c2ff843c6a1d879204d334aaf49e3d314455952502766b4f98dbded96b1fce5a5bd5b955a266c2c1d8a4a98681ef0f2f771fbd1320d17c
|
7
|
+
data.tar.gz: 504a89b18445379d896b32eec6be21666c49f41ad6311497ed3e19fc469eee4507cf52c40af49e3ad0c1ceb847551993f036dbe85916f1aae312ce607fd7e135
|
data/.buildpath
ADDED
data/.gitignore
ADDED
data/.project
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<projectDescription>
|
3
|
+
<name>gs2-ruby-sdk-ranking</name>
|
4
|
+
<comment></comment>
|
5
|
+
<projects>
|
6
|
+
</projects>
|
7
|
+
<buildSpec>
|
8
|
+
<buildCommand>
|
9
|
+
<name>org.eclipse.dltk.core.scriptbuilder</name>
|
10
|
+
<arguments>
|
11
|
+
</arguments>
|
12
|
+
</buildCommand>
|
13
|
+
</buildSpec>
|
14
|
+
<natures>
|
15
|
+
<nature>org.eclipse.dltk.ruby.core.nature</nature>
|
16
|
+
</natures>
|
17
|
+
</projectDescription>
|
data/Gemfile
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "gs2/sdk/for/ruby/ranking"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gs2/ranking/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gs2-ruby-sdk-ranking"
|
8
|
+
spec.version = Gs2::Ranking::VERSION
|
9
|
+
spec.authors = ["Game Server Services, Inc."]
|
10
|
+
spec.email = ["contact@gs2.io"]
|
11
|
+
spec.licenses = "Apache-2.0"
|
12
|
+
|
13
|
+
spec.summary = %q{Game Server Services GS2-Ranking Client Library}
|
14
|
+
spec.homepage = "https://gs2.io/"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "gs2-ruby-sdk-core", "~> 0.0.1"
|
22
|
+
spec.add_dependency "gs2-ruby-sdk-auth", "~> 0.0.1"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
end
|
data/lib/gs2-ranking.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'gs2/ranking/Client.rb'
|
@@ -0,0 +1,476 @@
|
|
1
|
+
require 'gs2/core/AbstractClient.rb'
|
2
|
+
|
3
|
+
module Gs2 module Ranking
|
4
|
+
|
5
|
+
# GS2-Ranking クライアント
|
6
|
+
#
|
7
|
+
# @author Game Server Services, Inc.
|
8
|
+
class Client < Gs2::Core::AbstractClient
|
9
|
+
|
10
|
+
@@ENDPOINT = 'ranking'
|
11
|
+
|
12
|
+
# コンストラクタ
|
13
|
+
#
|
14
|
+
# @param region [String] リージョン名
|
15
|
+
# @param gs2_client_id [String] GSIクライアントID
|
16
|
+
# @param gs2_client_secret [String] GSIクライアントシークレット
|
17
|
+
def initialize(region, gs2_client_id, gs2_client_secret)
|
18
|
+
super(region, gs2_client_id, gs2_client_secret)
|
19
|
+
end
|
20
|
+
|
21
|
+
# デバッグ用。通常利用する必要はありません。
|
22
|
+
def self.ENDPOINT(v = nil)
|
23
|
+
if v
|
24
|
+
@@ENDPOINT = v
|
25
|
+
else
|
26
|
+
return @@ENDPOINT
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# ランキングテーブルリストを取得
|
31
|
+
#
|
32
|
+
# @param pageToken [String] ページトークン
|
33
|
+
# @param limit [Integer] 取得件数
|
34
|
+
# @return [Array]
|
35
|
+
# * items
|
36
|
+
# [Array]
|
37
|
+
# * rankingTableId => ランキングテーブルID
|
38
|
+
# * ownerId => オーナーID
|
39
|
+
# * name => ランキングテーブル名
|
40
|
+
# * description => 説明文
|
41
|
+
# * createAt => 作成日時
|
42
|
+
# * updateAt => 更新日時
|
43
|
+
# * nextPageToken => 次ページトークン
|
44
|
+
def describe_ranking_table(pageToken = nil, limit = nil)
|
45
|
+
query = {}
|
46
|
+
if pageToken; query['pageToken'] = pageToken; end
|
47
|
+
if limit; query['limit'] = limit; end
|
48
|
+
return get(
|
49
|
+
'Gs2Ranking',
|
50
|
+
'DescribeRankingTable',
|
51
|
+
@@ENDPOINT,
|
52
|
+
'/ranking',
|
53
|
+
query);
|
54
|
+
end
|
55
|
+
|
56
|
+
# ランキングテーブルを作成<br>
|
57
|
+
# <br>
|
58
|
+
# GS2-Ranking を利用するには、まずランキングテーブルを作成する必要があります。<br>
|
59
|
+
# 1つのランキングテーブルには複数のゲームモードのランキングを格納することができます。<br>
|
60
|
+
#
|
61
|
+
# @param request [Array]
|
62
|
+
# * name => ランキングテーブル名
|
63
|
+
# * description => 説明文
|
64
|
+
# @return [Array]
|
65
|
+
# * item
|
66
|
+
# * rankingTableId => ランキングテーブルID
|
67
|
+
# * ownerId => オーナーID
|
68
|
+
# * name => ランキングテーブル名
|
69
|
+
# * description => 説明文
|
70
|
+
# * createAt => 作成日時
|
71
|
+
# * updateAt => 更新日時
|
72
|
+
def create_ranking_table(request)
|
73
|
+
if not request; raise ArgumentError.new(); end
|
74
|
+
body = {}
|
75
|
+
if request.has_key?('name'); body['name'] = request['name']; end
|
76
|
+
if request.has_key?('description'); body['description'] = request['description']; end
|
77
|
+
query = {}
|
78
|
+
return post(
|
79
|
+
'Gs2Ranking',
|
80
|
+
'CreateRankingTable',
|
81
|
+
@@ENDPOINT,
|
82
|
+
'/ranking',
|
83
|
+
body,
|
84
|
+
query);
|
85
|
+
end
|
86
|
+
|
87
|
+
# ランキングテーブルを取得
|
88
|
+
#
|
89
|
+
# @param request [Array]
|
90
|
+
# * rankingTableName => ランキングテーブル名
|
91
|
+
# @return [Array]
|
92
|
+
# * item
|
93
|
+
# * rankingTableId => ランキングテーブルID
|
94
|
+
# * ownerId => オーナーID
|
95
|
+
# * name => ランキングテーブル名
|
96
|
+
# * description => 説明文
|
97
|
+
# * createAt => 作成日時
|
98
|
+
# * updateAt => 更新日時
|
99
|
+
def get_ranking_table(request)
|
100
|
+
if not request; raise ArgumentError.new(); end
|
101
|
+
if not request.has_key?('rankingTableName'); raise ArgumentError.new(); end
|
102
|
+
if not request['rankingTableName']; raise ArgumentError.new(); end
|
103
|
+
query = {}
|
104
|
+
return get(
|
105
|
+
'Gs2Ranking',
|
106
|
+
'GetRankingTable',
|
107
|
+
@@ENDPOINT,
|
108
|
+
'/ranking/' + request['rankingTableName'],
|
109
|
+
query);
|
110
|
+
end
|
111
|
+
|
112
|
+
# ランキングテーブルを更新
|
113
|
+
#
|
114
|
+
# @param request [Array]
|
115
|
+
# * rankingTableName => ランキングテーブル名
|
116
|
+
# * description => 説明文
|
117
|
+
# @return [Array]
|
118
|
+
# * item
|
119
|
+
# * rankingTableId => ランキングテーブルID
|
120
|
+
# * ownerId => オーナーID
|
121
|
+
# * name => ランキングテーブル名
|
122
|
+
# * description => 説明文
|
123
|
+
# * createAt => 作成日時
|
124
|
+
# * updateAt => 更新日時
|
125
|
+
def update_ranking_table(request)
|
126
|
+
if not request; raise ArgumentError.new(); end
|
127
|
+
if not request.has_key?('rankingTableName'); raise ArgumentError.new(); end
|
128
|
+
if not request['rankingTableName']; raise ArgumentError.new(); end
|
129
|
+
body = {}
|
130
|
+
if request.has_key?('description'); body['description'] = request['description']; end
|
131
|
+
query = {}
|
132
|
+
return put(
|
133
|
+
'Gs2Ranking',
|
134
|
+
'UpdateRankingTable',
|
135
|
+
@@ENDPOINT,
|
136
|
+
'/ranking/' + request['rankingTableName'],
|
137
|
+
body,
|
138
|
+
query);
|
139
|
+
end
|
140
|
+
|
141
|
+
# ランキングテーブルを削除
|
142
|
+
#
|
143
|
+
# @param request [Array]
|
144
|
+
# * rankingTableName => ランキングテーブル名
|
145
|
+
def delete_ranking_table(request)
|
146
|
+
if not request; raise ArgumentError.new(); end
|
147
|
+
if not request.has_key?('rankingTableName'); raise ArgumentError.new(); end
|
148
|
+
if not request['rankingTableName']; raise ArgumentError.new(); end
|
149
|
+
query = {}
|
150
|
+
return delete(
|
151
|
+
'Gs2Ranking',
|
152
|
+
'DeleteRankingTable',
|
153
|
+
@@ENDPOINT,
|
154
|
+
'/ranking/' + request['rankingTableName'],
|
155
|
+
query);
|
156
|
+
end
|
157
|
+
|
158
|
+
# ゲームモードリストを取得
|
159
|
+
#
|
160
|
+
# @param request [Array]
|
161
|
+
# * rankingTableName => ランキングテーブル名
|
162
|
+
# @param pageToken [String] ページトークン
|
163
|
+
# @param limit [Integer] 取得件数
|
164
|
+
# @return [Array]
|
165
|
+
# * items
|
166
|
+
# [Array]
|
167
|
+
# * gameModeId => ゲームモードID
|
168
|
+
# * rankingTableId => ランキングテーブルID
|
169
|
+
# * gameMode => ゲームモード名
|
170
|
+
# * ownerId => オーナーID
|
171
|
+
# * asc => ソート方向
|
172
|
+
# * calcInterval => 集計間隔(分)
|
173
|
+
# * lastCalcAt => 最終集計日時
|
174
|
+
# * createAt => 作成日時
|
175
|
+
# * updateAt => 更新日時
|
176
|
+
# * nextPageToken => 次ページトークン
|
177
|
+
def describe_game_mode(request, pageToken = nil, limit = nil)
|
178
|
+
if not request; raise ArgumentError.new(); end
|
179
|
+
if not request.has_key?('rankingTableName'); raise ArgumentError.new(); end
|
180
|
+
if not request['rankingTableName']; raise ArgumentError.new(); end
|
181
|
+
query = {}
|
182
|
+
if pageToken; query['pageToken'] = pageToken; end
|
183
|
+
if limit; query['limit'] = limit; end
|
184
|
+
return get(
|
185
|
+
'Gs2Ranking',
|
186
|
+
'DescribeGameMode',
|
187
|
+
@@ENDPOINT,
|
188
|
+
'/ranking/' + request['rankingTableName'] + '/mode',
|
189
|
+
query);
|
190
|
+
end
|
191
|
+
|
192
|
+
# ゲームモードを作成<br>
|
193
|
+
# <br>
|
194
|
+
# ゲームモードを作成すると、ゲームモードの設定としてランキングが昇順なのか、降順なのかを設定できます。<br>
|
195
|
+
# レースゲームのようなタイムの値が小さいほど上位のランキングの場合は昇順を、<br>
|
196
|
+
# アクションゲームなどで、スコアの値が大きいほど上位のランキングの場合は降順を選択します。<br>
|
197
|
+
# <br>
|
198
|
+
# 他に、集計間隔を15分以上、24時間以下で分単位で設定できます。<br>
|
199
|
+
# ランキングを更新したい間隔に合わせて設定することになります。<br>
|
200
|
+
# 集計処理毎に費用が発生するため、高頻度であればあるほど利用料金は高くなります。<br>
|
201
|
+
#
|
202
|
+
# @param request [Array]
|
203
|
+
# * rankingTableName => ランキングテーブル名
|
204
|
+
# * gameMode => ゲームモード名
|
205
|
+
# * asc => ソート方向
|
206
|
+
# * calcInterval => 集計間隔(分)
|
207
|
+
# @return [Array]
|
208
|
+
# * item
|
209
|
+
# * gameModeId => ゲームモードID
|
210
|
+
# * rankingTableId => ランキングテーブルID
|
211
|
+
# * gameMode => ゲームモード名
|
212
|
+
# * ownerId => オーナーID
|
213
|
+
# * asc => ソート方向
|
214
|
+
# * calcInterval => 集計間隔(分)
|
215
|
+
# * lastCalcAt => 最終集計日時
|
216
|
+
# * createAt => 作成日時
|
217
|
+
# * updateAt => 更新日時
|
218
|
+
def create_game_mode(request)
|
219
|
+
if not request; raise ArgumentError.new(); end
|
220
|
+
if not request.has_key?('rankingTableName'); raise ArgumentError.new(); end
|
221
|
+
if not request['rankingTableName']; raise ArgumentError.new(); end
|
222
|
+
body = {}
|
223
|
+
if request.has_key?('gameMode'); body['gameMode'] = request['gameMode']; end
|
224
|
+
if request.has_key?('asc'); body['asc'] = request['asc']; end
|
225
|
+
if request.has_key?('calcInterval'); body['calcInterval'] = request['calcInterval']; end
|
226
|
+
query = {}
|
227
|
+
return post(
|
228
|
+
'Gs2Ranking',
|
229
|
+
'CreateGameMode',
|
230
|
+
@@ENDPOINT,
|
231
|
+
'/ranking/' + request['rankingTableName'] + '/mode',
|
232
|
+
body,
|
233
|
+
query);
|
234
|
+
end
|
235
|
+
|
236
|
+
# ゲームモードを取得
|
237
|
+
#
|
238
|
+
# @param request [Array]
|
239
|
+
# * rankingTableName => ランキングテーブル名
|
240
|
+
# * gameMode => ゲームモード名
|
241
|
+
# @return [Array]
|
242
|
+
# * item
|
243
|
+
# * gameModeId => ゲームモードID
|
244
|
+
# * rankingTableId => ランキングテーブルID
|
245
|
+
# * gameMode => ゲームモード名
|
246
|
+
# * ownerId => オーナーID
|
247
|
+
# * asc => ソート方向
|
248
|
+
# * calcInterval => 集計間隔(分)
|
249
|
+
# * lastCalcAt => 最終集計日時
|
250
|
+
# * createAt => 作成日時
|
251
|
+
# * updateAt => 更新日時
|
252
|
+
def get_game_mode(request)
|
253
|
+
if not request; raise ArgumentError.new(); end
|
254
|
+
if not request.has_key?('rankingTableName'); raise ArgumentError.new(); end
|
255
|
+
if not request['rankingTableName']; raise ArgumentError.new(); end
|
256
|
+
if not request.has_key?('gameMode'); raise ArgumentError.new(); end
|
257
|
+
if not request['gameMode']; raise ArgumentError.new(); end
|
258
|
+
query = {}
|
259
|
+
return get(
|
260
|
+
'Gs2Ranking',
|
261
|
+
'GetGameMode',
|
262
|
+
@@ENDPOINT,
|
263
|
+
'/ranking/' + request['rankingTableName'] + '/mode/' + request['gameMode'],
|
264
|
+
query);
|
265
|
+
end
|
266
|
+
|
267
|
+
# ゲームモードを更新
|
268
|
+
#
|
269
|
+
# @param request [Array]
|
270
|
+
# * rankingTableName => ランキングテーブル名
|
271
|
+
# * gameMode => ゲームモード名
|
272
|
+
# * calcInterval => 集計間隔(分)
|
273
|
+
# @return [Array]
|
274
|
+
# * item
|
275
|
+
# * gameModeId => ゲームモードID
|
276
|
+
# * rankingTableId => ランキングテーブルID
|
277
|
+
# * gameMode => ゲームモード名
|
278
|
+
# * ownerId => オーナーID
|
279
|
+
# * asc => ソート方向
|
280
|
+
# * calcInterval => 集計間隔(分)
|
281
|
+
# * lastCalcAt => 最終集計日時
|
282
|
+
# * createAt => 作成日時
|
283
|
+
# * updateAt => 更新日時
|
284
|
+
def update_game_mode(request)
|
285
|
+
if not request; raise ArgumentError.new(); end
|
286
|
+
if not request.has_key?('rankingTableName'); raise ArgumentError.new(); end
|
287
|
+
if not request['rankingTableName']; raise ArgumentError.new(); end
|
288
|
+
if not request.has_key?('gameMode'); raise ArgumentError.new(); end
|
289
|
+
if not request['gameMode']; raise ArgumentError.new(); end
|
290
|
+
body = {}
|
291
|
+
if request.has_key?('calcInterval'); body['calcInterval'] = request['calcInterval']; end
|
292
|
+
query = {}
|
293
|
+
return put(
|
294
|
+
'Gs2Ranking',
|
295
|
+
'UpdateGameMode',
|
296
|
+
@@ENDPOINT,
|
297
|
+
'/ranking/' + request['rankingTableName'] + '/mode/' + request['gameMode'],
|
298
|
+
body,
|
299
|
+
query);
|
300
|
+
end
|
301
|
+
|
302
|
+
# ゲームモードを削除
|
303
|
+
#
|
304
|
+
# @param request [Array]
|
305
|
+
# * rankingTableName => ランキングテーブル名
|
306
|
+
# * gameMode => ゲームモード名
|
307
|
+
def delete_game_mode(request)
|
308
|
+
if not request; raise ArgumentError.new(); end
|
309
|
+
if not request.has_key?('rankingTableName'); raise ArgumentError.new(); end
|
310
|
+
if not request['rankingTableName']; raise ArgumentError.new(); end
|
311
|
+
if not request.has_key?('gameMode'); raise ArgumentError.new(); end
|
312
|
+
if not request['gameMode']; raise ArgumentError.new(); end
|
313
|
+
query = {}
|
314
|
+
return delete(
|
315
|
+
'Gs2Ranking',
|
316
|
+
'DeleteGameMode',
|
317
|
+
@@ENDPOINT,
|
318
|
+
'/ranking/' + request['rankingTableName'] + '/mode/' + request['gameMode'],
|
319
|
+
query);
|
320
|
+
end
|
321
|
+
|
322
|
+
# ランキングを取得<br>
|
323
|
+
# <br>
|
324
|
+
# ランキングを取得します。<br>
|
325
|
+
# ランキングにはユーザID、スコア、メタデータといった基本情報のほかに、インデックスと順位が付加されています。<br>
|
326
|
+
# インデックスは先頭を1とした位置情報で、順位は同一スコアのユーザを同一順位として計算された値です。<br>
|
327
|
+
# ランキングの性質上、同一スコアでも別順位として扱いたい場合は順位の代わりにインデックスを利用することで実現できます。<br>
|
328
|
+
# <br>
|
329
|
+
# ランキングデータはランダムアクセスができますので、{#get_my_rank} で自分の順位を取得して、<br>
|
330
|
+
# その前後のランキンデータを取得する。というような処理も実現できます。<br>
|
331
|
+
#
|
332
|
+
# @param request [Array]
|
333
|
+
# * rankingTableName => ランキングテーブル名
|
334
|
+
# * gameMode => ゲームモード名
|
335
|
+
# @param offset [Integer] 取得開始オフセット
|
336
|
+
# @param limit [Integer] 取得件数
|
337
|
+
# @return [Array]
|
338
|
+
# * items
|
339
|
+
# [Array]
|
340
|
+
# * index => インデックス
|
341
|
+
# * rank => 順位
|
342
|
+
# * userId => ユーザID
|
343
|
+
# * score => スコア
|
344
|
+
# * meta => メタ情報
|
345
|
+
# * updateAt => 更新日時
|
346
|
+
# * nextPageToken => 次ページトークン
|
347
|
+
def get_ranking(request, offset = nil, limit = nil)
|
348
|
+
if not request; raise ArgumentError.new(); end
|
349
|
+
if not request.has_key?('rankingTableName'); raise ArgumentError.new(); end
|
350
|
+
if not request['rankingTableName']; raise ArgumentError.new(); end
|
351
|
+
if not request.has_key?('gameMode'); raise ArgumentError.new(); end
|
352
|
+
if not request['gameMode']; raise ArgumentError.new(); end
|
353
|
+
query = {}
|
354
|
+
if offset; query['offset'] = offset; end
|
355
|
+
if limit; query['limit'] = limit; end
|
356
|
+
return get(
|
357
|
+
'Gs2Ranking',
|
358
|
+
'GetRanking',
|
359
|
+
@@ENDPOINT,
|
360
|
+
'/ranking/' + request['rankingTableName'] + '/mode/' + request['gameMode'] + '/ranking',
|
361
|
+
query);
|
362
|
+
end
|
363
|
+
|
364
|
+
# スコアを登録<br>
|
365
|
+
# <br>
|
366
|
+
# スコアの登録は一時的にバッファリングされ、定期的にランキングデータとして書き込まれます。<br>
|
367
|
+
# そのため、スコア登録直後にランキング集計が開始された場合は、集計結果に含まれない可能性があります。<br>
|
368
|
+
# <br>
|
369
|
+
# accessToken には {http://static.docs.gs2.io/ruby/auth/Gs2/Auth/Client.html#login-instance_method Gs2::Auth::Client::login()} でログインして取得したアクセストークンを指定してください。<br>
|
370
|
+
#
|
371
|
+
# @param request [Array]
|
372
|
+
# * rankingTableName => ランキングテーブル名
|
373
|
+
# * gameMode => ゲームモード名
|
374
|
+
# * score => スコア
|
375
|
+
# * meta => メタ情報
|
376
|
+
# * accessToken => アクセストークン
|
377
|
+
# @return [Array]
|
378
|
+
# * item
|
379
|
+
# * rankingTableId => ランキングテーブルID
|
380
|
+
# * gameMode => ゲームモード名
|
381
|
+
# * userId => ユーザID
|
382
|
+
# * score => スコア
|
383
|
+
# * meta => メタ情報
|
384
|
+
# * updateAt => 更新日時
|
385
|
+
def put_score(request)
|
386
|
+
if not request; raise ArgumentError.new(); end
|
387
|
+
if not request.has_key?('rankingTableName'); raise ArgumentError.new(); end
|
388
|
+
if not request['rankingTableName']; raise ArgumentError.new(); end
|
389
|
+
if not request.has_key?('gameMode'); raise ArgumentError.new(); end
|
390
|
+
if not request['gameMode']; raise ArgumentError.new(); end
|
391
|
+
if not request.has_key?('accessToken'); raise ArgumentError.new(); end
|
392
|
+
if not request['accessToken']; raise ArgumentError.new(); end
|
393
|
+
body = {}
|
394
|
+
if request.has_key?('score'); body['score'] = request['score']; end
|
395
|
+
if request.has_key?('meta'); body['meta'] = request['meta']; end
|
396
|
+
header = {
|
397
|
+
'X-GS2-ACCESS-TOKEN' => request['accessToken']
|
398
|
+
}
|
399
|
+
query = {}
|
400
|
+
return post(
|
401
|
+
'Gs2Ranking',
|
402
|
+
'PutScore',
|
403
|
+
@@ENDPOINT,
|
404
|
+
'/ranking/' + request['rankingTableName'] + '/mode/' + request['gameMode'] + '/ranking',
|
405
|
+
body,
|
406
|
+
query,
|
407
|
+
header);
|
408
|
+
end
|
409
|
+
|
410
|
+
# 自分の順位を取得<br>
|
411
|
+
# <br>
|
412
|
+
# 自分の順位を取得できます、応答される値は集計時点での正確な値となります。<br>
|
413
|
+
# <br>
|
414
|
+
# accessToken には {http://static.docs.gs2.io/ruby/auth/Gs2/Auth/Client.html#login-instance_method Gs2::Auth::Client::login()} でログインして取得したアクセストークンを指定してください。<br>
|
415
|
+
#
|
416
|
+
# @param request [Array]
|
417
|
+
# * rankingTableName => ランキングテーブル名
|
418
|
+
# * gameMode => ゲームモード名
|
419
|
+
# * accessToken => アクセストークン
|
420
|
+
# @return [Array]
|
421
|
+
# * index => インデックス
|
422
|
+
# * rank => 順位
|
423
|
+
def get_my_rank(request)
|
424
|
+
if not request; raise ArgumentError.new(); end
|
425
|
+
if not request.has_key?('rankingTableName'); raise ArgumentError.new(); end
|
426
|
+
if not request['rankingTableName']; raise ArgumentError.new(); end
|
427
|
+
if not request.has_key?('gameMode'); raise ArgumentError.new(); end
|
428
|
+
if not request['gameMode']; raise ArgumentError.new(); end
|
429
|
+
if not request.has_key?('accessToken'); raise ArgumentError.new(); end
|
430
|
+
if not request['accessToken']; raise ArgumentError.new(); end
|
431
|
+
header = {
|
432
|
+
'X-GS2-ACCESS-TOKEN' => request['accessToken']
|
433
|
+
}
|
434
|
+
query = {}
|
435
|
+
return get(
|
436
|
+
'Gs2Ranking',
|
437
|
+
'GetMyRank',
|
438
|
+
@@ENDPOINT,
|
439
|
+
'/ranking/' + request['rankingTableName'] + '/mode/' + request['gameMode'] + '/ranking/rank',
|
440
|
+
query,
|
441
|
+
header);
|
442
|
+
end
|
443
|
+
|
444
|
+
# スコアを指定しておおよその順位を取得<br>
|
445
|
+
# <br>
|
446
|
+
# 指定したスコアを取ったと仮定して何位ぐらいになれるのか、といった指標を計算する際に利用します。<br>
|
447
|
+
# 原則1000位単位でおおよその順位を応答します。<br>
|
448
|
+
# <br>
|
449
|
+
# 上位プレイヤーに対しては1000位単位の解像度では情報が不足している場合があると思いますので、<br>
|
450
|
+
# 応答が上位プレイヤーだった場合は、更に {#get_ranking} で上位のスコアを取得して<br>
|
451
|
+
# さらに詳細な順位に絞り込んで情報提供する。というのもユーザ体験をよく出来ると思います。<br>
|
452
|
+
#
|
453
|
+
# @param request [Array]
|
454
|
+
# * rankingTableName => ランキングテーブル名
|
455
|
+
# * gameMode => ゲームモード名
|
456
|
+
# * score => スコア
|
457
|
+
# @return [Array]
|
458
|
+
# * min => おおよその順位の最小値
|
459
|
+
# * max => おおよその順位の最大値
|
460
|
+
def get_estimate_rank(request)
|
461
|
+
if not request; raise ArgumentError.new(); end
|
462
|
+
if not request.has_key?('rankingTableName'); raise ArgumentError.new(); end
|
463
|
+
if not request['rankingTableName']; raise ArgumentError.new(); end
|
464
|
+
if not request.has_key?('gameMode'); raise ArgumentError.new(); end
|
465
|
+
if not request['gameMode']; raise ArgumentError.new(); end
|
466
|
+
query = {}
|
467
|
+
if request.has_key?('score'); query['score'] = request['score']; end
|
468
|
+
return get(
|
469
|
+
'Gs2Ranking',
|
470
|
+
'GetEstimateRank',
|
471
|
+
@@ENDPOINT,
|
472
|
+
'/ranking/' + request['rankingTableName'] + '/mode/' + request['gameMode'] + '/ranking/estimate',
|
473
|
+
query);
|
474
|
+
end
|
475
|
+
end
|
476
|
+
end end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gs2-ruby-sdk-ranking
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Game Server Services, Inc.
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gs2-ruby-sdk-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: gs2-ruby-sdk-auth
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- contact@gs2.io
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".buildpath"
|
77
|
+
- ".gitignore"
|
78
|
+
- ".project"
|
79
|
+
- Gemfile
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/console
|
83
|
+
- bin/setup
|
84
|
+
- gs2-ruby-sdk-ranking.gemspec
|
85
|
+
- lib/gs2-ranking.rb
|
86
|
+
- lib/gs2/ranking/Client.rb
|
87
|
+
- lib/gs2/ranking/version.rb
|
88
|
+
homepage: https://gs2.io/
|
89
|
+
licenses:
|
90
|
+
- Apache-2.0
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.5.1
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Game Server Services GS2-Ranking Client Library
|
112
|
+
test_files: []
|