Need help for school project in coding a randomized action

Hey guys,
concerning a school project we have to develop our school in IF7.
Now i got the task to develop a desk in our class-room, with 6 Jelly beans on it
and if you push or shake the desk a random bean falls down and is takeable by the player.
I dont know how to code a randomized action which is started by the push/shake of the table.

I appreciate any kind of help and thank you already in advance. :slight_smile:

You should definitely try to figure this out yourself, so I’ve coded it and broken it into sections if you just need a hint.

[spoiler][code]“Candy Crush Class”

Classroom is a room. “You are in your Jellybean Studies 101 Classroom.”
A desk is a supporter in classroom. Desk is portable. The description is “There’s only one desk in here. [if a jellybean is on the desk]Someone has apparently left without their candy.”[/code][/spoiler]

[spoiler][code]A jellybean is a kind of thing. A red jellybean is a kind of jellybean. A black jellybean is a kind of jellybean. A horseradish jellybean is a kind of jellybean.

One red jellybean is on the desk. One black jellybean is on the desk. One horseradish jellybean is on the desk.

Understand “bean/jelly” as a jellybean.[/code][/spoiler]

[spoiler][code]Understand “shake [something]” as pushing.

Instead of pushing or pulling the desk:
try taking the desk.[/code][/spoiler]

After taking the desk: say "You jostle the desk, but it's a little too heavy to move around much."; try silently dropping desk; if a jellybean is on the desk: now a random jellybean on the desk is in the location; say "[line break]Whoops, there goes one of the jellybeans on the floor..."

After printing the name of a jellybean when the item described is in the location: say " on the floor".