Class: ClasslessMud::Commands::Look

Inherits:
Object
  • Object
show all
Defined in:
lib/classless_mud/commands/look.rb

Class Method Summary collapse

Class Method Details

.look_around(player) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/classless_mud/commands/look.rb', line 13

def self.look_around player
  player.puts player.room.description

  if player.room.items.any?
    items = player.room.items.map do |item|
      item.short_description
    end.join(", ")

    player.puts "You also see: #{items}"
  end

  if player.room.characters.any?
    characters = player.room.characters.map do |character|
      character.name
    end.join(", ")

    player.puts "Here: #{characters}"
  end
end

.look_at(player, look_target) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/classless_mud/commands/look.rb', line 33

def self.look_at player, look_target
  found = player.room.find look_target
  if found
    player.puts found.short_description
  else
    player.puts "I don't see that anywhere"
  end
end

.perform(game, player, message) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/classless_mud/commands/look.rb', line 4

def self.perform game, player, message
  look_command, look_target = message.split " ", 2
  if !look_target
    look_around player
  else
    look_at player, look_target
  end
end