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 280195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:05:49+00:00 2026-05-12T05:05:49+00:00

I am doing a RogueLike game, and would like to make the logic for

  • 0

I am doing a RogueLike game, and would like to make the logic for each entity modular. This probably could apply to web applications where there are roles and permission control too.

The idea is to have something like this – we have different type of entities in the game. a door can be bashed down, while a stone wall cannot be bashed. The logic module, say, could be a class called Bashable

public interface IBashable
{
    bool ProcessRequest(CharacterInfo character);
    string GetOutput();
    virtual int GetOutcome();
}

So a door with IBashable interface added to an object could be smashed. The ProcessReques() will use some rules to determine if the character manages to do so (perhaps a strength check).

An object without IBashable interface cannot be bashed open. The issue is – say a door have multiple logic components added to it. What I would like to do is to submit a request like this.

// Conan is derived from CharacterInfo class
BashDoorRequest request = new BashDoorRequest(conan);
Door d;
BashLogic bash;
PickLockLogic pick;
d.addLogic(bash);
d.addLogic(pick);

// Assuming the signature is processRequest(IRequest, where all request derived from)
d.processRequest(request)

The question is – how do I add the getmodules to activate? It is a BashDoorRequest, not PickLockRequest, so only the bash door logic would run.

I have two thinking – one is to use a visitor pattern, but it means quite a lot of classes added. The other is to have a tag or ID for each reach module and action. For example the bash logic may have a “bash” tag to it. Maybe I have two bash logic – one which allows players to bash the door, and another maybe, which reduces the HP of anyone bashing the door because it is spiked.

So I have to activate the two Logic Module for bashing, and the pick lock logic should not run. Should I have a hashamp of tags, and have each of the logic be grouped according to has?

This also apply to terrain; say characters cannot move through water. The water entity only has a ICannotWalk through logic added, but have a ISwimmable logic added. So how do I check only ICannotWalk module without wasting time to check the ISwimmable logic?

An other problem I am facing is the request object may have to take into more than one parameter, but passing in a hashtable to represent parameters feel like an overkill to me. Not to mention that some Logic Module may take in different parameters. (For example, a door is locked and requires a special key to open. The request for this would include the character’s inventory too and not the the character info. Unless I pass the entire inventory, character’s stats and everything to the Request.

Any ideas on how to implement this system will be welcomed!

  • 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-12T05:05:49+00:00Added an answer on May 12, 2026 at 5:05 am

    You may want to read about the command pattern – what you are calling a request is essentially a command. Each object could maintain a list of CommandActions, and when a command is passed in, attempt to match each command against the list of available CommandActions.

    Efficient dispatch of commands is often a challenge – especially when objects can respond to many different commands. There are several different ways to potentially resolve the performance issues:

    • Use a dictionary to match each command to its action based on a key shared by the two
    • Use command range groupings to narrow the search for an action based on key ranges
    • Assign each command a unique numeric ID and use binary search on an ordered collection to find actions
    • If more than one action can respond to a command, chain them together
    • Use specific methods to send common commands, rather than a generic ProcessRequest() method
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Doing something like this: from zipfile import ZipFile #open zip file zipfile = ZipFile('Photo.zip')
I am about to make a game using python and libtcod roguelike game library.
Doing a code review I've stumbled over GWM in Java-Spring-GWT web-application. As this product
When doing something like this: <div style=float: left;>Left Div</div> <div style=float: right;>Right Div</div> I
Im doing something like this to get a list of all users that have
Doing something like this: <?php $my_query = new WP_Query('category_name=process&posts_per_page=20'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate
When doing small icons, header graphics and the like for websites, is it better
When doing TDD , how to tell that's enough tests for this class /
doing this in AppDelegate: viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil]; Is there any problem
Doing this: var _partsCatalog = new DirectoryCatalog(directoryName);//Fully qualified path to our bin folder var

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.