NetAF 3.4.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package NetAF --version 3.4.2
                    
NuGet\Install-Package NetAF -Version 3.4.2
                    
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.4.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetAF" Version="3.4.2" />
                    
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.4.2
                    
#r "nuget: NetAF, 3.4.2"
                    
#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.4.2
                    
#: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.4.2
                    
Install as a Cake Addin
#tool nuget:?package=NetAF&version=3.4.2
                    
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 in to 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.

Room room = new("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.

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

Playable Character

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

PlayableCharacter player = new("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.

NonPlayableCharacter npc = new("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.
  • Log - display any gathered information.
  • 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.
  • Log frame - for displaying any gathered information.
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
PlayableCharacter player = new("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
RegionMaker regionMaker = new("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("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
OverworldMaker overworldMaker = new("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("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 282 7/14/2025
3.8.5 161 7/14/2025
3.8.4 122 7/11/2025
3.8.3 174 7/10/2025
3.8.2 168 7/10/2025
3.8.1 169 7/10/2025
3.8.0 160 7/10/2025
3.7.14 165 7/2/2025
3.7.13 168 7/2/2025
3.7.12 173 6/30/2025
3.7.11 320 5/14/2025
3.7.10 250 5/13/2025
3.7.9 174 5/8/2025
3.7.8 166 5/8/2025
3.7.7 184 5/7/2025
3.7.6 187 5/1/2025
3.7.5 173 5/1/2025
3.7.4 158 5/1/2025
3.7.3 193 4/29/2025
3.7.2 200 4/28/2025
3.7.1 148 4/25/2025
3.7.0 135 4/25/2025
3.6.3 196 4/24/2025
3.6.2 187 4/24/2025
3.6.1 334 4/24/2025
3.6.0 221 4/22/2025
3.5.2 229 4/17/2025
3.5.1 208 4/16/2025
3.5.0 226 4/15/2025
3.4.6 215 4/15/2025
3.4.5 255 4/10/2025
3.4.4 195 4/10/2025
3.4.3 193 4/9/2025
3.4.2 218 4/8/2025
3.4.1 203 4/8/2025
3.4.0 185 4/8/2025
3.3.8 206 3/30/2025
3.3.7 190 3/30/2025
3.3.6 190 3/30/2025
3.3.5 154 3/28/2025
3.3.4 175 3/27/2025
3.3.3 172 3/27/2025
3.3.2 668 3/25/2025
3.3.1 494 3/24/2025
3.3.0 452 3/24/2025
3.2.15 258 3/18/2025
3.2.14 166 3/16/2025
3.2.13 166 3/16/2025
3.2.12 124 3/15/2025
3.2.11 107 3/15/2025
3.2.10 102 3/15/2025
3.2.9 122 3/14/2025
3.2.8 158 3/14/2025
3.2.7 174 3/13/2025
3.2.6 180 3/13/2025
3.2.5 173 3/13/2025
3.2.4 184 3/13/2025
3.2.3 176 3/13/2025
3.2.2 183 3/13/2025
3.2.1 168 3/13/2025
3.2.0 226 3/11/2025
3.1.2 187 3/11/2025
3.1.1 231 3/9/2025
3.1.0 191 3/9/2025
3.0.3 243 3/7/2025
3.0.2 237 3/7/2025
3.0.1 238 3/7/2025
3.0.0 303 3/6/2025
2.10.7 249 3/5/2025
2.10.6 250 3/4/2025
2.10.5 241 3/4/2025
2.10.4 228 3/4/2025
2.10.3 237 3/4/2025
2.10.2 251 3/4/2025
2.10.1 184 2/28/2025
2.10.0 134 2/28/2025
2.9.17 302 1/14/2025
2.9.16 139 1/10/2025
2.9.15 141 1/10/2025
2.9.14 134 1/10/2025
2.9.13 288 12/6/2024
2.9.12 142 12/6/2024
2.9.11 143 12/5/2024
2.9.10 159 12/5/2024
2.9.9 145 12/5/2024
2.9.8 144 12/4/2024
2.9.7 130 12/4/2024
2.9.6 182 12/3/2024
2.9.5 159 11/29/2024
2.9.4 135 11/29/2024
2.9.3 131 11/29/2024
2.9.2 136 11/29/2024
2.9.1 373 11/28/2024
2.9.0 253 11/26/2024
2.8.2 141 11/24/2024
2.8.1 143 11/24/2024
2.8.0 158 11/23/2024
2.7.3 141 11/22/2024
2.7.2 142 11/22/2024
2.7.1 142 11/22/2024
2.7.0 147 11/22/2024
2.6.13 145 11/21/2024
2.6.12 134 11/18/2024
2.6.11 134 11/18/2024
2.6.10 137 11/18/2024
2.6.9 145 11/17/2024
2.6.8 141 11/17/2024
2.6.7 126 11/16/2024
2.6.6 136 11/16/2024
2.6.5 151 11/15/2024
2.6.4 144 11/15/2024
2.6.3 125 11/15/2024
2.6.2 155 11/15/2024
2.6.1 143 11/14/2024
2.6.0 140 11/14/2024
2.5.7 143 11/13/2024
2.5.6 162 11/12/2024
2.5.5 139 11/12/2024
2.5.4 154 11/10/2024
2.5.3 141 11/6/2024
2.5.2 159 11/4/2024
2.5.1 140 11/3/2024
2.5.0 143 11/3/2024
2.4.5 139 11/3/2024
2.4.4 149 11/3/2024
2.4.3 138 11/3/2024
2.4.2 130 11/3/2024
2.4.1 136 11/2/2024
2.4.0 144 11/2/2024
2.3.3 179 10/29/2024
2.3.2 144 10/28/2024
2.3.1 135 10/28/2024
2.3.0 139 10/28/2024
2.2.4 152 10/27/2024
2.2.3 131 10/27/2024
2.2.2 132 10/27/2024
2.2.1 144 10/27/2024
2.2.0 146 10/27/2024
2.1.3 143 10/25/2024
2.1.2 146 10/23/2024
2.1.1 139 10/23/2024
2.1.0 153 10/22/2024
2.0.1 128 10/21/2024
2.0.0 131 10/21/2024

Fixed bug where items could not be used on themselves.