I wanted to make a MUD where everyone is Astrid. Not a great idea for multiplayer, so I transformed that into a single player. Still not a great idea.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.1 KiB
76 lines
2.1 KiB
salet.game_id = "your-game-id-here" |
|
salet.game_version = "1.6" |
|
ably = new Ably.Realtime('v6yAiA.PKvuDg:iJhwQu-DkAWpDOUB') |
|
channel = ably.channels.get('astrid') |
|
|
|
$(document).ready(() -> |
|
window.addEventListener('popstate', (event) -> |
|
salet.goBack() |
|
) |
|
$("#night").on("click", () -> |
|
if (window.night) |
|
styles = { |
|
"-webkit-filter": "" |
|
"filter": "" |
|
"background-color": "" |
|
} |
|
$("body").css(styles) |
|
$("#night").removeClass("active") |
|
window.night = false |
|
else |
|
styles = { |
|
"-webkit-filter": "invert(1)hue-rotate(180deg)" |
|
"filter": "invert(1)hue-rotate(180deg)" |
|
"background-color": "#000" |
|
} |
|
$("body").css(styles) |
|
$("#night").addClass("active") |
|
window.night = true |
|
) |
|
|
|
channel.subscribe('enter', (message) -> |
|
if ( |
|
message.data.room == salet.current and |
|
message.data.name != salet.character.name |
|
) |
|
salet.view.write("В комнату входит "+message.data.name+".") |
|
) |
|
|
|
salet.beginGame() |
|
) |
|
|
|
### |
|
Element helpers. There is no real need to build monsters like a().id("hello") |
|
because you won't use them as is. It does not make sense in context, the |
|
author has Markdown and all utilities to *forget* about the markup. |
|
### |
|
way_to = (content, ref) -> |
|
return "<a href='#{ref}' class='way'>#{content}</a>" |
|
textlink = (content, ref) -> |
|
return "<a href='./_writer_#{ref}' class='once'>#{content}</a>" |
|
actlink = (content, ref) -> |
|
return "<a href='./#{ref}' class='once'>#{content}</a>" |
|
|
|
# The first room of the game. |
|
# For accessibility reasons the text is provided in HTML, not here. |
|
room "start", |
|
enter: () -> |
|
names = [ |
|
'рыжая Астрид', |
|
'Астрид-хулиганка', |
|
'волшебная русалка Астрид', |
|
'Астрид-ведьма' |
|
] |
|
salet.character.name = names[salet.rnd.randomInt(names.length)] |
|
dsc: "" |
|
choices: "#start" |
|
|
|
croom = (name, options) -> |
|
options.enter = () -> |
|
if (salet.interactive) |
|
channel.publish('enter', { |
|
room: @name, |
|
name: salet.character.name |
|
}) |
|
options.dsc = "### #{options.title}\n" + options.dsc |
|
return room(name,options)
|
|
|