Skip to content

bug: FSM vending machine buttons re-enable during wait states causing incorrect change calculation #770

@VaibhavJindal7

Description

@VaibhavJindal7

Description

The interactive vending machine FSM has two related
bugs in assets/js/interactive_soda_machine.js

Bug 1 — Buttons re-enable during Wait states

Steps to reproduce:

  1. Click "Drop 10¢"
  2. Click "Drop 10¢" again (total = 20¢)
  3. Machine enters W20 wait state
  4. Buttons sometimes still appear
  5. If user clicks "Drop 5¢" → gets only soda,
    no change returned
  6. If user clicks "Drop 10¢" → gets soda +
    only 5¢ change instead of correct amount

Expected Behavior

Buttons should be completely disabled from the
moment a coin is inserted until the machine
returns to idle state M0

Root Cause in Code

The button enable condition only checks:
if (soda_machine_fsm.state <= 4)

This misses states W15 (5) and W20 (6) where
buttons should still be disabled

Bug 2 — No feedback during processing

When machine is in any Wait state (W5, W10,
W15, W20) the buttons disappear but no message
is shown to the user explaining what is happening

Expected Behavior

Show a clear message like "Processing coin..."
or "Please wait..." during all wait states

Files affected

assets/js/interactive_soda_machine.js

Image

problem.video1.mp4
problem.video.2.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions