Module: Gamedata
- Included in:
- Report
- Defined in:
- lib/galaxy/report.rb
Overview
Module Gamedata provides G+ game-related data elements and collections and defines basic accessors to them for any Class including this module
Instance Attribute Summary collapse
-
#battles ⇒ Object
FIXME Add Battles (based on Battle Protocols) later.
-
#bombings ⇒ Object
Bombings in Report.
-
#fleets ⇒ Object
Fleets in Report.
-
#game ⇒ Object
Report game name.
-
#groups ⇒ Object
Groups in Report.
-
#order ⇒ Object
Order (Object?) associated with this report.
-
#owner ⇒ Object
Report owner race.
-
#planets ⇒ Object
Planets in Report.
-
#products ⇒ Object
Sciences in Report.
-
#races ⇒ Object
Establish Data Collections.
-
#routes ⇒ Object
Routes in Report.
-
#server ⇒ Object
Report server version (string).
-
#time ⇒ Object
Report time (from server).
-
#turn ⇒ Object
Report turn number.
Instance Method Summary collapse
- #battle_groups ⇒ Object
- #incoming_groups ⇒ Object
- #initialize(*args) ⇒ Object
- #sciences ⇒ Object
- #ships ⇒ Object (also: #designs)
- #unidentified_groups ⇒ Object (also: #unknown_groups)
- #unidentified_planets ⇒ Object (also: #unknown_planets)
- #uninhabited_planets ⇒ Object
- #your_active_groups ⇒ Object
- #your_groups ⇒ Object
- #your_planets ⇒ Object
Instance Attribute Details
#battles ⇒ Object
FIXME Add Battles (based on Battle Protocols) later
25 26 27 |
# File 'lib/galaxy/report.rb', line 25 def battles @battles end |
#bombings ⇒ Object
Bombings in Report
20 21 22 |
# File 'lib/galaxy/report.rb', line 20 def bombings @bombings end |
#fleets ⇒ Object
Fleets in Report
23 24 25 |
# File 'lib/galaxy/report.rb', line 23 def fleets @fleets end |
#game ⇒ Object
Report game name
12 13 14 |
# File 'lib/galaxy/report.rb', line 12 def game @game end |
#groups ⇒ Object
Groups in Report
24 25 26 |
# File 'lib/galaxy/report.rb', line 24 def groups @groups end |
#order ⇒ Object
Order (Object?) associated with this report
10 11 12 |
# File 'lib/galaxy/report.rb', line 10 def order @order end |
#owner ⇒ Object
Report owner race
11 12 13 |
# File 'lib/galaxy/report.rb', line 11 def owner @owner end |
#planets ⇒ Object
Planets in Report
21 22 23 |
# File 'lib/galaxy/report.rb', line 21 def planets @planets end |
#products ⇒ Object
Sciences in Report
19 20 21 |
# File 'lib/galaxy/report.rb', line 19 def products @products end |
#races ⇒ Object
Establish Data Collections
18 19 20 |
# File 'lib/galaxy/report.rb', line 18 def races @races end |
#routes ⇒ Object
Routes in Report
22 23 24 |
# File 'lib/galaxy/report.rb', line 22 def routes @routes end |
#server ⇒ Object
Report server version (string)
15 16 17 |
# File 'lib/galaxy/report.rb', line 15 def server @server end |
#time ⇒ Object
Report time (from server)
14 15 16 |
# File 'lib/galaxy/report.rb', line 14 def time @time end |
#turn ⇒ Object
Report turn number
13 14 15 |
# File 'lib/galaxy/report.rb', line 13 def turn @turn end |
Instance Method Details
#battle_groups ⇒ Object
61 62 63 |
# File 'lib/galaxy/report.rb', line 61 def battle_groups @groups.find_all {|g| g and g.from_battle?} || [] end |
#incoming_groups ⇒ Object
65 66 67 |
# File 'lib/galaxy/report.rb', line 65 def incoming_groups @groups.find_all {|g| g and g.incoming?} || [] end |
#initialize(*args) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/galaxy/report.rb', line 27 def initialize *args # When object of any including Class is instantiated (and calling super), # modify ActiveRecord:Base and point @@dataset attribute to this object ActiveRecord::Base.establish_dataset(self) # Initialize G+ collections @races = HashArray.new @bombings = HashArray.new @planets = HashArray.new @routes = HashArray.new @fleets = HashArray.new @groups = HashArray.new @products = HashArray.new # Generate Products that are present in each G+ report by default @products['Drive_Research'] = Product.new [], {:name=>'Drive', :prod_type=>'research'} @products['Weapons_Research'] = Product.new [], {:name=>'Weapons', :prod_type=>'research'} @products['Shields_Research'] = Product.new [], {:name=>'Shields', :prod_type=>'research'} @products['Cargo_Research'] = Product.new [], {:name=>'Cargo', :prod_type=>'research'} @products['Capital'] = Product.new [], {:name=>'Capital', :prod_type=>'cap'} @products['Materials'] = Product.new [], {:name=>'Materials', :prod_type=>'mat'} super *args end |
#sciences ⇒ Object
52 53 54 |
# File 'lib/galaxy/report.rb', line 52 def sciences @products.find_all {|p| p and p.race and p.science?} || [] #redefine find_all in HashArray? end |
#ships ⇒ Object Also known as: designs
56 57 58 |
# File 'lib/galaxy/report.rb', line 56 def ships @products.find_all {|p| p and p.race and p.ship?} || [] #redefine find_all in HashArray? end |
#unidentified_groups ⇒ Object Also known as: unknown_groups
77 78 79 |
# File 'lib/galaxy/report.rb', line 77 def unidentified_groups @groups.find_all {|g| g and g.unidentified?} || [] end |
#unidentified_planets ⇒ Object Also known as: unknown_planets
90 91 92 |
# File 'lib/galaxy/report.rb', line 90 def unidentified_planets @planets.find_all {|p| p and p.unidentified? } || [] end |
#uninhabited_planets ⇒ Object
86 87 88 |
# File 'lib/galaxy/report.rb', line 86 def uninhabited_planets @planets.find_all {|p| p and p.uninhabited? } || [] end |
#your_active_groups ⇒ Object
73 74 75 |
# File 'lib/galaxy/report.rb', line 73 def your_active_groups @groups.find_all {|g| g and g.your_active?} || [] end |
#your_groups ⇒ Object
69 70 71 |
# File 'lib/galaxy/report.rb', line 69 def your_groups @groups.find_all {|g| g and g.your?} || [] end |
#your_planets ⇒ Object
82 83 84 |
# File 'lib/galaxy/report.rb', line 82 def your_planets @planets.find_all {|p| p and p.your?} || [] end |