Feature Expand ChoiceAdventure Options

sapph

New member
I don't know how difficult this would be to implement, but it occurred to me that there are a number of ChoiceAdventures that can give you an item - but you want only a certain maximum of that item. And it can also give you stats. It would be nice if there was an option that said (say for 1470) "If I do not have a teacher's pen, get one. If I do, get stat gains". I suppose this would require some choiceadventures to have two UI dropdowns - one for the primary choice, and one for the secondary choice. It would also likely require modification of the ChoiceAdventure class/struct to delineate that this ChoiceAdventure has secondary options. Defintely doesn't sound simple, but would likely to have continuing benefits, IMO.
 

ckb

Well-known member
It is fairly easy to add this logic to your own script, in either a before- or after- adventure script, changing the properties of the "choiceAdventure###" for whatever you like.

as an example:
Code:
//Teacher's Pet choiceAdventure1470
//1: Teacher's Pet (30, sleaze res, DA/DR), 2: teacher's pen (acc, +3 stats/fight, +2 fam exp), 3: 125 Mus
if (available_amount($item[teacher's pen])==0) {
    set_property("choiceAdventure1470",2);
} else {
    set_property("choiceAdventure1470",1);
}
 

Veracity

Developer
Staff member
We have the technology for this. Consider Papaya War in The Palindome.

In ChoiceAdventures.java:

Code:
    // No sir, away!  A papaya war is on!
    new ChoiceSpoiler(
        127,
        "Plains",
        "Palindome",
        // Option...
        new Option("3 papayas", "papaya"),
        new Option("trade 3 papayas for stats"),
        new Option("stats"));
    // No sir, away!  A papaya war is on!
    new ChoiceCost(127, new Cost(2, ItemPool.get(ItemPool.PAPAYA, -3)));
Notice that is a ChoiceSpoiler, rather than a ChoiceAdventure. That means that we will display spoilers in the Relay Browser, but do not automatically generate this choice in the GUI. Which does not mean that we don't provide GUI configuration.

In ChoiceOptionsPanel.java:

Code:
  private final JComboBox<String> palindomePapayaSelect;
...
    this.palindomePapayaSelect = new JComboBox<>();
    this.palindomePapayaSelect.addItem("3 papayas");
    this.palindomePapayaSelect.addItem("Trade papayas for stats");
    this.palindomePapayaSelect.addItem("Fewer stats");
    this.palindomePapayaSelect.addItem("Stats until out of papayas then papayas");
    this.palindomePapayaSelect.addItem("Stats until out of papayas then fewer stats");
...
    this.addChoiceSelect("Plains", "Papaya War", this.palindomePapayaSelect);
...
    Preferences.setString(
        "choiceAdventure127", String.valueOf(this.palindomePapayaSelect.getSelectedIndex() + 1));
...
    this.palindomePapayaSelect.setSelectedIndex(
        Math.max(0, Preferences.getInteger("choiceAdventure127") - 1));
Notice that there are three options provided by KoL and two more that require run-time condition checking.

In defaults.txt:

Code:
user    choiceAdventure127    3

In ChoiceManager.specialChoiceDecision2()

Code:
        // No sir, away! A papaya war is on!
      case 127:
        switch (StringUtilities.parseInt(decision)) {
          case 1:
          case 2:
          case 3:
            return decision;
          case 4:
            return ChoiceManager.PAPAYA.getCount(KoLConstants.inventory) >= 3 ? "2" : "1";
          case 5:
            return ChoiceManager.PAPAYA.getCount(KoLConstants.inventory) >= 3 ? "2" : "3";
        }
        return decision;
And that's it.

I've been meaning to write a document to put in the "devdoc" directory in the repository on just how to add a new choice adventure.

- ChoiceAdventure vs. ChoiceSpoiler
- ChoiceAdventure.dynamicChoiceSpoilers, dynamicChoiceOptions
- ChoiceManager.specialChoiceHandling , specialChoiceDecision1, pickGoalChoice, specialChoiceDecision2
- ChoiceControl.preChoice, visitChoice, postChoice0, postChoice1, postChoice2, registerRequest

Not every choice needs every one of those, by a long shot.

Some things you should probably just put in your own script, but choices that might be of general interest to supply pseudo-choices for - like June Cleaver choices, as you point out - can be customized using existing code.
 
Top