aro 0.1.6 → 0.1.7
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 +16 -7
- data/bin/aro +24 -24
- data/checksums/aro-0.1.6.gem.sha512 +1 -0
- data/listen.rb +10 -0
- data/locale/en.usage.yml +57 -39
- data/locale/en.yml +23 -6
- data/sys/aro/d.rb +25 -0
- data/sys/aro/db.rb +96 -0
- data/sys/aro/mancy.rb +117 -0
- data/sys/aro/p.rb +25 -0
- data/sys/aro/r.rb +20 -0
- data/sys/aro/v.rb +25 -0
- data/sys/aro.rb +15 -0
- data/sys/cli/config.rb +518 -0
- data/sys/cli/constants.rb +53 -0
- data/{bin → sys}/cli/create.rb +6 -4
- data/sys/cli/deck.rb +98 -0
- data/sys/cli/dom.rb +45 -0
- data/sys/cli/nterface.rb +25 -0
- data/{bin → sys}/cli/usage.rb +1 -1
- data/sys/cli.rb +26 -0
- data/sys/dom/d.rb +106 -0
- data/sys/dom/dom.rb +194 -0
- data/sys/dom/p.rb +17 -0
- data/sys/models/deck.rb +212 -0
- data/sys/models/log.rb +10 -0
- data/sys/reiquire.rb +45 -0
- data/{lib/aro → sys/shr}/prompt.rb +11 -3
- data/sys/shr/t.rb +60 -0
- data/sys/shr/version.rb +18 -0
- data/sys/views/base.rb +29 -0
- data/sys/views/dom.rb +27 -0
- data/sys/views/games/deck.rb +97 -0
- data/sys/views/games/menu.rb +27 -0
- data/sys/views/setup/setup.rb +27 -0
- data/tasks/make.rake +2 -2
- metadata +55 -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/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/models/deck.rb
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
require :base64.to_s
|
|
2
|
+
require_relative :"../shr/t".to_s
|
|
3
|
+
|
|
4
|
+
class Aro::Deck < ActiveRecord::Base
|
|
5
|
+
has_many :logs
|
|
6
|
+
|
|
7
|
+
DECK_FILE = :".deck"
|
|
8
|
+
CARD_DELIM = :","
|
|
9
|
+
|
|
10
|
+
before_create :populate_cards
|
|
11
|
+
after_commit :generate_log
|
|
12
|
+
|
|
13
|
+
def self.make(new_name)
|
|
14
|
+
Aro::Db.new
|
|
15
|
+
new_deck = Aro::Deck.create(name: new_name)
|
|
16
|
+
if Aro::Deck.current_deck.nil?
|
|
17
|
+
File.open(Aro::Deck::DECK_FILE.to_s, "w") do |file|
|
|
18
|
+
file.write(new_deck.id)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
new_deck
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.fresh_cards
|
|
25
|
+
I18n.t("cards.index").map{|c| "+#{c}"}.join(Aro::Deck::CARD_DELIM.to_s)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def populate_cards
|
|
29
|
+
self.cards = Aro::Deck.fresh_cards
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def generate_log
|
|
33
|
+
prev_cards = Base64::decode64(logs.last.card_data) if logs.any?
|
|
34
|
+
if prev_cards.present? && prev_cards != cards || prev_cards.nil?
|
|
35
|
+
logs.create(
|
|
36
|
+
card_data: Base64::encode64(cards),
|
|
37
|
+
drawn_data: Base64::encode64(drawn || "")
|
|
38
|
+
)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.display_selection_menu
|
|
43
|
+
unless Aro::Deck.any?
|
|
44
|
+
Aro::P.say(I18n.t("cli.messages.no_decks"))
|
|
45
|
+
exit(CLI::EXIT_CODES[:SUCCESS])
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
selection = Aro::P.p.select("choose a deck:") do |menu|
|
|
49
|
+
Aro::Deck.all.each{|d|
|
|
50
|
+
if d.id == Aro::Deck.current_deck&.id
|
|
51
|
+
menu.default d.id
|
|
52
|
+
end
|
|
53
|
+
menu.choice(d.name, d.id)
|
|
54
|
+
}
|
|
55
|
+
end
|
|
56
|
+
File.open(Aro::Deck::DECK_FILE.to_s, "w") do |file|
|
|
57
|
+
file.write(selection)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def self.current_deck
|
|
62
|
+
if File.exist?(DECK_FILE.to_s)
|
|
63
|
+
current_deck_id = File.read(DECK_FILE.to_s)
|
|
64
|
+
return Aro::Deck.find_by(id: current_deck_id)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def self.card_strip(card)
|
|
69
|
+
card.gsub(/[+-]/, "").strip
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def show(count_n: Aro::Mancy::S, order_o: Aro::Log::ORDERING[:DESC])
|
|
73
|
+
unless count_n.kind_of?(Numeric) && count_n.to_i > Aro::Mancy::O
|
|
74
|
+
if count_n&.to_s&.to_sym == Aro::Mancy::ALL
|
|
75
|
+
count_n = logs.count
|
|
76
|
+
else
|
|
77
|
+
count_n = Aro::Mancy::S
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
count_n = [[Aro::Mancy::S, count_n.to_i].max, logs.count].min
|
|
81
|
+
Aro::V.say("count_n: #{count_n}")
|
|
82
|
+
Aro::V.say("order_o: #{order_o}")
|
|
83
|
+
unless Aro::Log::ORDERING.values.include?(order_o)
|
|
84
|
+
Aro::P.say(I18n.t("cli.warnings.invalid_order"))
|
|
85
|
+
order_o = Aro::Log::ORDERING[:DESC]
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# perform query
|
|
89
|
+
h_logs = logs.order(created_at: order_o).first(count_n)
|
|
90
|
+
|
|
91
|
+
# todo: this is doing more work than it needs to. needs debugging.
|
|
92
|
+
# Aro::V.say("h_logs.count: #{h_logs.count}")
|
|
93
|
+
|
|
94
|
+
# for now tests just expect text output
|
|
95
|
+
return h_logs if CLI::Config.is_test?
|
|
96
|
+
|
|
97
|
+
Aro::P.say(I18n.t("cli.messages.showing", name: name, count: count_n, order: order_o))
|
|
98
|
+
|
|
99
|
+
h_text = Aro::Vi::Deck.generate({
|
|
100
|
+
deck: self,
|
|
101
|
+
h_logs: h_logs,
|
|
102
|
+
count_n: count_n,
|
|
103
|
+
order_o: order_o
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
if count_n == Aro::Mancy::S
|
|
107
|
+
Aro::Vi::Deck.draw(h_text)
|
|
108
|
+
else
|
|
109
|
+
Aro::P.less(h_text)
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def explore
|
|
114
|
+
# allows user to browse each card in the current deck.
|
|
115
|
+
answer = Aro::P.p.select(
|
|
116
|
+
I18n.t("cli.messages.choose_card"),
|
|
117
|
+
# formatted for tty-prompt gem
|
|
118
|
+
cards.split(Aro::Deck::CARD_DELIM.to_s).map{|c| [I18n.t("cards.#{Aro::Deck.card_strip(c)}.name"), c]}.to_h,
|
|
119
|
+
per_page: Aro::Mancy::NUMERALS[:VII],
|
|
120
|
+
cycle: true,
|
|
121
|
+
default: Aro::Mancy::S
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
Aro::P.say(I18n.t("cards.#{Aro::Deck.card_strip(answer)}"))
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def shuffle
|
|
128
|
+
# shuffles the current deck and generates a log record.
|
|
129
|
+
update(cards: cards.split(Aro::Deck::CARD_DELIM.to_s).shuffle.join(Aro::Deck::CARD_DELIM.to_s))
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def reset
|
|
133
|
+
# completely reset the deck. replace all drawn and reset order.
|
|
134
|
+
# all orientations will be set to upright.
|
|
135
|
+
update(cards: Aro::Deck.fresh_cards, drawn: "")
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def replace
|
|
139
|
+
# replaces all drawn cards FIFO and puts them on the bottom of
|
|
140
|
+
# the deck. this will preserve all card orientations.
|
|
141
|
+
cards_arr = cards.split(Aro::Deck::CARD_DELIM.to_s) || []
|
|
142
|
+
drawn_arr = drawn&.split(Aro::Deck::CARD_DELIM.to_s) || []
|
|
143
|
+
|
|
144
|
+
# append each drawn card to cards
|
|
145
|
+
drawn_arr.each{|dc| cards_arr << dc }
|
|
146
|
+
|
|
147
|
+
# clear drawn
|
|
148
|
+
update(drawn: "", cards: cards_arr.join(Aro::Deck::CARD_DELIM.to_s))
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def draw(is_dt_dimension: true, z_max: 7, z: 1)
|
|
152
|
+
# the true card
|
|
153
|
+
abs_dev_tarot = nil
|
|
154
|
+
|
|
155
|
+
# oriented card
|
|
156
|
+
dev_tarot = nil
|
|
157
|
+
|
|
158
|
+
# get cards
|
|
159
|
+
cards_arr = cards.split(Aro::Deck::CARD_DELIM.to_s) || []
|
|
160
|
+
# get abs_cards
|
|
161
|
+
abs_cards_arr = cards_arr.map{|c| Aro::Deck.card_strip(c)}
|
|
162
|
+
# get drawn
|
|
163
|
+
drawn_arr = drawn&.split(Aro::Deck::CARD_DELIM.to_s) || []
|
|
164
|
+
|
|
165
|
+
sleeps = 0
|
|
166
|
+
sleeps_max = z_max
|
|
167
|
+
|
|
168
|
+
# find a card that is not already drawn
|
|
169
|
+
while sleeps <= sleeps_max && dev_tarot.nil? do
|
|
170
|
+
# use fallback randomness if /dev/tarot unavailable
|
|
171
|
+
if !is_dt_dimension || !File.exist?(Aro::T::DEV_TAROT_FILE.to_s)
|
|
172
|
+
dev_tarot = Aro::T.summon_ruby_facot(cards_arr).split("")
|
|
173
|
+
else
|
|
174
|
+
# preferred randomness
|
|
175
|
+
read_value = Aro::T.read_dev_tarot&.strip&.split("")
|
|
176
|
+
if read_value.count >= Aro::Mancy::N - 1
|
|
177
|
+
dev_tarot = read_value
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
unless dev_tarot.nil?
|
|
182
|
+
abs_dev_tarot = dev_tarot[Aro::Mancy::S] + Aro::Mancy::NUMERALS.key(
|
|
183
|
+
dev_tarot.join("")[Aro::Mancy::OS..].to_i
|
|
184
|
+
).to_s
|
|
185
|
+
if abs_cards_arr.include?(abs_dev_tarot)
|
|
186
|
+
# dev_tarot is valid
|
|
187
|
+
dev_tarot = dev_tarot[Aro::Mancy::O] + abs_dev_tarot
|
|
188
|
+
else
|
|
189
|
+
dev_tarot = nil
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
if dev_tarot.nil?
|
|
194
|
+
# dev_tarot is invalid
|
|
195
|
+
sleeps += 1
|
|
196
|
+
sleep(z.to_i)
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
# remove from cards
|
|
201
|
+
cards_arr.delete(cards_arr.select{|c| c.include?(abs_dev_tarot)}.first)
|
|
202
|
+
|
|
203
|
+
# insert dev_tarot to drawn
|
|
204
|
+
drawn_arr << dev_tarot
|
|
205
|
+
|
|
206
|
+
# update database
|
|
207
|
+
update(
|
|
208
|
+
cards: cards_arr.join(Aro::Deck::CARD_DELIM.to_s),
|
|
209
|
+
drawn: drawn_arr.join(Aro::Deck::CARD_DELIM.to_s)
|
|
210
|
+
)
|
|
211
|
+
end
|
|
212
|
+
end
|
data/sys/models/log.rb
ADDED
data/sys/reiquire.rb
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
reiquire.rb
|
|
4
|
+
|
|
5
|
+
ruby require helpers.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
# dependencies
|
|
12
|
+
require :active_record.to_s
|
|
13
|
+
require :"active_record/schema_dumper".to_s
|
|
14
|
+
require :base64.to_s
|
|
15
|
+
require :fileutils.to_s
|
|
16
|
+
require :i18n.to_s
|
|
17
|
+
require :"tty-prompt".to_s
|
|
18
|
+
require :yaml.to_s
|
|
19
|
+
|
|
20
|
+
module Reiquire
|
|
21
|
+
def self.aro
|
|
22
|
+
locale_path = Gem.loaded_specs[:aro.to_s]&.full_gem_path
|
|
23
|
+
# if CLI::Config.is_test?
|
|
24
|
+
# locale_path = Dir.pwd
|
|
25
|
+
# end
|
|
26
|
+
|
|
27
|
+
I18n.load_path += Dir["#{locale_path}/locale/*.yml"]
|
|
28
|
+
I18n.available_locales = [:en]
|
|
29
|
+
I18n.default_locale = :en
|
|
30
|
+
|
|
31
|
+
# require all aro folders
|
|
32
|
+
Reiquire::requires [:aro, :cli, :dom, :models, :shr, :views]
|
|
33
|
+
|
|
34
|
+
# require cli module
|
|
35
|
+
require_relative :"./cli".to_s
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.requires(dirs)
|
|
39
|
+
dirs.each{|d|
|
|
40
|
+
Dir[
|
|
41
|
+
File.join(__dir__, d.to_s, :"**/*.rb".to_s)
|
|
42
|
+
].each { |f| require f}
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
prompt.rb
|
|
4
|
+
|
|
5
|
+
base logger for aro.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
2
10
|
|
|
3
11
|
module Aro
|
|
4
|
-
class
|
|
12
|
+
class Prompt
|
|
5
13
|
include Singleton
|
|
6
14
|
|
|
7
15
|
attr_accessor :prompt
|
|
@@ -15,7 +23,7 @@ module Aro
|
|
|
15
23
|
end
|
|
16
24
|
|
|
17
25
|
def self.say(message)
|
|
18
|
-
|
|
26
|
+
raise :override_me.to_s
|
|
19
27
|
end
|
|
20
28
|
|
|
21
29
|
def self.less(display_text = "")
|
data/sys/shr/t.rb
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
t.rb
|
|
4
|
+
|
|
5
|
+
tarot.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
module Aro
|
|
12
|
+
module T
|
|
13
|
+
DEV_TAROT_FILE = :"/dev/tarot"
|
|
14
|
+
|
|
15
|
+
RUBY_FACOT = :"Ruby::Facot".to_s
|
|
16
|
+
|
|
17
|
+
def self.is_dev_tarot?
|
|
18
|
+
CLI::Config.ivar(:DIMENSION)&.to_sym == CLI::Config::DMS[:DEV_TAROT]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# read dev_tarot
|
|
22
|
+
def self.read_dev_tarot
|
|
23
|
+
dt = nil
|
|
24
|
+
return dt unless File.exist?(Aro::T::DEV_TAROT_FILE.to_s)
|
|
25
|
+
|
|
26
|
+
File.open(Aro::T::DEV_TAROT_FILE.to_s, "r"){|dtf| dt = dtf.read(Aro::Mancy::N)}
|
|
27
|
+
|
|
28
|
+
# VERY IMPORTANT!
|
|
29
|
+
Aro::P.say(I18n.t("cli.very_important", dev_tarot: dt))
|
|
30
|
+
return dt
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# summon ruby_facot
|
|
34
|
+
def self.summon_ruby_facot(cards_arr)
|
|
35
|
+
Aro::P.say(I18n.t("cli.messages.ruby_facot_random"))
|
|
36
|
+
ruby_facot = cards_arr.sample.split("")
|
|
37
|
+
|
|
38
|
+
# get orientation
|
|
39
|
+
ruby_facot_str = ["+","-"].sample
|
|
40
|
+
|
|
41
|
+
# get suite
|
|
42
|
+
ruby_facot_str += ruby_facot[1]
|
|
43
|
+
|
|
44
|
+
# calculate the sym
|
|
45
|
+
symm = ruby_facot.select{|c|
|
|
46
|
+
# loops through the characters in ruby_facot
|
|
47
|
+
# return all characters not matching:
|
|
48
|
+
# => character[0]: orientation
|
|
49
|
+
# => character[1]: suite
|
|
50
|
+
|
|
51
|
+
# the first two characters in the dev_tarot format designate the
|
|
52
|
+
!ruby_facot.first(Aro::Mancy::OS).include?(c)
|
|
53
|
+
}.join("").to_sym
|
|
54
|
+
ruby_facot_str += Aro::Mancy::NUMERALS[symm].to_s
|
|
55
|
+
|
|
56
|
+
# return ruby_facot_str
|
|
57
|
+
ruby_facot_str
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
data/sys/shr/version.rb
ADDED
data/sys/views/base.rb
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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 Aro
|
|
14
|
+
module Vi
|
|
15
|
+
class Base
|
|
16
|
+
def self.generate(model)
|
|
17
|
+
CLI::Nterface.exit_error_invalid_usage!
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.draw(model)
|
|
21
|
+
CLI::Nterface.exit_error_invalid_usage!
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.debug_log(model)
|
|
25
|
+
Aro::V.say(model)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/sys/views/dom.rb
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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 Aro
|
|
14
|
+
module Vi
|
|
15
|
+
class Dom < Aro::Vi::Base
|
|
16
|
+
def self.generate(model)
|
|
17
|
+
# todo: implement this
|
|
18
|
+
CLI::Nterface.exit_error_invalid_usage!
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.draw(model)
|
|
22
|
+
# todo: implement this
|
|
23
|
+
CLI::Nterface.exit_error_invalid_usage!
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,97 @@
|
|
|
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 Aro
|
|
15
|
+
module Vi
|
|
16
|
+
class Deck < Aro::Vi::Base
|
|
17
|
+
|
|
18
|
+
PARAMS = [
|
|
19
|
+
:deck,
|
|
20
|
+
:h_logs,
|
|
21
|
+
:count_n,
|
|
22
|
+
:order_o,
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
def self.generate(model)
|
|
26
|
+
self.debug_log(model)
|
|
27
|
+
mk = model.keys
|
|
28
|
+
dp = Aro::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]
|
|
39
|
+
divider = dc[:DIVIDER] * width
|
|
40
|
+
result = "\n"
|
|
41
|
+
result += divider + "\n\n"
|
|
42
|
+
result += "#{deck.name.upcase.center(width)}\n\n"
|
|
43
|
+
h_logs.each_with_index{|l, i|
|
|
44
|
+
result += divider + "\n"
|
|
45
|
+
result += l.created_at.strftime(CLI::Config::DATE_FORMAT).center(width) + "\n"
|
|
46
|
+
result += "#{order_o.to_sym == Aro::Log::ORDERING[:DESC] ? deck.logs.count - i : 1 + i} of #{deck.logs.count}".rjust(width) + "\n"
|
|
47
|
+
result += divider + "\n\n"
|
|
48
|
+
result += self.get_display_for_cards(
|
|
49
|
+
Base64::decode64(l.card_data).split(Aro::Deck::CARD_DELIM.to_s)
|
|
50
|
+
)
|
|
51
|
+
result += divider + "\n"
|
|
52
|
+
|
|
53
|
+
drawn_cards = Base64::decode64(l.drawn_data).split(Aro::Deck::CARD_DELIM.to_s)
|
|
54
|
+
|
|
55
|
+
if !drawn_cards.nil? && drawn_cards.any?
|
|
56
|
+
result += I18n.t("cli.messages.history_drawn").center(width) + "\n"
|
|
57
|
+
result += divider + "\n\n"
|
|
58
|
+
result += self.get_display_for_cards(
|
|
59
|
+
drawn_cards
|
|
60
|
+
)
|
|
61
|
+
result += "\n"
|
|
62
|
+
result += divider + "\n"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
Aro::Mancy::OS.times do
|
|
66
|
+
result += divider + "\n"
|
|
67
|
+
end
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
result
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def self.get_display_for_cards(input = [])
|
|
74
|
+
columns = CLI::Config.display_config[:COLUMNS].to_i
|
|
75
|
+
result = ""
|
|
76
|
+
input.each_with_index{|c, i|
|
|
77
|
+
|
|
78
|
+
s = (i + Aro::Mancy::S) % [Aro::Mancy::S, columns].max
|
|
79
|
+
o = Aro::Mancy::O == s
|
|
80
|
+
if i == I18n.t("cards.index").count - Aro::Mancy::S
|
|
81
|
+
result += c.ljust(columns)
|
|
82
|
+
else
|
|
83
|
+
result += c.ljust(columns) + (o ? "\n" : "")
|
|
84
|
+
end
|
|
85
|
+
}
|
|
86
|
+
result += "\n"
|
|
87
|
+
result
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def self.draw(model)
|
|
91
|
+
return false unless model.kind_of?(String)
|
|
92
|
+
|
|
93
|
+
Aro::P.say(model)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
views/games/menu.rb
|
|
4
|
+
|
|
5
|
+
the game menu view.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require_relative :"../base".to_s
|
|
12
|
+
|
|
13
|
+
module Aro
|
|
14
|
+
module Vi
|
|
15
|
+
class Menu < Aro::Vi::Base
|
|
16
|
+
def self.generate(model)
|
|
17
|
+
# todo: implement this
|
|
18
|
+
CLI::Nterface.exit_error_invalid_usage!
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.draw(model)
|
|
22
|
+
# todo: implement this
|
|
23
|
+
CLI::Nterface.exit_error_invalid_usage!
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
views/setup/setup.rb
|
|
4
|
+
|
|
5
|
+
the setup view.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require_relative :"../base".to_s
|
|
12
|
+
|
|
13
|
+
module Aro
|
|
14
|
+
module Vi
|
|
15
|
+
class Setup < Aro::Vi::Base
|
|
16
|
+
def self.generate(model)
|
|
17
|
+
# todo: implement this
|
|
18
|
+
CLI::Nterface.exit_error_invalid_usage!
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.draw(model)
|
|
22
|
+
# todo: implement this
|
|
23
|
+
CLI::Nterface.exit_error_invalid_usage!
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
data/tasks/make.rake
CHANGED