aro 0.2.2 → 0.2.4

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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile.lock +1 -1
  4. data/aro.gemspec +9 -9
  5. data/bin/aos +10 -3
  6. data/bin/aro +26 -13
  7. data/checksums/aro-0.2.3.gem.sha512 +1 -0
  8. data/locale/en.abot.yml +81 -0
  9. data/locale/en.amg.yml +7 -7
  10. data/locale/en.aos.yml +11 -7
  11. data/locale/en.cards.yml +361 -312
  12. data/locale/en.cor.yml +47 -0
  13. data/locale/en.data.yml +3 -3
  14. data/locale/en.dom.yml +15 -13
  15. data/locale/en.flie.yml +29 -0
  16. data/locale/en.usage.yml +103 -63
  17. data/locale/en.yml +5 -49
  18. data/sys/aos/abot.rb +255 -0
  19. data/sys/aos/aos.rb +381 -164
  20. data/sys/aos/cor.rb +770 -0
  21. data/sys/aos/data.rb +3 -3
  22. data/sys/aos/db/migrate/1765148774_create_yous.rb +1 -1
  23. data/sys/aos/db/migrate/1765933985_create_agodos.rb +22 -0
  24. data/sys/aos/db/migrate/1766203888_create_fpxies.rb +18 -0
  25. data/sys/aos/db.rb +15 -17
  26. data/sys/aos/flie.rb +144 -0
  27. data/sys/aos/models/agodo.rb +95 -0
  28. data/sys/aos/models/fpxy.rb +26 -0
  29. data/sys/aos/models/ilog.rb +3 -3
  30. data/sys/aos/models/you.rb +56 -4
  31. data/sys/aos/s.rb +2 -1
  32. data/sys/aos/vws/base.rb +64 -25
  33. data/sys/aos/vws/dom.rb +1 -1
  34. data/sys/aos/vws/games/abot.rb +21 -0
  35. data/sys/aos/vws/games/{game.rb → teck.rb} +35 -28
  36. data/sys/aos/vws/home.rb +23 -0
  37. data/sys/aos/vws/root/config.rb +4 -4
  38. data/sys/aos/vws/root/flie.rb +21 -0
  39. data/sys/aos/vws/welcome.rb +40 -4
  40. data/sys/aro/d.rb +4 -2
  41. data/sys/aro/db.rb +16 -9
  42. data/sys/aro/mancy.rb +16 -20
  43. data/sys/aro/models/base_model.rb +13 -0
  44. data/sys/aro/models/teck.rb +40 -23
  45. data/sys/aro/models/tlog.rb +2 -1
  46. data/sys/aro/p.rb +1 -1
  47. data/sys/aro/r.rb +2 -1
  48. data/sys/aro/v.rb +2 -2
  49. data/sys/cli/constants.rb +5 -10
  50. data/sys/cli/create.rb +3 -4
  51. data/sys/cli/dom.rb +3 -4
  52. data/sys/cli/nterface.rb +15 -9
  53. data/sys/cli/teck.rb +29 -38
  54. data/sys/cli/usage.rb +11 -1
  55. data/sys/cli.rb +7 -9
  56. data/sys/dom/d.rb +38 -29
  57. data/sys/dom/dom.rb +62 -37
  58. data/sys/dom/p.rb +1 -1
  59. data/sys/fpx.rb +104 -0
  60. data/sys/reiquire.rb +3 -2
  61. data/sys/shr/prompt.rb +2 -2
  62. data/sys/shr/t.rb +13 -15
  63. data/sys/shr/version.rb +1 -1
  64. data/tasks/make.rake +1 -1
  65. metadata +54 -43
  66. data/sys/aos/vws/games/abpps.rb +0 -19
  67. data/sys/aos/vws/games/hbpps.rb +0 -19
  68. data/sys/aos/vws/games/shpps.rb +0 -19
  69. data/sys/aos/vws/games/vipps.rb +0 -19
  70. data/sys/dom/config.rb +0 -718
data/sys/aos/vws/dom.rb CHANGED
@@ -23,7 +23,7 @@ module Aos
23
23
  lines << ""
24
24
  lines << I18n.t("aos.views.dom.quick_navigation")
25
25
  lines << ""
26
- lines << " => #{Aro::Dom::D.reserved_words.join(" ")}"
26
+ lines << " => #{Aro::Dom::D.reserved_words(Aos::Os.instance.you.root?).join(" ")}"
27
27
  lines << ""
28
28
  draw(lines)
29
29
  end
@@ -0,0 +1,21 @@
1
+ =begin
2
+
3
+ vws/games/abot.rb
4
+
5
+ the abot view.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ require_relative :"../base".to_s
12
+
13
+ module Aos
14
+ module Vw
15
+ class Abot < Aos::Vw::Base
16
+ def self.show
17
+ draw(Aos::Abot.instance.display_lines)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -13,24 +13,26 @@ require_relative :"../base".to_s
13
13
 
14
14
  module Aos
15
15
  module Vw
16
- class Game < Aos::Vw::Base
16
+ class Teck < Aos::Vw::Base
17
17
 
18
- DECK_PARAMS = [
18
+ TECK_PARAMS = [
19
19
  :teck,
20
20
  :tlog_records,
21
21
  :count_n,
22
22
  :order_o,
23
23
  ]
24
24
 
25
+ DIV_CHAR = :"."
26
+
25
27
  def self.show
26
- unless Aro::Mancy.game.nil?
27
- Aro::Mancy.game.show
28
+ unless Aro::Mancy.teck.nil?
29
+ Aro::Mancy.teck.show
28
30
  return
29
31
  end
30
32
 
31
33
  lines = []
32
- lines << I18n.t("aos.views.game.title").center(viewport_width)
33
- lines << I18n.t("aos.views.game.description").center(viewport_width)
34
+ lines << I18n.t("aos.views.game.title").center(Aos::Vw::Base.viewport_width)
35
+ lines << I18n.t("aos.views.game.description").center(Aos::Vw::Base.viewport_width)
34
36
 
35
37
  room_def = Aro::Dom::D::WINGS[:GAMES].values.filter{|gr|
36
38
  "#{Aos::Vw.name}::#{gr[:name].to_s.downcase.capitalize}" == self.name
@@ -44,32 +46,38 @@ module Aos
44
46
  end
45
47
 
46
48
  def self.show_game(model)
49
+ Aro::Db.load
47
50
  mk = model.keys
48
- dp = Aos::Vw::Game::DECK_PARAMS
51
+ dp = Aos::Vw::Teck::TECK_PARAMS
49
52
  return nil unless (mk & dp).count == dp.count
50
53
  return nil unless model.values.all?{|v| v != nil}
51
54
 
52
55
  teck = model[:teck]
53
56
  tlog_records = model[:tlog_records]
57
+ teck_tlog_count = teck.tlogs.count
54
58
  count_n = model[:count_n]
55
59
  order_o = model[:order_o]
56
60
 
57
- dc = Aro::Config.display_configuration
58
- width = count_n == Aro::Mancy::S ? viewport_width : dc[:WIDTH]
59
- divider = dc[:DIVIDER] * width
61
+ divider = "".ljust(
62
+ Aos::Vw::Base.viewport_width,
63
+ Aos::Vw::Teck::DIV_CHAR.to_s
64
+ )
60
65
  lines = []
61
66
  lines << divider
62
- lines << "#{teck.name.upcase.center(width)}"
67
+ lines << ""
68
+ lines << "#{teck.name.upcase.center(Aos::Vw::Base.viewport_width)}"
63
69
  tlog_records.each_with_index{|l, i|
64
70
  lines << divider
65
71
  lines << ""
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}"
68
- lines << of_text.ljust(width - timestamp.length) + timestamp
72
+ timestamp = l.created_at.strftime(Aos::Cor::DATE_FORMAT)
73
+ of_text = "#{order_o.to_sym == Aro::Tlog::ORDERING[:DESC] ? teck_tlog_count - i : 1 + i} of #{teck_tlog_count}"
74
+ lines << Aos::Vw::Base.get_body_line(
75
+ of_text.ljust(Aos::Vw::Base.viewport_width - timestamp.length - Aro::Mancy::OS) + timestamp
76
+ )
69
77
  lines << divider
70
78
  cards = Base64::decode64(l.card_data).split(Aro::Teck::CARD_DELIM.to_s)
71
79
  if !cards.nil? && cards.any?
72
- # lines << ""
80
+ lines << ""
73
81
  lines += self.get_display_for_cards(cards)
74
82
  # lines << divider
75
83
  end
@@ -77,7 +85,7 @@ module Aos
77
85
  drawn_cards = Base64::decode64(l.drawn_data).split(Aro::Teck::CARD_DELIM.to_s)
78
86
  if !drawn_cards.nil? && drawn_cards.any?
79
87
  lines << ""
80
- lines << I18n.t("cli.messages.history_drawn").center(width)
88
+ lines << I18n.t("cli.messages.history_drawn").center(Aos::Vw::Base.viewport_width)
81
89
  lines << divider
82
90
  lines << ""
83
91
  lines += self.get_display_for_cards(
@@ -95,20 +103,19 @@ module Aos
95
103
  end
96
104
 
97
105
  def self.get_display_for_cards(input = [])
98
- columns = Aos::Vw::Base::COL_POW.call(
99
- Aro::Config.display_configuration[:WIDTH].to_i
100
- )
106
+ return input unless input.any?
107
+ width = Aos::Cor.discon[:WIDTH]
108
+ c_width = Aro::Mancy::NUMERALS[:XI]
109
+ columns = (width / c_width).to_i
101
110
  lines = []
102
- return lines unless input.any?
103
- card_line = ""
104
- input.each_with_index{|c, i|
105
- s = (i + Aro::Mancy::S) % [Aro::Mancy::S, columns].max
106
- card_line += c.ljust(columns)
107
- if Aro::Mancy::O == s || i == input.count - Aro::Mancy::S
108
- lines << card_line
109
- card_line = ""
111
+ while input.any?
112
+ line = []
113
+ columns.times do
114
+ next if input[Aro::Mancy::O].nil?
115
+ line << input.delete_at(Aro::Mancy::O).center(c_width)
110
116
  end
111
- }
117
+ lines << line.join("")
118
+ end
112
119
  lines << ""
113
120
  lines
114
121
  end
@@ -0,0 +1,23 @@
1
+ =begin
2
+
3
+ vws/root/home.rb
4
+
5
+ the home view.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ require_relative :"./base".to_s
12
+
13
+ module Aos
14
+ module Vw
15
+ class Home < Aos::Vw::Base
16
+ def self.show
17
+ if Aos::Os.instance.you.home?
18
+ draw(Aos::Cor.instance.display_lines)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,8 +1,8 @@
1
1
  =begin
2
2
 
3
- vws/root/config.rb
3
+ vws/root/cor.rb
4
4
 
5
- the config view.
5
+ the cor view.
6
6
 
7
7
  by i2097i
8
8
 
@@ -12,9 +12,9 @@ require_relative :"../base".to_s
12
12
 
13
13
  module Aos
14
14
  module Vw
15
- class Config < Aos::Vw::Base
15
+ class Cor < Aos::Vw::Base
16
16
  def self.show
17
- draw(Aro::Config.instance.display_lines)
17
+ draw(Aos::Cor.instance.display_lines)
18
18
  end
19
19
  end
20
20
  end
@@ -0,0 +1,21 @@
1
+ =begin
2
+
3
+ vws/root/flie.rb
4
+
5
+ the flie view.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ require_relative :"../base".to_s
12
+
13
+ module Aos
14
+ module Vw
15
+ class Flie < Aos::Vw::Base
16
+ def self.show
17
+ draw(Aos::Flie.instance.display_lines)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -16,13 +16,49 @@ module Aos
16
16
  def self.show
17
17
  lines = []
18
18
 
19
- dc = Aro::Config.display_configuration
20
- height = dc[:HEIGHT]
19
+ dc = Aos::Cor.discon
21
20
  width = dc[:WIDTH]
22
21
 
23
-
24
22
  lines << "welcome to #{Aro::Dom.ethergeist_name}".center(width)
25
- lines <<
23
+ lines << ""
24
+ hwidth = width - (Aos::Vw::Base::MARGIN_H * Aro::Mancy::OS)
25
+ lines << "".ljust(hwidth, dc[:DIVIDER])
26
+ lines << "map".center(hwidth)
27
+ lines << "".ljust(hwidth, dc[:DIVIDER])
28
+ lines << ""
29
+ yous = Aos::You.where(pwd: Aro::Dom.dom_root)
30
+ dom_line = "#{Aro::Dom.ethergeist_name}"
31
+ dom_line += (yous.any? ? " [#{yous.map{|y| y.name}.join(" ")}]" : "")
32
+ lines << dom_line
33
+ Aro::Dom::D::LAYOUT.values.each{|wing|
34
+ yous = Aos::You.where(pwd: File.join(Aro::Dom.dom_root, wing[:name].to_s))
35
+ wing_line = "".ljust(Aro::Mancy::NUMERALS[:IV])
36
+ wing_line += wing[:name].to_s
37
+ wing_line += (yous.any? ? " [#{yous.map{|y| y.name}.join(" ")}]" : "")
38
+ lines << wing_line
39
+ wing[:rooms].each{|room|
40
+ yous = Aos::You.where(pwd: File.join(Aro::Dom.dom_root, Aro::Dom.room_path(room[:name])))
41
+ room_line = "".ljust(Aro::Mancy::NUMERALS[:VIII])
42
+ room_line += room[:name].to_s
43
+ room_line += (yous.any? ? " [#{yous.map{|y| y.name}.join(" ")}]" : "")
44
+ lines << room_line
45
+ }
46
+ }
47
+ lines << ""
48
+
49
+ yous = Aos::You.order(access: :desc).all
50
+ if yous.empty?
51
+ lines << "no yous."
52
+ else
53
+ lines << "".ljust(hwidth, dc[:DIVIDER])
54
+ lines << "roster".center(hwidth)
55
+ lines << "".ljust(hwidth, dc[:DIVIDER])
56
+ lines << ""
57
+ yous.each{|y|
58
+ next if y.root? && !Aos::Os.instance.you.root?
59
+ lines += y.get_lines.map{|l| l.center(hwidth)}
60
+ }
61
+ end
26
62
  draw(lines)
27
63
  end
28
64
  end
data/sys/aro/d.rb CHANGED
@@ -9,16 +9,18 @@
9
9
  =end
10
10
 
11
11
  require_relative :"../shr/prompt".to_s
12
+ require :aro.to_s
12
13
 
13
14
  module Aro
14
15
  class D < Aro::Prompt
15
16
  def self.say(message)
16
17
  return unless Aro::D.should_print?
17
- Aro::P::p.say(">[#{Aro::Mancy::I2097I}]>: #{message}\n")
18
+ super([">[#{Aro::Mancy::I2097I}]>: #{message}"])
18
19
  end
19
20
 
20
21
  def self.should_print?
21
- Aro::Mancy::ARO_ENV_DEBUG_MODES[Aro::Mancy::O].to_s == ENV[:ARO_ENV.to_s]
22
+ return false unless Aos::Cor.ivar(:ENV).present?
23
+ Aos::Cor::DBG_MODES.include?(Aos::Cor.ivar(:ENV)&.to_sym)
22
24
  end
23
25
  end
24
26
  end
data/sys/aro/db.rb CHANGED
@@ -8,6 +8,9 @@
8
8
 
9
9
  =end
10
10
 
11
+ require_relative :"./mancy".to_s
12
+ require_relative :"../aos/cor".to_s
13
+
11
14
  module Aro
12
15
  class Db
13
16
  include Singleton
@@ -26,7 +29,7 @@ module Aro
26
29
  end
27
30
 
28
31
  def self.configure_logger
29
- if Aro::Config.ivar(:LOG_ARO_DB).to_s == Aro::Config::BOOLS[:TRUE].to_s
32
+ if Aos::Cor.ivar(:LOG_ARO_DB).to_s == Aos::Cor::BOOLS[:TRUE].to_s
30
33
  ActiveRecord::Base.logger = Logger.new(STDOUT)
31
34
  else
32
35
  ActiveRecord::Base.logger = nil
@@ -35,19 +38,22 @@ module Aro
35
38
 
36
39
  def self.base_aro_dir
37
40
  base_aro_file = Aro::Mancy::ARO_FILE.to_s
38
- Aro::Config.is_test? ? "#{base_aro_file}_test" : base_aro_file
41
+ return "#{base_aro_file}_#{Aos::Cor::ENVS[:TEST]}" if Aos::Cor.is_test?
42
+
43
+ base_aro_file
39
44
  end
40
45
 
41
46
  def db_config_filepath
42
- File.join(Aro::Db.base_aro_dir, Aro::Db::DATABASE_YML.to_s)
47
+ @db_config_filepath ||= File.join(Aro::Db.base_aro_dir, Aro::Db::DATABASE_YML.to_s)
43
48
  end
44
49
 
45
50
  def setup_local_aro
46
51
  name = Aro::Mancy.in_aro? ? Aro::Mancy.aro_mancy_name : nil
47
- return if name.nil?
52
+ return if name.nil? || name.to_sym == Aos::Os::CMDS[:ABOT][:key]
48
53
 
49
54
  # create local .aro/ directory
50
55
  unless File.exist?(Aro::Db.base_aro_dir)
56
+ Aro::P.say("creating #{Aro::Mancy::ARO_FILE.to_s} directory...")
51
57
  FileUtils.mkdir(Aro::Db.base_aro_dir)
52
58
  end
53
59
 
@@ -57,18 +63,19 @@ module Aro
57
63
  adapter: :sqlite3.to_s,
58
64
  database: File.join(Aro::Db.base_aro_dir, Aro::Db::SQL_FILE.to_s),
59
65
  username: name,
60
- password: name
66
+ password: name,
67
+ pool: Aos::Os::DB_POOL
61
68
  }.to_yaml
62
69
  File.open(db_config_filepath, "w") do |file|
63
70
  file.write(c)
64
71
  end
65
72
  end
66
73
 
67
- connect(name)
74
+ connect
68
75
  migrate(name)
69
76
  end
70
77
 
71
- def connect(name)
78
+ def connect
72
79
  ActiveRecord::Base.establish_connection(
73
80
  YAML.load_file(db_config_filepath)
74
81
  )
@@ -77,8 +84,8 @@ module Aro
77
84
  def migrate(name)
78
85
  local_migrate_dir = File.join(Aro::Db.base_aro_dir, Aro::Db::MIGRATIONS_DIR.to_s)
79
86
  unless Dir.exist?(local_migrate_dir)
80
- gem_dir = Dir[Gem.loaded_specs[:aro.to_s]&.full_gem_path || '.'].first
81
- FileUtils.cp_r(File.join(gem_dir, Aro::Db::GEM_DB_PATH.to_s), Aro::Db::base_aro_dir)
87
+ gem_dir = Dir[Reiquire::GEM_PATH || '.'].first
88
+ FileUtils.cp_r(File.join(gem_dir, Aro::Db::GEM_DB_PATH.to_s), Aro::Db.base_aro_dir)
82
89
  end
83
90
 
84
91
  migration_version = Dir["#{local_migrate_dir}/*.rb"].map{|n|
data/sys/aro/mancy.rb CHANGED
@@ -12,7 +12,7 @@ module Aro
12
12
  class Mancy
13
13
  include Singleton
14
14
 
15
- attr_accessor :game
15
+ attr_accessor :current
16
16
 
17
17
  O = 0
18
18
  S = 1
@@ -21,14 +21,12 @@ module Aro
21
21
  N = 4
22
22
  V = 5
23
23
  PS1 = :">[#{Aro::Mancy.name}]>: "
24
- NAME_FILE = :".name"
24
+ NAME_FILE = :".aro_space"
25
25
  ARO_FILE = :".aro"
26
26
  I2097I = :i2097i
27
27
  YES = :aroyes
28
28
  ALL = :all
29
29
 
30
- ARO_ENV_DEBUG_MODES = [:development, :test]
31
-
32
30
  NUMERALS = {
33
31
  O: 0,
34
32
  I: 1,
@@ -55,20 +53,16 @@ module Aro
55
53
  XXII: 22,
56
54
  XXXVII: 37,
57
55
  XLII: 42,
56
+ LX: 60,
58
57
  C: 100,
59
58
  MMXCVII: Aro::Mancy::I2097I[Aro::Mancy::S..Aro::Mancy::N].to_i,
60
59
  }
61
60
 
62
- def initialize
61
+ def self.teck
63
62
  if Aro::Mancy.in_aro? && Aro::Mancy.is_initialized?
64
- Aro::Config.instance.load
65
- Aro::Mancy.init
66
- self.game = Aro::Teck.current_teck
63
+ self.instance.current = Aro::Teck.current_teck
67
64
  end
68
- end
69
-
70
- def self.game
71
- Aro::Mancy.instance.game
65
+ self.instance.current
72
66
  end
73
67
 
74
68
  def self.create(name)
@@ -77,7 +71,6 @@ module Aro
77
71
  # explicitly only allow String/Symbol types for name
78
72
  return false unless name.kind_of?(String) || name.kind_of?(Symbol)
79
73
  name = name.to_s.strip
80
-
81
74
  # create the new aro directory and database
82
75
  if !Dir.exist?(name)
83
76
  Aro::P.say(I18n.t("cli.messages.no_tecks"))
@@ -86,18 +79,23 @@ module Aro
86
79
  return false
87
80
  end
88
81
 
89
- # create name file
90
- File.open(File.join(name, Aro::Mancy::NAME_FILE.to_s), "w+") do |file|
91
- file.write(name)
92
- end
93
-
94
82
  Dir.chdir(name) do
83
+ Aos::Cor.instance.load
95
84
  Aro::Mancy.init
96
85
  end
97
86
  return true
98
87
  end
99
88
 
100
89
  def self.init
90
+ unless Aro::Mancy.in_aro? || Aos::Cor.is_test?
91
+ Aro::P.say("init aro running in present directory...")
92
+ new_name = File.basename(Dir.pwd)
93
+ Aro::P.say("echo #{new_name} > #{Aro::Mancy::NAME_FILE.to_s}")
94
+ File.open(Aro::Mancy::NAME_FILE.to_s, "w") do |file|
95
+ file.write(new_name)
96
+ end
97
+ end
98
+
101
99
  Aro::Db.load
102
100
  end
103
101
 
@@ -114,8 +112,6 @@ module Aro
114
112
  end
115
113
 
116
114
  def self.aro_mancy_name
117
- return nil unless Aro::Mancy.in_aro?
118
-
119
115
  File.read(Aro::Mancy::NAME_FILE.to_s).strip
120
116
  end
121
117
  end
@@ -0,0 +1,13 @@
1
+ =begin
2
+
3
+ aro/base_model.rb
4
+
5
+ aro base_model object.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ class Aro::BaseModel < ActiveRecord::Base
12
+
13
+ end
@@ -9,19 +9,20 @@
9
9
  =end
10
10
 
11
11
  require :base64.to_s
12
+ require_relative :"./base_model".to_s
12
13
 
13
14
  class Aro::Teck < ActiveRecord::Base
14
15
  has_many :tlogs
15
16
 
16
- DECK_FILE = :".teck"
17
+ TECK_FILE = :".aro_teck"
17
18
  CARD_DELIM = :","
18
19
 
19
20
  before_create :populate_cards
20
21
  after_commit :generate_log
21
22
 
22
23
  def self.make(new_name)
23
- return nil unless Aro::Mancy.is_initialized?
24
24
  Aro::Db.load
25
+ return nil unless Aro::Mancy.is_initialized?
25
26
  new_teck = Aro::Teck.create(name: new_name)
26
27
  Aro::Teck.select_teck(new_teck) if Aro::Teck.current_teck.nil?
27
28
  new_teck
@@ -32,6 +33,7 @@ class Aro::Teck < ActiveRecord::Base
32
33
  end
33
34
 
34
35
  def populate_cards
36
+ Aro::Db.load
35
37
  self.cards = Aro::Teck.fresh_cards
36
38
  end
37
39
 
@@ -46,6 +48,7 @@ class Aro::Teck < ActiveRecord::Base
46
48
  end
47
49
 
48
50
  def self.display_selection_menu
51
+ Aro::Db.load
49
52
  unless Aro::Teck.any?
50
53
  Aro::P.say(I18n.t("cli.messages.no_tecks"))
51
54
  exit(CLI::EXIT_CODES[:SUCCESS])
@@ -59,14 +62,15 @@ class Aro::Teck < ActiveRecord::Base
59
62
  def self.select_teck(teck)
60
63
  return unless teck.present?
61
64
  Aro::P.say(I18n.t("cli.messages.teck_selected", name: teck.name, room: Aro::Mancy::aro_mancy_name))
62
- File.open(Aro::Teck::DECK_FILE.to_s, "w") do |file|
65
+ File.open(File.join(Aro::Db.base_aro_dir, Aro::Teck::TECK_FILE.to_s), "w") do |file|
63
66
  file.write(teck.id)
64
67
  end
65
68
  end
66
69
 
67
70
  def self.current_teck
68
- if File.exist?(DECK_FILE.to_s)
69
- current_teck_id = File.read(DECK_FILE.to_s)
71
+ Aro::Db.load
72
+ if File.exist?(File.join(Aro::Db.base_aro_dir, TECK_FILE.to_s))
73
+ current_teck_id = File.read(File.join(Aro::Db.base_aro_dir, TECK_FILE.to_s))
70
74
  return Aro::Teck.find_by(id: current_teck_id)
71
75
  end
72
76
  end
@@ -76,14 +80,15 @@ class Aro::Teck < ActiveRecord::Base
76
80
  end
77
81
 
78
82
  def show(count_n: Aro::Mancy::S, order_o: Aro::Tlog::ORDERING[:DESC])
83
+ tlogs_count = tlogs.count
79
84
  unless count_n.kind_of?(Numeric) && count_n.to_i > Aro::Mancy::O
80
85
  if count_n&.to_s&.to_sym == Aro::Mancy::ALL
81
- count_n = tlogs.count
86
+ count_n = tlogs_count
82
87
  else
83
88
  count_n = Aro::Mancy::S
84
89
  end
85
90
  end
86
- count_n = [[Aro::Mancy::S, count_n.to_i].max, tlogs.count].min
91
+ count_n = [[Aro::Mancy::S, count_n.to_i].max, tlogs_count].min
87
92
  Aro::V.say("count_n: #{count_n}")
88
93
  Aro::V.say("order_o: #{order_o}")
89
94
 
@@ -93,17 +98,18 @@ class Aro::Teck < ActiveRecord::Base
93
98
  end
94
99
 
95
100
  # perform query
101
+ Aro::Db.load
96
102
  tlog_records = tlogs.order(created_at: order_o).first(count_n)
97
103
 
98
104
  # todo: this is doing more work than it needs to. needs debugging.
99
105
  # Aro::V.say("tlog_records.count: #{tlog_records.count}")
100
106
 
101
- # for now tests just expect text output
102
- return tlog_records if Aro::Config.is_test?
107
+ # for now tests just expect count
108
+ return tlog_records if Aos::Cor.is_test?
103
109
 
104
110
  Aro::D.say(I18n.t("cli.messages.showing", name: name, count: count_n, order: order_o))
105
111
 
106
- Aos::Vw::Game.show_game({
112
+ Aos::Vw::Teck.show_game({
107
113
  teck: self,
108
114
  tlog_records: tlog_records,
109
115
  count_n: count_n,
@@ -113,24 +119,33 @@ class Aro::Teck < ActiveRecord::Base
113
119
 
114
120
  def explore
115
121
  # allows user to browse each card in the current teck.
116
- answer = Aro::P.p.select(
122
+ answer = Aos::S.p.select(
117
123
  Aro::Mancy::PS1.to_s + I18n.t("cli.messages.choose_card"),
118
124
  # formatted for tty-prompt gem
119
125
  cards.split(Aro::Teck::CARD_DELIM.to_s).map{|c| [I18n.t("cards.#{Aro::Teck.card_strip(c)}.name"), c]}.to_h,
120
- per_page: Aro::Config.display_configuration[:HEIGHT] - Aro::Mancy::S,
126
+ per_page: Aos::Cor.discon[:HEIGHT] - Aro::Mancy::S,
121
127
  cycle: true,
122
128
  default: Aro::Mancy::S
123
129
  )
124
- # {name: "four of swords", tag_list: ["lord of rest from strife", "libra", "jupiter", "introspection", "recuperation", "regain strength", "rest", "solitude", "stability"], reversed_tag_list: ["lord of rest from strife", "libra", "jupiter", "burnt out", "inundated", "need a break", "overwhelmed"], summary: "", reversed_summary: ""}
125
- definition = I18n.t("cards.#{Aro::Teck.card_strip(answer)}")
126
- indent = Aro::Mancy::N
127
- Aro::P.say(definition[:name])
128
- Aro::P.say(definition[:summary])
129
- Aro::P.say("tags:")
130
- definition[:tag_list].sort.each{|tl| Aro::P.say("".rjust(indent) + tl)}
131
- Aro::P.say(definition[:reversed_summary])
132
- Aro::P.say("reverse tags:")
133
- definition[:reversed_tag_list].sort.each{|tl| Aro::P.say("".rjust(indent) + tl)}
130
+
131
+ Aro::Teck.print_card(answer)
132
+ end
133
+
134
+ def self.print_card(card_code)
135
+ card_code = card_code.to_s.upcase
136
+ orientation = "+"
137
+ if card_code.include?("-")
138
+ orientation = "-"
139
+ end
140
+
141
+ definition = I18n.t("cards.#{Aro::Teck.card_strip(card_code)}")
142
+ output = []
143
+ output << orientation + definition[:name]
144
+ output += definition["#{orientation}tags".to_sym].sort
145
+ # todo: add an actual summary
146
+ # Aro::P.say(definition["#{orientation}summary".to_sym])
147
+ width = Aos::Cor.discon[:WIDTH]
148
+ Aro::P.say("#{card_code}\n#{output.map{|l| l.center(width, Aos::Cor.discon[:DIVIDER])}.join("\n")}")
134
149
  end
135
150
 
136
151
  def shuffle
@@ -181,7 +196,7 @@ class Aro::Teck < ActiveRecord::Base
181
196
  # find a card that is not already drawn
182
197
  while sleeps <= sleeps_max && dev_tarot.nil? do
183
198
  # use fallback randomness if /dev/tarot unavailable
184
- if !is_dt_dimension || !File.exist?(Aro::T::DEV_TAROT_FILE.to_s)
199
+ unless Aro::T.is_dev_tarot? && Aro::T.is_dev_tarot_avail?
185
200
  dev_tarot = Aro::T.summon_ruby_facot.split("")
186
201
  else
187
202
  # preferred randomness
@@ -215,6 +230,8 @@ class Aro::Teck < ActiveRecord::Base
215
230
 
216
231
  # insert dev_tarot to drawn
217
232
  drawn_arr << dev_tarot
233
+ Aro::Teck.print_card(dev_tarot)
234
+ Aro::Db.load
218
235
 
219
236
  # update database
220
237
  update(
@@ -11,10 +11,11 @@
11
11
  require_relative :"./teck".to_s
12
12
 
13
13
  class Aro::Tlog < ActiveRecord::Base
14
- belongs_to :teck, :class_name => :"#{Aro::Teck.name}".to_s
14
+ belongs_to :teck
15
15
 
16
16
  ORDERING = {
17
17
  ASC: :asc,
18
18
  DESC: :desc
19
19
  }
20
+
20
21
  end
data/sys/aro/p.rb CHANGED
@@ -17,7 +17,7 @@ module Aro
17
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("#{Aro::Mancy::PS1}#{message}")
20
+ super(["#{Aro::Mancy::PS1}#{message}"])
21
21
  end
22
22
  end
23
23
  end
data/sys/aro/r.rb CHANGED
@@ -12,8 +12,9 @@ require_relative :"../shr/prompt".to_s
12
12
 
13
13
  module Aro
14
14
  class R < Aro::Prompt
15
+ PS1 = :">[#{Aro::T::RUBY_FACOT}]>:"
15
16
  def self.say(message)
16
- Aro::P::p.say(">[#{Aro::T::RUBY_FACOT}]>: #{message}\n")
17
+ super(["#{Aro::R::PS1} #{message}"])
17
18
  end
18
19
  end
19
20
  end