Class: CARPS::Reporter
- Inherits:
-
Object
- Object
- CARPS::Reporter
- Defined in:
- lib/carps/mod/dm/reporter.rb
Overview
Used by the dungeon master to generate reports
Subclasses should override the “player_turn” method
Instance Method Summary collapse
-
#ask_player(moniker, question) ⇒ Object
Ask a player some questions.
-
#delete_all_questions ⇒ Object
Delete all questions for all players.
-
#delete_questions(moniker) ⇒ Object
Delete all questions for a player.
-
#delete_reports ⇒ Object
Delete reports.
-
#edit(player) ⇒ Object
Edit the report for a player.
-
#initialize ⇒ Reporter
constructor
A new instance of Reporter.
-
#player_turn(moniker) ⇒ Object
Produce a ClientTurn for the player referred to by the moniker.
-
#player_turns(monikers) ⇒ Object
Produce a hash of email address to ClientTurn objects.
-
#sheet(moniker, sheet) ⇒ Object
A character sheet has been changed.
-
#update_player(player, status) ⇒ Object
Inform the reporter of updates to a player’s status report.
Constructor Details
#initialize ⇒ Reporter
Returns a new instance of Reporter.
29 30 31 32 33 |
# File 'lib/carps/mod/dm/reporter.rb', line 29 def initialize @status = {} @questions = {} @sheets = {} end |
Instance Method Details
#ask_player(moniker, question) ⇒ Object
Ask a player some questions
87 88 89 90 91 92 93 |
# File 'lib/carps/mod/dm/reporter.rb', line 87 def ask_player moniker, question if @questions.member? moniker @questions[moniker].push question else @questions[moniker] = [question] end end |
#delete_all_questions ⇒ Object
Delete all questions for all players
106 107 108 |
# File 'lib/carps/mod/dm/reporter.rb', line 106 def delete_all_questions @questions = {} end |
#delete_questions(moniker) ⇒ Object
Delete all questions for a player
101 102 103 |
# File 'lib/carps/mod/dm/reporter.rb', line 101 def delete_questions moniker @questions.delete moniker end |
#delete_reports ⇒ Object
Delete reports
96 97 98 |
# File 'lib/carps/mod/dm/reporter.rb', line 96 def delete_reports @status = {} end |
#edit(player) ⇒ Object
Edit the report for a player
71 72 73 74 75 76 77 78 79 |
# File 'lib/carps/mod/dm/reporter.rb', line 71 def edit player editor = Editor.load stat = @status[player] unless stat stat = "" end stat = "# Enter report for #{player}\n" + stat @status[player] = editor.edit stat end |
#player_turn(moniker) ⇒ Object
Produce a ClientTurn for the player referred to by the moniker
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/carps/mod/dm/reporter.rb', line 36 def player_turn moniker report = @status[moniker] unless report report = "" end status = StatusReport.new report qtext = @questions[moniker] unless qtext qtext = [] end questions = qtext.map {|q| que = Question.new q} sheet = @sheets[moniker] unless sheet sheet = Sheet::Character.new({}) end stats = sheet.attributes new_sheet = Sheet::NewSheet.new stats ClientTurn.new new_sheet, status, questions end |
#player_turns(monikers) ⇒ Object
Produce a hash of email address to ClientTurn objects
57 58 59 60 61 62 63 |
# File 'lib/carps/mod/dm/reporter.rb', line 57 def player_turns monikers turns = {} monikers.each do |moniker| turns[moniker] = player_turn moniker end turns end |
#sheet(moniker, sheet) ⇒ Object
A character sheet has been changed
66 67 68 |
# File 'lib/carps/mod/dm/reporter.rb', line 66 def sheet moniker, sheet @sheets[moniker] = sheet end |
#update_player(player, status) ⇒ Object
Inform the reporter of updates to a player’s status report
82 83 84 |
# File 'lib/carps/mod/dm/reporter.rb', line 82 def update_player player, status @status[player] = status end |