Class: CARPS::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/carps/mod/dm/resource.rb

Overview

Resource manager

Instance Method Summary collapse

Constructor Details

#initialize(rdir) ⇒ Resource

Takes as an argument a directory, within the users campaign directory



30
31
32
# File 'lib/carps/mod/dm/resource.rb', line 30

def initialize rdir
   @dir = $CONFIG + "campaigns/#{rdir}"
end

Instance Method Details

#new_npc(type) ⇒ Object

Create a new npc of a given type



35
36
37
38
39
40
41
42
43
# File 'lib/carps/mod/dm/resource.rb', line 35

def new_npc type
   sheet_loc = @dir + "/npcs/" + type + ".yaml"
   begin
      Sheet::Character.new YAML::load File.read sheet_loc
   rescue
      UI::warn "Could not create NPC: " + sheet_loc
      return nil
   end
end

#player_in(player, room_name) ⇒ Object

This player is in this room



56
57
58
59
60
61
# File 'lib/carps/mod/dm/resource.rb', line 56

def player_in player, room_name
   room = load_room room_name
   if room
      update_reporter player, room
   end
end

#players_in(players, room_name) ⇒ Object

Put everyone in this room



46
47
48
49
50
51
52
53
# File 'lib/carps/mod/dm/resource.rb', line 46

def players_in players, room_name
   room = load_room room_name
   if room
      players.each do |player|
         update_reporter player, room
      end
   end
end

#reporter=(report) ⇒ Object

Register a reporter, update the reporter with changes



64
65
66
# File 'lib/carps/mod/dm/resource.rb', line 64

def reporter= report
   @reporter = report
end