aro 0.2.0 → 0.2.2
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 +1 -0
- data/Gemfile.lock +3 -2
- data/README.md +1 -1
- data/aro.gemspec +1 -0
- data/bin/aos +2 -2
- data/bin/aro +4 -4
- data/checksums/aro-0.2.1.gem.sha512 +1 -0
- data/checksums/aro-0.2.2.gem.sha512 +1 -0
- data/listen.rb +1 -1
- data/locale/en.amg.yml +44 -0
- data/locale/en.aos.yml +13 -8
- data/locale/en.data.yml +30 -0
- data/locale/en.dom.yml +10 -8
- data/locale/en.usage.yml +22 -22
- data/locale/en.yml +16 -11
- data/sys/aos/amg.rb +184 -0
- data/sys/aos/aos.rb +203 -89
- data/sys/aos/data.rb +117 -0
- data/{db → sys/aos/db}/migrate/1765148774_create_yous.rb +1 -0
- data/sys/aos/db/migrate/1765762724_create_ilibs.rb +22 -0
- data/sys/aos/db/migrate/1765907766_create_ilogs.rb +18 -0
- data/sys/aos/db.rb +44 -25
- data/sys/aos/models/ilib.rb +46 -0
- data/sys/aos/models/ilog.rb +27 -0
- data/sys/aos/models/you.rb +50 -0
- data/sys/aos/vws/base.rb +120 -0
- data/sys/aos/{views → vws}/dom.rb +6 -10
- data/sys/aos/vws/games/abpps.rb +19 -0
- data/sys/aos/{views → vws}/games/game.rb +26 -25
- data/sys/aos/vws/games/hbpps.rb +19 -0
- data/sys/aos/vws/games/shpps.rb +19 -0
- data/sys/aos/vws/games/vipps.rb +19 -0
- data/sys/aos/{views → vws}/games.rb +3 -3
- data/sys/aos/vws/know/body.rb +19 -0
- data/sys/aos/vws/know/mind.rb +19 -0
- data/sys/aos/vws/know/spirit.rb +19 -0
- data/sys/aos/{views → vws}/know.rb +3 -3
- data/sys/aos/vws/root/amg.rb +21 -0
- data/sys/aos/vws/root/config.rb +21 -0
- data/sys/aos/vws/root/data.rb +21 -0
- data/sys/aos/{views/setup.rb → vws/root.rb} +4 -4
- data/sys/aos/vws/welcome/waite.rb +31 -0
- data/sys/aos/{views → vws}/welcome/winner.rb +3 -3
- data/sys/aos/vws/welcome.rb +30 -0
- data/{db/migrate/1763374647_create_decks.rb → sys/aro/db/migrate/1763374647_create_tecks.rb} +5 -5
- data/sys/aro/db/migrate/1763432541_create_tlogs.rb +20 -0
- data/sys/aro/db.rb +16 -15
- data/sys/aro/mancy.rb +4 -3
- data/sys/{models/deck.rb → aro/models/teck.rb} +56 -62
- data/sys/aro/models/tlog.rb +20 -0
- data/sys/aro/v.rb +1 -1
- data/sys/cli/constants.rb +1 -1
- data/sys/cli/dom.rb +1 -1
- data/sys/cli/{deck.rb → teck.rb} +20 -15
- data/sys/cli.rb +12 -12
- data/sys/dom/config.rb +718 -0
- data/sys/dom/d.rb +36 -18
- data/sys/dom/dom.rb +24 -14
- data/sys/reiquire.rb +8 -8
- data/sys/shr/ilib/crs/CMakeLists.txt +12 -0
- data/sys/shr/ilib/crs/compile.sh +5 -0
- data/sys/shr/ilib/crs/crs.c +24 -0
- data/sys/shr/ilib/crs/crs.o +0 -0
- data/sys/shr/ilib/crs/libcrs.so +0 -0
- data/sys/shr/prompt.rb +1 -5
- data/sys/shr/t.rb +14 -8
- data/sys/shr/version.rb +1 -1
- metadata +63 -26
- data/db/migrate/1763432541_create_logs.rb +0 -20
- data/locale/en.cngelog.yml +0 -5
- data/sys/aos/views/base.rb +0 -166
- data/sys/aos/views/games/abpps.rb +0 -21
- data/sys/aos/views/games/hbpps.rb +0 -21
- data/sys/aos/views/games/shpps.rb +0 -21
- data/sys/aos/views/games/vipps.rb +0 -21
- data/sys/aos/views/know/library.rb +0 -19
- data/sys/aos/views/know/temple.rb +0 -19
- data/sys/aos/views/setup/settings.rb +0 -37
- data/sys/aos/views/welcome/waite.rb +0 -19
- data/sys/aos/views/welcome.rb +0 -19
- data/sys/aos/you.rb +0 -19
- data/sys/cli/config.rb +0 -669
- data/sys/models/log.rb +0 -20
data/sys/aos/db.rb
CHANGED
|
@@ -2,30 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
db.rb
|
|
4
4
|
|
|
5
|
-
database for aos
|
|
5
|
+
database for aos.
|
|
6
6
|
|
|
7
7
|
by i2097i
|
|
8
8
|
|
|
9
9
|
=end
|
|
10
10
|
|
|
11
11
|
module Aos
|
|
12
|
-
class Db
|
|
12
|
+
class Db
|
|
13
|
+
include Singleton
|
|
14
|
+
|
|
13
15
|
DATABASE_YML = :"database.yml"
|
|
14
|
-
|
|
15
|
-
SCHEMA_FILE = :"schema.rb"
|
|
16
|
+
GEM_DB_PATH = :"sys/aos/db"
|
|
16
17
|
MIGRATIONS_DIR = :"db/migrate"
|
|
18
|
+
SCHEMA_FILE = :"schema.rb"
|
|
19
|
+
SQL_FILE = :"aos.sql"
|
|
17
20
|
|
|
18
|
-
def
|
|
21
|
+
def self.load(password = nil)
|
|
19
22
|
Aos::Db.configure_logger
|
|
20
23
|
if Aro::Dom.in_arodom?
|
|
21
|
-
set_up_aos
|
|
24
|
+
self.instance.set_up_aos(password)
|
|
22
25
|
else
|
|
23
26
|
Aro::P.say(I18n.t("cli.errors.not_in_aro" , cmd: Aro::Dom.name))
|
|
24
27
|
end
|
|
25
28
|
end
|
|
26
29
|
|
|
27
30
|
def self.configure_logger
|
|
28
|
-
if
|
|
31
|
+
if Aro::Config.ivar(:LOG_AOS_DB).to_s == Aro::Config::BOOLS[:TRUE].to_s
|
|
29
32
|
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
30
33
|
else
|
|
31
34
|
ActiveRecord::Base.logger = nil
|
|
@@ -33,14 +36,16 @@ module Aos
|
|
|
33
36
|
end
|
|
34
37
|
|
|
35
38
|
def self.base_aro_dir
|
|
36
|
-
Aro::Dom.ethergeist_path
|
|
39
|
+
# Aro::Dom.ethergeist_path
|
|
40
|
+
File.join(Aro::Dom.dom_root, Aro::Dom.room_path(:data))
|
|
37
41
|
end
|
|
38
42
|
|
|
39
43
|
def db_config_filepath
|
|
40
|
-
|
|
44
|
+
# intentionally using Aro::Db::DATABASE_YML here
|
|
45
|
+
File.join(Aos::Db.base_aro_dir, Aro::Db::DATABASE_YML.to_s)
|
|
41
46
|
end
|
|
42
47
|
|
|
43
|
-
def set_up_aos
|
|
48
|
+
def set_up_aos(password)
|
|
44
49
|
name = Aro::Dom.ethergeist_name
|
|
45
50
|
return if name.nil?
|
|
46
51
|
|
|
@@ -50,28 +55,42 @@ module Aos
|
|
|
50
55
|
end
|
|
51
56
|
|
|
52
57
|
unless File.exist?(db_config_filepath)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
unless password.nil?
|
|
59
|
+
Aro::D.say("creating database: #{db_config_filepath}")
|
|
60
|
+
# create database config yaml file
|
|
61
|
+
db_file_path = File.join(Aos::Db.base_aro_dir, Aos::Db::SQL_FILE.to_s)
|
|
62
|
+
File.open(db_config_filepath, "w") do |file|
|
|
63
|
+
file.write({
|
|
64
|
+
adapter: :sqlite3.to_s,
|
|
65
|
+
database: db_file_path,
|
|
66
|
+
username: name,
|
|
67
|
+
password: password,
|
|
68
|
+
}.to_yaml)
|
|
69
|
+
end
|
|
70
|
+
else
|
|
71
|
+
Aro::D.say("unable to create database without root password.")
|
|
63
72
|
end
|
|
64
73
|
end
|
|
65
74
|
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
if File.exist?(db_config_filepath)
|
|
76
|
+
connect(name)
|
|
77
|
+
migrate(name)
|
|
78
|
+
else
|
|
79
|
+
Aro::D.say("unable to set up database without root password.")
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def connect(name)
|
|
84
|
+
ActiveRecord::Base.establish_connection(
|
|
85
|
+
YAML.load_file(db_config_filepath)
|
|
86
|
+
)
|
|
68
87
|
end
|
|
69
88
|
|
|
70
89
|
def migrate(name)
|
|
71
|
-
local_migrate_dir = File.join(Aos::Db.base_aro_dir,
|
|
90
|
+
local_migrate_dir = File.join(Aos::Db.base_aro_dir, Aro::Db::MIGRATIONS_DIR.to_s)
|
|
72
91
|
unless Dir.exist?(local_migrate_dir)
|
|
73
92
|
gem_dir = Dir[Gem.loaded_specs[:aro.to_s]&.full_gem_path || '.'].first
|
|
74
|
-
FileUtils.cp_r(File.join(gem_dir,
|
|
93
|
+
FileUtils.cp_r(File.join(gem_dir, Aos::Db::GEM_DB_PATH.to_s), Aos::Db::base_aro_dir)
|
|
75
94
|
end
|
|
76
95
|
|
|
77
96
|
migration_version = Dir["#{local_migrate_dir}/*.rb"].map{|n|
|
|
@@ -79,7 +98,7 @@ module Aos
|
|
|
79
98
|
}.max
|
|
80
99
|
ActiveRecord::MigrationContext.new(local_migrate_dir).migrate(migration_version)
|
|
81
100
|
|
|
82
|
-
filename = File.join(Aos::Db.base_aro_dir,
|
|
101
|
+
filename = File.join(Aos::Db.base_aro_dir, Aro::Db::SCHEMA_FILE.to_s)
|
|
83
102
|
File.open(filename, "w+") do |f|
|
|
84
103
|
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection_pool, f)
|
|
85
104
|
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
ilib.rb
|
|
4
|
+
|
|
5
|
+
aos ilib object.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
# installed lib modules section
|
|
12
|
+
|
|
13
|
+
module CRS
|
|
14
|
+
SO_FILE = :"libcrs.so".to_s
|
|
15
|
+
SO_PATH = File.join(
|
|
16
|
+
Reiquire::GEM_PATH,
|
|
17
|
+
:"sys/shr/ilib/crs".to_s,
|
|
18
|
+
CRS::SO_FILE
|
|
19
|
+
)
|
|
20
|
+
extend FFI::Library
|
|
21
|
+
ffi_lib CRS::SO_PATH
|
|
22
|
+
attach_function :hello, [], :string
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# installed lib modules section
|
|
26
|
+
|
|
27
|
+
class Aos::Ilib < ActiveRecord::Base
|
|
28
|
+
before_create :set_so_path
|
|
29
|
+
|
|
30
|
+
enum :status, [
|
|
31
|
+
:available,
|
|
32
|
+
:installed,
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
def usage
|
|
36
|
+
# todo: each ffi lib should expose a 'usage' method
|
|
37
|
+
CRS.hello.strip
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def set_so_path
|
|
43
|
+
# todo make configurable for other modules
|
|
44
|
+
self.so_path = CRS::SO_PATH
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
ilog.rb
|
|
4
|
+
|
|
5
|
+
aos ilog object.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
module Aos
|
|
12
|
+
class Ilog < ActiveRecord::Base
|
|
13
|
+
belongs_to :you
|
|
14
|
+
|
|
15
|
+
def get_lines
|
|
16
|
+
[
|
|
17
|
+
I18n.t(
|
|
18
|
+
"data.ilogs.display",
|
|
19
|
+
you: self.you.name,
|
|
20
|
+
cmd: self.cmd,
|
|
21
|
+
timestamp: self.created_at.strftime(Aos::Os::DATE_FORMAT),
|
|
22
|
+
pwd: Aos::Os.osify(self.pwd)
|
|
23
|
+
)
|
|
24
|
+
]
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
you.rb
|
|
4
|
+
|
|
5
|
+
aos you object.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
module Aos
|
|
12
|
+
class You < ActiveRecord::Base
|
|
13
|
+
has_many :ilogs
|
|
14
|
+
before_validation :set_pwd
|
|
15
|
+
after_update :clear_aos_display
|
|
16
|
+
|
|
17
|
+
enum :access, [
|
|
18
|
+
:user,
|
|
19
|
+
:root,
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
def generate_ilog(cmd)
|
|
23
|
+
ilogs.create(
|
|
24
|
+
pwd: Aos::Os.osify(pwd),
|
|
25
|
+
cmd: cmd
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def get_lines
|
|
30
|
+
[
|
|
31
|
+
I18n.t(
|
|
32
|
+
"data.yous.display",
|
|
33
|
+
name: name,
|
|
34
|
+
access: Aos::You::accesses[access],
|
|
35
|
+
pwd: Aos::Os.osify(pwd)
|
|
36
|
+
)
|
|
37
|
+
]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def set_pwd
|
|
43
|
+
self.pwd = Dir.pwd if self.pwd.nil?
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def clear_aos_display
|
|
47
|
+
Aos::Os.instance.display_lines = [Aos::Os.osify(pwd, true)]
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
data/sys/aos/vws/base.rb
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
vws/base.rb
|
|
4
|
+
|
|
5
|
+
the base view (abstract).
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
module Aos
|
|
12
|
+
module Vw
|
|
13
|
+
class Base
|
|
14
|
+
BAR = :"".to_s
|
|
15
|
+
COL_POW = Proc.new{|n| n.pow(Aro::Mancy::S.to_f / Aro::Mancy::OS.to_f).to_i}
|
|
16
|
+
MARGIN_V = Aro::Mancy::S
|
|
17
|
+
MARGIN_H = Aro::Mancy::S
|
|
18
|
+
|
|
19
|
+
def self.show
|
|
20
|
+
draw([self.name])
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.draw(body_lines)
|
|
24
|
+
return false unless body_lines.kind_of?(Array)
|
|
25
|
+
lines = []
|
|
26
|
+
dc = Aro::Config.display_configuration
|
|
27
|
+
height = dc[:HEIGHT]
|
|
28
|
+
width = dc[:WIDTH]
|
|
29
|
+
|
|
30
|
+
# top vertical margin
|
|
31
|
+
Aos::Vw::Base::MARGIN_V.times do
|
|
32
|
+
lines << get_body_line("")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# yield => print lines
|
|
36
|
+
body_lines.each{|line|
|
|
37
|
+
lines << get_body_line(line)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
lines += get_aos_display_lines if Aro::Dom.in_arodom?
|
|
41
|
+
|
|
42
|
+
# print everything
|
|
43
|
+
Aos::S.say(lines.join("\n"))
|
|
44
|
+
|
|
45
|
+
# explicitly return true
|
|
46
|
+
true
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.get_aos_display_lines
|
|
50
|
+
# current Aos::Os output
|
|
51
|
+
lines = []
|
|
52
|
+
unless Aos::Os.instance.display_lines.empty?
|
|
53
|
+
dc = Aro::Config.display_configuration
|
|
54
|
+
width = dc[:WIDTH]
|
|
55
|
+
lines << "".center(width)
|
|
56
|
+
display_dim = get_display_dimension
|
|
57
|
+
Aos::Os.instance.display_lines.each{|line|
|
|
58
|
+
lines << line
|
|
59
|
+
}
|
|
60
|
+
lines << "".center(width)
|
|
61
|
+
lines << "v#{Aro::VERSION.to_s}".ljust(width - display_dim.length) + display_dim
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
lines
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def self.get_display_dimension
|
|
68
|
+
"#{self.get_dt.rjust(Aro::Mancy::V)} :<[#{self.get_dimension}]<"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def self.get_dt
|
|
72
|
+
Aro::T.read_dev_tarot.strip[Aro::Mancy::S..]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def self.get_dimension
|
|
76
|
+
(Aro::T.is_dev_tarot? ? Aro::T::DEV_TAROT : Aro::T::RUBY_FACOT)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def self.get_domain
|
|
80
|
+
Aro::Dom.in_arodom? ? Aro::Dom::domain : Aro::Mancy.domain
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def self.get_clock
|
|
84
|
+
Time.now.strftime(Aos::Os::DATE_FORMAT)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def self.viewport_width
|
|
88
|
+
dc = Aro::Config.display_configuration
|
|
89
|
+
width = dc[:WIDTH]
|
|
90
|
+
bar_width = (Aos::Vw::Base::BAR.length * Aro::Mancy::OS)
|
|
91
|
+
h_margin_width = (Aos::Vw::Base::MARGIN_H * Aro::Mancy::OS)
|
|
92
|
+
|
|
93
|
+
(width - (bar_width + h_margin_width))
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def self.get_body_line(line)
|
|
97
|
+
hm = Aos::Vw::Base::MARGIN_H
|
|
98
|
+
bar = Aos::Vw::Base::BAR
|
|
99
|
+
hm_space = " " * Aos::Vw::Base::MARGIN_H
|
|
100
|
+
just = Aro::Config.display_configuration[:WIDTH] - (hm_space.length + bar.length)
|
|
101
|
+
(bar + hm_space + (line || "")).ljust(just) + hm_space + bar
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def self.lines_for_cmd(cmd)
|
|
105
|
+
just_cmds = Aro::Mancy::NUMERALS[:IX]
|
|
106
|
+
lines = []
|
|
107
|
+
lines << "\"#{cmd[:key]}\""
|
|
108
|
+
lines << " => #{cmd[:description]}"
|
|
109
|
+
lines << ""
|
|
110
|
+
lines << "#{" ".rjust(just_cmds)} #{cmd[:usage]}"
|
|
111
|
+
lines << ""
|
|
112
|
+
lines
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def self.debug_log(lines)
|
|
116
|
+
Aro::V.say(lines)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
=begin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
vws/dom.rb
|
|
4
4
|
|
|
5
5
|
the dom view.
|
|
6
6
|
|
|
@@ -11,25 +11,21 @@
|
|
|
11
11
|
require_relative :"./base".to_s
|
|
12
12
|
|
|
13
13
|
module Aos
|
|
14
|
-
module
|
|
15
|
-
class Dom < Aos::
|
|
16
|
-
|
|
17
|
-
def self.show(model)
|
|
14
|
+
module Vw
|
|
15
|
+
class Dom < Aos::Vw::Base
|
|
16
|
+
def self.show
|
|
18
17
|
lines = []
|
|
19
18
|
lines << I18n.t("aos.views.dom.title")
|
|
20
19
|
lines << I18n.t("aos.views.dom.description")
|
|
21
20
|
lines << ""
|
|
22
21
|
lines << I18n.t("aos.constants.commands")
|
|
23
|
-
Aos::Os::CMDS
|
|
24
|
-
lines += lines_for_cmd(Aos::Os::CMDS[cmd])
|
|
25
|
-
}
|
|
26
|
-
|
|
22
|
+
lines += lines_for_cmd(Aos::Os::CMDS[:HELP])
|
|
27
23
|
lines << ""
|
|
28
24
|
lines << I18n.t("aos.views.dom.quick_navigation")
|
|
29
25
|
lines << ""
|
|
30
26
|
lines << " => #{Aro::Dom::D.reserved_words.join(" ")}"
|
|
31
27
|
lines << ""
|
|
32
|
-
draw(lines
|
|
28
|
+
draw(lines)
|
|
33
29
|
end
|
|
34
30
|
end
|
|
35
31
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
=begin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
vws/games/game.rb
|
|
4
4
|
|
|
5
5
|
the game view.
|
|
6
6
|
|
|
@@ -8,21 +8,21 @@
|
|
|
8
8
|
|
|
9
9
|
=end
|
|
10
10
|
|
|
11
|
-
require_relative :"../../../models/
|
|
11
|
+
require_relative :"../../../aro/models/teck".to_s
|
|
12
12
|
require_relative :"../base".to_s
|
|
13
13
|
|
|
14
14
|
module Aos
|
|
15
|
-
module
|
|
16
|
-
class Game < Aos::
|
|
15
|
+
module Vw
|
|
16
|
+
class Game < Aos::Vw::Base
|
|
17
17
|
|
|
18
18
|
DECK_PARAMS = [
|
|
19
|
-
:
|
|
20
|
-
:
|
|
19
|
+
:teck,
|
|
20
|
+
:tlog_records,
|
|
21
21
|
:count_n,
|
|
22
22
|
:order_o,
|
|
23
23
|
]
|
|
24
24
|
|
|
25
|
-
def self.show
|
|
25
|
+
def self.show
|
|
26
26
|
unless Aro::Mancy.game.nil?
|
|
27
27
|
Aro::Mancy.game.show
|
|
28
28
|
return
|
|
@@ -33,47 +33,48 @@ module Aos
|
|
|
33
33
|
lines << I18n.t("aos.views.game.description").center(viewport_width)
|
|
34
34
|
|
|
35
35
|
room_def = Aro::Dom::D::WINGS[:GAMES].values.filter{|gr|
|
|
36
|
-
"#{Aos::
|
|
36
|
+
"#{Aos::Vw.name}::#{gr[:name].to_s.downcase.capitalize}" == self.name
|
|
37
37
|
}.first
|
|
38
38
|
unless room_def.nil?
|
|
39
39
|
lines << I18n.t("aos.views.game.is_the", name: room_def[:name].to_s)
|
|
40
40
|
lines << I18n.t("aos.views.game.designed_for", description: room_def[:description])
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
draw(lines
|
|
43
|
+
draw(lines)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def self.show_game(model)
|
|
47
47
|
mk = model.keys
|
|
48
|
-
dp = Aos::
|
|
48
|
+
dp = Aos::Vw::Game::DECK_PARAMS
|
|
49
49
|
return nil unless (mk & dp).count == dp.count
|
|
50
50
|
return nil unless model.values.all?{|v| v != nil}
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
teck = model[:teck]
|
|
53
|
+
tlog_records = model[:tlog_records]
|
|
54
54
|
count_n = model[:count_n]
|
|
55
55
|
order_o = model[:order_o]
|
|
56
56
|
|
|
57
|
-
dc =
|
|
57
|
+
dc = Aro::Config.display_configuration
|
|
58
58
|
width = count_n == Aro::Mancy::S ? viewport_width : dc[:WIDTH]
|
|
59
59
|
divider = dc[:DIVIDER] * width
|
|
60
60
|
lines = []
|
|
61
|
-
lines <<
|
|
62
|
-
|
|
61
|
+
lines << divider
|
|
62
|
+
lines << "#{teck.name.upcase.center(width)}"
|
|
63
|
+
tlog_records.each_with_index{|l, i|
|
|
63
64
|
lines << divider
|
|
64
65
|
lines << ""
|
|
65
|
-
timestamp = l.created_at.strftime(
|
|
66
|
-
of_text = "#{order_o.to_sym == Aro::
|
|
66
|
+
timestamp = l.created_at.strftime(Aro::Config::DATE_FORMAT)
|
|
67
|
+
of_text = "#{order_o.to_sym == Aro::Tlog::ORDERING[:DESC] ? teck.tlogs.count - i : 1 + i} of #{teck.tlogs.count}"
|
|
67
68
|
lines << of_text.ljust(width - timestamp.length) + timestamp
|
|
68
69
|
lines << divider
|
|
69
|
-
cards = Base64::decode64(l.card_data).split(Aro::
|
|
70
|
+
cards = Base64::decode64(l.card_data).split(Aro::Teck::CARD_DELIM.to_s)
|
|
70
71
|
if !cards.nil? && cards.any?
|
|
71
|
-
lines << ""
|
|
72
|
+
# lines << ""
|
|
72
73
|
lines += self.get_display_for_cards(cards)
|
|
73
|
-
lines << divider
|
|
74
|
+
# lines << divider
|
|
74
75
|
end
|
|
75
76
|
|
|
76
|
-
drawn_cards = Base64::decode64(l.drawn_data).split(Aro::
|
|
77
|
+
drawn_cards = Base64::decode64(l.drawn_data).split(Aro::Teck::CARD_DELIM.to_s)
|
|
77
78
|
if !drawn_cards.nil? && drawn_cards.any?
|
|
78
79
|
lines << ""
|
|
79
80
|
lines << I18n.t("cli.messages.history_drawn").center(width)
|
|
@@ -82,8 +83,8 @@ module Aos
|
|
|
82
83
|
lines += self.get_display_for_cards(
|
|
83
84
|
drawn_cards
|
|
84
85
|
)
|
|
85
|
-
lines << ""
|
|
86
|
-
lines << divider
|
|
86
|
+
# lines << ""
|
|
87
|
+
# lines << divider
|
|
87
88
|
end
|
|
88
89
|
}
|
|
89
90
|
if count_n == Aro::Mancy::S
|
|
@@ -94,8 +95,8 @@ module Aos
|
|
|
94
95
|
end
|
|
95
96
|
|
|
96
97
|
def self.get_display_for_cards(input = [])
|
|
97
|
-
columns = Aos::
|
|
98
|
-
|
|
98
|
+
columns = Aos::Vw::Base::COL_POW.call(
|
|
99
|
+
Aro::Config.display_configuration[:WIDTH].to_i
|
|
99
100
|
)
|
|
100
101
|
lines = []
|
|
101
102
|
return lines unless input.any?
|