NetAF 3.8.6

dotnet add package NetAF --version 3.8.6
                    
NuGet\Install-Package NetAF -Version 3.8.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NetAF" Version="3.8.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetAF" Version="3.8.6" />
                    
Directory.Packages.props
<PackageReference Include="NetAF" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NetAF --version 3.8.6
                    
#r "nuget: NetAF, 3.8.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NetAF@3.8.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NetAF&version=3.8.6
                    
Install as a Cake Addin
#tool nuget:?package=NetAF&version=3.8.6
                    
Install as a Cake Tool

NetAF

A C# library that provides a framework for building text adventures and interactive stories in .NET.

Overview

NetAF is a simple, lightweight library for building text based adventures.

At its core NetAF provides simple classes for developing and controlling the flow of games.

Environments

Environments are broken down into three elements - Overworld, Region and Room. An Overworld contains one or more Regions. A Region contains one or more Rooms. A Room can contain up to six exits (north, south, east, west, up and down).

Overworld
├── Region
│   ├── Room
│   ├── Room
│   ├── Room
├── Region
│   ├── Room
│   ├── Room

Exits

Rooms contain exits. Exits can be locked to block progress through the game.

var room = new Room("Test Room", "A test room.", [new Exit(Direction.North)]);

Items

Items add richness to a game. Items support interaction with the player, rooms, other items and NPC's. Items can morph in to other items. For example, using item A on item B may cause item B to morph into item C.

var sword = new Item("Sword", "The heroes sword.");

Playable Character

Each NetAF game has at least one playable character. The game is played through the view point of a playable character.

var player = new PlayableCharacter("Dave", "The hero of the story.");

Non-playable Characters

Non-playable characters (NPC's) can be added to rooms and can help drive the narrative. NPC's can hold conversations, contains items, and interact with items.

var npc = new NonPlayableCharacter("Gary", "The antagonist of the story.");

Commands

NetAF provides commands for interacting with game elements:

  • Drop X - drop an item, where X is the item.
  • Examine X - allows items, characters and environments to be examined.
  • Take X - take an item, where X is the item.
  • Talk to X - talk to a NPC, where X is the NPC.
  • Use X on Y - use an item. Items can be used on a variety of targets. Where X is the item and Y is the target.
  • N, S, E, W, U, D - traverse through the rooms in a region.

NetAF also provides global commands to help with game flow and option management:

  • About - display version information.
  • Exit - exit the game.
  • Help X - display the help screen for a command, where X is the command.
  • History - display in-game history.
  • Notes - display any gathered in-game notes.
  • Commands - display the command list.
  • Commands On / Commands Off - toggle commands on/off.
  • Key On / Key Off - turn the Key on/off.
  • Map - display the map.
  • New - start a new game.

Custom commands can be added to games without the need to extend the existing interpretation.

Interpretation

NetAF provides classes for handling interpretation of input. Interpretation is extensible with the ability for custom interpreters to be added outside of the core NetAF library.

Conversations

Conversations can be held between the player and a NPC. Conversations support multiple lines of dialogue and responses.

Attributes

All game assets support customisable attributes. This provides the possibility to build systems within a game, for example adding currency and trading, adding HP to enemies, MP to your character, durability to Items etc.

Rendering

NetAF provides frames for rendering the various game screens. These are fully extensible and customisable. These include:

  • Scene frame - for displaying scenes in the game.
  • Help frame - for displaying in-game help for a specific command.
  • Map frame - for displaying the map.
  • Title frame - for displaying the title screen.
  • Completion frame - for displaying game complete.
  • Game over frame - for displaying game over.
  • Conversation frame - for displaying a conversation.
  • Visual frame - for displaying a visual.
  • Command list frame - for displaying a list of commands.
  • Note frame - for displaying any in-game notes.
  • History frame - for displaying in-game history.
Visuals

Although NetAF is primarily focused on text and interactive fiction, there are times where adding a visual can enrich the game.

For more information see the Visuals topic.

The NetAF.Imaging extension package can be used to extend the basic NetAF visual functions to allow conversion of images to visuals that can be displayed in a game.

NO_COLOR

NetAF supports the NO_COLOR standard through the NO_COLOR environment variable. To disable color in console output add the NO_COLOR environment variable and assign it a non-empty value. This will disable color output on the console.

Maps

Maps are automatically generated for regions and rooms, and can be viewed with the map command:

Maps display visited rooms, exits, player position, if an item is in a room, lower floors and more. Maps support panning and switching between vertical levels.

Persistence

Game state can be serialized allowing progress to be saved to file and restored later.

Targets

NetAF natively targets both the console and web and other targets can be added as needed. Included in the repo are both Console and Blazor examples.

Getting Started

Clone the repo/pull NuGet

Clone the repo:

git clone https://github.com/benpollarduk/netaf.git

Or add the NuGet package:

dotnet add package NetAF

Hello World

// create the player. this is the character the user plays as
var player = new PlayableCharacter("Dave", "A young boy on a quest to find the meaning of life.");

// create region maker. the region maker simplifies creating in game regions. a region contains a series of rooms
var regionMaker = new RegionMaker("Mountain", "An imposing volcano just East of town.")
{
    // add a room to the region at position x 0, y 0, z 0
    [0, 0, 0] = new Room("Cavern", "A dark cavern set in to the base of the mountain.")
};

// create overworld maker. the overworld maker simplifies creating in game overworlds. an overworld contains a series or regions
var overworldMaker = new OverworldMaker("Daves World", "An ancient kingdom.", regionMaker);

// create the callback for generating new instances of the game
// - information about the game
// - an introduction to the game, displayed at the star
// - asset generation for the overworld and the player
// - the conditions that end the game
// - the configuration for the game
var gameCreator = Game.Create(
    new GameInfo("The Life of Dave", "A very low budget adventure.", "Ben Pollard"),
    "Dave awakes to find himself in a cavern...",
    AssetGenerator.Retained(overworldMaker.Make(), player),
    GameEndConditions.NoEnd,
    ConsoleGameConfiguration.Default);

// begin the execution of the game
Game.Execute(gameCreator);

Tutorial

The quickest way to start getting to grips with NetAF is to take a look at the Getting Started page.

Example game

An example game is provided in the NetAF.Example directory and has been designed with the aim of showcasing the various features.

Set either the NetAF.Example.Console or NetAF.Example.Blazor project as the start up project and then build and run to start the application.

Documentation

Please visit https://benpollarduk.github.io/NetAF-docs/ to view the NetAF documentation.

For Open Questions

Visit https://github.com/benpollarduk/NetAF/issues

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on NetAF:

Package Downloads
NetAF.Blazor

An open source library containing Blazor components to allow NetAF to be using in Blazor applications. For examples see the project website at https://github.com/benpollarduk/netaf.blazor.

NetAF.Imaging

An extension to the NetAF library to add imaging capabilities. For examples see the project website at https://github.com/benpollarduk/netaf.imaging.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.8.6 151 7/14/2025
3.8.5 133 7/14/2025
3.8.4 91 7/11/2025
3.8.3 145 7/10/2025
3.8.2 136 7/10/2025
3.8.1 139 7/10/2025
3.8.0 130 7/10/2025
3.7.14 137 7/2/2025
3.7.13 136 7/2/2025
3.7.12 144 6/30/2025
3.7.11 293 5/14/2025
3.7.10 225 5/13/2025
3.7.9 146 5/8/2025
3.7.8 140 5/8/2025
3.7.7 158 5/7/2025
3.7.6 161 5/1/2025
3.7.5 147 5/1/2025
3.7.4 141 5/1/2025
3.7.3 165 4/29/2025
3.7.2 171 4/28/2025
3.7.1 123 4/25/2025
3.7.0 108 4/25/2025
3.6.3 171 4/24/2025
3.6.2 170 4/24/2025
3.6.1 304 4/24/2025
3.6.0 195 4/22/2025
3.5.2 203 4/17/2025
3.5.1 182 4/16/2025
3.5.0 201 4/15/2025
3.4.6 188 4/15/2025
3.4.5 229 4/10/2025
3.4.4 167 4/10/2025
3.4.3 166 4/9/2025
3.4.2 192 4/8/2025
3.4.1 178 4/8/2025
3.4.0 154 4/8/2025
3.3.8 179 3/30/2025
3.3.7 152 3/30/2025
3.3.6 163 3/30/2025
3.3.5 128 3/28/2025
3.3.4 145 3/27/2025
3.3.3 143 3/27/2025
3.3.2 623 3/25/2025
3.3.1 467 3/24/2025
3.3.0 418 3/24/2025
3.2.15 220 3/18/2025
3.2.14 141 3/16/2025
3.2.13 139 3/16/2025
3.2.12 98 3/15/2025
3.2.11 78 3/15/2025
3.2.10 75 3/15/2025
3.2.9 95 3/14/2025
3.2.8 132 3/14/2025
3.2.7 147 3/13/2025
3.2.6 154 3/13/2025
3.2.5 146 3/13/2025
3.2.4 159 3/13/2025
3.2.3 150 3/13/2025
3.2.2 147 3/13/2025
3.2.1 143 3/13/2025
3.2.0 190 3/11/2025
3.1.2 158 3/11/2025
3.1.1 201 3/9/2025
3.1.0 162 3/9/2025
3.0.3 218 3/7/2025
3.0.2 212 3/7/2025
3.0.1 214 3/7/2025
3.0.0 267 3/6/2025
2.10.7 224 3/5/2025
2.10.6 214 3/4/2025
2.10.5 214 3/4/2025
2.10.4 200 3/4/2025
2.10.3 213 3/4/2025
2.10.2 213 3/4/2025
2.10.1 147 2/28/2025
2.10.0 109 2/28/2025
2.9.17 277 1/14/2025
2.9.16 114 1/10/2025
2.9.15 112 1/10/2025
2.9.14 107 1/10/2025
2.9.13 263 12/6/2024
2.9.12 116 12/6/2024
2.9.11 118 12/5/2024
2.9.10 124 12/5/2024
2.9.9 120 12/5/2024
2.9.8 120 12/4/2024
2.9.7 115 12/4/2024
2.9.6 168 12/3/2024
2.9.5 132 11/29/2024
2.9.4 108 11/29/2024
2.9.3 106 11/29/2024
2.9.2 111 11/29/2024
2.9.1 326 11/28/2024
2.9.0 207 11/26/2024
2.8.2 118 11/24/2024
2.8.1 109 11/24/2024
2.8.0 133 11/23/2024
2.7.3 118 11/22/2024
2.7.2 117 11/22/2024
2.7.1 116 11/22/2024
2.7.0 121 11/22/2024
2.6.13 115 11/21/2024
2.6.12 109 11/18/2024
2.6.11 109 11/18/2024
2.6.10 111 11/18/2024
2.6.9 120 11/17/2024
2.6.8 115 11/17/2024
2.6.7 112 11/16/2024
2.6.6 112 11/16/2024
2.6.5 126 11/15/2024
2.6.4 119 11/15/2024
2.6.3 109 11/15/2024
2.6.2 130 11/15/2024
2.6.1 118 11/14/2024
2.6.0 114 11/14/2024
2.5.7 118 11/13/2024
2.5.6 130 11/12/2024
2.5.5 115 11/12/2024
2.5.4 127 11/10/2024
2.5.3 116 11/6/2024
2.5.2 134 11/4/2024
2.5.1 125 11/3/2024
2.5.0 118 11/3/2024
2.4.5 115 11/3/2024
2.4.4 123 11/3/2024
2.4.3 112 11/3/2024
2.4.2 114 11/3/2024
2.4.1 111 11/2/2024
2.4.0 117 11/2/2024
2.3.3 155 10/29/2024
2.3.2 119 10/28/2024
2.3.1 111 10/28/2024
2.3.0 113 10/28/2024
2.2.4 125 10/27/2024
2.2.3 117 10/27/2024
2.2.2 107 10/27/2024
2.2.1 120 10/27/2024
2.2.0 116 10/27/2024
2.1.3 119 10/25/2024
2.1.2 121 10/23/2024
2.1.1 114 10/23/2024
2.1.0 128 10/22/2024
2.0.1 104 10/21/2024
2.0.0 106 10/21/2024

Fixed bug when cloning prompts on custom commands.