aro 0.2.3 → 0.2.5

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 (62) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +101 -42
  3. data/LICENSE +1 -1
  4. data/README.md +1 -1
  5. data/aro.gemspec +10 -10
  6. data/bin/aro +8 -12
  7. data/bin/ino +22 -0
  8. data/checksums/aro-0.2.4.gem.sha512 +1 -0
  9. data/ino_rules_todo.txt +28 -0
  10. data/locale/en.abot.yml +15 -15
  11. data/locale/en.amg.yml +7 -7
  12. data/locale/en.aos.yml +7 -7
  13. data/locale/en.cards.yml +360 -313
  14. data/locale/en.data.yml +1 -1
  15. data/locale/en.dom.yml +3 -2
  16. data/locale/en.flie.yml +1 -1
  17. data/locale/en.ino.yml +9 -0
  18. data/locale/en.usage.yml +152 -69
  19. data/locale/en.yml +5 -3
  20. data/sys/aos/abot.rb +18 -20
  21. data/sys/aos/aos.rb +60 -48
  22. data/sys/aos/cor.rb +11 -14
  23. data/sys/aos/db.rb +1 -3
  24. data/sys/aos/models/agodo.rb +9 -2
  25. data/sys/aos/models/fpxy.rb +0 -2
  26. data/sys/aos/models/ilib.rb +0 -2
  27. data/sys/aos/models/ilog.rb +0 -2
  28. data/sys/aos/models/you.rb +46 -6
  29. data/sys/aos/vws/base.rb +13 -14
  30. data/sys/aos/vws/games/ino.rb +21 -0
  31. data/sys/aos/vws/games/teck.rb +19 -17
  32. data/sys/aos/vws/welcome.rb +1 -1
  33. data/sys/aro/db/migrate/1768856981_create_scrolls.rb +20 -0
  34. data/sys/aro/db/migrate/1768858841_create_legends.rb +16 -0
  35. data/sys/aro/db/migrate/1768858967_create_stories.rb +17 -0
  36. data/sys/aro/db/migrate/1768859060_create_chapters.rb +15 -0
  37. data/sys/aro/db/migrate/1768859126_create_statements.rb +22 -0
  38. data/sys/aro/db/migrate/1768859144_create_players.rb +18 -0
  39. data/sys/aro/db.rb +3 -5
  40. data/sys/aro/ino.rb +64 -0
  41. data/sys/aro/models/chapter.rb +18 -0
  42. data/sys/aro/models/legend.rb +28 -0
  43. data/sys/aro/models/player.rb +17 -0
  44. data/sys/aro/models/scroll.rb +46 -0
  45. data/sys/aro/models/statement.rb +14 -0
  46. data/sys/aro/models/story.rb +28 -0
  47. data/sys/aro/models/teck.rb +44 -13
  48. data/sys/cli/create.rb +1 -1
  49. data/sys/cli/dom.rb +2 -2
  50. data/sys/cli/nterface.rb +15 -9
  51. data/sys/cli/teck.rb +4 -6
  52. data/sys/cli/usage.rb +15 -1
  53. data/sys/dom/dom.rb +6 -2
  54. data/sys/fpx.rb +25 -37
  55. data/sys/shr/ilib/crs/crs.o +0 -0
  56. data/sys/shr/ilib/crs/libcrs.so +0 -0
  57. data/sys/shr/t.rb +2 -2
  58. data/sys/shr/version.rb +1 -1
  59. metadata +38 -22
  60. data/.ruby-version +0 -1
  61. data/sys/aos/models/base_model.rb +0 -13
  62. data/sys/aro/models/base_model.rb +0 -13
data/sys/aos/cor.rb CHANGED
@@ -421,6 +421,7 @@ module Aos
421
421
  Mutex.new.synchronize do
422
422
  def self.get_cor_path
423
423
  if self.instance.cor_path.nil?
424
+ Aos::Db.load
424
425
  if Aro::Dom.in_arodom?
425
426
  Aos::Os.instance.load_you!
426
427
  if Aos::Os.instance.you.root? ||
@@ -457,7 +458,7 @@ module Aos
457
458
  Aos::Cor.ivar(:ENV) == Aos::Cor::ENVS[:TEST].to_s
458
459
  end
459
460
 
460
- def self.display_configuration
461
+ def self.discon
461
462
  height = Aos::Cor.ivar(:HEIGHT).to_i
462
463
  width = Aos::Cor.ivar(:WIDTH).to_i
463
464
  if !Aro::Dom.in_arodom? ||
@@ -487,7 +488,7 @@ module Aos
487
488
  k = Aos::Cor::DEF.keys.filter{|k| k == args[Aro::Mancy::S]&.upcase&.to_sym}&.first
488
489
  unless k.nil?
489
490
  unless args[Aro::Mancy::OS].nil?
490
- # config <var_name> <var_value>
491
+ # config var_name var_value
491
492
  Aos::Cor.set_ivar(args[Aro::Mancy::S], args[Aro::Mancy::OS])
492
493
  end
493
494
 
@@ -677,7 +678,7 @@ module Aos
677
678
  end
678
679
 
679
680
  def lines_div
680
- ["#" * Aro::Mancy::NUMERALS[:XXI].pow(Aro::Mancy::OS)]
681
+ ["".ljust(Aro::Mancy::NUMERALS[:XLII] * Aro::Mancy::OS, "#")]
681
682
  end
682
683
 
683
684
  def lines_newline_comment
@@ -694,13 +695,12 @@ module Aos
694
695
 
695
696
  def lines_config_header
696
697
  [
697
- "# this #{Aos::Os} cor configuration file",
698
- "# was auto generated by the #{Aos::Cor.name}."
698
+ "# #{Aos::Os} cor configuration file generated by #{Aos::Cor.name}."
699
699
  ]
700
700
  end
701
701
 
702
702
  def lines_var_section_div
703
- ["# VARIABLE SECTION!"]
703
+ ["# Aos::Cor::DEF"]
704
704
  end
705
705
 
706
706
  def lines_def_type_description
@@ -712,16 +712,13 @@ module Aos
712
712
  }
713
713
  lines += lines_newline_comment_os
714
714
  lines << "# Aos::Cor::DEF"
715
- lines << "# define & expose an aos cor bash api via ENV variables."
716
- lines << "# there are two types of bash vars in aos."
715
+ lines << "# define and expose an aos cor bash api via ENV variables."
716
+ lines << "# there are two types of cor vars in aos."
717
717
  lines << "# 1) in vars (ivars). "
718
- lines << "# => ivars enter aos from this file during aos init."
719
- lines << "# => cor validates them and uses them unless unvalid."
720
- lines << "# => otherwise aos will use the defaults listed below."
718
+ lines << "# => write variables from this file."
719
+ lines << "# => they are validated and used unless unvalid."
721
720
  lines << "# 2) out vars (ovars)."
722
- lines << "# => ovars are read-only vars that aos cor exposes to bash."
723
- lines << "# => this is useful because it provides a bash interface"
724
- lines << "# => which can be used to write programs on top of aos."
721
+ lines << "# => read-only variables that aos cor exposes to bash."
725
722
  end
726
723
 
727
724
  def lines_var(k, v, mem_v = nil)
data/sys/aos/db.rb CHANGED
@@ -19,12 +19,10 @@ module Aos
19
19
  SQL_FILE = :"aos.sql"
20
20
 
21
21
  def self.load(password = nil)
22
- Aos::Db.configure_logger
23
22
  Mutex.new.synchronize do
24
23
  if Aro::Dom.in_arodom?
24
+ Aos::Db.configure_logger
25
25
  self.instance.set_up_aos(password)
26
- else
27
- Aro::P.say(I18n.t("cli.errors.not_in_aro" , cmd: Aro::Dom.name))
28
26
  end
29
27
  end
30
28
  end
@@ -9,7 +9,6 @@
9
9
  =end
10
10
 
11
11
  require :base64.to_s
12
- require_relative :"./base_model".to_s
13
12
 
14
13
  class Aos::Agodo < ActiveRecord::Base
15
14
  belongs_to :you
@@ -22,7 +21,7 @@ class Aos::Agodo < ActiveRecord::Base
22
21
 
23
22
  def godo
24
23
  godos_per_minute = Aro::Mancy::NUMERALS[:LX].to_f / rate.to_f
25
-
24
+ # todo: this is awful
26
25
  if Time.now - updated_at >= godos_per_minute
27
26
  system("#{:aos} #{self.go} #{Aos::Os::YOU_FLAG} #{self.you.name}")
28
27
  system("#{:aos} #{self.do.gsub("_", " ")} #{Aos::Os::YOU_FLAG} #{self.you.name}")
@@ -44,6 +43,14 @@ class Aos::Agodo < ActiveRecord::Base
44
43
  ]
45
44
  end
46
45
 
46
+ def create_home_directory
47
+ Aro::Dom.instance.generate_agodo_home(self)
48
+ end
49
+
50
+ def home
51
+ File.join(Aro::Dom.room_path(Aro::Dom::ABOT), Aos::Abot::AGODOS_DIR.to_s, self.you.name)
52
+ end
53
+
47
54
  private
48
55
 
49
56
  def create_you
@@ -8,8 +8,6 @@
8
8
 
9
9
  =end
10
10
 
11
- require_relative :"./base_model".to_s
12
-
13
11
  module Aos
14
12
  class Fpxy < ActiveRecord::Base
15
13
  # table_name :fpxies
@@ -10,8 +10,6 @@
10
10
 
11
11
  # installed lib modules section
12
12
 
13
- require_relative :"./base_model".to_s
14
-
15
13
  module CRS
16
14
  SO_FILE = :"libcrs.so".to_s
17
15
  SO_PATH = File.join(
@@ -8,8 +8,6 @@
8
8
 
9
9
  =end
10
10
 
11
- require_relative :"./base_model".to_s
12
-
13
11
  module Aos
14
12
  class Ilog < ActiveRecord::Base
15
13
  belongs_to :you
@@ -8,15 +8,14 @@
8
8
 
9
9
  =end
10
10
 
11
- require_relative :"./base_model".to_s
12
-
13
11
  module Aos
14
12
  class You < ActiveRecord::Base
15
13
  has_many :ilogs
16
14
  has_one :agodo
17
15
  has_many :fpxies
16
+
18
17
  before_validation :set_pwd
19
- before_create :create_home_directory
18
+ before_create :create_home_directory, :create_history_file
20
19
  after_update :clear_aos_display
21
20
 
22
21
  enum :access, [
@@ -25,8 +24,10 @@ module Aos
25
24
  :root,
26
25
  ]
27
26
 
27
+ AOS_HISTORY_FILE = :".aos_history"
28
28
  ARO_SRT_FILE = :".aro_srt"
29
29
 
30
+
30
31
  def generate_ilog(cmd)
31
32
  ilogs.create(
32
33
  pwd: Aos::Os.osify(pwd),
@@ -39,6 +40,7 @@ module Aos
39
40
  name: self.name,
40
41
  home: self.home,
41
42
  pwd: self.pwd,
43
+ stream_bytes: File.stat(stream_file).size
42
44
  }
43
45
  end
44
46
 
@@ -53,6 +55,10 @@ module Aos
53
55
  end
54
56
 
55
57
  def home
58
+ if agodo?
59
+ return agodo.home
60
+ end
61
+
56
62
  File.join(
57
63
  Aro::Dom::dom_root,
58
64
  Aro::Dom.room_path(root? ? Aro::Dom::COR : Aro::Dom::HOME),
@@ -72,21 +78,55 @@ module Aos
72
78
  end
73
79
 
74
80
  def stream(lines)
75
- File.open(File.join(self.home, Aos::You::ARO_SRT_FILE.to_s), "a+") do |aro_srt|
81
+ File.open(stream_file, "a+") do |aro_srt|
76
82
  aro_srt.write(lines.join("\n"))
77
83
  aro_srt.write("\n")
78
84
  end
79
85
  end
80
86
 
87
+ def history
88
+ return "" unless root? || user?
89
+ File.read(history_file).split("\n").compact
90
+ end
91
+
92
+ def add_history(entry)
93
+ return unless root? || user?
94
+ return if entry.nil? || entry.to_s.empty?
95
+ File.open(history_file, "a+") do |aos_history|
96
+ aos_history.write(entry)
97
+ aos_history.write("\n")
98
+ end
99
+ end
100
+
81
101
  private
82
102
 
83
103
  def set_pwd
84
104
  self.pwd = Dir.pwd if self.pwd.nil?
85
105
  end
86
106
 
107
+ def stream_file
108
+ File.join(self.home, Aos::You::ARO_SRT_FILE.to_s)
109
+ end
110
+
111
+ def history_file
112
+ File.join(self.home, Aos::You::AOS_HISTORY_FILE.to_s)
113
+ end
114
+
87
115
  def create_home_directory
88
- return if root? || agodo? || Dir.exist?(File.join(Aro::Dom.room_path(Aro::Dom::HOME), self.name))
89
- Aro::Dom.instance.generate_room(Aro::Dom::D::LAYOUT[:HOME], {name: self.name.to_sym})
116
+ return if root?
117
+
118
+ if agodo?
119
+ agodo&.create_home_directory
120
+ return
121
+ else
122
+ return if Dir.exist?(File.join(Aro::Dom.room_path(Aro::Dom::HOME), self.name))
123
+ Aro::Dom.instance.generate_room(Aro::Dom::D::LAYOUT[:HOME], {name: self.name.to_sym})
124
+ end
125
+ end
126
+
127
+ def create_history_file
128
+ return unless root? || user?
129
+ File.open(history_file, "w+")
90
130
  end
91
131
 
92
132
  def clear_aos_display
data/sys/aos/vws/base.rb CHANGED
@@ -12,7 +12,6 @@ module Aos
12
12
  module Vw
13
13
  class Base
14
14
  BAR = :"".to_s
15
- COL_POW = Proc.new{|n| n.pow(Aro::Mancy::S.to_f / Aro::Mancy::OS.to_f).to_i}
16
15
  MARGIN_V = Aro::Mancy::S
17
16
  MARGIN_H = Aro::Mancy::S
18
17
 
@@ -30,7 +29,7 @@ module Aos
30
29
  return false unless body_lines.kind_of?(Array)
31
30
  lines = []
32
31
 
33
- dc = Aos::Cor.display_configuration
32
+ dc = Aos::Cor.discon
34
33
  width = dc[:WIDTH]
35
34
 
36
35
  if Aro::Dom.in_arodom?
@@ -77,17 +76,8 @@ module Aos
77
76
  def self.get_aos_display_lines
78
77
  # current Aos::Os output
79
78
 
80
- width = Aos::Cor.display_configuration[:WIDTH]
79
+ width = Aos::Cor.discon[:WIDTH]
81
80
  lines = []
82
- Aos::Os.instance.display_lines ||= []
83
- unless Aos::Os.instance.display_lines.empty?
84
- Aos::Os.instance.display_lines.each{|line|
85
- lines << line
86
- }
87
- Aos::Os.instance.display_lines = []
88
- lines << "".center(width)
89
- end
90
-
91
81
  Aos::Db.load
92
82
 
93
83
  the_you = Aos::Os.instance.you_flag || Aos::Os.instance.you
@@ -108,6 +98,15 @@ module Aos
108
98
  lines << ("[ " + present_users.join(" ") + " ]").center(width)
109
99
  end
110
100
  lines << ":you_are_root".center(width) if the_you.root?
101
+ Aos::Os.instance.display_lines ||= []
102
+ unless Aos::Os.instance.display_lines.empty?
103
+ lines << ""
104
+ Aos::Os.instance.display_lines.each{|line|
105
+ lines << line
106
+ }
107
+ Aos::Os.instance.display_lines = []
108
+ lines << ""
109
+ end
111
110
  lines += get_main_divider(width)
112
111
  lines
113
112
  end
@@ -129,7 +128,7 @@ module Aos
129
128
  end
130
129
 
131
130
  def self.viewport_width
132
- dc = Aos::Cor.display_configuration
131
+ dc = Aos::Cor.discon
133
132
  width = dc[:WIDTH]
134
133
  bar_width = (Aos::Vw::Base::BAR.length * Aro::Mancy::OS)
135
134
  h_margin_width = (Aos::Vw::Base::MARGIN_H * Aro::Mancy::OS)
@@ -141,7 +140,7 @@ module Aos
141
140
  hm = Aos::Vw::Base::MARGIN_H
142
141
  bar = Aos::Vw::Base::BAR
143
142
  hm_space = " " * Aos::Vw::Base::MARGIN_H
144
- just = Aos::Cor.display_configuration[:WIDTH] - (hm_space.length + bar.length)
143
+ just = Aos::Cor.discon[:WIDTH] - (hm_space.length + bar.length)
145
144
  (bar + hm_space + (line || "")).ljust(just) + hm_space + bar
146
145
  end
147
146
 
@@ -0,0 +1,21 @@
1
+ =begin
2
+
3
+ vws/games/ino.rb
4
+
5
+ the ino view.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ require_relative :"../base".to_s
12
+
13
+ module Aos
14
+ module Vw
15
+ class Ino < Aos::Vw::Base
16
+ def self.show
17
+ draw(Aro::Ino.instance.display_lines)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -46,6 +46,7 @@ module Aos
46
46
  end
47
47
 
48
48
  def self.show_game(model)
49
+ Aro::Db.load
49
50
  mk = model.keys
50
51
  dp = Aos::Vw::Teck::TECK_PARAMS
51
52
  return nil unless (mk & dp).count == dp.count
@@ -57,9 +58,13 @@ module Aos
57
58
  count_n = model[:count_n]
58
59
  order_o = model[:order_o]
59
60
 
60
- divider = Aos::Vw::Teck::DIV_CHAR.to_s * Aos::Vw::Base.viewport_width
61
+ divider = "".ljust(
62
+ Aos::Vw::Base.viewport_width,
63
+ Aos::Vw::Teck::DIV_CHAR.to_s
64
+ )
61
65
  lines = []
62
66
  lines << divider
67
+ lines << ""
63
68
  lines << "#{teck.name.upcase.center(Aos::Vw::Base.viewport_width)}"
64
69
  tlog_records.each_with_index{|l, i|
65
70
  lines << divider
@@ -72,7 +77,7 @@ module Aos
72
77
  lines << divider
73
78
  cards = Base64::decode64(l.card_data).split(Aro::Teck::CARD_DELIM.to_s)
74
79
  if !cards.nil? && cards.any?
75
- # lines << ""
80
+ lines << ""
76
81
  lines += self.get_display_for_cards(cards)
77
82
  # lines << divider
78
83
  end
@@ -83,9 +88,7 @@ module Aos
83
88
  lines << I18n.t("cli.messages.history_drawn").center(Aos::Vw::Base.viewport_width)
84
89
  lines << divider
85
90
  lines << ""
86
- lines += self.get_display_for_cards(
87
- drawn_cards
88
- )
91
+ lines += self.get_display_for_cards(drawn_cards)
89
92
  # lines << ""
90
93
  # lines << divider
91
94
  end
@@ -98,20 +101,19 @@ module Aos
98
101
  end
99
102
 
100
103
  def self.get_display_for_cards(input = [])
101
- columns = Aos::Vw::Base::COL_POW.call(
102
- Aos::Cor.display_configuration[:WIDTH].to_i
103
- )
104
+ return input unless input.any?
105
+ width = Aos::Cor.discon[:WIDTH]
106
+ c_width = Aro::Mancy::NUMERALS[:XI]
107
+ columns = (width / c_width).to_i
104
108
  lines = []
105
- return lines unless input.any?
106
- card_line = ""
107
- input.each_with_index{|c, i|
108
- s = (i + Aro::Mancy::S) % [Aro::Mancy::S, columns].max
109
- card_line += c.ljust(columns)
110
- if Aro::Mancy::O == s || i == input.count - Aro::Mancy::S
111
- lines << card_line
112
- card_line = ""
109
+ while input.any?
110
+ line = []
111
+ columns.times do
112
+ next if input[Aro::Mancy::O].nil?
113
+ line << input.delete_at(Aro::Mancy::O).center(c_width)
113
114
  end
114
- }
115
+ lines << line.join("")
116
+ end
115
117
  lines << ""
116
118
  lines
117
119
  end
@@ -16,7 +16,7 @@ module Aos
16
16
  def self.show
17
17
  lines = []
18
18
 
19
- dc = Aos::Cor.display_configuration
19
+ dc = Aos::Cor.discon
20
20
  width = dc[:WIDTH]
21
21
 
22
22
  lines << "welcome to #{Aro::Dom.ethergeist_name}".center(width)
@@ -0,0 +1,20 @@
1
+ class CreateScrolls < ActiveRecord::Migration[8.1]
2
+
3
+ def self.up
4
+ create_table :scrolls do |t|
5
+ t.belongs_to :legend, null: false, foreign_key: true
6
+ t.belongs_to :player, null: false, foreign_key: true
7
+ t.string :name, null: false
8
+ t.string :cards, null: false, default: ""
9
+
10
+ t.timestamps
11
+ end
12
+
13
+ add_index :scrolls, :name
14
+ end
15
+
16
+ def self.down
17
+ drop_table :scrolls
18
+ end
19
+
20
+ end
@@ -0,0 +1,16 @@
1
+ class CreateLegends < ActiveRecord::Migration[8.1]
2
+
3
+ def self.up
4
+ create_table :legends do |t|
5
+ t.belongs_to :story, null: false, foreign_key: true
6
+ t.integer :play_to, null: false, default: Aro::Mancy::NUMERALS[:XI]
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+
12
+ def self.down
13
+ drop_table :legends
14
+ end
15
+
16
+ end
@@ -0,0 +1,17 @@
1
+ class CreateStories < ActiveRecord::Migration[8.1]
2
+
3
+ def self.up
4
+ create_table :stories do |t|
5
+ t.belongs_to :legend, null: false, foreign_key: true
6
+ t.belongs_to :chapter, null: false, foreign_key: true
7
+ t.belongs_to :dealer, null: false, foreign_key: true
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+
13
+ def self.down
14
+ drop_table :stories
15
+ end
16
+
17
+ end
@@ -0,0 +1,15 @@
1
+ class CreateChapters < ActiveRecord::Migration[8.1]
2
+
3
+ def self.up
4
+ create_table :chapters do |t|
5
+ t.belongs_to :story, null: false, foreign_key: true
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :chapters
13
+ end
14
+
15
+ end
@@ -0,0 +1,22 @@
1
+ class CreateStatements < ActiveRecord::Migration[8.1]
2
+
3
+ def self.up
4
+ create_table :statements do |t|
5
+ t.belongs_to :player, null: false, foreign_key: true
6
+ t.belongs_to :chapter, null: false, foreign_key: true
7
+
8
+ # all cards in the statement except the word
9
+ t.string :thought, null: false, default: ""
10
+
11
+ # the final card that must be played to close the statement
12
+ t.string :word, null: false, default: ""
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+
18
+ def self.down
19
+ drop_table :statements
20
+ end
21
+
22
+ end
@@ -0,0 +1,18 @@
1
+ class CreatePlayers < ActiveRecord::Migration[8.1]
2
+
3
+ def self.up
4
+ create_table :players do |t|
5
+ t.belongs_to :scroll, null: false, foreign_key: true
6
+ t.integer :you_id, null: false
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :players, :you_id
12
+ end
13
+
14
+ def self.down
15
+ drop_table :players
16
+ end
17
+
18
+ end
data/sys/aro/db.rb CHANGED
@@ -23,10 +23,8 @@ module Aro
23
23
 
24
24
  def self.load
25
25
  Aro::Db.configure_logger
26
- Mutex.new.synchronize do
27
- if Aro::Mancy.in_aro?
28
- self.instance.setup_local_aro
29
- end
26
+ if Aro::Mancy.in_aro?
27
+ self.instance.setup_local_aro
30
28
  end
31
29
  end
32
30
 
@@ -51,7 +49,7 @@ module Aro
51
49
 
52
50
  def setup_local_aro
53
51
  name = Aro::Mancy.in_aro? ? Aro::Mancy.aro_mancy_name : nil
54
- return if name.nil?
52
+ return if name.nil? || name.to_sym == Aos::Os::CMDS[:ABOT][:key]
55
53
 
56
54
  # create local .aro/ directory
57
55
  unless File.exist?(Aro::Db.base_aro_dir)
data/sys/aro/ino.rb ADDED
@@ -0,0 +1,64 @@
1
+ =begin
2
+
3
+ ino.rb
4
+
5
+ aro and ino.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ module Aro
12
+ def self.ino
13
+ Aro::Ino.process_command(ARGV)
14
+ end
15
+
16
+ class Ino
17
+ include Singleton
18
+
19
+ attr_accessor :scroll, :display_lines
20
+
21
+ CMDS = {
22
+ CREATE: {
23
+ key: :create,
24
+ description: I18n.t("ino.commands.description.create"),
25
+ usage: I18n.t("ino.commands.usage.create"),
26
+ }
27
+ }
28
+
29
+ def self.run
30
+
31
+ end
32
+
33
+ def self.process_command(args)
34
+ self.instance.display_lines = args
35
+ args = Aos::Os.sanitize_you(args)
36
+
37
+ if args[Aro::Mancy::O].nil? ||
38
+ CLI::FLAGS[:HELP].include?(args[Aro::Mancy::O].to_sym)
39
+ self.instance.display_lines = [I18n.t("usage.ino")]
40
+ Aos::Vw::Ino.show
41
+ return
42
+ end
43
+
44
+ case args[Aro::Mancy::O].to_sym
45
+ when Aro::Ino::CMDS[:CREATE][:key]
46
+ CLI::Nterface.exit_error_missing_args!(:var_aro_name) if args[Aro::Mancy::S].nil?
47
+ Aro::Db.load
48
+ self.instance.scroll = Aro::Scroll.find_by(name: args[Aro::Mancy::S].strip)
49
+ if self.instance.scroll.nil?
50
+ self.instance.scroll = Aro::Scroll.create(name: args[Aro::Mancy::S].strip)
51
+ self.instance.scroll.players << Aro::Player.create(you_id: Aos::Os.instance.you.id)
52
+ self.instance.display_lines = self.instance.scroll.display_lines
53
+ else
54
+ self.instance.display_lines = [I18n.t("ino.error.scroll_exists")]
55
+ end
56
+ else
57
+ self.instance.display_lines = [I18n.t("ino.messages.invalid_cmd")]
58
+ end
59
+
60
+ Aos::Vw::Ino.show
61
+ end
62
+
63
+ end
64
+ end
@@ -0,0 +1,18 @@
1
+ =begin
2
+
3
+ chapter.rb
4
+
5
+ chapter object.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ # require_relative :story.to_s
12
+ # require_relative :statement.to_s
13
+
14
+ class Aro::Chapter < ActiveRecord::Base
15
+ has_many :statements
16
+ belongs_to :story
17
+
18
+ end
@@ -0,0 +1,28 @@
1
+ =begin
2
+
3
+ legend.rb
4
+
5
+ legend object.
6
+
7
+ by i2097i
8
+
9
+ =end
10
+
11
+ # require_relative :scroll.to_s
12
+ require_relative :"./story".to_s
13
+
14
+ class Aro::Legend < ActiveRecord::Base
15
+ has_one :scroll
16
+ has_many :stories
17
+ belongs_to :story
18
+
19
+ # play_to:integer default 11
20
+
21
+ after_create :create_story
22
+
23
+ private
24
+
25
+ def create_story
26
+ self.story = Aro::Story.create()
27
+ end
28
+ end