-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoctor.rb
More file actions
43 lines (33 loc) · 1.24 KB
/
doctor.rb
File metadata and controls
43 lines (33 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# This file serves as an example of role-creation
# it's included in server.rb right after game.rb is included
# Initialize the data structure
class Doctor < Villager
include Visiter
@color="G"
def save(night, who, more = nil)
night.act([self, :save, who])
end
def brief_night(players = [])
send("It is time for you to save somebody. Type '@Gvisit <name>@d' to save them, and '@Gwho@d' to see a list of players.");
end
alias_method :visit, :save
end
# What happens when the action is performed
Night::ACTIONS[:save] = proc do |saver, savee|
# This block is run in the context of the current night.
# @player_status is how the night keeps track of what the
# players have done
@player_status[saver] ||= {}
unless @player_status[saver][:who_to_save] # This should only be activated once
at_death do |player, cause|
# Check if this player has been saved
if player == @player_status[saver][:who_to_save]
next :override # this player has been saved!
end
end
end
saver.send("You direct your attempts at saving the life of #{savee}.")
@player_status[saver][:who_to_save] = savee
end
# Note that we don't have to create a new command - the visit command will handle all of this
# for us