aro 0.1.8 → 0.1.9

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.
data/sys/cli/deck.rb CHANGED
@@ -13,11 +13,11 @@ module CLI
13
13
  def self.deck
14
14
  action = CLI::ARGV1&.to_sym
15
15
 
16
- if CLI::FLAGS[:HELP].include?(CLI::ARGV1)
16
+ if CLI::FLAGS[:HELP].include?(action.to_s)
17
17
  # todo: breakout usage into subcommand-specific verbiage
18
18
  CLI.usage::usage
19
19
  exit(CLI::EXIT_CODES[:SUCCESS])
20
- elsif CLI::ARGV1.nil?
20
+ elsif action.nil? || action == :aos
21
21
  # no args, open deck menu
22
22
  Aro::Db.new
23
23
  Aro::Deck.display_selection_menu
@@ -51,7 +51,7 @@ module CLI
51
51
  Aro::P.say(I18n.t("cli.messages.replacing_drawn", name: Aro::Mancy.game.name))
52
52
  Aro::Mancy.game.replace
53
53
  when CLI::CMDS[:DECK][:RESET]
54
- if Aro::Mancy::YES.to_s != Aro::P.p.ask(I18n.t("cli.messages.confirmation_prompt", name: Aro::Mancy.game.name))
54
+ if Aro::Mancy::YES.to_s != Aro::P.p.ask("#{Aro::Mancy::PS1}#{I18n.t("cli.messages.confirmation_prompt", name: Aro::Mancy.game.name)}")
55
55
  Aro::P.say(I18n.t("cli.messages.understood", name: Aro::Mancy.game.name))
56
56
  exit(CLI::EXIT_CODES[:SUCCESS])
57
57
  end
@@ -60,6 +60,11 @@ module CLI
60
60
  Aro::Mancy.game.reset
61
61
  end
62
62
 
63
+ if ARGV.include?(:aos.to_s)
64
+ # run silent
65
+ exit(CLI::EXIT_CODES[:SUCCESS])
66
+ end
67
+
63
68
  Aro::Mancy.game.show(**CLI::shoptions)
64
69
  end
65
70
  end
@@ -70,23 +75,23 @@ module CLI
70
75
  show_options_count = Aro::Mancy::S
71
76
  show_options_order = Aro::Log::ORDERING[:DESC]
72
77
 
73
- # Aro::P.say("ARGV.map{|a| a.to_sym} => #{ARGV.map{|a| a.to_sym}}")
78
+ # Aro::D.say("ARGV.map{|a| a.to_sym} => #{ARGV.map{|a| a.to_sym}}")
74
79
 
75
80
  count_option_flags = ARGV.map{|a| a.to_sym} & CLI::FLAGS[:SHOW_COUNT]
76
- # Aro::P.say("count_option_flags: #{count_option_flags}")
81
+ # Aro::D.say("count_option_flags: #{count_option_flags}")
77
82
  if count_option_flags.any?
78
83
  # get the ARGV index element after flag index
79
84
  show_options_count = ARGV[ARGV.index(count_option_flags.first.to_s) + 1]
80
85
  show_options_count = show_options_count.to_i unless [0, nil].include?(show_options_count&.to_i)
81
- # Aro::P.say("show_options_count: #{show_options_count}")
86
+ # Aro::D.say("show_options_count: #{show_options_count}")
82
87
  end
83
88
 
84
89
  order_option_flags = ARGV.map{|a| a.to_sym} & CLI::FLAGS[:SHOW_ORDER]
85
- # Aro::P.say("count_option_flags: #{order_option_flags}")
90
+ # Aro::D.say("count_option_flags: #{order_option_flags}")
86
91
  if order_option_flags.any?
87
92
  # get the ARGV index element after flag index
88
93
  show_options_order = ARGV[ARGV.index(order_option_flags.first.to_s) + 1].to_sym
89
- Aro::P.say("show_options_order: #{show_options_order}")
94
+ # Aro::D.say("show_options_order: #{show_options_order}")
90
95
  end
91
96
 
92
97
  {
data/sys/cli/dom.rb CHANGED
@@ -22,13 +22,20 @@ module CLI
22
22
 
23
23
  case action
24
24
  when CLI::CMDS[:DOM][:INIT]
25
- arodome = Aro::Dom.new
26
- arodome.generate
25
+ if Aro::Dom.is_initialized?
26
+ Aro::P.say(I18n.t("dom.errors.failed_already_initialized"))
27
+ elsif Aro::Dom.in_arodom? && !Aro::Dom.is_initialized?
28
+ arodome = Aro::Dom.new
29
+ arodome.generate
30
+ else
31
+ CLI::Nterface.exit_error_invalid_usage!
32
+ end
27
33
  when CLI::CMDS[:DOM][:NEW]
28
34
  CLI::Nterface.exit_error_missing_args! if CLI::ARGV2.nil?
29
35
  if Aro::Dom.in_arodom?
30
- # todo: i18n
31
- Aro::P.say("unable to create an arodome because you are already in arodom.")
36
+ Aro::P.say(I18n.t("dom.errors.failed_already_in_arodom"))
37
+ elsif Aro::Mancy.in_aro?
38
+ Aro::P.say(I18n.t("dom.errors.failed_in_aro_space"))
32
39
  else
33
40
  Aro::Dom.create(CLI::ARGV2.to_s)
34
41
  end
data/sys/dom/d.rb CHANGED
@@ -12,50 +12,60 @@ require_relative :dom.to_s
12
12
 
13
13
  module Aro
14
14
  class Dom::D
15
- # definition of rooms in each layout section
15
+ def self.reserved_words
16
+ reserved = []
17
+ Aro::Dom::D::LAYOUT.values.each{|wing|
18
+ reserved << wing[:name].to_s
19
+ wing[:rooms].each{|room| reserved << room[:name].to_s}
20
+ }
21
+
22
+ reserved.sort
23
+ end
24
+
25
+ # definition of rooms in each layout wing
16
26
  WINGS = {
17
27
  WELCOME: {
18
28
  WAITE: {
19
29
  name: Aro::Dom::WAITE,
20
- description: "sign up."
30
+ description: I18n.t("dom.rooms.waite.description"),
21
31
  },
22
32
  WINNER: {
23
33
  name: Aro::Dom::WINNER,
24
- description: "win."
34
+ description: I18n.t("dom.rooms.winner.description"),
25
35
  },
26
36
  },
27
37
  GAMES: {
28
38
  ABPPS: {
29
39
  name: Aro::Dom::ABPPS,
30
- description: "artificial beings."
40
+ description: I18n.t("dom.rooms.abpps.description"),
31
41
  },
32
42
  HBPPS: {
33
43
  name: Aro::Dom::HBPPS,
34
- description: "human beings."
44
+ description: I18n.t("dom.rooms.hbpps.description"),
35
45
  },
36
46
  SHPPS: {
37
47
  name: Aro::Dom::SHPPS,
38
- description: "human and artificial beings."
48
+ description: I18n.t("dom.rooms.shpps.description"),
39
49
  },
40
50
  VIPPS: {
41
51
  name: Aro::Dom::VIPPS,
42
- description: "very important - 100% /dev/tarot users."
52
+ description: I18n.t("dom.rooms.vipps.description"),
43
53
  },
44
54
  },
45
55
  KNOW: {
46
56
  LIBRARY: {
47
57
  name: Aro::Dom::LIBRARY,
48
- description: "definition management."
58
+ description: I18n.t("dom.rooms.library.description"),
49
59
  },
50
60
  TEMPLE: {
51
61
  name: Aro::Dom::TEMPLE,
52
- description: "mindfulness management."
62
+ description: I18n.t("dom.rooms.temple.description"),
53
63
  },
54
64
  },
55
65
  SETUP: {
56
66
  SETTINGS: {
57
67
  name: Aro::Dom::SETTINGS,
58
- description: "user settings and configuration."
68
+ description: I18n.t("dom.rooms.settings.description"),
59
69
  },
60
70
  },
61
71
  }
@@ -64,7 +74,7 @@ module Aro
64
74
  LAYOUT = {
65
75
  WELCOME: {
66
76
  name: Aro::Dom::WELCOME,
67
- description: "sign up process.",
77
+ description: I18n.t("dom.wings.welcome.description"),
68
78
  rooms: [
69
79
  Aro::Dom::D::WINGS[:WELCOME][:WAITE],
70
80
  Aro::Dom::D::WINGS[:WELCOME][:WINNER],
@@ -72,7 +82,7 @@ module Aro
72
82
  },
73
83
  GAMES: {
74
84
  name: Aro::Dom::GAMES,
75
- description: "aroflie game rooms.",
85
+ description: I18n.t("dom.wings.games.description"),
76
86
  rooms: [
77
87
  Aro::Dom::D::WINGS[:GAMES][:ABPPS],
78
88
  Aro::Dom::D::WINGS[:GAMES][:HBPPS],
@@ -82,7 +92,7 @@ module Aro
82
92
  },
83
93
  KNOW: {
84
94
  name: Aro::Dom::KNOW,
85
- description: "information space.",
95
+ description: I18n.t("dom.wings.know.description"),
86
96
  rooms: [
87
97
  Aro::Dom::D::WINGS[:KNOW][:LIBRARY],
88
98
  Aro::Dom::D::WINGS[:KNOW][:TEMPLE]
@@ -90,7 +100,7 @@ module Aro
90
100
  },
91
101
  SETUP: {
92
102
  name: Aro::Dom::SETUP,
93
- description: "user configuration space.",
103
+ description: I18n.t("dom.wings.setup.description"),
94
104
  rooms: [
95
105
  Aro::Dom::D::WINGS[:SETUP][:SETTINGS]
96
106
  ],
data/sys/dom/dom.rb CHANGED
@@ -12,48 +12,47 @@ require_relative :"../aos/s".to_s
12
12
 
13
13
  module Aro
14
14
  class Dom
15
- PS1 = Aro::Dom.name
15
+ PS1 = :">[#{Aro::Dom.name}]>: "
16
16
  DOT = :"."
17
17
  DOTT = :"#{DOT}#{DOT}"
18
18
  ETHERGEIST = :ethergeist
19
19
  ETHER_FILE = :".#{Aro::Dom::ETHERGEIST}"
20
20
 
21
- # < root found_space
21
+ # < root space
22
22
  ARODOME = :arodome
23
23
 
24
- # < user found_spaces
24
+ # < user spaces
25
25
  WELCOME = :welcome
26
26
  GAMES = :games
27
27
  KNOW = :know
28
28
  SETUP = :setup
29
29
 
30
- # > welcome found_spaces
30
+ # > welcome spaces
31
31
  WAITE = :waite
32
32
  WINNER = :winner
33
33
 
34
- # > game found_spaces
34
+ # > game spaces
35
35
  ABPPS = :abpps
36
36
  HBPPS = :hbpps
37
37
  SHPPS = :shpps
38
38
  VIPPS = :vipps
39
39
 
40
- # > know found_spaces
40
+ # > know spaces
41
41
  LIBRARY = :library
42
42
  TEMPLE = :temple
43
43
  # ...
44
44
 
45
- # > setup found_spaces
45
+ # > setup spaces
46
46
  SETTINGS = :settings
47
47
  # ...
48
48
 
49
49
  def self.create(name)
50
50
  if Dir.exist?(name) || File.exist?(name)
51
- # todo: i18n
52
- Aro::Dom::P.say("unable to create arodome at #{name}. file or directory already exists.")
51
+ Aro::Dom::P.say(I18n.t("dom.errors.failed_directory_exists", name: name))
52
+ return
53
53
  end
54
54
 
55
- # todo: i18n
56
- Aro::Dom::P.say("creating arodome named #{name}")
55
+ Aro::Dom::P.say(I18n.t("dom.messages.creating_arodome", name: name))
57
56
  FileUtils.mkdir(name)
58
57
  ether_file_path = "#{name}/#{Aro::Dom::ETHER_FILE}"
59
58
  FileUtils.mkdir(ether_file_path)
@@ -61,16 +60,25 @@ module Aro
61
60
  file.write(name)
62
61
  end
63
62
 
64
- # todo: i18n
65
- Aro::Dom::P.say("#{name} arodome created. enter the following commands to begin.")
66
- Aro::Dom::P.say("$ cd #{name}")
67
- Aro::Dom::P.say("$ aro dom init")
63
+ Aro::Dom::P.say(I18n.t("dom.messages.arodome_created", name: name))
68
64
  end
69
65
 
70
66
  def self.in_arodom?
71
67
  !Aro::Dom.ethergeist_path.nil?
72
68
  end
73
69
 
70
+ def self.is_initialized?
71
+ File.exist?(File.join(Aro::Dom::ethergeist_path, Aos::Db::SQL_FILE.to_s))
72
+ end
73
+
74
+ def self.domain
75
+ "#{Aro::Dom}#{Aos::Os::A}#{Aro::Dom.ethergeist_name}"
76
+ end
77
+
78
+ def self.dom_root
79
+ Aro::Dom.in_arodom? ? File.dirname(Aro::Dom::ethergeist_path) : nil
80
+ end
81
+
74
82
  def self.room_path(needle)
75
83
  return nil if needle.nil?
76
84
  needle = needle.to_s.strip
@@ -103,7 +111,6 @@ module Aro
103
111
  search_path.any?{|step|
104
112
  search_pwd = File.join(search_pwd, step)
105
113
  ls = Dir.glob("#{search_pwd}/#{ETHER_FILE}", File::FNM_DOTMATCH)
106
-
107
114
  path = ls.first if ls.any?
108
115
  !path.nil?
109
116
  }
@@ -111,25 +118,29 @@ module Aro
111
118
  return path
112
119
  end
113
120
 
114
- def self.dom_root
115
- File.dirname(Aro::Dom::ethergeist_path)
121
+ def self.ethergeist_name
122
+ return nil unless Aro::Dom.in_arodom?
123
+
124
+ File.read(
125
+ File.join(
126
+ Aro::Dom.ethergeist_path, Aro::Mancy::NAME_FILE.to_s
127
+ )
128
+ )
116
129
  end
117
130
 
118
131
  def generate
119
132
  return unless Aro::Dom.in_arodom?
120
133
 
121
134
  # todo: add file permissions to Aro::Dom::ARODOME and all WINGS
122
-
123
- Aro::Dom::P.say("generating wings...")
135
+ Aro::Dom::P.say(I18n.t("dom.messages.generating_wings"))
124
136
  Aro::Dom::D::LAYOUT.values.each{|w| generate_wing w}
125
-
126
- Aro::Dom::P.say("#{Aro::Dom.name} initialization complete!")
137
+ Aos::Db::new
138
+ Aro::Dom::P.say(I18n.t("dom.messages.initialization_complete", name: Aro::Dom.name))
127
139
  end
128
140
 
129
141
  def generate_wing(wing)
130
142
  return unless Aro::Dom::D::LAYOUT.values.include?(wing)
131
-
132
- Aro::Dom::P.say("generating the #{wing[:name]} wing...")
143
+ Aro::Dom::P.say(I18n.t("dom.messages.generating_wing", wing: wing[:name].to_s))
133
144
  FileUtils.mkdir(wing[:name].to_s)
134
145
 
135
146
  wing[:rooms].each{|r| generate_room(wing, r)}
@@ -138,7 +149,7 @@ module Aro
138
149
  def generate_room(wing, room)
139
150
  return unless Aro::Dom::D::WINGS[wing[:name].upcase].values.include?(room)
140
151
 
141
- Aro::Dom::P.say("generating the #{room[:name]} room.")
152
+ Aro::Dom::P.say(I18n.t("dom.messages.generating_room", room: room[:name].to_s))
142
153
 
143
154
  room_path = File.join(wing[:name].to_s, room[:name].to_s)
144
155
  FileUtils.mkdir(room_path)
@@ -157,5 +168,5 @@ module Aro
157
168
  )
158
169
  )
159
170
  end
160
- end
171
+ end
161
172
  end # aroadhome
data/sys/dom/p.rb CHANGED
@@ -11,7 +11,7 @@
11
11
  module Aro
12
12
  class Dom::P < Aro::Prompt
13
13
  def self.say(message)
14
- Aro::Dom::P.p.say(">[#{Aro::Dom::PS1}]>: #{message}")
14
+ Aro::Dom::P.p.say("#{Aro::Dom::PS1}#{message}")
15
15
  end
16
16
  end
17
17
  end
data/sys/models/deck.rb CHANGED
@@ -42,9 +42,9 @@ class Aro::Deck < ActiveRecord::Base
42
42
 
43
43
  def generate_log
44
44
  prev_cards = Base64::decode64(logs.last.card_data) if logs.any?
45
- if prev_cards.present? && prev_cards != cards || prev_cards.nil?
45
+ if (prev_cards.present? && prev_cards != cards) || (prev_cards.nil? || prev_cards.empty?)
46
46
  logs.create(
47
- card_data: Base64::encode64(cards),
47
+ card_data: Base64::encode64(cards || ""),
48
48
  drawn_data: Base64::encode64(drawn || "")
49
49
  )
50
50
  end
@@ -106,9 +106,9 @@ class Aro::Deck < ActiveRecord::Base
106
106
  # for now tests just expect text output
107
107
  return h_logs if CLI::Config.is_test?
108
108
 
109
- Aro::P.say(I18n.t("cli.messages.showing", name: name, count: count_n, order: order_o))
109
+ Aro::D.say(I18n.t("cli.messages.showing", name: name, count: count_n, order: order_o))
110
110
 
111
- Aos::Vi::Deck.show({
111
+ Aos::Vi::Game.show_game({
112
112
  deck: self,
113
113
  h_logs: h_logs,
114
114
  count_n: count_n,
@@ -146,7 +146,7 @@ class Aro::Deck < ActiveRecord::Base
146
146
  # the deck. this will preserve all card orientations.
147
147
  cards_arr = cards.split(Aro::Deck::CARD_DELIM.to_s) || []
148
148
  drawn_arr = drawn&.split(Aro::Deck::CARD_DELIM.to_s) || []
149
-
149
+
150
150
  # append each drawn card to cards
151
151
  drawn_arr.each{|dc| cards_arr << dc }
152
152
 
@@ -154,7 +154,7 @@ class Aro::Deck < ActiveRecord::Base
154
154
  update(drawn: "", cards: cards_arr.join(Aro::Deck::CARD_DELIM.to_s))
155
155
  end
156
156
 
157
- def draw(is_dt_dimension: true, z_max: 7, z: 1)
157
+ def draw(is_dt_dimension: true, z_max: 7, z: 1)
158
158
  # the true card
159
159
  abs_dev_tarot = nil
160
160
 
@@ -168,6 +168,10 @@ class Aro::Deck < ActiveRecord::Base
168
168
  # get drawn
169
169
  drawn_arr = drawn&.split(Aro::Deck::CARD_DELIM.to_s) || []
170
170
 
171
+ if cards_arr.empty?
172
+ Aro::P.say("there are no cards left to draw.")
173
+ return
174
+ end
171
175
  sleeps = 0
172
176
  sleeps_max = z_max
173
177
 
@@ -175,7 +179,7 @@ class Aro::Deck < ActiveRecord::Base
175
179
  while sleeps <= sleeps_max && dev_tarot.nil? do
176
180
  # use fallback randomness if /dev/tarot unavailable
177
181
  if !is_dt_dimension || !File.exist?(Aro::T::DEV_TAROT_FILE.to_s)
178
- dev_tarot = Aro::T.summon_ruby_facot(cards_arr).split("")
182
+ dev_tarot = Aro::T.summon_ruby_facot.split("")
179
183
  else
180
184
  # preferred randomness
181
185
  read_value = Aro::T.read_dev_tarot&.strip&.split("")
data/sys/reiquire.rb CHANGED
@@ -14,6 +14,7 @@ require :"active_record/schema_dumper".to_s
14
14
  require :base64.to_s
15
15
  require :fileutils.to_s
16
16
  require :i18n.to_s
17
+ require :readline.to_s
17
18
  require :"tty-prompt".to_s
18
19
  require :yaml.to_s
19
20
 
data/sys/shr/prompt.rb CHANGED
@@ -26,6 +26,10 @@ module Aro
26
26
  CLI::Config::BOOLS[:TRUE]
27
27
  end
28
28
 
29
+ def self.should_print?
30
+ CLI::Config::BOOLS[:TRUE]
31
+ end
32
+
29
33
  def self.say(message)
30
34
  raise :override_me.to_s
31
35
  end
data/sys/shr/t.rb CHANGED
@@ -11,7 +11,7 @@
11
11
  module Aro
12
12
  module T
13
13
  DEV_TAROT_FILE = :"/dev/tarot"
14
-
14
+ DEV_TAROT = :"Dev::Tarot".to_s
15
15
  RUBY_FACOT = :"Ruby::Facot".to_s
16
16
 
17
17
  def self.is_dev_tarot?
@@ -21,19 +21,21 @@ module Aro
21
21
  # read dev_tarot
22
22
  def self.read_dev_tarot
23
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::D.say(I18n.t("cli.very_important", dev_tarot: dt))
24
+ if Aro::T.is_dev_tarot? && File.exist?(Aro::T::DEV_TAROT_FILE.to_s)
25
+ File.open(Aro::T::DEV_TAROT_FILE.to_s, "r"){|dtf| dt = dtf.read(Aro::Mancy::N)}
26
+ # VERY IMPORTANT!
27
+ Aro::V.say(I18n.t("cli.very_important", dev_tarot: dt))
28
+ else
29
+ Aro::V.say("warning: summoning ruby_facot in #{__method__}")
30
+ dt = Aro::T.summon_ruby_facot unless Aro::T.is_dev_tarot?
31
+ end
30
32
  return dt
31
33
  end
32
34
 
33
35
  # 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("")
36
+ def self.summon_ruby_facot
37
+ Aro::D.say(I18n.t("cli.messages.ruby_facot_random"))
38
+ ruby_facot = I18n.t("cards.index").map{|c| "+#{c}"}.sample.split("")
37
39
 
38
40
  # get orientation
39
41
  ruby_facot_str = ["+","-"].sample
data/sys/shr/version.rb CHANGED
@@ -9,8 +9,10 @@
9
9
  =end
10
10
 
11
11
  module Aro
12
- VERSION = :"0.1.8"
12
+ VERSION = :"0.1.9"
13
13
  RELEASE_NOTES = :"this version".to_s + [
14
- "created aos"
14
+ "adds improved views.",
15
+ "adds aro gameplay within an arodome game room.",
16
+ "adds ability to set config ivars from aos."
15
17
  ].join(",")
16
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - i2097i
@@ -193,6 +193,7 @@ files:
193
193
  - checksums/aro-0.1.6.gem.sha512
194
194
  - checksums/aro-0.1.7.gem.sha512
195
195
  - checksums/aro-0.1.8.gem.sha512
196
+ - checksums/aro-0.1.9.gem.sha512
196
197
  - db/migrate/1763374647_create_decks.rb
197
198
  - db/migrate/1763432541_create_logs.rb
198
199
  - db/migrate/1765148774_create_yous.rb
@@ -200,6 +201,7 @@ files:
200
201
  - locale/en.aos.yml
201
202
  - locale/en.cards.yml
202
203
  - locale/en.cngelog.yml
204
+ - locale/en.dom.yml
203
205
  - locale/en.usage.yml
204
206
  - locale/en.yml
205
207
  - sys/aos/aos.rb
@@ -209,7 +211,6 @@ files:
209
211
  - sys/aos/views/dom.rb
210
212
  - sys/aos/views/games.rb
211
213
  - sys/aos/views/games/abpps.rb
212
- - sys/aos/views/games/deck.rb
213
214
  - sys/aos/views/games/game.rb
214
215
  - sys/aos/views/games/hbpps.rb
215
216
  - sys/aos/views/games/shpps.rb
@@ -269,5 +270,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
270
  requirements: []
270
271
  rubygems_version: 3.6.9
271
272
  specification_version: 4
272
- summary: this versioncreated aos
273
+ summary: this versionadds improved views.,adds aro gameplay within an arodome game
274
+ room.,adds ability to set config ivars from aos.
273
275
  test_files: []
@@ -1,95 +0,0 @@
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