lacuna 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lacuna.rb +4 -4
- data/lib/lacuna/extras/archaeology.rb +2 -2
- data/lib/lacuna/extras/buildings.rb +0 -1
- data/lib/lacuna/extras/empire.rb +2 -2
- data/lib/lacuna/version.rb +1 -1
- data/lib/lacuna_util.rb +40 -0
- data/lib/lacuna_util/task.rb +22 -0
- data/lib/lacuna_util/task/clean_mail.rb +52 -0
- data/lib/lacuna_util/task/make_halls.rb +52 -0
- data/lib/lacuna_util/version.rb +5 -0
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7744b49ad3b708412b1365117c6e3419f89031c
|
4
|
+
data.tar.gz: 5580bb3b12b46fe172fa0ec8c0013c64d5e41c16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab8eb2e426b969c889dae72652bf557a8e1d7b8bbc3e560a1026dd175d73a0425989d4e189ee60f3042f63db034ef5f008f7c9d5c88f65eb896c69225b590930
|
7
|
+
data.tar.gz: 5afdec1415459bbd0ab87020681e676a061cafec511a8185c1ae8581b190e0a19242718074e2f2ba5ad592167ed493c0da081320b5cb30606a0f8f94a0caebbc
|
data/lib/lacuna.rb
CHANGED
@@ -79,10 +79,6 @@ module Lacuna
|
|
79
79
|
@module_name = 'captcha'
|
80
80
|
end
|
81
81
|
|
82
|
-
class Archaeology < Lacuna::Extras::Archaeology
|
83
|
-
@module_name = 'archaeology'
|
84
|
-
end
|
85
|
-
|
86
82
|
# Note: this has no support for building specific extras. I guess we could
|
87
83
|
# just define them manually?
|
88
84
|
Lacuna::Buildings.types.each do |name|
|
@@ -93,4 +89,8 @@ module Lacuna
|
|
93
89
|
end
|
94
90
|
ENDOFDEFINITION
|
95
91
|
end
|
92
|
+
|
93
|
+
class Archaeology < Lacuna::Extras::Archaeology
|
94
|
+
@module_name = 'archaeology'
|
95
|
+
end
|
96
96
|
end
|
data/lib/lacuna/extras/empire.rb
CHANGED
@@ -4,8 +4,8 @@ module Lacuna
|
|
4
4
|
class Extras
|
5
5
|
class Empire < Lacuna::Module
|
6
6
|
def self.planets
|
7
|
-
planets = Lacuna::Empire.get_status['
|
8
|
-
planets.select { |
|
7
|
+
planets = Lacuna::Empire.get_status['empire']['planets']
|
8
|
+
planets.select { |id, name| !name.match /^(S|Z)ASS/ }
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
data/lib/lacuna/version.rb
CHANGED
data/lib/lacuna_util.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.dirname __FILE__
|
4
|
+
|
5
|
+
require 'require_all'
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
require 'lacuna_util/version'
|
9
|
+
|
10
|
+
class LacunaUtil
|
11
|
+
@@tasks = {}
|
12
|
+
@@config = {}
|
13
|
+
|
14
|
+
def self.config
|
15
|
+
@@config
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.config=(obj)
|
19
|
+
@@config = obj
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.register_task(task_class)
|
23
|
+
@@tasks[task_class.to_s] = task_class
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.task(name)
|
27
|
+
@@tasks[name]
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.has_task?(tname)
|
31
|
+
!@@tasks[tname].nil?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# LOAD ALL THE CONFIGURATION OPTIONS!
|
36
|
+
path = File.join(File.dirname(__FILE__), '..', 'config.json')
|
37
|
+
LacunaUtil.config = JSON.parse File.read path
|
38
|
+
|
39
|
+
# Load all the tasks
|
40
|
+
require_all File.join(File.dirname(__FILE__), 'lacuna_util', 'task')
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'lacuna'
|
4
|
+
|
5
|
+
class LacunaUtil
|
6
|
+
class Task
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
Lacuna.connect({
|
10
|
+
:name => LacunaUtil.config['name'],
|
11
|
+
:password => LacunaUtil.config['password'],
|
12
|
+
:server_name => LacunaUtil.config['server_name'] || 'us1',
|
13
|
+
})
|
14
|
+
end
|
15
|
+
|
16
|
+
def run
|
17
|
+
task_name = self.class
|
18
|
+
name = LacunaUtil.config['name']
|
19
|
+
puts "Running task #{task_name} as #{name}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'lacuna_util/task'
|
4
|
+
|
5
|
+
class CleanMail < LacunaUtil::Task
|
6
|
+
def run
|
7
|
+
super
|
8
|
+
|
9
|
+
status = Lacuna::Empire.get_status
|
10
|
+
|
11
|
+
if status['empire']['has_new_messages'].to_i == 0
|
12
|
+
puts "No messages to delete! You're all clear!"
|
13
|
+
return
|
14
|
+
end
|
15
|
+
|
16
|
+
# Array of message ids representing messages needing to be trashed.
|
17
|
+
to_trash = []
|
18
|
+
|
19
|
+
page = 1
|
20
|
+
seen = 0
|
21
|
+
tags = ['Parliament', 'Probe']
|
22
|
+
|
23
|
+
# Isolationists are not affected by Fissures.
|
24
|
+
tags << 'Fissure' if status['empire']['is_isolationist'].to_i > 0
|
25
|
+
|
26
|
+
while true
|
27
|
+
puts "Checking page #{page}"
|
28
|
+
|
29
|
+
inbox = Lacuna::Inbox.view_inbox({
|
30
|
+
:tags => tags,
|
31
|
+
:page_number => page,
|
32
|
+
})
|
33
|
+
|
34
|
+
inbox['messages'].each do |message|
|
35
|
+
seen += 1
|
36
|
+
to_trash << message['id']
|
37
|
+
end
|
38
|
+
|
39
|
+
# Check if this is the last page.
|
40
|
+
if inbox['message_count'].to_i == seen
|
41
|
+
break
|
42
|
+
else
|
43
|
+
page += 1
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
puts "Trashing #{to_trash.size} messages... hang on tight, kid!"
|
48
|
+
Lacuna::Inbox.trash_messages to_trash
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
LacunaUtil.register_task CleanMail
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'lacuna_util/task'
|
4
|
+
|
5
|
+
class MakeHalls < LacunaUtil::Task
|
6
|
+
# Array of the 4 recipes used to make Halls of Vrbansk
|
7
|
+
RECIPES = [
|
8
|
+
%w( goethite halite gypsum trona ),
|
9
|
+
%w( gold anthracite uraninite bauxite ),
|
10
|
+
%w( kerogen methane sulfur zircon ),
|
11
|
+
%w( monazite fluorite beryl magnetite ),
|
12
|
+
%w( rutile chromite chalcopyrite galena ),
|
13
|
+
]
|
14
|
+
|
15
|
+
def run
|
16
|
+
super
|
17
|
+
|
18
|
+
Lacuna::Empire.planets.each do |id, name|
|
19
|
+
puts "Checking on #{name}"
|
20
|
+
buildings = Lacuna::Body.get_buildings(id)['buildings']
|
21
|
+
archaeology = Lacuna::Body.find_building(buildings, 'Archaeology Ministry')
|
22
|
+
inventory = Lacuna::Archaeology.get_inventory(archaeology['id'])
|
23
|
+
|
24
|
+
made = 0
|
25
|
+
|
26
|
+
RECIPES.each do |recipe|
|
27
|
+
numbers = recipe.collect { |item| inventory[item] || 0 }
|
28
|
+
number = numbers.sort.first
|
29
|
+
list = recipe.map { |item| item.capitalize }.join ', '
|
30
|
+
|
31
|
+
next if number == 0
|
32
|
+
|
33
|
+
puts "Making #{number} halls with #{list}"
|
34
|
+
|
35
|
+
# Note: there is a limit of 5000 plans made per request.
|
36
|
+
# I'll fix this 'issue' when it actually becomes one. :)
|
37
|
+
# For the moment just run the script as many times as you
|
38
|
+
# need to make all the halls.
|
39
|
+
rs = Lacuna::Archaeology.assemble_glyphs(archaeology['id'], recipe, number)
|
40
|
+
made += rs['quantity']
|
41
|
+
end
|
42
|
+
|
43
|
+
if made > 0
|
44
|
+
puts "Successfully made #{made} Halls of Vrbansk"
|
45
|
+
else
|
46
|
+
puts "Didn't make any halls! :("
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
LacunaUtil.register_task MakeHalls
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lacuna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan McCallum
|
@@ -30,6 +30,11 @@ files:
|
|
30
30
|
- lib/lacuna/module.rb
|
31
31
|
- lib/lacuna/session.rb
|
32
32
|
- lib/lacuna/version.rb
|
33
|
+
- lib/lacuna_util.rb
|
34
|
+
- lib/lacuna_util/task.rb
|
35
|
+
- lib/lacuna_util/task/clean_mail.rb
|
36
|
+
- lib/lacuna_util/task/make_halls.rb
|
37
|
+
- lib/lacuna_util/version.rb
|
33
38
|
homepage: http://rubygems.org/gems/lacuna
|
34
39
|
licenses:
|
35
40
|
- MIT
|