Class: GamesAndRpgParadise::Mud::Continent
- Inherits:
-
Base
- Object
- Base
- GamesAndRpgParadise::Mud::Continent
show all
- Defined in:
- lib/games_and_rpg_paradise/mud/continent/continent.rb
Overview
GamesAndRpgParadise::Mud::Continent
Constant Summary
collapse
- NAMESPACE =
inspect
Instance Attribute Summary collapse
Class Method Summary
collapse
-
.[](i = ARGV) ⇒ Object
# === GamesAndRpgParadise::Mud::Continent[] ========================================================================= #.
Instance Method Summary
collapse
Methods inherited from Base
#find_adverb_for, #lang_wnum, #sentence, #word_wrap
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ Continent
#
initialize
The first argument should usually be the name of the continent at hand.
#
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/games_and_rpg_paradise/mud/continent/continent.rb', line 56
def initialize(
commandline_arguments = nil,
run_already = true
)
reset
set_commandline_arguments(
commandline_arguments
)
run if run_already
end
|
Instance Attribute Details
#available_settlements ⇒ Object
#
available_settlements
#
44
45
46
|
# File 'lib/games_and_rpg_paradise/mud/continent/continent.rb', line 44
def available_settlements
@available_settlements
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
#
GamesAndRpgParadise::Mud::Continent[]
#
201
202
203
|
# File 'lib/games_and_rpg_paradise/mud/continent/continent.rb', line 201
def self.[](i = ARGV)
new(i)
end
|
Instance Method Details
#add_city(i, optional_n_people = nil) ⇒ Object
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/games_and_rpg_paradise/mud/continent/continent.rb', line 88
def add_city(i, optional_n_people = nil)
if i.is_a? String or i.is_a? Symbol
i = City.new(i)
if optional_n_people
i.set_n_people(optional_n_people.to_s)
end
end
_ = @internal_hash[:cities]
unless _.include? i
_ << i
end
end
|
#cities? ⇒ Boolean
104
105
106
|
# File 'lib/games_and_rpg_paradise/mud/continent/continent.rb', line 104
def cities?
@internal_hash[:cities]
end
|
#coordinates ⇒ Object
#
coordinates
This method will report the coordinates of all settlements.
#
141
142
143
144
145
|
# File 'lib/games_and_rpg_paradise/mud/continent/continent.rb', line 141
def coordinates
all_settlements?.each { |this_settlement|
e '- '+simp(this_settlement.name)+' is at coordinate: '
}
end
|
#feedback ⇒ Object
#
feedback
Little feedback about what this class will contain. This is mostly thought as a debug-method.
#
130
131
132
133
134
|
# File 'lib/games_and_rpg_paradise/mud/continent/continent.rb', line 130
def feedback
cliner {
pp all_settlements?
}
end
|
#n_people? ⇒ Boolean
Also known as:
people?, n_people
#
n_people?
How many people live in the continent altogether.
#
152
153
154
155
156
|
# File 'lib/games_and_rpg_paradise/mud/continent/continent.rb', line 152
def n_people?
_ = 0
all_settlements?.each { |settlement| _ += settlement.n_people?.to_i }
return _
end
|
#name_of_the_continent? ⇒ Boolean
Also known as:
input?
#
name_of_the_continent?
#
120
121
122
|
# File 'lib/games_and_rpg_paradise/mud/continent/continent.rb', line 120
def name_of_the_continent?
@name_of_the_continent
end
|
#reset ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/games_and_rpg_paradise/mud/continent/continent.rb', line 70
def reset
@internal_hash = {}
@internal_hash[:n_people] = 0
@internal_hash[:cities] = []
end
|
#run ⇒ Object
187
188
189
|
# File 'lib/games_and_rpg_paradise/mud/continent/continent.rb', line 187
def run
determine_the_name_of_the_continent(first_argument?)
end
|
#set_n_people(i) ⇒ Object
Also known as:
n_people=
162
163
164
|
# File 'lib/games_and_rpg_paradise/mud/continent/continent.rb', line 162
def set_n_people(i)
@internal_hash[:n_people]
end
|
#set_name ⇒ Object
#
set_name_of_the_continent
#
set_name
115
116
117
118
119
|
# File 'lib/games_and_rpg_paradise/mud/continent/continent.rb', line 115
def set_name_of_the_continent(i = '')
i = i.first if i.is_a? Array
i = i.to_s.dup if i
@name_of_the_continent = i
end
|
#set_name_of_the_continent(i) ⇒ Object
Also known as:
determine_the_name_of_the_continent
#
set_name_of_the_continent
#
111
112
113
114
115
|
# File 'lib/games_and_rpg_paradise/mud/continent/continent.rb', line 111
def set_name_of_the_continent(i = '')
i = i.first if i.is_a? Array
i = i.to_s.dup if i
@name_of_the_continent = i
end
|
#settlements?(be_verbose = true) ⇒ Boolean
Also known as:
settlements_names?
#
settlements?
How many settlements are part of this continent?
This method will answer this question.
#
173
174
175
176
177
178
179
180
181
182
|
# File 'lib/games_and_rpg_paradise/mud/continent/continent.rb', line 173
def settlements?(
be_verbose = true
)
if be_verbose
cliner
e "We have #{n_settlements?} settlements."
all_settlements?.each { |entry| puts entry.name }
cliner
end
end
|