The Democrat Banana

First, let me say that the Democrat banana is in no way an attempt to send political messages or anything like that, it's merely the result of pure juvenileness.

How the Democrat banana behaves

Nicely. To be more specific, like this:

Atwood's Lounge
Crakes on the oryx-panelled walls create a comfortable dystopian appearance. Hand-drawn maps of the corporate compounds and pleeblands are taped to nearly every surface. Seating is plentiful, as catastrophic climate change has wiped out most of the population. The RejoovenEssencecompound lies to the north.

You can see: [...] Jewish were-banana, What development environments do you use?, Democrat banana (handling out pamphlets), What K3wlt0k annoys you?

> x democrat banana

It carries a badge reading "Banana for President 2004!"
Wow. The Democrats are getting kinda desparate in their search for good candidates. But hey, everybody likes a banana, right?
Banana notices you looking at it, and promptly hands you a pamphlet.

> x pamphlet

Wow. You never really thought about this, but what this pamphlet says is true! This country needs a firm banana to lead it into the new millenium!

> x democrat banana

It carries a badge reading "Banana for President 2004!"
Wow. The Democrats are getting kinda desparate in their search for good candidates. But hey, everybody likes a banana, right?
Banana says, "Vote Banana!"

> drop pamphlet

pamphlet disappears.

The pamphlets

I ended up creating 22 of these - they'll be set slippery later, so they return home when dropped. But otherwise, there's nothing special about them. (Here I assume the created pamphlet is #13976.)

@create pamphlet

@desc #13976 = Wow. You never really thought about this, but what this pamphlet says is true! This country needs a firm banana to lead it into the new millenium!

@link #13976 = #13979

@drop #13976 = @null()

@field #13976 = ohomemsg : disappears.

@teleport #13976 = #13979

The banana's description

The description should see if there's any spare pamphlets, and if there are, move one to the player.

We keep the pamphlets in room 13979 and use @object to pick one. The @tell(12456) command notifies me whenever someone receives a pamphlet.

@desc db = @print(
 "It carries a badge reading \"Banana for President 2004!\"%c
  Wow. The Democrats are getting kinda desparate in their search
  for good candidates. But hey, everybody likes a banana, right?%c",
 @switch(@object("%#", "pamphlet"), "-1",
  @let("x", @object(13979, "pamphlet"),
   @switch("%x", "-1",
    "The banana notices you looking at it, and says,
    \"I'm afraid I'm out of pamphlets. But vote Banana!\"",
    @print(
     "Banana notices you looking at it,
      and promptly hands you a pamphlet.",
     @tell(12456, "[%n receives a pamphlet.]"),
     @setflag("%x", "slippery"),
     @move("%x", "%#")
    )
   )
  ),
  "Banana says, \"Vote Banana!\""
 )
)

The banana's fail-message

While passing the banana can be quite fun, this particular banana is meant to stay in the lounge so it can continue to provide the important public service of handling out pamphlets.

@lock db = -1
@field db = fail : @print("Banana says, \"Excuse me! ",
 @switch(@object("%#", "pamphlet"), "-1",
  @let("x", @object(13979, "pamphlet"),
   @switch("%x", "-1",
    "I'm afraid I don't have any pamphlets you can get.
     But please, vote Banana.\"",
    @print(" Oh, and have a pamphlet.\"%c
           Banana gives you a pamphlet.",
     @tell(12456, "[%n receives a pamphlet.]"),
     @setflag("%x", "slippery"),
     @move("%x", "%#")
    )
   )
  ),
  "And... vote Banana.\""
 )
)

Pass the banana

This code doesn't actually have anything to do with the Democratic Banana, except that the banana is mentioned in the text the code generates.

The idea is that the Democrat Banana can pass bananas and other pass-the-banana style objects.
Of course, as the banana isn't a player, it's all a more or less clever illusion.

First, to make testing easy, I defined the ID of the Lounge as a separate field on the Banana Room (#14112).

@field #14112 = lounge_id : 14

There. While testing, I'd then set this field to another room, so I wouldn't disturb the players in the lounge. Now, a subroutine that lists the players in the lounge (or whatever room we use).

@field #14112 = makeplylist : @s("plycnt", 0);
 @contentsloop(@g("lounge_id"), "o",
  @switch("%o", {1691, 10861}, "",
   @switch(@type("%o"), 2,
    @let("x", @g("plycnt"),
     @print(
      @s("ply_%x", "%o"),
      @s("plycnt", @add("%x", 1))
     )
    ),
   "")
  )
 )

For each object in the lounge, we see if it's a player (@type() returns 2), and if so, add a field with the player's ID. We also update plycnt to reflect the total number of players in the lounge. And then we also check if the player is Alex (#1691) or Markov (#10861), in which case we don't add it.

Then comes the @desc of the Banana Room. Whenever an object is @teleported into a room, it evaluates description.
By putting the clever code in the description, @teleport some_object = #14112 causes some_object to be given to a player in the lounge.
First we check if it's actually an object (@type() returns 4), then we update the list of players in the lounge, picks a random player ID in the @let statement, and moves the object to that player.

@desc #14112 = @switch(@type("%#"), 4,
 @print(
  @call(14112, "makeplylist"),
  @let("x", @g(@print("ply_", @rand(@g("plycnt")) )),
   @tellroom(@g("lounge_id"), "-1", @print(
    "Democrat banana gives ",
    @shortname("%#"),
    " to ",
    @shortname("%x"),
    " and says, \"",
    @switch(@rand(5),
     0, "Vote Banana!\"",
     1, "Banana 2004!\"",
     2, "Here you go!\"",
     3, "Banana: The smart choice!\"",
     "Have a nice day!\""),
    @move("%#", "%x")
   ))
  )
 ),
 "A big sign says, \"Monkeys not allowed.\" It's not evident
  why they're not allowed in here, seeing as this is just a
  temporary stop for passed bananas."
)

Finally, for casual viewers, we also provide a normal description of the room.