Discourse Frotz 🧙

Uau, um novo plugin! :tada: Este é um pouco menos sério, embora. :video_game:

Discourse Frotz


NĂŁo Ă© mais necessĂĄrio mencionar o bot @ a cada passo. Uma vez em jogo, basta responder a ele.

Repositório Git: GitHub - merefield/discourse-frotz: A plugin that uses Frotz to give you an interactive fiction experience on your Discourse forum · GitHub

O que Ă©

É um ‘bot’ com o qual vocĂȘ pode jogar ficção interativa, tambĂ©m conhecida como jogos clĂĄssicos de aventura de texto, no seu fĂłrum Discourse. Ele funciona essencialmente como um adaptador para o interpretador Z-machine padrĂŁo e incrĂ­vel chamado ‘frotz’, disponĂ­vel em David Griffith / frotz · GitLab

Como usar

A configuração adiciona dois jogos; vocĂȘ pode adicionar mais nas configuraçÔes.

Cada entrada contém um Título e o nome do arquivo da história.

Para iniciar a interação, vocĂȘ precisa mencionar o bot definido nas configuraçÔes. Depois disso, responder a uma postagem dele Ă© suficiente.

Para listar os jogos disponĂ­veis, primeiro vocĂȘ precisa mencionar o bot e perguntar:

@meubot listar jogos

Isso fornecerå a variedade de opçÔes.

Para iniciar um jogo, digite:

iniciar jogo x substituindo x pelo nĂșmero da opção.

Se quiser mudar para outro jogo, vocĂȘ pode fazĂȘ-lo; o plugin salva seu progresso a cada movimento, permitindo que vocĂȘ retorne Ă  primeira histĂłria a qualquer momento. O plugin mantĂ©m um save para cada histĂłria para cada usuĂĄrio que tenta.

Para continuar um jogo existente, digite:

continuar jogo x substituindo x pelo nĂșmero da opção.

NB: Uma reconstrução completa destruirå todos os arquivos de save. Isso é um compromisso necessårio.

Como jogar um jogo de IF?

Muitos “Membros” cresceram com essas coisas. Para aqueles menos familiarizados, confira este guia rápido: Play Some Interactive Fiction

Configuração

Criar o UsuĂĄrio Bot

(desculpas, automatizar isso estĂĄ na minha lista!)

Em uma sessĂŁo ssh, entre no seu container e no console rails:

./launcher enter app
rails c

Em seguida, faça o seguinte:

u = User.create!(username: "Frotz", name: "FrotzBot", id:-5, email: "not@really.valid")
u.activate

Seu novo bot estarå então disponível para configuração na interface do usuårio (UI). Vå para as configuraçÔes do usuårio na UI através do botão de administrador e desative todas as notificaçÔes por e-mail. Atualize o avatar conforme seu gosto.

Instalar Discourse Frotz

Atualize seu app.yml

Isso Ă© um pouco mais invasivo do que um plugin comum.

Adicione isso ao app.yml:

hooks:
  after_code:
    - exec:
        cd: $home
        cmd:
          - git clone https://gitlab.com/DavidGriffith/frotz
    - exec:
        cd: $home/frotz
        cmd:
          - make dfrotz
    - exec:
        cd: $home/frotz
        cmd:
          - mkdir savegames
    - exec:
        cd: $home/frotz
        cmd:
          - mkdir stories
    - exec:
        cd: $home/frotz/stories
        cmd:
          - wget -O zork1.z3 https://eblong.com/infocom/gamefiles/zork1-r119-s880429.z3
    - exec:
        cd: $home/frotz/stories
        cmd:
          - wget --no-check-certificate http://www.douglasadams.com/creations/hhgg.z3
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/merefield/discourse-frotz

antes de suas outras entradas de plugin.

Agora vocĂȘ tambĂ©m precisa adicionar o plugin Discourse BBCode!!

Reconstrua com o habitual ./launcher rebuild app

Agora vĂĄ para as configuraçÔes do plugin e selecione o usuĂĄrio bot que vocĂȘ adicionou anteriormente:

image

HistĂłrias

VocĂȘ notarĂĄ que incluĂ­ algumas histĂłrias. VocĂȘ pode encontrar mais em https://ifdb.tads.org/.
Mas, cuidado com os limites de taxa aqui! Obter muitas histĂłrias do mesmo local pode causar um erro.

Observe também que as histórias não estão hospedadas em servidores protegidos por HTTPS (tut tut).

Se vocĂȘ insistir em carregar mais, adicione-as ao app.yml. VocĂȘ tambĂ©m pode adicionĂĄ-las manualmente no prompt de comando, mas saiba que elas serĂŁo apagadas na prĂłxima reconstrução completa.

Habilitar FrotzBot para mensagens privadas (caution advised)

Permite que os usuĂĄrios joguem em particular, mas o uso serĂĄ menos transparente. Se vocĂȘ tiver um servidor grande o suficiente, isso pode nĂŁo ser um problema para vocĂȘ. De qualquer forma, esteja ciente das implicaçÔes para a capacidade. Como alternativa, incentive os usuĂĄrios a jogar em uma Categoria designada.

image
padrĂŁo: DESATIVADO

Se (ele/ela) nĂŁo estiver habilitado lĂĄ, o usuĂĄrio receberĂĄ uma mensagem educada:

Restringir FrotzBot por Categoria

VocĂȘ pode restringir o bot a uma (lista de) Categoria para evitar encher outras ĂĄreas:

Atalhos de teclado!

Isso Ă© realmente importante para melhorar a experiĂȘncia de ‘jogo’. E vocĂȘ realmente sĂł precisa lembrar de dois:

  • Shift-R para responder ao bot

  • Ctrl-Enter para enviar sua prĂłxima jogada

LimitaçÔes e consideraçÔes

Nem todos os formatos de histĂłria e jogos sĂŁo suportados ainda, nem Ă© provĂĄvel que sejam. Existem muitos jogos que nĂŁo funcionam devido Ă  natureza de seus protocolos de chamada e resposta. Por causa da forma como interagimos postagem por postagem, temos que pedir ao Frotz para salvar o estado apĂłs cada movimento. Se uma etapa do jogo nĂŁo levar a um prompt no qual o sistema possa salvar (ignorando “pressione qualquer tecla” ou prompts “Mais” que devem ser tratados), a histĂłria nĂŁo funcionarĂĄ. Por exemplo, em “Act of Murder” (Ăłtimo jogo!), a senhora na porta pergunta se vocĂȘ Ă© um policial. Infelizmente, isso Ă© um estado do jogo que nĂŁo pode ser salvo, falhando nesse requisito, e nĂŁo vejo como farĂ­amos isso funcionar.

NB: O modo de lista de e-mails Ă© um desastre com isso, entĂŁo certifique-se de que isso nĂŁo Ă© algo que vocĂȘ usa antes de tentar usar este plugin!

É, sem dĂșvida, um pouco desperdiçador de recursos do fĂłrum, pois requer pelo menos duas postagens para cada ‘jogada’. Obviamente, muitas vezes Ă© mais apropriado jogar esse tipo de jogo usando uma interface de chat, em vez de um fĂłrum, mas vocĂȘ pode argumentar que isso poderia ser usado para criar Walkthroughs? :wink:

Para uma solução menos invasiva, considere: Turning a topic into interactive fiction ;)

Feedback

Todo feedback Ă© bem-vindo!

Créditos

Este plugin explora David Griffith / frotz · GitLab, o Frotz Z-Interpreter, que Ă© clonado e ‘compilado’ pelo script de configuração.

Obrigado a @P16 por me permitir usar trechos de cĂłdigo de um chatbot de cĂłdigo fechado no qual trabalhamos juntos.

45 curtidas

Wooah, back again!

New Feature-rettes

Enable FrotzBot for private messages (at your peril! :wink: )

Allows users to play in private, but usage will be less transparent. If you have a big enough server this may not be an issue for you.

image
default: OFF

If (s)he is not enabled there, the user will get a polite message:

Restrict to a list of Categories, or allow all:


default: ON for all Categories

10 curtidas

Hi Robert! Thank you, I really like this plugin !
I tried to install it on dev environment (without docker) and my system asked for the ncursesw lib when making dfrotz, after installing that it worked, will it be the case with a prod env with docker?

1 curtida

I tested on Production and building on Docker (to my surpirse) worked out of the box. Feel free to deploy to a Production instance and let me know how you get on.

Glad you like it!!

2 curtidas

For those like me, who might loose their last few hairs about that:

hhgg.z3,9,7,3
that’s :

  story_header_lines = 9
  story_load_lines = 7
  story_save_lines = 3

and now, how to adapt it
 :sweat_smile:, that’s an adventure inside an adventure
!

1 curtida

I’m currently working with the maintainer of Frotz to see if we can do away with those. It’s an approach I ported from restful-Frotz but hardly perfect :slight_smile:

1 curtida

Yes ! found it !
kheper.z8,20,15,4 almost works
for this one :

:smiley:

it’s nothing, but there is something weird

) Line-type display OFF
Compression mode MAX, hiding top 0 lines

is displayed once by Pause() with

[Pause notNeeded;
@read_char 1 notNeeded;
rtrue;
];

1 curtida

Ha, yeah, there are lots of quirks and a considerable amount of variety in the stories. I cannot promise to support all.

Right now my focus is on:

  1. simplifying code
  2. making the code more secure
  3. adding formatting where pragmatic.

#3 is surprisingly hard.

1 curtida

I’ve pushed some improvements to a feature branch:

This does away with the silly suppression settings, introduces translation to BBCode to support formatting and colour, leverages the Dumb Frotz command line options better, obviates the need to write to a text stream and squashes a vulnerability.

This branch requires the official BBCode plugin to be installed.

I’m still experimenting with it. Feel free to do so too.

I’ll probably merge after some significant trials.

1 curtida

Does the plugin need the whole frotz repo clone or does it just need $home/frotz/dfrotz to exist? Because I’d rather just compile it once and save the binary between rebuilds.

Not sure why you would care? The resources we are talking about are comparatively tiny. (6MB for the entire repo post make versus Gigabytes for the forum?). It clones the whole repo, then just makes dfrotz. Perhaps that is slightly wasteful, but the simplicity and repeatability is more important I feel. I could go into greater detail and perform a sparse clone, but that would make the build script more complex and less robust. Would it be worth it? Feel free to suggest an optimisation. This is all building inside the container, so will get cleaned whenever the container does.

I’m just trying to optimize for my tiny server, not asking you to change the general install.

1 curtida

This is a really cool plugin! This reminds me of a “classic” computer game that was created years ago(I forgot the name).

3 curtidas

It’s a great suggestion for a future optimisation if I can keep it simple and robust. Thanks!

1 curtida

Yes there are many playable classics. More via the link in the OP.

2 curtidas

BIG update: :tada: :kiwi_fruit:

(this has taken months of occasional background work and coordination with Frotz team).

Introducing full colour and monospaced formatting for stories

This big update comes with a bunch of improvements:

  • ADDED colour formatting and monospaced text support
  • IMPROVED simplified settings: no longer requires calibration of header and footer, just the desired title and story file, whoop!
  • IMPROVED uses Open3 gem for system commands, reducing risk of abuse/vulnerabilities.
  • IMPROVED internal interaction with command line to remove need for stream files, now copes with more/press any key prompts

Now REQUIRES the Discourse BBCode plugin!!

This required the collaboration of the maintainer of Frotz, David Griffiths and one of the very active members of that community, Borg323 who wrote the BBCode extensions against the BBCode Discourse standard. Many many thanks to them! We had to get a bit creative to get the monospaced text stuff to work, but the solution is really great!

Some examples of the new formatting (I’ve not fully tested these stories, these are just examples of formatting)

and notice the coloured compass here:

KNOWN ISSUES: There are loads of games that don’t work because of the nature of their call and response protocols. If one step of the game doesn’t lead you to a prompt at which you can save (ignoring press any key or More prompts which should be handled), then the story won’t work. e.g. in Act of Murder (great game!) the lady at the door asks if you are a policeman. Unfortunately this is a state of the game that’s unsaveable so fails this requirement and I can’t see a way we would get that to work.

There are probably games that are now compatible with Discourse Frotz that weren’t before 
 please experiment but note the limitation above!

Let me know if you have any issues getting this to work and I’ll refine the instructions as required.

8 curtidas

A reminder that you can use keyboard shortcuts to improve your experience with this plugin:

  • Shift-R to reply to the bot

  • Ctrl-Enter to submit your next move

(Standard out of the box keyboard shortcuts).

5 curtidas

Hi Robert !
finally had time to go further, so far so good, it worked right out of the box in prod env :+1:

Weirdly frotz is not able to respond in private messages unless I also set it in any category :thinking:
Next step : to play :grinning_face_with_smiling_eyes:

1 curtida

Thanks for the report!

I’ve gone ahead and fixed that: FIX: behaviour of private messages playing permission setting · merefield/discourse-frotz@34b022e · GitHub

NTS: must add some unit tests!

2 curtidas

I tried to add :grin: in a source,

it’s going to be fun !

1 curtida