Class: CARPS::Invite

Inherits:
Message show all
Defined in:
lib/carps/service/invite.rb

Overview

An invitation

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Message

#crypt, #crypt=, #delete, #from, #from=, #parse, #path=, #save, #session, #session=

Constructor Details

#initialize(dm, mod, about, session) ⇒ Invite

Returns a new instance of Invite.



35
36
37
38
39
40
# File 'lib/carps/service/invite.rb', line 35

def initialize dm, mod, about, session
   @dm = dm
   @mod = mod
   @about = about
   @session = session
end

Class Method Details

.parse(blob) ⇒ Object

Parse this from semi-structured text



43
44
45
46
47
48
49
# File 'lib/carps/service/invite.rb', line 43

def Invite.parse blob
   dm, blob = find K.master, blob
   mod, blob = find K.mod, blob
   about, blob = find K.about, blob
   session, blob = find K.session, blob
   [Invite.new(dm, mod, about, session), blob] 
end

Instance Method Details

#askObject

Ask if the player wants to accept this invitation, join the game if they do



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/carps/service/invite.rb', line 53

def ask
   puts "You have been invited to a game!"
   if load_mods.member? @mod
      game = Player::GameConfig.new "", @mod, @dm, @about, @session 
      game.display
      if UI::confirm("Do you want to join?")
         filename = UI::question "Enter a file name for the game:"
         game.filename = filename
         game.save
         return game
      else
         return nil
      end
   else
      puts "But it's for the mod: " + @mod 
      puts "Which you don't have installed."
      return nil 
   end
end

#emitObject



73
74
75
# File 'lib/carps/service/invite.rb', line 73

def emit
   V.master(@dm) + V.mod(@mod) + V.about(@about) + V.session(@session)
end