๐Ÿ’พ Archived View for bbs.geminispace.org โ€บ s โ€บ Interactive-Fiction โ€บ 11756 captured on 2023-12-28 at 16:18:27. Gemini links have been rewritten to link to archived content

View Raw

More Information

โžก๏ธ Next capture (2024-02-05)

-=-=-=-=-=-=-

1974 starting a new gamebook

1974 a gamebook

Just started a gamebook called 1974, about a family living in a local post-apocalypse. The idea is that some fictional country, Redhesia, got into a civil war bad enough to lead to a local collapse in civilization. The outside world has done little but locked them in, patrolling every border so that the "dangerous" refugees cannot come into "civilization".

It takes the form of letters written to an unknown "outsider", the reader, who can advise the protagonists into doing this or that, the server taking care of the rest.

I have like 5 "letters" drafted, but the final thing would have, at least, 50, so it's in a very early form.

As for the script is nothing fancy, a short python program. The data is mostly a dict, with the text being read from separate files, one for each letter.

The main process is a) examine the query string b) if the query string is in the sections dictionary, then call show_section function to display it as gemtext. When the outcome of a player choice is iffy, the script "rolls the dice" as it's generating the gemtext, modifying the links as necessary. That way I don't need to "intercept" a click event as we'd do in javascript.

Wish me luck


import os
from random import randint

sections_dict = {
  "11-13": {
         "filename":"11-13", 
         "options":[
            {
              "text":"Yes",
              "link":"11-14",
              "alt-link":"11-14",
              "dif":0
            },
            {
              "text":"No",
              "link":"11-14F",
              "alt-link":"11-14F",
              "dif":0
            }
             ]
        },
    "11-14": {
         "filename":"11-14", 
         "options":[
            {
              "text":"Yes",
              "link":"11-15",
              "alt-link":"11-15",
              "dif":0
            },
            {
              "text":"No",
              "link":"11-15n",
              "alt-link":"11-15n",
              "dif":0
            }
             ]
        },
    "11-14F": {
         "filename":"11-14F", 
         "options":[]
        },
    "11-15": {
         "filename":"11-15", 
         "options":[
            {
              "text":"Encourage him",
              "link":"11-16a",
              "alt-link":"11-16b",
              "dif":3
            },
            {
              "text":"Let him focus in more practical skills",
              "link":"11-16c",
              "alt-link":"11-16b",
              "dif":3
            }
             ]
        },
    "11-15n": {
         "filename":"11-15n", 
         "options":[
            {
              "text":"Yes",
              "link":"11-16a",
              "alt-link":"11-16b",
              "dif":3
            }
             ]
        },
}

FOOTER ="""___________________________
~  Miguel de Luis (Yretek)
   yretek@proton.me

โ€œ1974โ€ is a work of interactive fiction published on gemini, in the guise of letters, written with the help of virtual dice and python. Readers are encouraged to email me.

โ€œ1974โ€ when completed should have at least 50 sections (or letters) and so it's still a work in progress.

Dedicated to @skyjake as little gesture of gratitude for all his(?) work for gemini.
"""

def print_text(section_filename):
  section_file_path = '../../urney.xyz/data/1974/' + section_filename + '.gmi'
  with open(section_file_path, 'r') as reader:
    print(reader.read())

def show_section(section):
  print_text(section["filename"])
  if len(section["options"]) > 0:
    print("### Options")
    for option in section["options"]:
      dice = randint(1,6)
      if dice < option["dif"]:
        link = "alt-link"
      else:
        link = "link"
      print("=> gemini://urney.xyz/1974?" + option[link],  option["text"])
  else:
    print("### The End")

section_id = os.environ.get("QUERY_STRING")
if not section_id:
  section_id = "11-13"
section = sections_dict.get(section_id)

print("20 text/gemini\r")
print("# Urney.xyz - 1974")

if section:
  show_section(section)
else:
  print('## Something to be ')
  print('This letter has not yet been written.')
print(FOOTER)

Posted in: s/Interactive-Fiction

๐Ÿ•๏ธ Yretek

Nov 16 ยท 6 weeks ago ยท ๐Ÿ‘ skyjake, drh3xx

2 Comments โ†“

๐Ÿš€ skyjake ยท Nov 16 at 12:45:

It's nice to see new IF projects on Gemini!

(Please wrap the code in your post in a preformatted block, though.)

๐Ÿ drh3xx ยท Nov 16 at 12:47:

This sounds interesting. Can't wait for a link when it's completed.