Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3222994
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:03:20+00:00 2026-05-17T16:03:20+00:00

EDIT: If you can’t be bothered to read this mammoth question, I’ve put a

  • 0

EDIT: If you can’t be bothered to read this mammoth question, I’ve put a summary at the bottom.

I’m currently working on a sort of “framework” for a text adventure I am going to make in C#, as a coding excercise. In this framework, possible actions are defined by an “Interaction” class.

The potential “Actionable” objects are Inventory Items (stick, gun, sword), Environmental Items (wall, door, window) and Characters (people, animals). Each of these has a property which is a List of Interactions. At the moment, an Interaction is basically an “action/response” name value pair. When you type “smash window”, it looks through all possible actionable items that the Player has available and matches the subject (in this case, “Window”). It then works out that the action is “Smash” and looks up in the List of Interactions on the Window (Environmental Item) to get a response for the Smash action and then writes it to the console.

That is all done, but here is the point that I am stuck:

An action has any number of potential consequences, which differs by each potential interaction. These are:

– Returns a response describing the result of the action by looking it up on the interaction, possibly with a second subject

EITHER
– The subject of the action (inventory item, environmental item or character) changes it’s description
EG. “punch wall” could change the wall’s description to describe a dent in the wall

OR
– The subject of the action is replaced by another item
EG. “smash bottle” results in “bottle” changing to “broken bottle” or “kill John” results in the character John being replaced by environmental item “John’s corpse”.

– Returns a response describing the preceeding change
EG. “The broken pieces of the bottle are scattered across the floor.”

– An area’s description is changed.
EG. “smash lightbulb” results in the room’s description changing to describe a pitch black room

– Items are added/removed from the inventory or the environment
EG. “pick up bottle”. You now have a bottle in your inventory, and the bottle is removed from the environment.

– The directions available for movement and the areas which they lead to are changed
EG. “unlock door with key” allows you to move East into another room

– The player is moved to a new area
EG. “go north” takes you to another area.

I need to somehow determine in a generic way which of these consequences a particular Interaction should invoke, and invoke them. An action could potentially use a number of these consequences, or just one.

For example, if the item is a Bottle:

“fill bottle with water” would first return a response describing that you have filled the bottle with water. It would then replace the “bottle” item with a “bottle of water” item.
That is two consequences, returning a response and replacing an item.

Say you were then to do “throw bottle of water at window“. This is more complex. It would first return a response describing the events that take place, the bottle and the window would both smash and water would go everywhere. The bottle would be removed from the Player’s inventory.
Next, the “bottle of water” would be replaced by the “broken bottle” and the “Window” would be replaced with “Broken window”. The area description would also change to reflect this.
That is five consequences, returning a response, removing an item from inventory, replacing two items and updating the description of the current area.

As you can see, I need a generic way of being able to define on a per “Interaction” basis, what the consequences of that action will be and update other objects such as Item, Player (for inventory) and Area appropriately.

I’m sorry if this is unclear, and I will do my best to clarify if anyone has any questions.

EDIT: Is there a way for me to define a method on an Interaction that I can pass a number of methods to call (and their parameters) into? The initial response returned would be the default, mandatory consequence, and then there could be extra ones if specified.

For example, in the examples above, for the first interaction, “fill with water”, I would tell it to return a response (“You have filled the bottle with water”) and also to call a ReplaceItem method that would replace the “bottle” subject with a “bottle of water”.

For the second interaction I would tell it to return a response (“The bottle hurtles through the air into…”), call RemoveFromInventory on the subject of the action, call UpdateStatus on the bottle (“the bottle is smashed”) and the window (“the window is smashed”) and call UpdateAreaDescription to change the current area’s description (“You are standing in a room with a single window, the glass smashed to pieces”).

Does that sound feasible? I’m trying to keep this as generic as possible, for the sake of all the different possible interactions.

EDIT 2: To clarify further, and to attempt to summarize the problem:

In my game, there are Actionable objects (a bottle, a wall, John). Each Actionable object has a list of
Interaction objects which describe how a player can interact with them. At the moment, an Interaction has a
“Name” property (“throw”, “hit”, “break”) and returns a Response (“You throw the “).

The issue that I am trying to resolve is that an Interaction also needs to do a number of other things, varying
by each particular Interaction. Let’s take the example of a glass bottle.

“throw glass bottle”
– A response is returned (“You threw the glass bottle.”)
– The “Bottle”, is removed from the Player’s inventory.
– The is replaced with a new to reflect the change. (“Bottle” replaced with “Broken bottle”).
– A second response is returned (“The pieces of the glass bottle are scattered on the floor”).

“throw glass bottle at window”
– A response is returned (“You threw the glass bottle at the window.”)
– The object “Bottle”, is removed from the Player’s inventory.
– The object is replaced with a new object to reflect the change. (“Bottle” replaced with “Broken bottle”).
– A second, optional object is replaced with a new to reflect the change. (“Window” replaced with “Broken window”).
– The “Description” property of the current Area is updated. (“You are standing in a room, with a single broken window.”).

When I create the Interactions, how can I vary the additional actions that they perform, such as status changes
to the subject, or changes to the current Area’s description?

If you need more examples of actions as above, let me know and I’ll do a few more.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:03:21+00:00Added an answer on May 17, 2026 at 4:03 pm

    Alright guys, here’s how I handled it. It was the most generic way I could think of and I think it suits what I am trying to achieve.

    I added an “Invoke()” method to the Interaction class, a new Interface called IActionResult which defined an “Initiate()” method, and a number of different ActionResult types for each possible consequence. I also added a List of ActionResults to an Interaction. The Invoke method would simply loop through all of the IActionResult objects and call the Initiate() method.

    When you define an Interaction on an item, you would pass in a list of verbs for that Interaction and then add a number of ActionResult objects depending on the consequences of that Interaction.

    I also added a GlobalActionReference, which would be updated each time an action is performed, and an ActionResult would have appropriate access to the objects it needs to update through this.

    I really appreciate all of your suggestions, and I’m sorry if I wasn’t clear with my question or my comments (or even this answer). Thanks for your help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is with reference to this question: How to read output and give input
Can please someone put me out of my misery and tell me why this
Edit: You can get the full source here: http://pastebin.com/m26693 Edit again: I added some
Edit: We can close. Isn't truly asynchronous, non-blocking javascript impossible? var PATH = require
EDIT: You can see the search box live here . Before I explain, let
Edit: I can use Actionscript 3.0 and/or Java I have a bit of a
Are there any editors that can edit multi-gigabyte text files, perhaps by only loading
Is there a tool where you can edit a .NET dll directly? .net reflector
In the below code onclick edit how can the value of tag test be
I have a controller method called Edit in which the user can edit data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.