-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.rb
executable file
·46 lines (34 loc) · 979 Bytes
/
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/ruby
$:.push("ai", "items", "interface", "game_data", "utils")
# Load all the class definitions
require "config.rb"
require "telnet.rb"
require "aimanager.rb"
require "game.rb"
require "VT102.rb"
# Read in configuration
$config = ElConfig.new
$config.load
print $config.opt["name"] + ", a #nethack production...\n"
# Create the connection
$vt102 = VT102.new(80, 24)
$telnet = ElTelnet.new
$game = ElGame.new
# Handle the menu and log in
logged_in = $telnet.login
ai_manager = ElAIManager.new
if (logged_in)
$telnet.startgame
# While in the game, as long as we're not dead or ascended yet, continue playing.
while (true)
$vt102.print_screen() if $config.opt["vt102_debug"]
# Send the next command to the network
resp = ai_manager.run_next_task()
if (resp.include? "stamped scroll")
print "We received some mail -- assume it's a death threat, and quit"
$telnet.quitgame
return
end
end # Loop while in game
end
print "Goodbye!\n"