1
1
Fork 0
mirror of https://gitlab.com/Oreolek/cloak-salet.git synced 2024-06-16 15:10:54 +03:00

Multiplayer - working

This commit is contained in:
Alexander Yakovlev 2017-07-21 14:15:47 +07:00
parent dfe1c39845
commit b165f1cb5f
2 changed files with 33 additions and 18 deletions

View file

@ -1,8 +1,8 @@
salet.game_id = "8b0c371c-57f4-49b3-ae3c-cba07d1a9733"
salet.game_version = "1.0"
salet.verbRe = /^verb\_(\w+)\_(\w+)$/
salet.beforeAction = (room, actionId) ->
verbRe = /^verb\_(\w+)\_(\w+)$/
match = verbRe.exec(actionId)
match = salet.verbRe.exec(actionId)
if match? and match[1] and match[2]
verb = match[1]
unit = match[2]
@ -49,21 +49,38 @@ $(document).ready(() ->
salet.goBack()
return true
)
$("#page").on("click", "a", (event) ->
if (window.hasOwnProperty('TogetherJS') and !window.remote and TogetherJS.running)
options = {
type: "click"
}
link = $(event.target)
if link.attr("id") != undefined
options.id = link.attr("id")
if link.attr("href") != undefined
options.href = link.attr("href")
if options.href == undefined and options.id == undefined
return
TogetherJS.send(options)
)
window.remote = false
TogetherJS.config("ignoreForms", true)
TogetherJS.config("ignoreMessages", [
"cursor-update",
"keydown",
"scroll-update",
"cursor-update"
"keydown"
"scroll-update"
"form-focus"
"cursor-click"
])
TogetherJS.hub.on("cursor-click", (msg) ->
try
# If the element can't be found this will throw an exception:
element = $(msg.element)
console.log element
if element && element.tagName == 'A'
return salet.processClick($(element).attr("href"))
catch error
TogetherJS.hub.on("click", (msg) ->
if (! msg.sameUrl)
return
window.remote = true
if msg.id != undefined
$("##{msg.id}").trigger("click")
else if msg.href != undefined
$("#page a[href=#{msg.href}]").trigger("click")
window.remote = false
)
salet.beginGame()
@ -249,7 +266,7 @@ sysroom "map",
container: 'map'
})
s.bind('clickNode', (e) ->
switchTab('storytab')
switchTab("storytab")
salet.goTo(e.data.node.id)
)
return ""

View file

@ -51,10 +51,8 @@
</div>
<div class="row">
<div class="footer">
<a href="settings">
<button class="btn btn-outline-primary">Options</button>
</a>
<button id="erase" class="btn btn-outline-danger">Restart</button>
<a href="settings" class="btn btn-outline-primary">Options</a>
<a id="erase" class="btn btn-outline-danger">Restart</a>
</div>
</div>
</div> <!-- End of div.page -->