aro 0.2.1 → 0.2.3
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 +1 -1
- data/README.md +1 -1
- data/aro.gemspec +3 -3
- data/bin/aos +10 -3
- data/bin/aro +18 -11
- data/checksums/aro-0.2.1.gem.sha512 +1 -0
- data/checksums/aro-0.2.2.gem.sha512 +1 -0
- data/checksums/aro-0.2.3.gem.sha512 +1 -0
- data/locale/en.abot.yml +81 -0
- data/locale/en.amg.yml +44 -0
- data/locale/en.aos.yml +8 -38
- data/locale/en.cor.yml +47 -0
- data/locale/en.data.yml +30 -0
- data/locale/en.dom.yml +22 -18
- data/locale/en.flie.yml +29 -0
- data/locale/en.usage.yml +39 -26
- data/locale/en.yml +10 -51
- data/sys/aos/abot.rb +256 -0
- data/sys/aos/amg.rb +58 -56
- data/sys/aos/aos.rb +425 -180
- data/sys/aos/cor.rb +773 -0
- data/sys/aos/data.rb +117 -0
- data/sys/aos/db/migrate/1765148774_create_yous.rb +1 -0
- data/sys/aos/db/migrate/{1765762724_create_libs.rb → 1765762724_create_ilibs.rb} +5 -5
- data/sys/aos/db/migrate/1765907766_create_ilogs.rb +18 -0
- data/sys/aos/db/migrate/1765933985_create_agodos.rb +22 -0
- data/sys/aos/db/migrate/1766203888_create_fpxies.rb +18 -0
- data/sys/aos/db.rb +47 -27
- data/sys/aos/flie.rb +144 -0
- data/sys/aos/models/agodo.rb +96 -0
- data/sys/aos/models/base_model.rb +13 -0
- data/sys/aos/models/fpxy.rb +28 -0
- data/sys/{shr/lib/lib.rb → aos/models/ilib.rb} +11 -6
- data/sys/aos/models/ilog.rb +29 -0
- data/sys/aos/models/you.rb +98 -0
- data/sys/aos/s.rb +2 -1
- data/sys/aos/vws/base.rb +69 -78
- data/sys/aos/vws/dom.rb +1 -2
- data/sys/aos/vws/games/abot.rb +21 -0
- data/sys/aos/vws/games/{game.rb → teck.rb} +27 -24
- data/sys/aos/vws/home.rb +23 -0
- data/sys/aos/vws/know/{temple.rb → body.rb} +3 -3
- data/sys/aos/vws/know/{library.rb → mind.rb} +3 -3
- data/sys/aos/vws/know/spirit.rb +19 -0
- data/sys/aos/vws/{setup → root}/amg.rb +1 -2
- data/sys/aos/vws/{setup → root}/config.rb +4 -4
- data/sys/aos/vws/root/data.rb +21 -0
- data/sys/aos/vws/root/flie.rb +21 -0
- data/sys/aos/vws/{setup.rb → root.rb} +3 -3
- data/sys/aos/vws/welcome/waite.rb +1 -0
- data/sys/aos/vws/welcome.rb +47 -0
- data/sys/aro/d.rb +4 -2
- data/sys/aro/db/migrate/{1763374647_create_decks.rb → 1763374647_create_tecks.rb} +5 -5
- data/sys/aro/db/migrate/1763432541_create_tlogs.rb +20 -0
- data/sys/aro/db.rb +28 -19
- data/sys/aro/mancy.rb +18 -22
- data/sys/aro/models/base_model.rb +13 -0
- data/sys/{models/deck.rb → aro/models/teck.rb} +60 -57
- data/sys/aro/models/tlog.rb +21 -0
- data/sys/aro/p.rb +1 -1
- data/sys/aro/r.rb +2 -1
- data/sys/aro/v.rb +2 -2
- data/sys/cli/constants.rb +4 -10
- data/sys/cli/create.rb +2 -3
- data/sys/cli/dom.rb +1 -2
- data/sys/cli/{deck.rb → teck.rb} +38 -45
- data/sys/cli.rb +10 -11
- data/sys/dom/d.rb +68 -46
- data/sys/dom/dom.rb +79 -44
- data/sys/dom/p.rb +1 -1
- data/sys/fpx.rb +116 -0
- data/sys/reiquire.rb +8 -8
- data/sys/shr/prompt.rb +2 -6
- data/sys/shr/t.rb +11 -13
- data/sys/shr/version.rb +1 -1
- data/tasks/make.rake +1 -1
- metadata +82 -62
- data/locale/en.cngelog.yml +0 -5
- data/sys/aos/vws/games/abpps.rb +0 -19
- data/sys/aos/vws/games/hbpps.rb +0 -19
- data/sys/aos/vws/games/shpps.rb +0 -19
- data/sys/aos/vws/games/vipps.rb +0 -19
- data/sys/aos/you.rb +0 -21
- data/sys/aro/db/migrate/1763432541_create_logs.rb +0 -20
- data/sys/dom/config.rb +0 -665
- data/sys/models/log.rb +0 -20
- /data/sys/shr/{lib → ilib}/crs/CMakeLists.txt +0 -0
- /data/sys/shr/{lib → ilib}/crs/compile.sh +0 -0
- /data/sys/shr/{lib → ilib}/crs/crs.c +0 -0
- /data/sys/shr/{lib → ilib}/crs/crs.o +0 -0
- /data/sys/shr/{lib → ilib}/crs/libcrs.so +0 -0
data/sys/aos/vws/welcome.rb
CHANGED
|
@@ -13,7 +13,54 @@ require_relative :"./base".to_s
|
|
|
13
13
|
module Aos
|
|
14
14
|
module Vw
|
|
15
15
|
class Welcome < Aos::Vw::Base
|
|
16
|
+
def self.show
|
|
17
|
+
lines = []
|
|
16
18
|
|
|
19
|
+
dc = Aos::Cor.display_configuration
|
|
20
|
+
width = dc[:WIDTH]
|
|
21
|
+
|
|
22
|
+
lines << "welcome to #{Aro::Dom.ethergeist_name}".center(width)
|
|
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
|
|
62
|
+
draw(lines)
|
|
63
|
+
end
|
|
17
64
|
end
|
|
18
65
|
end
|
|
19
66
|
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
|
-
|
|
18
|
+
super([">[#{Aro::Mancy::I2097I}]>: #{message}"])
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
def self.should_print?
|
|
21
|
-
|
|
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
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
class
|
|
1
|
+
class CreateTecks < ActiveRecord::Migration[8.1]
|
|
2
2
|
|
|
3
3
|
def self.up
|
|
4
|
-
create_table :
|
|
4
|
+
create_table :tecks do |t|
|
|
5
5
|
t.string :name
|
|
6
6
|
t.string :cards, null: false, default: ""
|
|
7
7
|
t.string :drawn, null: false, default: ""
|
|
@@ -9,12 +9,12 @@ class CreateDecks < ActiveRecord::Migration[8.1]
|
|
|
9
9
|
t.timestamps
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
add_index :
|
|
12
|
+
add_index :tecks, :name, unique: true
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def self.down
|
|
16
|
-
remove_index :
|
|
17
|
-
drop_table :
|
|
16
|
+
remove_index :tecks, :name
|
|
17
|
+
drop_table :tecks
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class CreateTlogs < ActiveRecord::Migration[8.1]
|
|
2
|
+
|
|
3
|
+
def self.up
|
|
4
|
+
create_table :tlogs do |t|
|
|
5
|
+
t.string :card_data
|
|
6
|
+
t.string :drawn_data
|
|
7
|
+
|
|
8
|
+
t.timestamps
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
add_column :tlogs, :teck_id, :integer
|
|
12
|
+
add_index :tlogs, :teck_id
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.down
|
|
16
|
+
remove_index :tlogs, :teck_id
|
|
17
|
+
drop_table :tlogs
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
data/sys/aro/db.rb
CHANGED
|
@@ -8,44 +8,45 @@
|
|
|
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
|
|
16
|
+
include Singleton
|
|
17
|
+
|
|
13
18
|
DATABASE_YML = :"database.yml"
|
|
14
19
|
GEM_DB_PATH = :"sys/aro/db"
|
|
15
20
|
MIGRATIONS_DIR = :"db/migrate"
|
|
16
21
|
SCHEMA_FILE = :"schema.rb"
|
|
17
|
-
SQL_FILE = :"
|
|
22
|
+
SQL_FILE = :"aro.sql"
|
|
18
23
|
|
|
19
|
-
def
|
|
24
|
+
def self.load
|
|
20
25
|
Aro::Db.configure_logger
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
Mutex.new.synchronize do
|
|
27
|
+
if Aro::Mancy.in_aro?
|
|
28
|
+
self.instance.setup_local_aro
|
|
29
|
+
end
|
|
23
30
|
end
|
|
24
31
|
end
|
|
25
32
|
|
|
26
33
|
def self.configure_logger
|
|
27
|
-
if
|
|
34
|
+
if Aos::Cor.ivar(:LOG_ARO_DB).to_s == Aos::Cor::BOOLS[:TRUE].to_s
|
|
28
35
|
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
|
29
36
|
else
|
|
30
37
|
ActiveRecord::Base.logger = nil
|
|
31
38
|
end
|
|
32
39
|
end
|
|
33
40
|
|
|
34
|
-
def connect(name)
|
|
35
|
-
ActiveRecord::Base.establish_connection(config)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def config
|
|
39
|
-
@config ||= YAML.load_file(db_config_filepath)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
41
|
def self.base_aro_dir
|
|
43
42
|
base_aro_file = Aro::Mancy::ARO_FILE.to_s
|
|
44
|
-
|
|
43
|
+
return "#{base_aro_file}_#{Aos::Cor::ENVS[:TEST]}" if Aos::Cor.is_test?
|
|
44
|
+
|
|
45
|
+
base_aro_file
|
|
45
46
|
end
|
|
46
47
|
|
|
47
48
|
def db_config_filepath
|
|
48
|
-
File.join(Aro::Db.base_aro_dir, Aro::Db::DATABASE_YML.to_s)
|
|
49
|
+
@db_config_filepath ||= File.join(Aro::Db.base_aro_dir, Aro::Db::DATABASE_YML.to_s)
|
|
49
50
|
end
|
|
50
51
|
|
|
51
52
|
def setup_local_aro
|
|
@@ -54,6 +55,7 @@ module Aro
|
|
|
54
55
|
|
|
55
56
|
# create local .aro/ directory
|
|
56
57
|
unless File.exist?(Aro::Db.base_aro_dir)
|
|
58
|
+
Aro::P.say("creating #{Aro::Mancy::ARO_FILE.to_s} directory...")
|
|
57
59
|
FileUtils.mkdir(Aro::Db.base_aro_dir)
|
|
58
60
|
end
|
|
59
61
|
|
|
@@ -63,22 +65,29 @@ module Aro
|
|
|
63
65
|
adapter: :sqlite3.to_s,
|
|
64
66
|
database: File.join(Aro::Db.base_aro_dir, Aro::Db::SQL_FILE.to_s),
|
|
65
67
|
username: name,
|
|
66
|
-
password: name
|
|
68
|
+
password: name,
|
|
69
|
+
pool: Aos::Os::DB_POOL
|
|
67
70
|
}.to_yaml
|
|
68
71
|
File.open(db_config_filepath, "w") do |file|
|
|
69
72
|
file.write(c)
|
|
70
73
|
end
|
|
71
74
|
end
|
|
72
75
|
|
|
73
|
-
connect
|
|
76
|
+
connect
|
|
74
77
|
migrate(name)
|
|
75
78
|
end
|
|
76
79
|
|
|
80
|
+
def connect
|
|
81
|
+
ActiveRecord::Base.establish_connection(
|
|
82
|
+
YAML.load_file(db_config_filepath)
|
|
83
|
+
)
|
|
84
|
+
end
|
|
85
|
+
|
|
77
86
|
def migrate(name)
|
|
78
87
|
local_migrate_dir = File.join(Aro::Db.base_aro_dir, Aro::Db::MIGRATIONS_DIR.to_s)
|
|
79
88
|
unless Dir.exist?(local_migrate_dir)
|
|
80
|
-
gem_dir = Dir[
|
|
81
|
-
FileUtils.cp_r(File.join(gem_dir, Aro::Db::GEM_DB_PATH.to_s), Aro::Db
|
|
89
|
+
gem_dir = Dir[Reiquire::GEM_PATH || '.'].first
|
|
90
|
+
FileUtils.cp_r(File.join(gem_dir, Aro::Db::GEM_DB_PATH.to_s), Aro::Db.base_aro_dir)
|
|
82
91
|
end
|
|
83
92
|
|
|
84
93
|
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 :
|
|
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 = :".
|
|
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
|
|
63
|
-
Aro::Config.instance.load
|
|
61
|
+
def self.teck
|
|
64
62
|
if Aro::Mancy.in_aro? && Aro::Mancy.is_initialized?
|
|
65
|
-
Aro::
|
|
66
|
-
self.game = Aro::Deck.current_deck
|
|
63
|
+
self.instance.current = Aro::Teck.current_teck
|
|
67
64
|
end
|
|
68
|
-
|
|
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,28 +71,32 @@ 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
|
-
Aro::P.say(I18n.t("cli.messages.
|
|
76
|
+
Aro::P.say(I18n.t("cli.messages.no_tecks"))
|
|
84
77
|
FileUtils.mkdir(name)
|
|
85
78
|
else
|
|
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
|
|
101
|
-
Aro::
|
|
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
|
+
|
|
99
|
+
Aro::Db.load
|
|
102
100
|
end
|
|
103
101
|
|
|
104
102
|
def self.is_initialized?
|
|
@@ -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
|
|
@@ -1,45 +1,46 @@
|
|
|
1
1
|
=begin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
teck.rb
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
teck object.
|
|
6
6
|
|
|
7
7
|
by i2097i
|
|
8
8
|
|
|
9
9
|
=end
|
|
10
10
|
|
|
11
11
|
require :base64.to_s
|
|
12
|
-
require_relative :"
|
|
12
|
+
require_relative :"./base_model".to_s
|
|
13
13
|
|
|
14
|
-
class Aro::
|
|
15
|
-
has_many :
|
|
14
|
+
class Aro::Teck < ActiveRecord::Base
|
|
15
|
+
has_many :tlogs
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
TECK_FILE = :".aro_teck"
|
|
18
18
|
CARD_DELIM = :","
|
|
19
19
|
|
|
20
20
|
before_create :populate_cards
|
|
21
21
|
after_commit :generate_log
|
|
22
22
|
|
|
23
23
|
def self.make(new_name)
|
|
24
|
+
Aro::Db.load
|
|
24
25
|
return nil unless Aro::Mancy.is_initialized?
|
|
25
|
-
Aro::
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
new_deck
|
|
26
|
+
new_teck = Aro::Teck.create(name: new_name)
|
|
27
|
+
Aro::Teck.select_teck(new_teck) if Aro::Teck.current_teck.nil?
|
|
28
|
+
new_teck
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def self.fresh_cards
|
|
32
|
-
I18n.t("cards.index").map{|c| "+#{c}"}.join(Aro::
|
|
32
|
+
I18n.t("cards.index").map{|c| "+#{c}"}.join(Aro::Teck::CARD_DELIM.to_s)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def populate_cards
|
|
36
|
-
|
|
36
|
+
Aro::Db.load
|
|
37
|
+
self.cards = Aro::Teck.fresh_cards
|
|
37
38
|
end
|
|
38
39
|
|
|
39
40
|
def generate_log
|
|
40
|
-
prev_cards = Base64::decode64(
|
|
41
|
+
prev_cards = Base64::decode64(tlogs.last.card_data) if tlogs.any?
|
|
41
42
|
if (prev_cards.present? && prev_cards != cards) || (prev_cards.nil? || prev_cards.empty?)
|
|
42
|
-
|
|
43
|
+
tlogs.create(
|
|
43
44
|
card_data: Base64::encode64(cards || ""),
|
|
44
45
|
drawn_data: Base64::encode64(drawn || "")
|
|
45
46
|
)
|
|
@@ -47,28 +48,29 @@ class Aro::Deck < ActiveRecord::Base
|
|
|
47
48
|
end
|
|
48
49
|
|
|
49
50
|
def self.display_selection_menu
|
|
50
|
-
unless Aro::
|
|
51
|
-
Aro::P.say(I18n.t("cli.messages.
|
|
51
|
+
unless Aro::Teck.any?
|
|
52
|
+
Aro::P.say(I18n.t("cli.messages.no_tecks"))
|
|
52
53
|
exit(CLI::EXIT_CODES[:SUCCESS])
|
|
53
54
|
end
|
|
54
|
-
c_d = Aro::
|
|
55
|
-
Aro::
|
|
55
|
+
c_d = Aro::Teck.current_teck
|
|
56
|
+
Aro::Teck.all.each do |d|
|
|
56
57
|
Aro::P.say("#{d.id == c_d.id ? :*.to_s : " "}#{d.id}): #{d.name}")
|
|
57
58
|
end
|
|
58
59
|
end
|
|
59
60
|
|
|
60
|
-
def self.
|
|
61
|
-
return unless
|
|
62
|
-
Aro::P.say(I18n.t("cli.messages.
|
|
63
|
-
File.open(Aro::
|
|
64
|
-
file.write(
|
|
61
|
+
def self.select_teck(teck)
|
|
62
|
+
return unless teck.present?
|
|
63
|
+
Aro::P.say(I18n.t("cli.messages.teck_selected", name: teck.name, room: Aro::Mancy::aro_mancy_name))
|
|
64
|
+
File.open(File.join(Aro::Db.base_aro_dir, Aro::Teck::TECK_FILE.to_s), "w") do |file|
|
|
65
|
+
file.write(teck.id)
|
|
65
66
|
end
|
|
66
67
|
end
|
|
67
68
|
|
|
68
|
-
def self.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
def self.current_teck
|
|
70
|
+
Aro::Db.load
|
|
71
|
+
if File.exist?(File.join(Aro::Db.base_aro_dir, TECK_FILE.to_s))
|
|
72
|
+
current_teck_id = File.read(File.join(Aro::Db.base_aro_dir, TECK_FILE.to_s))
|
|
73
|
+
return Aro::Teck.find_by(id: current_teck_id)
|
|
72
74
|
end
|
|
73
75
|
end
|
|
74
76
|
|
|
@@ -76,54 +78,55 @@ class Aro::Deck < ActiveRecord::Base
|
|
|
76
78
|
card.gsub(/[+-]/, "").strip
|
|
77
79
|
end
|
|
78
80
|
|
|
79
|
-
def show(count_n: Aro::Mancy::S, order_o: Aro::
|
|
81
|
+
def show(count_n: Aro::Mancy::S, order_o: Aro::Tlog::ORDERING[:DESC])
|
|
82
|
+
tlogs_count = tlogs.count
|
|
80
83
|
unless count_n.kind_of?(Numeric) && count_n.to_i > Aro::Mancy::O
|
|
81
84
|
if count_n&.to_s&.to_sym == Aro::Mancy::ALL
|
|
82
|
-
count_n =
|
|
85
|
+
count_n = tlogs_count
|
|
83
86
|
else
|
|
84
87
|
count_n = Aro::Mancy::S
|
|
85
88
|
end
|
|
86
89
|
end
|
|
87
|
-
count_n = [[Aro::Mancy::S, count_n.to_i].max,
|
|
90
|
+
count_n = [[Aro::Mancy::S, count_n.to_i].max, tlogs_count].min
|
|
88
91
|
Aro::V.say("count_n: #{count_n}")
|
|
89
92
|
Aro::V.say("order_o: #{order_o}")
|
|
90
93
|
|
|
91
|
-
unless Aro::
|
|
94
|
+
unless Aro::Tlog::ORDERING.values.include?(order_o)
|
|
92
95
|
Aro::P.say(I18n.t("cli.warnings.invalid_order"))
|
|
93
|
-
order_o = Aro::
|
|
96
|
+
order_o = Aro::Tlog::ORDERING[:DESC]
|
|
94
97
|
end
|
|
95
98
|
|
|
96
99
|
# perform query
|
|
97
|
-
|
|
100
|
+
tlog_records = tlogs.order(created_at: order_o).first(count_n)
|
|
98
101
|
|
|
99
102
|
# todo: this is doing more work than it needs to. needs debugging.
|
|
100
|
-
# Aro::V.say("
|
|
103
|
+
# Aro::V.say("tlog_records.count: #{tlog_records.count}")
|
|
101
104
|
|
|
102
|
-
# for now tests just expect
|
|
103
|
-
return
|
|
105
|
+
# for now tests just expect count
|
|
106
|
+
return tlog_records if Aos::Cor.is_test?
|
|
104
107
|
|
|
105
108
|
Aro::D.say(I18n.t("cli.messages.showing", name: name, count: count_n, order: order_o))
|
|
106
109
|
|
|
107
|
-
Aos::Vw::
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
Aos::Vw::Teck.show_game({
|
|
111
|
+
teck: self,
|
|
112
|
+
tlog_records: tlog_records,
|
|
110
113
|
count_n: count_n,
|
|
111
114
|
order_o: order_o
|
|
112
115
|
})
|
|
113
116
|
end
|
|
114
117
|
|
|
115
118
|
def explore
|
|
116
|
-
# allows user to browse each card in the current
|
|
117
|
-
answer =
|
|
119
|
+
# allows user to browse each card in the current teck.
|
|
120
|
+
answer = Aos::S.p.select(
|
|
118
121
|
Aro::Mancy::PS1.to_s + I18n.t("cli.messages.choose_card"),
|
|
119
122
|
# formatted for tty-prompt gem
|
|
120
|
-
cards.split(Aro::
|
|
121
|
-
per_page:
|
|
123
|
+
cards.split(Aro::Teck::CARD_DELIM.to_s).map{|c| [I18n.t("cards.#{Aro::Teck.card_strip(c)}.name"), c]}.to_h,
|
|
124
|
+
per_page: Aos::Cor.display_configuration[:HEIGHT] - Aro::Mancy::S,
|
|
122
125
|
cycle: true,
|
|
123
126
|
default: Aro::Mancy::S
|
|
124
127
|
)
|
|
125
128
|
# {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: ""}
|
|
126
|
-
definition = I18n.t("cards.#{Aro::
|
|
129
|
+
definition = I18n.t("cards.#{Aro::Teck.card_strip(answer)}")
|
|
127
130
|
indent = Aro::Mancy::N
|
|
128
131
|
Aro::P.say(definition[:name])
|
|
129
132
|
Aro::P.say(definition[:summary])
|
|
@@ -135,27 +138,27 @@ class Aro::Deck < ActiveRecord::Base
|
|
|
135
138
|
end
|
|
136
139
|
|
|
137
140
|
def shuffle
|
|
138
|
-
# shuffles the current
|
|
139
|
-
update(cards: cards.split(Aro::
|
|
141
|
+
# shuffles the current teck and generates a log record.
|
|
142
|
+
update(cards: cards.split(Aro::Teck::CARD_DELIM.to_s).shuffle.join(Aro::Teck::CARD_DELIM.to_s))
|
|
140
143
|
end
|
|
141
144
|
|
|
142
145
|
def reset
|
|
143
|
-
# completely reset the
|
|
146
|
+
# completely reset the teck. replace all drawn and reset order.
|
|
144
147
|
# all orientations will be set to upright.
|
|
145
|
-
update(cards: Aro::
|
|
148
|
+
update(cards: Aro::Teck.fresh_cards, drawn: "")
|
|
146
149
|
end
|
|
147
150
|
|
|
148
151
|
def replace
|
|
149
152
|
# replaces all drawn cards FIFO and puts them on the bottom of
|
|
150
|
-
# the
|
|
151
|
-
cards_arr = cards.split(Aro::
|
|
152
|
-
drawn_arr = drawn&.split(Aro::
|
|
153
|
+
# the teck. this will preserve all card orientations.
|
|
154
|
+
cards_arr = cards.split(Aro::Teck::CARD_DELIM.to_s) || []
|
|
155
|
+
drawn_arr = drawn&.split(Aro::Teck::CARD_DELIM.to_s) || []
|
|
153
156
|
|
|
154
157
|
# append each drawn card to cards
|
|
155
158
|
drawn_arr.each{|dc| cards_arr << dc }
|
|
156
159
|
|
|
157
160
|
# clear drawn
|
|
158
|
-
update(drawn: "", cards: cards_arr.join(Aro::
|
|
161
|
+
update(drawn: "", cards: cards_arr.join(Aro::Teck::CARD_DELIM.to_s))
|
|
159
162
|
end
|
|
160
163
|
|
|
161
164
|
def draw(is_dt_dimension: true, z_max: 7, z: 1)
|
|
@@ -166,11 +169,11 @@ class Aro::Deck < ActiveRecord::Base
|
|
|
166
169
|
dev_tarot = nil
|
|
167
170
|
|
|
168
171
|
# get cards
|
|
169
|
-
cards_arr = cards.split(Aro::
|
|
172
|
+
cards_arr = cards.split(Aro::Teck::CARD_DELIM.to_s) || []
|
|
170
173
|
# get abs_cards
|
|
171
|
-
abs_cards_arr = cards_arr.map{|c| Aro::
|
|
174
|
+
abs_cards_arr = cards_arr.map{|c| Aro::Teck.card_strip(c)}
|
|
172
175
|
# get drawn
|
|
173
|
-
drawn_arr = drawn&.split(Aro::
|
|
176
|
+
drawn_arr = drawn&.split(Aro::Teck::CARD_DELIM.to_s) || []
|
|
174
177
|
|
|
175
178
|
if cards_arr.empty?
|
|
176
179
|
Aro::P.say("there are no cards left to draw.")
|
|
@@ -219,8 +222,8 @@ class Aro::Deck < ActiveRecord::Base
|
|
|
219
222
|
|
|
220
223
|
# update database
|
|
221
224
|
update(
|
|
222
|
-
cards: cards_arr.join(Aro::
|
|
223
|
-
drawn: drawn_arr.join(Aro::
|
|
225
|
+
cards: cards_arr.join(Aro::Teck::CARD_DELIM.to_s),
|
|
226
|
+
drawn: drawn_arr.join(Aro::Teck::CARD_DELIM.to_s)
|
|
224
227
|
)
|
|
225
228
|
end
|
|
226
229
|
end
|
data/sys/aro/p.rb
CHANGED
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
|
-
|
|
17
|
+
super(["#{Aro::R::PS1} #{message}"])
|
|
17
18
|
end
|
|
18
19
|
end
|
|
19
20
|
end
|
data/sys/aro/v.rb
CHANGED
|
@@ -14,11 +14,11 @@ module Aro
|
|
|
14
14
|
class V < Aro::D
|
|
15
15
|
def self.say(message)
|
|
16
16
|
return unless Aro::V.should_print?
|
|
17
|
-
|
|
17
|
+
super(message)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def self.should_print?
|
|
21
|
-
|
|
21
|
+
Aos::Cor.ivar(:VERBOSE).to_s == Aos::Cor::BOOLS[:TRUE].to_s && super
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
end
|
data/sys/cli/constants.rb
CHANGED
|
@@ -24,21 +24,15 @@ module CLI
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
CMDS = {
|
|
27
|
-
AOS: {
|
|
28
|
-
RUN: :run,
|
|
29
|
-
WATCH: :watch,
|
|
30
|
-
},
|
|
31
27
|
ARO: {
|
|
32
28
|
CREATE: :create,
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
COR: :cor,
|
|
30
|
+
TECK: :teck,
|
|
35
31
|
DOM: :dom,
|
|
36
32
|
INIT: :init,
|
|
37
33
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
DECK: {
|
|
34
|
+
COR: {}, # see Aos::Cor
|
|
35
|
+
TECK: {
|
|
42
36
|
DRAW: :draw,
|
|
43
37
|
EXPLORE: :explore,
|
|
44
38
|
NEW: :new,
|
data/sys/cli/create.rb
CHANGED