civility 1 → 2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/civility +1 -1
- data/lib/civility.rb +19 -11
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b0f74580880b0d37770465bf37e82dc32218f26
|
4
|
+
data.tar.gz: da8899ef0175eb9a1baf87abb25ac9478f95b4c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2ac60210ac526e0366b8065fb6dbdf903cabb490a52a7b8572e7f776147faf0aac6c29db0eaa04fc0f966ed6a19e5cf2244ddd0de768d0604dd77f7eca95844
|
7
|
+
data.tar.gz: ea43b7945ecbbdfe43b27f90bb5994a2d99af93709741dc63545bb3e96b4496f53d5e833551f30dd8edea083348f9d32e86955874f058f026214f03b6dbaf1c2
|
data/bin/civility
CHANGED
data/lib/civility.rb
CHANGED
@@ -5,7 +5,7 @@ require 'yaml'
|
|
5
5
|
require 'thor'
|
6
6
|
|
7
7
|
class Civility < Thor
|
8
|
-
VERSION = '
|
8
|
+
VERSION = '2'
|
9
9
|
SAVE_DIRECTORY = "/Documents/Aspyr/Sid\ Meier\'s\ Civilization\ 5/Saves/hotseat/"
|
10
10
|
FILE_PREFIX = 'civility'
|
11
11
|
FILE_EXT = 'Civ5Save'
|
@@ -35,27 +35,28 @@ class Civility < Thor
|
|
35
35
|
desc "games", "List your current games"
|
36
36
|
def games
|
37
37
|
return missing_auth_error unless auth_key
|
38
|
-
|
39
|
-
|
40
|
-
output_games(response['Games'])
|
41
|
-
self.config = @config.merge(games: response['Games'], updated_at: Time.now.to_i)
|
38
|
+
games = api_games
|
39
|
+
output_games(games)
|
42
40
|
end
|
43
41
|
|
44
42
|
desc 'play', 'Download a game to play'
|
45
|
-
def play(name)
|
43
|
+
def play(*name)
|
44
|
+
name = name.join(' ')
|
46
45
|
return missing_auth_error unless auth_key
|
47
46
|
game = game_by_name(name)
|
48
|
-
return missing_game_error unless game
|
47
|
+
return missing_game_error(name) unless game
|
49
48
|
path = game_path(game)
|
50
49
|
file('GetLatestSaveFileBytes', {authKey: auth_key, gameID: game['GameId']}, path)
|
51
50
|
puts "Saved #{game['Name']} to #{path}"
|
51
|
+
api_games
|
52
52
|
end
|
53
53
|
|
54
54
|
desc 'complete', 'Upload a completed turn'
|
55
|
-
def complete(name)
|
55
|
+
def complete(*name)
|
56
|
+
name = name.join(' ')
|
56
57
|
return missing_auth_error unless auth_key
|
57
58
|
game = game_by_name(name)
|
58
|
-
return missing_game_error unless game
|
59
|
+
return missing_game_error(name) unless game
|
59
60
|
path = game_path(game)
|
60
61
|
response = upload_file('SubmitTurn', {authKey: auth_key, turnId: game['CurrentTurn']['TurnId']}, path)
|
61
62
|
response = JSON.parse(response)
|
@@ -75,6 +76,13 @@ class Civility < Thor
|
|
75
76
|
|
76
77
|
private
|
77
78
|
|
79
|
+
def api_games
|
80
|
+
response = get('GetGamesAndPlayers', {authKey: auth_key, playerIDText: user_id})
|
81
|
+
response = JSON.parse(response)
|
82
|
+
self.config = @config.merge(games: response['Games'], updated_at: Time.now.to_i)
|
83
|
+
response['Games']
|
84
|
+
end
|
85
|
+
|
78
86
|
def game_path(game)
|
79
87
|
"#{Dir.home}#{SAVE_DIRECTORY}#{FILE_PREFIX}-#{normalize(game['Name'])}-#{game['GameId']}.#{FILE_EXT}"
|
80
88
|
end
|
@@ -171,8 +179,8 @@ class Civility < Thor
|
|
171
179
|
"Unable to parse response\nCode: #{response.code}\nBody: #{response.body}"
|
172
180
|
end
|
173
181
|
|
174
|
-
def missing_game_error
|
175
|
-
puts
|
182
|
+
def missing_game_error(name)
|
183
|
+
puts "Unable to find the game #{name}"
|
176
184
|
end
|
177
185
|
|
178
186
|
def missing_auth_error
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: civility
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
4
|
+
version: '2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abraham Williams
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: Civility is the easiest way to manage your Civ5 hotseat games hosted
|
28
42
|
on Giant Multiplayer Robot
|
29
43
|
email: abraham@abrah.am
|