ezii 0.0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ezii-client/Gemfile +6 -0
- data/ezii-client/Gemfile.lock +32 -0
- data/ezii-client/Procfile +2 -0
- data/ezii-client/README.md +16 -0
- data/ezii-client/chat.txt +1446 -0
- data/ezii-client/config.ru +1 -0
- data/ezii-client/fake.rb +5 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/functions/base_command.rb +26 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/functions/mouse_y_axis_to_3d_z_axis.rb +4 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/functions/record_audio_and_send_to_wit.rb +18 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/functions/rotate_camera_axis_using_mouse_drag.rb +37 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/functions/selection_cube.rb +35 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/gam.rb +388 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/gems.locked +75 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/gems.rb +10 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/lib/drb_server.rb +13 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/lib/mittsu_monkeypatches/box_geometry.rb +5 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/runnable.rb +20 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/shapes/cube.rb +29 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/sig/runable.rbi +9 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/test.sh +5 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/test/commands/test_move_cube.rb +18 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/test/commands/test_selection_cube.rb +31 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/test/test_command_remapping.rb +30 -0
- data/ezii-client/managables/programs/game_aided_manufacturing/test/test_helper.rb +75 -0
- data/ezii-client/managables/services/chat-bot-integrations/chat.txt +15 -0
- data/ezii-client/managables/services/chat-bot-integrations/gems.locked +66 -0
- data/ezii-client/managables/services/chat-bot-integrations/gems.rb +18 -0
- data/ezii-client/managables/services/chat-bot-integrations/gitter_zircon.rb +644 -0
- data/ezii-client/managables/services/chat-bot-integrations/regexes.rb +240 -0
- data/ezii-client/managables/services/chat-bot-integrations/setup-mac-os-x.sh +0 -0
- data/ezii-client/managables/services/chat-bot-integrations/setup.sh +1 -0
- data/ezii-client/managables/services/chat-bot-integrations/start.sh +3 -0
- data/ezii-client/managables/services/error-inspect/simplest-log +1 -0
- data/ezii-client/managables/services/error-inspect/simplest-log-init +1 -0
- data/ezii-client/managables/services/livestream-interactive/Twitch.Tv/ascii_nebuchadnezzar +9 -0
- data/ezii-client/managables/services/livestream-interactive/Twitch.Tv/chat.txt +1 -0
- data/ezii-client/managables/services/livestream-interactive/Twitch.Tv/twitch_zircon.rb +61 -0
- data/ezii-client/managables/services/livestream-interactive/Twitch.Tv/zion_fleet.rb +198 -0
- data/ezii-client/managables/services/livestream-interactive/chat.txt +40 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/README.md +3 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/__main__.js +58 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/black-out-random-word.js +74 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/random-sentence.js +57 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/random-wikipedia-page.js +25 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/random-words.js +34 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/rare-enough-word.js +41 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/functions/wikipedia-page.js +35 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/package.json +20 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/statistics/count-word.js +12 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/utils/log-to-natural-database.js +10 -0
- data/ezii-client/managables/services/stdlib-dot-com/koma/qanda-api@dev/word2vec-models/test-text8-vector.bin +0 -0
- data/ezii-client/managament_interface/gems.locked +13 -0
- data/ezii-client/managament_interface/gems.rb +3 -0
- data/ezii-client/managament_interface/management_interface +4 -0
- data/ezii-client/managament_interface/runnable.rb +30 -0
- data/ezii-client/rocknrolla +1 -0
- data/ezii-client/start.sh +2 -0
- data/ezii-client/test.wav +0 -0
- data/ezii-misc/detect-intent-from-git-patch.rb +46 -0
- data/ezii-server/Gemfile +23 -0
- data/ezii-server/Gemfile.lock +84 -0
- data/ezii-server/README.md +13 -0
- data/ezii-server/config.ru +2 -0
- data/ezii-server/eezee.rb +1243 -0
- data/ezii-server/httpsprojecteulernetproblem=155.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=205.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=228.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=262.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=3.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=333.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=334.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=337.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=426.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=442.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=449.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=497.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=51.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=514.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=520.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=571.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=587.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=588.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=599.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=72.png +0 -0
- data/ezii-server/httpsprojecteulernetproblem=93.png +0 -0
- data/ezii-server/regexes +258 -0
- data/ezii-server/sample.wav +0 -0
- data/ezii.gemspec +13 -0
- metadata +132 -0
@@ -0,0 +1,240 @@
|
|
1
|
+
if message =~ /bring probes to melting point/
|
2
|
+
@melting_point_receivables.push(@probes)
|
3
|
+
@probes = []
|
4
|
+
return "all of them? melt all the precious probes you idiot?"
|
5
|
+
end
|
6
|
+
|
7
|
+
if message =~ /probe (.*) (.*)/
|
8
|
+
action = :log
|
9
|
+
|
10
|
+
resource = $1
|
11
|
+
probe_identifier = $2
|
12
|
+
|
13
|
+
if probe_identifier =~ /(\d+)s/
|
14
|
+
duration_seconds = $1.to_i
|
15
|
+
end
|
16
|
+
|
17
|
+
if probe_identifier =~ /(\d+)bytes/
|
18
|
+
byte_count = $1.to_i
|
19
|
+
end
|
20
|
+
|
21
|
+
case resource
|
22
|
+
when /twitch.tv/
|
23
|
+
twitch_url = resource
|
24
|
+
action = :twitch
|
25
|
+
when /http/
|
26
|
+
action = :plain_curl
|
27
|
+
url = resource
|
28
|
+
end
|
29
|
+
|
30
|
+
case action
|
31
|
+
when :twitch
|
32
|
+
probe = record_live_stream_video_and_upload_get_url(url: twitch_url, duration_seonds: duration_seconds)
|
33
|
+
@probes.push(probe)
|
34
|
+
return probe
|
35
|
+
when :plain_curl
|
36
|
+
probe = get_string_of_x_bytes_by_curling_url(url: url, byte_count: byte_count)
|
37
|
+
@probes.push(probe)
|
38
|
+
return probe
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
if message =~ /show activity stream/
|
43
|
+
return "https://sideways-snowman.glitch.me/"
|
44
|
+
end
|
45
|
+
|
46
|
+
if message =~ /hey\Z/i
|
47
|
+
return "hey"
|
48
|
+
end
|
49
|
+
|
50
|
+
if message =~ /\Athrow (?:(.*)\s)?bomb\Z/i
|
51
|
+
if $1 == "bugsnag"
|
52
|
+
Bugsnag::Api.configure do |config|
|
53
|
+
config.auth_token = ENV["BUGSNAG_TOKEN"]
|
54
|
+
end
|
55
|
+
organizations = Bugsnag::Api.organizations
|
56
|
+
|
57
|
+
organization = organizations.first
|
58
|
+
|
59
|
+
projects = Bugsnag::Api.projects(organization[:id])
|
60
|
+
|
61
|
+
|
62
|
+
errors = Bugsnag::Api.errors(projects[0][:id], nil)
|
63
|
+
|
64
|
+
return errors.inspect[0...500]
|
65
|
+
end
|
66
|
+
|
67
|
+
return """
|
68
|
+
```
|
69
|
+
Local variables (5 first)
|
70
|
+
#{local_variables.sample(5)}
|
71
|
+
|
72
|
+
Instance variables (5 first)
|
73
|
+
#{instance_variables.sample(5)}
|
74
|
+
|
75
|
+
Public methods (5 first)
|
76
|
+
#{public_methods.sample(5)}
|
77
|
+
|
78
|
+
ENV (120 first chars)
|
79
|
+
#{ENV.inspect[0...120]}
|
80
|
+
|
81
|
+
\`ifconfig\` (120 first chars)
|
82
|
+
#{`ifconfig`[0...120]}
|
83
|
+
```
|
84
|
+
"""
|
85
|
+
end
|
86
|
+
|
87
|
+
if message =~ /\Abring to melting point #{melting_point_receiavable_regex}\Z/i
|
88
|
+
if($1 === "last used picture")
|
89
|
+
Nokogiri::HTML(`curl -L http://gazelle.botcompany.de/lastInput`)
|
90
|
+
|
91
|
+
url = doc.css('a').first.url
|
92
|
+
|
93
|
+
@melting_point_receivables.push(url)
|
94
|
+
end
|
95
|
+
@melting_point_receivables.push($1)
|
96
|
+
end
|
97
|
+
|
98
|
+
if message =~ /\Amelt\Z/
|
99
|
+
# First step, assigning a variable
|
100
|
+
@melting_point = @melting_point_receivables.sample
|
101
|
+
|
102
|
+
def liqudify(raw_data_object)
|
103
|
+
# https://stackoverflow.com/a/24076936/4132642
|
104
|
+
i_ptr_int = raw_data_object.object_id << 1
|
105
|
+
# https://stackoverflow.com/questions/47757960/how-to-get-value-at-a-memory-address-in-linux-shell
|
106
|
+
|
107
|
+
end
|
108
|
+
liqudify(@melting_point)
|
109
|
+
|
110
|
+
# Next step, doing something intelligent with the data
|
111
|
+
# loosening it up somehow
|
112
|
+
# LIQUIDIFYING IT
|
113
|
+
# CONVERTING IT ALL TO BYTES
|
114
|
+
# PRESERVING VOLUME, just changing it's "Aggregatzustand"
|
115
|
+
end
|
116
|
+
|
117
|
+
if message =~ /\Aget-melting-point\Z/
|
118
|
+
return @melting_point
|
119
|
+
end
|
120
|
+
|
121
|
+
if message =~ /launch rocket (.*)\]var\[(.*)/
|
122
|
+
url = $1 + @melting_point + $2
|
123
|
+
curl_response = `curl -L #{url}`[0...100]
|
124
|
+
|
125
|
+
return """
|
126
|
+
CURL
|
127
|
+
#{curl_response}
|
128
|
+
|
129
|
+
URL
|
130
|
+
#{url}
|
131
|
+
"""
|
132
|
+
end
|
133
|
+
|
134
|
+
if message =~ /\Awhat do you think?\Z/i
|
135
|
+
return "I think you're a stupid piece of shit and your dick smells worse than woz before he invented the home computer."
|
136
|
+
end
|
137
|
+
|
138
|
+
if message =~ /\Apass ball to @(\w+)\Z/i
|
139
|
+
@players[$1][:hasBall] = :yes
|
140
|
+
end
|
141
|
+
|
142
|
+
if message =~ /\Awho has ball\Z/i
|
143
|
+
return @players.find { |k, v| v[:hasBall] == :yes }[0]
|
144
|
+
end
|
145
|
+
|
146
|
+
if message =~ /\Aspace\Z/
|
147
|
+
exec_bash_visually_and_post_process_strings(
|
148
|
+
'/Users/lemonandroid/gam-git-repos/LemonAndroid/gam/managables/programs/game_aided_manufacturing/test.sh'
|
149
|
+
)
|
150
|
+
end
|
151
|
+
|
152
|
+
if message =~ /\Achat-variable (\w*) (.*)\Z/i
|
153
|
+
variable_value_used_by_chat_user = $2
|
154
|
+
return "Coming soon" if variable_value_used_by_chat_user == "selectDiscordMessage"
|
155
|
+
variable_identifier_used_by_chat_user = $1
|
156
|
+
|
157
|
+
if(variable_value_used_by_chat_user =~ /`(.*)`/)
|
158
|
+
variable_value_used_by_chat_user = eval($1)
|
159
|
+
end
|
160
|
+
|
161
|
+
@variables_for_chat_users[variable_identifier_used_by_chat_user] = variable_value_used_by_chat_user
|
162
|
+
|
163
|
+
return space_2_unicode("variable #{variable_identifier_used_by_chat_user} set to #{@variables_for_chat_users[variable_identifier_used_by_chat_user]}")
|
164
|
+
end
|
165
|
+
|
166
|
+
if message =~ /\Aget-chat-variable (\w*)\Z/i
|
167
|
+
return [
|
168
|
+
space_2_unicode("Getting variable value for key #{$1}"),
|
169
|
+
space_2_unicode(@variables_for_chat_users[$1].verbose_introspect(very_verbose=true))
|
170
|
+
].join
|
171
|
+
end
|
172
|
+
|
173
|
+
if message =~ /\Aget-method-definition #{variable_regex}#{method_call_regex}\Z/
|
174
|
+
return @variables_for_chat_users[$1].method($2.to_sym).source
|
175
|
+
end
|
176
|
+
|
177
|
+
if message =~ /\A@LemonAndroid List github repos\Z/i
|
178
|
+
return "https://api.github.com/users/LemonAndroid/repos"
|
179
|
+
end
|
180
|
+
|
181
|
+
if message =~ /\AList 10 most recently pushed to Github Repos of LemonAndroid\Z/i
|
182
|
+
texts = ten_most_pushed_to_github_repos
|
183
|
+
texts.each do |text|
|
184
|
+
return text
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
if message =~ /\A@LemonAndroid work on (\w+\/\w+)\Z/i
|
189
|
+
@currently_selected_project = $1
|
190
|
+
return space_2_unicode("currently selected project set to #{@currently_selected_project}")
|
191
|
+
end
|
192
|
+
|
193
|
+
if message =~ /@LemonAndroid currently selected project/i
|
194
|
+
return space_2_unicode("currently selected project is #{@currently_selected_project}")
|
195
|
+
end
|
196
|
+
|
197
|
+
if message =~ /\Ashow `(.*)`\Z/i
|
198
|
+
test = $1
|
199
|
+
exec_bash_visually_and_post_process_strings
|
200
|
+
end
|
201
|
+
|
202
|
+
if message =~ /\A@LemonAndroid\s+show eval `(.*)`\Z/i
|
203
|
+
texts = [eval($1).to_s]
|
204
|
+
texts.each do |text|
|
205
|
+
return space_2_unicode(text)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
if message =~ /\Als\Z/i
|
210
|
+
texts = execute_bash_in_currently_selected_project('ls')
|
211
|
+
texts.each do |text|
|
212
|
+
return text
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
if message =~ /\A@LemonAndroid cd ([^\s]+)\Z/i
|
217
|
+
path = nil
|
218
|
+
Dir.chdir(current_repo_dir) do
|
219
|
+
path = File.expand_path(File.join('.', Dir.glob("**/#{$1}")))
|
220
|
+
end
|
221
|
+
texts = execute_bash_in_currently_selected_project("ls #{path}")
|
222
|
+
|
223
|
+
return space_2_unicode("Listing directory `#{path}`")
|
224
|
+
texts.each do |text|
|
225
|
+
return text
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
if message =~ /\A@LemonAndroid cat ([^\s]+)\Z/i
|
230
|
+
path = nil
|
231
|
+
Dir.chdir(current_repo_dir) do
|
232
|
+
path = File.expand_path(File.join('.', Dir.glob("**/#{$1}")))
|
233
|
+
end
|
234
|
+
texts = execute_bash_in_currently_selected_project("cat #{path}")
|
235
|
+
|
236
|
+
return space_2_unicode("Showing file `#{path}`")
|
237
|
+
texts.each do |text|
|
238
|
+
return text
|
239
|
+
end
|
240
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
mkdir ~/gam-git-repos
|
@@ -0,0 +1 @@
|
|
1
|
+
tail -f /var/log/gam.stderr
|
@@ -0,0 +1 @@
|
|
1
|
+
sudo touch /var/log/gam.stderr
|
@@ -0,0 +1 @@
|
|
1
|
+
Welcome, GLHF!
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'zircon'
|
2
|
+
require 'colorize'
|
3
|
+
require 'net/http'
|
4
|
+
require 'cgi'
|
5
|
+
LOG_FILE = File.open('chat.txt', 'w')
|
6
|
+
|
7
|
+
SCREEN = []
|
8
|
+
|
9
|
+
TWITCH_CHANNEL = '#' + ENV["TWITCH_CHANNEL"]
|
10
|
+
|
11
|
+
def start
|
12
|
+
client = Zircon.new(
|
13
|
+
server: 'irc.twitch.tv',
|
14
|
+
port: '6667',
|
15
|
+
channel: TWITCH_CHANNEL,
|
16
|
+
username: 'ezii_tm_registerred',
|
17
|
+
password: ENV["EZE_TWITCH_TOKEN_CHAT"]
|
18
|
+
)
|
19
|
+
|
20
|
+
removed_colors = [:black, :white, :light_black, :light_white]
|
21
|
+
colors = String.colors - removed_colors
|
22
|
+
client.on_message do |message|
|
23
|
+
puts ">>> #{message.from}: #{message.body}".colorize(colors.sample)
|
24
|
+
LOG_FILE.write(message.body.to_s + "\n")
|
25
|
+
if message.body == "Nebuchadnezzar"
|
26
|
+
Thread.new do
|
27
|
+
i = 0
|
28
|
+
puts `ls`
|
29
|
+
Dir.chdir("managables/services/livestream-interactive/Twitch.Tv/") do
|
30
|
+
open("|ruby zion_fleet.rb") do |∫|
|
31
|
+
while response = ∫.gets
|
32
|
+
i += 1
|
33
|
+
next if i < 20
|
34
|
+
SCREEN.push(response)
|
35
|
+
# if rand < 0.00001
|
36
|
+
# byebug
|
37
|
+
# end
|
38
|
+
|
39
|
+
url = URI.parse('https://ezii-server.herokuapp.com/' + '?message=' + CGI.escape(response))
|
40
|
+
response = Net::HTTP.get(url)
|
41
|
+
puts response
|
42
|
+
client.privmsg(TWITCH_CHANNEL, response.gsub(/\s/, '.')) if !response.empty?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
if message.body
|
50
|
+
url = URI.parse('https://ezii-server.herokuapp.com/' + '?message=' + CGI.escape(message.body))
|
51
|
+
response = Net::HTTP.get(url)
|
52
|
+
puts response
|
53
|
+
client.privmsg(TWITCH_CHANNEL, response) if !response.empty?
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
client.run!
|
58
|
+
end
|
59
|
+
|
60
|
+
start()
|
61
|
+
|
@@ -0,0 +1,198 @@
|
|
1
|
+
require 'io/console'
|
2
|
+
|
3
|
+
def at(x, y, str)
|
4
|
+
print "\033[#{y};#{x}H#{str}"
|
5
|
+
end
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
#
|
11
|
+
# INIT
|
12
|
+
#
|
13
|
+
# terminal configuration
|
14
|
+
Kernel.system "tput civis; stty -icanon -echo; resize -s 30 120; clear"
|
15
|
+
height, width = 30, 30
|
16
|
+
# Ship initial position, speed and fired missiles
|
17
|
+
lvl = 0
|
18
|
+
y_pos = 10
|
19
|
+
y_incr = 1
|
20
|
+
hull = 20
|
21
|
+
shield = 20
|
22
|
+
zion = 40
|
23
|
+
weapon = ['~', '=>', '░▒▓█', 'Φ']
|
24
|
+
wpn_i = 1
|
25
|
+
fire = [] # [x_pos, y_pos]
|
26
|
+
enemies = [] # [x_pos, y_pos]
|
27
|
+
kills = 0
|
28
|
+
|
29
|
+
while true
|
30
|
+
#
|
31
|
+
# WINDOW
|
32
|
+
#
|
33
|
+
# top left
|
34
|
+
at(1, 1, "Level: #{lvl.to_s}")
|
35
|
+
at(1, 2, "Kills: #{kills.to_s}")
|
36
|
+
at(1, 5, "Enemies: #{enemies.size.to_s}")
|
37
|
+
# top center
|
38
|
+
at(58, 1, "ZION")
|
39
|
+
at(40, 2, "#{('|' * zion).ljust(40, ' ')}")
|
40
|
+
# top right
|
41
|
+
at(width - 28, 1, 'Nebuchadnezzar')
|
42
|
+
at(width - 28, 2, "Hull: #{('|' * hull).ljust(20, ' ')}")
|
43
|
+
at(width - 28, 3, "Shield: #{('|' * shield).ljust(20, ' ')}")
|
44
|
+
# bottom left
|
45
|
+
at(1, height, '\'q\' to quit')
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
#
|
52
|
+
# USER INPUT
|
53
|
+
#
|
54
|
+
# STDIN input refresh screen, or 0.005 scd. Might melts some CPU ?
|
55
|
+
refresh = Kernel.select([$stdin], nil, nil, 0.005)
|
56
|
+
if refresh then
|
57
|
+
case $stdin.getc
|
58
|
+
when 'q' then system('clear') && break
|
59
|
+
when ' ' then
|
60
|
+
wpn_i += 1
|
61
|
+
# unlock new weapons
|
62
|
+
fire << [34, y_pos + 7, weapon[0]]
|
63
|
+
fire << [34, y_pos + 6, weapon[0]] if kills >= 10
|
64
|
+
fire << [28, y_pos + 4, weapon[1]] if kills >= 50
|
65
|
+
fire << [22, y_pos + 5, weapon[1]] if kills >= 100
|
66
|
+
fire << [17, y_pos + 3, weapon[2]] if kills >= 200 && wpn_i % 5 == 0
|
67
|
+
# ANSI escape sequence
|
68
|
+
when "\033"
|
69
|
+
# Arrow up
|
70
|
+
when 'A' then y_pos -= 1
|
71
|
+
# Arrow down
|
72
|
+
when 'B' then y_pos += 1
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
#
|
82
|
+
# SHIP
|
83
|
+
#
|
84
|
+
# clear trailing lines
|
85
|
+
at(24, y_pos, "#{' ' * 5}")
|
86
|
+
at(29, y_pos + 1, "#{' ' * 10}")
|
87
|
+
at(39, y_pos + 2, "#{' ' * 3}")
|
88
|
+
at(42, y_pos + 3, ' ')
|
89
|
+
at(42, y_pos + 7, ' ')
|
90
|
+
at(33, y_pos + 8, "#{' ' * 9}")
|
91
|
+
at(28, y_pos + 9, "#{' ' * 5}")
|
92
|
+
|
93
|
+
# make sure ship stay on the screen
|
94
|
+
y_pos = y_pos + 1 if y_pos <= 0
|
95
|
+
y_pos = y_pos - 1 if y_pos >= height - 8
|
96
|
+
|
97
|
+
# display ship. Instanciate new File object every 0.01 scd ? ¯\_(ツ)_/¯
|
98
|
+
at(nil, y_pos, File.read('ascii_nebuchadnezzar'))
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
#
|
103
|
+
# FIRE
|
104
|
+
#
|
105
|
+
if fire.any?
|
106
|
+
fire.each_with_index do |f, i|
|
107
|
+
# shots move forward without leaving a character behind them
|
108
|
+
at(f[0], f[1], ' ')
|
109
|
+
f[0] += 1
|
110
|
+
|
111
|
+
(f[0] + f[2].size) < width ? at(f[0], f[1], f[2]) : at(f[0], f[1], "#{' ' * f[2].size}")
|
112
|
+
fire.delete_at(i) if f[0] > width
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
#
|
120
|
+
# ENEMIES
|
121
|
+
#
|
122
|
+
# e = [x_position, y_position, x_pos as float, speed]
|
123
|
+
|
124
|
+
# more and more enemies spawn
|
125
|
+
if lvl < 1000
|
126
|
+
enemies << [width, rand(9..27), width, rand(0.008..0.09)] if lvl % 360 == 0
|
127
|
+
elsif lvl <= 2500
|
128
|
+
enemies << [width, rand(9..27), width, rand(0.008..0.09)] if lvl % 140 == 0
|
129
|
+
elsif lvl <= 5000
|
130
|
+
enemies << [width, rand(9..27), width, rand(0.008..0.09)] if lvl % 51 == 0
|
131
|
+
elsif lvl <= 10_000
|
132
|
+
enemies << [width, rand(9..27), width, rand(0.008..0.09)] if lvl % 20 == 0
|
133
|
+
elsif lvl <= 11_000
|
134
|
+
enemies << [width, rand(9..27), width, rand(0.008..0.09)] if lvl % 15 == 0
|
135
|
+
elsif lvl <= 12_000
|
136
|
+
enemies << [width, rand(9..27), width, rand(0.008..0.09)] if lvl % 10 == 0
|
137
|
+
elsif lvl <= 13_000
|
138
|
+
enemies << [width, rand(9..27), width, rand(0.008..0.09)] if lvl % 5 == 0
|
139
|
+
elsif lvl > 13_000
|
140
|
+
enemies << [width, rand(9..27), width, rand(0.008..0.09)] if lvl % 2 == 0
|
141
|
+
end
|
142
|
+
|
143
|
+
enemies.each_with_index do |e, i|
|
144
|
+
# each enemy has his own speed
|
145
|
+
e[2] -= e[3]
|
146
|
+
# enemies speed increases with time
|
147
|
+
case lvl
|
148
|
+
when 1..2000 then nil
|
149
|
+
when 2001..5000 then e[2] -= 0.02
|
150
|
+
when 5001..7500 then e[2] -= 0.04
|
151
|
+
else e[2] -= 0.07
|
152
|
+
end
|
153
|
+
e[0] = e[2].to_i
|
154
|
+
|
155
|
+
# display enemies
|
156
|
+
at(e[0], e[1], '*')
|
157
|
+
at(e[0] + 1, e[1], ' ')
|
158
|
+
|
159
|
+
# kill an enemy if he gets shot
|
160
|
+
fire.each_with_index do |f, j|
|
161
|
+
if e[0] == f[0] && e[1] == f[1]
|
162
|
+
enemies.delete_at(i)
|
163
|
+
at(f[0] - 1, f[1], ' ')
|
164
|
+
# weapon[2] (= laser) go through enemies
|
165
|
+
fire.delete_at(j) if f[2] != weapon[2]
|
166
|
+
kills += 1
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
# an enemy damages the ship shield/hull if they're on the same cell
|
171
|
+
if e[0] < 42
|
172
|
+
if (e[0].between?(24, 28) && e[1] == y_pos + 1) ||
|
173
|
+
(e[0].between?(23, 38) && e[1] == y_pos + 2) ||
|
174
|
+
(e[0].between?(23, 41) && e[1] == y_pos + 3) ||
|
175
|
+
(e[0] <= 42 && e[1] == y_pos + 4) ||
|
176
|
+
(e[0] <= 42 && e[1] == y_pos + 5) ||
|
177
|
+
(e[0] <= 42 && e[1] == y_pos + 6) ||
|
178
|
+
(e[0].between?(27, 41) && e[1] == y_pos + 7) ||
|
179
|
+
(e[0].between?(28, 32) && e[1] == y_pos + 8)
|
180
|
+
then
|
181
|
+
shield < 1 ? hull -= 0.2 : shield -= 1
|
182
|
+
enemies.delete_at(i)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
# hide enemies if they cross the window and damage zion
|
187
|
+
if e[0] == 0
|
188
|
+
enemies.delete_at(i) && zion -= 1
|
189
|
+
end
|
190
|
+
end
|
191
|
+
# loose victory
|
192
|
+
break if hull < 0.2 || zion < 1
|
193
|
+
|
194
|
+
lvl += 1
|
195
|
+
end
|
196
|
+
|
197
|
+
Kernel.system "clear; tput cnorm; stty icanon echo"
|
198
|
+
|