aro 0.1.6 → 0.1.8
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 +17 -8
- data/bin/aos +19 -0
- data/bin/aro +24 -24
- data/checksums/aro-0.1.6.gem.sha512 +1 -0
- data/checksums/aro-0.1.7.gem.sha512 +1 -0
- data/checksums/aro-0.1.8.gem.sha512 +1 -0
- data/db/migrate/1763374647_create_decks.rb +3 -0
- data/db/migrate/1763432541_create_logs.rb +1 -0
- data/db/migrate/1765148774_create_yous.rb +19 -0
- data/listen.rb +10 -0
- data/locale/en.aos.yml +27 -0
- data/locale/en.cngelog.yml +5 -0
- data/locale/en.usage.yml +55 -38
- data/locale/en.yml +47 -15
- data/sys/aos/aos.rb +199 -0
- data/sys/aos/db.rb +81 -0
- data/sys/aos/s.rb +25 -0
- data/sys/aos/views/base.rb +139 -0
- data/sys/aos/views/dom.rb +45 -0
- data/sys/aos/views/games/abpps.rb +21 -0
- data/sys/aos/views/games/deck.rb +95 -0
- data/sys/aos/views/games/game.rb +24 -0
- data/sys/aos/views/games/hbpps.rb +21 -0
- data/sys/aos/views/games/shpps.rb +21 -0
- data/sys/aos/views/games/vipps.rb +21 -0
- data/sys/aos/views/games.rb +19 -0
- data/sys/aos/views/know/library.rb +19 -0
- data/sys/aos/views/know/temple.rb +19 -0
- data/sys/aos/views/know.rb +19 -0
- data/sys/aos/views/setup/settings.rb +50 -0
- data/sys/aos/views/setup.rb +19 -0
- data/sys/aos/views/welcome/waite.rb +19 -0
- data/sys/aos/views/welcome/winner.rb +19 -0
- data/sys/aos/views/welcome.rb +19 -0
- data/sys/aos/you.rb +15 -0
- data/sys/aro/d.rb +25 -0
- data/sys/aro/db.rb +89 -0
- data/sys/aro/mancy.rb +114 -0
- data/sys/aro/p.rb +25 -0
- data/sys/aro/r.rb +20 -0
- data/sys/aro/v.rb +24 -0
- data/sys/aro.rb +16 -0
- data/sys/cli/config.rb +582 -0
- data/sys/cli/constants.rb +56 -0
- data/{bin → sys}/cli/create.rb +6 -4
- data/sys/cli/deck.rb +98 -0
- data/sys/cli/dom.rb +37 -0
- data/sys/cli/nterface.rb +31 -0
- data/{bin → sys}/cli/usage.rb +1 -1
- data/sys/cli.rb +26 -0
- data/sys/dom/d.rb +101 -0
- data/sys/dom/dom.rb +161 -0
- data/sys/dom/p.rb +17 -0
- data/sys/models/deck.rb +218 -0
- data/sys/models/log.rb +20 -0
- data/sys/reiquire.rb +45 -0
- data/sys/shr/prompt.rb +37 -0
- data/sys/shr/t.rb +60 -0
- data/sys/shr/version.rb +16 -0
- data/tasks/make.rake +2 -2
- metadata +78 -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/prompt.rb +0 -25
- 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/cli/deck.rb
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
deck.rb
|
|
4
|
+
|
|
5
|
+
process deck commands.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
module CLI
|
|
12
|
+
# cli entrypoint
|
|
13
|
+
def self.deck
|
|
14
|
+
action = CLI::ARGV1&.to_sym
|
|
15
|
+
|
|
16
|
+
if CLI::FLAGS[:HELP].include?(CLI::ARGV1)
|
|
17
|
+
# todo: breakout usage into subcommand-specific verbiage
|
|
18
|
+
CLI.usage::usage
|
|
19
|
+
exit(CLI::EXIT_CODES[:SUCCESS])
|
|
20
|
+
elsif CLI::ARGV1.nil?
|
|
21
|
+
# no args, open deck menu
|
|
22
|
+
Aro::Db.new
|
|
23
|
+
Aro::Deck.display_selection_menu
|
|
24
|
+
elsif action == CLI::CMDS[:DECK][:NEW]
|
|
25
|
+
CLI::Nterface.exit_error_missing_args! if CLI::ARGV2.nil?
|
|
26
|
+
deck = Aro::Deck.make(CLI::ARGV2.to_s)
|
|
27
|
+
Aro::P.say(I18n.t("cli.messages.deck_created_sucessfully", name: Aro::Mancy.game.name))
|
|
28
|
+
Aro::Deck.display_selection_menu
|
|
29
|
+
elsif CLI::CMDS[:DECK].values.include?(action)
|
|
30
|
+
if Aro::Mancy.game.nil?
|
|
31
|
+
Aro::P.say(I18n.t("cli.errors.missing_deck", cmd: Aro::Mancy::I2097I))
|
|
32
|
+
exit(CLI::EXIT_CODES[:GENERAL_ERROR])
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
case action
|
|
36
|
+
when CLI::CMDS[:DECK][:EXPLORE]
|
|
37
|
+
Aro::Mancy.game.explore
|
|
38
|
+
exit(CLI::EXIT_CODES[:SUCCESS])
|
|
39
|
+
when CLI::CMDS[:DECK][:SHUFFLE]
|
|
40
|
+
Aro::P.say(I18n.t("cli.messages.shuffling", name: Aro::Mancy.game.name))
|
|
41
|
+
Aro::Mancy.game.shuffle
|
|
42
|
+
when CLI::CMDS[:DECK][:DRAW]
|
|
43
|
+
Aro::P.say(I18n.t("cli.messages.drawing", name: Aro::Mancy.game.name))
|
|
44
|
+
Aro::P.say(I18n.t("cli.messages.drawing_from_dimension", dimension: "#{CLI::Config.ivar(:DIMENSION)}"))
|
|
45
|
+
Aro::Mancy.game.draw(
|
|
46
|
+
is_dt_dimension: Aro::T::is_dev_tarot?,
|
|
47
|
+
z_max: CLI::Config.ivar(:Z_MAX).to_i,
|
|
48
|
+
z: CLI::Config.ivar(:Z)
|
|
49
|
+
)
|
|
50
|
+
when CLI::CMDS[:DECK][:REPLACE]
|
|
51
|
+
Aro::P.say(I18n.t("cli.messages.replacing_drawn", name: Aro::Mancy.game.name))
|
|
52
|
+
Aro::Mancy.game.replace
|
|
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))
|
|
55
|
+
Aro::P.say(I18n.t("cli.messages.understood", name: Aro::Mancy.game.name))
|
|
56
|
+
exit(CLI::EXIT_CODES[:SUCCESS])
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
Aro::P.say(I18n.t("cli.messages.resetting", name: Aro::Mancy.game.name))
|
|
60
|
+
Aro::Mancy.game.reset
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
Aro::Mancy.game.show(**CLI::shoptions)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# parse show options
|
|
68
|
+
# todo: better naming
|
|
69
|
+
def self.shoptions
|
|
70
|
+
show_options_count = Aro::Mancy::S
|
|
71
|
+
show_options_order = Aro::Log::ORDERING[:DESC]
|
|
72
|
+
|
|
73
|
+
# Aro::P.say("ARGV.map{|a| a.to_sym} => #{ARGV.map{|a| a.to_sym}}")
|
|
74
|
+
|
|
75
|
+
count_option_flags = ARGV.map{|a| a.to_sym} & CLI::FLAGS[:SHOW_COUNT]
|
|
76
|
+
# Aro::P.say("count_option_flags: #{count_option_flags}")
|
|
77
|
+
if count_option_flags.any?
|
|
78
|
+
# get the ARGV index element after flag index
|
|
79
|
+
show_options_count = ARGV[ARGV.index(count_option_flags.first.to_s) + 1]
|
|
80
|
+
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}")
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
order_option_flags = ARGV.map{|a| a.to_sym} & CLI::FLAGS[:SHOW_ORDER]
|
|
85
|
+
# Aro::P.say("count_option_flags: #{order_option_flags}")
|
|
86
|
+
if order_option_flags.any?
|
|
87
|
+
# get the ARGV index element after flag index
|
|
88
|
+
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}")
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
{
|
|
93
|
+
count_n: show_options_count,
|
|
94
|
+
order_o: show_options_order
|
|
95
|
+
}
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
end
|
data/sys/cli/dom.rb
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
dom.rb
|
|
4
|
+
|
|
5
|
+
process dom commands.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
module CLI
|
|
12
|
+
def self.dom
|
|
13
|
+
if CLI::FLAGS[:HELP].include?(CLI::ARGV1)
|
|
14
|
+
CLI.usage::usage
|
|
15
|
+
exit(CLI::EXIT_CODES[:SUCCESS])
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
action = CLI::ARGV1&.to_sym
|
|
19
|
+
|
|
20
|
+
CLI::Nterface.exit_error_invalid_usage! unless !action.nil? &&
|
|
21
|
+
CLI::CMDS[:DOM].values.include?(action)
|
|
22
|
+
|
|
23
|
+
case action
|
|
24
|
+
when CLI::CMDS[:DOM][:INIT]
|
|
25
|
+
arodome = Aro::Dom.new
|
|
26
|
+
arodome.generate
|
|
27
|
+
when CLI::CMDS[:DOM][:NEW]
|
|
28
|
+
CLI::Nterface.exit_error_missing_args! if CLI::ARGV2.nil?
|
|
29
|
+
if Aro::Dom.in_arodom?
|
|
30
|
+
# todo: i18n
|
|
31
|
+
Aro::P.say("unable to create an arodome because you are already in arodom.")
|
|
32
|
+
else
|
|
33
|
+
Aro::Dom.create(CLI::ARGV2.to_s)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
data/sys/cli/nterface.rb
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
nterface.rb
|
|
4
|
+
|
|
5
|
+
cli nterface.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
module CLI
|
|
12
|
+
class Nterface
|
|
13
|
+
def self.exit_error_missing_args!
|
|
14
|
+
Aro::P.say(I18n.t("cli.errors.header", cmd: Aro::Mancy::I2097I))
|
|
15
|
+
Aro::P.say(I18n.t("cli.errors.missing_args", cmd: Aro::Mancy::I2097I))
|
|
16
|
+
exit(CLI::EXIT_CODES[:INVALID_ARG])
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.exit_error_invalid_usage!
|
|
20
|
+
Aro::P.say(I18n.t("cli.errors.header", cmd: Aro::Mancy::I2097I))
|
|
21
|
+
Aro::P.say(I18n.t("cli.errors.invalid_usage", cmd: Aro::Mancy::I2097I))
|
|
22
|
+
exit(CLI::EXIT_CODES[:INVALID_ARG])
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.exit_error_not_initialized!
|
|
26
|
+
Aro::P.say(I18n.t("cli.errors.header", cmd: Aro::Mancy::I2097I))
|
|
27
|
+
Aro::P.say(I18n.t("cli.errors.not_initialized", cmd: Aro::Mancy::I2097I))
|
|
28
|
+
exit(CLI::EXIT_CODES[:INVALID_ARG])
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
data/{bin → sys}/cli/usage.rb
RENAMED
data/sys/cli.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
cli
|
|
4
|
+
|
|
5
|
+
the very first file loaded.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
module CLI
|
|
12
|
+
# init config
|
|
13
|
+
CLI::Config.instance
|
|
14
|
+
|
|
15
|
+
if CLI::CMDS[:DECK].values.include?(ARGV[0]&.to_sym)
|
|
16
|
+
# enable deck shortcut (skip typing deck while in-game)
|
|
17
|
+
ARGV0 = :deck
|
|
18
|
+
ARGV1 = ARGV[0]&.to_sym
|
|
19
|
+
ARGV2 = ARGV[1]&.to_sym
|
|
20
|
+
else
|
|
21
|
+
# default
|
|
22
|
+
ARGV0 = ARGV[0]&.to_sym
|
|
23
|
+
ARGV1 = ARGV[1]&.to_sym
|
|
24
|
+
ARGV2 = ARGV[2]&.to_sym
|
|
25
|
+
end
|
|
26
|
+
end
|
data/sys/dom/d.rb
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
d.rb
|
|
4
|
+
|
|
5
|
+
dom definition.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require_relative :dom.to_s
|
|
12
|
+
|
|
13
|
+
module Aro
|
|
14
|
+
class Dom::D
|
|
15
|
+
# definition of rooms in each layout section
|
|
16
|
+
WINGS = {
|
|
17
|
+
WELCOME: {
|
|
18
|
+
WAITE: {
|
|
19
|
+
name: Aro::Dom::WAITE,
|
|
20
|
+
description: "sign up."
|
|
21
|
+
},
|
|
22
|
+
WINNER: {
|
|
23
|
+
name: Aro::Dom::WINNER,
|
|
24
|
+
description: "win."
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
GAMES: {
|
|
28
|
+
ABPPS: {
|
|
29
|
+
name: Aro::Dom::ABPPS,
|
|
30
|
+
description: "artificial beings."
|
|
31
|
+
},
|
|
32
|
+
HBPPS: {
|
|
33
|
+
name: Aro::Dom::HBPPS,
|
|
34
|
+
description: "human beings."
|
|
35
|
+
},
|
|
36
|
+
SHPPS: {
|
|
37
|
+
name: Aro::Dom::SHPPS,
|
|
38
|
+
description: "human and artificial beings."
|
|
39
|
+
},
|
|
40
|
+
VIPPS: {
|
|
41
|
+
name: Aro::Dom::VIPPS,
|
|
42
|
+
description: "very important - 100% /dev/tarot users."
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
KNOW: {
|
|
46
|
+
LIBRARY: {
|
|
47
|
+
name: Aro::Dom::LIBRARY,
|
|
48
|
+
description: "definition management."
|
|
49
|
+
},
|
|
50
|
+
TEMPLE: {
|
|
51
|
+
name: Aro::Dom::TEMPLE,
|
|
52
|
+
description: "mindfulness management."
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
SETUP: {
|
|
56
|
+
SETTINGS: {
|
|
57
|
+
name: Aro::Dom::SETTINGS,
|
|
58
|
+
description: "user settings and configuration."
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
# overall layout
|
|
64
|
+
LAYOUT = {
|
|
65
|
+
WELCOME: {
|
|
66
|
+
name: Aro::Dom::WELCOME,
|
|
67
|
+
description: "sign up process.",
|
|
68
|
+
rooms: [
|
|
69
|
+
Aro::Dom::D::WINGS[:WELCOME][:WAITE],
|
|
70
|
+
Aro::Dom::D::WINGS[:WELCOME][:WINNER],
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
GAMES: {
|
|
74
|
+
name: Aro::Dom::GAMES,
|
|
75
|
+
description: "aroflie game rooms.",
|
|
76
|
+
rooms: [
|
|
77
|
+
Aro::Dom::D::WINGS[:GAMES][:ABPPS],
|
|
78
|
+
Aro::Dom::D::WINGS[:GAMES][:HBPPS],
|
|
79
|
+
Aro::Dom::D::WINGS[:GAMES][:SHPPS],
|
|
80
|
+
Aro::Dom::D::WINGS[:GAMES][:VIPPS],
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
KNOW: {
|
|
84
|
+
name: Aro::Dom::KNOW,
|
|
85
|
+
description: "information space.",
|
|
86
|
+
rooms: [
|
|
87
|
+
Aro::Dom::D::WINGS[:KNOW][:LIBRARY],
|
|
88
|
+
Aro::Dom::D::WINGS[:KNOW][:TEMPLE]
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
SETUP: {
|
|
92
|
+
name: Aro::Dom::SETUP,
|
|
93
|
+
description: "user configuration space.",
|
|
94
|
+
rooms: [
|
|
95
|
+
Aro::Dom::D::WINGS[:SETUP][:SETTINGS]
|
|
96
|
+
],
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
end
|
|
101
|
+
end
|
data/sys/dom/dom.rb
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
d.rb
|
|
4
|
+
|
|
5
|
+
aro and dom.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require_relative :"../aos/s".to_s
|
|
12
|
+
|
|
13
|
+
module Aro
|
|
14
|
+
class Dom
|
|
15
|
+
PS1 = Aro::Dom.name
|
|
16
|
+
DOT = :"."
|
|
17
|
+
DOTT = :"#{DOT}#{DOT}"
|
|
18
|
+
ETHERGEIST = :ethergeist
|
|
19
|
+
ETHER_FILE = :".#{Aro::Dom::ETHERGEIST}"
|
|
20
|
+
|
|
21
|
+
# < root found_space
|
|
22
|
+
ARODOME = :arodome
|
|
23
|
+
|
|
24
|
+
# < user found_spaces
|
|
25
|
+
WELCOME = :welcome
|
|
26
|
+
GAMES = :games
|
|
27
|
+
KNOW = :know
|
|
28
|
+
SETUP = :setup
|
|
29
|
+
|
|
30
|
+
# > welcome found_spaces
|
|
31
|
+
WAITE = :waite
|
|
32
|
+
WINNER = :winner
|
|
33
|
+
|
|
34
|
+
# > game found_spaces
|
|
35
|
+
ABPPS = :abpps
|
|
36
|
+
HBPPS = :hbpps
|
|
37
|
+
SHPPS = :shpps
|
|
38
|
+
VIPPS = :vipps
|
|
39
|
+
|
|
40
|
+
# > know found_spaces
|
|
41
|
+
LIBRARY = :library
|
|
42
|
+
TEMPLE = :temple
|
|
43
|
+
# ...
|
|
44
|
+
|
|
45
|
+
# > setup found_spaces
|
|
46
|
+
SETTINGS = :settings
|
|
47
|
+
# ...
|
|
48
|
+
|
|
49
|
+
def self.create(name)
|
|
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.")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# todo: i18n
|
|
56
|
+
Aro::Dom::P.say("creating arodome named #{name}")
|
|
57
|
+
FileUtils.mkdir(name)
|
|
58
|
+
ether_file_path = "#{name}/#{Aro::Dom::ETHER_FILE}"
|
|
59
|
+
FileUtils.mkdir(ether_file_path)
|
|
60
|
+
File.open(File.join(ether_file_path, Aro::Mancy::NAME_FILE.to_s), "w+") do |file|
|
|
61
|
+
file.write(name)
|
|
62
|
+
end
|
|
63
|
+
|
|
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")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def self.in_arodom?
|
|
71
|
+
!Aro::Dom.ethergeist_path.nil?
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def self.room_path(needle)
|
|
75
|
+
return nil if needle.nil?
|
|
76
|
+
needle = needle.to_s.strip
|
|
77
|
+
found_space = nil
|
|
78
|
+
found_room = nil
|
|
79
|
+
Aro::Dom::D::LAYOUT.values.each{|layout|
|
|
80
|
+
next unless found_room.nil?
|
|
81
|
+
found_space = layout[:name].to_s
|
|
82
|
+
if found_space == needle
|
|
83
|
+
found_room = found_space
|
|
84
|
+
found_space = nil
|
|
85
|
+
else
|
|
86
|
+
layout[:rooms].each{|room|
|
|
87
|
+
if room[:name].to_s == needle
|
|
88
|
+
found_room = room[:name].to_s
|
|
89
|
+
end
|
|
90
|
+
}
|
|
91
|
+
end
|
|
92
|
+
}
|
|
93
|
+
found_space = nil if found_room.nil?
|
|
94
|
+
|
|
95
|
+
[found_space, found_room].compact.join("/")
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def self.ethergeist_path
|
|
99
|
+
path = nil
|
|
100
|
+
search_path = Dir.pwd.split("/").reject{|p| p.empty?}
|
|
101
|
+
search_pwd = "/"
|
|
102
|
+
|
|
103
|
+
search_path.any?{|step|
|
|
104
|
+
search_pwd = File.join(search_pwd, step)
|
|
105
|
+
ls = Dir.glob("#{search_pwd}/#{ETHER_FILE}", File::FNM_DOTMATCH)
|
|
106
|
+
|
|
107
|
+
path = ls.first if ls.any?
|
|
108
|
+
!path.nil?
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return path
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def self.dom_root
|
|
115
|
+
File.dirname(Aro::Dom::ethergeist_path)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def generate
|
|
119
|
+
return unless Aro::Dom.in_arodom?
|
|
120
|
+
|
|
121
|
+
# todo: add file permissions to Aro::Dom::ARODOME and all WINGS
|
|
122
|
+
|
|
123
|
+
Aro::Dom::P.say("generating wings...")
|
|
124
|
+
Aro::Dom::D::LAYOUT.values.each{|w| generate_wing w}
|
|
125
|
+
|
|
126
|
+
Aro::Dom::P.say("#{Aro::Dom.name} initialization complete!")
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def generate_wing(wing)
|
|
130
|
+
return unless Aro::Dom::D::LAYOUT.values.include?(wing)
|
|
131
|
+
|
|
132
|
+
Aro::Dom::P.say("generating the #{wing[:name]} wing...")
|
|
133
|
+
FileUtils.mkdir(wing[:name].to_s)
|
|
134
|
+
|
|
135
|
+
wing[:rooms].each{|r| generate_room(wing, r)}
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def generate_room(wing, room)
|
|
139
|
+
return unless Aro::Dom::D::WINGS[wing[:name].upcase].values.include?(room)
|
|
140
|
+
|
|
141
|
+
Aro::Dom::P.say("generating the #{room[:name]} room.")
|
|
142
|
+
|
|
143
|
+
room_path = File.join(wing[:name].to_s, room[:name].to_s)
|
|
144
|
+
FileUtils.mkdir(room_path)
|
|
145
|
+
|
|
146
|
+
if wing[:name] == Aro::Dom::GAMES
|
|
147
|
+
File.open(File.join(room_path, Aro::Mancy::NAME_FILE.to_s), "w+") do |f|
|
|
148
|
+
f.write(room[:name])
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def self.ethergeist_name
|
|
154
|
+
File.read(
|
|
155
|
+
File.join(
|
|
156
|
+
Aro::Dom.ethergeist_path, Aro::Mancy::NAME_FILE.to_s
|
|
157
|
+
)
|
|
158
|
+
)
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end # aroadhome
|
data/sys/dom/p.rb
ADDED
data/sys/models/deck.rb
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
|
|
3
|
+
deck.rb
|
|
4
|
+
|
|
5
|
+
deck object.
|
|
6
|
+
|
|
7
|
+
by i2097i
|
|
8
|
+
|
|
9
|
+
=end
|
|
10
|
+
|
|
11
|
+
require :base64.to_s
|
|
12
|
+
require_relative :"../shr/t".to_s
|
|
13
|
+
|
|
14
|
+
class Aro::Deck < ActiveRecord::Base
|
|
15
|
+
has_many :logs
|
|
16
|
+
|
|
17
|
+
DECK_FILE = :".deck"
|
|
18
|
+
CARD_DELIM = :","
|
|
19
|
+
|
|
20
|
+
before_create :populate_cards
|
|
21
|
+
after_commit :generate_log
|
|
22
|
+
|
|
23
|
+
def self.make(new_name)
|
|
24
|
+
return nil unless Aro::Mancy.is_initialized?
|
|
25
|
+
Aro::Db.new
|
|
26
|
+
new_deck = Aro::Deck.create(name: new_name)
|
|
27
|
+
if Aro::Deck.current_deck.nil?
|
|
28
|
+
File.open(Aro::Deck::DECK_FILE.to_s, "w") do |file|
|
|
29
|
+
file.write(new_deck.id)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
new_deck
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.fresh_cards
|
|
36
|
+
I18n.t("cards.index").map{|c| "+#{c}"}.join(Aro::Deck::CARD_DELIM.to_s)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def populate_cards
|
|
40
|
+
self.cards = Aro::Deck.fresh_cards
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def generate_log
|
|
44
|
+
prev_cards = Base64::decode64(logs.last.card_data) if logs.any?
|
|
45
|
+
if prev_cards.present? && prev_cards != cards || prev_cards.nil?
|
|
46
|
+
logs.create(
|
|
47
|
+
card_data: Base64::encode64(cards),
|
|
48
|
+
drawn_data: Base64::encode64(drawn || "")
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.display_selection_menu
|
|
54
|
+
unless Aro::Deck.any?
|
|
55
|
+
Aro::P.say(I18n.t("cli.messages.no_decks"))
|
|
56
|
+
exit(CLI::EXIT_CODES[:SUCCESS])
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
selection = Aro::P.p.select("choose a deck:") do |menu|
|
|
60
|
+
Aro::Deck.all.each{|d|
|
|
61
|
+
if d.id == Aro::Deck.current_deck&.id
|
|
62
|
+
menu.default d.id
|
|
63
|
+
end
|
|
64
|
+
menu.choice(d.name, d.id)
|
|
65
|
+
}
|
|
66
|
+
end
|
|
67
|
+
File.open(Aro::Deck::DECK_FILE.to_s, "w") do |file|
|
|
68
|
+
file.write(selection)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def self.current_deck
|
|
73
|
+
if File.exist?(DECK_FILE.to_s)
|
|
74
|
+
current_deck_id = File.read(DECK_FILE.to_s)
|
|
75
|
+
return Aro::Deck.find_by(id: current_deck_id)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def self.card_strip(card)
|
|
80
|
+
card.gsub(/[+-]/, "").strip
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def show(count_n: Aro::Mancy::S, order_o: Aro::Log::ORDERING[:DESC])
|
|
84
|
+
unless count_n.kind_of?(Numeric) && count_n.to_i > Aro::Mancy::O
|
|
85
|
+
if count_n&.to_s&.to_sym == Aro::Mancy::ALL
|
|
86
|
+
count_n = logs.count
|
|
87
|
+
else
|
|
88
|
+
count_n = Aro::Mancy::S
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
count_n = [[Aro::Mancy::S, count_n.to_i].max, logs.count].min
|
|
92
|
+
Aro::V.say("count_n: #{count_n}")
|
|
93
|
+
Aro::V.say("order_o: #{order_o}")
|
|
94
|
+
|
|
95
|
+
unless Aro::Log::ORDERING.values.include?(order_o)
|
|
96
|
+
Aro::P.say(I18n.t("cli.warnings.invalid_order"))
|
|
97
|
+
order_o = Aro::Log::ORDERING[:DESC]
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# perform query
|
|
101
|
+
h_logs = logs.order(created_at: order_o).first(count_n)
|
|
102
|
+
|
|
103
|
+
# todo: this is doing more work than it needs to. needs debugging.
|
|
104
|
+
# Aro::V.say("h_logs.count: #{h_logs.count}")
|
|
105
|
+
|
|
106
|
+
# for now tests just expect text output
|
|
107
|
+
return h_logs if CLI::Config.is_test?
|
|
108
|
+
|
|
109
|
+
Aro::P.say(I18n.t("cli.messages.showing", name: name, count: count_n, order: order_o))
|
|
110
|
+
|
|
111
|
+
Aos::Vi::Deck.show({
|
|
112
|
+
deck: self,
|
|
113
|
+
h_logs: h_logs,
|
|
114
|
+
count_n: count_n,
|
|
115
|
+
order_o: order_o
|
|
116
|
+
})
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def explore
|
|
120
|
+
# allows user to browse each card in the current deck.
|
|
121
|
+
answer = Aro::P.p.select(
|
|
122
|
+
I18n.t("cli.messages.choose_card"),
|
|
123
|
+
# formatted for tty-prompt gem
|
|
124
|
+
cards.split(Aro::Deck::CARD_DELIM.to_s).map{|c| [I18n.t("cards.#{Aro::Deck.card_strip(c)}.name"), c]}.to_h,
|
|
125
|
+
per_page: Aro::Mancy::NUMERALS[:VII],
|
|
126
|
+
cycle: true,
|
|
127
|
+
default: Aro::Mancy::S
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
Aro::P.say(I18n.t("cards.#{Aro::Deck.card_strip(answer)}"))
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def shuffle
|
|
134
|
+
# shuffles the current deck and generates a log record.
|
|
135
|
+
update(cards: cards.split(Aro::Deck::CARD_DELIM.to_s).shuffle.join(Aro::Deck::CARD_DELIM.to_s))
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def reset
|
|
139
|
+
# completely reset the deck. replace all drawn and reset order.
|
|
140
|
+
# all orientations will be set to upright.
|
|
141
|
+
update(cards: Aro::Deck.fresh_cards, drawn: "")
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def replace
|
|
145
|
+
# replaces all drawn cards FIFO and puts them on the bottom of
|
|
146
|
+
# the deck. this will preserve all card orientations.
|
|
147
|
+
cards_arr = cards.split(Aro::Deck::CARD_DELIM.to_s) || []
|
|
148
|
+
drawn_arr = drawn&.split(Aro::Deck::CARD_DELIM.to_s) || []
|
|
149
|
+
|
|
150
|
+
# append each drawn card to cards
|
|
151
|
+
drawn_arr.each{|dc| cards_arr << dc }
|
|
152
|
+
|
|
153
|
+
# clear drawn
|
|
154
|
+
update(drawn: "", cards: cards_arr.join(Aro::Deck::CARD_DELIM.to_s))
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def draw(is_dt_dimension: true, z_max: 7, z: 1)
|
|
158
|
+
# the true card
|
|
159
|
+
abs_dev_tarot = nil
|
|
160
|
+
|
|
161
|
+
# oriented card
|
|
162
|
+
dev_tarot = nil
|
|
163
|
+
|
|
164
|
+
# get cards
|
|
165
|
+
cards_arr = cards.split(Aro::Deck::CARD_DELIM.to_s) || []
|
|
166
|
+
# get abs_cards
|
|
167
|
+
abs_cards_arr = cards_arr.map{|c| Aro::Deck.card_strip(c)}
|
|
168
|
+
# get drawn
|
|
169
|
+
drawn_arr = drawn&.split(Aro::Deck::CARD_DELIM.to_s) || []
|
|
170
|
+
|
|
171
|
+
sleeps = 0
|
|
172
|
+
sleeps_max = z_max
|
|
173
|
+
|
|
174
|
+
# find a card that is not already drawn
|
|
175
|
+
while sleeps <= sleeps_max && dev_tarot.nil? do
|
|
176
|
+
# use fallback randomness if /dev/tarot unavailable
|
|
177
|
+
if !is_dt_dimension || !File.exist?(Aro::T::DEV_TAROT_FILE.to_s)
|
|
178
|
+
dev_tarot = Aro::T.summon_ruby_facot(cards_arr).split("")
|
|
179
|
+
else
|
|
180
|
+
# preferred randomness
|
|
181
|
+
read_value = Aro::T.read_dev_tarot&.strip&.split("")
|
|
182
|
+
if read_value.count >= Aro::Mancy::N - 1
|
|
183
|
+
dev_tarot = read_value
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
unless dev_tarot.nil?
|
|
188
|
+
abs_dev_tarot = dev_tarot[Aro::Mancy::S] + Aro::Mancy::NUMERALS.key(
|
|
189
|
+
dev_tarot.join("")[Aro::Mancy::OS..].to_i
|
|
190
|
+
).to_s
|
|
191
|
+
if abs_cards_arr.include?(abs_dev_tarot)
|
|
192
|
+
# dev_tarot is valid
|
|
193
|
+
dev_tarot = dev_tarot[Aro::Mancy::O] + abs_dev_tarot
|
|
194
|
+
else
|
|
195
|
+
dev_tarot = nil
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
if dev_tarot.nil?
|
|
200
|
+
# dev_tarot is invalid
|
|
201
|
+
sleeps += 1
|
|
202
|
+
sleep(z.to_i)
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# remove from cards
|
|
207
|
+
cards_arr.delete(cards_arr.select{|c| c.include?(abs_dev_tarot)}.first)
|
|
208
|
+
|
|
209
|
+
# insert dev_tarot to drawn
|
|
210
|
+
drawn_arr << dev_tarot
|
|
211
|
+
|
|
212
|
+
# update database
|
|
213
|
+
update(
|
|
214
|
+
cards: cards_arr.join(Aro::Deck::CARD_DELIM.to_s),
|
|
215
|
+
drawn: drawn_arr.join(Aro::Deck::CARD_DELIM.to_s)
|
|
216
|
+
)
|
|
217
|
+
end
|
|
218
|
+
end
|