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

Instance Method Summary collapse

Instance Attribute Details

#battlesObject

FIXME Add Battles (based on Battle Protocols) later



25
26
27
# File 'lib/galaxy/report.rb', line 25

def battles
  @battles
end

#bombingsObject

Bombings in Report



20
21
22
# File 'lib/galaxy/report.rb', line 20

def bombings
  @bombings
end

#fleetsObject

Fleets in Report



23
24
25
# File 'lib/galaxy/report.rb', line 23

def fleets
  @fleets
end

#gameObject

Report game name



12
13
14
# File 'lib/galaxy/report.rb', line 12

def game
  @game
end

#groupsObject

Groups in Report



24
25
26
# File 'lib/galaxy/report.rb', line 24

def groups
  @groups
end

#orderObject

Order (Object?) associated with this report



10
11
12
# File 'lib/galaxy/report.rb', line 10

def order
  @order
end

#ownerObject

Report owner race



11
12
13
# File 'lib/galaxy/report.rb', line 11

def owner
  @owner
end

#planetsObject

Planets in Report



21
22
23
# File 'lib/galaxy/report.rb', line 21

def planets
  @planets
end

#productsObject

Sciences in Report



19
20
21
# File 'lib/galaxy/report.rb', line 19

def products
  @products
end

#racesObject

Establish Data Collections



18
19
20
# File 'lib/galaxy/report.rb', line 18

def races
  @races
end

#routesObject

Routes in Report



22
23
24
# File 'lib/galaxy/report.rb', line 22

def routes
  @routes
end

#serverObject

Report server version (string)



15
16
17
# File 'lib/galaxy/report.rb', line 15

def server
  @server
end

#timeObject

Report time (from server)



14
15
16
# File 'lib/galaxy/report.rb', line 14

def time
  @time
end

#turnObject

Report turn number



13
14
15
# File 'lib/galaxy/report.rb', line 13

def turn
  @turn
end

Instance Method Details

#battle_groupsObject



61
62
63
# File 'lib/galaxy/report.rb', line 61

def battle_groups
  @groups.find_all {|g| g and g.from_battle?} || []
end

#incoming_groupsObject



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

#sciencesObject



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

#shipsObject 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_groupsObject 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_planetsObject 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_planetsObject



86
87
88
# File 'lib/galaxy/report.rb', line 86

def uninhabited_planets
  @planets.find_all {|p| p and p.uninhabited? } || []
end

#your_active_groupsObject



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_groupsObject



69
70
71
# File 'lib/galaxy/report.rb', line 69

def your_groups
  @groups.find_all {|g| g and g.your?} || []
end

#your_planetsObject



82
83
84
# File 'lib/galaxy/report.rb', line 82

def your_planets
  @planets.find_all {|p| p and p.your?} || []
end