Class: GameMachine::Commands::ChatCommands
- Inherits:
-
Object
- Object
- GameMachine::Commands::ChatCommands
show all
- Includes:
- MessageHelper
- Defined in:
- lib/game_machine/commands/chat_commands.rb
Instance Method Summary
collapse
-
#chat_channel(topic) ⇒ Object
-
#chat_message(type, message_text, topic, sender_id = nil) ⇒ Object
-
#entity_id ⇒ Object
-
#invite(topic, inviter, invitee) ⇒ Object
-
#invite_message(inviter, invitee, topic) ⇒ Object
-
#join(topic, player_id, invite_id = nil) ⇒ Object
-
#join_message(topic, player_id, invite_id = nil) ⇒ Object
-
#leave(topic, player_id) ⇒ Object
-
#leave_message(topic, player_id) ⇒ Object
-
#register(chat_id, register_as) ⇒ Object
-
#send_group_message(topic, text, player_id) ⇒ Object
-
#send_private_message(text, player_id) ⇒ Object
-
#subscribers(topic) ⇒ Object
#entity, #entity_with_player, #is_component?, #is_entity?, #set_player
Instance Method Details
#chat_channel(topic) ⇒ Object
82
83
84
|
# File 'lib/game_machine/commands/chat_commands.rb', line 82
def chat_channel(topic)
MessageLib::ChatChannel.new.set_name(topic)
end
|
#chat_message(type, message_text, topic, sender_id = nil) ⇒ Object
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/game_machine/commands/chat_commands.rb', line 67
def chat_message(type,message_text,topic,sender_id=nil)
chat_message = MessageLib::ChatMessage.new.set_chat_channel(
chat_channel(topic)
).set_message(message_text).set_type(type)
if sender_id
chat_message.set_sender_id(sender_id)
end
entity(entity_id).set_chat_message(chat_message)
end
|
#entity_id ⇒ Object
78
79
80
|
# File 'lib/game_machine/commands/chat_commands.rb', line 78
def entity_id
'0'
end
|
#invite(topic, inviter, invitee) ⇒ Object
36
37
38
|
# File 'lib/game_machine/commands/chat_commands.rb', line 36
def invite(topic,inviter,invitee)
GameSystems::ChatManager.find.tell(invite_message(inviter,invitee,topic))
end
|
#invite_message(inviter, invitee, topic) ⇒ Object
44
45
46
47
48
49
|
# File 'lib/game_machine/commands/chat_commands.rb', line 44
def invite_message(inviter,invitee,topic)
entity_with_player(inviter,inviter).set_chat_invite(
MessageLib::ChatInvite.new.set_inviter(inviter).
set_invitee(invitee).set_channel_name(topic)
)
end
|
#join(topic, player_id, invite_id = nil) ⇒ Object
28
29
30
|
# File 'lib/game_machine/commands/chat_commands.rb', line 28
def join(topic,player_id,invite_id=nil)
GameSystems::ChatManager.find.tell(join_message(topic,player_id,invite_id))
end
|
#join_message(topic, player_id, invite_id = nil) ⇒ Object
51
52
53
54
55
56
57
58
59
|
# File 'lib/game_machine/commands/chat_commands.rb', line 51
def join_message(topic,player_id,invite_id=nil)
join_msg = MessageLib::JoinChat.new
chat_channel = chat_channel(topic)
if invite_id
chat_channel.set_invite_id(invite_id)
end
join_msg.add_chat_channel(chat_channel)
entity_with_player(player_id,player_id).set_join_chat(join_msg)
end
|
#leave(topic, player_id) ⇒ Object
32
33
34
|
# File 'lib/game_machine/commands/chat_commands.rb', line 32
def leave(topic,player_id)
GameSystems::ChatManager.find.tell(leave_message(topic,player_id))
end
|
#leave_message(topic, player_id) ⇒ Object
61
62
63
64
65
|
# File 'lib/game_machine/commands/chat_commands.rb', line 61
def leave_message(topic,player_id)
entity_with_player(player_id,player_id).set_leave_chat(
MessageLib::LeaveChat.new.add_chat_channel(chat_channel(topic))
)
end
|
#register(chat_id, register_as) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/game_machine/commands/chat_commands.rb', line 20
def register(chat_id,register_as)
message = entity(chat_id).set_chat_register(
MessageLib::ChatRegister.new.set_chat_id(chat_id).
set_register_as(register_as)
)
GameSystems::ChatManager.find.tell(message)
end
|
#send_group_message(topic, text, player_id) ⇒ Object
13
14
15
16
17
18
|
# File 'lib/game_machine/commands/chat_commands.rb', line 13
def send_group_message(topic,text,player_id)
message = chat_message('group',text,topic,player_id)
entity = entity_with_player(player_id,player_id).
set_chat_message(message.chat_message)
GameSystems::ChatManager.find.tell(entity)
end
|
#send_private_message(text, player_id) ⇒ Object
6
7
8
9
10
11
|
# File 'lib/game_machine/commands/chat_commands.rb', line 6
def send_private_message(text,player_id)
message = chat_message('private',text,player_id,player_id)
entity = entity_with_player(player_id,player_id).
set_chat_message(message.chat_message)
GameSystems::ChatManager.find.tell(entity)
end
|
#subscribers(topic) ⇒ Object
40
41
42
|
# File 'lib/game_machine/commands/chat_commands.rb', line 40
def subscribers(topic)
GameMachine::GameSystems::Chat.subscribers_for_topic(topic)
end
|