Method: Unit#set_function!
- Defined in:
- lib/lib/units/unit.rb
#set_function!(func, commanding_faction) ⇒ Object
Set desired function
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/lib/units/unit.rb', line 244 def set_function!(func, commanding_faction) # Check your neutrality if @faction == 0 puts PROMPT + to_s + ": neutral units can't have functions set" return end # Check origin of command if commanding_faction != @faction puts PROMPT + to_s + ": this unit does not take commands from other factions" return end # Check your abilities if func == FUNCBUILD and !can_build? puts PROMPT + to_s + ": this unit can't build other units" return end # Check current function and set the new one if @function.func == func puts PROMPT + to_s + ": function is already set to #{@function.func}" else @function.func = func puts PROMPT + to_s + ": function set to #{@function.func}" end end |