CanAdv can I adventure here?

CanAdventure 1.2

What is it?
A set of functions to determine if it's possible to adventure in a location. Inspired by zarqon's canadv, but takes a different approach. It's data driven, using a map of locations and predicates, and a general purpose predicate evaluator.

Note: Depends on zarqon's excellent zlib.ash and my log_lib.ash, pageCache.ash, and predicate.ash make sure you install them first.

For Users

canadv location will print whether you can/could adventure in location. Canadv with no parameters will pop up a dialog asking for a location name, an empty location name will cause canadv to list all possible locations and whether you can/could adventure in them.

For Script Authors

Canadv exports methods to check if you can currently adventure in a location, if you could possibly adventure in a location, and if you could adventure somewhere to do what's needed to prepare.

Methods

boolean can_adv(location where)
Returns true if your character can currently adventure in location where.

boolean could_adv(location where)
Returns true if your character could adventure in location where. (The location is open and you can satisfy the prerequisites.)

boolean doit_adv(location where)
Returns true if you could adventure in the location, and takes whatever actions are needed to prepare you to adventure there. Will not do anything that takes an adventure, consume food, drink booze, or use spleen items. Will use items to get effects, equip or unequip items, shrug buffs, uneffect unwanted effects, or change familiars.

Data Files

canadv_location_predicates.txt
Maps from location name to minimum buffed prime stat, "sticky", and a list of predicates. "Sticky" locations are ones that once opened, stay open. Examples of non-sticky locations are the cola wars battlefield, defiled cyrpt, and most boss locations.

Put this file in your data directory.

Issues

The issues are inherited from predicate's limitations. Doesn't go to the guild or council to get new quests or complete ones that you've finished. Won't adventure in the oasis to get ultrahydrated because that would take an adventure. Others as well.


Change Log
1.0 2009/11/18 Initial release
1.1 2009/11/19 added can_adv(location, boolean) for compatibility
1.2 2009/11/20 renamed to avoid confusion with zarqon's canadv
 

Attachments

  • CanAdventure.ash
    3.7 KB · Views: 154
  • CanAdventure.txt
    15.1 KB · Views: 241
Last edited:

Camber

Member
You probably want to rename this because Zarqon has a CanAdv.ash that has been in the forum's since Jun 4 2009.
 
I hear you. My intention is to make this one plug compatible with that one, so that you can use whichever suits you without having to change anything that depends on them. If zarqon feels strongly that he'd like me to name it something else I'll be happy to.

I (now) export a function with the signature can_adv(location, boolean) that should have the same semantics as his.
 
Last edited:
That sounds like it could get a little confusing. Same goes with your LevelUp.ash. dj_d has his one-click level script which is LevelUp.ash. I forsee many unnecessary posts by confused users in both threads or the wrong thread.
 
Last edited:

zarqon

Well-known member
The way you have it, a user needs to either delete or rename the script they don't want to be using -- yours or mine -- otherwise results are unpredictable (if the same file exists in different subdirectories, which one will be imported?). I appreciate your new solution to the problem and would like to allow scripters/users to use either, but that should be a preference somewhere -- not merely the presence or absence of an identically-named script in the directory.

Ideally, we should collaborate to make a single script that has a user setting for determining which method to use -- or provide a wrapper script that chooses which script to use. Two scripts with the same name (and even the same function declaration) is a recipe for confusion. I won't insist that you rename it, but I do think there is a better solution. Ideas?
 
I think it's. Simplest if I just rename it and if at some point we want to merge them or make a wrapper we can. It's no big deal.

I think we're going to see more interface/implementation issues and namespace issues going forward. I'm already finding it a hassle to manage includes. My desire for encapsulation is warring with the practical difficulty of managing the environment.

Anyw I'll chanege the name as soon as I have real access again. I'm on the road right now and don't have real internet access (literally "on the road" on I5 between Los Banos and Coalinga...)
 
I think it's simplest if I just rename it and if at some point we want to merge them or make a wrapper we can. It's no big deal.

I think we're going to see more interface/implementation issues and namespace issues going forward. I'm already finding it a hassle to manage includes. My desire for encapsulation is warring with the practical difficulty of managing the environment.

Anyway I'll change the name as soon as I have real access again. I'm on the road right now and don't have real internet access (literally "on the road" on I5 between Los Banos and Coalinga...)

[ETA - renamed!]
 
Last edited:

zarqon

Well-known member
I saw the renamed "UpLevel" so I checked here to see if it would be "AdvCan"... but no, you have a not-impossible-to-pronounce name instead. :)
 
Top