battlesnake 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -0
- data/Gemfile.lock +1 -1
- data/docs/Battlesnake/Base.html +251 -0
- data/docs/Battlesnake/Board.html +1217 -0
- data/docs/Battlesnake/Error.html +1 -1
- data/docs/Battlesnake/Game.html +813 -0
- data/docs/Battlesnake/Location.html +15 -2
- data/docs/Battlesnake/Snake.html +15 -2
- data/docs/Battlesnake.html +4 -4
- data/docs/_index.html +30 -1
- data/docs/class_list.html +1 -1
- data/docs/file.README.html +2 -2
- data/docs/index.html +2 -2
- data/docs/method_list.html +164 -12
- data/docs/top-level-namespace.html +1 -1
- data/lib/battlesnake/base.rb +15 -0
- data/lib/battlesnake/board.rb +89 -0
- data/lib/battlesnake/game.rb +44 -0
- data/lib/battlesnake/location.rb +1 -1
- data/lib/battlesnake/snake.rb +1 -1
- data/lib/battlesnake/version.rb +1 -1
- data/lib/battlesnake.rb +3 -0
- metadata +8 -2
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Battlesnake
|
4
|
+
##
|
5
|
+
# Represents a Battlesnake game.
|
6
|
+
class Game < Base
|
7
|
+
# @return [Hash] snake as a data structure usable by other objects.
|
8
|
+
attr_reader :as_json
|
9
|
+
|
10
|
+
# @return [String] unique identifier for this game.
|
11
|
+
attr_reader :id
|
12
|
+
|
13
|
+
# @return [Hash] information about the ruleset being used to run this game.
|
14
|
+
attr_reader :ruleset
|
15
|
+
|
16
|
+
# @return [String] name of the map used to populate the game board with snakes, food, and hazards.
|
17
|
+
attr_reader :map
|
18
|
+
|
19
|
+
# @return [Integer] how much time player APIs have to respond to requests for this game.
|
20
|
+
attr_reader :timeout
|
21
|
+
|
22
|
+
# @return [String] source of this game.
|
23
|
+
attr_reader :source
|
24
|
+
|
25
|
+
##
|
26
|
+
# Returns a new instance of Game.
|
27
|
+
#
|
28
|
+
# @param json_or_hash [String,Hash] can be a hash of attributes, or a JSON string which
|
29
|
+
# represents such a structure.
|
30
|
+
#
|
31
|
+
# @return [Game]
|
32
|
+
def initialize(json_or_hash)
|
33
|
+
data = json_or_hash.is_a?(String) ? JSON.parse(json_or_hash) : json_or_hash
|
34
|
+
|
35
|
+
@as_json = data
|
36
|
+
|
37
|
+
@id = data['id']
|
38
|
+
@ruleset = data['ruleset']
|
39
|
+
@map = data['map']
|
40
|
+
@timeout = data['timeout']
|
41
|
+
@source = data['source']
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/battlesnake/location.rb
CHANGED
@@ -4,7 +4,7 @@ module Battlesnake
|
|
4
4
|
##
|
5
5
|
# Represents a pair of (x,y) coordinates, and provides helper methods
|
6
6
|
# for managing distance and direction.
|
7
|
-
class Location
|
7
|
+
class Location < Base
|
8
8
|
# @return [Integer] a positive integer representing the distance from the
|
9
9
|
# left side of the board.
|
10
10
|
attr_reader :x
|
data/lib/battlesnake/snake.rb
CHANGED
data/lib/battlesnake/version.rb
CHANGED
data/lib/battlesnake.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: battlesnake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jaime Bellmyer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -100,7 +100,10 @@ files:
|
|
100
100
|
- bin/console
|
101
101
|
- bin/setup
|
102
102
|
- docs/Battlesnake.html
|
103
|
+
- docs/Battlesnake/Base.html
|
104
|
+
- docs/Battlesnake/Board.html
|
103
105
|
- docs/Battlesnake/Error.html
|
106
|
+
- docs/Battlesnake/Game.html
|
104
107
|
- docs/Battlesnake/Location.html
|
105
108
|
- docs/Battlesnake/Snake.html
|
106
109
|
- docs/_index.html
|
@@ -118,6 +121,9 @@ files:
|
|
118
121
|
- docs/method_list.html
|
119
122
|
- docs/top-level-namespace.html
|
120
123
|
- lib/battlesnake.rb
|
124
|
+
- lib/battlesnake/base.rb
|
125
|
+
- lib/battlesnake/board.rb
|
126
|
+
- lib/battlesnake/game.rb
|
121
127
|
- lib/battlesnake/location.rb
|
122
128
|
- lib/battlesnake/snake.rb
|
123
129
|
- lib/battlesnake/version.rb
|