Orange System | Starbase Trek

(GameBot is dbref #2117; last content update: July 5, 2001)
Currently coding the 50 adventure cards, ugh. This'll take some time.


The Basics of GameBot

"This game was loosely based around Trelaine, Squire of Gothos, who splits the Enterprise and its crew into four identical copies. I think that's how many copies we sold too..."

-- Peter Corless, playtester
http://www.employees.org/~pcorless/author.html

@create gamebot;bot;robot;game;gameboard;board;gb
@desc #2117 = @switch(@g("gstate"),
  {0,1},"A friendly gamebot stands ready to host a game of Star Trek: 
    The Enterprise^4 Encounter.",
  @print("An electronic table and gameboard, with a game of Star Trek: The
    Enterprise^4 Encounter already in progress.", @call(2117,"showboard")));
@field #2117 = varobj : 2117
@lock #2117 = #8796&!#8796
@link #2117 = #10322   // Starbase Trek
@set #2117 = expert

// The board layout looks like this:
// ------------------------------------------
//               BLUE(   )BASE
//                     |
//      1(   )-(  .)-(   )-(   )-(  ,)5
//     20(  ,)    2    3    4    (   )6
// YLLW  (   )19                7(  .)  RED
// (   )-(   )18                8(   )-(   )
// BASE  (  .)17                9(   )  BASE
//     16(   )   14   13    12   (  ,)10
//     15(  ,)-(   )-(   )-(  .)-(   )11
//                     |
//              GREEN(   )BASE
// ------------------------------------------
// BRGY=players  +=crew  .=tz  ,=tz&ezb
// When adv on space, advcode replaces space#,
// and space uses []s, not ()s.
// ------------------------------------------
//
// Notes:
// - use 1st position for + (crew) or blank (no crew)
// - use 2nd position for BRGY (1-player) or blank (no player)
// - use 3rd position for .(tz) or ,(tz&ezb) or blank (normal)
// - if 2,3,4 players in one space, use 2,3,4 literally.
// - eg using list below:
//    1(+  )-[+R.]-(   )-[   ]-( Y,)5
//            LZ     3    SGn
//
// Alternatively, might want to give option of a report like this:
// 1: 1 crew
// 2: [LZ], 2 crew, RED // tz
// 3: empty
// 4: [SGn]
// 5: YELLOW // tz, ebz
// ...

// SHOWBOARD
// - makes heavy use of fld sbnum and fns sbcod, sbspa
@field #2117 = showboard : @print(
  // line 1
  "%c------------------------------------------",
  // line 2
  "%c              BLUE( ",
  @switch(@g("ship1_loc"),41,"B"," "), " )BASE",
  // line 3
  "%c                    |",
  // line 4
  "%c   ", @s("sbnum",1), @call(2117,"sbcod"), @call(2117,"sbspa"),
  "-", @s("sbnum",2), @call(2117,"sbspa"),
  "-", @s("sbnum",3), @call(2117,"sbspa"),
  "-", @s("sbnum",4), @call(2117,"sbspa"),
  "-", @s("sbnum",5), @call(2117,"sbspa"), @call(2117,"sbcod"),
  // line 5
  "%c   ", @s("sbnum",20), @call(2117,"sbcod"), @call(2117,"sbspa"),
  "  ", @s("sbnum",2), @call(2117,"sbcod"),
  "   ", @s("sbnum",3), @call(2117,"sbcod"),
  "   ", @s("sbnum",4), @call(2117,"sbcod"),
  "  ", @s("sbnum",6), @call(2117,"sbspa"), @call(2117,"sbcod"),
  // line 6
  "%cYLLW  ", @s("sbnum",19), @call(2117,"sbspa"), @call(2117,"sbcod"),
  "             ",
  @s("sbnum",7), @call(2117,"sbcod"), @call(2117,"sbspa"), "  RED",
  // line 7
  "%c( ", @switch(@g("ship4_loc"),"44","Y"," "),
  " )-", @s("sbnum",18), @call(2117,"sbspa"), @call(2117,"sbcod"),
  "             ",
  @s("sbnum",8), @call(2117,"sbcod"), @call(2117,"sbspa"), "-( ",
  @switch(@g("ship2_loc"),"42","R"," "), " )",
  // line 8
  "%cBASE  ", @s("sbnum",17), @call(2117,"sbspa"), @call(2117,"sbcod"),
  "             ",
  @s("sbnum",9), @call(2117,"sbcod"), @call(2117,"sbspa"), "  BASE",
  // line 9
  "%c   ", @s("sbnum",16), @call(2117,"sbcod"), @call(2117,"sbspa"),
  "  ", @s("sbnum",14), @call(2117,"sbcod"),
  "   ", @s("sbnum",13), @call(2117,"sbcod"),
  "   ", @s("sbnum",12), @call(2117,"sbcod"),
  "  ", @s("sbnum",10), @call(2117,"sbspa"), @call(2117,"sbcod"),
  // line 10
  "%c   ", @s("sbnum",15), @call(2117,"sbcod"), @call(2117,"sbspa"),
  "-", @s("sbnum",14), @call(2117,"sbspa"),
  "-", @s("sbnum",13), @call(2117,"sbspa"),
  "-", @s("sbnum",12), @call(2117,"sbspa"),
  "-", @s("sbnum",11), @call(2117,"sbspa"), @call(2117,"sbcod"),
  // line 11
  "%c                    |",
  // line 12
  "%c             GREEN( ",
  @switch(@g("ship3_loc"),"43","G"," "), " )BASE",
  // line 13
  "%c------------------------------------------");

// SBCOD, Show Board CODe
// This is either the adventure space's #sbnum's number, or the abbrev.
// of the adventure card in that space. Must print 3 chars exactly.
// ------------------------------------------------------------------
@field #2117 = sbcod :
  @s("sbcod_done",0);
  // Search adventure cards to see if one is on the space.
  // Only one card can be there at a time.
  @fieldloop(2117,"acloc_",@switch("%v",@g("sbnum"),
    @let("k"=>@substr("%f",6),@switch("%v",
      // right-justify the code
      {1,2,3,7,8,9,14,15,16,20},
        @print( @s("sbcod_done",1),
          @substr(@print(" ",@g("accod_%k")),-3)
        ),
      // left-justify the code
      // {4,5,6,10,11,12,13,17,18,19},
        @print( @s("sbcod_done",1),
          @substr(@print(@g("accod_%k")," "),0,3)
        )
    ))
  ));
  // if no adventure card found, just show the space#.
  @switch(@g("sbcod_done"),0, @switch(@g("sbnum"),
     1, "  1",  2, "  2",  3, " 3 ",  4, "4  ",  5, "5  ",
     6, "6  ",  7, "  7",  8, "  8",  9, "  9", 10, "10 ",
    11, "11 ", 12, "12 ", 13, "13 ", 14, " 14", 15, " 15",
    16, " 16", 17, "17 ", 18, "18 ", 19, "19 ", 20, " 20"
  ));
----
TEST
@field #2117 = sbcod : @s("sbcod_done",0); @fieldloop(2117,"acloc_",@switch("%v",@g("sbnum"), @let("k"=>@substr("%f",6),@switch("%v",{1,2,3,7,8,9,14,15,16,20}, @print( @s("sbcod_done",1), @substr(@print(" ",@g("accod_%k")),-3)), @print( @s("sbcod_done",1), @substr(@print(@g("accod_%k")," "),0,3)))))); @switch(@g("sbcod_done"),0, @switch(@g("sbnum"), 1, "  1",  2, "  2",  3, " 3 ",  4, "4  ",  5, "5  ", 6, "6  ",  7, "  7",  8, "  8",  9, "  9", 10, "10 ", 11, "11 ", 12, "12 ", 13, "13 ", 14, " 14", 15, " 15", 16, " 16", 17, "17 ", 18, "18 ", 19, "19 ", 20, " 20"));
====

// SBSPA, Show Board SPAce
// Show adventure space #sbnum, represented in exactly 5 chars.
// ------------------------------------------------------------
@field #2117 = sbspa :
  // 1st, find out if an advcard here. Remember it in sbspa_1, sbspa_5.
  @s("sbspa_1","("); @s("sbspa_5",")");
  @switch(@g(@print("nac_",@g("sbnum"))),1, @print(
    @s("sbspa_1","["), @s("sbspa_5","]")
  ));
  // 2nd, find out if any crew here. Remember it in sbspa_2.
  @s("sbspa_2"," ");
  @fieldloop(2117,"ccloc_",@switch("%v",@g("sbnum"),@s("sbspa_2","+")));
  // 3rd, find out if any players here. Remember it in sbspa_3.
  @s("sbspa_3","");
  @switch(@g("ship1_loc"),@g("sbnum"),@s("sbspa_3",@print(@g("sbspa_3"),"B")));
  @switch(@g("ship2_loc"),@g("sbnum"),@s("sbspa_3",@print(@g("sbspa_3"),"R")));
  @switch(@g("ship3_loc"),@g("sbnum"),@s("sbspa_3",@print(@g("sbspa_3"),"G")));
  @switch(@g("ship4_loc"),@g("sbnum"),@s("sbspa_3",@print(@g("sbspa_3"),"Y")));
  @switch(@strlen(@g("sbspa_3")),
    0, @s("sbspa_3"," "), 2, @s("sbspa_3","2"),
    3, @s("sbspa_3"," "), 4, @s("sbspa_4","4"));
  // 4th, find out if tractor or exit battle zone here. Note in sbspa_4.
  @s("sbspa_4",@switch(@g("sbnum"),
    {2,7,12,17}, ".", {5,10,15,20}, ",", " "));
  // 5th, put it all together.
  @print(@g("sbspa_1"), @g("sbspa_2"), @g("sbspa_3"),
    @g("sbspa_4"), @g("sbspa_5"));
--------
@field #2117 = sbspa : @s("sbspa_1","("); @s("sbspa_5",")"); @switch(@g(@print("nac_",@g("sbnum"))),1, @print(@s("sbspa_1","["), @s("sbspa_5","]"))); @s("sbspa_2"," "); @fieldloop(2117,"ccloc_",@switch("%v",@g("sbnum"),@s("sbspa_2","+"))); @s("sbspa_3",""); @switch(@g("ship1_loc"),@g("sbnum"),@s("sbspa_3",@print(@g("sbspa_3"),"B"))); @switch(@g("ship2_loc"),@g("sbnum"),@s("sbspa_3",@print(@g("sbspa_3"),"R"))); @switch(@g("ship3_loc"),@g("sbnum"),@s("sbspa_3",@print(@g("sbspa_3"),"G"))); @switch(@g("ship4_loc"),@g("sbnum"),@s("sbspa_3",@print(@g("sbspa_3"),"Y"))); @switch(@strlen(@g("sbspa_3")), 0, @s("sbspa_3"," "), 2, @s("sbspa_3","2"), 3, @s("sbspa_3"," "), 4, @s("sbspa_4","4")); @s("sbspa_4",@switch(@g("sbnum"), {2,7,12,17}, ".", {5,10,15,20}, ",", " ")); @print(@g("sbspa_1"), @g("sbspa_2"), @g("sbspa_3"), @g("sbspa_4"), @g("sbspa_5"));
========

Terminology changes:

  1. Corrected the spelling of "Cochrane" (was "Conchrane", ick).
  2. Changed the Medicine specialty to "Medical".
  3. Now refer to named crew as "officers". Cadets are crew, just unnamed.
  4. Refer to the two-part bad adventure cards as DANGER/PROTECT.
  5. Refer to the two-part good adventure cards as WARP/IMPULSE.
  6. Reword rules so references to "any adventure" is now "any adventure space". Otherwise one might think there has to be an adventure card there.
  7. Reword rules so references to "specific card" is now "specific cardtype" or "specific type of card". Otherwise one might think one has to refer to "Phaser 1 Sulu" instead of just "Phaser 1".

lookup * (#2119)

@action lookup *;look up *;lu *;ask gamebot about *;ask about *;
 ask bot about *;ask board about *;ask gameboard about *;
 ask gb about * = bot : nowhere
@field #2119 = varobj : 2117
@set #2119 = puzzle
@desc #2119 = Lookup the rules of the game by asking GameBot about
 different topics, eg: 'lookup game' or 'ask gamebot about phaser 1'.
 GameBot knows many synonyms and abbreviations, eg: 'lu' is short for
 'lookup', and 'p1' is short for 'phaser 1'. So 'lu p1' is the same
 as 'ask gamebot about phaser 1'.
@succ #2119 = 
 // 1) Convert spaces in %0 to underscores, store result in field x0.
 //    This converts the phrase to lookup into a single word.
 @s("x0","lu_");
 @strloop("%0","x",@switch("%x"," ",
   @s("x0",@print(@g("x0"),"_")),@s("x0",@print(@g("x0"),"%x"))
 ));
 // 2) If topicvalue found begins with "lu_", set that as new topic.
 //    This lets me have synonyms for topics.
 @switch(@substr(@g(@g("x0")),0,3), "lu_", @s("x0",@g(@g("x0"))));
 // 3) Reply to the player with value of topic x0.
 @print("GameBot whispers (to you), \"", @strcheck(@execute(@g(@g("x0"))),
   "Sorry, I don't know the term '%4'."), "\"");

Lookup Topics

@field #2117 = lu_overview :
 New players should ask me about: intro, components, setup, turn, winning.
@field #2117 = lu_rules : lu_overview
@field #2117 = lu_ : lu_overview
@field #2117 = lu_game : lu_overview

@field #2117 = lu_adventure_space : lu_adventure
@field #2117 = lu_adventure : When you land on an Adventure Space,
 if there is already an Adventure Card there, then you will play that
 adventure. If the space is empty, you will play the next adventure
 from the Adventure Card deck. GameBoard will prompt you what your
 choices are, as appropriate. The Adventure Card will stay
 in the space after your adventure ends.

@field #2117 = lu_adventure_cards : lu_adventure-cards
@field #2117 = lu_adventure_card : lu_adventure-cards
@field #2117 = lu_adventure-card : lu_adventure-cards
@field #2117 = lu_adventure-cards : There are 50 Adventure Cards, each
 named after a different episode in STAR TREK. To lookup a specific
 Adventure Card, refer to it by its standard abbreviation (as per the
 Star Trek Concordance), eg: "lookup MW" to lookup Mudd's Women.

@field #2117 = lu_ae : ----Assignment: Earth [AE] / Gary Seven----
 %cWARP with SCIENCE:  You may take one marooned crewman from any space
 on the board.%cIMPULSE:  You may look at any one marooned crewman and
 move it to any adventure space.%c(Clarification: If you have SCIENCE, you
 may take a marooned crewman without looking at any of them. If you don't
 have SCIENCE, look at one crewman without taking any. If there aren't
 any marooned crewmen left, this adventure has no effect.)

@field #2117 = lu_aon : ----By Any Other Name [AON] / Hyperwarp----
 %cWARP with NAVIGATION:  Immediately move from one to six spaces (your
 choice) and have that adventure.%cIMPULSE:  Roll again and move BACKWARD.
 Have that adventure.

@field #2117 = lu_ar : ----Arena [Ar] / Photon Grenades----
 %cEnergize! Draw ONE Battle-card.

@field #2117 = lu_at : ----Amok Time [AT] / Pon Farr----
 %cRoll the die and move. If you do not pass a Base World, maroon a 
 crewman of your choice in the adventure you end on.%c(Clarification: If 
 you have this adventure right in front of a Base World, you must pass the 
 *next* Base World. 'Pass' means actually move past, not stop on.)

@field #2117 = lu_ay : ----All Our Yesterdays [AY] / Mr. Atoz----
 %cReplace any other adventure (or an empty space) with this one and bring
 in a new adventure here.%c(Clarification: Pick up the card and place it 
 in any other space. If the space already has a card, put that card in the
 adventure discard deck. Any ships that are already there simply ignore
 this adventure. Now draw a new adventure for this space.)

@field #2117 = lu_barrows : [1] Barrows is a Science officer.
 %c[2] Phaser 1 Barrows (Battle-card): If you have BARROWS, you may fight 
 this battle for 2 crew calls (or 2 picks in the Mind Meld). Play this 
 before the first Battle turn.

@field #2117 = lu_home : lu_base
@field #2117 = lu_home_base : lu_base
@field #2117 = lu_base_world : lu_base
@field #2117 = lu_base-world : lu_base
@field #2117 = lu_base : Each player has their own Base World; their ships
 begin the game there. Your ship won't return home until you announce that
 you have officers in all six specialties. At that time, you move your
 ship back to your Base World immediately, and "lock in" one of your crew
 (lookup lock). Each player will then have one last turn to try to keep
 you from winning (lookup last-ditch battle).

@field #2117 = lu_battles : lu_battle
@field #2117 = lu_battle : You may start a battle only in your turn, and 
 only once per turn. Battles can be started in two ways: 1) An Adventure 
 card may allow or force you to start a battle, 2) You may challenge 
 another player to battle if your ship ends its move in a Tractor Zone.
 %c   At the start of a battle, both players fill up their hands upto 2 
 Battle-cards, put their ships on the '6' spaces on either end of the 
 Battle Vortex, then take Battle-turns until the battle is over, starting
 with the player who started the battle (unless otherwise directed).
 %c   The winner of a battle gets a chance to take a crewmember from 
 his opponent's rack. (also lookup vortex, battle-card, battle-turn, hit, 
 mind meld)

@field #2117 = lu_battle_cards : lu_battle-cards
@field #2117 = lu_battle_card : lu_battle-cards
@field #2117 = lu_battle-card : lu_battle-cards
@field #2117 = lu_battle-cards : 1) When you begin a Battle, both you 
 and your opponent must have at least 2 Battle Cards. Draw cards until you
 have at least two. You may not draw additional cards during the Battle.
 %c2) You may never have more than 7 Battle Cards. If you ever have more 
 than seven, you must immediately discard the excess (you choose which).
 %c2) Battle Cards are discarded after they are played.
 %c3) Each Battle Card has a specific effect. Lookup the following
 card types: PHASER 1, PHASER 2, PHASER 3, PHOTON TORPEDO, SHIELD,
 SHIELD 2, WARP 2, COCHRANE ACCELERATION, TRACTOR, MATTER-ANTIMATTER
 LOOP, ESCAPE!
 %c4) Battle Cards with officer names on them are Special Battle Cards, 
 eg: PHASER 1 SULU (lookup special).

@field #2117 = lu_battle_turn : lu_battle-turn
@field #2117 = lu_battle-turn : In your Battle Turn, you may either play
 one Battle Card or move your ship one space forward on the Vortex towards
 the Mind Meld. Players alternate Battle Turns until one scores an
 "unshielded hit," or until one ship reaches the Mind Meld.

@field #2117 = lu_board : The board has shows a circular track of 20
 Adventure spaces, with one of the 4 Base Worlds branching out from the
 track at every fifth Adventure space. Some Adventure Spaces are labelled 
 as a Tractor Zone. Four of the Tractor Zones are also labelled as an Exit 
 Battle Zone.
 %c   In the center of the board is the Battle Vortex, and at its center
 is the Mind Meld space.

@field #2117 = lu_bt : ----Balance of Terror [BT] / Cloaking Device ----
 %cWARP with COMMAND:  Bring another ship into battle, you on '4', he on 
 '6'. He moves first.%cIMPULSE:  Draw ONE Battle Card and start a battle.

@field #2117 = lu_cadets : lu_cadet
@field #2117 = lu_cadet : Things to know about cadets:
 %c- Cadet specialties may never be used in adventures or towards winning 
 the game (exception: lookup kirk).
 %c- If you make a "crew call" for a specialty, your opponent can give you
 the Cadet with that specialty instead of an officer. In fact, if that is 
 the only crew your opponent has with the specialty you named, he must
 give you the Cadet.

@field #2117 = lu_crew_call : lu_call
@field #2117 = lu_call : You can make a "crew call" against another player if
 you win a Battle by scoring an "unshielded hit". Call for a specific 
 officer (eg: "call McCoy"), or for a specific specialty (eg: "call 
 science"). If your opponent has the named officer or specialty on his 
 rack, not counting locked in crew, he must give it to you. If he doesn't 
 have it, you get nothing. If he has it, but it's locked, you make another
 call.
 %c   If you ask for a specialty, and he has the Cadet in that specialty, 
 he can give you the Cadet instead of an officer. If you ask for a 
 specialty, and he doesn't have a crewmember with that specialty but does 
 have Starfleet, he must give you Starfleet (since Starfleet counts as all
 specialties).
 %c   BONUS: If you ask for an officer or Starfleet by name, and get it, 
 you also get one Battle-card from the deck.

@field #2117 = lu_card : lu_cards
@field #2117 = lu_deck : lu_cards
@field #2117 = lu_decks : lu_cards
@field #2117 = lu_cards : There are two decks of cards in this game:
 Adventure Cards and Battle Cards.

@field #2117 = lu_chapel : [1] Chapel is a Medical officer.
 %c[2] Phaser 1 Chapel (Battle Card): If you have CHAPEL, you may replace 
 the adventure you have just landed on with one from the deck.

@field #2117 = lu_chekov : [1] Chekov is a Navigation officer.
 %c[2] Phaser 1 Chekov (Battle Card): If you have CHEKOV, you may use this
 as a WARP 2.

@field #2117 = lu_ck : ----The Conscience of the King [CK] / 
 Kodos/Karidian----
 %cDANGER:  Maroon one crewman of your choice on an adventure space
 chosen by "Least Crew" player.
 %cPROTECT:  KIRK, RAND, or RILEY
 %c(Clarification: If the crewman is marooned on an occupied adventure, he
 may NOT be picked up until someone actually moves INTO the space.)

@field #2117 = lu_cml : ----Court Martial [CMl] / Areel Shaw----
 %cDANGER:  Immediately take another move - none of your crew or 
 specialties may be used for the new adventure.
 %cPROTECT:  SPOCK, SCOTT, or UHURA
 %c(Clarification: This means that you cannot be protected from, or 
 receive the full benefit of, the adventure which the extra move brings
 you to, regardless of what crewmembers you have.)

@field #2117 = lu_cmn : ----The Corbomite Maneuver [CMn] / Balok----
 %cDANGER:  Enter Battle, you on '6', your opponent on '4'. You move first.
 %cPROTECT:  KYLE, PALAMAS, or BARROWS

@field #2117 = lu_cms : ----The Cloud-minders [Cms] / Zenite----
 %cEnergize! Draw ONE Battle Card.

@field #2117 = lu_cmnd : lu_command
@field #2117 = lu_command : The Command specialty is represented by Kirk,
 Spock, and Scott. NOTE: You may not make a crew call for the Command
 specialty. Kirk, Spock, or Scott may be called for only by name.

@field #2117 = lu_conchrane : lu_cochrane
@field #2117 = lu_cochrane_acceleration : lu_cochrane
@field #2117 = lu_acceleration : lu_cochrane
@field #2117 = lu_ca : lu_cochrane
@field #2117 = lu_cochrane : COCHRANE ACCELERATION (Battle Card): Same as
 PHASER 1, then move forward one space on the Battle Vortex.

@field #2117 = lu_commun : lu_communication
@field #2117 = lu_communication : The Communication specialty is
 represented by Uhura, Kyle, Rand, and a cadet.

@field #2117 = lu_components : The game components are: a game board,
 24 counters to represent the crew, a deck of Adventure Cards, a deck of
 Battle Cards, plus a ship and a bridge rack for each player.

@field #2117 = lu_cp : ----Catspaw [Cp] / Magic Wand----
 %cFlip over another Adventure. If another player occupies the space, he 
 has the new Adventure but cannot start a battle.

@field #2117 = lu_counters : lu_crew
@field #2117 = lu_counter : lu_crew
@field #2117 = lu_crew : Each of the 24 crew counters bears either a name
 of a specific _Enterprise_ officer, or is an unnamed cadet, or is the
 special Starfleet counter. Also, each of the 24 crew counters has one
 of the six specialties, except for the Starfleet counter, which can be
 ANY specialty. There are three officers and one cadet for every specialty,
 except the Command specialty, for which there are only three officers.
 %c   See also: crew call, locking crew.

@field #2117 = lu_cx : ----Charile X [CX] / Charlie----
 %cWARP with RAND, PALAMAS, or ROMAINE:  Name a cardtype; all players
 must give you any cards of that type that they possess.
 %cIMPULSE:  Receive a card of a specific cardtype from one player.

@field #2117 = lu_dd : ----The Devil in the Dark [DD] / Horta----
 %cWARP with SPOCK, JONES, or LANDON:  Another player must discard three 
 cards at random.%cIMPULSE:  Another player must discard one card of his 
 choice.%c(Clarification: He can simply mix them up and allow you to draw 
 from his hand. The cards go to the discard pile.)

@field #2117 = lu_dma :----The Doomsday Machine [DMa] / Planet-Killer----
 %cDANGER:  Discard all Battle Cards except phasers and shields.
 %cPROTECT:  NAVIGATION%c(Clarification: This means you can keep Phaser
 1s, 2s, and 3s, as well as Shield 1s and Shield 2s.)

@field #2117 = lu_dmd : ----Dagger of the Mind [DMd] / Tantalus----
 %cDANGER:  Reveal one unlocked crewman to all players.
 %cPROTECT:  KIRK, MANNING, or NOEL

@field #2117 = lu_dy : ----The Deadly Years [DY] / Commodore Stocker----
 %cDANGER:  Discard all Phaser 2's and Phaser 3's.
 %cPROTECT:  ROMAINE, NOEL, or CHEKOV

@field #2117 = lu_ei : ----The Enterprise Incident [EI] / Cloaking
 Device----%cWARP with NAVIGATION:  Energize! Draw TWO Battle Cards from
 the deck or other players' hands.%cIMPULSE:  Energize! Draw ONE
 Battle Card.

@field #2117 = lu_em : ----Errand of Mercy [EM] / Organian Peace----
 %cDeal away your hand. Start to your left and deal clockwise. You choose
 which player gets which card.%c(Clarification: Keep dealing one at a time
 to the other players until all your cards are gone. In a two-player game,
 simply give your entire hand to the other player.)

@field #2117 = lu_esc : lu_escape
@field #2117 = lu_escape : ESCAPE! (Battle Card): The Battle ends
 immediately with no winner or loser. Opponent exits first, then you exit
 to the Exit Battle Zone of your choice. No crew calls are made.

@field #2117 = lu_et : ----Elaan of Troyius [ET] / Radians----
 %cEnergize! Draw ONE Battle Card.

@field #2117 = lu_ew : ----The Enemy Within [EW] / Transporter 
 Malfunction----%cIf you have more than one crewman with COMMAND (NOT 
 Starfleet), you must give one to the player with "Least Crew."

@field #2117 = lu_exchanging : lu_exchange
@field #2117 = lu_exchange : If you end your move on a space containing
 another player's ship, you must exchange your hands of Battle Cards. If
 three or more players co-occupy a space, hands are exchanged clockwise.
 GameBoard will do this for players automatically.

@field #2117 = lu_exit_battle_zone : lu_ebz
@field #2117 = lu_exit_zone : lu_ebz
@field #2117 = lu_exit : lu_ebz
@field #2117 = lu_ebz : After a Battle, both ships exit the Vortex onto any
 Exit Battle Zone space that does not contain a ship. The winner exits 
 first. If the Exit Battle Zone has any marooned crew, you may rescue one.
 If the Exit Battle Zone has an adventure card there, you play that 
 adventure unless it instructs you to start another battle.

@field #2117 = lu_fc : ----Friday's Child [FC] / Topaline----
 %cWARP with COMMUNICATION:  Energize! Draw TWO Battle Cards from the deck
 or other players' hands.%cIMPULSE:  Energize! Draw ONE Battle Card.

@field #2117 = lu_fw : ----For the World is Hollow and I Have Touched
 the Sky [FW] / Oracle----%cWARP with MANNING, McCOY, or CHAPEL:  Energize!
 Draw until you have SEVEN cards.%cIMPULSE:  Discard two cards and draw
 two new ones.%c(Clarification: You may choose which two to discard. If
 you have less than two, discard one (or none, if you have none) and draw
 two cards.)

@field #2117 = lu_gt : ----The Gamesters of Triskelion [GT] / 
 Triskelion----%cWARP with COMMUNICATION:  Look at another player's hand 
 and trade as many cards with him as you wish.%cIMPULSE:  Trade hands with 
 the player of your choice.%c(Example: You look at RED's hand. He has three
 Phaser 1s and a Phaser 3, plus a Shield. You have a Phaser 1. You can 
 trade your Phaser 1 for any one of his cards. If you had two cards, you 
 could trade each of them for one of his cards.)

@field #2117 = lu_unshielded_hit : lu_hit
@field #2117 = lu_hit : During a Battle, you can fire phasers and photon 
 torpedoes at your opponent using the appropriate battle cards, and score 
 a hit on your opponent. Your opponent may block the attack with a Shield 
 card; otherwise the hit is an "unshielded hit" and you win the battle and 
 may make a "crew call" against him.

@field #2117 = lu_introduction : lu_intro
@field #2117 = lu_intro : Captain Kirk and the crew of the Enterprise 
 are sent on a mission to re-establish contact with Trelane, the Squire of 
 Gothos (whom they first met in the STAR TREK episode _The Squire of 
 Gothos_). Trelane captures them and forces them to play a diabolical game.
 %c   Trelane creates four Enterprises and places a few crewmembers on 
 each one, marooning the rest of the crew on worlds from their past. 
 Trelane also disrupts each Enterprise's sensors, so that to each vessel,
 the other three ships appear to be Klingon battle cruisers. Trelane hopes
 the Enterprises will destroy each other while attempting to rescue the
 marooned crew.%c   In THE ENTERPRISE^4 ENCOUNTER, from two to four players
 assume command of an Enterprise and try to assemble a full crew by
 rescuing them from adventures, and by taking them from other players. The 
 first player to do so wins the game.

@field #2117 = lu_jones : [1] Jones is a Security officer.
 %c[2] Phaser 1 Jones (Battle Card): If you have JONES, you may lock in
 one of your crew during your move (may not be used to lock in JONES.)

@field #2117 = lu_kirk : [1] Kirk is a Command officer.
 %c[2] Phaser 1 Kirk (Battle Card): If you have KIRK, you may play this
 and make one Cadet's specialty count for a single adventure, or one try
 at victory.

@field #2117 = lu_kyle : [1] Kyle is a Communications officer.
 %c[2] Photon Torpedo Kyle (Battle Card): If you have KYLE, you may pick
 up one marooned crewmember.

@field #2117 = lu_landon : [1] Landon is a Security officer.
 %c[2] Phaser 1 Landon (Battle Card): If you have LANDON, you may look at
 another player's hand.

@field #2117 = lu_last-ditch_battle : lu_last-ditch
@field #2117 = lu_last-ditch : Once you have locked in a crewmember and
 moved to your Base World, each other player takes one last turn. He may
 either make a normal move, or he may call a "last-ditch battle" against
 you.
 %c   Last-ditch battle is fought in the same way as regular battle, your
 challenger moving first, and fought for the regular stakes.
 %c   If you have three or more crewmembers locked in, anyone who loses a
 last-ditch battle against you is out of the game.
 %c   If you win the battle, you make a crew call/Mind Meld as normal;
 then return to your Base World and place the loser on an empty Exit
 Battle Zone.
 %c   If you lose the battle but still have all six specialties, the winner
 exits to the Exit Battle Zone of his choice and you return to your Base 
 World.
 %c   If you lose a battle and no longer have all six specialties, you 
 exit the Battle Vortex as from a normal battle and play continues.
 %c   If you survive every other player's turn with all six specialties
 intact, you win the game!
---
@field #2117 = lu_last-ditch : Once you have locked in a crewmember and moved to your Base World, each other player takes one last turn. He may either make a normal move, or he may call a "last-ditch battle" against you.%c   Last-ditch battle is fought in the same way as regular battle, your challenger moving first, and fought for the regular stakes.%c   If you have three or more crewmembers locked in, anyone who loses a last-ditch battle against you is out of the game.%c   If you win the battle, you make a crew call/Mind Meld as normal; then return to your Base World and place the loser on an empty Exit Battle Zone.%c   If you lose the battle but still have all six specialties, the winner exits to the Exit Battle Zone of his choice and you return to your Base World.%c   If you lose a battle and no longer have all six specialties, you exit the Battle Vortex as from a normal battle and play continues.%c   If you survive every other player's turn with all six specialties intact, you win the game!
===

@field #2117 = lu_least : lu_least_crew
@field #2117 = lu_least_crew: This is the player with the least crew, not
 counting the player having the adventure. If there is a tie, the player
 having the adventure chooses between the tied players.
 %c   In a two-player game, cards referring to "least crew" now refer to
 the opposing player.

@field #2117 = lu_lock_in : lu_lock
@field #2117 = lu_locking_crew : lu_lock
@field #2117 = lu_locked_crew : lu_lock
@field #2117 = lu_locked : lu_lock
@field #2117 = lu_locking : lu_lock
@field #2117 = lu_lock : When you announce that you have all 6 specialties,
 you may lock in one crewmember. The crewmember's name is announced to
 all players. Locked crew may be used in adventures, but can't be taken
 from you in any way except via the special effect of the Phaser 1 Manning
 Battle Card. If a player makes a "crew call" for a locked-in officer or
 for a specialty that only your locked-in crew has, tell him so, and he
 gets to make a crew call for someone/something else.%c   You can lock an
 additional crewmember if you lose your 6th specialty and then regain it.
 If you have all 6 specialties locked in, you win the game immediately.
 %c   If all three members of a specialty and Starfleet are locked in,
 players without that specialty are "out of the game".

@field #2117 = lu_matter_antimatter_loop : lu_loop
@field #2117 = lu_matter-antimatter_loop : lu_loop
@field #2117 = lu_matter_antimatter : lu_loop
@field #2117 = lu_matter-antimatter : lu_loop
@field #2117 = lu_matter : lu_loop
@field #2117 = lu_mal : lu_loop
@field #2117 = lu_m-a_loop : lu_loop
@field #2117 = lu_m-a : lu_loop
@field #2117 = lu_loop : MATTER-ANTIMATTER LOOP (Battle Card): Put your
 opponent back on the '6' space of his Battle Vortex.

@field #2117 = lu_lz : ----The Lights of Zetar [LZ] / Zetarians----
 %cWARP with SCOTT, ROMAINE, or BARROWS:  Make a crew call against player
 of your choice; if correct, trade for one of your crewmen.
 %cIMPULSE:  Make a card call; if correct, trade for one of your cards.
 %c(Clarification: You must choose the player whom you wish to make the
 call against BEFORE you make the call. In the trade, you must give a
 crewman for a crewman, a card for a card.)

@field #2117 = lu_manning : [1] Manning is a Security officer.
 %c[2] Phaser 1 Manning (Battle Card): If you have MANNING, you may make a
 crew call or Mind Meld against locked-in crew. (They remain locked-in for
 you.)

@field #2117 = lu_bones : lu_mccoy
@field #2117 = lu_mccoy : [1] McCoy is a Medical officer.
 %c[2] Phaser 1 McCoy (Battle Card): If you have McCOY, you may ask one
 player for SPOCK. If that player has SPOCK (not locked in), he must give
 him to you.

@field #2117 = lu_me : ----The Menagerie [Me] / The Keepers----
 %cDANGER:  Player with "Least Crew" takes one crewman from you at random.
 %cPROTECT:  COMMAND

@field #2117 = lu_medicine : lu_medical
@field #2117 = lu_med : lu_medical
@field #2117 = lu_medical : The Medical specialty is represented by McCoy,
 Chapel, Noel, and a cadet.

@field #2117 = lu_met : ----Metamorphosis [Met] / The Companion----
 %cReverse direction of movement for all ships.%c(Clarification: All 
 players move in a counterclockwise direction (until someone lands on this
 again) but play passes to the left as usual.)

@field #2117 = lu_mind : lu_mind_meld
@field #2117 = lu_meld : lu_mind_meld
@field #2117 = lu_mind-meld : lu_mind_meld
@field #2117 = lu_mindmeld : lu_mind_meld
@field #2117 = lu_mind_meld : If you reach Mind Meld during Battle, the
 battle ends and you win. You may look at your opponent's Bridge rack and
 take the crewmember of your choice.%c   Also, if you name the crew you 
 are taking out loud to all players, you may also take one Battle Card from
 the deck.

@field #2117 = lu_mm : ----Mirror, Mirror [MM] / Dilithium----
 %cWARP with SCIENCE:  Energize! Draw THREE Battle Cards.
 %cIMPULSE:  Energize! Draw TWO Battle Cards.

@field #2117 = lu_most : lu_most_crew
@field #2117 = lu_most_crew: This is the player with the most crew, not 
 counting the player having the adventure. If there is a tie, the player 
 having the adventure chooses between the tied players.%c   In a two-player
 game, cards referring to "most crew" now refer to the opposing player.

@field #2117 = lu_movement : lu_move
@field #2117 = lu_moving : lu_move
@field #2117 = lu_move : At the start of your turn, GameBot will prompt you
 to roll the die for movement. This is mandatory. If your ship lands on
 a space with an Adventure Card, and an adjacent space does not contain an
 Adventure Card, you must move forward or backward to the empty space. This
 is called "exploring new worlds". If both adjacent spaces are empty, 
 GameBoard will prompt you to either "explore forward" or "explore back".

@field #2117 = lu_mt : ----Man Trap [MT] / Salt Monster----
 %cEach player must pass one non-Cadet crewman to the player on his left.
 %c(Clarification: If you have no officers (or all are locked in), you do
 not participate in this adventure.)

@field #2117 = lu_mw : ----Mudd's Women [MW] / Venus Drug----
 %cYou may use one Special card in your hand without having the named
 crewman.%c(Clarification: If none of your special cards are appropriate
 at the moment, this adventure has no effect.

@field #2117 = lu_nav : lu_navigation
@field #2117 = lu_navigation : The Navigation specialty is represented by
 Sulu, Chekov, Riley, and a cadet.

@field #2117 = lu_noel : [1] Noel is a Medical officer.
 %c[2] Phase 3 Noel (Battle Card): If you have NOEL, you may play this as
 another player is about to make a crew call against you. He gets no
 guesses. (Does not affect Mind Meld.)

@field #2117 = lu_nt : ----The Naked Time [NT] / Virus----
 %cDANGER:  Lose three random cards from your hand.
 %cPROTECT:  LANDON, SULU, or RILEY

@field #2117 = lu_oa : ----Operation - Annihilate! [OA] / Parasites----
 %cBring another ship to this world and trade hands. He does NOT have this
 adventure.%c(Clarification: If there are other ships here, they do NOT
 participate in the trade.)

@field #2117 = lu_officers : lu_officer
@field #2117 = lu_officer : In Command: Kirk, Spock, Scott.
 %cIn Communication: Uhura, Kyle, Rand.%cIn Medical: McCoy, Chapel, Noel.
 %cIn Navigation: Sulu, Chekov, Riley.%cIn Science: Barrows, Palamas, 
 Romaine.%cIn Security: Jones, Landon, Manning.%cIn ANY: Starfleet.

@field #2117 = lu_pa : ----A Piece of the Action [PA] / Oxmyx----
 %cEnergize! Draw ONE Battle Card.

@field #2117 = lu_palamas : [1] Palamas is a Science officer.
 %c[2] Phaser 1 Palamas (Battle Card): If you have PALAMAS, you may play
 this on a player calling battle. You select the opponent (this card may
 not be used for last-ditch battle).)

@field #2117 = lu_phaser : Phaser Battle-cards come in three strengths: 
 lookup Phaser 1, Phaser 2, and Phaser 3.
@field #2117 = lu_phaser_1 : PHASER 1 (Battle Card): When you play this you
 may roll the die one time. If you roll a number equal to or higher than
 the number of the Vortex space you are on, you score a hit. If your
 opponent doesn't block it with a Shield, you win the battle (lookup hit).
@field #2117 = lu_phaser_2 : PHASER 2 (Battle Card): Like a Phaser 1, but
 you get to roll again if your first shot misses or if your opponent
 plays a Shield against your first shot.
@field #2117 = lu_phaser_3 : PHASER 3 (Battle Card): Like a Phaser 1 or 2,
 except that you can roll three times.
@field #2117 = lu_ph : lu_phaser
@field #2117 = lu_ph1 : lu_phaser_1
@field #2117 = lu_ph2 : lu_phaser_2
@field #2117 = lu_ph3 : lu_phaser_3

@field #2117 = lu_pt : lu_photon
@field #2117 = lu_photon_torpedo : lu_photon
@field #2117 = lu_torpedo : lu_photon
@field #2117 = lu_photon : PHOTON TORPEDO (Battle Card): When you play this
 card, you automatically score one hit without rolling the die. Photon
 Torpedoes can still be Shielded, though.

@field #2117 = lu_pf : ----Patterns of Force [PF] / John Gil----
 %cWARP with MEDICAL:  You may ask each player for a specific type of
 card.%cIMPULSE:  You may ask one player for a specific type of card.
 %c(Clarification: You may ask each player in turn for a different card.
 If a player doesn't have what you ask for, he gives you nothing.)

@field #2117 = lu_danger : lu_protect
@field #2117 = lu_protect : Some adventures give you a choice of a DANGER
 or a way to PROTECT yourself. If you have one the officers or specialty
 listed after PROTECT, you may "choose protect" or just "protect" to
 avoid the danger. Otherwise, you must "choose danger" (or "danger").

@field #2117 = lu_pst : ----Plato's Stepchildren [PSt] / Kironide----
 %cWARP with MEDICAL:  Energize! Draw TWO Battle Cards from the deck or
 other players' hands.%cIMPULSE:  Energize! Draw ONE Battle Card.

@field #2117 = lu_psy : ----The Paradise Syndrome [PSy] / Obelisk----
 %cYou may look through the discard pile and select one Battle Card.

@field #2117 = lu_ra : ----The Return of the Archons [RA] / Landru----
 %cDANGER:  Give one crewman of your choice to the player of your choice.
 %cPROTECT:  JONES, MANNING, or SULU

@field #2117 = lu_bridge_rack : lu_rack
@field #2117 = lu_bridge : lu_rack
@field #2117 = lu_racks : lu_rack
@field #2117 = lu_rack : Your bridge rack is where you keep the members of
 your crew. Each player has a rack of the appropriate color. You have to
 be holding a rack to be able to see which crewmembers are in it. 
 %c   Also, whoever has the rack is considered by GameBoard to be that
 player. For example, if you hold both the red and blue racks, then you're
 both the red and blue players. If you want another mudPlayer to take over
 for you in the game, just give your rack and hand over to him or her,
 and GameBoard will figure it out.

@field #2117 = lu_rand : [1] Rand is a Communications officer.
 %c[2] Phaser 1 Rand (Battle Card): If you have RAND, you may choose your
 own exit from battle, even if you lost. You exit first.

@field #2117 = lu_marooned : lu_rescue
@field #2117 = lu_rescuing : lu_rescue
@field #2117 = lu_rescue : If you end your move on a space which has any
 marooned crew counters on it, you get one of them taken at random. You
 do not get to look at any other crew counters that may be there. The
 crew counter is added to your bridge rack.

@field #2117 = lu_riley : [1] Riley is a Navigation officer.%c[2] Phaser 1
 Riley (Battle Card): If you have RILEY, you may take your die roll in
 either direction (play this after rolling).)

@field #2117 = lu_rm : ----Requiem for Methuselah [RM] / Ryetalin----
 %cEnergize! Draw TWO Battle Cards.

@field #2117 = lu_romaine : [1] Romaine is a Science officer.
 %c[2] Warp 2 Romaine (Battle Card): If you have ROMAINE, you may play
 this on any player in battle. He must discard one SHIELD 1 or SHIELD 2.

@field #2117 = lu_rt : ----Return to Tomorrow [RT] / Sargon----
 %cWARP with SCIENCE:  Take one unlocked crewman at random form player
 with "Most Crew".%cIMPULSE:  Make one crew call for information only.
 %c(Clarification: "One crew call for information" means: select a player,
 and make a crew call against him. If he has what you call for, he tells
 you, but does not give it to you.)

@field #2117 = lu_sb : ----Spock's Brain [SB] / Kara----%cDANGER:  Player
 with "Least Crew" takes one crew from you at random.%cPROTECT:  SECURITY

@field #2117 = lu_sc : ----The Savage Curtain [SC] / Yarnek----
 %cChoose two other players to immediately battle each other. You decide
 who moves first.%c(Clarification: Remember that there may be only one
 battle per turn. If you enact this adventure, you may not call battle
 again later this turn.%cAlso, this adventure has no effect in a two-player
 game.) 

@field #2117 = lu_sci : lu_science
@field #2117 = lu_science : The Science specialty is represented by
 Barrows, Palamas, Romaine, and a cadet.

@field #2117 = lu_scotty : lu_scott
@field #2117 = lu_scott : [1] Scott is a Command officer.
 %c[2] Phaser 1 Scott (Battle Card): If you have SCOTT, you may play this
 as if it were a PHASER 3.

@field #2117 = lu_sec : lu_security
@field #2117 = lu_security : The Security specialty is represented by
 Jones, Landon, Manning, and a cadet.

@field #2117 = lu_setup : The GameBot will take care of most setup details.
 In brief: Each player chooses a color and gets the corresponding ship,
 bridge rack, and hand. The decks are shuffled. Each player gets 3
 Battle-cards for his hand, and 2 randomly chosen crew (or 3 crew in a
 2-player game) for his bridge rack. The other crew counters are placed
 randomly on the board, face down. A player is chosen at random to go
 first.

@field #2117 = lu_sgn : ----Spectre of the Gun [SGn] / Melkotians----
 %cWARP with SECURITY:  Force one player to maroon a crew of his choice on
 an adventure space of your choice.%cIMPULSE:  Force a player to discard one
 card of the type you name.%c(Clarification: The marooned crew may NOT be
 picked up by current occupants of the Adventure space. In the IMPULSE
 section, if the player does not have the card you name, there is no
 effect.)

@field #2117 = lu_shield : Lookup 'shield 1' or 'shield 2'.

@field #2117 = lu_shield_1 : SHIELD 1 (Battle Card): You play a Shield 1 
 when your opponent scores a hit on your ship. Each Shield card negates
 ONE hit. Playing a Shield does not cost a Battle Turn since you play it
 in your opponent's Battle Turn.
@field #2117 = lu_sh1 : lu_shield_1

@field #2117 = lu_shield_2 : SHIELD 2 (Battle Card): A Shield 2 negates TWO
 hits in the same Battle Turn. That is, if your opponent plays a Phaser 2
 or 3, the Shield 2 card will negate two hits from that card. The Shield 2
 will NOT negate hits made in different Battle Turns.
@field #2117 = lu_sh2 : lu_shield_2

@field #2117 = lu_enterprise : lu_ship
@field #2117 = lu_enterprises : lu_ship
@field #2117 = lu_ships : lu_ship
@field #2117 = lu_ship : Each player gets a marker in the shape of the
 starship Enterprise in his or her color. It starts out on the player's
 Base World, and on his or her turn, moves clockwise around the board on
 the Adventure Spaces. Eg: you may use "x yellow ship" to find where the
 yellow Enterprise is.
@field #2117 = lu_starships : lu_ship
@field #2117 = lu_starship : lu_ship
@field #2117 = lu_spaceship : lu_ship
@field #2117 = lu_spaceships : lu_ship

@field #2117 = lu_sl : ----Shore Leave [SL] / Fantasy Planet----
 %cWARP with KYLE, BARROWS, or SULU:  Move your ship to any other adventure 
 space and have that adventure.%cIMPULSE:  Move your ship forward or back
 one space and have that adventure.

@field #2117 = lu_special_battle_cards : lu_special
@field #2117 = lu_special : Special Battle Cards are the same as normal
 Battle-cards, except they have an extra optional effect which you may only
 use if you have the named officer. Eg: You can only play PHASER 1 SULU's
 special effect if you have Sulu. Look up the officer's name to learn what
 his or her special Battle Card does. Special cards may be played whenever
 appropriate, not just during battle.%c  To play PHASER 1 SULU as a normal
 PHASER 1, type "play phaser 1 sulu".%c  To play PHASER 1 SULU as Sulu's
 special effect, just type "play sulu".

@field #2117 = lu_specialty : lu_specialties
@field #2117 = lu_specialties : The six specialties are Command,
 Communication, Medical, Navigation, Science, and Security. There are
 three officers and one cadet in each specialty, except Command which
 has only three officers. You need one officer from each of the six
 specialties to win the game.%c   NOTE 1: Cadet specialties cannot help
 you in adventures, nor can cadet specialties help you win the game.
 %c   NOTE 2: The Starfleet crew counter is wild, and can have ANY
 specialty.

@field #2117 = lu_mr_spock : lu_spock
@field #2117 = lu_spock : [1] Spock is a Command officer.
 %c[2] Phaser 1 Spock (Battle Card): If you have SPOCK, you may play this
 card when your opponent reaches Mind Meld. He gets nothing.

@field #2117 = lu_starfleet : The Starfleet counter can act as any
 specialty, and you win if you have five other specialties plus this
 counter.

@field #2117 = lu_sulu : [1] Sulu is a Navigation officer.
 %c[2] Phaser 1 Sulu (Battle Card): If you have SULU, you may play this on
 another player as he is about to move. You move him from 1 to 6 spaces.

@field #2117 = lu_ta : ----A Taste of Armageddon [TA] / Anan-7----
 %cDANGER:  Fight "Battle to the Death" - no exit until one player has
 only shields, or no cards.%cPROTECT:  COMMAND%c(Clarification: This means
 that you select an opponent and start a battle. After the end of the
 battle, if both players still have cards that are not shields, start
 ANOTHER battle instead of exiting. You do NOT draw to fill your hand to
 two cards in the second and subsequent battles.)

@field #2117 = lu_tractor : TRACTOR (Battle Card): You move FORWARD one
 space on the Battle Vortex, and your opponent moves BACK one space.

@field #2117 = lu_tractor-zone : lu_tz
@field #2117 = lu_tractor_zone : lu_tz
@field #2117 = lu_zone : Do you mean Tractor Zone ("lookup tz") or Exit
  Battle Zone ("lookup ebz")?
@field #2117 = lu_tz : If you have an adventure in a space that is also a
 Tractor Zone, and if you haven't already been in a battle this turn, you
 may start a Battle with any other player. He cannot refuse. The winner of
 a Battle gets a chance to take a crewman from the loser.

@field #2117 = lu_two-player : lu_two
@field #2117 = lu_two_player : lu_two
@field #2117 = lu_two : In a two-player game, the following changes are 
 made:%c- Each player begins with three crewmen on his Bridge rack.%c- All
 cards referring to "least crew" or "most crew" now refer to the opposing
 player.%c- The Savage Curtain [SC] adventure has no effect on play.
 %c- The Errand of Mercy [EM] adventure requires you to give your entire
 hand to the other player.

@field #2117 = lu_tsp : ----This Side of Paradise [TSP] / Spore Plants----
 %cDANGER:  Each player (starting to your left) may ask you for a specific
 type of card.%cPROTECT:  LANDON, McCOY, or RILEY%c(Clarification: Each
 player may ask you for a different card.)

@field #2117 = lu_phases : lu_turn
@field #2117 = lu_phase : lu_turn
@field #2117 = lu_turns : lu_turn
@field #2117 = lu_turn : Each player's turn consists of the following
 phases:%c1) Movement, 2) Exchange battle cards, 3) Rescue marooned crew, 
 4) Adventure, 5) Battle, 6) Winning the game.

@field #2117 = lu_tw : ----The Tholian Web [TW] / Interdimensional Warp----
 %cWARP with UHURA, JONES, or CHEKOV:  Move another ship to any adventure
 space (except this one).
 %cIMPULSE:  Move another ship forward or back one space.

@field #2117 = lu_tws : ----That Which Survives [TWS] / Losira----
 %cDANGER:  Maroon one crewman of your choice here.%cPROTECT:  MEDICAL

@field #2117 = lu_ty : ----Tomorrow is Yesterday [TY] / Black Star----
 %cDANGER:  The player with "Least Crew" puts your ship on any adventure
 space.%cPROTECT:  UHURA, KYLE, or CHAPEL

@field #2117 = lu_uhura : [1] Uhura is a Communications officer.
 %c[2] Phaser 1 Uhura (Battle Card): If you have UHURA, you may play this
 when you are named to enter battle. The caller must call someone else.
 (This effect may not be used in last-ditch battle.)

@field #2117 = lu_battle-vortex : lu_vortex
@field #2117 = lu_battle_vortex : lu_vortex
@field #2117 = lu_vortex : The Battle Vortex is where Battles take place. 
 The layout of the Vortex is a straight track of 13 spaces labelled as 
 follows: %c[6]-[5]-[4]-[3]-[2]-[1]-(Mind Meld)-[1]-[2]-[3]-[4]-[5]-[6]
 %c(also lookup battle, battle card, battle turn, hit, mind meld)

@field #2117 = lu_wa2 : lu_warp_2
@field #2117 = lu_warp : lu_warp_2
@field #2117 = lu_warp_2 : WARP 2 (Battle Card): When you play this card,
 you may immediately move your ship ahead 2 spaces on the Battle Vortex.

@field #2117 = lu_we : ----Wink of an Eye [WE] / Scalos----
 %cWARP with SECURITY:  Take three more turns. Calling a battle ends this
 adventure.%cIMPULSE:  Take two more turns. Calling a battle ends this
 adventure.

@field #2117 = lu_winning : lu_win
@field #2117 = lu_win : To win the game, you must have one crewmember from
 each of the six specialties or put all other players out of the game.
 When you have all six specialties, GameBoard will announce the fact, you
 will get to "lock in" a crewmember, and everyone else gets one chance
 at "last-ditch battle" to prevent you from winning.

@field #2117 = lu_wnm :----Where No Man Has Gone Before [WNM] / Lithium----
 %cEnergize! Draw ONE Battle Card.

@field #2117 = lu_wm : ----Who Mourns for Adonais? [WM] / Apollo----
 %cDANGER:  Reveal your hand to all players.
 %cPROTECT:  SCOTT, PALAMAS, or CHEKOV

Action: new game

@action new game;start game;begin game;new;newgame = bot : nowhere
@desc #2417 = Starts a new game of Star Trek: The Enterprise^4 Encounter, 
  for 2 to 4 players.
@field #2417 = varobj : 2117

// note: hide all racks and hands in the Praw!
@succ #2417 = @tellroom(@location("%#"),"",
 @print("GameBot exclaims, \"New game!\"%cGameBot produces four game 
  tokens from a hidden compartment in its chest."));
 @s("arg1",2229);@call(2117,"botdrop");
 @s("arg1",2236);@call(2117,"botdrop");
 @s("arg1",2235);@call(2117,"botdrop");
 @s("arg1",2160);@call(2117,"botdrop");
 @move(10487,9671);@move(10488,9671);@move(10489,9671);@move(10490,9671);
 @move(10491,9671);@move(10492,9671);@move(10493,9671);@move(10494,9671);
 @s("gstate","1");
 @tellroom(@location("%#"),"","GameBot says, \"First, everyone who's
  playing, please take a spaceship. The color of your ship will be your
  color in the game. It's okay with me if someone wants to play as two
  players. Leave unused ships on the floor. When everyone's ready to 
  continue, someone should type 'OK'.\"");
-----
**TEST**
@succ #2417 = @tellroom(@location("%#"),"", @print("GameBot exclaims, \"New game!\"%cGameBot produces four game tokens from a hidden compartment in its chest.")); @s("arg1",2229);@call(2117,"botdrop"); @s("arg1",2236);@call(2117,"botdrop"); @s("arg1",2235);@call(2117,"botdrop"); @s("arg1",2160);@call(2117,"botdrop"); @move(10487,9671);@move(10488,9671);@move(10489,9671);@move(10490,9671); @move(10491,9671);@move(10492,9671);@move(10493,9671);@move(10494,9671); @s("gstate","1"); @tellroom(@location("%#"),"","GameBot says, \"First, everyone who's playing, please take a spaceship. The color of your ship will be your color in the game. It's okay with me if someone wants to play as two players. Leave unused ships on the floor. When everyone's ready to continue, someone should type 'OK'.\"");
=====

@field #2117 = botdrop : @move(@g("arg1"),@location("%#"));
 @setflag(@g("arg1"),"!dark"); @setfield(@g("arg1"),"lock","");
 @tellroom(@location("%#"),"",@print("GameBot drops ",
  @shortname(@g("arg1")), "."));

ok (#10485)

@action ok;ready;done;continue = bot : nowhere
@field #10485 = varobj : 2117
@desc #10485 = Continues the game, assuming it has paused for some reason.
@succ #10485 = @switch(@g("gstate"),
 "1", @call("2117","do_1"), "2", @call("2117","do_2"),
 "GameBot whispers (to you), \"But the game isn't paused.\"");

x space * (#10510)

**RENAME**
@action x space *;look space *;l space * = bot : nowhere
@field #10510 = varobj : 2117
@set #10510 = puzzle
@desc #10510 = Look at what's at one of the adventure spaces,
  eg: 'x space 3' looks at adventure space #3.

// - The weird @add("%0",0) phrase gets rids or leading zeroes
//   and spaces so 'space  3' works properly.
@succ #10510 =
 @switch(@or(@lt("%0",1),@gt("%0",20)), "1",
  "GameBoard whispers (to you), \"I don't know that space.
  Adventure spaces are numbered from 1 to 20.\"",
  @print(
   @s("sbac",99),
   @fieldloop(2117,"acloc_",@switch("%v",@add(0,"%0"),
    @s("sbac",@substr("%f",6)))),
   "GameBoard whispers (to you), \"Space #", @add("%0",0),
   @switch(@g("sbac"),99," is unexplored.",@print(
    " has the '", @g(@print("acnam_",@g("sbac"))),
    " [", @g(@print("accod_",@g("sbac"))), "]' adventure."
   )),
   @s("sbac",""),
   @switch(@g(@print("ncc_",@add("%0",0))),0,"",
    1," One crewman is marooned there.",@print(
    " ", @g(@print("ncc_",@add("%0",0))), " crewmen are marooned there."
   )),
   @switch(@g("ship1_loc"),@add("%0",0)," The blue ship is there."),
   @switch(@g("ship2_loc"),@add("%0",0)," The red ship is there."),
   @switch(@g("ship3_loc"),@add("%0",0)," The green ship is there."),
   @switch(@g("ship4_loc"),@add("%0",0)," The yellow ship is there."),
   @switch(@add("%0",0),{2,7,12,17}," It is also a Tractor Zone.",
    {5,10,15,20}," It is also a Tractor Zone and an Exit Battle Zone."),
   "\""
 ));
------
**TEST**
@succ #10510 = @switch(@or(@lt("%0",1),@gt("%0",20)), "1","GameBoard whispers (to you), \"I don't know that space. Adventure spaces are numbered from 1 to 20.\"",@print(@s("sbac",99),@fieldloop(2117,"acloc_",@switch("%v",@add(0,"%0"),@s("sbac",@substr("%f",6)))),"GameBoard whispers (to you), \"Space #", @add("%0",0),@switch(@g("sbac"),99," is unexplored.",@print(" has the '", @g(@print("acnam_",@g("sbac")))," [", @g(@print("accod_",@g("sbac"))),"]' adventure.")),@s("sbac",""),@switch(@g(@print("ncc_",@add("%0",0))),0,"",1," One crewman is marooned there.",@print(" ", @g(@print("ncc_",@add("%0",0))), " crewmen are marooned there.")), @switch(@g("ship1_loc"),@add("%0",0)," The blue ship is there."), @switch(@g("ship2_loc"),@add("%0",0)," The red ship is there."), @switch(@g("ship3_loc"),@add("%0",0)," The green ship is there."), @switch(@g("ship4_loc"),@add("%0",0)," The yellow ship is there."), @switch(@add("%0",0),{2,7,12,17}," It is also a Tractor Zone.", {5,10,15,20}," It is also a Tractor Zone and an Exit Battle Zone."), "\""));
======

roll die (#10497)

@action roll die;roll;toss die;throw die = bot : nowhere
@desc #10497 = Rolls a normal 6-sided die.
@field #10497 = varobj : 2117
@succ #10497 = 
 @switch(@g("gstate"), 3, @call(2117,"phase1"),
  "['ROLL' is not a valid option right now.]" );

// Rolling the die at beginning of movement phase.
// First, best check that it's the player who SHOULD roll.
// If not, STOP HERE. Else go phase1b
@field #2117 = phase1 :
 @call(2117,"calc_whodbr_turn");
 @switch("%#", @g("whodbr_turn"), @call(2117,"phase1b"),
  @print("Gamebot whispers (to you), \"Sorry, but it's the ",
   @g("whocna_turn"), " player who must 'ROLL' now.\""));
-----
**TEST**
@field bot = phase1 : @call(2117,"calc_whodbr_turn"); @switch("%#", @g("whodbr_turn"), @call(2117,"phase1b"), @print("Gamebot whispers (to you), \"Sorry, but it's the ", @g("whocna_turn"), " player who must 'ROLL' now.\""));
=====

@field #2117 = phase1b :
 @s("dieval",@add(@rand(6),1));
 @tell("%#", @print("You roll a ", @g("dieval"), "."));
 @tellroom(@location("%#"),"%#", @print("%n rolls a ", @g("dieval"), "."));
 // Calculate the nowdir from the stddir.
 @s("nowdir",@g("stddir"));
 // Move the player's ship dieval spaces in the nowdir direction.
 // Do a little fakery to map Base Worlds to Adventure Spaces
 @s("loc_x0",@g(@print("ship",@g("whoclr_turn"),"_loc")));
 @s("loc_x1",@g(@print("ship",@g("whoclr_turn"),"_loc")));
 @switch(@g("loc_x1"),41,@s("loc_x1",2),42,@s("loc_x1",7),
    43,@s("loc_x1",12),44,@s("loc_x1",17));
 @switch(@g("nowdir"),
  0, @s("loc_x2",@add(@mod(@sub(@add(@g("loc_x1"),@g("dieval")),1),20),1)),
  1, @s("loc_x2",@add(@mod(@add(@sub(@g("loc_x1"),@g("dieval")),19),20),1))
 );
 @tellroom(@location("%#"),"",@print("From ", 
  @switch(@g("loc_x0"), 41,"the Blue Base World", 42,"the Red Base World",
   43,"the Green Base World", 44,"the Yellow Base World",
   @print("space #", @g("loc_x0"))),
  ", the ", @g(@print("clrnam",@g("whoclr_turn"))),
  " ship glides clockwise around the board by ",
  @g("dieval"), @switch(@g("dieval"),"1", " space", " spaces"),
  ", arriving at space #", @g("loc_x2"),
  "."));
 @s(@print("ship",@g("whoclr_turn"),"_loc"),@g("loc_x2"));
 // Set isadv_here = 1 if adventure card already here.
 // Set isadv_forw = 1 if adventure card in forward direction
 // Set isadv_back = 1 if adventure card in back direction
 @s("isadv_here",0); @s("isadv_forw",0); @s("isadv_back",0);
 @s("loc_x2f",@add(@mod(@g("loc_x2"),20),1));
 @s("loc_x2b",@add(@mod(@add(@g("loc_x2"),18),20),1));
 @fieldloop(2117,"acloc_",@switch("%v",
  @g("loc_x2"),@s("isadv_here",1),
  @g("loc_x2f"),@s("isadv_forw",1),
  @g("loc_x2b"),@s("isadv_back",1)
 ));
 // if isadv_here = 1 and isadv_forw = 0 and isadv_back = 0,
 //   then we have to ask the player (gstate=4) and STOP HERE.
 @switch(@and(@eq(@g("isadv_here"),1),
        @eq(0,@g("isadv_forw"),@g("isadv_back"))),
  "1", @print(@s("gstate",4), @tellroom(@location(""),"",@print(
   "An adventure card is here, but not at either neighboring space. \"",
   @g("whorna_turn"), ",\" GameBoard says, \"you must \"explore new worlds\".
   Do you choose to go 'FORWARD' to #",
   @g("loc_x2f"), " or 'BACK' to #", @g("loc_x2b"), "?\""
  ))), 
  // else go phase1c
  @call(2117,"phase1c")
 );

@field #2117 = phase1forw : TODO
@field #2117 = phase1back : TODO

@field #2117 = phase1c :
  // If isadv_here = 1 and isadv_forw = 1 and isadv_back = 0,
  //   then back 1
  @switch(@and(@eq(@g("isadv_here"),@g("isadv_forw"),1),@eq(@g("isadv_back"),0)),
   "1", @print( @tellroom(@location("%#"),"", @print(
     "An adventure card is both here and ahead, but not behind, so the ",
     @g(@print("clrnam",@g("whoclr_turn"))),
     " ship moves back 1 space, to space #",
     @g("loc_x2b"), ".")),
     @s(@print("ship",@g("whoclr_turn"),"_loc"),@g("loc_x2b")))
  );
  // Elseif isadv_here = 1 and isadv_forw = 0 and isadv_back = 1,
  //   then forward 1
  @switch(@and(@eq(@g("isadv_here"),@g("isadv_back"),1),@eq(@g("isadv_forw"),0)),
   "1", @print( @tellroom(@location("%#"),"", @print(
     "An adventure card is both here and behind, but not ahead, so the ",
     @g(@print("clrnam",@g("whoclr_turn"))),
     " ship moves forward 1 space, to space #",
     @g("loc_x2f"), ".")),
     @s(@print("ship",@g("whoclr_turn"),"_loc"),@g("loc_x2f")))
  );
  // Else we stay where we are because all are full.
  @switch(@eq(1,@g("isadv_here"),@g("isadv_back"),@g("isadv_forw")),
   "1", @print(@tellroom(@location("%#"),"",@print(
     "An adventure card is here, but also ahead and behind, so the ",
     @g(@print("clrnam",@g("whoclr_turn"))),
     " ship stops."))));
  // Else we stay where we are because the locn has no card.
  @switch(@g("isadv_here"),
   "0", @print(@tellroom(@location("%#"),"",@print(
     "No adventure card is here, so the ",
     @g(@print("clrnam",@g("whoclr_turn"))),
     " ship stops here to explore."))));
  // Continue goto phase2: Exchanging Battle Cards
  @call(2117,"phase2");

**TO TEST**
// PHASE 2: EXCHANGING BATTLE CARDS
// Build the whoclrs_here string. Prepend and append it with a '5'
// to represent a "fifth" player.
// If the whoclr_here string is longer than 3 chars, then
// strloop through it, treating it in pairs, eg:
//  "5ABC5" means A gives his hand to 5, B gives his hand to A, etc.
@field #2117 = phase2 : 
  @s("loc_x0",@g(@print("ship",@g("whoclr_turn"),"_loc")));
  @s("whoclrs_here","5");
  @switch(@g("ship4_loc"),@g("loc_x0"),
    @s("whoclrs_here",@print(@g("whoclrs_here"),"4")));
  @switch(@g("ship3_loc"),@g("loc_x0"),
    @s("whoclrs_here",@print(@g("whoclrs_here"),"3")));
  @switch(@g("ship2_loc"),@g("loc_x0"),
    @s("whoclrs_here",@print(@g("whoclrs_here"),"2")));
  @switch(@g("ship1_loc"),@g("loc_x0"),
    @s("whoclrs_here",@print(@g("whoclrs_here"),"1")));
  @s("whoclrs_here",@print(@g("whoclrs_here"),"5"));
  @switch(@strlen(@g("whoclrs_here")),{4,5,6},@print(
    @tellroom(@location("%#"),"",@print(
      "GameBoard says, \"There are now ",
      @sub(@strlen(@g("whoclrs_here")),2),
      " players in this space; those players must now
      exchange their battle cards in their hands.\"")),
    @call(2117,"phase2b")));
  @call(2117,"phase3");
---------
@field #2117 = phase2 : @s("loc_x0",@g(@print("ship",@g("whoclr_turn"),"_loc"))); @s("whoclrs_here","5"); @switch(@g("ship1_loc"),@g("loc_x0"), @s("whoclrs_here",@print(@g("whoclrs_here"),"1"))); @switch(@g("ship2_loc"),@g("loc_x0"), @s("whoclrs_here",@print(@g("whoclrs_here"),"2"))); @switch(@g("ship3_loc"),@g("loc_x0"), @s("whoclrs_here",@print(@g("whoclrs_here"),"3"))); @switch(@g("ship4_loc"),@g("loc_x0"), @s("whoclrs_here",@print(@g("whoclrs_here"),"4"))); @s("whoclrs_here",@print(@g("whoclrs_here"),"5")); @switch(@strlen(@g("whoclrs_here")),{4,5,6},@print(@tellroom(@location("%#"),"",@print("GameBoard says, \"There are now ", @sub(@strlen(@g("whoclrs_here")),2), " players in this space; those players must now exchange their battle cards in their hands.\"")), @call(2117,"phase2b"))); @call(2117,"phase3");
=========

**TO TEST**
@field #2117 = phase2b :
  @s("i",0");
  @strloop(@g("whoclrs_here"),"x", @switch(
    @lt(@add(@g("i"),1),@strlen(@g("whoclrs_here"))), "1", @print(
      @s("arg1",@add(40,@substr(@g("whoclrs_here"),@add(@g("i"),1),1))),
      @s("arg2",@add(40,"%x")),
      @call(2117,"qmove_bc")
  )));
-------
@field #2117 = phase2b : @s("i",0"); @strloop(@g("whoclrs_here"),"x", @switch( @lt(@add(@g("i"),1),@strlen(@g("whoclrs_here"))), "1", @print( @s("arg1",@add(40,@substr(@g("whoclrs_here"),@add(@g("i"),1),1))), @s("arg2",@add(40,"%x")), @call(2117,"qmove_bc"))));
=======

**TO TEST**
// quick move all battle cards from arg1 to arg2
// note: assuming arg1 is empty.
// therefore, we can leave the bcpos_X values as is.
// This is ONLY to be called by phase2b.
@field #2117 = qmove_bc:
 @tellroom(@location("%#"),"",@print(
  "GameBoard moves the cards from the ",
  @switch(@g("arg1"),41,"blue",42,"red",43,"green",44,"yellow","sidebar"),
  " hand to the ",
  @switch(@g("arg2"),41,"blue",42,"red",43,"green",44,"yellow","sidebar"),
  " hand."
 ));
 @fieldloop(2117,"bcloc_",@switch("%v",@g("arg1"),
  @s("%f",@g("arg2"))));
 @s(@print("nbc_",@g("arg2")),@g(@print("nbc_",@g("arg1"))));
 @s(@print("nbc_",@g("arg1")),0);
-------
@field #2117 = qmove_bc: @tellroom(@location("%#"),"",@print("GameBoard moves the cards from the ", @switch(@g("arg1"),41,"blue",42,"red",43,"green",44,"yellow","sidebar"), " hand to the ", @switch(@g("arg2"),41,"blue",42,"red",43,"green",44,"yellow","sidebar"), " hand.")); @fieldloop(2117,"bcloc_",@switch("%v",@g("arg1"), @s("%f",@g("arg2")))); @s(@print("nbc_",@g("arg1")),@g(@print("nbc_",@g("arg2")))); @s(@print("nbc_",@g("arg2")),0);
=======

**TO TEST**
// PHASE 3: RESCUE A MAROONED CREWMEMBER
// CAUTION: Assuming this is the whoclr_turn player doing this.
// NOTE: The value of cc_moved is set by botdealcc1.
@field #2117 = phase3 :
 // if ncc[shipX_loc] > 0,...
 @switch(@gt(@g(@print("ncc_",@g(@print("ship",@g("whoclr_turn"),"_loc")))),0),
 "1", @print(
   @s("arg1",@g(@print("ship",@g("whoclr_turn"),"_loc"))),
   @s("arg2",@add(40,@g("whoclr_turn"))),
   @call(2117,"botdealcc1"),
   @tellroom(@location("%#"),"%#",@print(
     "%n rescues a marooned crew member, and adds him or her to %p ",
     @g(@print("clrnam",@g("whoclr_turn"))), " bridge rack."
   )),
   @tell("%#",@print(
    "You rescue ", @g(@print("ccnam_",@g("cc_moved"))), " (",
    @g(@print("speabbr_",@g(@print("ccspe_",@g("cc_moved"))))),
    "), who was marooned, and add ",
    @switch(@substr(@g("ccsexs"),@g("cc_moved"),1),"F","her","him"), 
    " to your ", @g(@print("clrnam",@g("whoclr_turn"))), " bridge rack."
   ))
 ), @tellroom(@location("%#"),"","No crew to rescue here."));
 @s("whoord_inadv",@g("whoord_turn")); @s("whoclr_inadv",@g("whoclr_turn"));
 @call(2117,"phase4");
-----------
@field #2117 = phase3 : @switch(@gt(@g(@print("ncc_",@g(@print("ship",@g("whoclr_turn"),"_loc")))),0), "1", @print(@s("arg1",@g(@print("ship",@g("whoclr_turn"),"_loc"))), @s("arg2",@add(40,@g("whoclr_turn"))), @call(2117,"botdealcc1"), @tellroom(@location("%#"),"%#",@print("%n rescues a marooned crew member, and adds him or her to %p ", @g(@print("clrnam",@g("whoclr_turn"))), " bridge rack.")), @tell("%#",@print("You rescue ", @g(@print("ccnam_",@g("cc_moved"))), " (", @g(@print("speabbr_",@g(@print("ccspe_",@g("cc_moved"))))), "), who was marooned, and add ", @switch(@substr(@g("ccsexs"),@g("cc_moved"),1),"F","her","him"), " to your ", @g(@print("clrnam",@g("whoclr_turn"))), " bridge rack."))), @tellroom(@location("%#"),"","No crew to rescue here.")); @s("whoord_inadv",@g("whoord_turn")); @s("whoclr_inadv",@g("whoclr_turn")); @call(2117,"phase4");
===========

//PHASE 4: HAVE AN ADVENTURE
// If no card here, put the next one from the deck here and play it.
// Else, play the card that's here.
@field #2117 = phase4 :
 @s("loc_x0",@g(@print("ship",@g("whoclr_inadv"),"_loc")));
 @call(2117,"calc_whodbr_inadv");
 @s("the_ac",99);
 @fieldloop(2117,"acloc_",@switch("%v", @g("loc_x0"),
   @print(
     // OLDONE, anything else TODO?
     @s("the_ac",@substr("%f",6))
   )
 ));
 @switch(@g("the_ac"),99, @print(
  // DEALONE
  @fieldloop("2117","acloc_",
    @let("k"=>@substr("%f",6),@switch( @and(@eq("%v",0),
         @eq(@g("acpos_%k"),@sub(@g("nac_0"),1))),
       "1", @print(
         @s("the_ac","%k"), @s("%f",@g("loc_x0")),
         @s("acpos_%k", @g(@print("nac_",@g("loc_x0"))))
       )
    ))
  ),
  @s("nac_0", @sub(@g("nac_0"),1)),
  @s(@print("nac_",@g("loc_x0")), 1),
  @tell(@g("whodbr_inadv"),
   "You draw a new adventure card and put it into play."),
  @tellroom(@location("%#"),@g("whodbr_inadv"), @print(
   @g("whorna_inadv"),
   " draws a new adventure card it puts it into play."))
 ));
 @tellroom(@location("%#"),"",@print("GameBoard says, \"",
  @g("whocna_inadv"), "'s adventure is...%c",
  @call(2117,@print("lu_",@g(@print("accod_",@g("the_ac"))))), "\""
 ));
 @call(2117,@print("do_adv_",@g("the_ac")));
---------
**TEST**
@field #2117 = phase4 : @s("loc_x0",@g(@print("ship",@g("whoclr_inadv"),"_loc"))); @call(2117,"calc_whodbr_inadv"); @s("the_ac",99); @fieldloop(2117,"acloc_",@switch("%v", @g("loc_x0"), @print( @s("the_ac",@substr("%f",6))))); @switch(@g("the_ac"),99, @print(@fieldloop("2117","acloc_", @let("k"=>@substr("%f",6),@switch( @and(@eq("%v",0), @eq(@g("acpos_%k"),@sub(@g("nac_0"),1))), "1", @print(@s("the_ac","%k"), @s("%f",@g("loc_x0")), @s("acpos_%k", @g(@print("nac_",@g("loc_x0")))))))), @s("nac_0", @sub(@g("nac_0"),1)), @s(@print("nac_",@g("loc_x0")), 1), @tell(@g("whodbr_inadv"), "You draw a new adventure card and put it into play."), @tellroom(@location("%#"),@g("whodbr_inadv"), @print(@g("whorna_inadv"), " draws a new adventure card it puts it into play.")))); @tellroom(@location("%#"),"",@print("GameBoard says, \"", @g("whocna_inadv"), "'s adventure is...%c", @call(2117,@print("lu_",@g(@print("accod_",@g("the_ac"))))), "\"")); @call(2117,@print("do_adv_",@g("the_ac")));
=========

**TO TEST**
// [AE] Assignment Earth - offer 'warp' or 'impulse'
@field #2117 = do_adv_0 : @s("gstate",5); @call(2117,"setmsg_wrpimp");

// to warp, SCIENCE: Barrows(20),Palamas(21),Romaine(22),Starfleet(0)
// TODO: Cadet-Sci(23) plus Kirk(1) plus Phaser 1 Kirk complication
@field #2117 = do_adv_0w :
 @call(2117,"echo_warp");
 @s("why_warp_ok","officer with Science");
 @s("rack_inadv",@add(40,@g("whoclr_inadv")));
 @switch(@or(@eq(@g("ccloc_20"),@g("rack_inadv")),
     @eq(@g("ccloc_21"),@g("rack_inadv")),
     @eq(@g("ccloc_22"),@g("rack_inadv")),
     @eq(@g("ccloc_0"),@g("rack_inadv"))),
  "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_0wz")),
  @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_0i"))
 );
----------
**TEST**
@field bot = do_adv_0w : @call(2117,"echo_warp"); @s("why_warp_ok","officer with Science"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_20"),@g("rack_inadv")), @eq(@g("ccloc_21"),@g("rack_inadv")), @eq(@g("ccloc_22"),@g("rack_inadv")), @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_0wz")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_0i")));
==========

// TODO: If no crew are marooned, end the adventure.
// Else, choose a space that has a marooned man on it.
@field #2117 = do_adv_0wz :
 @s("gstate",6);
 @tellroom(@location("%#"),"",@print(
   "GameBoard says (to %n), \"", @g("whocna_inadv"),
   "choose a space with marooned crew on it, eg: 'SPACE 10'."
 ));
-----
**TEST**
@field #2117 = do_adv_0wz : @s("gstate",6); @tellroom(@location("%#"),"",@print("GameBoard says (to %n), \"", @g("whocna_inadv"), "choose a space with marooned crew on it, eg: 'SPACE 10'."));
=====

// Verify that the chosen space has a crewman on it.
// If it does, move a crewman from there to the inadv's rack and end adv.
@field #2117 = do_adv_0ws :
  @switch("%#",@g("whodbr_inadv"),@print(
    @call(2117,"echo_space"),
    @switch("1",
      @eq(@g(@print("ncc_",@g("space_chosen"))),0),@print(
        @tellroom(@location("%#"),"",@print(
          "GameBoard says (to %n), \"", @g("whocna_inadv"),
          ", that space has no marooned crew. Choose another space.\""
        ))
      ),
      @print(
        @s("arg1",@g("space_chosen")),
        @s("arg2",@add(40,@g("whoclr_inadv"))),
        @call(2117,"botdealcc1"),
        @tell("%#",@print(
          "You rescue ", @g(@print("ccnam_",@g("cc_moved"))), " (",
          @g(@print("speabbr_",@g(@print("ccspe_",@g("cc_moved"))))),
          ") from space #", @g("space_chosen"), " and add ",
          @switch(@substr(@g("ccsexs"),@g("cc_moved"),1),"F","her","him"), 
          " to your ",
          @g(@print("clrnam",@g("whoclr_turn"))), " bridge rack."
        )),
        @tellroom(@location("%#"),"%#",@print(
          "%n rescues a marooned crew member from space #", @g("space_chosen"),
          ", and adds him or her to %p ",
          @g(@print("clrnam",@g("whoclr_inadv"))), " bridge rack."
        )),
        @call(2117,"end_adv")
      )
    )
  ), @call(2117,"you_not_inadv"));
------
**TEST**
@field #2117 = do_adv_0ws : @switch("%#",@g("whodbr_inadv"),@print(@call(2117,"echo_space"), @switch("1", @eq(@g(@print("ncc_",@g("space_chosen"))),0),@print(@tellroom(@location("%#"),"",@print("GameBoard says (to %n), \"", @g("whocna_inadv"), ", that space has no marooned crew. Choose another space.\""))), @print(@s("arg1",@g("space_chosen")), @s("arg2",@add(40,@g("whoclr_inadv"))), @call(2117,"botdealcc1"), @tell("%#",@print("You rescue ", @g(@print("ccnam_",@g("cc_moved"))), " (", @g(@print("speabbr_",@g(@print("ccspe_",@g("cc_moved"))))), ") from space #", @g("space_chosen"), " and add ", @switch(@substr(@g("ccsexs"),@g("cc_moved"),1),"F","her","him"), " to your ", @g(@print("clrnam",@g("whoclr_turn"))), " bridge rack.")), @tellroom(@location("%#"),"%#",@print("%n rescues a marooned crew member from space #", @g("space_chosen"), ", and adds him or her to %p ", @g(@print("clrnam",@g("whoclr_inadv"))), " bridge rack.")), @call(2117,"end_adv")))), @call(2117,"you_not_inadv"));
======

// TODO: If no crew are marooned, end the adventure.
// Else, choose a space that has a marooned man on it.
@field #2117 = do_adv_0i :
 @call(2117,"echo_impulse"); @s("gstate",7);
 @tellroom(@location("%#"),"",@print(
  "GameBoard says (to %n), \"", @g("whocna_inadv"),
  "choose a space with marooned crew on it, eg: 'SPACE 10'."));
-----
**TEST**
@field #2117 = do_adv_0i : @call(2117,"echo_impulse"); @s("gstate",7); @tellroom(@location("%#"),"",@print("GameBoard says (to %n), \"", @g("whocna_inadv"), "choose a space with marooned crew on it, eg: 'SPACE 10'."));
=====

// Verify that the chosen space has a crewman on it.
// If it does, move a crewman from there to the 0 pile,
//  tell inadv who it is, and ask for a space to move it to.
@field #2117 = do_adv_0is1 :
  @switch("%#",@g("whodbr_inadv"),@print(
    @call(2117,"echo_space"),
    @switch("1",
      @eq(@g(@print("ncc_",@g("space_chosen"))),0),@print(
        @tellroom(@location("%#"),"",@print(
          "GameBoard says (to %n), \"", @g("whocna_inadv"),
          ", that space has no marooned crew. Choose another space.\""
        ))
      ),
      @print(
        @s("arg1",@g("space_chosen")), @s("arg2",0),
        @call(2117,"botdealcc1"),
        @tell("%#",@print(
          "GameBoard picks up a crewman from space #", @g("space_chosen"),
          " and shows it to you: ", @g(@print("ccnam_",@g("cc_moved"))), " (",
          @g(@print("speabbr_",@g(@print("ccspe_",@g("cc_moved"))))), ")."
        )),
        @tellroom(@location("%#"),"%#",@print(
          "GameBoard picks up a crewman from space #", @g("space_chosen"),
          " and shows it to %n."
        )),
        @tellroom(@location("%#"),"",@print(
          "GameBoard says (to %n), \"", @g("whocna_inadv"),
          ", now choose the new space where it will go, eg: 'SPACE 10'."
        )),
        @s("gstate",8)
      )
    )
  ), @call(2117,"you_not_inadv"));
-------
**TEST**
@field #2117 = do_adv_0is1 : @switch("%#",@g("whodbr_inadv"),@print(@call(2117,"echo_space"), @switch("1", @eq(@g(@print("ncc_",@g("space_chosen"))),0),@print(@tellroom(@location("%#"),"",@print("GameBoard says (to %n), \"", @g("whocna_inadv"), ", that space has no marooned crew. Choose another space.\""))), @print(@s("arg1",@g("space_chosen")), @s("arg2",0), @call(2117,"botdealcc1"), @tell("%#",@print("GameBoard picks up a crewman from space #", @g("space_chosen"), " and shows it to you: ", @g(@print("ccnam_",@g("cc_moved"))), " (", @g(@print("speabbr_",@g(@print("ccspe_",@g("cc_moved"))))), ").")), @tellroom(@location("%#"),"%#",@print("GameBoard picks up a crewman from space #", @g("space_chosen"), " and shows it to %n.")), @tellroom(@location("%#"),"",@print("GameBoard says (to %n), \"", @g("whocna_inadv"), ", now choose the new space where it will go, eg: 'SPACE 10'.")), @s("gstate",8)))), @call(2117,"you_not_inadv"));
=======

@field #2117 = do_adv_0is2 :
 @switch("%#",@g("whodbr_inadv"),@print(
  @call(2117,"echo_space"),
  @s("arg1",0), @s("arg2",@g("space_chosen")),
  @call(2117,"botdealcc1"),
  @tell("%#",@print(
   "GameBoard maroons ", @g(@print("ccnam_",@g("cc_moved"))), " (",
   @g(@print("speabbr_",@g(@print("ccspe_",@g("cc_moved"))))),
   ") on space #", @g("space_chosen"), "."
  )),
  @tellroom(@location("%#"),"%#",@print(
   "GameBoard maroons the crewman on space #", @g("space_chosen"), "."
  )),
  @call(2117,"end_adv")
 ), @call(2117,"you_not_inadv"));
-------
**TEST**
@field #2117 = do_adv_0is2 : @switch("%#",@g("whodbr_inadv"),@print(@call(2117,"echo_space"), @s("arg1",0), @s("arg2",@g("space_chosen")), @call(2117,"botdealcc1"), @tell("%#",@print("GameBoard maroons ", @g(@print("ccnam_",@g("cc_moved"))), " (", @g(@print("speabbr_",@g(@print("ccspe_",@g("cc_moved"))))), ") on space #", @g("space_chosen"), ".")), @tellroom(@location("%#"),"%#",@print("GameBoard maroons the crewman on space #", @g("space_chosen"), ".")), @call(2117,"end_adv")), @call(2117,"you_not_inadv"));
=======

**TO TEST**
// [AON] By Any Other Name - offer 'warp' or 'impulse'
@field bot = do_adv_1 : @s("gstate",9); @call(2117,"setmsg_wrpimp");

// to warp, NAV: Chekov(12),Riley(13),Sulu(14),Starfleet(0)
// TODO: Nav-Cadet plus Kirk(1) plus Phaser 1 Kirk complication
@field bot = do_adv_1w :
  @call(2117,"echo_warp");
  @s("why_warp_ok","officer with Navigation");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_12"),@g("rack_inadv")),
      @eq(@g("ccloc_13"),@g("rack_inadv")),
      @eq(@g("ccloc_14"),@g("rack_inadv")),
      @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_warp_ok"), @call(2117,"do_adv_1w1")
    ),
    @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_1i"))
  );
--------
**TEST**
@field bot = do_adv_1w : @call(2117,"echo_warp"); @s("why_warp_ok","officer with Navigation"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_12"),@g("rack_inadv")), @eq(@g("ccloc_13"),@g("rack_inadv")), @eq(@g("ccloc_14"),@g("rack_inadv")), @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_1w1")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_1i")));
========

@field bot = do_adv_1w1 : TODO
@field bot = do_adv_1i : TODO
  @call(2117,"echo_impulse");

// [Ar] Arena - deal him a new battle card. END ADV.
@field bot = do_adv_2 :
  @s("arg1",0); @s("arg2",@add(40,@g("whoclr_inadv")));
  @call(2117,"echo_dealbc");
  @s("whoclr_cards",@g("whoclr_inadv")); @call(2117,"echo_7cardmax");
  @call(2117,"end_adv");
-----
**TEST**
@field bot = do_adv_2 : @s("arg1",0); @s("arg2",@add(40,@g("whoclr_inadv"))); @call(2117,"echo_dealbc"); @s("whoclr_cards",@g("whoclr_inadv")); @call(2117,"echo_7cardmax"); @call(2117,"end_adv");
=====

// [AT] Amok Time - autoroll & move ship.
// Might either offer 'maroon crewname' or END THIS ADV AND START NEW ADV.
@field bot = do_adv_3 :
  @call(2117,"do_adv_3_roll");
  @switch(@g("didpassbase"),
    "0",@switch(@g(@print("ncc_",@add(40,@g("whoclr_inadv")))),
      "0",@print(
        @tellroom(@location("%#"),"",@print(
          "GameBoard says, \"", @g("whocna_inadv"),
          " didn't pass a Base World, but has no crewman to maroon anyway.\""
        )),
        @call(2117,"end_adv")
      ),
      "1",@print(
        @fieldloop(2117,"ccloc_",@switch("%v", @add(40,@g("whoclr_inadv")),
          @s("crew_chosen",@substr("%f",6))
        )),
        @call(2117,"do_adv_3cz")
      ),
      @print(
        @s("gstate",11),
        @tellroom(@location("%#"),"",@print(
          "GameBoard says (to ", @g("whorna_inadv"),
          "), \"", @g("whocna_inadv"),
          ", you didn't pass a Base World. Choose which of your crewman to maroon, eg: 'CREW SULU'.\""
        ))
      )
    ),
    @print(
      @tellroom(@location("%#"),"",@print(
        "GameBoard says, \"", @g("whocna_inadv"),
        " passed the ", @ucfirst(@g(@print("clrnam",@g("basepassed")))),
        " Base World and so avoided the danger.\""
      )),
      @call(2117,"end_adv")
    )
  );
-------
**TEST**
@field bot = do_adv_3 : @call(2117,"do_adv_3_roll"); @switch(@g("didpassbase"), "0",@switch(@g(@print("ncc_",@add(40,@g("whoclr_inadv")))), "0",@print(@tellroom(@location("%#"),"",@print("GameBoard says, \"", @g("whocna_inadv"), " didn't pass a Base World, but has no crewman to maroon anyway.\"")), @call(2117,"end_adv")), "1",@print(@fieldloop(2117,"ccloc_",@switch("%v", @add(40,@g("whoclr_inadv")), @s("crew_chosen",@substr("%f",6)))), @call(2117,"do_adv_3cz")), @print(@s("gstate",11), @tellroom(@location("%#"),"",@print("GameBoard says (to ", @g("whorna_inadv"), "), \"", @g("whocna_inadv")))), ", you didn't pass a Base World. Choose which of your crewman to maroon, eg: 'CREW SULU'.\"")))), @print(@tellroom(@location("%#"),"",@print("GameBoard says, \"", @g("whocna_inadv"), " passed the ", @ucfirst(@g(@print("clrnam",@g("basepassed")))), " Base World and so avoided the danger.\"")), @call(2117,"end_adv")));
=======

// TODO: autoroll and move ship. Set basepassed to 1..4 or 0 if none.
@field bot = do_adv_3_roll : TODO

// maroon the chosen crewman, end adv
@field bot = do_adv_3cz : TODO
  @call(2117,"end_adv");

// [AY] All Our Yesterdays - offer choice of 'space #' to move adv to.
@field bot = do_adv_4 :
  @s("gstate",12);
  @tellroom(@location("%#"),"",@print(
    "GameBoard says (to ", @g("whorna_inadv"),
    "), \"", @g("whocna_inadv"),
    "choose any other space to move this adventure to, eg: 'SPACE 10'."
  ));
------
**TEST**
@field bot = do_adv_4 : @s("gstate",12); @tellroom(@location("%#"),"",@print("GameBoard says (to ", @g("whorna_inadv"), "), \"", @g("whocna_inadv"), "choose any other space to move this adventure to, eg: 'SPACE 10'."));
======

@field bot = do_adv_4s :
  @switch("%#",@g("whodbr_inadv"),@print(
    @call(2117,"echo_space"),
    @s("space_this",@g(@print("ship",@g("whoclr_inadv"),"_loc"))),
    @switch("1",
      @eq(@g("space_chosen"),@g("space_this")), @print(
        "GameBoard says (to %n), \"No, any *other* space. Choose again.\""
      ),
      @print(
        // if card on space_chosen, discard it.
        @switch(@g(@print("nac_",@g("space_chosen"))),"1",@print(
          @s("arg1",@g("space_chosen")), @s("arg2",99),
          @call(2117,"botdealac1"),
          @tellroom(@location("%#"),"",@print(
            "GameBoard discards the '", @g(@print("acnam_",@g("ac_moved"))),
            " [", @g(@print("accod_",@g("ac_moved"))),
            "]' adventure from space #", @g("space_chosen"), "."
          ))
        )),
        // move [AY] adventure to space_chosen.
        @s("acloc_4",@g("space_chosen")),
        @s(@print("nac_",@g("space_chosen")),1),
        @s(@print("nac_",@g("space_this")),0),
        @tellroom(@location("%#"),"",@print(
          "GameBoard moves the 'All Our Yesterdays [AY]' adventure from space #",
          @g("space_this"), " to space #", @g("space_chosen"), "."
        )),
        // deal new adventure to space_this.
        @s("arg1",0), @s("arg2",@g("space_this")),
        @call(2117,"botdealac1"),
        @tellroom(@location("%#"),"",@print(
          "GameBoard deals the '", @g(@print("acnam_",@g("ac_moved"))),
          " [", @g(@print("accod_",@g("ac_moved"))),
          "]' adventure into space #", @g("space_this"), "."
        )),
        @call(2117,"end_adv")
      )
    )
  ), @call(2117,"you_not_inadv"));
------
**TEST**
@field bot = do_adv_4s : @switch("%#",@g("whodbr_inadv"),@print(@call(2117,"echo_space"), @s("space_this",@g(@print("ship",@g("whoclr_inadv"),"_loc"))), @switch("1", @eq(@g("space_chosen"),@g("space_this")), @print("GameBoard says (to %n), \"No, any *other* space. Choose again.\""), @print(@switch(@g(@print("nac_",@g("space_chosen"))),"1",@print(@s("arg1",@g("space_chosen")), @s("arg2",99), @call(2117,"botdealac1"), @tellroom(@location("%#"),"",@print("GameBoard discards the '", @g(@print("acnam_",@g("ac_moved"))), " [", @g(@print("accod_",@g("ac_moved"))), "]' adventure from space #", @g("space_chosen"), ".")))), @s("acloc_4",@g("space_chosen")), @s(@print("nac_",@g("space_chosen")),1), @s(@print("nac_",@g("space_this")),0), @tellroom(@location("%#"),"",@print("GameBoard moves the 'All Our Yesterdays [AY]' adventure from space #", @g("space_this"), " to space #", @g("space_chosen"), ".")), @s("arg1",0), @s("arg2",@g("space_this")), @call(2117,"botdealac1"), @tellroom(@location("%#"),"",@print("GameBoard deals the '", @g(@print("acnam_",@g("ac_moved"))), " [", @g(@print("accod_",@g("ac_moved"))), "]' adventure into space #", @g("space_this"), ".")), @call(2117,"end_adv")))), @call(2117,"you_not_inadv"));
======

**TO TEST**
// [BT] Balance of Terror - offer choice of 'warp' or 'impulse'
@field bot = do_adv_5 : @s("gstate",13); @call(2117,"setmsg_wrpimp");

// to warp, COMMAND: Kirk(1),Scott(2),Spock(3),Starfleet(0)
@field bot = do_adv_5w :
  @call(2117,"echo_warp");
  @s("why_warp_ok","officer with Command");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_1"),@g("rack_inadv")),
      @eq(@g("ccloc_2"),@g("rack_inadv")),
      @eq(@g("ccloc_3"),@g("rack_inadv")),
      @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_warp_ok"), @call(2117,"do_adv_5w1")
    ),
    @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_5i"))
  );
--------
**TEST**
@field bot = do_adv_5w : @call(2117,"echo_warp"); @s("why_warp_ok","officer with Command"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_1"),@g("rack_inadv")), @eq(@g("ccloc_2"),@g("rack_inadv")), @eq(@g("ccloc_3"),@g("rack_inadv")), @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_5w1")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_5i")));
========

// Warp confirmed. Now decide who you're going to fight.
// 1) if there's already been a battle this turn, or it's not your turn,
// then there's no battle at all, and this adventure ends.
// 2) else if there's only 2 players, calculate who the opponent is.
// 3) else ask who the opponent will be.
@field bot = do_adv_5w1 :
  @switch("1",
    @not(@eq(@g("whoclr_inadv"),@g("whoclr_turn"))), @print(
      @tellroom(@location("%#"),"",@print(
        "GameBoard says, \"", @g("whocna_inadv"),
        "can't start a battle when it's not %p turn, so no battle occurs.\""
      )),
      @call(2117,"end_adv")
    ),
    @eq(@g("isbatdone"),1), @print(
      @tellroom(@location("%#"),"",
        "GameBoard says, \"There's already been a battle this turn, so no battle occurs.\""
      ),
      @call(2117,"end_adv")
    ),
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @tellroom(@location("%#"),"",@print( "GameBoard says, \"",
        @g("whocna_inadv"), " challenges ",
        @g("whocna_chosen"), " to battle.")),
      @call(2117,"do_adv_5wb")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",14), @s("q1","who will you battle?"), @call(2117,"q_who")
    )
  );
---------
**TEST**
@field bot = do_adv_5w1 : @switch("1", @not(@eq(@g("whoclr_inadv"),@g("whoclr_turn"))), @print(@tellroom(@location("%#"),"",@print("GameBoard says, \"", @g("whocna_inadv"), "can't start a battle when it's not %p turn, so no battle occurs.\"")), @call(2117,"end_adv")), @eq(@g("isbatdone"),1), @print(@tellroom(@location("%#"),"", @print("GameBoard says, \"There's already been a battle this turn, so no battle occurs.\"")), @call(2117,"end_adv")), @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x", @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @tellroom(@location("%#"),"",@print( "GameBoard says, \"", @g("whocna_inadv"), " challenges ", @g("whocna_chosen"), " to battle.")), @call(2117,"do_adv_5wb")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",14), @s("q1","who will you battle?"), @call(2117,"q_who")));
=========

**TEST**
// has chosen which player to battle
@field bot = do_adv_5wp : @call(2117,"echo_player"); @call(2117,"do_adv_5wb");

// TODO: battle whoclr_chosen, you on '4', he on '6'. He moves first.
@field bot = do_adv_5wb : TODO
  @s("whoclr_bat1",@g("whoclr_inadv"));
  @s("whoclr_bat2",@g("whoclr_chosen"));
  @s(@print("ship",@g("whoclr_bat1"),"_loc"),21);
  @s(@print("ship",@g("whoclr_bat2"),"_loc"),21);
  @s(@print("ship",@g("whoclr_bat1"),"_pos"),4);
  @s(@print("ship",@g("whoclr_bat2"),"_loc"),6);
  @s("whoclr_bturn",@g("whoclr_bat2"));
  @call(2117,"do_battle");

// draw a battle card, then start a battle
// 1) if there's already been a battle this turn, or it's not your turn,
// then there's no battle at all, and this adventure ends.
// 2) else if there's only 2 players, calculate who the opponent is.
// 3) else ask who the opponent will be (gstate 15).
@field bot = do_adv_5i :
  @call(2117,"echo_impulse");
  @tellroom(@location("%#"),"","[TODO (5i): draw 1 battle card]");
  @switch("1",
    @not(@eq(@g("whoclr_inadv"),@g("whoclr_turn"))), @print(
      @tellroom(@location("%#"),"",@print(
        "GameBoard says, \"", @g("whocna_inadv"),
        "can't start a battle when it's not %p turn, so no battle occurs.\""
      )),
      @call(2117,"end_adv")
    ),
    @eq(@g("isbatdone"),1), @print(
      @tellroom(@location("%#"),"", @print(
        "GameBoard says, \"There's already been a battle this turn, so no battle occurs.\""
      )),
      @call(2117,"end_adv")
    ),
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @tellroom(@location("%#"),"",@print( "GameBoard says, \"",
        @g("whocna_inadv"), " challenges ",
        @g("whocna_chosen"), " to battle.")),
      @call(2117,"do_adv_5ib")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",15), @s("q1","who will you battle?"), @call(2117,"q_who")
    )
  );
--------
**TEST**
@field bot = do_adv_5i : @call(2117,"echo_impulse"); @tellroom(@location("%#"),"","[TODO (5i): draw 1 battle card]"); @switch("1", @not(@eq(@g("whoclr_inadv"),@g("whoclr_turn"))), @print(@tellroom(@location("%#"),"",@print("GameBoard says, \"", @g("whocna_inadv"), "can't start a battle when it's not %p turn, so no battle occurs.\"")), @call(2117,"end_adv")), @eq(@g("isbatdone"),1), @print(@tellroom(@location("%#"),"", @print("GameBoard says, \"There's already been a battle this turn, so no battle occurs.\"")), @call(2117,"end_adv")), @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x", @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @tellroom(@location("%#"),"",@print( "GameBoard says, \"", @g("whocna_inadv"), " challenges ", @g("whocna_chosen"), " to battle.")), @call(2117,"do_adv_5ib")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",15), @s("q1","who will you battle?"), @call(2117,"q_who")));
========

@field bot = do_adv_5ip : TODO
  @call(2117,"echo_player");
@field bot = do_adv_5ib : TODO

**TEST**
// [CK] The Conscience of the King - choice of 'danger' or 'protect'
@field bot = do_adv_6 : @s("gstate",16); @call(2117,"setmsg_danpro");

// [CK-Dan]
// 1) if you don't have any crewmen to maroon, end adv.
// 2) else calc LeastCrew player.
//    If tie, ask which player LeastCrew will be;
//    else continue to ask LeastCrew which space it'll be marooned to.
@field bot = do_adv_6d :
  @call(2117,"echo_danger"); @call(2117,"calc_whoclr_least");
  @switch("1",
    @eq(@g(@print("ncc_",@add(40,@g("whoclr_inadv")))),0), @print(
      @tellroom(@location("%#"),"",@print(
        "GameBoard says, \"Since ", @g("whocna_inadv"),
        " has no crew to maroon...\""
      )),
      @call(2117,"end_adv")
    ),
    @eq(@g("whoclr_least"),0), @print(
      @s("gstate",18),
      @s("q1","there's a tie for who has the 'Least Crew'. You must choose one. Will it be:"),
      @call(2117,"q_who")
    ),
    @print(
      @call(2117,"calc_whodbr_least"), @s("gstate",19),
      @tellroom(@location("%#"),"",@print(
        "GameBoard asks ", @g("whorna_least"), ", \"",
        @g("whocna_least"), 
        "Choose the space where ", @g("whocna_inadv"),
        "must maroon one of crewmember, eg: 'SPACE 3'.\""
      ))
    )
  );
-----
**TEST**
@field bot = do_adv_6d : @call(2117,"echo_danger"); @call(2117,"calc_whoclr_least"); @switch("1", @eq(@g(@print("ncc_",@add(40,@g("whoclr_inadv")))),0), @print(@tellroom(@location("%#"),"",@print("GameBoard says, \"Since ", @g("whocna_inadv"), " has no crew to maroon...\"")), @call(2117,"end_adv")), @eq(@g("whoclr_least"),0), @print(@s("gstate",18), @s("q1","there's a tie for who has the 'Least Crew'. You must choose one. Will it be:"), @call(2117,"q_who")), @print(@call(2117,"calc_whodbr_least"), @s("gstate",19), @tellroom(@location("%#"),"",@print("GameBoard asks ", @g("whorna_least"), ", \"", @g("whocna_least"), "Choose the space where ", @g("whocna_inadv"), "must maroon one of crewmember, eg: 'SPACE 3'.\""))));
=====

**TEST NODEL**
@field bot = do_adv_6dp : @call(2117,"echo_player"); @call(2117,"do_adv_6dpz");

@field bot = do_adv_6dpz : TODO

// space selected, now figure out which crewman
@field bot = do_adv_6ds :
  @call(2117,"calc_whodbr_least");
  @switch("%#",@g("whodbr_least"),@print(
    @call(2117,"echo_space"),
    @switch(@g(@print("ncc_",@add(40,@g("whoclr_inadv")))),
      "1",@print(
        @fieldloop(2117,"ccloc_",@switch("%v", @add(40,@g("whoclr_inadv")),
          @s("crew_chosen",@substr("%f",6))
        )),
        @call(2117,"do_adv_6dcz")
      ),
      @print(
        @s("gstate",17),
        @tellroom(@location("%#"),"",@print(
          "GameBoard says (to ", @g("whorna_inadv"),
          "), \"", @g("whocna_inadv"),
          ", choose which of your crewman to maroon, eg: 'CREW SMITH'.\""
        ))
      )
    )
  ), @call(2117,"you_not_least"));
------
**ADD**
@field bot = do_adv_6ds : @call(2117,"calc_whodbr_least"); @switch("%#",@g("whodbr_least"),@print(@call(2117,"echo_space"), @switch(@g(@print("ncc_",@add(40,@g("whoclr_inadv")))), "1",@print(@fieldloop(2117,"ccloc_",@switch("%v", @add(40,@g("whoclr_inadv")), @s("crew_chosen",@substr("%f",6)))), @call(2117,"do_adv_6dcz")), @print(@s("gstate",17), @tellroom(@location("%#"),"",@print("GameBoard says (to ", @g("whorna_inadv"), "), \"", @g("whocna_inadv"), ", choose which of your crewman to maroon, eg: 'CREW SMITH'.\""))))), @call(2117,"you_not_least"));
======

@field bot = do_adv_6dc : TODO
@field bot = do_adv_6dcz : TODO

// to protect, must have KIRK (1), RAND (6), or RILEY (13)
@field bot = do_adv_6p :
  @call(2117,"echo_protect");
  @s("why_pro_ok","of Kirk, Rand, or Riley");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_1"),@g("rack_inadv")),
      @eq(@g("ccloc_6"),@g("rack_inadv")),
      @eq(@g("ccloc_13"),@g("rack_inadv"))), "1", @print(
    @call("echo_pro_ok"), @call(2117,"end_adv")
    ),
    @print(@call("echo_pro_nok"), @call(2117,"do_adv_6d"))
  );
---------
**TEST**
@field bot = do_adv_6p : @call(2117,"echo_protect"); @s("why_pro_ok","of Kirk, Rand, or Riley"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_1"),@g("rack_inadv")), @eq(@g("ccloc_6"),@g("rack_inadv")), @eq(@g("ccloc_13"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_pro_ok"), @call(2117,"end_adv")), @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_6d")));
=========

**TEST**
// [CMl] Court Martial - choice of 'danger' or 'protect'
@field bot = do_adv_7 : @s("gstate",20); @call(2117,"setmsg_danpro");

@field bot = do_adv_7d : TODO
  @call(2117,"echo_danger");

// to protect, must have SPOCK (3), SCOTT (2), or UHURA (4)
@field bot = do_adv_7p :
  @call(2117,"echo_protect");
  @s("why_pro_ok","of Spock, Scott, or Uhura");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_3"),@g("rack_inadv")),
      @eq(@g("ccloc_2"),@g("rack_inadv")),
      @eq(@g("ccloc_4"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_pro_ok"), @call(2117,"end_adv")
    ),
    @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_7d"))
  );
-----------
**TEST**
@field bot = do_adv_7p : @call(2117,"echo_protect"); @s("why_pro_ok","of Spock, Scott, or Uhura"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_3"),@g("rack_inadv")), @eq(@g("ccloc_2"),@g("rack_inadv")), @eq(@g("ccloc_4"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_pro_ok"), @call(2117,"end_adv")), @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_7d")));
===========

**TEST**
// [CMn] The Corbomite Maneuver - choice of 'danger' or 'protect'
@field bot = do_adv_8 : @s("gstate",21); @call(2117,"setmsg_danpro");

// 1) if there's already been a battle this turn, or it's not your turn,
// then there's no battle at all, and this adventure ends.
// 2) else if there's only 2 players, calculate who the opponent is.
// 3) else ask who the opponent will be.
@field bot = do_adv_8d :
  @call(2117,"echo_danger");
  @switch("1",
    @not(@eq(@g("whoclr_inadv"),@g("whoclr_turn"))), @print(
      @tellroom(@location("%#"),"",@print(
        "GameBoard says, \"", @g("whocna_inadv"),
        "can't start a battle when it's not %p turn, so no battle occurs.\""
      )),
      @call(2117,"end_adv")
    ),
    @eq(@g("isbatdone"),1), @print(
      @tellroom(@location("%#"),"",
        "GameBoard says, \"There's already been a battle this turn, so no battle occurs.\""
      ),
      @call(2117,"end_adv")
    ),
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @tellroom(@location("%#"),"",@print( "GameBoard says, \"",
        @g("whocna_inadv"), " challenges ",
        @g("whocna_chosen"), " to battle.")),
      @call(2117,"do_adv_8db")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",22), @s("q1","who will you battle?"), @call(2117,"q_who")
    )
  );
---------
**TEST**
@field bot = do_adv_8d : @call(2117,"echo_danger"); @switch("1",@not(@eq(@g("whoclr_inadv"),@g("whoclr_turn"))), @print(@tellroom(@location("%#"),"",@print("GameBoard says, \"", @g("whocna_inadv"), "can't start a battle when it's not %p turn, so no battle occurs.\"")), @call(2117,"end_adv")), @eq(@g("isbatdone"),1), @print(@tellroom(@location("%#"),"", "GameBoard says, \"There's already been a battle this turn, so no battle occurs.\""), @call(2117,"end_adv")), @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x", @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @tellroom(@location("%#"),"",@print( "GameBoard says, \"", @g("whocna_inadv"), " challenges ", @g("whocna_chosen"), " to battle.")), @call(2117,"do_adv_8db")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",22), @s("q1","who will you battle?"), @call(2117,"q_who")));
=========

**TEST NODEL**
@field bot = do_adv_8dp : @call(2117,"echo_player"); @call(2117,"do_adv_8db");

// TODO: battle whoclr_chosen, you on '6', he on '4'. You move first.
@field bot = do_adv_8db : TODO
  @s("whoclr_bat1",@g("whoclr_inadv"));
  @s("whoclr_bat2",@g("whoclr_chosen"));
  @s(@print("ship",@g("whoclr_bat1"),"_loc"),21);
  @s(@print("ship",@g("whoclr_bat2"),"_loc"),21);
  @s(@print("ship",@g("whoclr_bat1"),"_pos"),6);
  @s(@print("ship",@g("whoclr_bat2"),"_loc"),4);
  @s("whoclr_bturn",@g("whoclr_bat1"));
  @call(2117,"do_battle");

// to protect, must have KYLE (5), PALAMAS (21), or BARROWS (20)
@field bot = do_adv_8p :
  @call(2117,"echo_protect");
  @s("why_pro_ok","of Kyle, Palamas, or Barrows");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_5"),@g("rack_inadv")),
      @eq(@g("ccloc_21"),@g("rack_inadv")),
      @eq(@g("ccloc_20"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_pro_ok"), @call(2117,"end_adv")
    ),
    @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_8d"))
  );
----------
**TEST**
@field bot = do_adv_8p : @call(2117,"echo_protect"); @s("why_pro_ok","of Kyle, Palamas, or Barrows"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_5"),@g("rack_inadv")), @eq(@g("ccloc_21"),@g("rack_inadv")), @eq(@g("ccloc_20"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_pro_ok"), @call(2117,"end_adv")), @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_8d")));
==========

// [Cms] The Cloud-minders - no choice
@field bot = do_adv_9 : TODO

// [Cp] Catspaw - no choice
@field bot = do_adv_10 : TODO

**TO TEST**
// [CX] Charlie X - choose 'warp' or 'impulse'
@field bot = do_adv_11 : @s("gstate",23); @call(2117,"setmsg_wrpimp");

// to warp: Rand(6), Palamas(21), Romaine(22)
@field bot = do_adv_11w :
  @call(2117,"echo_warp");
  @s("why_warp_ok","of Rand, Palamas, or Romaine");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_6"),@g("rack_inadv")),
      @eq(@g("ccloc_21"),@g("rack_inadv")),
      @eq(@g("ccloc_22"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_warp_ok"), @call(2117,"do_adv_11wz")
    ),
    @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_11i"))
  );
-------
**ADD**
@field bot = do_adv_11w : @call(2117,"echo_warp"); @s("why_warp_ok","of Rand, Palamas, or Romaine"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_6"),@g("rack_inadv")), @eq(@g("ccloc_21"),@g("rack_inadv")), @eq(@g("ccloc_22"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_11wz")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_11i")));
=======

**ADD NODEL**
@field bot = do_adv_11wz : @s("gstate",24); @call(2117,"q_ct");

// for each player other than inadv, move all the cards of the chosen
// cardtype from player's hand to inadv's hand, if any.
@field bot = do_adv_11wt :
  @switch("%#",@g("whodbr_inadv"),@print(
    @call(2117,"echo_ct"),
    @s("arg2",@add(40,@g("whoclr_inadv"))),
    @fieldloop(2117,"bcloc_",@switch("%v",{41,42,43,44},
      @switch("1",@and( @not(@eq("%v",@g("arg2"))),
      @eq(@g(@print("bcct_",@substr("%f",6))),@g("ct_chosen")) ),@print(
        @s("arg1","%v"),
        @s("arg3",@substr("%f",6)),
        @call(2117,"bcgive1")
      ))
    )),
    @call(2117,"end_adv")
  ), @call(2117,"you_not_inadv"));
-----
**ADD**
@field bot = do_adv_11wt : @switch("%#",@g("whodbr_inadv"),@print(@call(2117,"echo_ct"), @s("arg2",@add(40,@g("whoclr_inadv"))), @fieldloop(2117,"bcloc_",@switch("%v",{41,42,43,44}, @switch("1",@and( @not(@eq("%v",@g("arg2"))), @eq(@g(@print("bcct_",@substr("%f",6))),@g("ct_chosen")) ),@print(@s("arg1","%v"), @s("arg3",@substr("%f",6)), @call(2117,"bcgive1"))))), @call(2117,"end_adv")), @call(2117,"you_not_inadv"));
=====  

// name the player to get a cardtype from
// 1) If 2-player game, calc who whoclr_chosen is,
// 2) Else ask.
@field bot = do_adv_11i :
  @call(2117,"echo_impulse");
  @switch("1",
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @call(2117,"do_adv_11ip")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",25), @s("q1","who will you ask for a card?"),
      @call(2117,"q_who")
    )
  );
-----
**TEST**
@field bot = do_adv_11i : @call(2117,"echo_impulse"); @switch("1", @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x", @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @call(2117,"do_adv_11ip")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",25), @s("q1","who will you ask for a card?"), @call(2117,"q_who")));
=====

**ADD NODEL**
@field bot = do_adv_11ip : @call(2117,"echo_player"); @call(2117,"do_adv_11ipz");

**ADD NODEL**
// know the player, now name a cardtype
@field bot = do_adv_11ipz : @s("gstate",26); @call(2117,"q_ct");

// We now know the player and cardtype.
// 1) if chosen player hasn't got such a card, say so and end adv.
// 2) else, if he has a generic card of that type, autochoose it.
// 3) else, ask chosen to now name which of his cards to give
@field bot = do_adv_11it : TODO

// know the player and specific card, so move it over
// (unless, of course, he's named a card not of the given type,
// or a card he doesn't actually have.)
@field bot = do_adv_11iz : TODO

**TO TEST**
// [DD] The Devil in the Dark - choose 'warp' or 'impulse'
@field bot = do_adv_12 : @s("gstate",27); @call(2117,"setmsg_wrpimp");

// to warp, Spock(3), Jones(16), Landon(18)
@field bot = do_adv_12w :
  @call(2117,"echo_warp");
  @s("why_warp_ok","of Spock, Jones, or Landon");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_3"),@g("rack_inadv")),
      @eq(@g("ccloc_16"),@g("rack_inadv")),
      @eq(@g("ccloc_18"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_warp_ok"), @call(2117,"do_adv_12w1")
    ),
    @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_12i")
    )
  );
---------
**TEST**
@field bot = do_adv_12w : @call(2117,"echo_warp"); @s("why_warp_ok","of Spock, Jones, or Landon"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_3"),@g("rack_inadv")), @eq(@g("ccloc_16"),@g("rack_inadv")), @eq(@g("ccloc_18"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_12w1")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_12i")));
=========

// [DD] choose another player who will have to discard 3 cards at random
// 1) if there's only 2 players, calculate who the other one is.
// 2) else ask to choose a player.
@field bot = do_adv_12w1 :
  @switch("1",
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @call(2117,"do_adv_12wz")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",28), @s("q1","choose who discards three cards at random."),
      @call(2117,"q_who")
    )
  );
---------
**TEST**
@field bot = do_adv_12w1 : @switch("1", @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x", @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @call(2117,"do_adv_12wz")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",28), @s("q1","choose who discards three cards at random."), @call(2117,"q_who")));
=========

@field bot = do_adv_12wp : TODO
  @call(2117,"echo_player");

// [DD-WRP] whoclr_chosen discards 3 cards at random
@field bot = do_adv_12wz : [TODO: 12wz]

// [DD-IMP] choose another player who will have to discard a card of his choice
// 1) if there's only 2 players, calculate who the other one is.
// 2) else ask to choose a player.
@field bot = do_adv_12i :
  @call(2117,"echo_impulse");
  @switch("1",
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @call(2117,"do_adv_12iz")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",29), @s("q1","choose who will discard a card."),
      @call(2117,"q_who")
    )
  );
---------
**TEST**
@field bot = do_adv_12i : @call(2117,"echo_impulse"); @switch("1", @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x", @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @call(2117,"do_adv_12iz")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",29), @s("q1","choose who will discard a card."), @call(2117,"q_who")));
=========

@field bot = do_adv_12ip : TODO
  @call(2117,"echo_player");

// [DD-IMP] whoclr_chosen chooses a card to discard
@field bot = do_adv_12ic : TODO

// [DD-IMP] whoclr_chosen discards the bcard_chosen
@field bot = do_adv_12iz : TODO

**TEST**
// [Dma] The Doomsday Machine - choose 'danger' or 'protect'
@field bot = do_adv_13 : @s("gstate",31); @call(2117,"setmsg_danpro");

@field bot = do_adv_13d : TODO
  @call(2117,"echo_danger");

// to protect, NAVIGATION: CHEKOV (12), RILEY (13), SULU (14), STARFLEET (0)
// TODO: CADET-Nav (15) plus KIRK (1) plus PHASER 1 KIRK complication
@field bot = do_adv_13p :
  @call(2117,"echo_protect");
  @s("why_pro_ok","officer with Navigation");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_12"),@g("rack_inadv")),
      @eq(@g("ccloc_13"),@g("rack_inadv")),
      @eq(@g("ccloc_14"),@g("rack_inadv")),
      @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_pro_ok"), @call(2117,"end_adv")
    ),
    @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_13d"))
  );
----------
**TEST**
@field bot = do_adv_13p : @call(2117,"echo_protect"); @s("why_pro_ok","officer with Navigation"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_12"),@g("rack_inadv")), @eq(@g("ccloc_13"),@g("rack_inadv")), @eq(@g("ccloc_14"),@g("rack_inadv")), @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_pro_ok"), @call(2117,"end_adv")), @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_13d")));
==========

**TEST**
// [DMd] Dagger of the Mind - choose 'danger' or 'protect'
@field bot = do_adv_14 : @s("gstate",32); @call(2117,"setmsg_danpro");

// tmpc = countYourUnlockedCrew()
@field bot = do_adv_14d :
  @call(2117,"echo_danger");
  @s("tmpc",0);
  @fieldloop(2117,"ccloc_",@let("k"=>@substr("%f",6),@switch("1",
    @and( @eq("%v",@add(40,@g("whoclr_inadv"))),
          @eq(0,@g("cclkd_%k")) ), @print(
      @s("tmpc",@add(1,@g("tmpc"))),
      @s("crew_chosen","%k")
    )
  )));
  @switch(@g("tmpc"),
    "0", @print(
      @tellroom(@location("%#"),"",@print(
        "GameBoard says, \"", @g("whocna_inadv"),
        " has no unlocked crewmen to reveal.\""
      )),
      @call(2117,"end_adv")
    ),
    "1", @call(2117,"do_adv_14dcz"),
    @print(
      @s("gstate",33),
      @tellroom(@location("%#"),"",@print(
        "GameBoard says (to ", @g("whorna_inadv"),
        "), \"", @g("whocna_inadv"),
        ", choose which of your crewman to reveal, eg: 'CREW SMITH'.\""
      ))
    )
  );
-------
**ADD**
=======

@field bot = do_adv_14dc : TODO
@field bot = do_adv_14dcz : TODO

// to protect, must have KIRK (1), MANNING (17), or NOEL (10)
@field bot = do_adv_14p :
  @call(2117,"echo_protect");
  @s("why_pro_ok","of Kirk, Manning, or Noel");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_1"),@g("rack_inadv")),
      @eq(@g("ccloc_17"),@g("rack_inadv")),
      @eq(@g("ccloc_10"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_pro_ok"), @call(2117,"end_adv")
    ),
    @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_14d"))
  );
---------
**TEST**
@field bot = do_adv_14p : @call(2117,"echo_protect"); @s("why_pro_ok","of Kirk, Manning, or Noel"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_1"),@g("rack_inadv")), @eq(@g("ccloc_17"),@g("rack_inadv")), @eq(@g("ccloc_10"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_pro_ok"), @call(2117,"end_adv")), @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_14d")));
=========

**TEST**
// [DY] The Deadly Years - choose 'danger' or 'protect'
@field bot = do_adv_15 : @s("gstate",34); @call(2117,"setmsg_danpro");

@field bot = do_adv_15d : TODO
  @call(2117,"echo_danger");

**TEST**
// to protect, must have ROMAINE (22), NOEL (10), or CHEKOV (12)
@field bot = do_adv_15p :
  @call(2117,"echo_protect");
  @s("why_pro_ok","of Romaine, Noel, or Chekov");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_22"),@g("rack_inadv")),
      @eq(@g("ccloc_10"),@g("rack_inadv")),
      @eq(@g("ccloc_12"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_pro_ok"), @call(2117,"end_adv")
    ),
    @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_15d"))
  );
-----------
**TEST**
@field bot = do_adv_15p : @call(2117,"echo_protect"); @s("why_pro_ok","of Romaine, Noel, or Chekov"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_22"),@g("rack_inadv")), @eq(@g("ccloc_10"),@g("rack_inadv")), @eq(@g("ccloc_12"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_pro_ok"), @call(2117,"end_adv")), @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_15d")));
===========

**TO TEST**
// [EI] The Enterprise Incident - choose 'warp' or 'impulse'
@field bot = do_adv_16 : @s("gstate",35); @call(2117,"setmsg_wrpimp");

// to warp, NAV: CHEKOV (12), RILEY (13), SULU (14), STARFLEET (0)
// TODO: CADET-Nav (15) plus KIRK (1) plus PHASER 1 KIRK complication
@field bot = do_adv_16w :
  @call(2117,"echo_warp");
  @s("why_warp_ok","officer with Navigation");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_12"),@g("rack_inadv")),
      @eq(@g("ccloc_13"),@g("rack_inadv")),
      @eq(@g("ccloc_14"),@g("rack_inadv")),
      @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_warp_ok"), @call(2117,"do_adv_16w1")
    ),
    @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_16i"))
  );
---------
**TEST**
@field bot = do_adv_16w : @call(2117,"echo_warp"); @s("why_warp_ok","officer with Navigation"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_12"),@g("rack_inadv")), @eq(@g("ccloc_13"),@g("rack_inadv")), @eq(@g("ccloc_14"),@g("rack_inadv")), @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_16w1")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_16i")));
=========

// ask for player or deck to get 1st card from
@field bot = do_adv_16w1 :
  @strloop(@g("whoclrs"),"x",@s("isclropt%x","1"));
  @s(@print("isclropt",@g("whoclr_inadv")),"0");
  @s("gstate",36); @s("q1","first"); @call(2117,"q_who_or_deck");
-----
**TEST**
@field bot = do_adv_16w1 : @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")); @s(@print("isclropt",@g("whoclr_inadv")),"0"); @s("gstate",36); @s("q1","first"); @call(2117,"q_who_or_deck");
=====

// 1) get 1st card from deck
// 2) then ask for player or deck to get 2nd card from (do_adv_16w2)
@field bot = do_adv_16wk1 : TODO
  @call(2117,"echo_deck");
  [TODO: draw card from deck];
  @call(2117,"do_adv_16w2");

// 1) get 1st card from whoclr_chosen
// 2) then ask for player or deck to get 2nd card from (do_adv_16w2)
@field bot = do_adv_16wp1 : TODO
  @call(2117,"echo_player");
  [TODO: draw card from whoclr_chosen];
  @call(2117,"do_adv_16w2");

// ask for player or deck to get 2nd card from
@field bot = do_adv_16w2 :
  @strloop(@g("whoclrs"),"x",@s("isclropt%x","1"));
  @s(@print("isclropt",@g("whoclr_inadv")),"0");
  @s("gstate",37); @s("q1","second"); @call(2117,"q_who_or_deck");
-----
**TEST**
@field bot = do_adv_16w2 : @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")); @s(@print("isclropt",@g("whoclr_inadv")),"0"); @s("gstate",37); @s("q1","second"); @call(2117,"q_who_or_deck");
=====

// get 2st card from deck, end adv.
@field bot = do_adv_16wk2 : TODO
  @call(2117,"echo_deck");

// get 2st card from whoclr_chosen, end adv
@field bot = do_adv_16wp2 : TODO
  @call(2117,"echo_player");

// Impulse. draw one card from deck
@field bot = do_adv_16i : TODO
  @call(2117,"echo_impulse");

// [EM] Errand of Mercy - choose a card to give
@field bot = do_adv_17 : TODO

// [ET] Elaan of Troyius - no choice
@field bot = do_adv_18 : TODO

// [EW] The Enemy Within - choose crewman with Command to give
@field bot = do_adv_19 :
  @s("ncmnd",0);
  @switch(@g("ccloc_1"),@add(40,@g("whoclr_inadv")),
    @s("ncmnd",@add(1,@g("ncmnd"))));
  @switch(@g("ccloc_2"),@add(40,@g("whoclr_inadv")),
    @s("ncmnd",@add(1,@g("ncmnd"))));
  @switch(@g("ccloc_3"),@add(40,@g("whoclr_inadv")),
    @s("ncmnd",@add(1,@g("ncmnd"))));
  @call(2117,"calc_whoclr_least");
  @switch("1",
    @lt(@g("ncmnd"),2), @print(
      @tellroom(@location("%#"),"",@print(
        "GameBoard says, \"But ", @g("whocna_inadv"),
        " doesn't have more than one crewman with Command, so...\""
      )),
      @call(2117,"end_adv")
    ),
    @eq(@g("whoclr_least"),0), @print(
      @s("gstate",40),
      @s("q1","there's a tie for who has the 'Least Crew'. You must choose one. Will it be:"),
      @s(2117,"q_who")
    ),
    @call(2117,"do_adv_19pz")
  );
----------
**TEST**
@field bot = do_adv_19 : @s("ncmnd",0); @switch(@g("ccloc_1"),@add(40,@g("whoclr_inadv")), @s("ncmnd",@add(1,@g("ncmnd")))); @switch(@g("ccloc_2"),@add(40,@g("whoclr_inadv")), @s("ncmnd",@add(1,@g("ncmnd")))); @switch(@g("ccloc_3"),@add(40,@g("whoclr_inadv")), @s("ncmnd",@add(1,@g("ncmnd")))); @call(2117,"calc_whoclr_least"); @switch("1", @lt(@g("ncmnd"),2), @print(@tellroom(@location("%#"),"",@print("GameBoard says, \"But ", @g("whocna_inadv"), " doesn't have more than one crewman with Command, so...\"")), @call(2117,"end_adv")), @eq(@g("whoclr_least"),0), @print(@s("gstate",40), @s("q1","there's a tie for who has the 'Least Crew'. You must choose one. Will it be:"), @s(2117,"q_who")), @call(2117,"do_adv_19pz"));
==========

**TEST NODEL**
@field bot = do_adv_19p : @call(2117,"echo_player"); @call(2117,"do_adv_19pz");

// ask to choose CREW KIRK, SPOCK, or SCOTT
@field bot = do_adv_19pz :
  @s("gstate",39);
  @tellroom(@location("%#"),"",@print(
    "GameBoard says (to ", @g("whorna_inadv"),
    "), \"", @g("whocna_inadv"),
    ", choose which of your crewman with Command to give to ",
    @g("whocna_least"), ", eg: 'CREW KIRK'.\""
  ));
------
**TEST**
@field bot = do_adv_19pz : @s("gstate",39); @tellroom(@location("%#"),"",@print("GameBoard says (to ", @g("whorna_inadv"), "), \"", @g("whocna_inadv"), ", choose which of your crewman with Command to give to ", @g("whocna_least"), ", eg: 'CREW KIRK'.\""));
======

@field bot = do_adv_19c : TODO

**TEST**
// [FC] Friday's Child - choose 'warp' or 'impulse'
@field bot = do_adv_20 : @s("gstate",41); @call(2117,"setmsg_wrpimp");

// to warp, COMMUN: Uhura(4),Kyle(5),Rand(6),Starfleet(0)
// TODO: Cadet-Commun(7) plus Kirk(1) plus Phaser 1 Kirk complication
@field bot = do_adv_20w :
  @call(2117,"echo_warp");
  @s("why_warp_ok","officer with Communication");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_4"),@g("rack_inadv")),
      @eq(@g("ccloc_5"),@g("rack_inadv")),
      @eq(@g("ccloc_6"),@g("rack_inadv")),
      @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_warp_ok"), @call(2117,"do_adv_20w1")
    ),
    @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_20i"))
  );
--------
**TEST**
@field bot = do_adv_20w : @call(2117,"echo_warp"); @s("why_warp_ok","officer with Communication"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_4"),@g("rack_inadv")), @eq(@g("ccloc_5"),@g("rack_inadv")), @eq(@g("ccloc_6"),@g("rack_inadv")), @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_20w1")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_20i")));
========

@field bot = do_adv_20w1 :
  @strloop(@g("whoclrs"),"x",@s("isclropt%x","1"));
  @s(@print("isclropt",@g("whoclr_inadv")),"0");
  @s("gstate",42); @s("q1","first"); @call(2117,"q_who_or_deck");
-----
**TEST**
@field bot = do_adv_20w1 : @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")); @s(@print("isclropt",@g("whoclr_inadv")),"0"); @s("gstate",42); @s("q1","first"); @call(2117,"q_who_or_deck");
=====

// 1) get 1st card from deck
// 2) then ask for player or deck to get 2nd card from (do_adv_20w2)
@field bot = do_adv_20wk1 : TODO
  @call(2117,"echo_deck");
  [TODO: draw card from deck];
  @call(2117,"do_adv_20w2");

// 1) get 1st card from whoclr_chosen
// 2) then ask for player or deck to get 2nd card from (do_adv_20w2)
@field bot = do_adv_20wp1 : TODO
  @call(2117,"echo_player");
  [TODO: draw card from whoclr_chosen];
  @call(2117,"do_adv_20w2");

// ask for player or deck to get 2nd card from
@field bot = do_adv_20w2 :
  @strloop(@g("whoclrs"),"x",@s("isclropt%x","1"));
  @s(@print("isclropt",@g("whoclr_inadv")),"0");
  @s("gstate",43); @s("q1","second"); @call(2117,"q_who_or_deck");
-----
**TEST**
@field bot = do_adv_20w2 : @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")); @s(@print("isclropt",@g("whoclr_inadv")),"0"); @s("gstate",43); @s("q1","second"); @call(2117,"q_who_or_deck");
=====

// get 2nd card from whoclr_chosen, end adv
@field bot = do_adv_20wp2 : TODO
  @call(2117,"echo_player");

// get 2nd card from deck, end adv
@field bot = do_adv_20wk2 : TODO
  @call(2117,"echo_deck");

// draw one card from deck, end adv
@field bot = do_adv_20i : TODO
  @call(2117,"echo_impulse");

**TEST**
// [FW] For the World is Hollow... - choose 'warp' or 'impulse'
@field bot = do_adv_21 : @s("gstate",44); @call(2117,"setmsg_wrpimp");

// to warp, Manning(17), McCoy(8), Chapel(9)
@field bot = do_adv_21w :
  @call(2117,"echo_warp");
  @s("why_echo_ok","of Manning, McCoy, or Chapel");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_17"),@g("rack_inadv")),
      @eq(@g("ccloc_8"),@g("rack_inadv")),
      @eq(@g("ccloc_9"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_warp_ok"), @call(2117,"do_adv_21w1")
    ),
    @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_21i"))
  );
--------
**TEST**
@field bot = do_adv_21w : @call(2117,"echo_warp"); @s("why_echo_ok","of Manning, McCoy, or Chapel"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_17"),@g("rack_inadv")), @eq(@g("ccloc_8"),@g("rack_inadv")), @eq(@g("ccloc_9"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_21w1")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_21i")));
========

@field bot = do_adv_21w1 : TODO
@field bot = do_adv_21i : TODO
  @call(2117,"echo_impulse");

**TEST**
// [GT] The Gamesters of Triskelion - choose 'warp' or 'impulse'
@field bot = do_adv_22 : @s("gstate",47); @call(2117,"setmsg_wrpimp");

// to warp, COMMUN: Uhura(4), Kyle(5), Rand(6), Starfleet(0)
// TODO: Cadet-Commun(7) plus Kirk(1) plus Phaser 1 Kirk complication
@field bot = do_adv_22w :
  @call(2117,"echo_warp");
  @s("why_warp_ok","officer with Communication");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_4"),@g("rack_inadv")),
      @eq(@g("ccloc_5"),@g("rack_inadv")),
      @eq(@g("ccloc_6"),@g("rack_inadv")),
      @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_warp_ok"), @call(2117,"do_adv_22w1")
    ),
    @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_22i"))
  );
--------
**TEST**
@field bot = do_adv_22w : @call(2117,"echo_warp"); @s("why_warp_ok","officer with Communication"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_4"),@g("rack_inadv")), @eq(@g("ccloc_5"),@g("rack_inadv")), @eq(@g("ccloc_6"),@g("rack_inadv")), @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_22w1")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_22i")));
========

// 1) if 2-player game, calc who it is
// 2) else ask choice of other player
@field bot = do_adv_22w1 :
  @switch("1",
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @call(2117,"do_adv_22wp")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",48), @s("q1","whose hand do you want to trade cards with?"),
      @call(2117,"q_who")
    )
  );
-----
**TEST**
@field bot = do_adv_22w1 : @switch("1", @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x", @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @call(2117,"do_adv_22wp")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",48), @s("q1","whose hand do you want to trade cards with?"), @call(2117,"q_who")));
=====

@field bot = do_adv_22wp : TODO
  @call(2117,"echo_player");

@field bot = do_adv_22i :
  @call(2117,"echo_impulse");
  @switch("1",
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @call(2117,"do_adv_22ip")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",50), @s("q1","who do you want to trade hands with?"),
      @call(2117,"q_who")
    )
  );
-----
**TEST**
@field bot = do_adv_22i : @call(2117,"echo_impulse"); @switch("1",@eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x",@g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @call(2117,"do_adv_22ip")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",50), @s("q1","who do you want to trade hands with?"), @call(2117,"q_who")));
=====

@field bot = do_adv_22ip : TODO
  @call(2117,"echo_player");

**TEST**
// [LZ] The Lights of Zetar - choose 'warp' or 'impulse'
@field bot = do_adv_23 : @s("gstate",51); @call(2117,"setmsg_wrpimp");

// to warp, Scott(2), Romaine(22), Barrows(20)
@field bot = do_adv_23w : TODO
  @call(2117,"echo_warp");
  @s("why_warp_ok","of Scott, Romaine, or Barrows");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_2"),@g("rack_inadv")),
      @eq(@g("ccloc_22"),@g("rack_inadv")),
      @eq(@g("ccloc_20"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_warp_ok"), @call(2117,"do_adv_23w1")
    ),
    @print(call(2117,"echo_warp_nok"), @call(2117,"do_adv_23i"))
  );
--------
**TEST**
@field bot = do_adv_23w : @call(2117,"echo_warp"); @s("why_warp_ok","of Scott, Romaine, or Barrows"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_2"),@g("rack_inadv")), @eq(@g("ccloc_22"),@g("rack_inadv")), @eq(@g("ccloc_20"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_23w1")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_23i")));
========

@field bot = do_adv_23w1 :
  @switch("1",
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @call(2117,"do_adv_23wpz")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",52), @s("q1","who do you want to make a crew call against?"),
      @call(2117,"q_who")
    )
  );
-----
**TEST**
@field bot = do_adv_23w1 : @switch("1", @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x", @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @call(2117,"do_adv_23wpz")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",52), @s("q1","who do you want to make a crew call against?"), @call(2117,"q_who")));
=====

**TEST NODEL**
@field bot = do_adv_23wp : @call(2117,"echo_player"); @call(2117,"do_adv_23wpz");

@field bot = do_adv_23wpz :
  @s("gstate",53);
  @tellroom(@location("%#"),"",@print(
    "GameBoard says (to ", @g("whorna_inadv"),
    "), \"", @g("whocna_inadv"),
    ", make your crew call against ", @g("whocna_chosen"),
    ". You may either call for a crewman by name, eg: 'CREW SMITH',
    or call for any crewman with an specific specialty
    (except Command), eg: 'SPEC SECURITY'.\""
  ));
------
**TEST**
@field bot = do_adv_23wpz : @s("gstate",53); @tellroom(@location("%#"),"",@print("GameBoard says (to ", @g("whorna_inadv"), "), \"", @g("whocna_inadv"), ", make your crew call against ", @g("whocna_chosen"), ". You may either call for a crewman by name, eg: 'CREW SMITH', or call for any crewman with an specific specialty (except Command), eg: 'SPEC SECURITY'.\""));
======

// inadv made a crew call by name
@field bot = do_adv_23wc1 : TODO

// inadv made a crew call by specialty
// 1) count all the locked and unlocked crew that whoclr_chosen
//    has in the requested specialty.
// 2) If whoclr_chosen has no unlocked crew in that specialty,
//    say so, and end the adventure. Otherwise, say that the call is successful.
// 3) Ask whoclr_chosen to choose a crewmember by name amongst
//    his unlocked crew in the chosen specialty. DON'T AUTOSELECT IT.
@field bot = do_adv_23wy :
  @call(2117,"echo_spec"); @s("nlocked",0); @s("nunlocked",0);
  @fieldloop(2117,"ccloc_",@let("k"=>@substr("%f",6),@switch("1",
    @and( @eq("%v",@add(40,@g("whoclr_chosen"))),
          @or( @eq(@g("spec_chosen"),@g("ccspe_%k")),@eq(0,@g("ccspe_%k")) )
        ),
    @switch(@g("cclkd_%k"),
      "0", @s("nunlocked",@add(1,@g("nunlocked"))),
      "1", @s("nlocked",@add(1,@g("nlocked")))
    )
  )));
  @switch("1",
    @and(@eq(@g("nunlocked"),0),@gt(@g("nlocked"),0)), @print(
      @tellroom(@location("%#"),"",@print(
        "GameBoard says, \"Sorry, ", @g("whocna_chosen"),
        " does have ", @g("nunlocked"),
        " crew with ", @g(@print("spenam_",@g("spec_chosen"))),
        ", but locked. ", @g("whocna_inadv"),
        ", in this case, you may make another crew call."
      ))
    ),
    @eq(@g("nunlocked"),0), @print(
      @tellroom(@location("%#"),"",@print(
       "GameBoard says, \"No. ", @g("whocna_chosen"),
       " has no crew with ", @g(@print("spenam_",@g("spec_chosen"))), ".\""
      )),
      @call(2117,"end_adv")
    ),
    @print(
      @s("gstate",118),
      @tellroom(@location("%#"),"",@print(
       "GameBoard says, \"Yes. ", @g("whocna_chosen"),
       " has at least one with ", @g(@print("spenam_",@g("spec_chosen"))),
       ". ", @g("whocna_chosen"),
       ", choose which one of your crewmen with ", @g(@print("spenam_",@g("spec_chosen"))),
       " you will give to ", @g("whocna_inadv"),
       ", eg: 'CREW SMITH'.\""
      ))
    )
  );
------
**ADD**
======

@field bot = do_adv_23i :
  @call(2117,"echo_impulse");
  @switch("1",
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @call(2117,"do_adv_23ip")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",55), @s("q1","who do you want to make a card call against?"),
      @call(2117,"q_who")
    )
  );
-----
**TEST**
@field bot = do_adv_23i : @call(2117,"echo_impulse"); @switch("1", @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x",@g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @call(2117,"do_adv_23ip")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",55), @s("q1","who do you want to make a card call against?"), @call(2117,"q_who")));
=====

@field bot = do_adv_23ip : TODO
  @call(2117,"echo_player");

**TEST**
// [Me] The Menagerie - choose 'danger' or 'protect'
@field bot = do_adv_24 : @s("gstate",58); @call(2117,"setmsg_danpro");

// Player with Least Crew takes one crewman from you at random
@field bot = do_adv_24d : 
  @call(2117,"echo_danger"); @call(2117,"calc_whoclr_least");
  @switch("1",
    @eq(0,@g(@print("ncc_",@add(40,@g("whoclr_inadv"))))), @print(
      @tellroom(@location("%#"),"",@print(
        "GameBoard says, \"But ", @g("whocna_inadv"),
        " has no crew to lose, so..."
      )),
      @call(2117,"end_adv")
    ),
    @eq(@g("whoclr_least"),0), @print(
      @s("gstate",59),
      @s("q1","there's a tie for who has the 'Least Crew'. You must choose one. Will it be:"),
      @call(2117,"q_who")
    ),
    @call(2117,"do_adv24dp1")
  );
-----
**TEST**
@field bot = do_adv_24d : @call(2117,"echo_danger"); @call(2117,"calc_whoclr_least"); @switch("1", @eq(0,@g(@print("ncc_",@add(40,@g("whoclr_inadv"))))), @print(@tellroom(@location("%#"),"",@print("GameBoard says, \"But ", @g("whocna_inadv"), " has no crew to lose, so...")), @call(2117,"end_adv")), @eq(@g("whoclr_least"),0), @print(@s("gstate",59), @s("q1","there's a tie for who has the 'Least Crew'. You must choose one. Will it be:"), @call(2117,"q_who")), @call(2117,"do_adv24dp1"));
=====

@field bot = do_adv_24dp :
  @call(2117,"echo_player");
  @s("whoclr_least",@g("whoclr_chosen"));
  @call(2117,"do_adv_24dp1");
-----
**TEST**
@field bot = do_adv_24dp : @call(2117,"echo_player"); @s("whoclr_least",@g("whoclr_chosen")); @call(2117,"do_adv_24dp1");
=====

@field bot = do_adv24dp1 : TODO

// to protect, COMMAND: Kirk (1), Spock (3), Scott (2), Starfleet (0)
@field bot = do_adv_24p :
  @call(2117,"echo_protect");
  @s("why_pro_ok","officer with Command");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_1"),@g("rack_inadv")),
      @eq(@g("ccloc_2"),@g("rack_inadv")),
      @eq(@g("ccloc_3"),@g("rack_inadv")),
      @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_pro_ok"), @call(2117,"end_adv")
    ),
    @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_24d"))
  );
---------
**TEST**
@field bot = do_adv_24p : @call(2117,"echo_protect"); @s("why_pro_ok","officer with Command"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_1"),@g("rack_inadv")), @eq(@g("ccloc_2"),@g("rack_inadv")), @eq(@g("ccloc_3"),@g("rack_inadv")), @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_pro_ok"), @call(2117,"end_adv")), @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_24d")));
=========

// [Met] Metamorphosis - no choice
@field bot = do_adv_25 : TODO

**TEST**
// [MM] Mirror, Mirror - choose 'warp' or 'impulse'
@field bot = do_adv_26 : @s("gstate",60); @call(2117,"setmsg_wrpimp");

// to warp, SCI: Barrows(20),Palamas(21),Romaine(22),Starfleet(0)
// TODO: Cadet-Sci(23) plus Kirk(1) plus Phaser 1 Kirk complication
@field bot = do_adv_26w :
  @call(2117,"echo_warp");
  @s("why_warp_ok","officer with Science");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_20"),@g("rack_inadv")),
      @eq(@g("ccloc_21"),@g("rack_inadv")),
      @eq(@g("ccloc_22"),@g("rack_inadv")),
      @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_warp_ok"), @call(2117,"do_adv_26w1")
    ),
    @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_26i"))
  );
---------
**TEST**
@field bot = do_adv_26w : @call(2117,"echo_warp"); @s("why_warp_ok","officer with Science"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_20"),@g("rack_inadv")), @eq(@g("ccloc_21"),@g("rack_inadv")), @eq(@g("ccloc_22"),@g("rack_inadv")), @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_26w1")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_26i")));
=========

@field bot = do_adv_26w1 : TODO
@field bot = do_adv_26i : TODO
  @call(2117,"echo_impulse");

// [MT] Man Trap - choose officer to give away
// -2 means that that player hasn't answered the call yet.
// -1 means that that player has no unlocked non-Cadet crew to pass left
//    (or isn't in the game)
@field bot = do_adv_27 :
  @s("crew_chosen_by_1","-1"); @s("crew_chosen_by_2","-1");
  @s("crew_chosen_by_3","-1"); @s("crew_chosen_by_4","-1");
  @fieldloop(@g("whoclrs"),"x",@s("crew_chosen_by_%x","-2"));
  @s("gstate",61);
  @tellroom(@location("%#"),"",@print(
    "GameBoard says, \"ALL PLAYERS, if you have at least one unlocked non-Cadet
    crewman, please select one to pass to your left, eg: 'CREW SMITH'.
    If you don't have a crewman to pass, type 'OK'.\""
  ));
-----
**TEST**
@field bot = do_adv_27 : @s("crew_chosen_by_1","-1"); @s("crew_chosen_by_2","-1"); @s("crew_chosen_by_3","-1"); @s("crew_chosen_by_4","-1"); @fieldloop(@g("whoclrs"),"x",@s("crew_chosen_by_%x","-2")); @s("gstate",61); @tellroom(@location("%#"),"",@print("GameBoard says, \"ALL PLAYERS, if you have at least one unlocked non-Cadet crewman, please select one to pass to your left, eg: 'CREW SMITH'. If you don't have a crewman to pass, type 'OK'.\""));
=====

// someone chose a crewman
@field bot = do_adv_27c : TODO

// someone chose 'ok'
@field bot = do_adv_27o : TODO

// test that everyone has answered
@field bot = do_adv_27_test : TODO

// pass all the selected crew, one player to the left.
@field bot = do_adv_27z : TODO

// [MW] Mudd's Women - choose special card to play
@field bot = do_adv_28 : TODO

**TEST**
// [NT] The Naked Time - choose 'danger' or 'protect'
@field bot = do_adv_29 : @s("gstate",63); @call(2117,"setmsg_danpro");

@field bot = do_adv_29d : TODO
  @call(2117,"echo_danger");

// to protect, must have LANDON (18), SULU (14), or RILEY (13)
@field bot = do_adv_29p :
  @call(2117,"echo_protect");
  @s("why_pro_ok","of Landon, Sulu, or Riley");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_18"),@g("rack_inadv")),
      @eq(@g("ccloc_14"),@g("rack_inadv")),
      @eq(@g("ccloc_13"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_pro_ok"), @call(2117,"end_adv")
    ),
    @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_29d"))
  );
----------
**TEST**
@field bot = do_adv_29p : @call(2117,"echo_protect"); @s("why_pro_ok","of Landon, Sulu, or Riley"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_18"),@g("rack_inadv")), @eq(@g("ccloc_14"),@g("rack_inadv")), @eq(@g("ccloc_13"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_pro_ok"), @call(2117,"end_adv")), @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_29d")));
==========

// [OA] Operation - Annihilate! - choose another player.
@field bot = do_adv_30 :
  @switch("1",
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @call(2117,"do_adv_30z")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",64),
      @s("q1","who do you want to move and trade hands with?"),
      @call(2117,"q_who")
    )
  );
-----
**TEST**
@field bot = do_adv_30 : @switch("1", @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x", @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @call(2117,"do_adv_30z")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",64), @s("q1","who do you want to move and trade hands with?"), @call(2117,"q_who")));
=====

**TEST NODEL**
@field bot = do_adv_30p : @call(2117,"echo_player"); @call(2117,"do_adv_30z");

@field bot = do_adv_30z : TODO

// [PA] A Piece of the Action - no choice
@field bot = do_adv_31 : TODO

**TEST**
// [PF] Patterns of Force - choose 'warp' or 'impulse'
@field bot = do_adv_32 : @s("gstate",65); @call(2117,"setmsg_wrpimp");

// to warp, MED: McCoy(8),Chapel(9),Noel(10),Starfleet(0)
// TODO: Cadet-Med(11) plus Kirk(1) plus Phaser 1 Kirk complication
@field bot = do_adv_32w :
  @call(2117,"echo_warp");
  @s("why_warp_ok","officer with Medical");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_8"),@g("rack_inadv")),
      @eq(@g("ccloc_9"),@g("rack_inadv")),
      @eq(@g("ccloc_10"),@g("rack_inadv")),
      @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_warp_ok"), @call(2117,"do_adv_32w1")
    ),
    @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_32i"))
  );
--------
**TEST**
@field bot = do_adv_32w : @call(2117,"echo_warp"); @s("why_warp_ok","officer with Medical"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_8"),@g("rack_inadv")), @eq(@g("ccloc_9"),@g("rack_inadv")), @eq(@g("ccloc_10"),@g("rack_inadv")), @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_32w1")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_32i")));
========

@field bot = do_adv_32w1 : TODO

@field bot = do_adv_32i :
  @call(2117,"echo_impulse");
  @switch("1",
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @call(2117,"do_adv_32ic")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",72), @s("q1","who do you want to ask for a card?"),
      @call(2117,"q_who")
    )
  );
-----
**TEST**
@field bot = do_adv_32i : @call(2117,"echo_impulse"); @switch("1", @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x",@g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @call(2117,"do_adv_32ic")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",72), @s("q1","who do you want to ask for a card?"), @call(2117,"q_who")));
=====

@field bot = do_adv_32ip : TODO
  @call(2117,"echo_player");
@field bot = do_adv_32ic : TODO

**TEST**
// [PSt] Plato's Stepchildren - choose 'warp' or 'impulse'
@field bot = do_adv_33 : @s("gstate",75); @call(2117,"setmsg_wrpimp");

// to warp, MED: McCoy(8),Chapel(9),Noel(10),Starfleet(0)
// TODO: Cadet-Med(11) plus Kirk(1) plus Phaser 1 Kirk complication
@field bot = do_adv_33w :
  @call(2117,"echo_warp");
  @s("why_warp_ok","officer with Medical");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_8"),@g("rack_inadv")),
      @eq(@g("ccloc_9"),@g("rack_inadv")),
      @eq(@g("ccloc_10"),@g("rack_inadv")),
      @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_warp_ok"), @call(2117,"do_adv_33w1")
    ),
    @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_33i"))
  );
-------
**TEST**
@field bot = do_adv_33w : @call(2117,"echo_warp"); @s("why_warp_ok","officer with Medical"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_8"),@g("rack_inadv")), @eq(@g("ccloc_9"),@g("rack_inadv")), @eq(@g("ccloc_10"),@g("rack_inadv")), @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_33w1")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_33i")));
=======

@field bot = do_adv_33w1 :
  @strloop(@g("whoclrs"),"x",@s("isclropt%x","1"));
  @s(@print("isclropt",@g("whoclr_inadv")),"0");
  @s("gstate",76); @s("q1","first"), @call(2117,"q_who_or_deck");
-----
**TEST**
@field bot = do_adv_33w1 : @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")); @s(@print("isclropt",@g("whoclr_inadv")),"0"); @s("gstate",76); @s("q1","first"), @call(2117,"q_who_or_deck");
=====

@field bot = do_adv_33wp1 : TODO
  @call(2117,"echo_player");
@field bot = do_adv_33wk1 : TODO
  @call(2117,"echo_deck");

@field bot = do_adv_33w2 :
  @strloop(@g("whoclrs"),"x",@s("isclropt%x","1"));
  @s(@print("isclropt",@g("whoclr_inadv")),"0");
  @s("gstate",77); @s("q1","second"); @call(2117,"q_who_or_deck");
-----
**TEST**
@field bot = do_adv_33w2 : @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")); @s(@print("isclropt",@g("whoclr_inadv")),"0"); @s("gstate",77); @s("q1","second"); @call(2117,"q_who_or_deck");
=====

@field bot = do_adv_33wp2 : TODO
  @call(2117,"echo_player");
@field bot = do_adv_33wk2 : TODO
  @call(2117,"echo_deck");

@field bot = do_adv_33i : TODO
  @call(2117,"echo_impulse");

// [PSy] The Paradise Syndrome - choose card from discard pile
@field bot = do_adv_34 : TODO

**TEST**
// [RA] The Return of the Archons - choose 'danger' or 'protect'
@field bot = do_adv_35 : @s("gstate",79); @call(2117,"setmsg_danpro");

// 1) If you don't have any crew to give away, end adv.
// 2) Else if 2-player game, calc who opponent is.
// 3) Else ask who you'll give a crewman to.
@field bot = do_adv_35d :
  @call(2117,"echo_danger");
  @switch("1",
    @eq(0,@g(@print("ncc_",@add(40,@g("whoclr_inadv"))))), @print(
      @tellroom(@location("%#"),"",@print(
        "But since ", @g("whocna_inadv"),
        " has no crew to give away,..."
      )),
      @call(2117,"end_adv")
    ),
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @call(2117,"do_adv_35dpz")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",81), @s("q1","who will you give a crewman to?"),
      @call(2117,"q_who")
    )
  );
---------
**TEST**
@field bot = do_adv_35d : @call(2117,"echo_danger"); @switch("1", @eq(0,@g(@print("ncc_",@add(40,@g("whoclr_inadv"))))), @print(@tellroom(@location("%#"),"",@print("But since ", @g("whocna_inadv"), " has no crew to give away,...")), @call(2117,"end_adv")), @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x", @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @call(2117,"do_adv_35dpz")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",81), @s("q1","who will you give a crewman to?"), @call(2117,"q_who")));
=========  

**TEST NODEL**
@field bot = do_adv_35dp : @call(2117,"echo_player"); @call(2117,"do_adv_35dpz");

// choose a crewman to give away
@field bot = do_adv_35dpz :
  @switch("1", @g(@print("ncc_",@add(40,@g("whoclr_inadv")))),
    @print(
      @fieldloop(2117,"ccloc_",@switch("%v",@add(40,@g("whoclr_inadv")),
        @s("crew_chosen",@substr("%f",6))
      )),
      @call(2117,"do_adv_35dz")
    ),
    @print(
      @s("gstate",80),
      @tellroom(@location("%#"),"",@print(
        "GameBoard says (to ", @g("whorna_inadv"), "), \"",
        @g("whocna_inadv"), ", choose which of your crewmen to give to ",
        @g("whocna_chosen"), ", eg: 'CREW SMITH'.\""
      ))
    )
  );
-----
**TEST**
@field bot = do_adv_35dpz : @switch("1", @g(@print("ncc_",@add(40,@g("whoclr_inadv")))), @print(@fieldloop(2117,"ccloc_",@switch("%v",@add(40,@g("whoclr_inadv")), @s("crew_chosen",@substr("%f",6)))), @call(2117,"do_adv_35dz")), @print(@s("gstate",80), @tellroom(@location("%#"),"",@print("GameBoard says (to ", @g("whorna_inadv"), "), \"", @g("whocna_inadv"), ", choose which of your crewmen to give to ", @g("whocna_chosen"), ", eg: 'CREW SMITH'.\""))));
=====

@field bot = do_adv_35dc : TODO
@field bot = do_adv_35dz : TODO

// to protect, must have JONES (16), MANNING (17), or SULU (14)
@field bot = do_adv_35p :
  @call(2117,"echo_protect");
  @s("why_pro_ok","of Jones, Manning, or Sulu");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_16"),@g("rack_inadv")),
      @eq(@g("ccloc_17"),@g("rack_inadv")),
      @eq(@g("ccloc_14"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_pro_ok"), @call(2117,"end_adv")
    ),
    @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_35d"))
  );
-------
**TEST**
@field bot = do_adv_35p : @call(2117,"echo_protect"); @s("why_pro_ok","of Jones, Manning, or Sulu"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_16"),@g("rack_inadv")), @eq(@g("ccloc_17"),@g("rack_inadv")), @eq(@g("ccloc_14"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_pro_ok"), @call(2117,"end_adv")), @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_35d")));
=======

// [RM] Requiem for Methuselah - no choice
@field bot = do_adv_36 : TODO

**TEST**
// [RT] Return to Tomorrow - choose 'warp' or 'impulse'
@field bot = do_adv_37 : @s("gstate",82); @call(2117,"setmsg_wrpimp");

// to warp, SCI: Barrows(20),Palamas(21),Romaine(22),Starfleet(0)
// TODO: Cadet-Sci(23) plus Kirk(1) plus Phaser 1 Kirk complication
@field bot = do_adv_37w :
  @call(2117,"echo_warp");
  @s("why_warp_ok","officer with Science");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_20"),@g("rack_inadv")),
      @eq(@g("ccloc_21"),@g("rack_inadv")),
      @eq(@g("ccloc_22"),@g("rack_inadv")),
      @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_warp_ok"), @call(2117,"do_adv_37w1")
    ),
    @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_37i"))
  );
--------
**TEST**
@field bot = do_adv_37w : @call(2117,"echo_warp"); @s("why_warp_ok","officer with Science"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_20"),@g("rack_inadv")), @eq(@g("ccloc_21"),@g("rack_inadv")), @eq(@g("ccloc_22"),@g("rack_inadv")), @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_37w1")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_37i")));
========

@field bot = do_adv_37w1 :
  @call(2117,"calc_whoclr_most");
  @switch("1",
    @eq(@g("whoclr_most"),0), @print(
      @s("gstate",83),
      @s("q1","there's a tie for who has the 'Most Crew'. You must choose one. Will it be:"),
      @call(2117,"q_who")
    ),
    @call(2117,"do_adv_37wp1")
  );
---------
**TEST**
@field bot = do_adv_37w1 : @call(2117,"calc_whoclr_most"); @switch("1", @eq(@g("whoclr_most"),0), @print(@s("gstate",83), @s("q1","there's a tie for who has the 'Most Crew'. You must choose one. Will it be:"), @call(2117,"q_who")), @call(2117,"do_adv_37wp1"));
=========

**TEST NODEL**
@field bot = do_adv_37wp : @call(2117,"echo_player"); @call(2117,"do_adv_37wp1");

@field bot = do_adv_37wp1 : TODO

@field bot = do_adv_37i :
  @call(2117,"echo_impulse");
  @switch("1",
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @call(2117,"do_adv_37ip1")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",84), @s("q1","who will you make your crew call (for information only) against?"),
      @call(2117,"q_who")
    )
  );
---------
**TEST**
@field bot = do_adv_37i : @call(2117,"echo_impulse"); @switch("1", @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x", @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @call(2117,"do_adv_37ip1")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",84), @s("q1","who will you make your crew call (for information only) against?"), @call(2117,"q_who")));
=========

**TEST NODEL**
@field bot = do_adv_37ip : @call(2117,"echo_player"); @call(2117,"do_adv_37ip1");

@field bot = do_adv_37ip1 :
  @s("gstate",85);
  @tellroom(@location("%#"),"",@print(
    "GameBoard says (to ", @g("whorna_inadv"),
    "), \"", @g("whocna_inadv"),
    ", make your crew call (for information only) against ",
    @g("whocna_chosen"),
    ". You may either call for a crewman by name, eg: 'CREW SMITH',
    or call for any crewman with an specific specialty
    (except Command), eg: 'SPEC SECURITY'.\""
  ));
------
**TEST**
@field bot = do_adv_37ip1 : @s("gstate",85); @tellroom(@location("%#"),"",@print("GameBoard says (to ", @g("whorna_inadv"), "), \"", @g("whocna_inadv"), ", make your crew call (for information only) against ", @g("whocna_chosen"), ". You may either call for a crewman by name, eg: 'CREW SMITH', or call for any crewman with an specific specialty (except Command), eg: 'SPEC SECURITY'.\""));
======

**TEST**
// [SB] Spock's Brain - choose 'danger' or 'protect'
@field bot = do_adv_38 : @s("gstate",86); @call(2117,"setmsg_danpro");

// 1) if you don't have any crew, end adv.
// 2) else if Least Crew is tied, break the tie,
// 3) else go do the danger (do_adv_38dz)
@field bot = do_adv_38d :
  @call(2117,"echo_danger");
  @call(2117,"calc_least_crew");
  @switch("1",
    @eq(0,@g(@print("ncc_",@g("whoclr_inadv")))), @print(
      @tellroom(@location("%#"),"",@print(
        "GameBoard says, \"But ", @g("whocna_inadv"),
        " doesn't have any crewmembers to lose. Therefore...\""
      )),
      @call(2117,"end_adv")
    ),
    @eq(0,@g("whoclr_least")), @print(
      @s("gstate",87),
      @s("q1","there's a tie for who has the 'Least Crew'. You must choose one. Will it be:"),
      @call(2117,"q_who")
    ),
    @call(2117,"do_adv_38dz")
  );
-----
**TEST**
@field bot = do_adv_38d : @call(2117,"echo_danger"); @call(2117,"calc_least_crew"); @switch("1", @eq(0,@g(@print("ncc_",@g("whoclr_inadv")))), @print(@tellroom(@location("%#"),"",@print("GameBoard says, \"But ", @g("whocna_inadv"), " doesn't have any crewmembers to lose. Therefore...\"")), @call(2117,"end_adv")), @eq(0,@g("whoclr_least")), @print(@s("gstate",87), @s("q1","there's a tie for who has the 'Least Crew'. You must choose one. Will it be:"), @call(2117,"q_who")), @call(2117,"do_adv_38dz"));
=====

@field bot = do_adv_38dp : TODO
  @call(2117,"echo_player");

@field bot = do_adv_38dz : TODO

// to protect, SECURITY: JONES (16), MANNING (17), LANDON (18), STARFLEET (0)
// TODO: Cadet-Sec (19) plus Kirk (1) plus Phaser 1 Kirk complication
@field bot = do_adv_38p :
  @call(2117,"echo_protect");
  @s("why_pro_ok","officer with Security");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_16"),@g("rack_inadv")),
      @eq(@g("ccloc_17"),@g("rack_inadv")),
      @eq(@g("ccloc_18"),@g("rack_inadv")),
      @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_pro_ok"), @call(2117,"end_adv")
    ),
    @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_38d"))
  );
--------
**TEST**
@field bot = do_adv_38p : @call(2117,"echo_protect"); @s("why_pro_ok","officer with Security"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_16"),@g("rack_inadv")), @eq(@g("ccloc_17"),@g("rack_inadv")), @eq(@g("ccloc_18"),@g("rack_inadv")), @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_pro_ok"), @call(2117,"end_adv")), @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_38d")));
========

// [SC] The Savage Curtain
// 1) If only 2-players in game, end adv.
// 2) Else if there's been a battle this turn, end adv.
// 3) Else, ask who will be the player entering battle first?
@field bot = do_adv_39 :
  @switch("1",@eq(@g("nwho"),2),@print(
      @tellroom(@location("%#"),"",
       "GameBoard says, \"It's a 2-player game; this adventure is ignored.\""),
      @call(2117,"end_adv")
    ),
    @eq(@g("isbatdone"),1), @print(
      @tellroom(@location("%#"),"",
        "GameBoard says, \"There's already been a battle this turn, so no battle occurs.\""
      ),
      @call(2117,"end_adv")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",88),
      @s("q1","who will enter the battle and move first?"),
      @call(2117,"q_who")
    )
  );
------
**TEST**
@field bot = do_adv_39 : @switch("1",@eq(@g("nwho"),2),@print(@tellroom(@location("%#"),"","GameBoard says, \"It's a 2-player game; this adventure is ignored.\""), @call(2117,"end_adv")), @eq(@g("isbatdone"),1), @print(@tellroom(@location("%#"),"","GameBoard says, \"There's already been a battle this turn, so no battle occurs.\""), @call(2117,"end_adv")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",88), @s("q1","who will enter the battle and move first?"), @call(2117,"q_who")));
======

// 1) if a 3-player game, calculate who'll be player2 in battle
// 2) else, ask who it'll be.
@field bot = do_adv_39p1 :
  @call(2117,"echo_player");
  @s("whoclr_bat1",@g("whoclr_chosen"));
  @switch("1",@eq(@g("nwho"),3),@print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "",
        @g("whoclr_bat1"), "",
        @s("whoclr_bat2","%x"))),
      @tellroom(@location("%#"),"",@print( "GameBoard says, \"And ",
        @g("whocna_bat2"), " will also enter battle, and move second.")),
      @call(2117,"do_adv_39b")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s(@print("isclropt",@g("whoclr_bat1")),"0"),
      @s("gstate",89),
      @s("q1","who will enter the battle and move second?"),
      @call(2117,"q_who")
    )
  );
------
**TEST**
@field bot = do_adv_39p1 : @call(2117,"echo_player"); @s("whoclr_bat1",@g("whoclr_chosen")); @switch("1",@eq(@g("nwho"),3),@print(@strloop(@g("whoclrs"),"x",@switch("%x", @g("whoclr_inadv"), "", @g("whoclr_bat1"), "", @s("whoclr_bat2","%x"))), @tellroom(@location("%#"),"",@print( "GameBoard says, \"And ", @g("whocna_bat2"), " will also enter battle, and move second.")), @call(2117,"do_adv_39b")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s(@print("isclropt",@g("whoclr_bat1")),"0"), @s("gstate",89), @s("q1","who will enter the battle and move second?"), @call(2117,"q_who")));
======

@field bot = do_adv_39p2 :
  @call(2117,"echo_player");
  @s("whoclr_bat2",@g("whoclr_chosen"));
  @call(2117,"do_adv_39b");
------
**TEST**
@field bot = do_adv_39p2 : @call(2117,"echo_player"); @s("whoclr_bat2",@g("whoclr_chosen")); @call(2117,"do_adv_39b");
======

@field bot = do_adv_39b :
  @s(@print("ship",@g("whoclr_bat1"),"_loc"),21);
  @s(@print("ship",@g("whoclr_bat2"),"_loc"),21);
  @s(@print("ship",@g("whoclr_bat1"),"_pos"),6);
  @s(@print("ship",@g("whoclr_bat2"),"_loc"),6);
  @s("whoclr_bturn",@g("whoclr_bat1"));
  @call(2117,"do_battle");
-----
**TEST**
@field bot = do_adv_39b : @s(@print("ship",@g("whoclr_bat1"),"_loc"),21); @s(@print("ship",@g("whoclr_bat2"),"_loc"),21); @s(@print("ship",@g("whoclr_bat1"),"_pos"),6); @s(@print("ship",@g("whoclr_bat2"),"_loc"),6); @s("whoclr_bturn",@g("whoclr_bat1")); @call(2117,"do_battle");
=====

**TEST**
// [SGn] Spectre of the Gun - choose 'warp' or 'impulse'
@field bot = do_adv_40 : @s("gstate",90); @call(2117,"setmsg_wrpimp");

// to warp, SECURITY: Jones(16),Manning(17),Landon(18),Starfleet(0)
// TODO: Cadet-Sec() plus Kirk(1) plus Phaser 1 Kirk complication
@field bot = do_adv_40w :
  @call(2117,"echo_warp");
  @s("why_warp_ok","officer with Security");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_16"),@g("rack_inadv")),
      @eq(@g("ccloc_17"),@g("rack_inadv")),
      @eq(@g("ccloc_18"),@g("rack_inadv")),
      @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_warp_ok"), @call(2117,"do_adv_40w1")
    ),
    @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_40i"))
  );
---------
**TEST**
@field bot = do_adv_40w : @call(2117,"echo_warp"); @s("why_warp_ok","officer with Security"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_16"),@g("rack_inadv")), @eq(@g("ccloc_17"),@g("rack_inadv")), @eq(@g("ccloc_18"),@g("rack_inadv")), @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_40w1")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_40i")));
=========

@field bot = do_adv_40w1 :
  @switch("1",
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @call(2117,"do_adv_40wpz")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",91), @s("q1","who will you force to maroon a crewman?"),
      @call(2117,"q_who")
    )
  );
---------
**TEST**
@field bot = do_adv_40w1 : @switch("1", @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x", @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @call(2117,"do_adv_40wpz")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",91), @s("q1","who will you force to maroon a crewman?"), @call(2117,"q_who")));
=========

**TEST NODEL**
@field bot = do_adv_40wp : @call(2117,"echo_player"); @call(2117,"do_adv_40wpz");

// The player has been chosen. Now choose the space.
// (If the chosen player has no unlocked crew, end the adventure.)
@field bot = do_adv_40wpz : TODO

@field bot = do_adv_40ws : TODO

// The space has been chosen. Now whoclr_chosen must choose one of his crew.
// TODO: Autochoose if he has only one unlocked crewman.
@field bot = do_adv_40wsz :
  @s("gstate",93);
  @tellroom(@location("%#"),"",@print(
    "GameBoard says (to ", @g("whorna_chosen"),
    "), \"", @g("whocna_chosen"),
    "choose which of your crew to maroon, eg: 'CREW SMITH'."
  ));
-----
**TEST**
@field bot = do_adv_40wsz : @call(2117,"calc_whodbr_chosen"); @s("gstate",93); @tellroom(@location("%#"),"",@print("GameBoard says (to ", @g("whorna_chosen"), "), \"", @g("whocna_chosen"), "choose which of your crew to maroon, eg: 'CREW SMITH'."));
=====

@field bot = do_adv_40wc : TODO

@field bot = do_adv_40wcz : TODO

@field bot = do_adv_40i :
  @call(2117,"echo_impulse");
  @switch("1",
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @call(2117,"do_adv_40ipz")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",94), @s("q1","who will you force to discard a card?"),
      @call(2117,"q_who")
    )
  );
--------
**TEST**
@field bot = do_adv_40i : @call(2117,"echo_impulse"); @switch("1", @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x", @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @call(2117,"do_adv_40ipz")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",94), @s("q1","who will you force to discard a card?"), @call(2117,"q_who")));
========

**TEST NODEL**
@field bot = do_adv_40ip : @call(2117,"echo_player"); @call(2117,"do_adv_40ipz");

@field bot = do_adv_40ipz : TODO

**TEST**
// [SL] Shore Leave - choose 'warp' or 'impulse'
@field bot = do_adv_41 : @s("gstate",97); @call(2117,"setmsg_wrpimp");

// to warp, Kyle(5), Barrows(20), Sulu(14)
@field bot = do_adv_41w :
  @call(2117,"echo_warp"); @s("why_warp_ok","of Kyle, Barrows, or Sulu");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_5"),@g("rack_inadv")),
      @eq(@g("ccloc_20"),@g("rack_inadv")),
      @eq(@g("ccloc_14"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_warp_ok"), @call(2117,"do_adv_41wz")
    ),
    @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_41i"))
  );
-------
**TEST**
@field bot = do_adv_41w : @call(2117,"echo_warp"); @s("why_warp_ok","of Kyle, Barrows, or Sulu"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_5"),@g("rack_inadv")), @eq(@g("ccloc_20"),@g("rack_inadv")), @eq(@g("ccloc_14"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_41wz")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_41i")));
=======

// choose any other space
@field bot = do_adv_41wz :
  @s("gstate",98);
  @tellroom(@location("%#"),"",@print(
    "GameBoard says (to ", @g("whorna_inadv"),
    "), \"", @g("whocna_inadv"),
    "choose any other space to move to, eg: 'SPACE 10'."
  ));
-----
**TEST**
@field bot = do_adv_41wz : @s("gstate",98); @tellroom(@location("%#"),"",@print("GameBoard says (to ", @g("whorna_inadv"), "), \"", @g("whocna_inadv"), "choose any other space to move to, eg: 'SPACE 10'."));
=====

// NOTE: sets whoclr_nxtadv and nxtadv_rolled for next adventure.
@field bot = do_adv_41ws :
  @switch("%#",@g("whodbr_inadv"),@print(
    @call(2117,"echo_space"),
    @s("space_this",@g(@print("ship",@g("whoclr_inadv"),"_loc"))),
    @switch("1",
      @eq(@g("space_chosen"),@g("space_this")), @print(
        "GameBoard says (to %n), \"No, any *other* space. Choose again.\""
      ),
      @print(
        @s(@print("ship",@g("whoclr_inadv"),"_loc"),@g("space_chosen")),
        @tellroom(@location("%#"),"",@print(
          "The ", @lc(@g("whocna_inadv")),
          " ship flies over to space #", @g("space_chosen"), "."
        ),
        @s("whoclr_nxtadv",@g("whoclr_inadv")),
        @s("nxtadv_rolled",0),
        @call(2117,"end_adv")
      )
    )
  ), @call(2117,"you_not_inadv"));
------
**TEST**
@field bot = do_adv_41ws : @switch("%#",@g("whodbr_inadv"),@print(@call(2117,"echo_space"), @s("space_this",@g(@print("ship",@g("whoclr_inadv"),"_loc"))), @switch("1", @eq(@g("space_chosen"),@g("space_this")), @print("GameBoard says (to %n), \"No, any *other* space. Choose again.\""), @print(@s(@print("ship",@g("whoclr_inadv"),"_loc"),@g("space_chosen")), @tellroom(@location("%#"),"",@print("The ", @lc(@g("whocna_inadv")), " ship flies over to space #", @g("space_chosen"), "."), @s("whoclr_nxtadv",@g("whoclr_inadv")), @s("nxtadv_rolled",0), @call(2117,"end_adv")))), @call(2117,"you_not_inadv"));
======

@field bot = do_adv_41i :
  @call(2117,"echo_impulse"); @s("gstate",99);
  @s("loc_x",@g(@print("ship",@g("whoclr_inadv"),"_loc")));
  @switch(@g("stddir"),
    0,@print(
      @s("loc_xf",@add(@mod(@g("loc_x"),20),1)),
      @s("loc_xb",@add(@mod(@add(@g("loc_x"),18),20),1))
    ),1,@print(
      @s("loc_xf",@add(@mod(@add(@g("loc_x"),18),20),1)),
      @s("loc_xb",@add(@mod(@g("loc_x"),20),1))
    )
  );
  @tellroom(@location("%#"),"",@print(
    "GameBoard says (to ", @g("whorna_inadv"),
    "), \"", @g("whocna_inadv"),
    ", choose to move 'FORWARD' (to #", @g("loc_xf"),
    "), or 'BACK' (to #", @g("loc_xb"), ").\""
  ));
-----
**ADD**
@field bot = do_adv_41i : @call(2117,"echo_impulse"); @s("gstate",99); @s("loc_x",@g(@print("ship",@g("whoclr_inadv"),"_loc"))); @switch(@g("stddir"), 0,@print(@s("loc_xf",@add(@mod(@g("loc_x"),20),1)), @s("loc_xb",@add(@mod(@add(@g("loc_x"),18),20),1))),1,@print(@s("loc_xf",@add(@mod(@add(@g("loc_x"),18),20),1)), @s("loc_xb",@add(@mod(@g("loc_x"),20),1)))); @tellroom(@location("%#"),"",@print("GameBoard says (to ", @g("whorna_inadv"), "), \"", @g("whocna_inadv"), ", choose to move 'FORWARD' (to #", @g("loc_xf"), "), or 'BACK' (to #", @g("loc_xb"), ").\""));
=====

// forward 1 space
@field bot = do_adv_41if :
  @switch("%#",@g("whodbr_inadv"),@print(
    @call(2117,"echo_forward"),
    @s("loc_x",@g(@print("ship",@g("whoclr_inadv"),"_loc"))),
    @switch(@g("stddir"),
      0, @s("loc_xf",@add(@mod(@g("loc_x"),20),1)),
      1, @s("loc_xf",@add(@mod(@add(@g("loc_x"),18),20),1))
    ),
    @s(@print("ship",@g("whoclr_inadv"),"_loc"),@g("loc_xf")),
    @tellroom(@location("%#"),"",@print(
      "The ", @lc(@g("whocna_inadv")),
      " ship moves forward one space to #", @g("loc_xf"), "."
    ),
    @s("whoclr_nxtadv",@g("whoclr_inadv")),
    @s("nxtadv_rolled",0),
    @call(2117,"end_adv")
  ), @call(2117,"you_not_inadv"));
-----
**TEST**
@field bot = do_adv_41if : @switch("%#",@g("whodbr_inadv"),@print(@call(2117,"echo_forward"), @s("loc_x",@g(@print("ship",@g("whoclr_inadv"),"_loc"))), @switch(@g("stddir"), 0, @s("loc_xf",@add(@mod(@g("loc_x"),20),1)), 1, @s("loc_xf",@add(@mod(@add(@g("loc_x"),18),20),1))), @s(@print("ship",@g("whoclr_inadv"),"_loc"),@g("loc_xf")), @tellroom(@location("%#"),"",@print("The ", @lc(@g("whocna_inadv")), " ship moves forward one space to #", @g("loc_xf"), "."), @s("whoclr_nxtadv",@g("whoclr_inadv")), @s("nxtadv_rolled",0), @call(2117,"end_adv")), @call(2117,"you_not_inadv"));
=====

// back 1 space
@field bot = do_adv_41ia :
  @switch("%#",@g("whodbr_inadv"),@print(
    @call(2117,"echo_back"),
    @s("loc_x",@g(@print("ship",@g("whoclr_inadv"),"_loc"))),
    @switch(@g("stddir"),
      1, @s("loc_xb",@add(@mod(@g("loc_x"),20),1)),
      0, @s("loc_xb",@add(@mod(@add(@g("loc_x"),18),20),1))
    ),
    @s(@print("ship",@g("whoclr_inadv"),"_loc"),@g("loc_xb")),
    @tellroom(@location("%#"),"",@print(
      "The ", @lc(@g("whocna_inadv")),
      " ship moves back one space to #", @g("loc_xb"), "."
    ),
    @s("whoclr_nxtadv",@g("whoclr_inadv")),
    @s("nxtadv_rolled",0),
    @call(2117,"end_adv")
  ), @call(2117,"you_not_inadv"));
-----
**TEST**
@field bot = do_adv_41ia : @switch("%#",@g("whodbr_inadv"),@print(@call(2117,"echo_back"), @s("loc_x",@g(@print("ship",@g("whoclr_inadv"),"_loc"))), @switch(@g("stddir"), 1, @s("loc_xb",@add(@mod(@g("loc_x"),20),1)), 0, @s("loc_xb",@add(@mod(@add(@g("loc_x"),18),20),1))), @s(@print("ship",@g("whoclr_inadv"),"_loc"),@g("loc_xb")), @tellroom(@location("%#"),"",@print("The ", @lc(@g("whocna_inadv")), " ship moves back one space to #", @g("loc_xb"), "."), @s("whoclr_nxtadv",@g("whoclr_inadv")), @s("nxtadv_rolled",0), @call(2117,"end_adv")), @call(2117,"you_not_inadv"));
=====

**TEST**
// [TA] A Taste of Armageddon - choose 'danger' or 'protect'
@field bot = do_adv_42 : @s("gstate",100); @call(2117,"setmsg_danpro");

// Decide who you're going to "Battle to the Death".
// 1) if there's already been a battle this turn, or it's not your turn,
// then there's no battle at all, and this adventure ends.
// 2) else if there's only 2 players, calculate who the opponent is.
// 3) else ask who the opponent will be.
@field bot = do_adv_42d :
  @call(2117,"echo_danger");
  @switch("1",
    @not(@eq(@g("whoclr_inadv"),@g("whoclr_turn"))), @print(
      @tellroom(@location("%#"),"",@print(
        "GameBoard says, \"", @g("whocna_inadv"),
        "can't start a battle when it's not %p turn, so no battle occurs.\""
      )),
      @call(2117,"end_adv")
    ),
    @eq(@g("isbatdone"),1), @print(
      @tellroom(@location("%#"),"", @print(
        "GameBoard says, \"There's already been a battle this turn, so no battle occurs.\""
      )),
      @call(2117,"end_adv")
    ),
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @tellroom(@location("%#"),"",@print( "GameBoard says, \"",
        @g("whocna_inadv"), " challenges ",
        @g("whocna_chosen"), " to 'Battle to the Death'.")),
      @call(2117,"do_adv_42db")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",101),
      @s("q1","who will you 'Battle to the Death'?"),
      @call(2117,"q_who")
    )
  );
---------------
**TEST**
@field bot = do_adv_42d : @call(2117,"echo_danger"); @switch("1", @not(@eq(@g("whoclr_inadv"),@g("whoclr_turn"))), @print(@tellroom(@location("%#"),"",@print("GameBoard says, \"", @g("whocna_inadv"), "can't start a battle when it's not %p turn, so no battle occurs.\"")), @call(2117,"end_adv")), @eq(@g("isbatdone"),1), @print(@tellroom(@location("%#"),"", @print("GameBoard says, \"There's already been a battle this turn, so no battle occurs.\"")), @call(2117,"end_adv")), @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x", @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @tellroom(@location("%#"),"",@print( "GameBoard says, \"", @g("whocna_inadv"), " challenges ", @g("whocna_chosen"), " to 'Battle to the Death'.")), @call(2117,"do_adv_42db")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",101), @s("q1","who will you 'Battle to the Death'?"), @call(2117,"q_who")));
===============

**TEST NODEL**
// has chosen which player to battle
@field bot = do_adv_42dp : @call(2117,"echo_player"); @call(2117,"do_adv_42db");

// TODO: battle whoclr_chosen "to death".
@field bot = do_adv_42db : TODO
  @s("whoclr_bat1",@g("whoclr_inadv"));
  @s("whoclr_bat2",@g("whoclr_chosen"));
  @s(@print("ship",@g("whoclr_bat1"),"_loc"),21);
  @s(@print("ship",@g("whoclr_bat2"),"_loc"),21);
  @s(@print("ship",@g("whoclr_bat1"),"_pos"),6);
  @s(@print("ship",@g("whoclr_bat2"),"_loc"),6);
  @s("whoclr_bturn",@g("whoclr_bat1"));
  @call(2117,"do_battle");

// to protect, COMMAND: Kirk (1), Spock (3), Scott (2), Starfleet (0)
@field bot = do_adv_42p :
  @call(2117,"echo_protect");
  @s("why_pro_ok","officer with Command");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_1"),@g("rack_inadv")),
      @eq(@g("ccloc_2"),@g("rack_inadv")),
      @eq(@g("ccloc_3"),@g("rack_inadv")),
      @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_pro_ok"), @call(2117,"end_adv")
    ),
    @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_42d"))
  );
---------
**TEST**
@field bot = do_adv_42p : @call(2117,"echo_protect"); @s("why_pro_ok","officer with Command"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_1"),@g("rack_inadv")), @eq(@g("ccloc_2"),@g("rack_inadv")), @eq(@g("ccloc_3"),@g("rack_inadv")), @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_pro_ok"), @call(2117,"end_adv")), @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_42d")));
=========

**TEST**
// [TSP] This Side of Paradise - choose 'danger' or 'protect'
@field bot = do_adv_43 : @s("gstate",102); @call(2117,"setmsg_danpro");

@field bot = do_adv_43d : TODO
  @call(2117,"echo_danger");

// to protect, must have LANDON (18), MCCOY (8), or RILEY (13)
@field bot = do_adv_43p :
  @call(2117,"echo_protect");
  @s("why_pro_ok","of Landon, McCoy, or Riley");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_18),@g("rack_inadv")),
      @eq(@g("ccloc_8"),@g("rack_inadv")),
      @eq(@g("ccloc_13"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_pro_ok"), @call(2117,"end_adv")
    ),
    @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_43d"))
  );
--------
**TEST**
@field bot = do_adv_43p : @call(2117,"echo_protect"); @s("why_pro_ok","of Landon, McCoy, or Riley"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_18),@g("rack_inadv")), @eq(@g("ccloc_8"),@g("rack_inadv")), @eq(@g("ccloc_13"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_pro_ok"), @call(2117,"end_adv")), @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_43d")));
========

**TEST**
// [TW] The Tholian Web - choose 'warp' or 'impulse'
@field bot = do_adv_44 : @s("gstate",106); @call(2117,"setmsg_wrpimp");

// to warp, Uhura(4), Jones(16), Chekov(12)
@field bot = do_adv_44w :
  @call(2117,"echo_warp"); @s("why_warp_ok","of Uhura, Jones, or Chekov");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_4"),@g("rack_inadv")),
      @eq(@g("ccloc_16"),@g("rack_inadv")),
      @eq(@g("ccloc_12"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_warp_ok"), @call(2117,"do_adv_44w1")
    ),
    @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_44i"))
  );
--------
**TEST**
@field bot = do_adv_44w : @call(2117,"echo_warp"); @s("why_warp_ok","of Uhura, Jones, or Chekov"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_4"),@g("rack_inadv")), @eq(@g("ccloc_16"),@g("rack_inadv")), @eq(@g("ccloc_12"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_44w1")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_44i")));
========

// decide who to move
@field bot = do_adv_44w1 :
  @switch("1",
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @call(2117,"do_adv_44wpz")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",107), @s("q1","who will you move?"),
      @call(2117,"q_who")
    )
  );
---------
**TEST**
@field bot = do_adv_44w1 : @switch("1", @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x", @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @call(2117,"do_adv_44wpz")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",107), @s("q1","who will you move?"), @call(2117,"q_who")));
=========

**TEST NODEL**
@field bot = do_adv_44wp : @call(2117,"echo_player"); @call(2117,"do_adv_44wpz");

// now decide which adventure, except this one, to move him to
@field bot = do_adv_44wpz :
  @s("gstate",108);
  @call(2117,"calc_whodbr_chosen");
  @tellroom(@location("%#"),"",@print(
    "GameBoard says (to ", @g("whorna_inadv"),
    "), \"", @g("whocna_inadv"), "choose any other space to move ",
    @g("whocna_chosen"), " to, eg: 'SPACE 10'."
  ));
-----
**TEST**
@field bot = do_adv_44wpz : @s("gstate",108); @call(2117,"calc_whodbr_chosen"); @tellroom(@location("%#"),"",@print("GameBoard says (to ", @g("whorna_inadv"), "), \"", @g("whocna_inadv"), "choose any other space to move ", @g("whocna_chosen"), " to, eg: 'SPACE 10'."));
=====

@field bot = do_adv_44ws :
  @switch("%#",@g("whodbr_inadv"),@print(
    @call(2117,"echo_space"), @call(2117,"calc_whodbr_chosen"),
    @s("space_this",@g(@print("ship",@g("whoclr_inadv"),"_loc"))),
    @switch("1",
      @eq(@g("space_chosen"),@g("space_this")), @print(
        "GameBoard says (to %n), \"No, any *other* space. Choose again.\""
      ),
      @print(
        @s(@print("ship",@g("whoclr_chosen"),"_loc"),@g("space_chosen")),
        @tellroom(@location("%#"),"",@print(
          "The ", @lc(@g("whocna_chosen")),
          " ship flies over to space #", @g("space_chosen"), "."
        ),
        @s("whoclr_nxtadv",@g("whoclr_chosen")),
        @s("nxtadv_rolled",0),
        @call(2117,"end_adv")
      )
    )
  ), @call(2117,"you_not_inadv"));
------
**TEST**
@field bot = do_adv_44ws : @switch("%#",@g("whodbr_inadv"),@print(@call(2117,"echo_space"), @call(2117,"calc_whodbr_chosen"), @s("space_this",@g(@print("ship",@g("whoclr_inadv"),"_loc"))), @switch("1", @eq(@g("space_chosen"),@g("space_this")), @print("GameBoard says (to %n), \"No, any *other* space. Choose again.\""), @print(@s(@print("ship",@g("whoclr_chosen"),"_loc"),@g("space_chosen")), @tellroom(@location("%#"),"",@print("The ", @lc(@g("whocna_chosen")), " ship flies over to space #", @g("space_chosen"), "."), @s("whoclr_nxtadv",@g("whoclr_chosen")), @s("nxtadv_rolled",0), @call(2117,"end_adv")))), @call(2117,"you_not_inadv"));
======

// decide who to move
// TODO: what if 2-player game and the other guy's still in the Vortex?
// TODO: Or, same thing, but 3-players? Or 4-players?
@field bot = do_adv_44i :
  @call(2117,"echo_impulse");
  @switch("1",
    @eq(@g("nwho"),2), @print(
      @strloop(@g("whoclrs"),"x",@switch("%x",
        @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))),
      @call(2117,"do_adv_44ipz")
    ),
    @print(
      @strloop(@g("whoclrs"),"x",@s("isclropt%x","1")),
      @s(@print("isclropt",@g("whoclr_inadv")),"0"),
      @s("gstate",109), @s("q1","who will you move forward or back one space?"),
      @call(2117,"q_who")
    )
  );
-------
**TEST**
@field bot = do_adv_44i : @call(2117,"echo_impulse"); @switch("1", @eq(@g("nwho"),2), @print(@strloop(@g("whoclrs"),"x",@switch("%x", @g("whoclr_inadv"), "", @s("whoclr_chosen","%x"))), @call(2117,"do_adv_44ipz")), @print(@strloop(@g("whoclrs"),"x",@s("isclropt%x","1")), @s(@print("isclropt",@g("whoclr_inadv")),"0"), @s("gstate",109), @s("q1","who will you move forward or back one space?"), @call(2117,"q_who")));
=======

**TEST NODEL**
@field bot = do_adv_44ip : @call(2117,"echo_player"); @call(2117,"do_adv_44ipz");

// now decide forward or back
@field bot = do_adv_44ipz :
  @s("gstate",110);
  @call(2117,"calc_whodbr_chosen");
  @s("loc_x",@g(@print("ship",@g("whoclr_chosen"),"_loc")));
  @switch(@g("stddir"),
    0,@print(
      @s("loc_xf",@add(@mod(@g("loc_x"),20),1)),
      @s("loc_xb",@add(@mod(@add(@g("loc_x"),18),20),1))
    ),1,@print(
      @s("loc_xf",@add(@mod(@add(@g("loc_x"),18),20),1)),
      @s("loc_xb",@add(@mod(@g("loc_x"),20),1))
    )
  );
  @tellroom(@location("%#"),"",@print(
    "GameBoard says (to ", @g("whorna_inadv"),
    "), \"", @g("whocna_inadv"),
    "choose to move the ", @lc(@g("whocna_chosen")),
    " ship 'FORWARD' (to #", @g("loc_xf"),
    "), or 'BACK' (to #", @g("loc_xb"), ").\""
  ));
-----
**TEST**
@field bot = do_adv_44ipz : @s("gstate",110); @call(2117,"calc_whodbr_chosen"); @s("loc_x",@g(@print("ship",@g("whoclr_chosen"),"_loc"))); @switch(@g("stddir"), 0,@print(@s("loc_xf",@add(@mod(@g("loc_x"),20),1)), @s("loc_xb",@add(@mod(@add(@g("loc_x"),18),20),1))),1,@print(@s("loc_xf",@add(@mod(@add(@g("loc_x"),18),20),1)), @s("loc_xb",@add(@mod(@g("loc_x"),20),1)))); @tellroom(@location("%#"),"",@print("GameBoard says (to ", @g("whorna_inadv"), "), \"", @g("whocna_inadv"), "choose to move the ", @lc(@g("whocna_chosen")), " ship 'FORWARD' (to #", @g("loc_xf"), "), or 'BACK' (to #", @g("loc_xb"), ").\""));
=====

// forward 1 space
@field bot = do_adv_44if :
  @switch("%#",@g("whodbr_inadv"),@print(
    @call(2117,"echo_forward"),
    @s("loc_x",@g(@print("ship",@g("whoclr_chosen"),"_loc"))),
    @switch(@g("stddir"),
      0, @s("loc_xf",@add(@mod(@g("loc_x"),20),1)),
      1, @s("loc_xf",@add(@mod(@add(@g("loc_x"),18),20),1))
    ),
    @s(@print("ship",@g("whoclr_chosen"),"_loc"),@g("loc_xf")),
    @tellroom(@location("%#"),"",@print(
      "The ", @lc(@g("whocna_chosen")),
      " ship moves forward one space to #", @g("loc_xf"), "."
    ),
    @s("whoclr_nxtadv",@g("whoclr_chosen")),
    @s("nxtadv_rolled",0),
    @call(2117,"end_adv")
  ), @call(2117,"you_not_inadv"));
-----
**TEST**
@field bot = do_adv_44if : @switch("%#",@g("whodbr_inadv"),@print(@call(2117,"echo_forward"), @s("loc_x",@g(@print("ship",@g("whoclr_chosen"),"_loc"))), @switch(@g("stddir"), 0, @s("loc_xf",@add(@mod(@g("loc_x"),20),1)), 1, @s("loc_xf",@add(@mod(@add(@g("loc_x"),18),20),1))), @s(@print("ship",@g("whoclr_chosen"),"_loc"),@g("loc_xf")), @tellroom(@location("%#"),"",@print("The ", @lc(@g("whocna_chosen")), " ship moves forward one space to #", @g("loc_xf"), "."), @s("whoclr_nxtadv",@g("whoclr_chosen")), @s("nxtadv_rolled",0), @call(2117,"end_adv")), @call(2117,"you_not_inadv"));
=====

// back 1 space
@field bot = do_adv_44ia :
  @switch("%#",@g("whodbr_inadv"),@print(
    @call(2117,"echo_back"),
    @s("loc_x",@g(@print("ship",@g("whoclr_chosen"),"_loc"))),
    @switch(@g("stddir"),
      1, @s("loc_xb",@add(@mod(@g("loc_x"),20),1)),
      0, @s("loc_xb",@add(@mod(@add(@g("loc_x"),18),20),1))
    ),
    @s(@print("ship",@g("whoclr_chosen"),"_loc"),@g("loc_xb")),
    @tellroom(@location("%#"),"",@print(
      "The ", @lc(@g("whocna_chosen")),
      " ship moves back one space to #", @g("loc_xb"), "."
    ),
    @s("whoclr_nxtadv",@g("whoclr_chosen")),
    @s("nxtadv_rolled",0),
    @call(2117,"end_adv")
  ), @call(2117,"you_not_inadv"));
-----
**TEST**
@field bot = do_adv_44ia : @switch("%#",@g("whodbr_inadv"),@print(@call(2117,"echo_back"), @s("loc_x",@g(@print("ship",@g("whoclr_chosen"),"_loc"))), @switch(@g("stddir"), 1, @s("loc_xb",@add(@mod(@g("loc_x"),20),1)), 0, @s("loc_xb",@add(@mod(@add(@g("loc_x"),18),20),1))), @s(@print("ship",@g("whoclr_chosen"),"_loc"),@g("loc_xb")), @tellroom(@location("%#"),"",@print("The ", @lc(@g("whocna_chosen")), " ship moves back one space to #", @g("loc_xb"), "."), @s("whoclr_nxtadv",@g("whoclr_chosen")), @s("nxtadv_rolled",0), @call(2117,"end_adv")), @call(2117,"you_not_inadv"));
=====

**TEST**
// [TWS] That Which Survives - choose 'danger' or 'protect'
@field bot = do_adv_45 : @s("gstate",111); @call(2117,"setmsg_danpro");

@field bot = do_adv_45d : TODO
  @call(2117,"echo_danger");

// to protect, MEDICAL: McCoy (8), Chapel (9), Noel (10), Starfleet (0)
// TODO: Cadet-Med (11) plus Kirk (1) plus Phaser 1 Kirk complication
@field bot = do_adv_45p :
  @call(2117,"echo_protect");
  @s("why_pro_ok","officer with Medical");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_8"),@g("rack_inadv")),
      @eq(@g("ccloc_9"),@g("rack_inadv")),
      @eq(@g("ccloc_10"),@g("rack_inadv")),
      @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_pro_ok"), @call(2117,"end_adv")
    ),
    @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_45d"))
  );
--------
**TEST**
@field bot = do_adv_45p : @call(2117,"echo_protect"); @s("why_pro_ok","officer with Medical"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_8"),@g("rack_inadv")), @eq(@g("ccloc_9"),@g("rack_inadv")), @eq(@g("ccloc_10"),@g("rack_inadv")), @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_pro_ok"), @call(2117,"end_adv")), @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_45d")));
========

**TEST**
// [TY] Tomorrow is Yesterday - choose 'danger' or 'protect'
@field bot = do_adv_46 : @s("gstate",113); @call(2117,"setmsg_danpro");

@field bot = do_adv_46d :
  @call(2117,"echo_danger"); @call(2117,"calc_whoclr_least");
  @switch("1",
    @eq(0,@g("whoclr_least")), @print(
      @s("gstate",114),
      @s("q1","there's a tie for who has the 'Least Crew'. You must choose one. Will it be:"),
      @call(2117,"q_who")
    ),
    @print(
      "[TODO: LC chooses a space to move inadv's ship to]"
    )
  );
-----
**TEST**
@field bot = do_adv_46d : @call(2117,"echo_danger"); @call(2117,"calc_whoclr_least"); @switch("1", @eq(0,@g("whoclr_least")), @print(@s("gstate",114), @s("q1","there's a tie for who has the 'Least Crew'. You must choose one. Will it be:"), @call(2117,"q_who")), @print("[TODO: LC chooses a space to move inadv's ship to]"));
=====

@field bot = do_adv_46dp : TODO
  @call(2117,"echo_player");

// to protect, must have UHURA (4), KYLE (5), or CHAPEL (9)
@field bot = do_adv_46p :
  @call(2117,"echo_protect");
  @s("why_pro_ok","of Uhura, Kyle, or Chapel");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_4"),@g("rack_inadv")),
      @eq(@g("ccloc_5"),@g("rack_inadv")),
      @eq(@g("ccloc_9"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_pro_ok"), @call(2117,"end_adv")
    ),
    @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_46d"))
  );
--------
**TEST**
@field bot = do_adv_46p : @call(2117,"echo_protect"); @s("why_pro_ok","of Uhura, Kyle, or Chapel"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_4"),@g("rack_inadv")), @eq(@g("ccloc_5"),@g("rack_inadv")), @eq(@g("ccloc_9"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_pro_ok"), @call(2117,"end_adv")), @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_46d")));
========

**TEST**
// [WE] Wink of an Eye - choose 'warp' or 'impulse'
@field bot = do_adv_47 : @s("gstate",116); @call(2117,"setmsg_wrpimp");

// to warp, SECURITY: Jones(16),Manning(17),Landon(18),Starfleet(0)
// TODO: Cadet-Sec(19) plus Kirk(1) plus Phaser 1 Kirk complication
@field bot = do_adv_47w :
  @call(2117,"echo_warp");
  @s("why_warp_ok","officer with Security");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_16"),@g("rack_inadv")),
      @eq(@g("ccloc_17"),@g("rack_inadv")),
      @eq(@g("ccloc_18"),@g("rack_inadv")),
      @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(
    @call(2117,"echo_warp_ok"), @call(2117,"do_adv_47w1")
    ),
    @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_47i"))
  );
-------
**TEST**
@field bot = do_adv_47w : @call(2117,"echo_warp"); @s("why_warp_ok","officer with Security"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_16"),@g("rack_inadv")), @eq(@g("ccloc_17"),@g("rack_inadv")), @eq(@g("ccloc_18"),@g("rack_inadv")), @eq(@g("ccloc_0"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_warp_ok"), @call(2117,"do_adv_47w1")), @print(@call(2117,"echo_warp_nok"), @call(2117,"do_adv_47i")));
=======

@field bot = do_adv_47w1 : [TODO: Take 3 more turns; calling a battle ends this adventure]
@field bot = do_adv_47i : [TODO: Take 2 more turns; calling a battle ends this adventure]
  @call(2117,"echo_impulse");

// [WNM] Where No Man Has Gone Before - no choice
@field bot = do_adv_48 : TODO

**TEST**
// [WM] Who Mourns for Adonais? - choose 'danger' or 'protect'
@field bot = do_adv_49 : @s("gstate",117); @call(2117,"setmsg_danpro");

// danger: reveal hand to all players.
@field bot = do_adv_49d :
  @call(2117,"echo_danger");
  @s("lstloc",@add(40,@g("whoclr_inadv")));
  @tellroom(@location("%#"),"",@print(
    "%n shows everyone the contents of %p hand. In the ",
    @g(@print("clrnam",@g("whoclr_inadv"))), " hand, you see ",
    @call(2117,"botlstbc"), "."
  ));
  @call(2117,"end_adv");
------
**TEST**
@field bot = do_adv_49d : @call(2117,"echo_danger"); @s("lstloc",@add(40,@g("whoclr_inadv"))); @tellroom(@location("%#"),"",@print("%n shows everyone the contents of %p hand. In the ", @g(@print("clrnam",@g("whoclr_inadv"))), " hand, you see ", @call(2117,"botlstbc"), ".")); @call(2117,"end_adv");
======

// to protect, must have SCOTT (2), PALAMAS (21), or CHEKOV (12)
@field bot = do_adv_49p :
  @call(2117,"echo_protect");
  @s("why_pro_ok","of Scott, Palamas, or Chekov");
  @s("rack_inadv",@add(40,@g("whoclr_inadv")));
  @switch(@or(@eq(@g("ccloc_2"),@g("rack_inadv")),
      @eq(@g("ccloc_21"),@g("rack_inadv")),
      @eq(@g("ccloc_12"),@g("rack_inadv"))),
   "1", @print(@call(2117,"echo_pro_ok"), @call(2117,"end_adv")),
   @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_49d")));
---------
**TEST**
@field bot = do_adv_49p : @call(2117,"echo_protect"); @s("why_pro_ok","of Scott, Palamas, or Chekov"); @s("rack_inadv",@add(40,@g("whoclr_inadv"))); @switch(@or(@eq(@g("ccloc_2"),@g("rack_inadv")), @eq(@g("ccloc_21"),@g("rack_inadv")), @eq(@g("ccloc_12"),@g("rack_inadv"))), "1", @print(@call(2117,"echo_pro_ok"), @call(2117,"end_adv")), @print(@call(2117,"echo_pro_nok"), @call(2117,"do_adv_49d")));
=========

// SET MESSAGES

@field bot = setmsg_danpro :
  @switch(@g("ndanpro"),0,
    @s("gb_msg", @print(
      "GameBoard asks ", @g("whorna_inadv"),
      ", \"", @g("whocna_inadv"),
      ", will you encounter the 'DANGER', or will you 'PROTECT' yourself?\"")),
    @s("gb_msg", @print(
      "GameBoard says (to ", @g("whorna_inadv"),
      "), \"", @g("whocna_inadv"), ", choose 'DANGER' or 'PROTECT'.\"")));
  @tellroom(@location("%#"),"",@g("gb_msg"));
  @s("ndanpro",1);

@field bot = setmsg_wrpimp :
  @switch(@g("nwrpimp"),0,
    @s("gb_msg", @print(
      "GameBoard asks ", @g("whorna_inadv"),
      ", \"", @g("whocna_inadv"),
      ", will you go to 'WARP' speed, or settle for 'IMPULSE'?\"")),
    @s("gb_msg", @print(
      "GameBoard says (to ", @g("whorna_inadv"),
      "), \"", @g("whocna_inadv"), ", choose 'WARP' or 'IMPULSE'.\"")));
  @tellroom(@location("%#"),"",@g("gb_msg"));
  @s("nwrpimp",1);

Action: space * (dbref #10571)

@action space * = bot : nowhere
@field space * = varobj : 2117
@set space * = puzzle
@desc space * = Selects one of the 20 adventure spaces. Several adventures
  will ask you to select a space for various reasons, eg: where to move
  a ship, or where to maroon a crewman. 'SPACE 15' selects adventure space 15.

// 1) Do a little cleanup on %0 (eg: allow leading #s or spaces).
@succ space * =
  @call(2117,"calc_whodbr_inadv");
  @s("space_chosen","%0");
  @switch(@substr("%0",0,1),"#",@s("space_chosen",@substr("%0",1)));
  @s("space_chosen",@add(0,@g("space_chosen")));
  @switch(@or(@lt(@g("space_chosen"),1),@gt(@g("space_chosen"),20)),
    "1",@print(@s("space_chosen",0),
      "[Invalid space. Adventure spaces are numbered from 1 to 20.]"));
  @switch(@gt(@g("space_chosen"),"0"), "1", @switch(@g("gstate"),
   6,@call(2117,"do_adv_0ws"), 7,@call(2117,"do_adv_0is1"),
   8,@call(2117,"do_adv_0is2"), 12,@call(2117,"do_adv_4s"),
   19,@call(2117,"do_adv_6ds"), 92,@call(2117,"do_adv_40ws"),
   98,@call(2117,"do_adv_41ws"), 108,@call(2117,"do_adv_44ws"),
   "['SPACE' is not a valid option at this time.]"
  ));
------
**TEST**
@succ space * = @call(2117,"calc_whodbr_inadv"); @s("space_chosen","%0"); @switch(@substr("%0",0,1),"#",@s("space_chosen",@substr("%0",1))); @s("space_chosen",@add(0,@g("space_chosen"))); @switch(@or(@lt(@g("space_chosen"),1),@gt(@g("space_chosen"),20)), "1",@print(@s("space_chosen",0), "[Invalid space. Adventure spaces are numbered from 1 to 20.]")); @switch(@gt(@g("space_chosen"),"0"), "1", @switch(@g("gstate"), 6,@call(2117,"do_adv_0ws"), 7,@call(2117,"do_adv_0is1"), 8,@call(2117,"do_adv_0is2"), 12,@call(2117,"do_adv_4s"), 19,@call(2117,"do_adv_6ds"), 92,@call(2117,"do_adv_40ws"), 98,@call(2117,"do_adv_41ws"), 108,@call(2117,"do_adv_44ws"), "['SPACE' is not a valid option at this time.]"));
======

Action: spec * (dbref #10569)

@action spec *;specialty * = bot : nowhere
@field spec * = varobj : 2117
@set spec * = puzzle
@desc spec * = Name a specialty in a "crew call", eg: 'SPEC SECURITY'.
  Note that you cannot call for the Command specialty.

@succ spec * = 
  @s("spec_chosen","-1");
  @switch("%0",{"commu","commun","communication"},@s("spec_chosen",2),
    {"med","medic","mecidine","medical"},@s("spec_chosen",3),
    {"nav","navig","navigation"},@s("spec_chosen",4),
    {"sci","scien","science"},@s("spec_chosen",5),
    {"sec","secur","security"},@s("spec_chosen",6),
    {"comma","command","cmnd"},"[The Command specialty cannot be called.]",
    "[Invalid specialty.]"
  );
  @switch(@gt(@g("spec_chosen"),"-1"), "1", @switch(@g("gstate"),
   53,@call(2117,"do_adv_23wy"), 85,@call(2117,"do_adv_37iy"),
   "['SPEC' is not a valid option at this time.]"
  ));
-----
**TEST**
@succ spec * = @s("spec_chosen","-1"); @switch("%0",{"commu","commun","communication"},@s("spec_chosen",2), {"med","medic","mecidine","medical"},@s("spec_chosen",3), {"nav","navig","navigation"},@s("spec_chosen",4), {"sci","scien","science"},@s("spec_chosen",5), {"sec","secur","security"},@s("spec_chosen",6), {"comma","command","cmnd"},"[The Command specialty cannot be called.]", "[Invalid specialty.]"); @switch(@gt(@g("spec_chosen"),"-1"), "1", @switch(@g("gstate"), 53,@call(2117,"do_adv_23wy"), 85,@call(2117,"do_adv_37iy"), "['SPEC' is not a valid option at this time.]"));
=====

Action: warp (#dbref #7081)

@action warp;do warp;pick warp;choose warp = bot : nowhere
@field warp = varobj : 2117
@desc warp = Choose to do the WARP half of a WARP/IMPULSE adventure.
  You must have one of the officers or the speciality named 
  (not counting cadets) to do so;
  however, which officer you are using for the adventure is not revealed.
  You are never forced to choose WARP, you can choose IMPULSE instead.

// - GameBot must be offering you the WARP/IMPULSE choice.
// TODO: make sure only whodbr_inadv uses this action.
@succ warp =
  @call(2117,"calc_whodbr_inadv");
  @switch(@g("gstate"),
    5, @call(2117,"do_adv_0w"), 9, @call(2117,"do_adv_1w"),
    13, @call(2117,"do_adv_5w"), 23, @call(2117,"do_adv_11w"),
    27, @call(2117,"do_adv_12w"), 35, @call(2117,"do_adv_16w"),
    41, @call(2117,"do_adv_20w"), 44, @call(2117,"do_adv_21w"),
    47, @call(2117,"do_adv_22w"), 51, @call(2117,"do_adv_23w"),
    60, @call(2117,"do_adv_26w"), 65, @call(2117,"do_adv_32w"),
    75, @call(2117,"do_adv_33w"), 82, @call(2117,"do_adv_37w"),
    90, @call(2117,"do_adv_40w"), 97, @call(2117,"do_adv_41w"),
    106, @call(2117,"do_adv_44w"), 116, @call(2117,"do_adv_47w"),
    "['WARP' isn't a valid option right now.]"
  )
--------
**TEST**
@succ warp = @call(2117,"calc_whodbr_inadv"); @switch(@g("gstate"), 5, @call(2117,"do_adv_0w"), 9, @call(2117,"do_adv_1w"), 13, @call(2117,"do_adv_5w"), 23, @call(2117,"do_adv_11w"), 27, @call(2117,"do_adv_12w"), 35, @call(2117,"do_adv_16w"), 41, @call(2117,"do_adv_20w"), 44, @call(2117,"do_adv_21w"), 47, @call(2117,"do_adv_22w"), 51, @call(2117,"do_adv_23w"), 60, @call(2117,"do_adv_26w"), 65, @call(2117,"do_adv_32w"), 75, @call(2117,"do_adv_33w"), 82, @call(2117,"do_adv_37w"), 90, @call(2117,"do_adv_40w"), 97, @call(2117,"do_adv_41w"), 106, @call(2117,"do_adv_44w"), 116, @call(2117,"do_adv_47w"), "['WARP' isn't a valid option right now.]")
========

Action: attack * (dbref #10511)

@action attack *;fight *;battle *;challenge * = bot : nowhere
@set attack * = puzzle
@field attack * = varobj : 2117
@desc attack * = Challenge another player to battle; eg: 'attack blue'.
  You may start a battle only once per turn and only during your turn.
  Also, you must either be given the opportunity to battle by an Adventure
  card, or be on a Tractor Zone space at the end of an Adventure.

@succ attack * = **TODO**

Action: back (dbref #10513)

@action back;move back;go back;backward;move backward;go backward = bot : nowhere
@field back = varobj : 2117
@desc back = Choose to move your ship in the backward direction.

// Note: call'd fns are responsible for ensuring that only the correct
//       player (inadv) can enter the prompted option.
@succ back =
  @switch(@g("gstate"),
    4, @call(2117,"phase1back"),
    99, @call(2117,"do_adv_41ia"),
    110, @call(2117,"do_adv_44ia"),
    "['BACK' is not a valid option at this time.]"
  );
-----
**TEST**
@succ back = @switch(@g("gstate"), 4, @call(2117,"phase1back"), 99, @call(2117,"do_adv_41ia"), 110, @call(2117,"do_adv_44ia"), "['BACK' is not a valid option at this time.]");
=====

Action: cardtype * (dbref #)

@action cardtype *;cardt *;ctype *;ct * = bot : nowhere
@field cardtype * = varobj : 2117
@set cardtype * = puzzle
@desc cardtype * = TODO

@succ cardtype * =
  @s("ct_chosen","");
  @switch("%0",
  {"ca","cochr","accel","cochr accel","cochrane",
    "acceleration","cochrane accleration"}, @s("ct_chosen","ca"),
  {"esc","escape"}, @s("ct_chosen","es"),
  {"mal","loop","matter","m-a loop"}, @s("ct_chosen","ma"),
  {"p1","phaser 1"}, @s("ct_chosen","p1"),
  {"p2","phaser 2"}, @s("ct_chosen","p2"),
  {"p3","phaser 3"}, @s("ct_chosen","p3"),
  {"pt","photo","photon","torpe","torpedo","photon torpedo"}, 
    @s("ct_chosen","pt"),
  {"s1","shield 1"}, @s("ct_chosen","s1"),
  {"s2","shield 2"}, @s("ct_chosen","s2"),
  {"tr","tract","tractor"}, @s("ct_chosen","tr"),
  {"w2","warp","warp 2"}, @s("ct_chosen","w2"),
  "[Not a valid cardtype. Valid cardtypes are:
    CA, ESC, MAL, P1, P2, P3, PT, S1, S2, TR, and W2.]"
  );
  @switch(@strlen(@g("ct_chosen")),2, @switch(@g("gstate"),
    24,@call(2117,"do_adv_11wt"), 26,@call(2117,"do_adv_11it"),
    56,@call(2117,"do_adv_23it"), 66,@call(2117,"do_adv_32wt1"),
    68,@call(2117,"do_adv_32wt2"), 70,@call(2117,"do_adv_32wt3"),
    73,@call(2117,"do_adv_32it"), 95,@call(2117,"do_adv_40it"),
    "['CARDTYPE' is not a valid option right now.]"
  ));
-----
**ADD**
@succ cardtype * = @s("ct_chosen",""); @switch("%0", {"ca","cochr","accel","cochr accel","cochrane","acceleration","cochrane accleration"}, @s("ct_chosen","ca"), {"esc","escape"}, @s("ct_chosen","es"), {"mal","loop","matter","m-a loop"}, @s("ct_chosen","ma"), {"p1","phaser 1"}, @s("ct_chosen","p1"), {"p2","phaser 2"}, @s("ct_chosen","p2"), {"p3","phaser 3"}, @s("ct_chosen","p3"), {"pt","photo","photon","torpe","torpedo","photon torpedo"}, @s("ct_chosen","pt"), {"s1","shield 1"}, @s("ct_chosen","s1"), {"s2","shield 2"}, @s("ct_chosen","s2"), {"tr","tract","tractor"}, @s("ct_chosen","tr"), {"w2","warp","warp 2"}, @s("ct_chosen","w2"), "[Not a valid cardtype. Valid cardtypes are: CA, ESC, MAL, P1, P2, P3, PT, S1, S2, TR, and W2.]"); @switch(@strlen(@g("ct_chosen")),2, @switch(@g("gstate"), 24,@call(2117,"do_adv_11wt"), 26,@call(2117,"do_adv_11it"), 56,@call(2117,"do_adv_23it"), 66,@call(2117,"do_adv_32wt1"), 68,@call(2117,"do_adv_32wt2"), 70,@call(2117,"do_adv_32wt3"), 73,@call(2117,"do_adv_32it"), 95,@call(2117,"do_adv_40it"), "['CARDTYPE' is not a valid option right now.]"));
=====

Action: crew * (dbref #10126)

@action crew *;crewman *;crewmember * = bot : nowhere
@field crew * = varobj : 2117
@set crew * = puzzle
@desc crew * = Name a crewman, eg: "crew kirk". Crew names may be abbreviated
  to five letters, eg: "crew starf" is the same as "crew starfleet".
  Cadets must be referred to by their specialty, eg: "crew cadet security",
  or "crew cadet secur", or just "crew secur".

// NOTE: sets value of crew_chosen
@succ crew * =
  @s("crew_chosen","-1");
  @switch("%0",{"starfleet","starf"},@s("crew_chosen",0),
    "kirk",@s("crew_chosen",1), {"scott","scotty"},@s("crew_chosen",2),
    "spock",@s("crew_chosen",3), "uhura",@s("crew_chosen",4),
    "kyle",@s("crew_chosen",5), "rand",@s("crew_chosen",6),
    {"cadet communication","cadet commun","cadet commu",
    "communication","commun","commu"},@s("crew_chosen",7),
    {"mccoy","bones"},@s("crew_chosen",8),
    {"chapel","chape"},@s("crew_chosen",9), "noel",@s("crew_chosen",10),
    {"cadet medicine","cadet medical","cadet medic","cadet med",
    "medicine","medical","medic","med"},@s("crew_chosen,11),
    {"chekov","cheko"},@s("crew_chosen,12), "riley",@s("crew_chosen",13),
    "sulu",@s("crew_chosen",14),
    {"cadet navigation","cadet navig","cadet nav",
    "navigation","navig","nav"},@s("crew_chosen",15),
    "jones",@s("crew_chosen",16), {"manning","manni"},@s("crew_chosen",17),
    {"landon","lando"},@s("crew_chosen",18),
    {"cadet security","cadet secur","cadet sec",
    "security","secur","sec"},@s("crew_chosen",19),
    {"barrows","barro"},@s("crew_chosen",20),
    {"palamas","palam"},@s("crew_chosen",21),
    {"romaine","romai"},@s("crew_chosen",22),
    {"cadet science","cadet scien","cadet sci",
    "science","scien","sci"},@s("crew_chosen",23),
    "cadet","[That's ambiguous. Refer to cadets by their specialty,
    eg: 'CREW CADET COMMUNICATION', or 'CREW COMMU' for short.]",
    "[Invalid crew name.]"
  );
  @switch(@gt(@g("crew_chosen"),"-1"), "1", @switch(@g("gstate"),
   11, @call(2117,"do_adv_3c"), 17, @call(2117,"do_adv_6dc"),
   33, @call(2117,"do_adv_14dc"), 39, @call(2117,"do_adv_19c"),
   53, @call(2117,"do_adv_23wc1"), 54, @call(2117,"do_adv_23wc2"),
   61, @call(2117,"do_adv_27c"), 80, @call(2117,"do_adv_35dc"),
   85, @call(2117,"do_adv_37ic"), 93, @call(2117,"do_adv_40wc"),
   118, @call(2117,"do_adv_23wc3"),
   "['CREW' is not a valid option at this time.]"
  ));
-----
**TEST**
@succ crew * = @s("crew_chosen","-1"); @switch("%0",{"starfleet","starf"},@s("crew_chosen",0), "kirk",@s("crew_chosen",1), {"scott","scotty"},@s("crew_chosen",2), "spock",@s("crew_chosen",3), "uhura",@s("crew_chosen",4), "kyle",@s("crew_chosen",5), "rand",@s("crew_chosen",6), {"cadet communication","cadet commun","cadet commu","communication","commun","commu"},@s("crew_chosen",7), {"mccoy","bones"},@s("crew_chosen",8), {"chapel","chape"},@s("crew_chosen",9), "noel",@s("crew_chosen",10), {"cadet medicine","cadet medical","cadet medic","cadet med","medicine","medical","medic","med"},@s("crew_chosen,11), {"chekov","cheko"},@s("crew_chosen,12), "riley",@s("crew_chosen",13), "sulu",@s("crew_chosen",14), {"cadet navigation","cadet navig","cadet nav","navigation","navig","nav"},@s("crew_chosen",15), "jones",@s("crew_chosen",16), {"manning","manni"},@s("crew_chosen",17), {"landon","lando"},@s("crew_chosen",18), {"cadet security","cadet secur","cadet sec","security","secur","sec"},@s("crew_chosen",19), {"barrows","barro"},@s("crew_chosen",20), {"palamas","palam"},@s("crew_chosen",21), {"romaine","romai"},@s("crew_chosen",22), {"cadet science","cadet scien","cadet sci","science","scien","sci"},@s("crew_chosen",23), "cadet","[That's ambiguous. Refer to cadets by their specialty, eg: 'CREW CADET COMMUNICATION', or 'CREW COMMU' for short.]", "[Invalid crew name.]"); @switch(@gt(@g("crew_chosen"),"-1"), "1", @switch(@g("gstate"), 11, @call(2117,"do_adv_3c"), 17, @call(2117,"do_adv_6dc"), 33, @call(2117,"do_adv_14dc"), 39, @call(2117,"do_adv_19c"), 53, @call(2117,"do_adv_23wc1"), 54, @call(2117,"do_adv_23wc2"), 61, @call(2117,"do_adv_27c"), 80, @call(2117,"do_adv_35dc"), 85, @call(2117,"do_adv_37ic"), 93, @call(2117,"do_adv_40wc"), "['CREW' is not a valid option at this time.]"));
=====

Action: danger (dbref #10507)

@action danger;do danger;pick danger;choose danger = bot : nowhere
@field danger = varobj : 2117
@desc danger = Choose to do the DANGER half of a DANGER/PROTECT adventure.
  You may be forced to choose DANGER because you don't have the necessary
  officers or specialty to choose PROTECT; however, GameBoard still offers you
  the choice so other players aren't told that explicitly.

// - GameBot must be offering you the DANGER/PROTECT choice.
**TEST**
@succ danger =
  @call(2117,"calc_whodbr_inadv");
  @switch(@g("whodbr_inadv"),"%#",
    @switch(@g("gstate"),
      16, @call(2117,"do_adv_6d"), 20, @call(2117,"do_adv_7d"),
      21, @call(2117,"do_adv_8d"), 31, @call(2117,"do_adv_13d"),
      32, @call(2117,"do_adv_14d"), 34, @call(2117,"do_adv_15d"),
      58, @call(2117,"do_adv_24d"), 63, @call(2117,"do_adv_29d"),
      79, @call(2117,"do_adv_35d"), 86, @call(2117,"do_adv_38d"),
      100, @call(2117,"do_adv_42d"), 102, @call(2117,"do_adv_43d"),
      111, @call(2117,"do_adv_45d"), 113, @call(2117,"do_adv_46d"),
      117, @call(2117,"do_adv_49d"),
      "['DANGER' isn't a valid option right now.]"
    ),
    "['DANGER' isn't a valid option for you right now.]"
  );
------
@succ danger = @call(2117,"calc_whodbr_inadv"); @switch(@g("whodbr_inadv"),"%#", @switch(@g("gstate"), 16, @call(2117,"do_adv_6d"), 20, @call(2117,"do_adv_7d"), 21, @call(2117,"do_adv_8d"), 31, @call(2117,"do_adv_13d"), 32, @call(2117,"do_adv_14d"), 34, @call(2117,"do_adv_15d"), 58, @call(2117,"do_adv_24d"), 63, @call(2117,"do_adv_29d"), 79, @call(2117,"do_adv_35d"), 86, @call(2117,"do_adv_38d"), 100, @call(2117,"do_adv_42d"), 102, @call(2117,"do_adv_43d"), 111, @call(2117,"do_adv_45d"), 113, @call(2117,"do_adv_46d"), 117, @call(2117,"do_adv_49d"), "['DANGER' isn't a valid option right now.]"), "['DANGER' isn't a valid option for you right now.]");
======

Action: deck (dbref #10566)

@action deck = bot : nowhere
@field deck = varobj : 2117
@desc deck = Choose to get a card from the deck, instead of a player.

@succ deck = **TODO**
  @switch(@g("gstate"),
    36,@call(2117,"do_adv_16wk1"), 37,@call(2117,"do_adv_16wk2"),
    42,@call(2117,"do_adv_20wk1"), 43,@call(2117,"do_adv_20wk2"),
    76,@call(2117,"do_adv_33wk1"), 77,@call(2117,"do_adv_33wk2"),
    "['DECK' is not a valid option at this time.]"
  );

Action: forward (dbref #10514)

@action forward;move forward;go forward = bot : nowhere
@field forward = varobj : 2117
@desc forward = Choose to move your ship in the forward direction.

// Note: call'd fns are responsible for ensuring that only the correct
//       player can enter the prompted option.
@succ forward =
  @switch(@g("gstate"),
    4, @call(2117,"phase1forw"),
    99, @call(2117,"do_adv_41if"),
    110, @call(2117,"do_adv_44if"),
    "['FORWARD' is not a valid option at this time.]"
  );
-----
**TEST**
@succ forward = @switch(@g("gstate"), 4, @call(2117,"phase1forw"), 99, @call(2117,"do_adv_41if"), 110, @call(2117,"do_adv_44if"), "['FORWARD' is not a valid option at this time.]");
=====

Action: impulse (dbref #10506)

@action impulse;do impulse;pick impulse;choose impulse = bot : nowhere
@field impulse = varobj : 2117
@desc impulse = Choose to do the IMPULSE half of a WARP/IMPULSE adventure.
  You may be forced to choose IMPULSE because you don't have the necessary
  officers or specialty to choose WARP; however, GameBoard still offers you
  the choice so other players aren't told that explicitly.

**TEST**
// - GameBot must be offering you the WARP/IMPULSE choice.
@succ impulse =
  @call(2117,"calc_whodbr_inadv");
  @switch(@g("whodbr_inadv"),"%#",
    @switch(@g("gstate"),
    5, @call(2117,"do_adv_0i"), 9, @call(2117,"do_adv_1i"),
    13, @call(2117,"do_adv_5i"), 23, @call(2117,"do_adv_11i"),
    27, @call(2117,"do_adv_12i"), 35, @call(2117,"do_adv_16i"),
    41, @call(2117,"do_adv_20i"), 44, @call(2117,"do_adv_21i"),
    47, @call(2117,"do_adv_22i"), 51, @call(2117,"do_adv_23i"),
    60, @call(2117,"do_adv_26i"), 65, @call(2117,"do_adv_32i"),
    75, @call(2117,"do_adv_33i"), 82, @call(2117,"do_adv_37i"),
    90, @call(2117,"do_adv_40i"), 97, @call(2117,"do_adv_41i"),
    106, @call(2117,"do_adv_44i"), 116, @call(2117,"do_adv_47i"),
    "['IMPULSE' isn't a valid option right now.]"
    ),
  "['IMPULSE' isn't a valid option for you right now.]"
  );
------
@succ impulse = @call(2117,"calc_whodbr_inadv"); @switch(@g("whodbr_inadv"),"%#", @switch(@g("gstate"), 5, @call(2117,"do_adv_0i"), 9, @call(2117,"do_adv_1i"), 13, @call(2117,"do_adv_5i"), 23, @call(2117,"do_adv_11i"), 27, @call(2117,"do_adv_12i"), 35, @call(2117,"do_adv_16i"), 41, @call(2117,"do_adv_20i"), 44, @call(2117,"do_adv_21i"), 47, @call(2117,"do_adv_22i"), 51, @call(2117,"do_adv_23i"), 60, @call(2117,"do_adv_26i"), 65, @call(2117,"do_adv_32i"), 75, @call(2117,"do_adv_33i"), 82, @call(2117,"do_adv_37i"), 90, @call(2117,"do_adv_40i"), 97, @call(2117,"do_adv_41i"), 106, @call(2117,"do_adv_44i"), 116, @call(2117,"do_adv_47i"), "['IMPULSE' isn't a valid option right now.]"), "['IMPULSE' isn't a valid option for you right now.]");
======

Action: pass (dbref #10515)

@action pass;forgo = bot : nowhere
@field pass = varobj : 2117
@desc pass = Pass on an opportunity of the moment, eg: fighting a battle, or playing a Battle-card's special effect.

@succ pass = **TODO**

Action: play * (dbref #10504)

@action play * = bot : nowhere
@field play * = varobj : 2117
@set play * = puzzle
@desc play * = Play the named card, eg: 'play p1 jones'.

@succ play * =
  // Check that he's carrying a game hand
  @switch("%#",{@location("10491"),@location("10492"),
    @location("10493"),@location("10494")},
  // If so, figure out which cardtype, and handle it.
  @switch("%0",
  {"ca","cochr","accel","cochr accel","cochrane",
    "acceleration","cochrane accleration"}, @call("2117","play_ca"),
  {"esc","escape"}, @call("2117","play_esc"),
  {"mal","loop","matter","m-a loop"}, @call("2117","play_mal"),
  "phaser", @call("2117","play_phaser"),
  {"p1","phaser 1"}, @call("2117","play_p1"),
  {"p1 uhura","phaser 1 uhura"}, @call("2117","play_p1_uhura"),
  "uhura", @call("2117","play_uhura"),
  {"p1 sulu","phaser 1 sulu"}, @call("2117","play_p1_sulu"),
  "sulu", @call("2117","play_sulu"),
  {"p1 spock","phaser 1 spock"}, @call("2117","play_p1_spock"),
  "spock", @call("2117","play_spock"),
  {"p1 scott","p1 scotty","phaser 1 scott","phaser 1 scotty"},
    @call("2117","play_p1_scott"),
  {"scott","scotty"}, @call("2117","play_scott"),
  {"p1 mccoy","p1 bones","phaser 1 mccoy","phaser 1 bones"},
    @call("2117","play_mccoy"),
  {"mccoy","bones"}, @call("2117","play_mccoy"),
  {"p1 manni","p1 manning","phaser 1 manni","phaser 1 manning"},
    @call("2117","play_p1_manni"),
  {"manni","manning"}, @call("2117","play_manni"),
  {"p1 lando","p1 landon","phaser 1 lando","phaser 1 landon"}, 
    @call("2117","play_p1_lando"),
  {"lando","landon"}, @call("2117","play_lando"),
  {"p1 kirk","phaser 1 kirk"}, @call("2117","play_p1_kirk"),
  "kirk", @call("2117","play_kirk"),
  {"p1 jones","phaser 1 jones"}, @call("2117","play_p1_jones"),
  "jones", @call("2117","play_jones"),
  {"p1 cheko","p1 chekov","phaser 1 cheko","phaser 1 chekov"},
    @call("2117","play_p1_cheko"),
  {"cheko","chekov"}, @call("2117","play_cheko"),
  {"p1 chape","p1 chapel","phaser 1 chape","phaser 1 chapel"},
    @call("2117","play_p1_chape"),
  {"chape","chapel"}, @call("2117","play_chape"),
  {"p1 barro","p1 barrows","phaser 1 barro","phaser 1 barrows"},
    @call("2117","play_p1_barro"),
  {"barro","barrows"}, @call("2117","play_barro"),
  {"p1 riley","phaser 1 riley"}, @call("2117","play_p1_riley"),
  "riley", @call("2117","play_riley"),
  {"p1 rand","phaser 1 rand"}, @call("2117","play_p1_rand"),
  "rand", @call("2117","play_rand"),
  {"p1 palam","p1 palamas","phaser 1 palam","phaser 1 palamas"},
    @call("2117","play_p1_palam"),
  {"palam","palamas"}, @call("2117","play_palam"),
  {"p2","phaser 2"}, @call("2117","play_p2"),
  {"p3","phaser 3"}, @call("2117","play_p3"),
  {"p3 noel","phaser 3 noel"}, @call("2117","play_p3_noel"),
  "noel", @call("2117","play_noel"),
  {"pt","photo","photon","torpe","torpedo","photon torpedo"}, 
    @call("2117","play_pt"),
  {"pt kyle","photo kyle","photon kyle","torpe kyle","torpedo kyle",
    "photon torpedo kyle"}, @call("2117","play_pt_kyle"),
  "kyle", @call("2117","play_kyle"),
  {"shiel","shield"}, @call("2117","play_shield"),
  {"s1","shield 1"}, @call("2117","play_s1"),
  {"s2","shield 2"}, @call("2117","play_s2"),
  {"tr","tract","tractor"}, @call("2117","play_tr"),
  {"w2","warp","warp 2"}, @call("2117","play_w2"),
  {"w2 romai","warp romai","warp 2 romai","w2 romaine","warp romaine",
   "warp 2 romaine"}, @call("2117","play_w2_romai"),
  {"romai","romaine"}, @call("2117","play_romai"),
  "GameBoard whispers (to you), \"Play what card?\""),
  "GameBoard whispers (to you), \"But you're not holding a hand to play 
  a card from!\""
);

**TODO**
// PLAY COCHRANE ACCELERATION
// effect:
// - same as Phaser 1, then one forward move
// restrictions on use:
// - must have the card
// - must be in his own battle turn
// - must not have already played a battle card in this battle turn
// - must not have already moved in this battle turn
@field bot = play_ca :

**TODO**
@field bot = play_esc :

**TODO**
@field bot = play_mal :

**TODO**
@field bot = play_phaser :

**TODO**
@field bot = play_p1 :

**TODO**
@field bot = play_p1_uhura :

**TODO**
@field bot = play_uhura :

**TODO**
@field bot = play_p1_sulu :

**TODO**
@field bot = play_sulu :

**TODO**
@field bot = play_p1_spock :

**TODO**
@field bot = play_spock :

**TODO**
@field bot = play_p1_scott :

**TODO**
@field bot = play_scott :

**TODO**
@field bot = play_p1_mccoy :

**TODO**
@field bot = play_mccoy :

**TODO**
@field bot = play_p1_manni :

**TODO**
@field bot = play_manni :

**TODO**
@field bot = play_p1_lando :

**TODO**
@field bot = play_lando :

**TODO**
@field bot = play_p1_kirk :

**TODO**
@field bot = play_kirk :

**TODO**
@field bot = play_p1_jones :

**TODO**
@field bot = play_jones :

**TODO**
@field bot = play_p1_cheko :

**TODO**
@field bot = play_cheko :

**TODO**
@field bot = play_p1_chape :

**TODO**
@field bot = play_chape :

**TODO**
@field bot = play_p1_barro :

**TODO**
@field bot = play_barro :

**TODO**
@field bot = play_p1_riley :

**TODO**
@field bot = play_riley :

**TODO**
@field bot = play_p1_rand :

**TODO**
@field bot = play_rand :

**TODO**
@field bot = play_p1_palam :

**TODO**
@field bot = play_palam :

**TODO**
@field bot = play_p2 :

**TODO**
@field bot = play_p3 :

**TODO**
@field bot = play_p3_noel :

**TODO**
@field bot = play_noel :

**TODO**
@field bot = play_pt :

**TODO**
@field bot = play_pt_kyle :

**TODO**
@field bot = play_kyle :

**TODO**
@field bot = play_shield :

**TODO**
@field bot = play_s1 :

**TODO**
@field bot = play_s2 :

**TODO**
@field bot = play_tr :

**TODO**
@field bot = play_w2 :

**TODO**
@field bot = play_w2_romai :

**TODO**
@field bot = play_romai :

Action: player * (dbref #10533)

@action player *;color *;colour * = bot : nowhere
@field player * = varobj : 2117
@set player * = puzzle
@desc player * = Choose one of the four players, eg: 'PLAYER RED'.

@succ player * =
  // 1st, make sure the argument is a color word.
  @switch("%0",{"blue","b"},@s("whoclr_chosen",1),
    {"red","r"},@s("whoclr_chosen",2),
    {"green","g"},@s("whoclr_chosen",3),
    {"yellow","y"},@s("whoclr_chosen",4),
    @print(@s("whoclr_chosen",0), @call(2117,"list_clropts2"))
  );
  // 2nd, make sure the color is one that was set "chooseable"
  // eg: BLUE is choosable iff @g("isclropt1") equals "1"
  @switch(@g("whoclr_chosen"), {1,2,3,4},
    @switch(@g(@print("isclropt",@g("whoclr_chosen"))), "1", "", @print(
      @s("whoclr_chosen",0), @call(2117,"list_clropts2")
  )));
  @call(2117,"calc_whodbr_chosen");
  // 3rd, gstate branch
  @switch(@g("whoclr_chosen"), {1,2,3,4},
   @switch(@g("gstate"), 14,@call(2117,"do_adv_5wp"),
    15,@call(2117,"do_adv_5ip"), 18,@call(2117,"do_adv_6dp"),
    22,@call(2117,"do_adv_8dp"), 25,@call(2117,"do_adv_11ip"),
    28,@call(2117,"do_adv_12wp"), 29,@call(2117,"do_adv_12ip"),
    36,@call(2117,"do_adv_16wp1"), 37,@call(2117,"do_adv_16wp2"),
    40,@call(2117,"do_adv_19p"), 42,@call(2117,"do_adv_20wp1"),
    43,@call(2117,"do_adv_20wp2"), 48,@call(2117,"do_adv_22wp"),
    50,@call(2117,"do_adv_22ip"), 52,@call(2117,"do_adv_23wp"),
    55,@call(2117,"do_adv_23ip"), 59,@call(2117,"do_adv_24dp"),
    64,@call(2117,"do_adv_30p"), 72,@call(2117,"do_adv_32ip"),
    76,@call(2117,"do_adv_33wp1"), 77,@call(2117,"do_adv_33wp2"),
    81,@call(2117,"do_adv_35dp"), 83,@call(2117,"do_adv_37wp"),
    84,@call(2117,"do_adv_37ip"), 87,@call(2117,"do_adv_38dp"),
    88,@call(2117,"do_adv_39p1"), 89,@call(2117,"do_adv_39p2"),
    91,@call(2117,"do_adv_40wp"), 94,@call(2117,"do_adv_40ip"),
    101,@call(2117,"do_adv_42dp"), 107,@call(2117,"do_adv_44wp"),
    109,@call(2117,"do_adv_44ip"), 114,@call(2117,"do_adv_46dp"),
    "['PLAYER' is not a valid action at this time.]"
  ));
---------
**TEST**
@succ player * = @switch("%0",{"blue","b"},@s("whoclr_chosen",1), {"red","r"},@s("whoclr_chosen",2), {"green","g"},@s("whoclr_chosen",3), {"yellow","y"},@s("whoclr_chosen",4), @print(@s("whoclr_chosen",0), @call(2117,"list_clropts2"))); @switch(@g("whoclr_chosen"), {1,2,3,4}, @switch(@g(@print("isclropt",@g("whoclr_chosen"))), "1", "", @print(@s("whoclr_chosen",0), @call(2117,"list_clropts2")))); @call(2117,"calc_whodbr_chosen"); @switch(@g("whoclr_chosen"), {1,2,3,4}, @switch(@g("gstate"), 14,@call(2117,"do_adv_5wp"), 15,@call(2117,"do_adv_5ip"), 18,@call(2117,"do_adv_6dp"), 22,@call(2117,"do_adv_8dp"), 25,@call(2117,"do_adv_11ip"), 28,@call(2117,"do_adv_12wp"), 29,@call(2117,"do_adv_12ip"), 36,@call(2117,"do_adv_16wp1"), 37,@call(2117,"do_adv_16wp2"), 40,@call(2117,"do_adv_19p"), 42,@call(2117,"do_adv_20wp1"), 43,@call(2117,"do_adv_20wp2"), 48,@call(2117,"do_adv_22wp"), 50,@call(2117,"do_adv_22ip"), 52,@call(2117,"do_adv_23wp"), 55,@call(2117,"do_adv_23ip"), 59,@call(2117,"do_adv_24dp"), 64,@call(2117,"do_adv_30p"), 72,@call(2117,"do_adv_32ip"), 76,@call(2117,"do_adv_33wp1"), 77,@call(2117,"do_adv_33wp2"), 81,@call(2117,"do_adv_35p"), 83,@call(2117,"do_adv_37wp"), 84,@call(2117,"do_adv_37ip"), 87,@call(2117,"do_adv_38dp"), 88,@call(2117,"do_adv_39p1"), 89,@call(2117,"do_adv_39p2"), 91,@call(2117,"do_adv_40wp"), 94,@call(2117,"do_adv_40ip"), 101,@call(2117,"do_adv_42dp"), 107,@call(2117,"do_adv_44wp"), 109,@call(2117,"do_adv_44ip"), 114,@call(2117,"do_adv_46dp"), "['PLAYER' is not a valid action at this time.]"));
=========

@field bot = list_clropts :
  @switch(@g("isclropt1"),1," 'PLAYER BLUE'?");
  @switch(@g("isclropt2"),1," 'PLAYER RED'?");
  @switch(@g("isclropt3"),1," 'PLAYER GREEN'?");
  @switch(@g("isclropt4"),1," 'PLAYER YELLOW'?");
------
**TEST**
@field bot = list_clropts : @switch(@g("isclropt1"),1," 'PLAYER BLUE'?"); @switch(@g("isclropt2"),1," 'PLAYER RED'?"); @switch(@g("isclropt3"),1," 'PLAYER GREEN'?"); @switch(@g("isclropt4"),1," 'PLAYER YELLOW'?");
======

@field bot = list_clropts2 :
  @print("[Current 'PLAYER' options are:",
    @switch(@g("isclropt1"),"1"," BLUE"),
    @switch(@g("isclropt2"),"1"," RED"),
    @switch(@g("isclropt3"),"1"," GREEN"),
    @switch(@g("isclropt4"),"1"," YELLOW"),
    ". If no options were listed, 'PLAYER' is not a valid action at this time.]"
  );
--------
**TEST**
@field bot = list_clropts2 : @print("[Current 'PLAYER' options are:", @switch(@g("isclropt1"),"1"," BLUE"), @switch(@g("isclropt2"),"1"," RED"), @switch(@g("isclropt3"),"1"," GREEN"), @switch(@g("isclropt4"),"1"," YELLOW"), ". If no options were listed, 'PLAYER' is not a valid action at this time.]");
========

Action: protect (dbref #10508)

@action protect;do protect;pick protect;choose protect = bot : nowhere
@field protect = varobj : 2117
@desc protect = Choose to do the PROTECT half of a DANGER/PROTECT adventure.
  You must have one of the officers or the speciality named 
  (not counting cadets) to do so;
  however, which officer you are using for the adventure is not revealed.
  You are never forced to choose PROTECT, you can choose DANGER instead.

// - GameBot must be offering you the DANGER/PROTECT choice.
**TEST**
@succ protect =
  @call(2117,"calc_whodbr_inadv");
  @switch(@g("whodbr_inadv"),"%#",
  @switch(@g("gstate"),
    16, @call(2117,"do_adv_6p"), 20, @call(2117,"do_adv_7p"),
    21, @call(2117,"do_adv_8p"), 31, @call(2117,"do_adv_13p"),
    32, @call(2117,"do_adv_14p"), 34, @call(2117,"do_adv_15p"),
    58, @call(2117,"do_adv_24p"), 63, @call(2117,"do_adv_29p"),
    79, @call(2117,"do_adv_35p"), 86, @call(2117,"do_adv_38p"),
    100, @call(2117,"do_adv_42p"), 102, @call(2117,"do_adv_43p"),
    111, @call(2117,"do_adv_45p"), 113, @call(2117,"do_adv_46p"),
    117, @call(2117,"do_adv_49p"),
    "['PROTECT' isn't a valid option right now.]"
  ),
  "['PROTECT' isn't a valid option for you right now.]"
  );
------
@succ protect = @call(2117,"calc_whodbr_inadv"); @switch(@g("whodbr_inadv"),"%#", @switch(@g("gstate"), 16, @call(2117,"do_adv_6p"), 20, @call(2117,"do_adv_7p"), 21, @call(2117,"do_adv_8p"), 31, @call(2117,"do_adv_13p"), 32, @call(2117,"do_adv_14p"), 34, @call(2117,"do_adv_15p"), 58, @call(2117,"do_adv_24p"), 63, @call(2117,"do_adv_29p"), 79, @call(2117,"do_adv_35p"), 86, @call(2117,"do_adv_38p"), 100, @call(2117,"do_adv_42p"), 102, @call(2117,"do_adv_43p"), 111, @call(2117,"do_adv_45p"), 113, @call(2117,"do_adv_46p"), 117, @call(2117,"do_adv_49p"), "['PROTECT' isn't a valid option right now.]"), "['PROTECT' isn't a valid option for you right now.]");
======

Bookkeeping

//  Location codes                              Position codes within Loc
//  -----------------------------------------+----------------------------
//  0      a DECK                            |  0..n-1 = top..bottom
//  1..20  Adventures spaces 1..20           |  0..n-1 = left..right
//  21     The Battle Vortex                 |  0 = Mind Meld, 1..6 = Track
//  41     Blue Base World/Bridge Rack/Hand  |  0..n-1 = left..right
//  42     Red Base World/Bridge Rack/Hand   |  0..n-1 = left..right
//  43     Green Base World/Bridge Rack/Hand |  0..n-1 = left..right
//  44     Yellow Base World/Bridge Rack/Hand|  0..n-1 = left..right
//  99     a DISCARD pile                    |  0..n-1 = top..bottom

// Finicky Bits
// ---------------
// stddir : Standard Direction that ship are currently travelling.
//          0 = clockwise around the board; 1 = counterclockwise.
// nowdir : Direction to move ship now.
//		0 = clockwise; 1 = counterclockwise.

@field bot = clrnam1 : blue
@field bot = clrnam2 : red
@field bot = clrnam3 : green
@field bot = clrnam4 : yellow

The State Machine

// GAME STATE (gstate)
// -------------------------------------------------------
// 0 = No game in progress. GameBot is waiting for 'new'.
// 1 = In setup, players are choosing colors. GameBot is waiting for 'ok'.
// 2 = In setup, GameBot has dealt cards, crews. GameBot is waiting for 'ok'.
// 3 = Movement phase of turn. GameBot is waiting for 'roll'.
// 4 = Movement phase of turn. GameBot is waiting for 'forward' or 'back'.
//     (This is part of that _exploring new worlds_ business.)
// 5 = Adv 0 [AE]. GameBot is waiting for 'warp' or 'impulse'.
// 6 = Adv 0 [AE]-WRP. GameBot is waiting for 'space #' (to get crew)
// 7 = Adv 0 [AE]-IMP. GameBot is waiting for 'space #' (to see a crew)
// 8 = Adv 0 [AE]-IMP. GameBot is waiting for 'space #' (to maroon)
// 9 = Adv 1 [AON]. GameBot is waiting for 'warp' or 'impulse'
// 10 = Adv 1 [AON]-WRP. choice of # (1..6) to move
// -- = Adv 2 [Ar] (gstate not needed)
// 11 = Adv 3 [AT] choice of crewman to maroon.
// 12 = Adv 4 [AY] choice of space# to put this adv card
// 13 = Adv 5 [BT] choice of 'warp' or 'impulse'
// 14 = Adv 5 [BT]-WRP. choice of player to battle
// 15 = Adv 5 [BT]-IMP. choice of player to battle
// 16 = Adv 6 [CK]. choice of 'danger' or 'protect'
// 17 = Adv 6 [CK]-DAN. choice of crewman to maroon.
// 18 = Adv 6 [CK]-DAN. choice of Least Crew player (if tie)
// 19 = Adv 6 [CK]-DAN. "Least Crew" player's choice of space#.
// 20 = Adv 7 [CMl]. choice of 'danger' or 'protect'
// 21 = Adv 8 [CMn]. choice of 'danger' or 'protect'
// 22 = Adv 8 [CMn]-DAN. choice of player to battle
// -- = Adv 9 [Cms]. (no gstate needed)
// -- = Adv 10 [Cp]. (no gstate needed)
// 23 = Adv 11 [CX]. choice of 'warp' or 'impulse'
// 24 = Adv 11 [CX]-WRP. choice of type of card
// 25 = Adv 11 [CX]-IMP. choice of player to get card from
// 26 = Adv 11 [CX]-IMP. choice of type of card
// 27 = Adv 12 [DD]. choice of 'warp' or 'impulse'
// 28 = Adv 12 [DD]-WRP. choice of player
// 29 = Adv 12 [DD]-IMP. choice of player
// 30 = Adv 12 [DD]-IMP. Chosen player must choose a card to discard.
// 31 = Adv 13 [DMa]. choice of 'danger' or 'protect'
// 32 = Adv 14 [DMd]. choice of 'danger' or 'protect'
// 33 = Adv 14 [DMd]-DAN. choice of crewman to reveal
// 34 = Adv 15 [DY]. choice of 'danger' or 'protect'
// 35 = Adv 16 [EI]. choice of 'warp' or 'impulse'
// 36 = Adv 16 [EI]-WRP. choice of player or deck to get 1st card
// 37 = Adv 16 [EI]-WRP. choice of player or deck to get 2nd card
// 38 = Adv 17 [EM]. choose a card to give away
// -- = Adv 18 [ET]. (gstate not needed)
// 39 = Adv 19 [EW]. choice of crewman with Command
// 40 = Adv 19 [EW]. choice of Least Crew player (if tie)
// 41 = Adv 20 [FC]. choice of warp or impulse
// 42 = Adv 20 [FC]-WRP. choice of player or deck to get 1st card
// 43 = Adv 20 [FC]-WRP. choice of player or deck to get 2nd card
// 44 = Adv 21 [FW]. choice of warp or impulse
// 45 = Adv 21 [FW]-IMP. choice of 1st card to discard
// 46 = Adv 21 [FW]-IMP. choice of 2nd card to discard
// 47 = Adv 22 [GT]. choice of warp or impulse
// 48 = Adv 22 [GT]-WRP. choice of player
// 49 = Adv 22 [GT]-WRP. choice of 'trade cardname for cardname' or 'ok'
// 50 = Adv 22 [GT]-IMP. choice of player
// 51 = Adv 23 [LZ]. choice of 'warp' or 'impulse'
// 52 = Adv 23 [LZ]-WRP. choose a player to make a crew call against
// 53 = Adv 23 [LZ]-WRP. choose a crewname/specialty to call
// 54 = Adv 23 [LZ]-WRP. choose a crewman to give away in trade
// 55 = Adv 23 [LZ]-IMP. choose a player to make a card call against
// 56 = Adv 23 [LZ]-IMP. choose a card type to call
// 57 = Adv 23 [LZ]-IMP. choose a card to give away in trade
// 58 = Adv 24 [Me]. choose 'danger' or 'protect'
// 59 = Adv 24 [Me]-DAN. choose Least Crew player (if a tie)
// -- = Adv 25 [Met]. (gstate not needed)
// 60 = Adv 26 [MM]. choose 'warp' or 'impulse'
// 61 = Adv 27 [MT]. ALL PLAYERS choose a non-Cadet to pass left.
// 62 = Adv 28 [MW]. choice of card to play without named officer
// 63 = Adv 29 [NT]. choose 'danger' or 'protect'
// 64 = Adv 30 [OA]. choose player
// -- = Adv 31 [PA]. (gstate not needed)
// 65 = Adv 32 [PF]. choose warp or impulse
// 66 = Adv 32 [PF]-WRP. choose cardtype from 1st player on left
// 67 = Adv 32 [PF]-WRP. 1ST PLAYER chooses card to give
// 68 = Adv 32 [PF]-WRP. choose cardtype from 2nd player on left
// 69 = Adv 32 [PF]-WRP. 2ND PLAYER chooses card to give
// 70 = Adv 32 [PF]-WRP. choose cardtype form 3rd player on left
// 71 = Adv 32 [PF]-WRP. 3RD PLAYER chooses card to give
// 72 = Adv 32 [PF]-IMP. choose player to ask
// 73 = Adv 32 [PF]-IMP. choose cardtype from chosen player
// 74 = Adv 32 [PF]-IMP. CHOSEN PLAYER chooses card to give
// 75 = Adv 33 [PSt]. choose warp or impulse
// 76 = Adv 33 [PSt]-WRP. choose player or deck to draw 1st card
// 77 = Adv 33 [PSt]-WRP. choose player or deck to draw 2nd card
// 78 = Adv 34 [PSy]. choose a card from the discard pile
// 79 = Adv 35 [RA]. choice of danger or protect
// 80 = Adv 35 [RA]-DAN. choice of crewman to give
// 81 = Adv 35 [RA]-DAN. choice of player to give crewman to
// -- = Adv 36 [RM]. (gstate not needed)
// 82 = Adv 37 [RT]. choice of 'warp' or 'impulse'
// 83 = Adv 37 [RT]-WRP. choose Most Crew player (if a tie)
// 84 = Adv 37 [RT]-IMP. choose player for crew call
// 85 = Adv 37 [RT]-IMP. choose name/specialty for crew call
// 86 = Adv 38 [SB]. choice of 'danger' or 'protect' 
// 87 = Adv 38 [SB]-DAN. choice of tiebreaking "least crew" player
// 88 = Adv 39 [SC]. choose 1st player to enter battle (and to move first)
// 89 = Adv 39 [SC]. choose 2nd player to enter battle (and to move second)
// 90 = Adv 40 [SGn]. choose 'warp' or 'impulse'
// 91 = Adv 40 [SGn]-WRP. choose a player
// 92 = Adv 40 [SGn]-WRP. choose an adventure space
// 93 = Adv 40 [SGn]-WRP. CHOSEN PLAYER chooses one of his crewman to maroon
// 94 = Adv 40 [SGn]-IMP. choose a player
// 95 = Adv 40 [SGn]-IMP. choose a card type
// 96 = Adv 40 [SGn]-IMP. CHOSEN PLAYER chooses card to discard
// 97 = Adv 41 [SL]. choice of warp or impulse
// 98 = Adv 41 [SL]-WRP. choice of adventure space.
// 99 = Adv 41 [SL]-IMP. choice of 'forward' or 'back'
// 100 = Adv 42 [TA]. choice of danger or protect
// 101 = Adv 42 [TA]-DAN. choice of player for "Battle to the Death"
// 102 = Adv 43 [TSP]. choice of danger or protect
// 103 = Adv 43 [TSP]-DAN. 1ST PLAYER ON LEFT chooses a card
// 104 = Adv 43 [TSP]-DAN. 2ND PLAYER ON LEFT chooses a card
// 105 = Adv 43 [TSP]-DAN. 3RD PLAYER ON LEFT chooses a card
// 106 = Adv 44 [TW]. choose 'warp' or 'impulse'
// 107 = Adv 44 [TW]-WRP. choose a player to move
// 108 = Adv 44 [TW]-WRP. choose an adventure space to move the player to.
// 109 = Adv 44 [TW]-IMP. choose a player to move
// 110 = Adv 44 [TW]-IMP. choose to move that player 'forward' or 'back' one space
// 111 = Adv 45 [TWS]. choose danger or protect
// 112 = Adv 45 [TWS]-DAN. choose crewman to maroon
// 113 = Adv 46 [TY]. choice of 'danger' or 'protect'
// 114 = Adv 46 [TY]-DAN. choice of player (tiebreak "Least Crew")
// 115 = Adv 46 [TY]-DAN. LEAST CREW player chooses adventure space
// 116 = Adv 47 [WE]. choose warp or impulse
// --- = Adv 48 [WNM]. (gstate not needed)
// 117 = Adv 49 [WM]. choice of 'danger' or 'protect'
// -------------------------------------------------------
// 118 = Adv 23 [LZ]-WRP. CHOSEN must choose a crewman to lose,
//              after a successful crew call by Specialty.


@field bot = do_1 : 
 // Echo who said 'ok' to the room
 @tellroom(@location("%#"),"","%n says (to GameBot), \"Ok.\"");
 // GameBot should count the players and make note of their dbrefs.
 @s("nwho","0");
 @s("db_who_b",@location("2229")); @switch(@type(@g("db_who_b")),2,
  @s("nwho",@add(@g("nwho"),"1")), @s("db_who_b","0"));
 @s("db_who_r",@location("2236")); @switch(@type(@g("db_who_r")),2,
  @s("nwho",@add(@g("nwho"),"1")), @s("db_who_r","0"));
 @s("db_who_g",@location("2235")); @switch(@type(@g("db_who_g")),2,
  @s("nwho",@add(@g("nwho"),"1")), @s("db_who_g","0"));
 @s("db_who_y",@location("2160")); @switch(@type(@g("db_who_y")),2,
  @s("nwho",@add(@g("nwho"),"1")), @s("db_who_y","0"));
 // If there are less than 2 players, it should complain and stop here.
 // Otherwise, continue with do_1b.
 @switch(@g("nwho"),{"0","1"},
  @tellroom(@location("%#"),"","GameBot says, \"Sorry, but I need at
  least two players to continue.\""), @call("%!","do_1b"));

// ELSE 2 or more players
@field #2117 = do_1b :
// Tell how many players and who's playing what.
 @tellroom(@location("%#"),"",@print("GameBot says,
  \"Great! There are ", @g("nwho"), " players.\""));
 @s("whoclrs","");
 @switch(@g("db_who_b"),"0","",@print(@s("whoclrs","1"),
  @tellroom(@location("%#"),"",@print("GameBot says, \"",
  @shortname(@g("db_who_b"))," is playing BLUE.\""))));
 @switch(@g("db_who_r"),"0","",@print(
  @s("whoclrs",@print(@g("whoclrs"),"2")),
  @tellroom(@location("%#"),"",@print("GameBot says, \"",
  @shortname(@g("db_who_r"))," is playing RED.\""))));
 @switch(@g("db_who_g"),"0","",@print(
  @s("whoclrs",@print(@g("whoclrs"),"3")),
  @tellroom(@location("%#"),"",@print("GameBot says, \"",
  @shortname(@g("db_who_g"))," is playing GREEN.\""))));
 @switch(@g("db_who_y"),"0","",@print(
  @s("whoclrs",@print(@g("whoclrs"),"4")),
  @tellroom(@location("%#"),"",@print("GameBot says, \"",
  @shortname(@g("db_who_y"))," is playing YELLOW.\""))));
 // Hide all the ships on the floor, eg: dark, locked.
 @tellroom(@location("%#"),"","GameBot says, \"Now, if I could just
  have those ships back, please...\"");
 @s("arg1",2229); @call(2117,"bottake");
 @s("arg1",2236); @call(2117,"bottake");
 @s("arg1",2235); @call(2117,"bottake");
 @s("arg1",2160); @call(2117,"bottake");
 // Turn itself into a gameboard.
 @tellroom(@location("%#"),"","GameBot says, \"Thank you. Now, move back
  a bit, please.\"%cGameBot transforms himself into a large table with
  an electronic gameboard embedded in the tabletop!");
 // Put the ships on the Base Worlds.
 @switch(@g("db_who_b"),"0",@s("ship1_loc","99"),@print(
  @s("ship1_loc","41"),@tellroom(@location("%#"),"",
  "GameBoard puts the blue ship on the Blue Base World.")));
 @switch(@g("db_who_r"),"0",@s("ship2_loc","99"),@print(
  @s("ship2_loc","42"),@tellroom(@location("%#"),"",
  "GameBoard puts the red ship on the Red Base World.")));
 @switch(@g("db_who_g"),"0",@s("ship3_loc","99"),@print(
  @s("ship3_loc","43"),@tellroom(@location("%#"),"",
  "GameBoard puts the green ship on the Green Base World.")));
 @switch(@g("db_who_y"),"0",@s("ship4_loc","99"),@print(
  @s("ship4_loc","44"),@tellroom(@location("%#"),"",
  "GameBoard puts the yellow ship on the Yellow Base World.")));
 // Give bridge racks to players.
 @tellroom(@location("%#"),"","GameBoard says, \"Everyone gets a bridge
  rack. This will be used to hold your crew counters, which you keep
  hidden from other players. Only you can see what's on your rack.\"");
 @switch(@g("db_who_b"),"0","",@print(
  @s("arg1","10488"),@s("arg2",@g("db_who_b")),@call(2117,"botgive")));
 @switch(@g("db_who_r"),"0","",@print(
  @s("arg1","10489"),@s("arg2",@g("db_who_r")),@call(2117,"botgive")));
 @switch(@g("db_who_g"),"0","",@print(
  @s("arg1","10490"),@s("arg2",@g("db_who_g")),@call(2117,"botgive")));
 @switch(@g("db_who_y"),"0","",@print(
  @s("arg1","10487"),@s("arg2",@g("db_who_y")),@call(2117,"botgive")));
 // Shuffle the decks; deal battle-cards; give hands to players.
 @call("2117","botshuf_a"); @call("2117","botshuf_b");
 @call("2117","botgivehands");
 // Shuffle the crew; deal crew to players and adventure spaces.
 @call("2117","botshuf_c"); @call("2117","botdeal_cs");
 @call("2117","botmaroon_all");
 // Stop to let everyone look at things before continuing.
 // Set gstate to 2, and wait for any PLAYER to say 'ready' again.
 @s("gstate","2"); @tellroom(@location("%#"),"","GameBoard says, \"I'll
 pause here. Any player, say 'OK' to continue.\"");

@field #2117 = do_2 :
  //Echo who said 'ok' to the room.
  @tellroom(@location("%#"),"","%n says (to GameBoard), \"Ok.\"");
  //If someone other than a player, chide them and stop here.
  @switch("%#",{@location("10487"),@location("10488"),
      @location("10498"),@location("10490")},
    @call(2117,"do_2b"),
    @tellroom(@location("%#"),"","GameBoard ignores %n's command since
      %s isn't currently a player in the game.\"")
  );

// GameBoard should remind people how to look stuff up.
// Then it should randomly decide who goes first,
// set gstate to 3, do any other finicky business,
// and prompt the 1st player to roll die.
@field #2117 = do_2b :
  @tellroom(@location("%#"),"","GameBoard says, \"A reminder to everyone.
   Don't forget to 'LOOKUP' stuff in my database. That's where all the
   rules to the game are, and I can't tell you anything unless you ask.
   And 'X BOARD' to see the current status of the game. Okay? Let's play!\"");
  @call(2117,"calc_who1st_turn");
  @tellroom(@location("%#"),"",@print("GameBoard says, \"",
    @g("whocna_turn"), " will go first.\""));
  @s("gstate","3"); @s("stddir","0"); @s("nowdir","0");
  @tellroom(@location("%#"),"",@print("GameBoard says (to ",
    @g("whorna_turn"), "), \"'ROLL' the die.\""));
------
**TEST**
@field #2117 = do_2b : @tellroom(@location("%#"),"","GameBoard says, \"A reminder to everyone. Don't forget to 'LOOKUP' stuff in my database. That's where all the rules to the game are, and I can't tell you anything unless you ask. And 'X BOARD' to see the current status of the game. Okay? Let's play!\""); @call(2117,"calc_who1st_turn"); @tellroom(@location("%#"),"",@print("GameBoard says, \"", @g("whocna_turn"), " will go first.\"")); @s("gstate","3"); @s("stddir","0"); @s("nowdir","0"); @tellroom(@location("%#"),"",@print("GameBoard says (to ", @g("whorna_turn"), "), \"'ROLL' the die.\""));
======

Implied Objects: Adventure cards

//  GameBot fieldnames w.r.t. Adventure Cards
//  where XX is the adventure number (0..49)
//  -------------------------------------------
//  acloc_XX  Location of XX (may be 0, 1..20, 99).
//  acpos_XX  Position of XX (in deck or discard).
//  accod_XX  Code of XX (eg: MW; DY)
//  acnam_XX  Name of XX (eg: Mudd's Women; The Deadly Years)

@field #2117 = accod_0  : AE
@field #2117 = accod_1  : AON
@field #2117 = accod_2  : Ar
@field #2117 = accod_3  : AT
@field #2117 = accod_4  : AY
@field #2117 = accod_5  : BT
@field #2117 = accod_6  : CK
@field #2117 = accod_7  : CMl
@field #2117 = accod_8  : CMn
@field #2117 = accod_9  : Cms
@field #2117 = accod_10 : Cp
@field #2117 = accod_11 : CX
@field #2117 = accod_12 : DD
@field #2117 = accod_13 : DMa
@field #2117 = accod_14 : DMd
@field #2117 = accod_15 : DY
@field #2117 = accod_16 : EI
@field #2117 = accod_17 : EM
@field #2117 = accod_18 : ET
@field #2117 = accod_19 : EW
@field #2117 = accod_20 : FC
@field #2117 = accod_21 : FW
@field #2117 = accod_22 : GT
@field #2117 = accod_23 : LZ
@field #2117 = accod_24 : Me
@field #2117 = accod_25 : Met
@field #2117 = accod_26 : MM
@field #2117 = accod_27 : MT
@field #2117 = accod_28 : MW
@field #2117 = accod_29 : NT
@field #2117 = accod_30 : OA
@field #2117 = accod_31 : PA
@field #2117 = accod_32 : PF
@field #2117 = accod_33 : PSt
@field #2117 = accod_34 : PSy
@field #2117 = accod_35 : RA
@field #2117 = accod_36 : RM
@field #2117 = accod_37 : RT
@field #2117 = accod_38 : SB
@field #2117 = accod_39 : SC
@field #2117 = accod_40 : SGn
@field #2117 = accod_41 : SL
@field #2117 = accod_42 : TA
@field #2117 = accod_43 : TSP
@field #2117 = accod_44 : TW
@field #2117 = accod_45 : TWS
@field #2117 = accod_46 : TY
@field #2117 = accod_47 : WE
@field #2117 = accod_48 : WNM
@field #2117 = accod_49 : WM

@field #2117 = acnam_0  : Assignment: Earth
@field #2117 = acnam_1  : By Any Other Name
@field #2117 = acnam_2  : Arena
@field #2117 = acnam_3  : Amok Time
@field #2117 = acnam_4  : All Our Yesterdays
@field #2117 = acnam_5  : Balance of Terror
@field #2117 = acnam_6  : The Conscience of the King
@field #2117 = acnam_7  : Court Martial
@field #2117 = acnam_8  : The Corbomite Maneuver
@field #2117 = acnam_9  : The Cloud-minders
@field #2117 = acnam_10 : Catspaw
@field #2117 = acnam_11 : Charlie X
@field #2117 = acnam_12 : The Devil in the Dark
@field #2117 = acnam_13 : The Doomsday Machine
@field #2117 = acnam_14 : Dagger of the Mind
@field #2117 = acnam_15 : The Deadly Years
@field #2117 = acnam_16 : The Enterprise Incident
@field #2117 = acnam_17 : Errand of Mercy
@field #2117 = acnam_18 : Elaan of Troyius
@field #2117 = acnam_19 : The Enemy Within
@field #2117 = acnam_20 : Friday's Child
@field #2117 = acnam_21 : For the World is Hollow and I Have Touched the Sky
@field #2117 = acnam_22 : The Gamesters of Triskelion
@field #2117 = acnam_23 : The Lights of Zetar
@field #2117 = acnam_24 : The Menagerie
@field #2117 = acnam_25 : Metamorphosis
@field #2117 = acnam_26 : Mirror, Mirror
@field #2117 = acnam_27 : Man Trap
@field #2117 = acnam_28 : Mudd's Women
@field #2117 = acnam_29 : The Naked Time
@field #2117 = acnam_30 : Operation - Annihilate!
@field #2117 = acnam_31 : A Piece of the Action
@field #2117 = acnam_32 : Patterns of Force
@field #2117 = acnam_33 : Plato's Stepchildren
@field #2117 = acnam_34 : The Paradise Syndrome
@field #2117 = acnam_35 : The Return of the Archons
@field #2117 = acnam_36 : Requiem for Methuselah
@field #2117 = acnam_37 : Return to Tomorrow
@field #2117 = acnam_38 : Spock's Brain
@field #2117 = acnam_39 : The Savage Curtain
@field #2117 = acnam_40 : Spectre of the Gun
@field #2117 = acnam_41 : Shore Leave
@field #2117 = acnam_42 : A Taste of Armageddon
@field #2117 = acnam_43 : This Side of Paradise
@field #2117 = acnam_44 : The Tholian Web
@field #2117 = acnam_45 : That Which Survives
@field #2117 = acnam_46 : Tomorrow is Yesterday
@field #2117 = acnam_47 : Wink of an Eye
@field #2117 = acnam_48 : Where No Man Has Gone Before
@field #2117 = acnam_49 : Who Mourns for Adonais?

// initialize the Adventure Deck.
// called by botshuf_a during gstate 1.
old @field #2117 = init_acs :
 // first initialize acpos_X = X, acloc_X = 0
 @s("i","0");
 @fieldloop("2117","acnam_", @print(
	@s(@print("acpos_",@g("i")),@g("i")), 
	@s(@print("acloc_",@g("i")),"0"),
	@s("i",@add(@g("i"),"1"))
 ));
new @field #2117 = init_acs :
 // first initialize acpos_X = X, acloc_X = 0
 @s("i","0");
 @fieldloop("2117","acnam_", @let("i"=>@g("i"),@print(
	@s("acpos_%i","%i"), 
	@s("acloc_%i","0"),
	@s("i",@add("%i","1"))
 )));
----
ADD AND TEST FIRST!!!
@field #2117 = init_acs : @s("i","0"); @fieldloop("2117","acnam_", @let("i"=>@g("i"),@print(@s("acpos_%i","%i"), @s("acloc_%i","0"), @s("i",@add("%i","1")))));
====

// number of adventure cards at a given location
@field #2117 = init_nacs :
 @s("nac_0","50"); @s("nac_1","0"); @s("nac_2","0"); @s("nac_3","0");
 @s("nac_4","0"); @s("nac_5","0"); @s("nac_6","0"); @s("nac_7","0");
 @s("nac_8","0"); @s("nac_9","0"); @s("nac_10","0"); @s("nac_11","0");
 @s("nac_12","0"); @s("nac_13","0"); @s("nac_14","0"); @s("nac_15","0");
 @s("nac_16","0"); @s("nac_17","0"); @s("nac_18","0"); @s("nac_19","0");
 @s("nac_20","0"); @s("nac_99","0");
---------
@field #2117 = init_nacs : @s("nac_0","50"); @s("nac_1","0"); @s("nac_2","0"); @s("nac_3","0"); @s("nac_4","0"); @s("nac_5","0"); @s("nac_6","0"); @s("nac_7","0"); @s("nac_8","0"); @s("nac_9","0"); @s("nac_10","0"); @s("nac_11","0"); @s("nac_12","0"); @s("nac_13","0"); @s("nac_14","0"); @s("nac_15","0"); @s("nac_16","0"); @s("nac_17","0"); @s("nac_18","0"); @s("nac_19","0"); @s("nac_20","0"); @s("nac_99","0");
=========

// shuffle the Adventure Deck
// NOTE: ALSO INITIALIZING! ASSUMING ALL 50 CARDS IN DECK!
@field #2117 = botshuf_a :
 @switch(@g("gstate"),"1",@print(
  @call(2117,"init_acs"), @call(2117,"init_nacs")));
 @tellroom(@location("%#"),"","GameBoard shuffles the Adventure cards.");
 // Do the actual shuffling (via acpos's)
 // for i=49..1 { j=rand(0..i); k=pos(i); pos(i)=pos(j); pos(j)=k; }
 @s("i","49");
 @strloop("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","x", @print(
    @s( "j", @rand(@g("i")) ),
    @s( "k", @g(@print("acpos_",@g("i"))) ),
    @s( @print("acpos_",@g("i")), @g(@print("acpos_",@g("j"))) ),
    @s( @print("acpos_",@g("j")), @g("k") ),
    @s( "i", @sub(@g("i"),"1") )
 ));
-----------
**TO TEST**
@field #2117 = botshuf_a : @switch(@g("gstate"), "1", @print(@call("2117","init_acs"), @call(2117,"init_nacs"))); @tellroom(@location("%#"),"","GameBoard shuffles the Adventure cards."); @s("i","49"); @strloop("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","x", @print(@s( "j", @rand(@g("i"))), @s( "k", @g(@print("acpos_",@g("i")))), @s( @print("acpos_",@g("i")), @g(@print("acpos_",@g("j")))), @s( @print("acpos_",@g("j")), @g("k")), @s( "i", @sub(@g("i"),"1"))));
===========

@field #2117 = botdealac1 :
  @fieldloop("2117","acloc_",
    @switch( @and(@eq("%v",@g("arg1")),
      @eq(@g(@print("acpos_",@substr("%f","6"))),
          @sub(@g(@print("nac_",@g("arg1"))),"1"))),
      "1", @print(
        @s("ac_moved",@substr("%f","6")),
    	@s("%f",@g("arg2")),
	@s(@print("acpos_",@substr("%f","6")),
          @g(@print("nac_",@g("arg2"))))
      )
    )	
  );
  @s(@print("nac_",@g("arg1")), @sub(@g(@print("nac_",@g("arg1"))),"1"));
  @s(@print("nac_",@g("arg2")), @add(@g(@print("nac_",@g("arg2"))),"1"));
------
**TEST**
@field #2117 = botdealac1 : @fieldloop("2117","acloc_", @switch( @and(@eq("%v",@g("arg1")), @eq(@g(@print("acpos_",@substr("%f","6"))), @sub(@g(@print("nac_",@g("arg1"))),"1"))), "1", @print(@s("ac_moved",@substr("%f","6")), @s("%f",@g("arg2")), @s(@print("acpos_",@substr("%f","6")), @g(@print("nac_",@g("arg2"))))))); @s(@print("nac_",@g("arg1")), @sub(@g(@print("nac_",@g("arg1"))),"1")); @s(@print("nac_",@g("arg2")), @add(@g(@print("nac_",@g("arg2"))),"1"));
======

Implied Objects: Battle cards

//  GameBot fieldnames w.r.t. Battle Cards
//  where XX is the card number (0..42).
//  NOTE: XX can't be a name, because need to generate fldname for shuffling
//  -------------------------------------------
//  bcloc_XX  Location of XX (0,41..44,99)
//  bcpos_XX  Position of XX within location bcloc_XX
//  bccod_XX  Code of XX
//  bcnam_XX  Name of XX
//  bcct_XX   Cardtype of XX
//  ctnam_CC  Name of cardtype CC

@field #2117 = bccod_0 : CA
@field #2117 = bccod_1 : CA
@field #2117 = bccod_2 : CA
@field #2117 = bccod_3 : CA
@field #2117 = bccod_4 : Esc
@field #2117 = bccod_5 : MAL
@field #2117 = bccod_6 : P1 Barro
@field #2117 = bccod_7 : P1 Chape
@field #2117 = bccod_8 : P1 Cheko
@field #2117 = bccod_9 : P1 Jones
@field #2117 = bccod_10 : P1 Kirk
@field #2117 = bccod_11 : P1 Lando
@field #2117 = bccod_12 : P1 Manni
@field #2117 = bccod_13 : P1 McCoy
@field #2117 = bccod_14 : P1 Palam
@field #2117 = bccod_15 : P1 Rand
@field #2117 = bccod_16 : P1 Riley
@field #2117 = bccod_17 : P1 Scott
@field #2117 = bccod_18 : P1 Spock
@field #2117 = bccod_19 : P1 Sulu
@field #2117 = bccod_20 : P1 Uhura
@field #2117 = bccod_21 : P2
@field #2117 = bccod_22 : P2
@field #2117 = bccod_23 : P2
@field #2117 = bccod_24 : P2
@field #2117 = bccod_25 : P2
@field #2117 = bccod_26 : P2
@field #2117 = bccod_27 : P3
@field #2117 = bccod_28 : P3 Noel
@field #2117 = bccod_29 : PT
@field #2117 = bccod_30 : PT Kyle
@field #2117 = bccod_31 : S1
@field #2117 = bccod_32 : S1
@field #2117 = bccod_33 : S1
@field #2117 = bccod_34 : S1
@field #2117 = bccod_35 : S1
@field #2117 = bccod_36 : S1
@field #2117 = bccod_37 : S2
@field #2117 = bccod_38 : Tr
@field #2117 = bccod_39 : Tr
@field #2117 = bccod_40 : Tr
@field #2117 = bccod_41 : W2
@field #2117 = bccod_42 : W2 Romai

@field #2117 = bcct_0 : ca
@field #2117 = bcct_1 : ca
@field #2117 = bcct_2 : ca
@field #2117 = bcct_3 : ca
@field #2117 = bcct_4 : es
@field #2117 = bcct_5 : ma
@field #2117 = bcct_6 : p1
@field #2117 = bcct_7 : p1
@field #2117 = bcct_8 : p1
@field #2117 = bcct_9 : p1
@field #2117 = bcct_10 : p1
@field #2117 = bcct_11 : p1
@field #2117 = bcct_12 : p1
@field #2117 = bcct_13 : p1
@field #2117 = bcct_14 : p1
@field #2117 = bcct_15 : p1
@field #2117 = bcct_16 : p1
@field #2117 = bcct_17 : p1
@field #2117 = bcct_18 : p1
@field #2117 = bcct_19 : p1
@field #2117 = bcct_20 : p1
@field #2117 = bcct_21 : p2
@field #2117 = bcct_22 : p2
@field #2117 = bcct_23 : p2
@field #2117 = bcct_24 : p2
@field #2117 = bcct_25 : p2
@field #2117 = bcct_26 : p2
@field #2117 = bcct_27 : p3
@field #2117 = bcct_28 : p3
@field #2117 = bcct_29 : pt
@field #2117 = bcct_30 : pt
@field #2117 = bcct_31 : s1
@field #2117 = bcct_32 : s1
@field #2117 = bcct_33 : s1
@field #2117 = bcct_34 : s1
@field #2117 = bcct_35 : s1
@field #2117 = bcct_36 : s1
@field #2117 = bcct_37 : s2
@field #2117 = bcct_38 : tr
@field #2117 = bcct_39 : tr
@field #2117 = bcct_40 : tr
@field #2117 = bcct_41 : w2
@field #2117 = bcct_42 : w2

@field #2117 = bcnam_0 : Cochrane Acceleration
@field #2117 = bcnam_1 : Cochrane Acceleration
@field #2117 = bcnam_2 : Cochrane Acceleration
@field #2117 = bcnam_3 : Cochrane Acceleration
@field #2117 = bcnam_4 : Escape!
@field #2117 = bcnam_5 : Matter-Antimatter Loop
@field #2117 = bcnam_6 : Phaser 1 Barrows
@field #2117 = bcnam_7 : Phaser 1 Chapel
@field #2117 = bcnam_8 : Phaser 1 Chekov
@field #2117 = bcnam_9 : Phaser 1 Jones
@field #2117 = bcnam_10 : Phaser 1 Kirk
@field #2117 = bcnam_11 : Phaser 1 Landon
@field #2117 = bcnam_12 : Phaser 1 Manning
@field #2117 = bcnam_13 : Phaser 1 McCoy
@field #2117 = bcnam_14 : Phaser 1 Palamas
@field #2117 = bcnam_15 : Phaser 1 Rand
@field #2117 = bcnam_16 : Phaser 1 Riley
@field #2117 = bcnam_17 : Phaser 1 Scott
@field #2117 = bcnam_18 : Phaser 1 Spock
@field #2117 = bcnam_19 : Phaser 1 Sulu
@field #2117 = bcnam_20 : Phaser 1 Uhura
@field #2117 = bcnam_21 : Phaser 2
@field #2117 = bcnam_22 : Phaser 2
@field #2117 = bcnam_23 : Phaser 2
@field #2117 = bcnam_24 : Phaser 2
@field #2117 = bcnam_25 : Phaser 2
@field #2117 = bcnam_26 : Phaser 2
@field #2117 = bcnam_27 : Phaser 3
@field #2117 = bcnam_28 : Phaser 3 Noel
@field #2117 = bcnam_29 : Photon Torpedo
@field #2117 = bcnam_30 : Photon Torpedo Kyle
@field #2117 = bcnam_31 : Shield 1
@field #2117 = bcnam_32 : Shield 1
@field #2117 = bcnam_33 : Shield 1
@field #2117 = bcnam_34 : Shield 1
@field #2117 = bcnam_35 : Shield 1
@field #2117 = bcnam_36 : Shield 1
@field #2117 = bcnam_37 : Shield 2
@field #2117 = bcnam_38 : Tractor
@field #2117 = bcnam_39 : Tractor
@field #2117 = bcnam_40 : Tractor
@field #2117 = bcnam_41 : Warp 2
@field #2117 = bcnam_42 : Warp 2 Romaine

@field #2117 = ctnam_ca = Cochrane Acceleration
@field #2117 = ctnam_es = Escape!
@field #2117 = ctnam_ma = Matter-Antimatter Loop
@field #2117 = ctnam_p1 = Phaser 1
@field #2117 = ctnam_p2 = Phaser 2
@field #2117 = ctnam_p3 = Phaser 3
@field #2117 = ctnam_pt = Photon Torpedo
@field #2117 = ctnam_s1 = Shield 1
@field #2117 = ctnam_s2 = Shield 2
@field #2117 = ctnam_tr = Tractor
@field #2117 = ctnam_w2 = Warp 2

// initialize the Battle Deck.
// called by botshuf_b during gstate 1.
@field #2117 = init_bcs :
 // first initialize bcpos_X = X, bcloc_X = 0
 @s("i","0");
 @fieldloop(2117,"bcnam_", @let("i"=>@g("i"),@print(
  @s("bcpos_%i","%i"), @s("bcloc_%i","0"), @s("i",@add("%i","1"))
 )));
----
TEST
@field #2117 = init_bcs : @s("i","0"); @fieldloop(2117,"bcnam_", @let("i"=>@g("i"),@print(@s("bcpos_%i","%i"), @s("bcloc_%i","0"), @s("i",@add("%i","1")))));
====

@field #2117 = init_nbcs :
 @s("nbc_0","43"); @s("nbc_41","0"); @s("nbc_42","0"); @s("nbc_43","0");
 @s("nbc_44","0"); @s("nbc_45","0"); @s("nbc_99","0");

// shuffle the Battle Deck
// NOTE: initializes during gstate 1
// Do the actual shuffling (via acpos's)
// for i=42..1 { j=rand(0..i); k=pos(i); pos(i)=pos(j); pos(j)=k; }
@field #2117 = botshuf_b :
  @switch(@g("gstate"),"1",@print(
   @call(2117,"init_bcs"),@call(2117,"init_nbcs"));
  @tellroom(@location("%#"),"","GameBoard shuffles the Battle cards.");
  @s("i",42);
  @strloop("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","x", @print(
    @s("j",@rand(@g("i"))),
    @switch("1",@eq(0,@g(@print("bcloc_",@g("i"))),@g(@print("bcloc_",@g("j")))),
      @s("k",@g(@print("bcpos_",@g("i")))),
      @s(@print("bcpos_",@g("i")),@g(@print("bcpos_",@g("j")))),
      @s(@print("bcpos_",@g("j")),@g("k")),
      @s("i",@sub(@g("i"),"1"))
    )
  ));
-----
**TEST**
@field #2117 = botshuf_b : @switch(@g("gstate"), "1", @print(@call("2117","init_bcs"), @call("2117","init_nbcs")); @tellroom(@location("%#"),"","GameBoard shuffles the Battle cards."); @s("i",42); @strloop("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","x", @print(@s("j",@rand(@g("i"))), @switch("1",@eq(0,@g(@print("bcloc_",@g("i"))),@g(@print("bcloc_",@g("j")))), @s("k",@g(@print("bcpos_",@g("i")))), @s(@print("bcpos_",@g("i")),@g(@print("bcpos_",@g("j")))), @s(@print("bcpos_",@g("j")),@g("k")), @s("i",@sub(@g("i"),"1")))));
=====

// give out initial hands to all players
@field #2117 = botgivehands : 
 @tellroom(@location("%#"),"","GameBoard deals three cards to each player.");
 @switch(@g("db_who_b"),"0","", @print(
  @s("arg1",0),@s("arg2",41),@call(2117,"botdeal_b3"),
  @s("arg1","10492"),@s("arg2",@g("db_who_b")),@call(2117,"botgive")));
 @switch(@g("db_who_r"),"0","", @print(
  @s("arg1",0),@s("arg2",42),@call(2117,"botdeal_b3"),
  @s("arg1","10493"),@s("arg2",@g("db_who_r")),@call(2117,"botgive")));
 @switch(@g("db_who_g"),"0","", @print(
  @s("arg1",0),@s("arg2",43),@call(2117,"botdeal_b3"),
  @s("arg1","10494"),@s("arg2",@g("db_who_g")),@call(2117,"botgive")));
 @switch(@g("db_who_y"),"0","", @print(
  @s("arg1",0),@s("arg2",44),@call(2117,"botdeal_b3"),
  @s("arg1","10491"),@s("arg2",@g("db_who_y")),@call(2117,"botgive")));

// deal out 3 battle cards into hand (arg1->arg2)
@field #2117 = botdeal_b3 : @call(2117,"botdeal_b1");
  @call(2117,"botdeal_b1"); @call(2117,"botdeal_b1");

// TODO: This should be a noisy version of botdeal_b1.
// TEST: Reshuffle discards when necessary.
// NOTE: With a max of 4 players, and max of 7 cards per hand,
//       we can guarantee that there are always cards after a reshuffle.
@field #2117 = echo_dealbc : @call(2117,"botdeal_b1");
-----
**TEST**
@field #2117 = echo_dealbc : @call(2117,"botdeal_b1");
=====

// make sure that the whoclr_cards player has 7-cards maximum
@field #2117 = echo_7cardmax : TODO

// BOTDEAL_B1
// Deals 1 battle card from location "arg1" to location "arg2".
//--------------------------------------------------------------
// - Field bcloc_XX has the location of battle card #XX.
// - Field bcpos_XX has the position of battle card #XX within the location.
// - Field nbc_LL has the number of crew counters in location #LL.
// - Note that the value of bcpos_XX should be from 0..nbc_{bcloc_XX}.
//--------------------------------------------------------------
// Eg: If "arg1" is 0, and "arg2" is 41,
//     Then search the bc fields for XX such that
//        bcloc_XX = 0 and bcpos_XX = nbc_0 - 1 (deal off bottom of loc0).
//     When you find XX, do this:
//        bcloc_XX = 41; bcpos_XX = nbc_41 (add to bottom of loc41). 
//     Then nbc_0--; nbc_41++.
//--------------------------------------------------------------
// **TODO** Assumes that a card is in the location arg1
@field #2117 = botdeal_b1 : 
  @switch(@g("nbc_0"),"0",@print(
    @fieldloop(2117,"bcloc_",@switch("%v",99,@s("%f",0))),
    @call(2117,"botshuf_b")));
  @fieldloop("2117","bcloc_",
    @switch( @and(@eq("%v",@g("arg1")),
         @eq(@g(@print("bcpos_",@substr("%f","6"))),
         @sub(@g(@print("nbc_",@g("arg1"))),"1"))),
       "1", @print(
          @s("bc_moved",@substr("%f","6")),
	  @s("%f",@g("arg2")),
	  @s(@print("bcpos_",@substr("%f","6")),
	    @g(@print("nbc_",@g("arg2"))))
       )
    )	
  );
  @s(@print("nbc_",@g("arg1")), @sub(@g(@print("nbc_",@g("arg1"))),"1"));
  @s(@print("nbc_",@g("arg2")), @add(@g(@print("nbc_",@g("arg2"))),"1"));
-----
**TEST**
@field #2117 = botdeal_b1 : @switch(@g("nbc_0"),"0",@print(@fieldloop(2117,"bcloc_",@switch("%v",99,@s("%f",0))), @call(2117,"botshuf_b"))); @fieldloop("2117","bcloc_", @switch( @and(@eq("%v",@g("arg1")), @eq(@g(@print("bcpos_",@substr("%f","6"))), @sub(@g(@print("nbc_",@g("arg1"))),"1"))), "1", @print(@s("bc_moved",@substr("%f","6")), @s("%f",@g("arg2")), @s(@print("bcpos_",@substr("%f","6")), @g(@print("nbc_",@g("arg2"))))))); @s(@print("nbc_",@g("arg1")), @sub(@g(@print("nbc_",@g("arg1"))),"1")); @s(@print("nbc_",@g("arg2")), @add(@g(@print("nbc_",@g("arg2"))),"1"));
=====

// All we want to do is move a card from one hand to another,
// but it's unbelievably awkward.
// Similar in concept to botdeal_b1, but we could be moving a card
// from anywhere within arg1 to arg2, not just from arg1's end.
// The specific card we want to move is arg3.
// Also, make this noisy, saying what card goes where for the giver
// and receiver, and a more generic message for everyone else.
@field #2117 = bcgive1 :
  @s("oldpos", @g(@print("bcpos_",@g("arg3"))));
  @s(@print("bcloc_",@g("arg3")), @g("arg2"));
  @s(@print("bcpos_",@g("arg3")), @g(@print("nbc_",@g("arg2"))));
  @fieldloop("2117","bcloc_",
    @switch( @and(@eq("%v",@g("arg1")),
         @gt(@g(@print("bcpos_",@substr("%f","6"))),@g("oldpos"))),
       "1", @s(@print("bcpos_",@substr("%f","6")),
	    @sub(@g(@print("bcpos_",@substr("%f","6")),1))
    )	
  );
  @s(@print("nbc_",@g("arg1")), @sub(@g(@print("nbc_",@g("arg1"))),"1"));
  @s(@print("nbc_",@g("arg2")), @add(@g(@print("nbc_",@g("arg2"))),"1"));
  @s("whodbr_arg1", @location(@switch(@g("whoclr_arg1"),
    1,10488,2,10489,3,10490,4,10487)));
  @s("whocna_arg1", @uc(@g(@print("clrnam",@g("whoclr_arg1")))));
  @s("whodbr_arg2", @location(@switch(@g("whoclr_arg2"),
    1,10488,2,10489,3,10490,4,10487)));
  @s("whocna_arg2", @uc(@g(@print("clrnam",@g("whoclr_arg2")))));
  @tell(@g("whodbr_arg1"),@print( 
    "You give a ", @g(@print("bcnam_",@g("arg3"))),
    " card to ", @g("whocna_arg2"), "."
  ));
  @tell(@g("whodbr_arg2"),@print( 
    @g("whocna_arg1"), " gives a ", @g(@print("bcnam_",@g("arg3"))),
    " card to you."
  ));
  @tellroom(@location("%#"),{@g("whodbr_arg1"),@g("whodbr_arg2")},@print(
    @g("whocna_arg1"), " gives a card to ", @g("whocna_arg2"), "."
  ));
-----
**ADD**
@field bot = bcgive1 : @s("oldpos", @g(@print("bcpos_",@g("arg3")))); @s(@print("bcloc_",@g("arg3")), @g("arg2")); @s(@print("bcpos_",@g("arg3")), @g(@print("nbc_",@g("arg2")))); @fieldloop("2117","bcloc_", @switch( @and(@eq("%v",@g("arg1")), @gt(@g(@print("bcpos_",@substr("%f","6"))),@g("oldpos"))), "1", @s(@print("bcpos_",@substr("%f","6")), @sub(@g(@print("bcpos_",@substr("%f","6")),1)))); @s(@print("nbc_",@g("arg1")), @sub(@g(@print("nbc_",@g("arg1"))),"1")); @s(@print("nbc_",@g("arg2")), @add(@g(@print("nbc_",@g("arg2"))),"1")); @s("whodbr_arg1", @location(@switch(@g("whoclr_arg1"), 1,10488,2,10489,3,10490,4,10487))); @s("whocna_arg1", @uc(@g(@print("clrnam",@g("whoclr_arg1"))))); @s("whodbr_arg2", @location(@switch(@g("whoclr_arg2"), 1,10488,2,10489,3,10490,4,10487))); @s("whocna_arg2", @uc(@g(@print("clrnam",@g("whoclr_arg2"))))); @tell(@g("whodbr_arg1"),@print("You give a ", @g(@print("bcnam_",@g("arg3"))), " card to ", @g("whocna_arg2"), ".")); @tell(@g("whodbr_arg2"),@print(@g("whocna_arg1"), " gives a ", @g(@print("bcnam_",@g("arg3"))), " card to you.")); @tellroom(@location("%#"),{@g("whodbr_arg1"),@g("whodbr_arg2")},@print(@g("whocna_arg1"), " gives a card to ", @g("whocna_arg2"), "."));
=====

// list the battle cards of location lstloc.
// NOTE: **TODO** this isn't listing the cards in position order yet.
@field bot = botlstbc :
 // first, count how many crew are at that location (ie: set lstcnt).
 @s("lstcnt","0");
 @fieldloop("2117","bcloc_",@switch("%v",@g("lstloc"),
  @s("lstcnt",@add(@g("lstcnt"),"1"))
 ));
 // if lstcnt=0, the list is "nothing"
 @switch(@g("lstcnt"),"0","nothing", @print(
 // else
  @s("lsti","1"),
  @fieldloop("2117","bcloc_", @switch( "%v", @g("lstloc"), @print(
    // name (code)
    @g(@print("bcnam_",@substr("%f","6"))), " (",
    @g(@print("bccod_",@substr("%f","6"))),
    ")",
    // if 2nd last, print " and "
    @switch(@g("lsti"), @sub(@g("lstcnt"),"1"), " and ",
    // else if not last, "print ", "
      @g("lstcnt"), "", ", "),
    // increment lsti
    @s("lsti",@add(@g("lsti"),"1"))
  )))
 ));

Implied Objects: Crew counters

//  GameBot fieldnames w.r.t. Crew Counters
//  where XX is the counter number (0..23).
//  NOTE: XX can't be a name, because need to generate fldname for shuffling
//  -------------------------------------------
//  ccloc_XX   Location of XX
//  ccpos_XX   Position of XX within location ccloc_XX
//  ccnam_XX   Name of XX
//  ccspe_XX   Specialty code
//  cclkd_XX   0 = unlocked; 1 = locked
//  ccsexs     A 24-character 'array', where M = male; F = female
//  spenam_N   Name of specialty #N
//  speabbr_N  Abbreviation of specialty #N's name

@field bot = ccsexs : MMMMFMFFMFFMMMMMMMFMFFFM

@field bot = ccnam_0 : Starfleet
@field bot = ccnam_1 : Kirk
@field bot = ccnam_2 : Scott
@field bot = ccnam_3 : Spock
@field bot = ccnam_4 : Uhura
@field bot = ccnam_5 : Kyle
@field bot = ccnam_6 : Rand
@field bot = ccnam_7 : Cadet
@field bot = ccnam_8 : McCoy
@field bot = ccnam_9 : Chapel
@field bot = ccnam_10 : Noel
@field bot = ccnam_11 : Cadet
@field bot = ccnam_12 : Chekov
@field bot = ccnam_13 : Riley
@field bot = ccnam_14 : Sulu
@field bot = ccnam_15 : Cadet
@field bot = ccnam_16 : Jones
@field bot = ccnam_17 : Manning
@field bot = ccnam_18 : Landon
@field bot = ccnam_19 : Cadet
@field bot = ccnam_20 : Barrows
@field bot = ccnam_21 : Palamas
@field bot = ccnam_22 : Romaine
@field bot = ccnam_23 : Cadet

//  Specialty codes (0=any; 1=cmnd; 2=commun; 3=med; 4=nav; 5=sec; 6=sci)
@field bot = ccspe_0 : 0
@field bot = ccspe_1 : 1
@field bot = ccspe_2 : 1
@field bot = ccspe_3 : 1
@field bot = ccspe_4 : 2
@field bot = ccspe_5 : 2
@field bot = ccspe_6 : 2
@field bot = ccspe_7 : 2
@field bot = ccspe_8 : 3
@field bot = ccspe_9 : 3
@field bot = ccspe_10 : 3
@field bot = ccspe_11 : 3
@field bot = ccspe_12 : 4
@field bot = ccspe_13 : 4
@field bot = ccspe_14 : 4
@field bot = ccspe_15 : 4
@field bot = ccspe_16 : 5
@field bot = ccspe_17 : 5
@field bot = ccspe_18 : 5
@field bot = ccspe_19 : 5
@field bot = ccspe_20 : 6
@field bot = ccspe_21 : 6
@field bot = ccspe_22 : 6
@field bot = ccspe_23 : 6

// Specialty names
@field bot = spenam_0: ANY
@field bot = spenam_1: Command
@field bot = spenam_2: Communication
@field bot = spenam_3: Medical
@field bot = spenam_4: Navigation
@field bot = spenam_5: Security
@field bot = spenam_6: Science

// Specialty abbreviations
@field bot = speabbr_0: ANY
@field bot = speabbr_1: Cmnd.
@field bot = speabbr_2: Commun.
@field bot = speabbr_3: Med.
@field bot = speabbr_4: Nav.
@field bot = speabbr_5: Sec.
@field bot = speabbr_6: Sci.

// shuffle the Crew counters
@field bot = botshuf_c :
 @tellroom(@location("%#"),"",@print("GameBoard shuffles the Crew counters.
  It puts ",
  @switch(@g("nwho"),"2","3","2"),
  " crew on each player's rack, and randomly distributes the other ",
  @sub("24",@switch(@g("nwho"),"2","6","3","6","4","8","0")),
  " crew face down amongst the Adventure spaces."));
 @call("2117","init_nccs");
 // first initialize ccpos_X = X, ccloc_X = 0, cclkd_X = 0
 @s("i","0");
 @fieldloop("2117","ccnam_", @print(
	@s(@print("ccpos_",@g("i")),@g("i")), 
	@s(@print("ccloc_",@g("i")),"0"),
	@s(@print("cclkd_",@g("i")),"0"),
	@s("i",@add(@g("i"),"1"))
 ));
 // Do the actual shuffling (via ccpos's)
 // for i=23..1 { j=rand(0..i); k=pos(i); pos(i)=pos(j); pos(j)=k; }
 @s("i","23");
 @strloop("xxxxxxxxxxxxxxxxxxxxxxx","x", @print(
    @s( "j", @rand(@g("i")) ),
    @s( "k", @g(@print("ccpos_",@g("i"))) ),
    @s( @print("ccpos_",@g("i")), @g(@print("ccpos_",@g("j"))) ),
    @s( @print("ccpos_",@g("j")), @g("k") ),
    @s( "i", @sub(@g("i"),"1") )
 ));

// list the crew contents of location lstloc.
// NOTE: **TODO** this isn't listing the crew in position order yet.
@field bot = botlstcc :
 // first, count how many crew are at that location (ie: set lstcnt).
 @s("lstcnt","0");
 @fieldloop("2117","ccloc_",@switch("%v",@g("lstloc"),
  @s("lstcnt",@add(@g("lstcnt"),"1"))
 ));
 // if lstcnt=0, the list is "nobody"
 @switch(@g("lstcnt"),"0","nobody", @print(
 // else
  @s("lsti","1"),
  @fieldloop("2117","ccloc_", @switch( "%v", @g("lstloc"), @print(
    // name (specialty/locked)
    @g(@print("ccnam_",@substr("%f","6"))), " (",
    @g(@print("speabbr_",@g(@print("ccspe_",@substr("%f","6"))))),
    @switch(@g(@print("cclkd_",@substr("%f","6"))),"1","/locked"),
    ")",
    // if 2nd last, print " and "
    @switch(@g("lsti"), @sub(@g("lstcnt"),"1"), " and ",
    // else if not last, "print ", "
      @g("lstcnt"), "", ", "),
    // increment lsti
    @s("lsti",@add(@g("lsti"),"1"))
  )))
 ));

// BOTDEALCC1
// Deals 1 crew counter from location "arg1" to location "arg2".
//--------------------------------------------------------------
// - Field ccloc_XX has the location of crew member #XX.
// - Field ccpos_XX has the position of crew member #XX within the location.
// - Field ncc_LL has the number of crew counters in location #LL.
// - Note that the value of ccpos_XX should be from 0..ncc_{ccloc_XX}.
//--------------------------------------------------------------
// Eg: If "arg1" is 0, and "arg2" is 41,
//     Then search the cc fields for XX such that
//        ccloc_XX = 0 and ccpos_XX = ncc_0 - 1 (deal off bottom of loc0).
//     When you find XX, do this:
//        ccloc_XX = 41; ccpos_XX = ncc_41 (add to bottom of loc41). 
//     Then ncc_0--; ncc_41++.
//     Set value of cc_moved to XX
//--------------------------------------------------------------
@field gamebot = botdealcc1 :
@fieldloop("2117","ccloc_",
  @switch( @and(@eq("%v",@g("arg1")),
       @eq(@g(@print("ccpos_",@substr("%f","6"))),
       @sub(@g(@print("ncc_",@g("arg1"))),"1"))),
     "1",
     @print(
      @s("cc_moved",@substr("%f","6")),
	@s("%f",@g("arg2")),
	@s(@print("ccpos_",@substr("%f","6")), @g(@print("ncc_",@g("arg2"))))
     )
  )	
);
@s(@print("ncc_",@g("arg1")), @sub(@g(@print("ncc_",@g("arg1"))),"1"));
@s(@print("ncc_",@g("arg2")), @add(@g(@print("ncc_",@g("arg2"))),"1"));

// BOTDEAL_CS
//-------------
// GameBot deals 2 (or 3) crewmen to each player's rack.
// GameBot should only do this once per game, during setup.
//-------------
// for each player { botdealcc1, botdealcc1, if 2 players {botdealcc1} }
@field #2117 = botdeal_cs :
 @s("arg1","0");
 @switch(@g("db_who_b"),"0","", @print(@s("arg2","41"),
  @call("2117","botdealcc1"),@call("2117","botdealcc1"),
  @switch(@eq(@g("nwho"),"2"), "1", @call("2117","botdealcc1")) ));
 @switch(@g("db_who_r"),"0","", @print(@s("arg2","42"),
  @call("2117","botdealcc1"),@call("2117","botdealcc1"),
  @switch(@eq(@g("nwho"),"2"), "1", @call("2117","botdealcc1")) ));
 @switch(@g("db_who_g"),"0","", @print(@s("arg2","43"),
  @call("2117","botdealcc1"),@call("2117","botdealcc1"),
  @switch(@eq(@g("nwho"),"2"), "1", @call("2117","botdealcc1")) ));
 @switch(@g("db_who_y"),"0","", @print(@s("arg2","44"),
  @call("2117","botdealcc1"),@call("2117","botdealcc1"),
  @switch(@eq(@g("nwho"),"2"), "1", @call("2117","botdealcc1")) ));

// BOTMAROON_ALL
// maroon all crew not on a rack
//---
// for each cc{ if loc_X is 0{ move cc_X to rand(1..20) }}
@field bot = botmaroon_all :
 @s("arg1","0");
 @strloop( @substr("xxxxxxxxxxxxxxxxxxxxxxxx",0,@g("ncc_0")), "x", @print(
   @s("arg2",@add(@rand("20"),"1")),
   @call("2117","botdealcc1")
 ));

@field bot = init_nccs :
 @s("ncc_0","24"); @s("ncc_1","0"); @s("ncc_2","0"); @s("ncc_3","0");
 @s("ncc_4","0"); @s("ncc_5","0"); @s("ncc_6","0"); @s("ncc_7","0");
 @s("ncc_8","0"); @s("ncc_9","0"); @s("ncc_10","0"); @s("ncc_11","0");
 @s("ncc_12","0"); @s("ncc_13","0"); @s("ncc_14","0"); @s("ncc_15","0");
 @s("ncc_16","0"); @s("ncc_17","0"); @s("ncc_18","0"); @s("ncc_19","0");
 @s("ncc_20","0"); @s("ncc_41","0"); @s("ncc_42","0"); @s("ncc_43","0");
 @s("ncc_44","0");

Implied Objects: Players

Some clarifications on the concepts, here.

// Fields w.r.t. Player roles
// ------------------------------
// nwho    = number of players in the game (2..4)
// whoclrs = a simple string containing the colors in play.
//           Eg: "234" means red+green+yellow,
//           "134" means blue+green+yellow, "14" means blue+yellow, etc.
// whoord_turn = The order# of the player whose turn it is.
// whoclr_turn = The color# of the player whose turn it is.
// whodbr_turn = The dbref# of the player whose turn it is.
// whocna_turn = The colorname of the player whose turn it is.
// ------------
// whoclr_inadv = The color# of the player who's in an adventure.
// whoclr_chosen = The color# of the player who's been "chosen".
// whoclr_least = The color# of the player who's "Least Crew".
// whoclr_most = The color# of the player who's "Most Crew".
// whoclr_bat1 = The color# of the player who started a battle.
// whoclr_bat2 = The color# of the player who opposes whoord_bat2.
// whoclr_batwin = The color# of the player who won the battle.
// whoclr_batlos = The color# of the player who lost the battle.

// CALC_WHO1ST_TURN
// Calculate which player goes first
// - assumes whoclrs and nwho are already calculated
// - sets whoord_turn, whoclr_turn, whodbr_turn
// --------------------------------------------------
@field bot = calc_who1st_turn :
  @s("whoord_turn", @rand(@g("nwho")));
  @s("whoclr_turn", @substr(@g("whoclrs"),@g("whoord_turn"),1));
  @call(2117,"calc_whodbr_turn");
-----
**TEST**
@field bot = calc_who1st_turn : @s("whoord_turn", @rand(@g("nwho"))); @s("whoclr_turn", @substr(@g("whoclrs"),@g("whoord_turn"),1)); @call(2117,"calc_whodbr_turn");
=====

// CALC_WHONXT_TURN
// Calculate the next player to take a turn
// - sets whoord_turn, whoclr_turn, whodbr_turn
// ----------------------------------------
@field bot = calc_whonxt_turn :
  @s("whoord_turn", @mod(@add(@g("whoord_turn"),1),@g("nwho")));
  @s("whoclr_turn", @substr(@g("whoclrs"),@g("whoord_turn"),1));
  @call(2117,"calc_whodbr_turn");
-----
**TEST**
@field bot = calc_whonxt_turn : @s("whoord_turn", @mod(@add(@g("whoord_turn"),1),@g("nwho"))); @s("whoclr_turn", @substr(@g("whoclrs"),@g("whoord_turn"),1)); @call(2117,"calc_whodbr_turn");
=====

// CALC_WHOCLR_LEAST
// Calculate the player with the "least crew", excluding
// the player "whoclr_inadv". Store value in whoclr_least.
// Note 1) In a 2-player game, this is always the other player.
// Note 2) If there's a tie, set whoclr_least to 0,
//  and set isclropt1..4 to 1 if theyre a candidate.
// ----------------------------------------
@field bot = calc_whoclr_least :
  @strloop("1234","x",@s("isclropt%x",0));
  @s("low_cc",0);
  @strloop(@g("whoclrs"),"x",@switch("1",
    @eq("%x",@g("whoclr_inadv")),"",
    @lt(@g(@print("ncc_,@add(40,"%x"))),@g("low_cc")),
      @s("low_cc",@g(@print("ncc_",@add(40,"%x"))))
  ));
  @s("nlow_cc",0);
  @strloop(@g("whoclrs"),"x",@switch("1",
    @eq(@g(@print("ncc_,@add(40,"%x"))),@g("low_cc")), @print(
      @s("nlow_cc",@add(1,@g("nlow_cc"))),
      @s("isclropt%x",1),
      @s("whoclr_least","%x")
    )
  ));
  @switch("1",@gt(@g("nlow_cc"),1),@s("whoclr_least",0));
-----
**TEST**
@field bot = calc_whoclr_least : @strloop("1234","x",@s("isclropt%x",0)); @s("low_cc",0); @strloop(@g("whoclrs"),"x",@switch("1", @eq("%x",@g("whoclr_inadv")),"", @lt(@g(@print("ncc_,@add(40,"%x"))),@g("low_cc")), @s("low_cc",@g(@print("ncc_",@add(40,"%x")))))); @s("nlow_cc",0); @strloop(@g("whoclrs"),"x",@switch("1", @eq(@g(@print("ncc_,@add(40,"%x"))),@g("low_cc")), @print(@s("nlow_cc",@add(1,@g("nlow_cc"))), @s("isclropt%x",1), @s("whoclr_least","%x")))); @switch("1",@gt(@g("nlow_cc"),1),@s("whoclr_least",0));
=====

// CALC_WHOCLR_MOST
// Calculate the player with the "most crew", excluding
// the player "whoclr_inadv". Store value in whoclr_most.
// Note 1) In a 2-player game, this is always the other player.
// Note 2) If there's a tie, set whoclr_most to 0.
//  and set isclropt1..4 to 1 if theyre a candidate.
// ------------------------------------------
@field bot = calc_whoclr_most :
  @strloop("1234","x",@s("isclropt%x",0));
  @s("high_cc",0);
  @strloop(@g("whoclrs"),"x",@switch("1",
    @eq("%x",@g("whoclr_inadv")),"",
    @gt(@g(@print("ncc_,@add(40,"%x"))),@g("high_cc")),
      @s("high_cc",@g(@print("ncc_",@add(40,"%x"))))
  ));
  @s("nhigh_cc",0);
  @strloop(@g("whoclrs"),"x",@switch("1",
    @eq(@g(@print("ncc_,@add(40,"%x"))),@g("high_cc")), @print(
      @s("nhigh_cc",@add(1,@g("nhigh_cc"))),
      @s("isclropt%x",1),
      @s("whoclr_most","%x")
    )
  ));
  @switch("1",@gt(@g("nhigh_cc"),1),@s("whoclr_most",0));
-----
**TEST**
@field bot = calc_whoclr_most : @strloop("1234","x",@s("isclropt%x",0)); @s("high_cc",0); @strloop(@g("whoclrs"),"x",@switch("1", @eq("%x",@g("whoclr_inadv")),"", @gt(@g(@print("ncc_,@add(40,"%x"))),@g("high_cc")), @s("high_cc",@g(@print("ncc_",@add(40,"%x")))))); @s("nhigh_cc",0); @strloop(@g("whoclrs"),"x",@switch("1", @eq(@g(@print("ncc_,@add(40,"%x"))),@g("high_cc")), @print(@s("nhigh_cc",@add(1,@g("nhigh_cc"))), @s("isclropt%x",1), @s("whoclr_most","%x")))); @switch("1",@gt(@g("nhigh_cc"),1),@s("whoclr_most",0));
=====

// This has to be recalc'd all the time at the top of several actions
// in case players have changed.
@field bot = calc_whodbr_inadv :
  @s("whodbr_inadv", @location(@switch(@g("whoclr_inadv"),
    1,10488,2,10489,3,10490,4,10487)));
  @s("whocna_inadv", @uc(@g(@print("clrnam",@g("whoclr_inadv")))));
  @s("whorna_inadv", @shortname(@g("whodbr_inadv")));
--------
**TEST**
@field bot = calc_whodbr_inadv : @s("whodbr_inadv", @location(@switch(@g("whoclr_inadv"), 1,10488,2,10489,3,10490,4,10487))); @s("whocna_inadv", @uc(@g(@print("clrnam",@g("whoclr_inadv"))))); @s("whorna_inadv", @shortname(@g("whodbr_inadv")));
========

@field bot = calc_whodbr_turn :
  @s("whodbr_turn", @location(@switch(@g("whoclr_turn"),
    1,10488,2,10489,3,10490,4,10487)));
  @s("whocna_turn", @uc(@g(@print("clrnam",@g("whoclr_turn")))));
  @s("whorna_turn", @shortname(@g("whodbr_turn")));
------
**TEST**
@field bot = calc_whodbr_turn : @s("whodbr_turn", @location(@switch(@g("whoclr_turn"), 1,10488,2,10489,3,10490,4,10487))); @s("whocna_turn", @uc(@g(@print("clrnam",@g("whoclr_turn"))))); @s("whorna_turn", @shortname(@g("whodbr_turn")));
======

@field bot = calc_whodbr_chosen :
  @s("whodbr_chosen", @location(@switch(@g("whoclr_chosen"),
    1,10488,2,10489,3,10490,4,10487)));
  @s("whocna_chosen", @uc(@g(@print("clrnam",@g("whoclr_chosen")))));
  @s("whorna_chosen", @shortname(@g("whodbr_chosen")));
------
**TEST**
@field bot = calc_whodbr_chosen : @s("whodbr_chosen", @location(@switch(@g("whoclr_chosen"), 1,10488,2,10489,3,10490,4,10487))); @s("whocna_chosen", @uc(@g(@print("clrnam",@g("whoclr_chosen"))))); @s("whorna_chosen", @shortname(@g("whodbr_chosen")));
======

@field bot = calc_whodbr_least :
  @s("whodbr_least", @location(@switch(@g("whoclr_least"),
    1,10488,2,10489,3,10490,4,10487)));
  @s("whocna_least", @uc(@g(@print("clrnam",@g("whoclr_least")))));
  @s("whorna_least", @shortname(@g("whodbr_least")));
-----
**TEST**
@field bot = calc_whodbr_least : @s("whodbr_least", @location(@switch(@g("whoclr_least"), 1,10488,2,10489,3,10490,4,10487))); @s("whocna_least", @uc(@g(@print("clrnam",@g("whoclr_least"))))); @s("whorna_least", @shortname(@g("whodbr_least")));
=====

@field bot = calc_whodbr_most :
  @s("whodbr_most", @location(@switch(@g("whoclr_most"),
    1,10488,2,10489,3,10490,4,10487)));
  @s("whocna_most", @uc(@g(@print("clrnam",@g("whoclr_most")))));
  @s("whorna_most", @shortname(@g("whodbr_most")));
-----
**TEST**
@field bot = calc_whodbr_most : @s("whodbr_most", @location(@switch(@g("whoclr_most"), 1,10488,2,10489,3,10490,4,10487))); @s("whocna_most", @uc(@g(@print("clrnam",@g("whoclr_most"))))); @s("whorna_most", @shortname(@g("whodbr_most")));
=====

Related Objects: Ships

// GameBot fields w.r.t. ships
// Note ship1=blue, ship2=red, ship3=green, ship4=yellow
// -----------------------------------------------------
// shipX_loc = Location of shipX (X=1..4)
// shipX_pos = Position of shipX with location (only important for Vortex)

blue Enterprise (dbref #2229)

@create blue Enterprise;blue ship;be;Enterprise;blue;ship
@set #2229 = dark
@field #2229 = varobj : 2117
@lock #2229 = me & !me
@zone #2229 = #10719
@desc #2229 = @switch(@g("ship1_loc"), "41", "BLUE is on the Blue Base
 World.", "21", @switch(@g("ship1_pos"),"0", "BLUE is on the Mind Meld
 space of the Battle Vortex", @print("BLUE is on Battle space ",
 @g("ship1_pos"), " in the Battle Vortex.")), "0", "This is a small blue
 model of the starship Enterprise.", "99", "I don't see that here.",
 @print("BLUE is on Adventure space ", @g("ship1_loc"), "."));

red Enterprise (dbref #2236)

@create red Enterprise;red ship;re;Enterprise;red;ship
@set #2236 = dark
@field #2236 = varobj : 2117
@lock #2236 = me & !me
@zone #2236 = #10719
@desc #2236 = @switch(@g("ship2_loc"), "42", "RED is on the Red Base
 World.", "21", @switch(@g("ship2_pos"),"0", "RED is on the Mind Meld
 space of the Battle Vortex", @print("RED is on Battle space ",
 @g("ship2_pos"), " in the Battle Vortex.")), "0", "This is a small red
 model of the starship Enterprise.", "99", "I don't see that here.",
 @print("RED is on Adventure space ", @g("ship2_loc"), "."));

green Enterprise (dbref #2235)

@create green Enterprise;green ship;ge;Enterprise;green;ship
@set #2235 = dark
@field #2235 = varobj : 2117
@lock #2235 = me & !me
@zone #2235 = #10719
@desc #2235 = @switch(@g("ship3_loc"), "43", "GREEN is on the Green Base
 World.", "21", @switch(@g("ship3_pos"),"0", "GREEN is on the Mind Meld
 space of the Battle Vortex", @print("GREEN is on Battle space ",
 @g("ship3_pos"), " in the Battle Vortex.")), "0", "This is a small green
 model of the starship Enterprise.", "99", "I don't see that here.",
 @print("GREEN is on Adventure space ", @g("ship3_loc"), "."));

yellow Enterprise (dbref #2160)

@create yellow Enterprise;yellow ship;ye;Enterprise;yellow;ship
@set #2160 = dark
@field #2160 = varobj : 2117
@lock #2160 = me & !me
@zone #2160 = #10719
@desc #2160 = @switch(@g("ship4_loc"), "44", "YELLOW is on the Yellow Base
 World.", "21", @switch(@g("ship4_pos"),"0", "YELLOW is on the Mind Meld
 space of the Battle Vortex", @print("YELLOW is on Battle space ",
 @g("ship4_pos"), " in the Battle Vortex.")), "0", "This is a small yellow
 model of the starship Enterprise.", "99", "I don't see that here.",
 @print("YELLOW is on Adventure space ", @g("ship4_loc"), "."));

Related Objects: Hands

blue hand (dbref #10492)

@create blue hand;blue cards;hand;cards;bh
@field #10492 = varobj : 2117
@zone #10492 = #10719
@link #10492 = #10322
@desc #10492 = @switch(@location("%!"), "%#", @print("In the blue hand,
 you see ", @setfield("2117","lstloc","41"), @call("2117","botlstbc"),
 "."), "It's the blue player's hand. You can't see what's in it because
 you're not holding it.");

red hand (dbref #10493)

@create red hand;red cards;hand;cards;rh
@field #10493 = varobj : 2117
@zone #10493 = #10719
@link #10493 = #10322
@desc #10493 = @switch(@location("%!"), "%#", @print("In the red hand,
 you see ", @setfield("2117","lstloc","42"), @call("2117","botlstbc"),
 "."), "It's the red player's hand. You can't see what's in it because
 you're not holding it.");

green hand (dbref #10494)

@create green hand;green cards;hand;cards;gh
@field #10494 = varobj : 2117
@zone #10494 = #10719
@link #10494 = #10322
@desc #10494 = @switch(@location("%!"), "%#", @print("In the green hand,
 you see ", @setfield("2117","lstloc","43"), @call("2117","botlstbc"),
 "."), "It's the green player's hand. You can't see what's in it because
 you're not holding it.");

yellow hand (dbref #10491)

@create yellow hand;yellow cards;hand;cards;yh
@field #10491 = varobj : 2117
@zone #10491 = #10719
@link #10491 = #10322
@desc #10491 = @switch(@location("%!"), "%#", @print("In the yellow hand,
 you see ", @setfield("2117","lstloc","44"), @call("2117","botlstbc"),
 "."), "It's the yellow player's hand. You can't see what's in it because
 you're not holding it.");

Related Objects: Racks

blue bridge rack (dbref #10488)

@create blue bridge rack;blue bridge;blue rack;bridge rack;bridge;rack;bbr
@zone #10488 = #10719
@desc #10488 = @switch(@location("%!"), "%#", @print("On the blue bridge
 rack, you see ", @setfield("2117","lstloc","41"),
 @call("2117","botlstcc"), "."), "It's the blue player's bridge rack.
 You can't see what's on it because you're not holding it.");

red bridge rack (dbref #10489)

@create red bridge rack;red bridge;red rack;bridge rack;bridge;rack;rbr
@zone #10489 = #10719
@desc #10489 = @switch(@location("%!"), "%#", @print("On the red bridge
 rack, you see ", @setfield("2117","lstloc","42"),
 @call("2117","botlstcc"), "."), "It's the red player's bridge rack.
 You can't see what's on it because you're not holding it.");

green bridge rack (dbref #10490)

@create green bridge rack;green bridge;green rack;bridge rack;bridge;
 rack;gbr
@zone #10490 = #10719
@desc #10490 = @switch(@location("%!"), "%#", @print("On the green bridge
 rack, you see ",@setfield("2117","lstloc","43"),
 @call("2117","botlstcc"), "."), "It's the green player's bridge rack.
 You can't see what's on it because you're not holding it.");

yellow bridge rack (dbref #10487)

@create yellow bridge rack;yellow bridge;yellow rack;bridge rack;bridge;
 rack;ybr
@zone #10487 = #10719
@desc #10487 = @switch(@location("%!"), "%#", @print("On the yellow
 bridge rack, you see ", @setfield("2117","lstloc","44"),
 @call("2117","botlstcc"), "."), "It's the yellow player's bridge rack.
 You can't see what's on it because you're not holding it.");

Unsorted and Undercooked stuff

@field bot = bottake : 
  @tell(@location(@g("arg1")),@print("%cGameBot takes ",
    @shortname(@g("arg1")), " from you."));
  @tellroom(@location("%#"),@location(@g("arg1")),@print("GameBot takes ",
    @shortname(@g("arg1")), 
    @switch(@type(@location(@g("arg1"))),"2",@print(" from ",
    @shortname(@location(@g("arg1"))))), "."));
  @move(@g("arg1"),@location("%#")); @setflag(@g("arg1"),"dark");
  @setfield(@g("arg1"),"lock","me & !me");

@field bot = botgive :
  @move(@g("arg1"),@g("arg2"));
  @setflag(@g("arg1"),"!dark"); @setfield(@g("arg1"),"lock","");
  @tell(@g("arg2"),@print("GameBoard gives ",
    @shortname(@g("arg1")), " to you."));
  @tellroom(@location("%#"),@g("arg2"),@print("GameBoard gives ",
    @shhortname(@g("arg1")), " to ", @shortname(@g("arg2")), "."));

// Call this at the end of an adventure. Say that the adventure is over.
// 1a) If whoclr_inadv moved during this adventure, he starts a new adventure.
// 1b) Else if someone else moved, then they start a new adventure.
//     NOTE: test whoclr_nxtadv and nxtadv_rolled 
// 2) Else if winner of battle is in Battle Vortex, move him out.
// 3) Else if loser of battle is in Battle Vortex, move him out.
// 4) Else goto phase5 (possible Tractor Zone Battle)
// 5) Then test if anyone has won the game.
// LOTS TODO!!
@field bot = end_adv :
  @tellroom(@location("%#"),"","GameBoard says, \"This adventure is over.\"");
  @tellroom(@location("%#"),"","[TODO: Lots of stuff]");
  @call(2117,"end_turn");
------
**TEST**
@field bot = end_adv : @tellroom(@location("%#"),"","GameBoard says, \"This adventure is over.\""); @tellroom(@location("%#"),"","[TODO: Lots of stuff]"); @call(2117,"end_turn");
======

@field bot = end_turn :
  @tellroom(@location("%#"),"",@print(
    "GameBoard says, \"", @g("whocna_turn")))), "'s turn ends.\""
  ));
  @call(2117,"calc_whonxt_turn");
  @s("isbatdone",0);
  @s("gstate",3);
  @tellroom(@location("%#"),"",@print(
    "GameBoard says (to ", @g("whorna_turn"), "), \"", @g("whocna_turn"),
    ", it is now your turn. 'ROLL' the die.\""
  ));
------
**TEST**
@field bot = end_turn : @tellroom(@location("%#"),"",@print("GameBoard says, \"", @g("whocna_turn"), "'s turn ends.\"")); @call(2117,"calc_whonxt_turn"); @s("isbatdone",0); @s("gstate",3); @tellroom(@location("%#"),"",@print("GameBoard says (to ", @g("whorna_turn"), "), \"", @g("whocna_turn"), ", it is now your turn. 'ROLL' the die.\""));
======

@field bot = echo_ct :
  @tellroom(@location("%#"),"",@print(
    "%n says, \"Cardtype ", @g(@print("ctnam_",@g("ct_chosen"))), "\""
  ));
-----
**ADD**
@field bot = echo_ct : @tellroom(@location("%#"),"",@print("%n says, \"Cardtype ", @g(@print("ctnam_",@g("ct_chosen"))), "\""));
=====

@field bot = echo_back : @tellroom(@location("%#"),"","%n says, \"Back.\"");
@field bot = echo_danger : @tellroom(@location("%#"),"","%n says, \"Danger.\"");
@field bot = echo_deck : @tellroom(@location("%#"),"","%n says, \"Deck.\"");
@field bot = echo_forward : @tellroom(@location("%#"),"","%n says, \"Forward.\"");
@field bot = echo_impulse : @tellroom(@location("%#"),"","%n says, \"Impulse.\"");
@field bot = echo_player : @tellroom(@location("%#"),"",@print("%n says, \"Player ", @ucfirst(@g(@print("clrnam",@g("whoclr_chosen")))), ".\""));
@field bot = echo_protect : @tellroom(@location("%#"),"","%n says, \"Protect.\"");

// note: assumes why_pro_ok set,
//       eg: @s("why_pro_ok","officer with Science")
@field bot = echo_pro_ok :
  @tellroom(@location("%#"),"", @print(
  "GameBoard says, \"Protect Confirmed. ", @g("whocna_inadv"),
  " has at least one ", @g("why_pro_ok"), "."));
-----
**TEST**
@field bot = echo_pro_ok : @tellroom(@location("%#"),"", @print("GameBoard says, \"Protect Confirmed. ", @g("whocna_inadv"), " has at least one ", @g("why_pro_ok"), "."));
=====

@field bot = echo_pro_nok :
  @tellroom(@location("%#"),"", @print(
  "GameBoard says, \"Protect Denied. ", @g("whocna_inadv"),
  " does not have any ", @g("why_pro_ok"), ". Must choose Danger instead.\"")),
-----
**TEST**
@field bot = echo_pro_nok : @tellroom(@location("%#"),"", @print("GameBoard says, \"Protect Denied. ", @g("whocna_inadv"), " does not have any ", @g("why_pro_ok"), ". Must choose Danger instead.\"")),
=====

**TEST NODEL**
@field bot = echo_space : @tellroom(@location("%#"),"",@print("%n says, \"Space #", @g("space_chosen"), ".\""));

**TEST NODEL**
@field bot = echo_warp : @tellroom(@location("%#"),"","%n says, \"Warp.\"");

// note: assumes why_warp_ok set,
//       eg: @s("why_warp_ok","officer with Science")
@field bot = echo_warp_ok :
  @tellroom(@location("%#"),"", @print(
    "GameBoard says, \"Warp Confirmed. ", @g("whocna_inadv"),
    " has at least one ", @g("why_warp_ok"), "."));
-----
**TEST**
@field bot = echo_warp_ok : @tellroom(@location("%#"),"", @print("GameBoard says, \"Warp Confirmed. ", @g("whocna_inadv"), " has at least one ", @g("why_warp_ok"), "."));
=====

// note: assumes why_warp_ok set,
//       eg: @s("why_warp_ok","of Kirk, Spock, or McCoy")
@field bot = echo_warp_nok :
  @tellroom(@location("%#"),"", @print(
    "GameBoard says, \"Warp Denied. ", @g("whocna_inadv")))),
    " does not have any ", @g("why_warp_ok"), ". Must choose Impulse instead.\""));
-----
**TEST**
@field bot = echo_warp_nok : @tellroom(@location("%#"),"", @print("GameBoard says, \"Warp Denied. ", @g("whocna_inadv"), " does not have any ", @g("why_warp_ok"), ". Must choose Impulse instead.\""));
=====

@field bot = q_ct :
  @tellroom(@location("%#"),"",@print(
    "GameBoard says (to ", @g("whorna_inadv"),
    "), \"", @g("whocna_inadv"),
    ", name a cardtype, eg: 'CARDTYPE P1'.
    (Valid cardtypes are: CA, ESC, MAL, P1, P2, P3, PT, S1, S2, TR, and W2.)\""
  ));
-----
**ADD**
@field bot = q_ct : @tellroom(@location("%#"),"",@print("GameBoard says (to ", @g("whorna_inadv"), "), \"", @g("whocna_inadv"), ", name a cardtype, eg: 'CARDTYPE P1'. (Valid cardtypes are: CA, ESC, MAL, P1, P2, P3, PT, S1, S2, TR, and W2.)\""));
=====

// assumes q1 is set
@field bot = q_who :
  @tellroom(@location("%#"),"",@print("GameBoard asks ",
   @g("whorna_inadv"), ", \"", @g("whocna_inadv"), ", ", @g("q1"),
   @call(2117,"list_clropts"), "\""))
---------
**TEST**
@field bot = q_who : @tellroom(@location("%#"),"",@print("GameBoard asks ", @g("whorna_inadv"), ", \"", @g("whocna_inadv"), ", ", @g("q1"), @call(2117,"list_clropts"), "\""))
=========

// with this fn, the value of q1 should be "first" or "second"
@field bot = q_who_or_deck :
  @tellroom(@location("%#"),"",@print("GameBoard asks ",
   @g("whorna_inadv"), ", \"", @g("whocna_inadv"),
   ", where will you take your ", @g("q1"), " card from?",
   @call(2117,"list_clropts"), "Or the 'DECK'?\""))
---------
**TEST**
@field bot = q_who_or_deck : @tellroom(@location("%#"),"",@print("GameBoard asks ", @g("whorna_inadv"), ", \"", @g("whocna_inadv"), ", where will you take your ", @g("q1"), " card from?", @call(2117,"list_clropts"), "Or the 'DECK'?\""))
=========

@field bot = you_not_inadv :
  @tell("%#",@print("[Current choice must be made by the ",
  @g("whocna_inadv"), " player.]" ));
------
**TEST**
@field bot = you_not_inadv : @tell("%#",@print("[Current choice must be made by the ", @g("whocna_inadv"), " player.]" ));
======

@field bot = you_not_least :
  @tell("%#",@print("[Current choice must be made by the ",
  @g("whocna_least"), " player.]" ));
-----
**TEST**
@field bot = you_not_least : @tell("%#",@print("[Current choice must be made by the ", @g("whocna_least"), " player.]" ));
=====

@field bot = you_not_most :
  @tell("%#",@print("[Current choice must be made by the ",
  @g("whocna_most"), " player.]" ));
-----
**TEST**
@field bot = you_not_most : @tell("%#",@print("[Current choice must be made by the ", @g("whocna_most"), " player.]" ));
=====

// DEBUG ROUTINE - where's the adventure cards? [code:loc,pos]
// @exec @call("2117","bug_ac")
//-----------------------------
@field bot = bug_ac : 
 @fieldloop("2117","accod_", @print("[%v:",
  @g(@print("acloc_",@substr("%f","6"))), ",",
  @g(@print("acpos_",@substr("%f","6"))), "] "));

// DEBUG ROUTINE - where's the battle cards? [code:loc,pos]
// @exec @call("2117","bug_bc")
//-----------------------------
@field bot = bug_bc : 
 @fieldloop("2117","bccod_", @print("[%v:",
  @g(@print("bcloc_",@substr("%f","6"))), ",",
  @g(@print("bcpos_",@substr("%f","6"))), "] "));

// DEBUG ROUTINE - where's the crew? [name:loc,pos]
// @exec @call("2117","bug_cc")
//-----------------------------
@field bot = bug_cc : 
 @fieldloop("2117","ccnam_", @print("[%v:",
  @g(@print("ccloc_",@substr("%f","6"))), ",",
  @g(@print("ccpos_",@substr("%f","6"))), "]"));