{"id":18564838,"url":"https://github.com/marcoplaitano/interactive-fiction","last_synced_at":"2025-04-10T04:32:05.490Z","repository":{"id":177293401,"uuid":"456878000","full_name":"marcoplaitano/interactive-fiction","owner":"marcoplaitano","description":"A choice-based interactive fiction game implemented in Python","archived":false,"fork":false,"pushed_at":"2024-04-08T10:18:07.000Z","size":20,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T16:11:08.639Z","etag":null,"topics":["choice-based-game","cli-game","interactive-fiction","interactive-fiction-game","python-cli-game","python-game","text-adventure","text-adventure-game"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcoplaitano.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-08T10:07:05.000Z","updated_at":"2023-08-17T20:21:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"9e56c2f0-305b-4e12-a60d-4a9c18bb80b4","html_url":"https://github.com/marcoplaitano/interactive-fiction","commit_stats":null,"previous_names":["marcoplaitano/interactive-fiction"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoplaitano%2Finteractive-fiction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoplaitano%2Finteractive-fiction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoplaitano%2Finteractive-fiction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoplaitano%2Finteractive-fiction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcoplaitano","download_url":"https://codeload.github.com/marcoplaitano/interactive-fiction/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248157527,"owners_count":21057029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["choice-based-game","cli-game","interactive-fiction","interactive-fiction-game","python-cli-game","python-game","text-adventure","text-adventure-game"],"created_at":"2024-11-06T22:16:29.312Z","updated_at":"2025-04-10T04:32:05.193Z","avatar_url":"https://github.com/marcoplaitano.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# INTERACTIVE FICTION\n\nA choice-based interactive fiction game implemented in Python.\n\nIn [this type] of game, the player is presented with a situation, a \"scene\", and\nthe only way to progress is by choosing the next move from a list of possible\nactions related to that particular scene.  \nEach action results in a different outcome, leading to a new situation.\n\n![demo image]\n\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n## Usage\n\nClone this repository and run the main script:\n\n```shell\npython3 src/main.py\n```\n\n### How to play\n\nEvery scene is presented with a **title**, a **description** and a numbered list of\nall the possible **actions**.  \nTo choose from the list, simply type in the number corresponding to the action\nyou want to perform.\n\n#### Passwords\n\nWhen you choose an action you might be asked to input a string to actually\nperform it.  \nOnly if the string given in input matches a certain value the action will be\nconsidered successful.  \nAn example of this might be choosing actions similar to \"*Answer the question*\"\nor \"*Type the password*\".\n\n#### Menu\n\nType `0` at any time during the game to access the menu and perform actions\nlike saving/loading the progress or quitting the game.\n\n#### Save \u0026 Load\n\nYou can save \u0026 load the progress to/from a text file via the game's menu.\n\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n## Write a new story\n\nThe source code is completely oblivious of the game's story.  \nIt is really easy to tweak the example presented or write a completely different\nstory.  \nTo do so, edit the given [JSON file].\n\nThe entirety of the game data can be represented with 3 simple abstractions:\n\n### Scene\n\nThe JSON object representing a **Scene** has the following elements:\n\n+ `title`  \nA short string\n+ `description`  \nA string, or an array of strings.  \nIf a string, use `\\n` to indicate new lines; if an array, each entry is a\nnew line.\n+ `tag`  \nA non-negative, unique integer to identify the scene with.  \nThe tag of the initial scene of the game must be `0`.\n+ `gameOver`  \nBoolean value; if `true` the game ends when the player reaches the scene.\n+ `actions`  \nAn array of **Action** objects.  \n\n### Action\n\nThe JSON object representing an **Action** has the following elements:\n\n+ `prompt`  \nA string that describes the action.\n+ `result`  \nA non-negative integer; it represents the `tag` of the **Scene** that will\nfollow the performing of this action.\n\nOptionally, an **Action** may contain a **Password** object.\n\n### Password\n\nThe JSON object representing a **Password** has the following elements:\n\n+ `value`  \nString that will be compared to the user input.\n+ `fail`  \nA non-negative integer; it represents the `tag` of the **Scene** that will\nfollow the performing of this action if the user input does not match the\npassword's `value`.\n\n### Example:\n\n```yaml\n[\n  {\n    \"title\": \"Scene 0\",\n    # --- Example of description with single string.\n    \"description\": \"Describe this scene.\\nNew line with escape character.\",\n    # --- The first scene must have tag = 0\n    \"tag\": 0,\n    \"gameOver\": false,\n    \"actions\": [\n      { \"prompt\": \"Go to scene 1\", \"result\": 1 },\n      { \"prompt\": \"Go to scene 2\", \"result\": 2 }\n    ]\n  },\n\n  {\n    \"title\": \"Scene 1\",\n    # --- Example of description with array of strings.\n    \"description\": [\"A new scene of the game.\", \"New line in description.\"],\n    \"tag\": 1,\n    \"gameOver\": false,\n    \"actions\": [\n      { \"prompt\": \"Go back\", \"result\": 0 },\n      # --- Go to scene 2 if user answers \"hello\", scene 0 otherwise.\n      { \"prompt\": \"What is the meaning of ciao?\", \"result\": 2,\n            \"password\": { \"value\": \"hello\", \"fail\": 0 }\n      }\n    ]\n  },\n\n  {\n    \"title\": \"Scene 2\",\n    \"description\": [\"End of the Game.\"],\n    \"tag\": 2,\n    # --- The game ends in this scene. The array of actions is empty.\n    \"gameOver\": true,\n    \"actions\": []\n  }\n]\n```\n\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n## Author\n\nMarco Plaitano\n\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n## License\n\nDistributed under the [MIT] license.\n\n\u003c!-- LINKS --\u003e\n\n[this type]:\nhttps://www.ifwiki.org/Choice-based_interactive_fiction\n\"Wiki Article\"\n\n[demo image]:\nhttps://github.com/marcoplaitano/images/blob/main/interactive_fiction_demo.png\n\"Demo image\"\n\n[JSON file]:\ndata/story.json\n\"Repository file\"\n\n[MIT]:\nLICENSE\n\"Repository file\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcoplaitano%2Finteractive-fiction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcoplaitano%2Finteractive-fiction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcoplaitano%2Finteractive-fiction/lists"}