Class: HouddUser
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- HouddUser
- Defined in:
- app/models/houdd_user.rb
Overview
This class describes an user of Houdd.
Instance Method Summary (collapse)
-
- (Object) allotment_is_not_100
Validate the total number of allot_for_item, allot_for_const and allot_for_research is 100%.
-
- (Integer) allotment_total_of_production_queue
Return the allotment total of production_queues.
-
- (Integer) allotment_total_of_research
Return the allotment total of researches.
-
- (Array<Specie>) asexual_species
Return asexual species which belong to user.
-
- (Boolean) available_sp_resources?(sp_resources)
Return true or false by whether passed sp_resources are available or not.
-
- (Integer) foods_total
Return the total number of foods in mini_maps.
-
- (Integer) moneys_total
Return the total number of moneys in mini_maps.
-
- (Integer) productions_total
Return the total number of productions in mini_maps.
-
- (Integer) remaining_production_total
Return the total number of remaining productions.
-
- (Array<Specie>) sexual_species
Return sexual species which belong to user.
-
- (Array) sp_resources_all
Return all the sp_resources in mini_maps.
-
- (Array<Specie>) species
Return species which belong to user.
Instance Method Details
- (Object) allotment_is_not_100
Validate the total number of allot_for_item, allot_for_const and allot_for_research is 100%.
20 21 22 23 24 |
# File 'app/models/houdd_user.rb', line 20 def allotment_is_not_100 if not allot_for_item.blank? and not allot_for_const.blank? and not allot_for_research.blank? errors.add(:base, I18n.t('activerecord.errors.models.houdd_user.attributes.allotment_is_not_100')) if (allot_for_item + allot_for_const + allot_for_research) != 100 end end |
- (Integer) allotment_total_of_production_queue
Return the allotment total of production_queues.
86 87 88 89 90 91 92 |
# File 'app/models/houdd_user.rb', line 86 def allotment_total_of_production_queue allotment_total = 0 production_queues.each do |production_queue| allotment_total += production_queue.allotment unless production_queue.allotment.blank? end return allotment_total end |
- (Integer) allotment_total_of_research
Return the allotment total of researches.
96 97 98 99 100 101 102 |
# File 'app/models/houdd_user.rb', line 96 def allotment_total_of_research allotment_total = 0 researches.each do |research| allotment_total += research.allotment unless research.allotment.blank? end return allotment_total end |
- (Array<Specie>) asexual_species
Return asexual species which belong to user. 'Asexual specie' means speice can create new mob by splitting.
54 55 56 57 58 59 60 61 62 |
# File 'app/models/houdd_user.rb', line 54 def asexual_species species = Array.new mobs.each do |mob| species << mob.specie if mob.asexual? end return species.uniq end |
- (Boolean) available_sp_resources?(sp_resources)
Return true or false by whether passed sp_resources are available or not.
133 134 135 |
# File 'app/models/houdd_user.rb', line 133 def available_sp_resources?(sp_resources) return sp_resources_all.include?(sp_resources) end |
- (Integer) foods_total
Return the total number of foods in mini_maps.
66 67 68 69 70 71 72 |
# File 'app/models/houdd_user.rb', line 66 def foods_total foods_total = 0 mini_maps.each do |map| foods_total += map.foods_total end return foods_total end |
- (Integer) moneys_total
Return the total number of moneys in mini_maps.
112 113 114 115 116 117 118 |
# File 'app/models/houdd_user.rb', line 112 def moneys_total moneys_total = 0 mini_maps.each do |map| moneys_total += map.moneys_total end return moneys_total end |
- (Integer) productions_total
Return the total number of productions in mini_maps.
76 77 78 79 80 81 82 |
# File 'app/models/houdd_user.rb', line 76 def productions_total productions_total = 0 mini_maps.each do |map| productions_total += map.productions_total end return productions_total end |
- (Integer) remaining_production_total
Return the total number of remaining productions.
106 107 108 |
# File 'app/models/houdd_user.rb', line 106 def remaining_production_total return productions_total - allotment_total_of_production_queue - allotment_total_of_research end |
- (Array<Specie>) sexual_species
Return sexual species which belong to user. 'Sexual specie' means speice can create new mob by mating.
41 42 43 44 45 46 47 48 49 |
# File 'app/models/houdd_user.rb', line 41 def sexual_species species = Array.new mobs.each do |mob| species << mob.specie if not mob.asexual? end return species.uniq end |
- (Array) sp_resources_all
Return all the sp_resources in mini_maps.
122 123 124 125 126 127 128 |
# File 'app/models/houdd_user.rb', line 122 def sp_resources_all sp_resource_all = Array.new mini_maps.each do |map| sp_resource_all << map.sp_resources_all unless map.sp_resources_all.blank? end return sp_resource_all.uniq end |
- (Array<Specie>) species
Return species which belong to user.
28 29 30 31 32 33 34 35 36 |
# File 'app/models/houdd_user.rb', line 28 def species species = Array.new mobs.each do |mob| species << mob.specie end return species.uniq end |