Skip to content
Snippets Groups Projects
Commit 67c28b9a authored by dg's avatar dg
Browse files

Achievements are now broadcasted over the community chat

git-svn-id: http://svn.net-core.org/repos/t-engine4@3126 51575b47-30f0-44d4-a5cc-537603b46e54
parent f2470f12
No related branches found
No related tags found
No related merge requests found
......@@ -65,6 +65,15 @@ function _M:event(e)
if type(game) == "table" and game.logChat then
game.logChat("#YELLOW#<%s> %s", e.name, e.msg)
end
elseif e.se == "Achievement" then
e.msg = e.msg:removeColorCodes()
self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}}
self:addMessage(e.channel, e.login, e.name, "has earned the achievement <"..e.msg..">")
if type(game) == "table" and game.logChat then
game.logChat("#LIGHT_BLUE#%s has earned the achievement <%s>", e.name, e.msg)
end
elseif e.se == "Join" then
self.channels[e.channel] = self.channels[e.channel] or {users={}, log={}}
self.channels[e.channel].users[e.login] = {name=e.name, login=e.login}
......@@ -129,6 +138,11 @@ function _M:talk(msg)
core.profile.pushOrder(string.format("o='ChatTalk' channel=%q msg=%q", self.cur_channel, msg))
end
function _M:achievement(name)
if not profile.auth then return end
core.profile.pushOrder(string.format("o='ChatAchievement' channel=%q msg=%q", self.cur_channel, name))
end
--- Request a line to send
-- TODO: make it better than a simple dialog
function _M:talkBox()
......
......@@ -92,6 +92,7 @@ function _M:gainPersonalAchievement(silent, id, src, ...)
if not silent then
game.log("#LIGHT_GREEN#Personal New Achievement: %s!", a.name)
Dialog:simplePopup("Personal New Achievement: #LIGHT_GREEN#"..a.name, a.desc)
profile.chat:achievement(a.name)
end
if a.on_gain then a:on_gain(src, true) end
return true
......@@ -132,6 +133,7 @@ function _M:gainAchievement(id, src, ...)
profile:saveModuleProfile("achievement."..id, self.achieved[id])
game.log("#LIGHT_GREEN#New Achievement: %s!", a.name)
Dialog:simplePopup("New Achievement: #LIGHT_GREEN#"..a.name, a.desc)
profile.chat:achievement(a.name)
if a.on_gain then a:on_gain(src) end
return true
......
......@@ -320,6 +320,11 @@ function _M:orderChatTalk(o)
self:read("200")
end
function _M:orderChatAchievement(o)
self:command("ACHV", o.channel, o.msg)
self:read("200")
end
function _M:orderChatJoin(o)
self:command("JOIN", o.channel)
if self:read("200") then
......
......@@ -32,6 +32,9 @@ function _M:event(e)
if e.e == "ChatTalk" then
cprofile.pushEvent(string.format("e='Chat' se='Talk' channel=%q login=%q name=%q msg=%q", e.channel, e.login, e.name, e.msg))
print("[USERCHAT] channel talk", e.login, e.channel, e.msg)
elseif e.e == "ChatAchievement" then
cprofile.pushEvent(string.format("e='Chat' se='Achievement' channel=%q login=%q name=%q msg=%q", e.channel, e.login, e.name, e.msg))
print("[USERCHAT] channel achievement", e.login, e.channel, e.msg)
elseif e.e == "ChatJoin" then
self.channels[e.channel] = self.channels[e.channel] or {}
self.channels[e.channel][e.login] = true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment