tt2 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4a428227ce35f912c281e7ac78f5bb40d8b1bceb
4
+ data.tar.gz: 7278b6126c0e732a29a9779578930c3bd1da6225
5
+ SHA512:
6
+ metadata.gz: e71965509cc0692b09833ba53c902e0b39f836072e6af0b039bf3e43e9bf19d9c7dbc1b6618fb75b6d56720a4caf3ef2c9ac9c9c3ab975aaaa4c7d8a9547025a
7
+ data.tar.gz: aa4bbf9ffa8b8a8d9bf6ce59f625805bc85111dbe6e6deee11fcbc6b153e448b3eacbc44919b4075b8fa4191e2ae5a7389ca8704026f7490c222f66c7b8c1362
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Steve Whittaker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ #
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem ''
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/exe/tt2 ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'tt2'
5
+ require 'tty'
6
+
7
+ prompt = TTY::Prompt.new
8
+ prompt.yes?('Would you like to create an account?')
data/lib/tt2.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'tt2/version'
2
+ require 'tt2/util'
3
+ require 'tt2/save_parser'
4
+
5
+ # Tap Titans 2 (TT2) is an incremental/clicker game made by Game Hive Games of
6
+ # Toronto, Canada.
7
+ module TT2
8
+ end
data/lib/tt2/client.rb ADDED
@@ -0,0 +1,31 @@
1
+ require 'httparty'
2
+ module TT2
3
+ # The TT2 API client
4
+ class Client
5
+ include HTTParty
6
+
7
+ base_uri 'https://tt2.gamehivegames.com'
8
+ headers 'Accept' => 'application/vnd.gamehive.btb4-v1.0+json',
9
+ 'User-Agent' => 'BestHTTP',
10
+ 'Content-Type' => 'application/json; charset=UTF-8'
11
+
12
+ def query_options(data = '')
13
+ { d: 'ios',
14
+ v: '1.7.1',
15
+ time: Tt2::Util.current_time_ticks,
16
+ dummy: Time.now - @created_at,
17
+ s: Tt2::Util.request_signature(data) }
18
+ end
19
+
20
+ def initialize(player_id:, auth_token:)
21
+ @player_id = player_id
22
+ @auth_token = auth_token
23
+
24
+ reset_time
25
+ end
26
+
27
+ def reset_time
28
+ @created_at = Time.now
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,50 @@
1
+ require 'openssl'
2
+ require 'json'
3
+
4
+ module TT2
5
+ # Initial Ruby save-file parser from
6
+ # https://www.reddit.com/r/TapTitans2/comments/5zzhx1/clan_mgmt_101_import_save_twice_a_day_kick/df37xnv/
7
+ # modified to clean up a bit.
8
+ module SaveParser
9
+ ENCRYPTION_KEY = ['4bc07927192f4e9a'].pack('H*')
10
+
11
+ class << self
12
+ def read(filename = 'ISavableGlobal.adat')
13
+ encrypted = File.read(filename).bytes
14
+
15
+ plain = decrypt(encrypted)
16
+
17
+ json = plain.slice(plain.index('saveString') + 12...
18
+ plain.index('playerData') - 2)
19
+
20
+ parse_json(json)
21
+ end
22
+
23
+ def decrypt(encrypted)
24
+ iv = encrypted.shift(8).pack('c*')
25
+ encrypted = encrypted.pack('c*')
26
+
27
+ des = OpenSSL::Cipher.new('DES-CBC')
28
+ des.decrypt
29
+ des.key = ENCRYPTION_KEY
30
+ des.iv = iv
31
+
32
+ des.update(encrypted) + des.final
33
+ end
34
+
35
+ def parse_json(json)
36
+ # For stripping the JSON of the .NET-special fields `$content` and `$type`
37
+ clean_up = proc do |o|
38
+ next unless o.is_a? Hash
39
+ o.each_pair do |k, v|
40
+ next unless v.is_a? Hash
41
+ v.delete('$type')
42
+ o[k] = v['$content'] if v.key?('$content')
43
+ end
44
+ end
45
+
46
+ JSON.load(JSON.load(json), clean_up) # rubocop:disable Security/JSONLoad
47
+ end
48
+ end
49
+ end
50
+ end
data/lib/tt2/util.rb ADDED
@@ -0,0 +1,54 @@
1
+ require 'openssl'
2
+
3
+ module TT2
4
+ # This is where all of the fun utility functions like to come and hang out.
5
+ module Util
6
+ BOSSES = %w[ Sponkinack Lucanus Caratacos Sklatborg Drakon
7
+ Straton Grokstomp Grekksfist Zeksgrat FumpTorm
8
+ RamBloggs Brongunk Plogriftus Darmbonack Gredmash
9
+ Skurrfesto Ragnosplock Grombdiblort Frombknock Braakstoof
10
+ Furrglork Skernuut Drezzgart Gelklore Verduug ].freeze
11
+
12
+ PETS = { 'Pet1' => 'Nova', 'Pet2' => 'Toto', 'Pet3' => 'Cerberus', 'Pet4' => 'Mousy',
13
+ 'Pet5' => 'Harker', 'Pet6' => 'Bubbles', 'Pet7' => 'Demos', 'Pet8' => 'Tempest',
14
+ 'Pet9' => 'Basky', 'Pet10' => 'Scraps', 'Pet11' => 'Zero', 'Pet12' => 'Polly',
15
+ 'Pet13' => 'Hamy', 'Pet14' => 'Phobos', 'Pet15' => 'Fluffers', 'Pet16' => 'Kit' }.freeze
16
+
17
+ ARTIFACTS = { 'Artifact1' => 'Heroic Shield', 'Artifact2' => 'Stone of the Valrunes',
18
+ 'Artifact3' => 'The Arcana Cloak', 'Artifact4' => 'Axe of Muerte',
19
+ 'Artifact5' => "Invader's Shield", 'Artifact6' => 'Elixir of Eden',
20
+ 'Artifact7' => 'Parchment of Foresight', 'Artifact8' => "Hunter's Ointment",
21
+ 'Artifact9' => "Laborer's Pendant", 'Artifact10' => 'Bringer of Ragnarok',
22
+ 'Artifact11' => "Titan's Mask", 'Artifact12' => 'Swamp Gauntlet',
23
+ 'Artifact13' => 'Forbidden Scroll', 'Artifact14' => 'Aegis',
24
+ 'Artifact15' => 'Ring of Fealty', 'Artifact16' => 'Glacial Axe',
25
+ 'Artifact17' => "Hero's Blade", 'Artifact18' => 'Egg of Fortune',
26
+ 'Artifact19' => 'Chest of Contentment', 'Artifact20' => 'Book of Prophecy',
27
+ 'Artifact21' => 'Divine Chalice', 'Artifact22' => 'Book of Shadows',
28
+ 'Artifact23' => 'Helmet of Madness', 'Artifact24' => 'Staff of Radiance',
29
+ 'Artifact25' => 'Lethe Water', 'Artifact26' => 'Heavenly Sword3',
30
+ 'Artifact27' => 'Glove of Kuma', 'Artifact28' => 'Amethyst Staff',
31
+ 'Artifact29' => 'Drunken Hammer', 'Artifact31' => 'Divine Retribution',
32
+ 'Artifact32' => 'Fruit of Eden', 'Artifact33' => 'The Sword of Storms',
33
+ 'Artifact34' => 'Charm of the Ancient', 'Artifact35' => 'Blade of Damocles',
34
+ 'Artifact36' => 'Infinity Pendulum', 'Artifact37' => 'Oak Staff',
35
+ 'Artifact38' => 'Furies Bow', 'Artifact39' => 'Titan Spear' }.freeze
36
+
37
+ AVATARS = {}.freeze
38
+
39
+ # The signature hash for all requests
40
+ def request_signature(data, key: '000')
41
+ digest = OpenSSL::Digest.new('md5')
42
+ OpenSSL::HMAC.hexdigest(digest, key, data)
43
+ end
44
+
45
+ # TT2 uses the C# value of DateTime.Now.Ticks, this is the ruby equivalent
46
+ def current_time_ticks
47
+ min_time = Time.utc(0o001, 0o1, 0o1).to_r
48
+ now = Time.now.to_r
49
+
50
+ time_delta_nanoseconds = (now - min_time) * Rational(10_000_000)
51
+ time_delta_nanoseconds.ceil
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,3 @@
1
+ module TT2
2
+ VERSION = '0.1.0'.freeze
3
+ end
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tt2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Steve Whittaker
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-08-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: tty
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.7'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: thor
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: httparty
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Assorted utilities for the wonderful Tap Titans 2 game.
112
+ email: swhitt@gmail.com
113
+ executables:
114
+ - tt2
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - LICENSE.txt
119
+ - README.md
120
+ - exe/tt2
121
+ - lib/tt2.rb
122
+ - lib/tt2/client.rb
123
+ - lib/tt2/save_parser.rb
124
+ - lib/tt2/util.rb
125
+ - lib/tt2/version.rb
126
+ homepage: https://github.com/swhitt/tt2
127
+ licenses:
128
+ - MIT
129
+ metadata: {}
130
+ post_install_message:
131
+ rdoc_options: []
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ requirements: []
145
+ rubyforge_project:
146
+ rubygems_version: 2.6.11
147
+ signing_key:
148
+ specification_version: 4
149
+ summary: Tap Titans 2 Utilities
150
+ test_files: []