Class: CARPS::Player::Mod

Inherits:
Mod
  • Object
show all
Defined in:
lib/carps/mod/player/mod.rb

Overview

Player mod

subclasses should provide a method called description

description should return a string, a summary of the game. Who wrote it, owns the copyright and where to find the rules are appropriate facts.

Instance Method Summary collapse

Methods inherited from Mod

#mailer=

Constructor Details

#initializeMod

Returns a new instance of Mod.



35
36
37
38
# File 'lib/carps/mod/player/mod.rb', line 35

def initialize
   @sheet = Sheet::Character.new({})
   @first_time = true
end

Instance Method Details

#configuredObject

This game has been configured



41
42
43
# File 'lib/carps/mod/player/mod.rb', line 41

def configured
   @first_time = false
end

#edit_sheetObject

Edit the character sheet



51
52
53
54
# File 'lib/carps/mod/player/mod.rb', line 51

def edit_sheet
   editor.fill @sheet
   @edited = true
end

#first_time?Boolean

This game has never been run before

Returns:

  • (Boolean)


46
47
48
# File 'lib/carps/mod/player/mod.rb', line 46

def first_time?
   @first_time
end

#next_turnObject

Send answers to dungeon master



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/carps/mod/player/mod.rb', line 88

def next_turn
   if @answers
      @mailer.relay @answers
      @turn = nil
      done = true
   end
   if @edited
      @edited = false
      @mailer.relay Sheet::NewSheet.new @sheet.attributes
      done = true
   end
   unless done
      UI::put_error "Nothing to send."
   end
   save
end

#saveObject

Save the game



62
63
64
# File 'lib/carps/mod/player/mod.rb', line 62

def save
   @mailer.save self
end

#show_sheetObject

Show the character sheet



57
58
59
# File 'lib/carps/mod/player/mod.rb', line 57

def show_sheet
   puts @sheet.emit
end

#take_turnObject

Take a turn



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/carps/mod/player/mod.rb', line 67

def take_turn
   if @turn
      @answers = @turn.take
   else
      tu = @mailer.check ClientTurn
      if tu
         @turn = tu
         stats = @turn.sheet.dump
         unless stats.empty?
            @sheet = Sheet::Character.new stats
            UI::highlight "Received new character sheet."
         end
         @answers = @turn.take
      else
         UI::put_error "Turn not received."
      end
   end
   save
end