aro 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +5 -5
- data/.ruby-version +1 -1
- data/Gemfile.lock +32 -14
- data/aro.gemspec +17 -8
- data/bin/aos +19 -0
- data/bin/aro +24 -24
- data/checksums/aro-0.1.6.gem.sha512 +1 -0
- data/checksums/aro-0.1.7.gem.sha512 +1 -0
- data/checksums/aro-0.1.8.gem.sha512 +1 -0
- data/db/migrate/1763374647_create_decks.rb +3 -0
- data/db/migrate/1763432541_create_logs.rb +1 -0
- data/db/migrate/1765148774_create_yous.rb +19 -0
- data/listen.rb +10 -0
- data/locale/en.aos.yml +27 -0
- data/locale/en.cngelog.yml +5 -0
- data/locale/en.usage.yml +55 -38
- data/locale/en.yml +47 -15
- data/sys/aos/aos.rb +199 -0
- data/sys/aos/db.rb +81 -0
- data/sys/aos/s.rb +25 -0
- data/sys/aos/views/base.rb +139 -0
- data/sys/aos/views/dom.rb +45 -0
- data/sys/aos/views/games/abpps.rb +21 -0
- data/sys/aos/views/games/deck.rb +95 -0
- data/sys/aos/views/games/game.rb +24 -0
- data/sys/aos/views/games/hbpps.rb +21 -0
- data/sys/aos/views/games/shpps.rb +21 -0
- data/sys/aos/views/games/vipps.rb +21 -0
- data/sys/aos/views/games.rb +19 -0
- data/sys/aos/views/know/library.rb +19 -0
- data/sys/aos/views/know/temple.rb +19 -0
- data/sys/aos/views/know.rb +19 -0
- data/sys/aos/views/setup/settings.rb +50 -0
- data/sys/aos/views/setup.rb +19 -0
- data/sys/aos/views/welcome/waite.rb +19 -0
- data/sys/aos/views/welcome/winner.rb +19 -0
- data/sys/aos/views/welcome.rb +19 -0
- data/sys/aos/you.rb +15 -0
- data/sys/aro/d.rb +25 -0
- data/sys/aro/db.rb +89 -0
- data/sys/aro/mancy.rb +114 -0
- data/sys/aro/p.rb +25 -0
- data/sys/aro/r.rb +20 -0
- data/sys/aro/v.rb +24 -0
- data/sys/aro.rb +16 -0
- data/sys/cli/config.rb +582 -0
- data/sys/cli/constants.rb +56 -0
- data/{bin → sys}/cli/create.rb +6 -4
- data/sys/cli/deck.rb +98 -0
- data/sys/cli/dom.rb +37 -0
- data/sys/cli/nterface.rb +31 -0
- data/{bin → sys}/cli/usage.rb +1 -1
- data/sys/cli.rb +26 -0
- data/sys/dom/d.rb +101 -0
- data/sys/dom/dom.rb +161 -0
- data/sys/dom/p.rb +17 -0
- data/sys/models/deck.rb +218 -0
- data/sys/models/log.rb +20 -0
- data/sys/reiquire.rb +45 -0
- data/sys/shr/prompt.rb +37 -0
- data/sys/shr/t.rb +60 -0
- data/sys/shr/version.rb +16 -0
- data/tasks/make.rake +2 -2
- metadata +78 -22
- data/.release +0 -20
- data/bin/cli/config.rb +0 -231
- data/bin/cli/constants.rb +0 -39
- data/bin/cli/deck.rb +0 -100
- data/bin/cli.rb +0 -39
- data/lib/aro/c.rb +0 -32
- data/lib/aro/create.rb +0 -29
- data/lib/aro/db.rb +0 -107
- data/lib/aro/environment.rb +0 -3
- data/lib/aro/i18n.rb +0 -12
- data/lib/aro/prompt.rb +0 -25
- data/lib/aro/version.rb +0 -4
- data/lib/aro.rb +0 -45
- data/lib/models/deck.rb +0 -294
- data/lib/models/log.rb +0 -12
data/sys/aos/aos.rb
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
aos.rb
|
|
4
|
+
|
|
5
|
+
aos.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require :aro.to_s
|
|
12
|
+
|
|
13
|
+
module Aos
|
|
14
|
+
|
|
15
|
+
def self.run
|
|
16
|
+
Aos::Os::boot(Aos::you)
|
|
17
|
+
Aos::Os.instance.run
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.watch
|
|
21
|
+
Aos::Os::boot(Aos::you)
|
|
22
|
+
Aos::Os::instance.render
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.you
|
|
26
|
+
Aos::Db.new
|
|
27
|
+
you = Aos::You.where(name: :you).first
|
|
28
|
+
if you.nil?
|
|
29
|
+
you = Aos::You.new(name: :you, pwd: Dir.pwd)
|
|
30
|
+
you.save
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
you
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class Os
|
|
37
|
+
include Singleton
|
|
38
|
+
|
|
39
|
+
attr_accessor :you, :running, :view
|
|
40
|
+
|
|
41
|
+
PS1 = "@#{Aos::Os}$"
|
|
42
|
+
|
|
43
|
+
CMDS = {
|
|
44
|
+
CD: {
|
|
45
|
+
key: :cd,
|
|
46
|
+
description: I18n.t("aos.commands.description.cd"),
|
|
47
|
+
usage: I18n.t("aos.commands.usage.cd"),
|
|
48
|
+
},
|
|
49
|
+
CONFIG: {
|
|
50
|
+
key: :config,
|
|
51
|
+
description: I18n.t("aos.commands.description.config"),
|
|
52
|
+
usage: I18n.t("aos.commands.usage.config"),
|
|
53
|
+
cmds: {
|
|
54
|
+
SET: {
|
|
55
|
+
key: :set,
|
|
56
|
+
description: I18n.t("aos.commands.description.config_set"),
|
|
57
|
+
usage: I18n.t("aos.commands.usage.config_set"),
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
EXIT: {
|
|
62
|
+
key: :exit,
|
|
63
|
+
description: I18n.t("aos.commands.description.exit"),
|
|
64
|
+
usage: I18n.t("aos.commands.usage.exit"),
|
|
65
|
+
},
|
|
66
|
+
LS: {
|
|
67
|
+
key: :ls,
|
|
68
|
+
description: I18n.t("aos.commands.description.ls"),
|
|
69
|
+
usage: I18n.t("aos.commands.usage.ls"),
|
|
70
|
+
},
|
|
71
|
+
PWD: {
|
|
72
|
+
key: :pwd,
|
|
73
|
+
description: I18n.t("aos.commands.description.pwd"),
|
|
74
|
+
usage: I18n.t("aos.commands.usage.pwd"),
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
def self.boot(you)
|
|
79
|
+
self.instance.you = you
|
|
80
|
+
self.instance.load_view
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def load_view
|
|
84
|
+
view_name = Aos::Os.osify(you.pwd).split("/").last || :dom.to_s
|
|
85
|
+
view_cls = (Aos::Vi.name + "::#{view_name.capitalize}").constantize
|
|
86
|
+
Aro::D.say("loading view #{view_cls}")
|
|
87
|
+
self.view = view_cls
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def render
|
|
91
|
+
return if view.nil?
|
|
92
|
+
|
|
93
|
+
view.show(you)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def run
|
|
97
|
+
self.running = true
|
|
98
|
+
|
|
99
|
+
# begin game loop
|
|
100
|
+
while running do
|
|
101
|
+
# get input
|
|
102
|
+
cmd = Aos::S.p.ask(Aos::Os::PS1)
|
|
103
|
+
|
|
104
|
+
# default to passthrough
|
|
105
|
+
passthrough = true
|
|
106
|
+
|
|
107
|
+
# get args
|
|
108
|
+
args = cmd.split(" ")
|
|
109
|
+
|
|
110
|
+
# search for room path
|
|
111
|
+
room_path = Aro::Dom.room_path(args[0])
|
|
112
|
+
if !room_path.empty?
|
|
113
|
+
you.update(pwd: File.join(
|
|
114
|
+
File.dirname(Aro::Dom.ethergeist_path),
|
|
115
|
+
room_path
|
|
116
|
+
))
|
|
117
|
+
Dir.chdir(you.pwd)
|
|
118
|
+
next
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# determine if command is Aos::Os::CMDS
|
|
122
|
+
if Aos::Os::CMDS.values.map{|v| v[:key]}.include?(args[0].to_sym)
|
|
123
|
+
Dir.chdir(you.pwd)
|
|
124
|
+
passthrough = false
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# config commands
|
|
128
|
+
|
|
129
|
+
if args[0].to_sym == Aos::Os::CMDS[:CONFIG][:key]
|
|
130
|
+
if args[1].nil?
|
|
131
|
+
# show settings
|
|
132
|
+
you.update(pwd:
|
|
133
|
+
File.join(
|
|
134
|
+
File.dirname(Aro::Dom.ethergeist_path),
|
|
135
|
+
Aro::Dom::SETUP.to_s,
|
|
136
|
+
Aro::Dom::SETTINGS.to_s
|
|
137
|
+
)
|
|
138
|
+
)
|
|
139
|
+
else
|
|
140
|
+
Aos::S.say("not implemented.")
|
|
141
|
+
end
|
|
142
|
+
elsif args[0] == Aos::Os::CMDS[:LS][:key].to_s
|
|
143
|
+
Aos::S.say(Dir[File.join(Dir.pwd, "*/")].map{|p| "@/" + Aos::Os::osify(p)}.join("\n"))
|
|
144
|
+
elsif args[0] == Aos::Os::CMDS[:PWD][:key].to_s
|
|
145
|
+
osified = "@/" + Aos::Os::osify(you.pwd)
|
|
146
|
+
Aos::S.say(osified)
|
|
147
|
+
elsif args[0] == Aos::Os::CMDS[:EXIT][:key].to_s
|
|
148
|
+
Aos::S.say("exiting...")
|
|
149
|
+
self.running = false
|
|
150
|
+
elsif args[0] == Aos::Os::CMDS[:CD][:key].to_s
|
|
151
|
+
|
|
152
|
+
if args[1].nil? || args[1] == "~/"
|
|
153
|
+
# no arg takes you to arodom root
|
|
154
|
+
you.update(pwd: File.dirname(Aro::Dom.ethergeist_path))
|
|
155
|
+
else
|
|
156
|
+
if args[1].include?("..")
|
|
157
|
+
# going up
|
|
158
|
+
if File.dirname(Aro::Dom.ethergeist_path) == you.pwd
|
|
159
|
+
Aos::S.say("within #{Aos::Os}, one cannot leave the #{Aro::Dom}.")
|
|
160
|
+
else
|
|
161
|
+
# todo: support dots in paths
|
|
162
|
+
# this only supports moving one level up
|
|
163
|
+
|
|
164
|
+
pwd_arr = you.pwd.split("/")
|
|
165
|
+
new_pwd = (pwd_arr.first(pwd_arr.length - 1)).join("/")
|
|
166
|
+
|
|
167
|
+
you.update(pwd: new_pwd)
|
|
168
|
+
end
|
|
169
|
+
elsif !args[1].nil?
|
|
170
|
+
if args[1][0] != "/" && Dir.exist?(args[1])
|
|
171
|
+
you.update(pwd: File.join(you.pwd, args[1]))
|
|
172
|
+
else
|
|
173
|
+
Aos::S.say("that directory is invalid.")
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
if passthrough
|
|
180
|
+
system(cmd)
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
CLI::EXIT_CODES[:SUCCESS]
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def self.osify(path)
|
|
188
|
+
# strips off non-arodom part of path
|
|
189
|
+
# Aos::Os::osify()
|
|
190
|
+
|
|
191
|
+
path_arr = path.split("/")
|
|
192
|
+
Aro::Dom::dom_root.split("/").each{|rdp|
|
|
193
|
+
path_arr.delete(rdp)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
path_arr.join("/")
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
end
|
data/sys/aos/db.rb
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
db.rb
|
|
4
|
+
|
|
5
|
+
database for aos room.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
module Aos
|
|
12
|
+
class Db < Aro::Db
|
|
13
|
+
DATABASE_YML = :"database.yml"
|
|
14
|
+
SQL_FILE = :"database.sql"
|
|
15
|
+
SCHEMA_FILE = :"schema.rb"
|
|
16
|
+
MIGRATIONS_DIR = :"db/migrate"
|
|
17
|
+
|
|
18
|
+
def initialize
|
|
19
|
+
# ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
20
|
+
unless Aro::Dom.in_arodom?
|
|
21
|
+
Aro::P.say(I18n.t("cli.errors.not_in_aro" , cmd: Aro::Dom.name))
|
|
22
|
+
return
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
set_up_aos
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.base_aro_dir
|
|
29
|
+
Aro::Dom.ethergeist_path
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def db_config_filepath
|
|
33
|
+
File.join(Aos::Db.base_aro_dir, Aos::Db::DATABASE_YML.to_s)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def set_up_aos
|
|
37
|
+
name = Aro::Dom.ethergeist_name
|
|
38
|
+
return if name.nil?
|
|
39
|
+
|
|
40
|
+
# create local /.ethergeist directory
|
|
41
|
+
unless File.exist?(Aos::Db.base_aro_dir)
|
|
42
|
+
FileUtils.mkdir(Aos::Db.base_aro_dir)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
Aro::D.say("creating database: #{db_config_filepath}")
|
|
46
|
+
unless File.exist?(db_config_filepath)
|
|
47
|
+
# create database config yaml file
|
|
48
|
+
c = {
|
|
49
|
+
adapter: :sqlite3.to_s,
|
|
50
|
+
database: File.join(Aos::Db.base_aro_dir, Aos::Db::SQL_FILE.to_s),
|
|
51
|
+
username: name,
|
|
52
|
+
password: name
|
|
53
|
+
}.to_yaml
|
|
54
|
+
File.open(db_config_filepath, "w") do |file|
|
|
55
|
+
file.write(c)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
connect(name)
|
|
60
|
+
migrate(name)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def migrate(name)
|
|
64
|
+
local_migrate_dir = File.join(Aos::Db.base_aro_dir, Aos::Db::MIGRATIONS_DIR.to_s)
|
|
65
|
+
unless Dir.exist?(local_migrate_dir)
|
|
66
|
+
gem_dir = Dir[Gem.loaded_specs[:aro.to_s]&.full_gem_path || '.'].first
|
|
67
|
+
FileUtils.cp_r(File.join(gem_dir, "db"), Aos::Db::base_aro_dir)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
migration_version = Dir["#{local_migrate_dir}/*.rb"].map{|n|
|
|
71
|
+
Pathname.new(n).basename.to_s.split("_")[0].to_i
|
|
72
|
+
}.max
|
|
73
|
+
ActiveRecord::MigrationContext.new(local_migrate_dir).migrate(migration_version)
|
|
74
|
+
|
|
75
|
+
filename = File.join(Aos::Db.base_aro_dir, Aos::Db::SCHEMA_FILE.to_s)
|
|
76
|
+
File.open(filename, "w+") do |f|
|
|
77
|
+
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection_pool, f)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
data/sys/aos/s.rb
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
s.rb
|
|
4
|
+
|
|
5
|
+
s logger for i2097i.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require_relative :"../shr/prompt".to_s
|
|
12
|
+
|
|
13
|
+
module Aos
|
|
14
|
+
class S < Aro::Prompt
|
|
15
|
+
def self.say(message)
|
|
16
|
+
return unless Aos::S.should_print?
|
|
17
|
+
Aro::P::p.say(message)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.should_print?
|
|
21
|
+
true
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
views/base.rb
|
|
4
|
+
|
|
5
|
+
the base view (abstract).
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require :aro.to_s
|
|
12
|
+
|
|
13
|
+
module Aos
|
|
14
|
+
module Vi
|
|
15
|
+
class Base
|
|
16
|
+
BAR = :|.to_s
|
|
17
|
+
MARGIN_V = Aro::Mancy::S
|
|
18
|
+
MARGIN_H = Aro::Mancy::S
|
|
19
|
+
|
|
20
|
+
def self.show(model)
|
|
21
|
+
# default view
|
|
22
|
+
draw([self.name], model)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.draw(lines, you = nil)
|
|
26
|
+
return false unless lines.kind_of?(Array)
|
|
27
|
+
|
|
28
|
+
dc = CLI::Config.display_config
|
|
29
|
+
height = dc[:HEIGHT]
|
|
30
|
+
width = dc[:WIDTH]
|
|
31
|
+
divider = dc[:DIVIDER] * width
|
|
32
|
+
|
|
33
|
+
# lines printed
|
|
34
|
+
printed = Aro::Mancy::O
|
|
35
|
+
|
|
36
|
+
# max printable lines
|
|
37
|
+
# vertical margins
|
|
38
|
+
max_lines = height - Aos::Vi::Base::MARGIN_V * Aro::Mancy::OS
|
|
39
|
+
# footer
|
|
40
|
+
max_lines = max_lines - Aro::Mancy::OS
|
|
41
|
+
|
|
42
|
+
# header
|
|
43
|
+
Aro::Mancy::S.times do |i|
|
|
44
|
+
printed += Aro::Mancy::S
|
|
45
|
+
Aos::S.say(divider)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
t_divider = dc[:DIVIDER] * ((width - self.name.length) / Aro::Mancy::OS)
|
|
49
|
+
printed += Aro::Mancy::S
|
|
50
|
+
Aos::S.say((t_divider + self.name.to_s.upcase).ljust(width, dc[:DIVIDER]))
|
|
51
|
+
|
|
52
|
+
Aro::Mancy::S.times do
|
|
53
|
+
printed += Aro::Mancy::S
|
|
54
|
+
Aos::S.say(divider)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# top vertical margin
|
|
58
|
+
Aos::Vi::Base::MARGIN_V.times do
|
|
59
|
+
printed += Aro::Mancy::S
|
|
60
|
+
print_regular_line("")
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# print lines
|
|
64
|
+
lines.each{|line|
|
|
65
|
+
next if printed == max_lines
|
|
66
|
+
|
|
67
|
+
printed += Aro::Mancy::S
|
|
68
|
+
print_regular_line(line)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
# fill empty space
|
|
72
|
+
while printed < max_lines
|
|
73
|
+
printed += Aro::Mancy::S
|
|
74
|
+
print_regular_line("")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# bottom vertical margin
|
|
78
|
+
Aos::Vi::Base::MARGIN_V.times do
|
|
79
|
+
printed += Aro::Mancy::S
|
|
80
|
+
print_regular_line("")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# footer
|
|
84
|
+
if you.nil?
|
|
85
|
+
Aos::S.say("")
|
|
86
|
+
Aos::S.say("")
|
|
87
|
+
else
|
|
88
|
+
Aos::S.say(divider[Aro::Mancy::O..width - Aro::Mancy::S])
|
|
89
|
+
Aos::S.say("#{Aos::Os}_v#{Aro::VERSION}_#{Aro::Dom}: /#{Aos::Os::osify(you.pwd)}")
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
Aro::D.say("invalid printed height: #{height}, printed: #{printed}") if printed != height
|
|
93
|
+
|
|
94
|
+
# explicitly return true
|
|
95
|
+
true
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def self.viewport_width
|
|
99
|
+
dc = CLI::Config.display_config
|
|
100
|
+
width = dc[:WIDTH]
|
|
101
|
+
bar_width = (Aos::Vi::Base::BAR.length * Aro::Mancy::OS)
|
|
102
|
+
h_margin_width = (Aos::Vi::Base::MARGIN_H * Aro::Mancy::OS)
|
|
103
|
+
|
|
104
|
+
(width - (bar_width + h_margin_width))
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def self.print_regular_line(line)
|
|
108
|
+
hm = Aos::Vi::Base::MARGIN_H
|
|
109
|
+
bar = Aos::Vi::Base::BAR
|
|
110
|
+
hm_space = " " * Aos::Vi::Base::MARGIN_H
|
|
111
|
+
just = CLI::Config.display_config[:WIDTH] - (hm_space.length + bar.length)
|
|
112
|
+
Aos::S.say((bar + hm_space + (line || "")).ljust(just) + hm_space + bar)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def self.lines_for_cmd(cmd)
|
|
116
|
+
just_cmds = Aro::Mancy::NUMERALS[:IX]
|
|
117
|
+
cmd_lines = []
|
|
118
|
+
key_proc = Proc.new{|k| "$ #{k}"}
|
|
119
|
+
desc_proc = Proc.new{|desc| "#{"desc:".rjust(just_cmds)} #{desc}"}
|
|
120
|
+
usage_proc = Proc.new{|usage| "#{"usage:".rjust(just_cmds)} #{usage}"}
|
|
121
|
+
|
|
122
|
+
cmd_lines << key_proc.call(cmd[:key])
|
|
123
|
+
cmd_lines << desc_proc.call(cmd[:description])
|
|
124
|
+
cmd_lines << usage_proc.call(cmd[:usage])
|
|
125
|
+
(cmd[:cmds] || []).each{|k, v|
|
|
126
|
+
cmd_lines << key_proc.call("#{cmd[:key]} #{v[:key]}")
|
|
127
|
+
cmd_lines << desc_proc.call(v[:description])
|
|
128
|
+
cmd_lines << usage_proc.call(v[:usage])
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
cmd_lines
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def self.debug_log(lines)
|
|
135
|
+
Aro::V.say(lines)
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
views/dom.rb
|
|
4
|
+
|
|
5
|
+
the dom view.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require_relative :"./base".to_s
|
|
12
|
+
|
|
13
|
+
module Aos
|
|
14
|
+
module Vi
|
|
15
|
+
class Dom < Aos::Vi::Base
|
|
16
|
+
|
|
17
|
+
def self.show(model)
|
|
18
|
+
lines = []
|
|
19
|
+
lines << I18n.t("aos.views.dom.title")
|
|
20
|
+
lines << I18n.t("aos.views.dom.description")
|
|
21
|
+
lines << ""
|
|
22
|
+
lines << I18n.t("aos.constants.commands")
|
|
23
|
+
Aos::Os::CMDS.keys.sort.each{|cmd|
|
|
24
|
+
lines += lines_for_cmd(Aos::Os::CMDS[cmd])
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
lines << ""
|
|
28
|
+
lines << I18n.t("aos.views.dom.quick_navigation")
|
|
29
|
+
lines << ""
|
|
30
|
+
just = Aro::Mancy::NUMERALS[:XI]
|
|
31
|
+
converter = Proc.new{|layout|
|
|
32
|
+
"#{layout[:name].to_s.ljust(just)} #{layout[:rooms].map{|r| r[:name].to_s.ljust(just)}.join(" ")}"
|
|
33
|
+
}
|
|
34
|
+
lines << converter.call(Aro::Dom::D::LAYOUT[:WELCOME])
|
|
35
|
+
lines << ""
|
|
36
|
+
lines << converter.call(Aro::Dom::D::LAYOUT[:GAMES])
|
|
37
|
+
lines << ""
|
|
38
|
+
lines << converter.call(Aro::Dom::D::LAYOUT[:KNOW])
|
|
39
|
+
lines << ""
|
|
40
|
+
lines << converter.call(Aro::Dom::D::LAYOUT[:SETUP])
|
|
41
|
+
draw(lines, model)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
views/games/abpps.rb
|
|
4
|
+
|
|
5
|
+
the apbbs view.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require_relative :"./game".to_s
|
|
12
|
+
|
|
13
|
+
module Aos
|
|
14
|
+
module Vi
|
|
15
|
+
class Abpps < Aos::Vi::Game
|
|
16
|
+
def self.show(model)
|
|
17
|
+
draw(super, model)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
views/games/deck.rb
|
|
4
|
+
|
|
5
|
+
the deck game view.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require_relative :"../base".to_s
|
|
12
|
+
require_relative :"../../../models/deck".to_s
|
|
13
|
+
|
|
14
|
+
module Aos
|
|
15
|
+
module Vi
|
|
16
|
+
class Deck < Aos::Vi::Base
|
|
17
|
+
|
|
18
|
+
PARAMS = [
|
|
19
|
+
:deck,
|
|
20
|
+
:h_logs,
|
|
21
|
+
:count_n,
|
|
22
|
+
:order_o,
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
def self.show(model)
|
|
26
|
+
self.debug_log(model)
|
|
27
|
+
mk = model.keys
|
|
28
|
+
dp = Aos::Vi::Deck::PARAMS
|
|
29
|
+
return nil unless (mk & dp).count == dp.count
|
|
30
|
+
return nil unless model.values.all?{|v| v != nil}
|
|
31
|
+
|
|
32
|
+
deck = model[:deck]
|
|
33
|
+
h_logs = model[:h_logs]
|
|
34
|
+
count_n = model[:count_n]
|
|
35
|
+
order_o = model[:order_o]
|
|
36
|
+
|
|
37
|
+
dc = CLI::Config.display_config
|
|
38
|
+
width = dc[:WIDTH] = viewport_width
|
|
39
|
+
divider = dc[:DIVIDER] * viewport_width
|
|
40
|
+
lines = []
|
|
41
|
+
lines << divider
|
|
42
|
+
lines << ""
|
|
43
|
+
lines << "#{deck.name.upcase.center(width)}"
|
|
44
|
+
lines << ""
|
|
45
|
+
h_logs.each_with_index{|l, i|
|
|
46
|
+
lines << divider
|
|
47
|
+
lines << l.created_at.strftime(CLI::Config::DATE_FORMAT).center(width)
|
|
48
|
+
lines << "#{order_o.to_sym == Aro::Log::ORDERING[:DESC] ? deck.logs.count - i : 1 + i} of #{deck.logs.count}".rjust(width)
|
|
49
|
+
lines << divider
|
|
50
|
+
lines << ""
|
|
51
|
+
lines << ""
|
|
52
|
+
lines += self.get_display_for_cards(
|
|
53
|
+
Base64::decode64(l.card_data).split(Aro::Deck::CARD_DELIM.to_s)
|
|
54
|
+
)
|
|
55
|
+
lines << divider
|
|
56
|
+
|
|
57
|
+
drawn_cards = Base64::decode64(l.drawn_data).split(Aro::Deck::CARD_DELIM.to_s)
|
|
58
|
+
|
|
59
|
+
if !drawn_cards.nil? && drawn_cards.any?
|
|
60
|
+
lines << I18n.t("cli.messages.history_drawn").center(width)
|
|
61
|
+
lines << divider
|
|
62
|
+
lines << ""
|
|
63
|
+
lines += self.get_display_for_cards(
|
|
64
|
+
drawn_cards
|
|
65
|
+
)
|
|
66
|
+
lines << ""
|
|
67
|
+
lines << divider
|
|
68
|
+
end
|
|
69
|
+
}
|
|
70
|
+
if count_n == Aro::Mancy::S
|
|
71
|
+
draw(lines)
|
|
72
|
+
else
|
|
73
|
+
Aro::P.less(lines.join("\n"))
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def self.get_display_for_cards(input = [])
|
|
78
|
+
columns = CLI::Config.display_config[:COLUMNS].to_i
|
|
79
|
+
lines = []
|
|
80
|
+
card_line = ""
|
|
81
|
+
input.each_with_index{|c, i|
|
|
82
|
+
s = (i + Aro::Mancy::S) % [Aro::Mancy::S, columns].max
|
|
83
|
+
card_line += c.ljust(columns)
|
|
84
|
+
if Aro::Mancy::O == s || i == input.count - Aro::Mancy::S
|
|
85
|
+
lines << card_line
|
|
86
|
+
card_line = ""
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
}
|
|
90
|
+
lines << ""
|
|
91
|
+
lines
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
views/games/game.rb
|
|
4
|
+
|
|
5
|
+
the game view.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require_relative :"../base".to_s
|
|
12
|
+
|
|
13
|
+
module Aos
|
|
14
|
+
module Vi
|
|
15
|
+
class Game < Aos::Vi::Base
|
|
16
|
+
def self.show(model)
|
|
17
|
+
lines = []
|
|
18
|
+
lines << I18n.t("aos.views.game.title").center(viewport_width)
|
|
19
|
+
lines << I18n.t("aos.views.game.description").center(viewport_width)
|
|
20
|
+
lines
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
views/games/hbpps.rb
|
|
4
|
+
|
|
5
|
+
the hpbbs view.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require_relative :"./game".to_s
|
|
12
|
+
|
|
13
|
+
module Aos
|
|
14
|
+
module Vi
|
|
15
|
+
class Hbpps < Aos::Vi::Game
|
|
16
|
+
def self.show(model)
|
|
17
|
+
draw(super, model)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
views/games/shpps.rb
|
|
4
|
+
|
|
5
|
+
the shbbs view.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require_relative :"./game".to_s
|
|
12
|
+
|
|
13
|
+
module Aos
|
|
14
|
+
module Vi
|
|
15
|
+
class Shpps < Aos::Vi::Game
|
|
16
|
+
def self.show(model)
|
|
17
|
+
draw(super, model)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
views/games/vipps.rb
|
|
4
|
+
|
|
5
|
+
the vipps view.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require_relative :"./game".to_s
|
|
12
|
+
|
|
13
|
+
module Aos
|
|
14
|
+
module Vi
|
|
15
|
+
class Vipps < Aos::Vi::Game
|
|
16
|
+
def self.show(model)
|
|
17
|
+
draw(super, model)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|