-
Notifications
You must be signed in to change notification settings - Fork 1
/
zsd
executable file
·92 lines (67 loc) · 1.25 KB
/
zsd
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env ruby
$rpath = "#{File.expand_path '~'}/.zsd"
require "optparse"
$options = []
OptionParser.new { |opts|
opts.on("-i", "--info", "Shows info on current game") {
$options << "i"
}
opts.on("-h", "--help", "Shows help page") {
$options << "h"
}
opts.on("-s", "--scores", "Shows top 5 high scores") {
$options << "s"
}
opts.on("-u", "--update", "Updates zsd") {
$options << "u"
}
opts.on("-t", "--testing", "For dev use only") {
$rpath = "."
}
}.parse!
require "#{$rpath}/require/other"
def main
cli = Cli.new
unless $options.empty?
$options.each { |o|
case o
when "i"
cli.player.info
exit
# when "h"
# cli.tutorial
# exit
when "s"
cli.scores
exit
when "u"
system "~/.zsd/update.sh"
exit
end
}
end
%w[ TERM INT HUP ].each { |signal|
trap(signal) {
exit_game $player
}
}
start cli
end
def start cli
p_info("Type help for help.")
loop {
cli.spawn_zombie
while cli.zombie.is_alive
input = prompt(">").split
command = input[0]
if cli.commands.include? command
cli.send(command, *input[1..-1])
else
p_warn("Unknown Command.") unless command.nil?
end
end # zombie has died if loop ends
} # end game loop
end
if __FILE__ == $0
main
end