AnssiR66 / AlanStdLib

The Standard Library for ALAN Interactive Fiction Language
Other
5 stars 2 forks source link

Implicit Taking for 'wear': Attention Required #107

Open tajmone opened 3 years ago

tajmone commented 3 years ago

The wear verb in lib_clothing.i might need to be checked thoroughly regarding how implicit-taking is being handled.

There are various places in its DOES block where an implicit-taking can occur, but none of them seems to print the attempt-taking message, so we might need to check how the verb fails when the item is held by a non-compliant character.

Most likely, the "You pick up..." message should be printed after the LOCATE statement, because if the latter fails the VERB will abort. This will ensure that the message is only shown if the implicit taking action succeeds. But this doesn't address the problem of how a failed implicit-taking will look like (we need to actually test this to asses the current state of affairs).

The verb's CHECKs do handle the case of an items being worn, so the problem here might only affect not-worn items which are inside containers with an EXTRACT clause that would prevent the implicit-taking actions (non compliant NPCs, but also object containers too).

This is the code that might be problematic (two occurrences of the problem):

      --========================================================================
      -- Outcome of the wear action...
      --========================================================================

      SET my_game:temp_cnt TO COUNT IsA clothing, IN my_game:temp_clothes.
      IF my_game:temp_cnt <> 0
        THEN
          -- ----------------------------------
          -- It's not possible to wear the item
          -- ----------------------------------
          -- We'll just take it (if not already possessed).

          -- >>> implicit take >>>
          IF THIS NOT IN hero
            THEN "You pick up $+1."
          END IF.
          LOCATE THIS IN hero.
          -- <<< implicit take <<<
          -- -------------------------------------
          -- List worn items preventing the action
          -- -------------------------------------
          "In order to wear $+1 you should first take off"
          FOR EACH blocking_item IsA clothing, IN my_game:temp_clothes
            DO
              SAY THE blocking_item.
              DECREASE my_game:temp_cnt.
              DEPENDING ON my_game:temp_cnt
                = 1 THEN "and"
                = 0 THEN "."
                ELSE ","
              END DEPEND.
          END FOR.
        ELSE
          -- ------------------------------
          -- It's possible to wear the item
          -- ------------------------------
          IF THIS NOT IN hero
            THEN
              -- ------------------------------
              -- The item is picked up and worn
              -- ------------------------------
            "You pick up $+1 and put"
            IF THIS IS NOT plural
              THEN  "it"
              ELSE  "them"
            END IF. "on."
            ELSE
              -- -----------------------
              -- The item is simply worn
              -- -----------------------
              "You put on $+1."
          END IF.
          LOCATE THIS IN hero.
          MAKE THIS worn.
      END IF.
  END VERB wear.