aro 0.1.8 → 0.2.0
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/bin/aos +8 -3
- data/bin/aro +5 -2
- data/checksums/aro-0.1.9.gem.sha512 +1 -0
- data/checksums/aro-0.2.0.gem.sha512 +1 -0
- data/db/migrate/1763374647_create_decks.rb +2 -2
- data/listen.rb +1 -1
- data/locale/en.aos.yml +5 -1
- data/locale/en.cards.yml +156 -156
- data/locale/en.cngelog.yml +1 -1
- data/locale/en.dom.yml +42 -0
- data/locale/en.usage.yml +15 -10
- data/locale/en.yml +12 -15
- data/sys/aos/aos.rb +249 -114
- data/sys/aos/db.rb +13 -6
- data/sys/aos/views/base.rb +72 -45
- data/sys/aos/views/dom.rb +1 -10
- data/sys/aos/views/games/game.rb +92 -0
- data/sys/aos/views/setup/settings.rb +3 -16
- data/sys/aos/you.rb +4 -0
- data/sys/aro/db.rb +12 -7
- data/sys/aro/mancy.rb +16 -9
- data/sys/aro/p.rb +2 -2
- data/sys/cli/config.rb +131 -44
- data/sys/cli/constants.rb +3 -3
- data/sys/cli/deck.rb +27 -13
- data/sys/cli/dom.rb +11 -4
- data/sys/dom/d.rb +24 -14
- data/sys/dom/dom.rb +41 -27
- data/sys/dom/p.rb +1 -1
- data/sys/models/deck.rb +25 -12
- data/sys/reiquire.rb +2 -0
- data/sys/shr/prompt.rb +4 -0
- data/sys/shr/t.rb +19 -9
- data/sys/shr/version.rb +2 -4
- metadata +5 -3
- data/sys/aos/views/games/deck.rb +0 -95
data/sys/aos/views/base.rb
CHANGED
|
@@ -13,88 +13,115 @@ require :aro.to_s
|
|
|
13
13
|
module Aos
|
|
14
14
|
module Vi
|
|
15
15
|
class Base
|
|
16
|
-
BAR =
|
|
16
|
+
BAR = :"".to_s
|
|
17
|
+
COL_POW = Proc.new{|n| n.pow(Aro::Mancy::S.to_f / Aro::Mancy::OS.to_f).to_i}
|
|
17
18
|
MARGIN_V = Aro::Mancy::S
|
|
18
19
|
MARGIN_H = Aro::Mancy::S
|
|
19
20
|
|
|
20
21
|
def self.show(model)
|
|
21
|
-
# default view
|
|
22
22
|
draw([self.name], model)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
+
def self.get_json(lines, you = nil)
|
|
26
|
+
{
|
|
27
|
+
body: lines,
|
|
28
|
+
you: you&.to_json,
|
|
29
|
+
domain: self.get_domain,
|
|
30
|
+
clock: self.get_clock,
|
|
31
|
+
dimension: self.get_dimension,
|
|
32
|
+
dev_tarot: self.get_dt,
|
|
33
|
+
}
|
|
34
|
+
end
|
|
35
|
+
|
|
25
36
|
def self.draw(lines, you = nil)
|
|
37
|
+
unless CLI::Config.is_format_text?
|
|
38
|
+
Aos::S.say(self.get_json(lines, you))
|
|
39
|
+
return true
|
|
40
|
+
end
|
|
41
|
+
|
|
26
42
|
return false unless lines.kind_of?(Array)
|
|
27
43
|
|
|
28
44
|
dc = CLI::Config.display_config
|
|
29
45
|
height = dc[:HEIGHT]
|
|
30
46
|
width = dc[:WIDTH]
|
|
31
|
-
divider = dc[:DIVIDER] * width
|
|
32
|
-
|
|
33
|
-
# lines printed
|
|
34
|
-
printed = Aro::Mancy::O
|
|
35
47
|
|
|
36
|
-
|
|
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
|
|
48
|
+
print_aos_div
|
|
41
49
|
|
|
42
50
|
# header
|
|
43
51
|
Aro::Mancy::S.times do |i|
|
|
44
|
-
|
|
45
|
-
Aos::S.say(
|
|
52
|
+
Aos::S.say("".center(width, dc[:DIVIDER]))
|
|
53
|
+
Aos::S.say("".center(width))
|
|
54
|
+
Aos::S.say("\n")
|
|
46
55
|
end
|
|
47
56
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
57
|
+
half = ((width - self.name.length) / Aro::Mancy::OS.to_f).ceil
|
|
58
|
+
domain = self.get_domain
|
|
59
|
+
clock = self.get_clock
|
|
60
|
+
Aos::S.say(
|
|
61
|
+
(
|
|
62
|
+
domain.ljust(half) + self.name.to_s.upcase
|
|
63
|
+
).ljust(width - clock.length) + clock
|
|
64
|
+
)
|
|
51
65
|
|
|
52
66
|
Aro::Mancy::S.times do
|
|
53
|
-
|
|
54
|
-
Aos::S.say(divider)
|
|
67
|
+
Aos::S.say("".center(width, dc[:DIVIDER]))
|
|
55
68
|
end
|
|
56
69
|
|
|
57
70
|
# top vertical margin
|
|
58
71
|
Aos::Vi::Base::MARGIN_V.times do
|
|
59
|
-
|
|
60
|
-
print_regular_line("")
|
|
72
|
+
Aos::S.say(get_body_line(""))
|
|
61
73
|
end
|
|
62
74
|
|
|
63
|
-
# print lines
|
|
75
|
+
# yield => print lines
|
|
64
76
|
lines.each{|line|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
printed += Aro::Mancy::S
|
|
68
|
-
print_regular_line(line)
|
|
77
|
+
Aos::S.say(get_body_line(line))
|
|
69
78
|
}
|
|
70
79
|
|
|
71
|
-
# fill empty space
|
|
72
|
-
while printed < max_lines
|
|
73
|
-
printed += Aro::Mancy::S
|
|
74
|
-
print_regular_line("")
|
|
75
|
-
end
|
|
76
|
-
|
|
77
80
|
# bottom vertical margin
|
|
78
81
|
Aos::Vi::Base::MARGIN_V.times do
|
|
79
|
-
|
|
80
|
-
print_regular_line("")
|
|
82
|
+
Aos::S.say("[#{Aos::Os} v#{Aro::VERSION.to_s}]".center(width))
|
|
81
83
|
end
|
|
82
84
|
|
|
83
85
|
# footer
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
Aro::D.say("invalid printed height: #{height}, printed: #{printed}") if printed != height
|
|
93
|
-
|
|
86
|
+
display_dim = self.get_display_dimension
|
|
87
|
+
Aos::S.say(
|
|
88
|
+
(
|
|
89
|
+
">[#{domain}]>#{Aos::Os::osify(you&.pwd || Dir.pwd)}"
|
|
90
|
+
).ljust(width - display_dim.length) + display_dim
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
print_aos_div
|
|
94
94
|
# explicitly return true
|
|
95
95
|
true
|
|
96
96
|
end
|
|
97
97
|
|
|
98
|
+
def self.get_display_dimension
|
|
99
|
+
"#{self.get_dt.rjust(Aro::Mancy::V)} :<[#{self.get_dimension}]<"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def self.get_dt
|
|
103
|
+
Aro::T.read_dev_tarot.strip[Aro::Mancy::S..]
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def self.get_dimension
|
|
107
|
+
(Aro::T.is_dev_tarot? ? Aro::T::DEV_TAROT : Aro::T::RUBY_FACOT)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def self.get_domain
|
|
111
|
+
Aro::Dom.in_arodom? ? Aro::Dom::domain : Aro::Mancy.domain
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def self.get_clock
|
|
115
|
+
Time.now.strftime(Aos::Os::DATE_FORMAT)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def self.print_aos_div
|
|
119
|
+
Aro::Mancy::S.times do
|
|
120
|
+
Aos::S.say("\n")
|
|
121
|
+
Aos::S.say("".center(CLI::Config.display_config[:WIDTH], "="))
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
98
125
|
def self.viewport_width
|
|
99
126
|
dc = CLI::Config.display_config
|
|
100
127
|
width = dc[:WIDTH]
|
|
@@ -104,12 +131,12 @@ module Aos
|
|
|
104
131
|
(width - (bar_width + h_margin_width))
|
|
105
132
|
end
|
|
106
133
|
|
|
107
|
-
def self.
|
|
134
|
+
def self.get_body_line(line)
|
|
108
135
|
hm = Aos::Vi::Base::MARGIN_H
|
|
109
136
|
bar = Aos::Vi::Base::BAR
|
|
110
137
|
hm_space = " " * Aos::Vi::Base::MARGIN_H
|
|
111
138
|
just = CLI::Config.display_config[:WIDTH] - (hm_space.length + bar.length)
|
|
112
|
-
|
|
139
|
+
(bar + hm_space + (line || "")).ljust(just) + hm_space + bar
|
|
113
140
|
end
|
|
114
141
|
|
|
115
142
|
def self.lines_for_cmd(cmd)
|
data/sys/aos/views/dom.rb
CHANGED
|
@@ -27,17 +27,8 @@ module Aos
|
|
|
27
27
|
lines << ""
|
|
28
28
|
lines << I18n.t("aos.views.dom.quick_navigation")
|
|
29
29
|
lines << ""
|
|
30
|
-
|
|
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])
|
|
30
|
+
lines << " => #{Aro::Dom::D.reserved_words.join(" ")}"
|
|
39
31
|
lines << ""
|
|
40
|
-
lines << converter.call(Aro::Dom::D::LAYOUT[:SETUP])
|
|
41
32
|
draw(lines, model)
|
|
42
33
|
end
|
|
43
34
|
end
|
data/sys/aos/views/games/game.rb
CHANGED
|
@@ -8,15 +8,107 @@
|
|
|
8
8
|
|
|
9
9
|
=end
|
|
10
10
|
|
|
11
|
+
require_relative :"../../../models/deck".to_s
|
|
11
12
|
require_relative :"../base".to_s
|
|
12
13
|
|
|
13
14
|
module Aos
|
|
14
15
|
module Vi
|
|
15
16
|
class Game < Aos::Vi::Base
|
|
17
|
+
|
|
18
|
+
DECK_PARAMS = [
|
|
19
|
+
:deck,
|
|
20
|
+
:h_logs,
|
|
21
|
+
:count_n,
|
|
22
|
+
:order_o,
|
|
23
|
+
]
|
|
24
|
+
|
|
16
25
|
def self.show(model)
|
|
26
|
+
unless Aro::Mancy.game.nil?
|
|
27
|
+
Aro::Mancy.game.show
|
|
28
|
+
return
|
|
29
|
+
end
|
|
30
|
+
|
|
17
31
|
lines = []
|
|
18
32
|
lines << I18n.t("aos.views.game.title").center(viewport_width)
|
|
19
33
|
lines << I18n.t("aos.views.game.description").center(viewport_width)
|
|
34
|
+
|
|
35
|
+
room_def = Aro::Dom::D::WINGS[:GAMES].values.filter{|gr|
|
|
36
|
+
"#{Aos::Vi.name}::#{gr[:name].to_s.downcase.capitalize}" == self.name
|
|
37
|
+
}.first
|
|
38
|
+
unless room_def.nil?
|
|
39
|
+
lines << I18n.t("aos.views.game.is_the", name: room_def[:name].to_s)
|
|
40
|
+
lines << I18n.t("aos.views.game.designed_for", description: room_def[:description])
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
draw(lines, model)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.show_game(model)
|
|
47
|
+
mk = model.keys
|
|
48
|
+
dp = Aos::Vi::Game::DECK_PARAMS
|
|
49
|
+
return nil unless (mk & dp).count == dp.count
|
|
50
|
+
return nil unless model.values.all?{|v| v != nil}
|
|
51
|
+
|
|
52
|
+
deck = model[:deck]
|
|
53
|
+
h_logs = model[:h_logs]
|
|
54
|
+
count_n = model[:count_n]
|
|
55
|
+
order_o = model[:order_o]
|
|
56
|
+
|
|
57
|
+
dc = CLI::Config.display_config
|
|
58
|
+
width = count_n == Aro::Mancy::S ? viewport_width : dc[:WIDTH]
|
|
59
|
+
divider = dc[:DIVIDER] * width
|
|
60
|
+
lines = []
|
|
61
|
+
lines << "#{deck.name.upcase.center(width)}"
|
|
62
|
+
h_logs.each_with_index{|l, i|
|
|
63
|
+
lines << divider
|
|
64
|
+
lines << ""
|
|
65
|
+
timestamp = l.created_at.strftime(CLI::Config::DATE_FORMAT)
|
|
66
|
+
of_text = "#{order_o.to_sym == Aro::Log::ORDERING[:DESC] ? deck.logs.count - i : 1 + i} of #{deck.logs.count}"
|
|
67
|
+
lines << of_text.ljust(width - timestamp.length) + timestamp
|
|
68
|
+
lines << divider
|
|
69
|
+
cards = Base64::decode64(l.card_data).split(Aro::Deck::CARD_DELIM.to_s)
|
|
70
|
+
if !cards.nil? && cards.any?
|
|
71
|
+
lines << ""
|
|
72
|
+
lines += self.get_display_for_cards(cards)
|
|
73
|
+
lines << divider
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
drawn_cards = Base64::decode64(l.drawn_data).split(Aro::Deck::CARD_DELIM.to_s)
|
|
77
|
+
if !drawn_cards.nil? && drawn_cards.any?
|
|
78
|
+
lines << ""
|
|
79
|
+
lines << I18n.t("cli.messages.history_drawn").center(width)
|
|
80
|
+
lines << divider
|
|
81
|
+
lines << ""
|
|
82
|
+
lines += self.get_display_for_cards(
|
|
83
|
+
drawn_cards
|
|
84
|
+
)
|
|
85
|
+
lines << ""
|
|
86
|
+
lines << divider
|
|
87
|
+
end
|
|
88
|
+
}
|
|
89
|
+
if count_n == Aro::Mancy::S
|
|
90
|
+
draw(lines)
|
|
91
|
+
else
|
|
92
|
+
Aro::P.less(lines.join("\n"))
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def self.get_display_for_cards(input = [])
|
|
97
|
+
columns = Aos::Vi::Base::COL_POW.call(
|
|
98
|
+
CLI::Config.display_config[:WIDTH].to_i
|
|
99
|
+
)
|
|
100
|
+
lines = []
|
|
101
|
+
return lines unless input.any?
|
|
102
|
+
card_line = ""
|
|
103
|
+
input.each_with_index{|c, i|
|
|
104
|
+
s = (i + Aro::Mancy::S) % [Aro::Mancy::S, columns].max
|
|
105
|
+
card_line += c.ljust(columns)
|
|
106
|
+
if Aro::Mancy::O == s || i == input.count - Aro::Mancy::S
|
|
107
|
+
lines << card_line
|
|
108
|
+
card_line = ""
|
|
109
|
+
end
|
|
110
|
+
}
|
|
111
|
+
lines << ""
|
|
20
112
|
lines
|
|
21
113
|
end
|
|
22
114
|
end
|
|
@@ -15,27 +15,14 @@ module Aos
|
|
|
15
15
|
class Settings < Aos::Vi::Base
|
|
16
16
|
def self.show(model)
|
|
17
17
|
just_access = Aro::Mancy::NUMERALS[:VI]
|
|
18
|
-
just_key = Aro::Mancy::NUMERALS[:
|
|
18
|
+
just_key = Aro::Mancy::NUMERALS[:XXII]
|
|
19
19
|
just_value = Aro::Mancy::NUMERALS[:VI]
|
|
20
20
|
bullet = ":"
|
|
21
21
|
|
|
22
22
|
# print CLI::Config::DEF
|
|
23
23
|
lines = []
|
|
24
|
-
lines << "CLI::Config::DEF
|
|
25
|
-
lines
|
|
26
|
-
lines << ""
|
|
27
|
-
CLI::Config::DEF.each{|k, deff|
|
|
28
|
-
val = nil
|
|
29
|
-
|
|
30
|
-
if deff[:access] == CLI::Config::DEF_ACCESS[:READ]
|
|
31
|
-
val = CLI::Config.ovar(k)
|
|
32
|
-
else
|
|
33
|
-
val = CLI::Config.ivar(k)
|
|
34
|
-
k = CLI::Config.ivar_k(k)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
lines << "#{deff[:access].to_s.rjust(just_access)}#{bullet} #{k.to_s.ljust(just_key)}=#{val}"
|
|
38
|
-
}
|
|
24
|
+
lines << "<CLI::Config::DEF>"
|
|
25
|
+
lines += CLI::Config.dump_config
|
|
39
26
|
|
|
40
27
|
# print config commands
|
|
41
28
|
lines << ""
|
data/sys/aos/you.rb
CHANGED
data/sys/aro/db.rb
CHANGED
|
@@ -16,13 +16,18 @@ module Aro
|
|
|
16
16
|
MIGRATIONS_DIR = :"db/migrate"
|
|
17
17
|
|
|
18
18
|
def initialize
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
Aro::Db.configure_logger
|
|
20
|
+
if Aro::Mancy.in_aro?
|
|
21
|
+
setup_local_aro
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.configure_logger
|
|
26
|
+
if CLI::Config.ivar(:LOG_ARO_DB).to_s == CLI::Config::BOOLS[:TRUE].to_s
|
|
27
|
+
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
28
|
+
else
|
|
29
|
+
ActiveRecord::Base.logger = nil
|
|
23
30
|
end
|
|
24
|
-
|
|
25
|
-
setup_local_aro
|
|
26
31
|
end
|
|
27
32
|
|
|
28
33
|
def connect(name)
|
|
@@ -43,7 +48,7 @@ module Aro
|
|
|
43
48
|
end
|
|
44
49
|
|
|
45
50
|
def setup_local_aro
|
|
46
|
-
name = Aro::Mancy.
|
|
51
|
+
name = Aro::Mancy.in_aro? ? Aro::Mancy.aro_mancy_name : nil
|
|
47
52
|
return if name.nil?
|
|
48
53
|
|
|
49
54
|
# create local .aro/ directory
|
data/sys/aro/mancy.rb
CHANGED
|
@@ -19,7 +19,8 @@ module Aro
|
|
|
19
19
|
OS = 2
|
|
20
20
|
E = 3
|
|
21
21
|
N = 4
|
|
22
|
-
|
|
22
|
+
V = 5
|
|
23
|
+
PS1 = :">[#{Aro::Mancy.name}]>: "
|
|
23
24
|
NAME_FILE = :".name"
|
|
24
25
|
ARO_FILE = :".aro"
|
|
25
26
|
I2097I = :i2097i
|
|
@@ -59,7 +60,7 @@ module Aro
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
def initialize
|
|
62
|
-
if Aro::Mancy.
|
|
63
|
+
if Aro::Mancy.in_aro? && Aro::Mancy.is_initialized?
|
|
63
64
|
Aro::Mancy.init
|
|
64
65
|
self.game = Aro::Deck.current_deck
|
|
65
66
|
end
|
|
@@ -70,7 +71,7 @@ module Aro
|
|
|
70
71
|
end
|
|
71
72
|
|
|
72
73
|
def self.create(name)
|
|
73
|
-
return false if Aro::Mancy.
|
|
74
|
+
return false if Aro::Mancy.in_aro? || name.nil?
|
|
74
75
|
|
|
75
76
|
# explicitly only allow String/Symbol types for name
|
|
76
77
|
return false unless name.kind_of?(String) || name.kind_of?(Symbol)
|
|
@@ -99,16 +100,22 @@ module Aro
|
|
|
99
100
|
Aro::Db.new
|
|
100
101
|
end
|
|
101
102
|
|
|
102
|
-
def self.start
|
|
103
|
-
Aos.start(:aro)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
103
|
def self.is_initialized?
|
|
107
|
-
Dir.exist?(Aro::Db.base_aro_dir)
|
|
104
|
+
!Aro::Db.base_aro_dir.nil? && Dir.exist?(Aro::Db.base_aro_dir)
|
|
108
105
|
end
|
|
109
106
|
|
|
110
|
-
def self.
|
|
107
|
+
def self.in_aro?
|
|
111
108
|
File.exist?(Aro::Mancy::NAME_FILE.to_s)
|
|
112
109
|
end
|
|
110
|
+
|
|
111
|
+
def self.domain
|
|
112
|
+
"#{Aro::Mancy}#{Aos::Os::A}#{Aro::Mancy.aro_mancy_name}"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def self.aro_mancy_name
|
|
116
|
+
return nil unless Aro::Mancy.in_aro?
|
|
117
|
+
|
|
118
|
+
File.read(Aro::Mancy::NAME_FILE.to_s).strip
|
|
119
|
+
end
|
|
113
120
|
end
|
|
114
121
|
end
|
data/sys/aro/p.rb
CHANGED
|
@@ -14,10 +14,10 @@ require_relative :"./r".to_s
|
|
|
14
14
|
module Aro
|
|
15
15
|
class P < Aro::Prompt
|
|
16
16
|
def self.say(message)
|
|
17
|
-
if
|
|
17
|
+
if Aro::Mancy.in_aro? && !Aro::T.is_dev_tarot?
|
|
18
18
|
Aro::R.say(message)
|
|
19
19
|
else
|
|
20
|
-
Aro::P::p.say("
|
|
20
|
+
Aro::P::p.say("#{Aro::Mancy::PS1}#{message}")
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
end
|