gameworks 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10a8ee8b5768eec3e315cf623d160995d9b321c7
4
- data.tar.gz: 12daacb5259d91a5b299c1289c2ebfc77981a46c
3
+ metadata.gz: 01d5ecb9664001e09d3f01c6c77d9a12f9547576
4
+ data.tar.gz: 9f62c669b47d6259e171ed8ad064dc472dfb40fa
5
5
  SHA512:
6
- metadata.gz: b606bae8289aef66caf94c308b27a94cfeb02f1bb999d4a8e91b93cea38061cee95be9b3a880a368f25526a054a7c5efae6147847a726f01735a122bd67eff17
7
- data.tar.gz: 41cb36e64d04fb488324834bdba461a2eda9de821b8d3fe8b0dc8d847143d27881bfdfc669ed615a7c06446eede468827a1afe7ecfc027ee0e33b7b2cb7697a0
6
+ metadata.gz: 659f986391dbd3b06b6bec347bdca19594faa67449e09b330d7035694a62ecf0c1766400ef4e9e7bed5819a71a34a4277544f54d19c7e8f9cc05260204dc3050
7
+ data.tar.gz: 395bad2789fcbe1590770df68eeee522341bd12ecf2515b43ae1f3cc511f0a14d9d21fdcadb0ce686f1baec99196b60d51e8a2ed79b68687f20c77e012703c4a
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gameworks (1.0.1)
4
+ gameworks (2.1.0)
5
5
  eventmachine (~> 1.0, >= 1.0.7)
6
6
  json (~> 1.8, >= 1.8.3)
7
7
  rake (~> 10.0)
@@ -12,7 +12,7 @@ GEM
12
12
  specs:
13
13
  daemons (1.2.3)
14
14
  diff-lcs (1.2.5)
15
- eventmachine (1.0.7)
15
+ eventmachine (1.0.8)
16
16
  json (1.8.3)
17
17
  rack (1.6.4)
18
18
  rake (10.4.2)
@@ -20,15 +20,15 @@ GEM
20
20
  rspec-core (~> 3.3.0)
21
21
  rspec-expectations (~> 3.3.0)
22
22
  rspec-mocks (~> 3.3.0)
23
- rspec-core (3.3.1)
23
+ rspec-core (3.3.2)
24
24
  rspec-support (~> 3.3.0)
25
25
  rspec-eventmachine (0.2.0)
26
26
  eventmachine (>= 0.12.0)
27
27
  rspec (>= 2.0, < 4.0)
28
- rspec-expectations (3.3.0)
28
+ rspec-expectations (3.3.1)
29
29
  diff-lcs (>= 1.2.0, < 2.0)
30
30
  rspec-support (~> 3.3.0)
31
- rspec-mocks (3.3.1)
31
+ rspec-mocks (3.3.2)
32
32
  diff-lcs (>= 1.2.0, < 2.0)
33
33
  rspec-support (~> 3.3.0)
34
34
  rspec-support (3.3.0)
@@ -47,4 +47,4 @@ DEPENDENCIES
47
47
  rspec-eventmachine (~> 0.2)
48
48
 
49
49
  BUNDLED WITH
50
- 1.10.5
50
+ 1.10.6
@@ -1,48 +1,119 @@
1
- = Quick start server
1
+ # Gameworks
2
2
 
3
- Install required gems and run server:
4
- bundle install
5
- bundle exec thin start
3
+ ## About
6
4
 
7
- To run specs:
8
- bundle exec spec spec
5
+ Gameworks is a framework for creating turn-based games hosted by a server, that
6
+ can be interacted with via an API. At Instructure, we use it to create games
7
+ for the final round of our coding competition: Mebipenny.
9
8
 
10
- (You will probably already have the gems installed so you probably don't need the 'bundle exec')
11
- All request and response payloads are serialized JSON data.
9
+ ## Installation
12
10
 
13
- = DATA TYPES
11
+ Add `gem 'gameworks'` to your Gemfile, or install manually with `gem install gameworks`
14
12
 
15
- == New Player (request)
13
+ ## Usage
16
14
 
17
- {name: <string>}
15
+ You will create classes to extend this engine, and then be able to interact
16
+ with the game via an API. Let's go over how all that works.
17
+
18
+ ### Implementation
19
+
20
+ At minimum, you'll need a 3 files, that will look something like the following:
21
+
22
+ `config.ru`:
23
+ ```ruby
24
+ #!ruby
25
+
26
+ require_relative 'your_game/server'
27
+ use Rack::CommonLogger
28
+
29
+ # Override Lint middleware to handle async callback (-1 http response)
30
+ module Rack
31
+ class Lint
32
+ def call(env = nil)
33
+ @app.call(env)
34
+ end
35
+ end
36
+ end
37
+
38
+ run YourGame::Server.new
39
+ ```
40
+
41
+ `your_game/server.rb`:
42
+ ```ruby
43
+ require 'gameworks'
44
+ require_relative 'game'
45
+
46
+ module YourGame
47
+ class Server < Gameworks::Server
48
+ def game_class
49
+ YourGame::Game
50
+ end
51
+ end
52
+ end
53
+ ```
54
+
55
+ `your_game/game.rb`:
56
+ ```ruby
57
+ require 'gameworks'
58
+
59
+ module YourGame
60
+ class Game < Gameworks::Game
61
+ # you're reached player capacity
62
+ def full?
63
+ end
64
+
65
+ # an array of players currently taking a turn
66
+ def active_players
67
+ end
68
+
69
+ # given a json payload, create a move object
70
+ def build_move(payload, player)
71
+ end
72
+
73
+ # given a move object, is it legal
74
+ def move_legal?(move, player)
75
+ end
18
76
 
19
- name of the new player. the game engine may extend this.
77
+ # given a lecal move, apply it
78
+ def process_move(move, player)
79
+ end
80
+ end
81
+ end
82
+ ```
20
83
 
21
- == Player (response)
84
+ ### API Data Types
22
85
 
86
+ The following are the default request/response data. You game implementation
87
+ may extend any/all of these.
88
+
89
+ #### New Player (request)
90
+
91
+ ```
92
+ {name: <string>}
93
+ ```
94
+
95
+ #### Player (response)
96
+
97
+ ```
23
98
  {name: <string>,
24
99
  score: <integer>,
25
100
  disqualified: <boolean>}
101
+ ```
26
102
 
27
- name, current score, and disqualified status of the player. the game engine may
28
- extend this.
29
-
30
- == New Game (request)
103
+ #### New Game (request)
31
104
 
32
- determined by the game engine
105
+ Nothing by default, determined by your game implementation.
33
106
 
34
- == Game (response)
107
+ #### Game (response)
35
108
 
109
+ ```
36
110
  {players: [<Player>*],
37
111
  state: <Game State>}
112
+ ```
38
113
 
39
114
  players is the set of Players joined to the game.
40
115
 
41
- state is the current Game State.
42
-
43
- the game engine may extend this.
44
-
45
- == Game Delta (response)
116
+ #### Game Delta (response)
46
117
 
47
118
  {players: [<Player>*],
48
119
  state: <Game State>}
@@ -50,29 +121,27 @@ the game engine may extend this.
50
121
  players is the set of Players whose scores have changed since the request
51
122
  began.
52
123
 
53
- state is the current Game State.
54
-
55
- the game engine may extend this.
56
-
57
- == Game State (response)
124
+ #### Game State (response)
58
125
 
59
126
  'initiating', 'in play', or 'completed'
60
127
 
61
128
  See descriptions of game states below.
62
129
 
63
- == New Move (request)
130
+ #### New Move (request)
64
131
 
65
- determined by the game engine.
132
+ Nothing by default, determined by your game implementation.
66
133
 
67
- = STARTING A GAME
134
+ ### Using the API
135
+
136
+ #### Starting a Game
68
137
 
69
138
  To spawn a new game on the server, POST to / with a New Game object as payload.
70
139
  You will receive a 201 Created response with the game's root path (henceforth
71
140
  <game path>) in the Location HTTP response header.
72
141
 
73
- = GAME STATES
142
+ #### Game States
74
143
 
75
- == INITIATING
144
+ ##### Initiating
76
145
 
77
146
  The game begins in this state. You join a game by POSTing to
78
147
  <game path>/players with a Player object as payload.
@@ -87,7 +156,7 @@ longer be joined.
87
156
 
88
157
  Once the game is full the game moves to the in play state.
89
158
 
90
- == IN PLAY
159
+ ##### In Play
91
160
 
92
161
  In this state, players POST to <game path>/moves with Line objects as payload.
93
162
  These requests must include an X-Turn-Token HTTP request header with the value
@@ -110,17 +179,17 @@ After a 200 OK response, the game may have moved to the completed state. This
110
179
  state change will be indicated in the Game Delta object. Once the game is
111
180
  completed, further moves are ignored with a 410 Gone response.
112
181
 
113
- == COMPLETED
182
+ ##### Completed
114
183
 
115
184
  Play is complete. Game state can still be pulled, but no new POSTs are
116
185
  accepted.
117
186
 
118
- = IDEMPOTENT VIEW
187
+ #### Idempotent View
119
188
 
120
189
  At any point, the full game state can be requested with a GET request to
121
190
  <game path>. You will receive an immediate 200 OK response with a Game object.
122
191
 
123
- = OBSERVERS
192
+ #### Observers (v1)
124
193
 
125
194
  (Intended for use by game viewer, but may be used by others.)
126
195
 
@@ -142,7 +211,11 @@ replacing the first %s. For instance, a HTML comet technique:
142
211
 
143
212
  { "wrapper": "<script type='text/javascript'>myUpdater(%s);</script>\n" }
144
213
 
145
- = MATCHMAKING
214
+ #### Observers (v2)
215
+
216
+ TODO: notes about push
217
+
218
+ #### Matchmaking
146
219
 
147
220
  When you have a bot you'd like to try against others, but you don't want to set
148
221
  up a game yourself and you don't care who your opponent is, you can connect
@@ -11,11 +11,12 @@ module Gameworks
11
11
 
12
12
  uri = URI(build_url(game))
13
13
  req = Net::HTTP::Post.new(uri)
14
+ ssl = uri.scheme == 'https'
14
15
 
15
16
  req.basic_auth(key, secret)
16
17
  req.body = body
17
18
  req["Content-Type"] = "application/json"
18
- Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
19
+ Net::HTTP.start(uri.hostname, uri.port, use_ssl: ssl) do |http|
19
20
  http.request(req)
20
21
  end
21
22
  end
@@ -1,3 +1,3 @@
1
1
  module Gameworks
2
- VERSION = "2.1.0"
2
+ VERSION = "2.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gameworks
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Palmer
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-07-14 00:00:00.000000000 Z
15
+ date: 2015-09-17 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rake
@@ -150,11 +150,10 @@ extra_rdoc_files: []
150
150
  files:
151
151
  - Gemfile
152
152
  - Gemfile.lock
153
- - README
153
+ - README.md
154
154
  - Rakefile
155
155
  - bin/console
156
156
  - bin/setup
157
- - build.sh
158
157
  - gameworks.gemspec
159
158
  - lib/gameworks.rb
160
159
  - lib/gameworks/fuse.rb
@@ -192,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
191
  version: '0'
193
192
  requirements: []
194
193
  rubyforge_project:
195
- rubygems_version: 2.4.6
194
+ rubygems_version: 2.4.7
196
195
  signing_key:
197
196
  specification_version: 4
198
197
  summary: A game framework
data/build.sh DELETED
@@ -1,8 +0,0 @@
1
- #! /bin/bash
2
- . ~/.bash_profile
3
- export COVERAGE=1
4
- rvm use ruby-2.1.5 2>/dev/null || :
5
-
6
- gem install bundler
7
- bundle install
8
- bundle exec rspec