Index / Orange System / last update: May 2002

Orange System | Starbase Battleship


Starbase Battleship (dbref #10321)

@dig Starbase Battleship
@field #10321 = exit_0 : 10350
@field #10321 = nexits : 1
@zone #10321 = #10719
@desc #10321 = @tell("%#","The curved gunmetal walls of Starbase Battleship
 are festooned with assorted wheels, pipes, trophies, and beer taps.
 In other words, it's a sports bar in a submarine. But less cramped.");
 @call(10633,"each_turn");

southeast (dbref #10350)

@open southeast;se;out;exit = #10325
@odrop #10350 = enters from the northwest.
@field #10350 = exitto : to Grand Gaming Central
@osucc #10350 = goes southeast.
@succe #10350 = You walk southeast...
@desc #10350 = @tell("%#","It's a portal connecting this starbase to
 Grand Gaming Central"); @call(10633,"each_turn");

recall button (dbref #11834)

If the game boards aren’t here, just push this button to get them back.

@create recall button;button;rb
@lock #11834 = #-1
@link #11834 = #10321
@fail #11834 = @tell("%#","The recall button is part of the wall.
 You can't take it."); @call(10633,"each_turn");
@desc #11834 = @tell("%#",@print("There's a small button on the wall
 labelled \"Recall\". Below it is a display that reads:
 \"Blue board: ",@shortname(@location(11812)),
 " / Red board: ",@shortname(@location(11813)),
 " / Viewer: ",@shortname(@location(11896)),"\"."));
 @call(10633,"each_turn");
@field #11834 = push : @tell("%#","You push the recall button.");
 @tellroom(@location("%#"),"%#","%n pushes the recall button.");
 @switch(@location("%!"),@location(11812),"",@print(
  @move(11812,@location("%!")),
  @tellroom(@location("%#"),"","The blue Battleship board appears
  in the room!")));
 @switch(@location("%!"),@location(11813),"",@print(
  @move(11813,@location("%!")),
  @tellroom(@location("%#"),"","The red Battleship board appears
  in the room!")));
 @switch(@location("%!"),@location(11896),"",@print(
  @move(11896,@location("%!")),
  @tellroom(@location("%#"),"","The public Battleship viewer appears
  in the room!")));
 @call(10633,"each_turn");

scenery (dbref #837)

@create scenery;wheels;pipes;trophies;trophy;beer taps;taps
@set #837 = dark
@fail #837 = The scenery objects are just here for show. They aren't functional.
@lock #837 = #-1
@desc #837 = The scenery objects are just here for show. They aren't functional.

blue Battleship board (dbref #11812)

@create blue Battleship board;blue board;Battleship board;board;bbb
@set #11812 = expert
@field #11812 = ohome : goes back home to Starbase Battleship.
@link #11812 = #10321
@desc #11812 = 
 @switch(1,
  @not(@eq(@location(11812),"%#")),
   "To play a game of Battleship, pick up this board
   and get another player to hold the red one. Only the
   players holding the boards can use them.
   Players do not have to be in the same room to play.
   Read the actions on the boards for more information.
   %cObvious Actions: rules, put * across from *, put * down from *,
   clear *, commit, shoot *, end game",
  @call(11812,"desc2"));
@field #11812 = desc2 :
 @call(11812,"init_legend");
 @strloop("_abcdefghijk","x",@print(
  @g("oppo_%x"),@g("line_%x"),@g("lgnd_%x"),"%c"
 ));
@succ #11812 =
 @print("You pick up the blue Battleship board, and its screen lights up.");
 @switch(@getfield(11896,"w_%#"),1,@print(
  @setfield(11896,"w_%#",""),
  "%cYou are no longer on the shipwatch.",
  @fieldloop(11896,"w_%#",@tell(@substr("%f",2),
   "[shipwatch] %n leaves the shipwatch."))
 ));
 @print("%cREMINDER: @leavec/@mutec #shipwatch if you're on the channel.");
 @s("line__",@print(@substr(@print("BLUE: ",
  @switch(@type(@location(11812)),2,
  @substr(@shortname(@location(11812)),0,14),"???"),
  "                "),0,24),"|"));
 @setfield(11813,"oppo__",@print(@substr(@print("BLUE: ",
  @switch(@type(@location(11812)),2,
  @substr(@shortname(@location(11812)),0,14),"???"),
  "                "),0,24),"|"));
---
TEST
@succ #11812 = @print("You pick up the blue Battleship board, and its screen lights up."); @switch(@getfield(11896,"w_%#"),1,@print( @setfield(11896,"w_%#",""), "%cYou are no longer on the shipwatch.", @fieldloop(11896,"w_%#",@tell(@substr("%f",2), "[shipwatch] %n leaves the shipwatch.")))); @print("%cREMINDER: @leavec/@mutec #shipwatch if you're on the channel."); @s("line__",@print(@substr(@print("BLUE: ", @switch(@type(@location(11812)),2, @substr(@shortname(@location(11812)),0,14),"???"), "                "),0,24),"|")); @setfield(11813,"oppo__",@print(@substr(@print("BLUE: ", @switch(@type(@location(11812)),2, @substr(@shortname(@location(11812)),0,14),"???"), "                "),0,24),"|"));
/// @s("oppo__",@print(@substr(@print("RED: ", @switch(@type(@location(11813)),2, @substr(@shortname(@location(11813)),0,14),"???"), "                "),0,24),"|"));
===
@drop #11812 = You drop the blue Battleship board, and its screen
 fades from view.

// phase 0 = setup; 1 = Blue's turn; 2 = Red's turn; 3 = postgame.
@field bbb = phase : 0

// your board layout.
@field bbb = line__ : BLUE: ???               |
@field bbb = line_a : a . . . . . . . . . .   |
@field bbb = line_b : b . . . . . . . . . .   |
@field bbb = line_c : c . . . . . . . . . .   |
@field bbb = line_d : d . . . . . . . . . .   |
@field bbb = line_e : e . . . . . . . . . .   |
@field bbb = line_f : f . . . . . . . . . .   |
@field bbb = line_g : g . . . . . . . . . .   |
@field bbb = line_h : h . . . . . . . . . .   |
@field bbb = line_i : i . . . . . . . . . .   |
@field bbb = line_j : j . . . . . . . . . .   |
@field bbb = line_k : + 1 2 3 4 5 6 7 8 9 10  |
// what you see on your opponent's board.
@field bbb = oppo__ : RED: ???                |
@field bbb = oppo_a : a . . . . . . . . . .   |
@field bbb = oppo_b : b . . . . . . . . . .   |
@field bbb = oppo_c : c . . . . . . . . . .   |
@field bbb = oppo_d : d . . . . . . . . . .   |
@field bbb = oppo_e : e . . . . . . . . . .   |
@field bbb = oppo_f : f . . . . . . . . . .   |
@field bbb = oppo_g : g . . . . . . . . . .   |
@field bbb = oppo_h : h . . . . . . . . . .   |
@field bbb = oppo_i : i . . . . . . . . . .   |
@field bbb = oppo_j : j . . . . . . . . . .   |
@field bbb = oppo_k : + 1 2 3 4 5 6 7 8 9 10  |

// the setup legend (these fields used by both boards)
@field bbb = init_legend :
 @s("lgnd__",@switch(@getfield(11812,"phase"),
 0,"Phase: Setup",1,"Phase: Blue's Turn",
 2,"Phase: Red's Turn",3,"Phase: Post-Game"));
 @s("lgnd_g",@switch(@getfield(11812,"phase"),
 0,"===== SETUP ACTIONS ====",3,"=== POSTGAME ACTIONS ===",
 "===== TURN ACTIONS ====="));
 @s("lgnd_i",@switch(@getfield(11812,"phase"),
 0,"put * across from *",3,"end game","shoot *"));
 @s("lgnd_j",@switch(@getfield(11812,"phase"),
 0,"put * down from *",3,"","end game"));
 @s("lgnd_k",@switch(@getfield(11812,"phase"),
 0,"clear *, commit",""));
@field bbb = lgnd__ : Phase:
@field bbb = lgnd_a : ======== SHIPS =========
@field bbb = lgnd_b : AAAAA = Aircraft Carrier
@field bbb = lgnd_c : BBBB = Battleship
@field bbb = lgnd_d : CCC = Cruiser
@field bbb = lgnd_e : SSS = Submarine
@field bbb = lgnd_f : DD = Destroyer
@field bbb = lgnd_g : ===... ACTIONS===
@field bbb = lgnd_h : rules
@field bbb = lgnd_i : ...
@field bbb = lgnd_j : ...
@field bbb = lgnd_k : ...

// are your ships placed yet?
@field bbb = placed_a : 0
@field bbb = placed_b : 0
@field bbb = placed_c : 0
@field bbb = placed_s : 0
@field bbb = placed_d : 0

// how many hits has each ship taken?
@field bbb = hits_a : 0
@field bbb = hits_b : 0
@field bbb = hits_c : 0
@field bbb = hits_s : 0
@field bbb = hits_d : 0

// setup functions
@field bbb = clear_board :
 @strloop("abcdefghij","x",@s("line_%x","%x . . . . . . . . . .   |"));
 @s("placed_a",0); @s("placed_b",0); @s("placed_c",0);
 @s("placed_s",0); @s("placed_d",0);
 @call(11812,"desc2");
@field bbb = clear_ship :
 @strloop("abcdefghij","x",@print(
  @s("line_tmp",""),
  @strloop(@g("line_%x"),"y",@switch("%y",@g("ship"),
   @s("line_tmp",@print(@g("line_tmp"),".")),
   @s("line_tmp",@print(@g("line_tmp"),"%y"))
  )),
  @s("line_%x",@g("line_tmp"))
 ));
 @s(@print("placed_",@g("ship")),0);
 @call(11812,"desc2");
@field bbb = test_fit_across : @or(
 @and(@eq(@g("ship"),"A"),@lt(@g("col"),7)),
 @and(@eq(@g("ship"),"B"),@lt(@g("col"),8)),
 @and(@eq(@g("ship"),"C"),@lt(@g("col"),9)),
 @and(@eq(@g("ship"),"S"),@lt(@g("col"),9)),
 @and(@eq(@g("ship"),"D"),@lt(@g("col"),10)));
@field bbb = test_free_across :
 @print(
  @s("tmplen",@switch(@g("ship"),"A",9,"B",7,"C",5,"S",5,"D",3)),
  @s("ok",1),
  @strloop(@substr(@g(@print("line_",@g("row"))),
   @mul(2,@g("col")), @g("tmplen")),"x",
   @switch("%x",{"."," "},"",@s("ok",0))),
  @g("ok")
 );
@field bbb = put_ship_across :
 @s("shiplong",@switch(@g("ship"),
  "A","A A A A A","B","B B B B","C","C C C","S","S S S","D","D D"));
 @s(@print("line_",@g("row")),@print(
  @substr(@g(@print("line_",@g("row"))),0, @mul(2,@g("col"))),
  @g("shiplong"),
  @substr(@g(@print("line_",@g("row"))),
   @add(@mul(2,@g("col")),@strlen(@g("shiplong"))))
 ));
 @s(@print("placed_",@g("ship")),1);
 @call(11812,"desc2");
@field bbb = test_fit_down :
 @s("val",@switch(@g("row"),"a",1,"b",2,"c",3,"d",4,"e",5,"f",6,
  "g",7,"h",8,"i",9,"j",10,11));
 @or(
 @and(@eq(@g("ship"),"A"),@lt(@g("val"),7)),
 @and(@eq(@g("ship"),"B"),@lt(@g("val"),8)),
 @and(@eq(@g("ship"),"C"),@lt(@g("val"),9)),
 @and(@eq(@g("ship"),"S"),@lt(@g("val"),9)),
 @and(@eq(@g("ship"),"D"),@lt(@g("val"),10)));
@field bbb = test_free_down :
 @s("tmpoff",@switch(@g("row"),"a",1,"b",2,"c",3,"d",4,"e",5,"f",6,
  "g",7,"h",8,"i",9,"j",10,11));
 @s("tmplen",@switch(@g("ship"),"A",5,"B",4,"C",3,"S",3,"D",2));
 @s("tmpstr","");
 @strloop(@substr("_abcdefghij",@g("tmpoff"),@g("tmplen")),"x",
  @s("tmpstr",@print(
   @g("tmpstr"),
   @substr(@g("line_%x"),@mul(2,@g("col")),1)
  ))
 );
 @s("ok",1);
 @strloop(@g("tmpstr"),"y",@switch("%y",{"."," "},"",@s("ok",0)));
 @g("ok");
@field bbb = put_ship_down :
 @s("tmpoff",@switch(@g("row"),"a",1,"b",2,"c",3,"d",4,"e",5,"f",6,
  "g",7,"h",8,"i",9,"j",10,11));
 @s("tmplen",@switch(@g("ship"),"A",5,"B",4,"C",3,"S",3,"D",2));
 @strloop(@substr("_abcdefghij",@g("tmpoff"),@g("tmplen")),"x",
  @s("line_%x",@print(
   @substr(@g("line_%x"),0,@mul(2,@g("col"))),
   @g("ship"),
   @substr(@g("line_%x"),@add(1,@mul(2,@g("col"))))
  ))
 );
 @s(@print("placed_",@g("ship")),1);
 @call(11812,"desc2");

// mid-game functions
@field #11812 = do_commit :
 @s("committed",1);
 @tell("%#","You commit your setup.");
 @tell(@location(11813),"%n commits %p setup.");
 @fieldloop(11896,"w_",@tell(@substr("%f",2),
  "[shipwatch] %n commits %p setup."));
 @switch(1,@getfield(11813,"committed"),@call(11812,"do_commit2"));
---
@field #11812 = do_commit : @s("committed",1); @tell("%#","You commit your setup."); @tell(@location(11813),"%n commits %p setup."); @fieldloop(11896,"w_",@tell(@substr("%f",2), "[shipwatch] %n commits %p setup.")); @switch(1,@getfield(11813,"committed"),@call(11812,"do_commit2"));
===
@field #11813 = do_commit :
 @s("committed",1);
 @tell("%#","You commit your setup.");
 @tell(@location(11812),"%n commits %p setup.");
 @fieldloop(11896,"w_",@tell(@substr("%f",2),
  "[shipwatch] %n commits %p setup."));
 @switch(1,@getfield(11812,"committed"),@call(11812,"do_commit2"));
---
@field #11813 = do_commit : @s("committed",1); @tell("%#","You commit your setup."); @tell(@location(11812),"%n commits %p setup."); @fieldloop(11896,"w_",@tell(@substr("%f",2), "[shipwatch] %n commits %p setup.")); @switch(1,@getfield(11812,"committed"),@call(11812,"do_commit2"));
===
@field #11812 = do_commit2 :
 @switch(@rand(2),0,@print(
  @setfield(11812,"phase",1), @setfield(11812,"tmp",@shortname(@location(11812)))),
  @print(
  @setfield(11812,"phase",2), @setfield(11812,"tmp",@shortname(@location(11813)))));
 @strloop("abcdefghij","x",@print(
  @setfield(11812,"oppo_%x","%x . . . . . . . . . .   |"),
  @setfield(11813,"oppo_%x","%x . . . . . . . . . .   |")
 ));
 @fieldloop(11812,"hits_",@setfield(11812,"%f",0));
 @fieldloop(11813,"hits_",@setfield(11813,"%f",0));
 @tell(@location(11813),@print("** The Battle begins! ",
  @getfield(11812,"tmp")," goes first **%c",
  @call(11813,"desc2")));
 @tell(@location(11812),@print("** The Battle begins! ",
  @getfield(11812,"tmp")," goes first **%c",
  @call(11812,"desc2")));
 @fieldloop(11896,"w_",@tell(@substr("%f",2),@print("[shipwatch] ** The Battle begins! ",
  @getfield(11812,"tmp")," goes first **")));
----
TEST
@field #11812 = do_commit2 : @switch(@rand(2),0,@print( @setfield(11812,"phase",1), @setfield(11812,"tmp",@shortname(@location(11812)))), @print( @setfield(11812,"phase",2), @setfield(11812,"tmp",@shortname(@location(11813))))); @strloop("abcdefghij","x",@print( @setfield(11812,"oppo_%x","%x . . . . . . . . . .   |"), @setfield(11813,"oppo_%x","%x . . . . . . . . . .   |"))); @fieldloop(11812,"hits_",@setfield(11812,"%f",0)); @fieldloop(11813,"hits_",@setfield(11813,"%f",0)); @tell(@location(11813),@print("** The Battle begins! ", @getfield(11812,"tmp")," goes first **%c", @call(11813,"desc2"))); @tell(@location(11812),@print("** The Battle begins! ", @getfield(11812,"tmp")," goes first **%c", @call(11812,"desc2"))); @fieldloop(11896,"w_",@tell(@substr("%f",2),@print("[shipwatch] ** The Battle begins! ", @getfield(11812,"tmp")," goes first **")));
====
@field #11812 = clear_waves :
 @strloop("abcdefghij","x",@print(
  @s("oppo_tmp",""),
  @strloop(@g("oppo_%x"),"y",@switch("%y",{"(",")"},
   @s("oppo_tmp",@print(@g("oppo_tmp")," ")),
   @s("oppo_tmp",@print(@g("oppo_tmp"),"%y"))
  )),
  @s("oppo_%x",@g("oppo_tmp")),
  @s("line_tmp",""),
  @strloop(@getfield(11813,"line_%x"),"y",@switch("%y",{"(",")"},
   @s("line_tmp",@print(@g("line_tmp")," ")),
   @s("line_tmp",@print(@g("line_tmp"),"%y"))
  )),
  @setfield(11813,"line_%x",@g("line_tmp"))
 ));
@field #11812 = do_shoot :
 @call(11812,"clear_waves");
 @s("ship",@lc(@substr(@getfield(11813,@print("line_",@g("row"))),
  @mul(2,@g("col")),1)));
 @switch(@g("ship"),".",@call(11812,"shot_missed"),
  @call(11812,"shot_hit"));
@field #11812 = shot_missed :
 @s(@print("oppo_",@g("row")),@print(
  @substr(@g(@print("oppo_",@g("row"))),0,@sub(@mul(2,@g("col")),1)),
  "(o)",
  @substr(@g(@print("oppo_",@g("row"))),@add(@mul(2,@g("col")),2))
 ));
 @setfield(11813,@print("line_",@g("row")),@print(
  @substr(@getfield(11813,@print("line_",@g("row"))),0,@sub(@mul(2,@g("col")),1)),
  "(o)",
  @substr(@getfield(11813,@print("line_",@g("row"))),@add(@mul(2,@g("col")),2))
 ));
 @s("phase",2);
 @tell("%#",@print("You shoot ",
  @g("row"),@g("col"),". Miss. ",@shortname(@location(11813)),"'s turn.%c"));
 @tell(@location(11813),@print("%n shoots ",
  @g("row"),@g("col"),". Miss. Your turn.%c",
  @call(11813,"desc2")));
 @fieldloop(11896,"w_",@tell(@substr("%f",2),@print("[shipwatch] %n shoots ",
  @g("row"),@g("col"),". Miss.")));
@field #11812 = shot_hit :
 @s(@print("oppo_",@g("row")),@print(
  @substr(@g(@print("oppo_",@g("row"))),0,@sub(@mul(2,@g("col")),1)),
  "(@)",
  @substr(@g(@print("oppo_",@g("row"))),@add(@mul(2,@g("col")),2))
 ));
 @setfield(11813,@print("line_",@g("row")),@print(
  @substr(@getfield(11813,@print("line_",@g("row"))),0,@sub(@mul(2,@g("col")),1)),
  "(",@lc(@g("ship")),")",
  @substr(@getfield(11813,@print("line_",@g("row"))),@add(@mul(2,@g("col")),2))
 ));
 @setfield(11813,@print("hits_",@g("ship")),
  @add(@getfield(11813,@print("hits_",@g("ship"))),1));
 // test if a ship sank
 @s("shipsank",@eq(
  @getfield(11813,@print("hits_",@g("ship"))),
  @switch(@g("ship"),"a",5,"b",4,"c",3,"s",3,"d",2)
 ));
 // if ship sank, copy over ship letters to oppo_*
 @switch(@g("shipsank"),1,@call(11812,"do_shipsank"));
 // test if won
 @s("youwon",@and(
  @eq(@getfield(11813,"hits_a"),5),@eq(@getfield(11813,"hits_b"),4),
  @eq(@getfield(11813,"hits_c"),3),@eq(@getfield(11813,"hits_s"),3),
  @eq(@getfield(11813,"hits_d"),2)
 ));
 @switch(@g("youwon"),1,@print(@s("phase",3),
  @strloop("abcdefghij","x",@print(
   @s("oppo_%x",@getfield(11813,"line_%x")),
   @setfield(11813,"oppo_%x",@g("line_%x"))
  ))),@s("phase",2));
 @call(11812,"do_hit_results");
@field #11812 = do_hit_results :
 @tell("%#",@print("You shoot ",@g("row"),@g("col"),". Hit!",
  @switch(1,@g("shipsank"),@print(" You sank ",@shortname(@location(11813)),"'s ",
   @switch(@g("ship"),"a","Aircraft Carrier!","b","Battleship!",
   "c","Cruiser!","s","Submarine!","d","Destroyer!"))),
  @switch(1,@g("youwon"),"%c*** You are victorious ***%c"," Red's turn.%c"),
  @switch(1,@g("youwon"),@call(11812,"desc2"))
 ));
 @tell(@location(11813),@print("%n shoots ",@g("row"),@g("col"),". Hit!",
  @switch(1,@g("shipsank"),@print(" %n sank your ",
   @switch(@g("ship"),"a","Aircraft Carrier!","b","Battleship!",
   "c","Cruiser!","s","Submarine!","d","Destroyer!"))),
  @switch(1,@g("youwon"),"%c*** You have lost ***%c"," Your turn.%c"),
  @call(11813,"desc2")
 ));
 @fieldloop(11896,"w_",@tell(@substr("%f",2),@print(
  "[shipwatch] %n shoots ",@g("row"),@g("col"),". Hit!",
  @switch(1,@g("shipsank"),@print(" %n sank ",@shortname(@location(11813)),"'s ",
   @switch(@g("ship"),"a","Aircraft Carrier!","b","Battleship!",
   "c","Cruiser!","s","Submarine!","d","Destroyer!"))),
  @switch(1,@g("youwon"),"%c[shipwatch] *** %n is victorious ***")
 )));
 @switch(1,@g("youwon"),@call(11812,"addtoladder"));
---
TEST
@field #11812 = do_hit_results : @tell("%#",@print("You shoot ",@g("row"),@g("col"),". Hit!", @switch(1,@g("shipsank"),@print(" You sank ",@shortname(@location(11813)),"'s ", @switch(@g("ship"),"a","Aircraft Carrier!","b","Battleship!", "c","Cruiser!","s","Submarine!","d","Destroyer!"))), @switch(1,@g("youwon"),"%c*** You are victorious ***%c"," Red's turn.%c"), @switch(1,@g("youwon"),@call(11812,"desc2")))); @tell(@location(11813),@print("%n shoots ",@g("row"),@g("col"),". Hit!", @switch(1,@g("shipsank"),@print(" %n sank your ", @switch(@g("ship"),"a","Aircraft Carrier!","b","Battleship!", "c","Cruiser!","s","Submarine!","d","Destroyer!"))), @switch(1,@g("youwon"),"%c*** You have lost ***%c"," Your turn.%c"), @call(11813,"desc2"))); @fieldloop(11896,"w_",@tell(@substr("%f",2),@print( "[shipwatch] %n shoots ",@g("row"),@g("col"),". Hit!", @switch(1,@g("shipsank"),@print(" %n sank ",@shortname(@location(11813)),"'s ", @switch(@g("ship"),"a","Aircraft Carrier!","b","Battleship!", "c","Cruiser!","s","Submarine!","d","Destroyer!"))), @switch(1,@g("youwon"),"%c[shipwatch] *** %n is victorious ***")))); @switch(1,@g("youwon"),@call(11812,"addtoladder"));
===
@field #11812 = addtoladder :
 @setfield(1049,"who_%#","%#");
 @setfield(1049,"nwin_%#",@add(1,@getfield(1049,"nwin_%#")));
 @setfield(1049,"nlos_%#",@add(0,@getfield(1049,"nlos_%#")));
 @setfield(1049,"ngam_%#",@add(1,@getfield(1049,"ngam_%#")));
 @setfield(1049,"ratio_%#",
  @idiv(@mul(@getfield(1049,"nwin_%#"),1000),@getfield(1049,"ngam_%#")));
 @setfield(1049,@print("who_",@location(11813)),@location(11813));
 @setfield(1049,@print("nwin_",@location(11813)),
  @add(0,@getfield(1049,@print("nwin_",@location(11813)))));
 @setfield(1049,@print("nlos_",@location(11813)),
  @add(1,@getfield(1049,@print("nlos_",@location(11813)))));
 @setfield(1049,@print("ngam_",@location(11813)),
  @add(1,@getfield(1049,@print("ngam_",@location(11813)))));
 @setfield(1049,@print("ratio_",@location(11813)),
  @idiv(@mul(@getfield(1049,@print("nwin_",@location(11813)))
  ,1000),@getfield(1049,@print("ngam_",@location(11813)))));
---
@field #11812 = addtoladder : @setfield(1049,"who_%#","%#"); @setfield(1049,"nwin_%#",@add(1,@getfield(1049,"nwin_%#"))); @setfield(1049,"nlos_%#",@add(0,@getfield(1049,"nlos_%#"))); @setfield(1049,"ngam_%#",@add(1,@getfield(1049,"ngam_%#"))); @setfield(1049,"ratio_%#", @idiv(@mul(@getfield(1049,"nwin_%#"),1000),@getfield(1049,"ngam_%#"))); @setfield(1049,@print("who_",@location(11813)),@location(11813)); @setfield(1049,@print("nwin_",@location(11813)), @add(0,@getfield(1049,@print("nwin_",@location(11813))))); @setfield(1049,@print("nlos_",@location(11813)), @add(1,@getfield(1049,@print("nlos_",@location(11813))))); @setfield(1049,@print("ngam_",@location(11813)), @add(1,@getfield(1049,@print("ngam_",@location(11813))))); @setfield(1049,@print("ratio_",@location(11813)), @idiv(@mul(@getfield(1049,@print("nwin_",@location(11813))) ,1000),@getfield(1049,@print("ngam_",@location(11813)))));
===
@field #11812 = do_shipsank :
 @strloop("abcdefghij","x",@print(
  @s("tmp",""),@s("i",0),
  @strloop(@getfield(11813,"line_%x"),"y",@print(
   @s("tmp",@print(@g("tmp"),@switch("%y",@g("ship"),
    @g("ship"),
    @substr(@g("oppo_%x"),@g("i"),1)
   ))),
   @s("i",@add(1,@g("i")))
  )),
  @s("oppo_%x",@g("tmp"))
 ));

bbb put * across from * (dbref #11818)

@action put * across from *;put * across at *;put * at * across;
 put * from * across;
 place * across from *;place * across at *;place * at * across;
 place * from * across;
 bbb put * across from *;bbb put * across at *;
 bbb put * at * across;bbb put * from * across = #11812 : nowhere
@set #11818 = puzzle
@set #11818 = dark
@field #11818 = varobj : 11812
@succ #11818 =
 @s("ship",@switch("%0",
  {"aircraft carrier","aircraft","air car","aircar","air","aship","ac","a","aaaaa"},"A",
  {"battleship","battle","bat","bship","b","bbbb"},"B",
  {"cruiser","cru","cship","c","ccc"},"C",
  {"submarine","sub","sship","s","sss"},"S",
  {"destroyer","des","dship","d","dd"},"D",
  0));
 @s("row",@substr("%1",0,1));
 @s("col",@substr("%1",1));
 @switch(0,
  @eq(@location(11812),"%#"),
   "(Sorry, you must be holding the board in order to use it.)",
  @eq(@g("phase"),"0"),
   "(Sorry, but you only place ships during the setup phase.)",
  @g("ship"),
   "(Which ship? Ship abbreviations are A, B, C, S, and D.)",
  @not(@g(@print("placed_",@g("ship")))),
   "(But that ship's already on the board! If you want to move it,
   you must clear it first.)",
  @switch(@g("row"),{"a","b","c","d","e","f","g","h","i","j"},1,0),
   "[Which row? Rows are from a to j.]",
  @and(@lt(0,@g("col")),@lt(@g("col"),11)),
   "(Which column? Columns are from 1 to 10.)",
  @call(11812,"test_fit_across"),
   "(Sorry, I can't. That would put the ship partway off the board.)",
  @call(11812,"test_free_across"),
   "(Sorry, I can't. There's another ship in the way there.)",
  @call(11812,"put_ship_across")
 );
@desc #11818 = During setup, place all five of your ships on your grid,
 either across or down.
 There cannot be any overlap, nor may ships be partway off the grid.
 You have five ships to place, one of each of the five listed types.
 Ship names may be referred to in full, or with abbreviations, or
 just their first letter. Grid locations are from a1 to j10.
 The "put" syntax is slightly flexible.
 For example, these four commands all do the same thing:
 %c   put battleship across from b5
 %c   put bship across at b5
 %c   put bbbb from b5 across
 %c   put b at b5 across

bbb put * down from * (dbref #11819)

@action put * down from *;put * down at *;put * at * down;put * from * down;
 place * down from *;place * down at *;place * at * down;place * from * down;
 bbb put * down from *;bbb * down at *;bbb put * at * down;bbb put * from * down
 = #11812 : nowhere
@set #11819 = puzzle
@set #11819 = dark
@field #11819 = varobj : 11812
@succ #11819 =
 @s("ship",@switch("%0",
  {"aircraft carrier","aircraft","air car","aircar","air","aship","ac","a","aaaaa"},"A",
  {"battleship","battle","bat","bship","b","bbbb"},"B",
  {"cruiser","cru","cship","c","ccc"},"C",
  {"submarine","sub","sship","s","sss"},"S",
  {"destroyer","des","dship","d","dd"},"D",
  0));
 @s("row",@substr("%1",0,1));
 @s("col",@substr("%1",1));
 @switch(0,
  @eq(@location(11812),"%#"),
   "(Sorry, you must be holding the board in order to use it.)",
  @eq(@g("phase"),"0"),
   "(Sorry, but you only place ships during the setup phase.)",
  @g("ship"),
   "(Which ship? Ship abbreviations are A, B, C, S, and D.)",
  @not(@g(@print("placed_",@g("ship")))),
   "(But that ship's already on the board! If you want to move it,
   you must clear it first.)",
  @switch(@g("row"),{"a","b","c","d","e","f","g","h","i","j"},1,0),
   "(Which row? Rows are from a to j.)",
  @and(@lt(0,@g("col")),@lt(@g("col"),11)),
   "(Which column? Columns are from 1 to 10.)",
  @call(11812,"test_fit_down"),
   "(Sorry, I can't. That would put the ship partway off the board.)",
  @call(11812,"test_free_down"),
   "(Sorry, I can't. There's another ship in the way there.)",
  @call(11812,"put_ship_down")
 );
@desc #11819 = During setup, place all five of your ships on your grid,
 either across or down.
 There cannot be any overlap, nor may ships be partway off the grid.
 You have five ships to place, one of each of the five listed types.
 Ship names may be referred to in full, or with abbreviations, or
 just their first letter. Grid locations are from a1 to j10.
 The "put" syntax is slightly flexible.
 For example, these four commands all do the same thing:
 %c   put submarine down from d4
 %c   put sub down at d4
 %c   put sss from d4 down
 %c   put s at d4 down

bbb clear * (dbref #11821)

@action clear *;remove *;bbb clear *;bbb remove * = #11812 : nowhere
@set #11821 = puzzle
@set #11821 = dark
@field #11821 = varobj : 11812
@desc #11821 = During setup, use the CLEAR command to remove one or all
 of your ships from your board. For example:
 %c   clear all       [Clears all ships from your board.]
 %c   clear b         [Clears just your battleship.]
@succ #11821 =
 @switch(0,
  @eq(@location(11812),"%#"),
   "(Sorry, you must be holding the board in order to use it.)",
  @eq(@g("phase"),0),
   "(Sorry, you can only clear ships during setup.)",
  @eq(@g("committed"),0),
   "(Sorry, you cannot clear ships after you've committed your setup.)",
  @print(
 @s("ship",@switch("%0",
  {"aircraft carrier","aircraft","air car","aircar","air","aship","ac","a","aaaaa"},"A",
  {"battleship","battle","bat","bship","b","bbbb"},"B",
  {"cruiser","cru","cship","c","ccc"},"C",
  {"submarine","sub","sship","s","sss"},"S",
  {"destroyer","des","dship","d","dd"},"D",
  {"all","board"},"*",
  0)),
 @switch(@g("ship"),
  0,"(I don't understand. You can clear either a ship, or \"clear all\".)",
  "*",@call(11812,"clear_board"),
  @call(11812,"clear_ship"))
 ));

bbb commit (dbref #11831)

@action commit;start game;bbb commit;bbb start game = #11812 : nowhere
@set #11831 = dark
@desc #11831 = When you have finished placing your ships during the
 set-up phase, type "commit" to lock your game board pattern.
 The game begins when both players have committed their boards.
 A synonym for "commit" is "start game".
@field #11831 = varobj : 11812
@old_succ #11831 =
 @switch(0,
  @eq(@location(11812),"%#"),
   "(Sorry, you must be holding the board in order to use it.)",
  @eq(@g("phase"),0),
   "(Sorry, you can only commit during setup.)",
  @and(@g("placed_a"),@g("placed_b"),@g("placed_c"),@g("placed_s"),
  @g("placed_d")),
   "(You haven't finished placing all of your ships yet.)",
  @and(@getfield(11813,"placed_a"),@getfield(11813,"placed_b"),
  @getfield(11813,"placed_c"),@getfield(11813,"placed_s"),
  @getfield(11813,"placed_d")),
   "(Your opponent hasn't finished placing the red ships yet.)",
  @call(11812,"do_commit")
 );
@succ #11831 =
 @switch(0,
  @eq(@location(11812),"%#"),
   "(Sorry, you must be holding the board in order to use it.)",
  @eq(@g("phase"),0),
   "(Sorry, you can only commit during setup.)",
  @and(@g("placed_a"),@g("placed_b"),@g("placed_c"),@g("placed_s"),
  @g("placed_d")),
   "(You haven't finished placing all of your ships yet.)",
  @call(11812,"do_commit")
 );

bbb shoot * (dbref #11814)

@action shoot *;fire *;hit *;try *;call *;
 bbb shoot *;bbb fire *;bbb hit *;bbb try *;bbb call * = #11812 : nowhere
@set #11814 = puzzle
@set #11814 = dark
@field #11814 = varobj : 11812
@succ #11814 = @s("row",@substr("%0",0,1)); @s("col",@substr("%0",1));
 @switch(0,
  @eq(@location(11812),"%#"),
   "(Sorry, you must be holding the board in order to use it.)",
  @eq(@g("phase"),1),
   "(Sorry, but you can only shoot during your turn.)",
  @switch(@g("row"),{"a","b","c","d","e","f","g","h","i","j"},1,0),
   "(Which row? Rows are from a to j.)",
  @and(@lt(0,@g("col")),@lt(@g("col"),11)),
   "(Which column? Columns are from 1 to 10.)",
  @eq(@substr(@getfield(11812,@print("oppo_",@g("row"))),
    @mul(2,@g("col")),1),"."),
   @print("(You've already shot ",@g("row"),@g("col"),". Try another location.)"),
  @call(11812,"do_shoot")
 );
@desc #11814 = During your turn, use the SHOOT command to fire a shot
 at a location on your opponent's grid, eg: SHOOT B9. Synonyms for "shoot"
 are "fire", "hit", "try" and "call". A miss is marked with "o", and
 a hit is marked with "@". When you hit all parts of a ship, the at-signs
 are replaced with the ship's letter, and that ship is destroyed.
 You win the game if you destroy all of your opponent's ships before
 your opponent destroys all of your ships.

bbb end game (dbref #11820)

@action end game;bbb end game = #11812 : nowhere
@set #11820 = dark
@desc #11820 = When one player has won the game, the boards are put
 into a post-game mode, showing both player's layouts. To end the game
 fully and start a new game, one player must use the END GAME command.
 You can also use this command to end a game early, or
 kill an abandoned game.
@succ #11820 =
 @switch(1,
  @not(@or(@eq(@location(11812),"%#"),@eq(@location(11813),"%#"))),
   "(Sorry, you must be holding the board in order to use it.)",
  @eq(@g("phase"),0),
   "(Sorry. The 'end game' command cannot be used during setup.)",
  @print(
   @setfield(11812,"phase",0),
   @strloop("abcsd","x",@print(
    @setfield(11812,"placed_%x",0),@setfield(11812,"hits_%x",0),
    @setfield(11813,"placed_%x",0),@setfield(11813,"hits_%x",0)
   )),
   @strloop("abcdefghij","x",@print(
    @setfield(11812,"line_%x","%x . . . . . . . . . .   |"),
    @setfield(11812,"oppo_%x","%x . . . . . . . . . .   |"),
    @setfield(11813,"line_%x","%x . . . . . . . . . .   |"),
    @setfield(11813,"oppo_%x","%x . . . . . . . . . .   |")
   )),
   @setfield(11812,"committed",0),
   @setfield(11813,"committed",0),
   @tell(@location(11812),@print("(%n resets the boards...)%c",
    @call(11812,"desc2"))),
   @tell(@location(11813),@print("(%n resets the boards...)%c",
    @call(11813,"desc2"))),
   @fieldloop(11896,"w_",@tell(@substr("%f",2),
    "[shipwatch] %n resets the boards."))
  )
 );

rules (dbref #11686)

@action rules;bbb rules;battleship rules = #11812 : nowhere
@set #11686 = dark
@succ #11686 = @call(11686,"description")
@desc #11686 =
 Battleship is a game for two players; one player holds the blue board,
 the other, the red. During setup, each player secretly puts his
 five ships on a 10 by 10 grid, with commands like: "put battleship
 across from a3" or "put destroyer down from j8". Move a ship off
 the board with the "clear" command. When both players have
 finished their setup, one of them starts the game with the "commit"
 command. One player will be chosen randomly to begin.
 %c   Players then take turns shooting at each other's grid, naming the
 target location, eg: "shoot b5". The first player to destroy all parts
 of all of his opponent's ships wins the game.
 %c   After a game is won or lost, the boards are in a postgame phase
 so the players can see both full grids. Use the "end game" command to
 fully clear and reset the game back to the setup phase.
 %c   Also: Read each command for more information on that command.
 %c   Grid symbols: .=unknown, o=miss, @=hit. Uppercase letters represent
 intact ship parts; lowercase letters represent destroyed ship parts.

red Battleship board (dbref #11813)

@create red Battleship board;red board;Battleship board;board;rbb
@set #11813 = expert
@field #11813 = ohome : goes back home to Starbase Battleship.
@link #11813 = #10321
@succ #11813 =
 @print("You pick up the red Battleship board, and its screen lights up.");
 @switch(@getfield(11896,"w_%#"),1,@print(
  @setfield(11896,"w_%#",""),
  "%cYou are no longer on the shipwatch.",
  @fieldloop(11896,"w_%#",@tell(@substr("%f",2),
   "[shipwatch] %n leaves the shipwatch."))
 ));
 @print("%cREMINDER: @leavec/@mutec #shipwatch if you're on the channel.");
 @s("line__",@print(@substr(@print("RED: ",
  @switch(@type(@location(11813)),2,
  @substr(@shortname(@location(11813)),0,14),"???"),
  "                "),0,24),"|"));
 @setfield(11812,"oppo__",@print(@substr(@print("RED: ",
  @switch(@type(@location(11813)),2,
  @substr(@shortname(@location(11813)),0,14),"???"),
  "                "),0,24),"|"));
---
TEST
@succ #11813 = @print("You pick up the red Battleship board, and its screen lights up."); @switch(@getfield(11896,"w_%#"),1,@print( @setfield(11896,"w_%#",""), "%cYou are no longer on the shipwatch.", @fieldloop(11896,"w_%#",@tell(@substr("%f",2), "[shipwatch] %n leaves the shipwatch.")))); @print("%cREMINDER: @leavec/@mutec #shipwatch if you're on the channel."); @s("line__",@print(@substr(@print("RED: ", @switch(@type(@location(11813)),2, @substr(@shortname(@location(11813)),0,14),"???"), "                "),0,24),"|")); @setfield(11812,"oppo__",@print(@substr(@print("RED: ", @switch(@type(@location(11813)),2, @substr(@shortname(@location(11813)),0,14),"???"), "                "),0,24),"|"));
///@s("oppo__",@print(@substr(@print("BLUE: ", @switch(@type(@location(11812)),2, @substr(@shortname(@location(11812)),0,14),"???"), "                "),0,24),"|"));
===
@drop #11813 = You drop the red Battleship board, and its screen
 fades from view.
@desc #11813 = 
 @switch(1,
  @not(@eq(@location(11813),"%#")),
   "To play a game of Battleship, pick up this board
   and get another player to hold the blue one. Only the
   players holding the boards can use them.
   Players do not have to be in the same room to play.
   Read the actions on the boards for more information.
   %cObvious Actions: rules, put * across from *, put * down from *,
   clear *, commit, shoot *, end game",
  @call(11813,"desc2"));
@field #11813 = desc2 :
 @call(11812,"init_legend");
 @strloop("_abcdefghijk","x",@print(
  @g("oppo_%x"),@g("line_%x"),@getfield(11812,"lgnd_%x"),"%c"
 ));

// your board layout.
@field #11813 = line__ : RED: ???                |
@field #11813 = line_a : a . . . . . . . . . .   |
@field #11813 = line_b : b . . . . . . . . . .   |
@field #11813 = line_c : c . . . . . . . . . .   |
@field #11813 = line_d : d . . . . . . . . . .   |
@field #11813 = line_e : e . . . . . . . . . .   |
@field #11813 = line_f : f . . . . . . . . . .   |
@field #11813 = line_g : g . . . . . . . . . .   |
@field #11813 = line_h : h . . . . . . . . . .   |
@field #11813 = line_i : i . . . . . . . . . .   |
@field #11813 = line_j : j . . . . . . . . . .   |
@field #11813 = line_k : + 1 2 3 4 5 6 7 8 9 10  |
// what you see on your opponent's board.
@field #11813 = oppo__ : BLUE: ???               |
@field #11813 = oppo_a : a . . . . . . . . . .   |
@field #11813 = oppo_b : b . . . . . . . . . .   |
@field #11813 = oppo_c : c . . . . . . . . . .   |
@field #11813 = oppo_d : d . . . . . . . . . .   |
@field #11813 = oppo_e : e . . . . . . . . . .   |
@field #11813 = oppo_f : f . . . . . . . . . .   |
@field #11813 = oppo_g : g . . . . . . . . . .   |
@field #11813 = oppo_h : h . . . . . . . . . .   |
@field #11813 = oppo_i : i . . . . . . . . . .   |
@field #11813 = oppo_j : j . . . . . . . . . .   |
@field #11813 = oppo_k : + 1 2 3 4 5 6 7 8 9 10  |
// are your ships placed yet?
@field #11813 = placed_a : 0
@field #11813 = placed_b : 0
@field #11813 = placed_c : 0
@field #11813 = placed_s : 0
@field #11813 = placed_d : 0
// how many hits has each ship taken?
@field #11813 = hits_a : 0
@field #11813 = hits_b : 0
@field #11813 = hits_c : 0
@field #11813 = hits_s : 0
@field #11813 = hits_d : 0
// setup functions
@field #11813 = clear_board :
 @strloop("abcdefghij","x",@s("line_%x","%x . . . . . . . . . .   |"));
 @s("placed_a",0); @s("placed_b",0); @s("placed_c",0);
 @s("placed_s",0); @s("placed_d",0);
 @call(11813,"desc2");
@field #11813 = clear_ship :
 @strloop("abcdefghij","x",@print(
  @s("line_tmp",""),
  @strloop(@g("line_%x"),"y",@switch("%y",@g("ship"),
   @s("line_tmp",@print(@g("line_tmp"),".")),
   @s("line_tmp",@print(@g("line_tmp"),"%y"))
  )),
  @s("line_%x",@g("line_tmp"))
 ));
 @s(@print("placed_",@g("ship")),0);
 @call(11813,"desc2");
@field #11813 = test_fit_across : @or(
 @and(@eq(@g("ship"),"A"),@lt(@g("col"),7)),
 @and(@eq(@g("ship"),"B"),@lt(@g("col"),8)),
 @and(@eq(@g("ship"),"C"),@lt(@g("col"),9)),
 @and(@eq(@g("ship"),"S"),@lt(@g("col"),9)),
 @and(@eq(@g("ship"),"D"),@lt(@g("col"),10)));
@field #11813 = test_free_across :
 @print(
  @s("tmplen",@switch(@g("ship"),"A",9,"B",7,"C",5,"S",5,"D",3)),
  @s("ok",1),
  @strloop(@substr(@g(@print("line_",@g("row"))),
   @mul(2,@g("col")), @g("tmplen")),"x",
   @switch("%x",{"."," "},"",@s("ok",0))),
  @g("ok")
 );
@field #11813 = put_ship_across :
 @s("shiplong",@switch(@g("ship"),
  "A","A A A A A","B","B B B B","C","C C C","S","S S S","D","D D"));
 @s(@print("line_",@g("row")),@print(
  @substr(@g(@print("line_",@g("row"))),0, @mul(2,@g("col"))),
  @g("shiplong"),
  @substr(@g(@print("line_",@g("row"))),
   @add(@mul(2,@g("col")),@strlen(@g("shiplong"))))
 ));
 @s(@print("placed_",@g("ship")),1);
 @call(11813,"desc2");
@field #11813 = test_fit_down :
 @s("val",@switch(@g("row"),"a",1,"b",2,"c",3,"d",4,"e",5,"f",6,
  "g",7,"h",8,"i",9,"j",10,11));
 @or(
 @and(@eq(@g("ship"),"A"),@lt(@g("val"),7)),
 @and(@eq(@g("ship"),"B"),@lt(@g("val"),8)),
 @and(@eq(@g("ship"),"C"),@lt(@g("val"),9)),
 @and(@eq(@g("ship"),"S"),@lt(@g("val"),9)),
 @and(@eq(@g("ship"),"D"),@lt(@g("val"),10)));
@field #11813 = test_free_down :
 @s("tmpoff",@switch(@g("row"),"a",1,"b",2,"c",3,"d",4,"e",5,"f",6,
  "g",7,"h",8,"i",9,"j",10,11));
 @s("tmplen",@switch(@g("ship"),"A",5,"B",4,"C",3,"S",3,"D",2));
 @s("tmpstr","");
 @strloop(@substr("_abcdefghij",@g("tmpoff"),@g("tmplen")),"x",
  @s("tmpstr",@print(
   @g("tmpstr"),
   @substr(@g("line_%x"),@mul(2,@g("col")),1)
  ))
 );
 @s("ok",1);
 @strloop(@g("tmpstr"),"y",@switch("%y",{"."," "},"",@s("ok",0)));
 @g("ok");
@field #11813 = put_ship_down :
 @s("tmpoff",@switch(@g("row"),"a",1,"b",2,"c",3,"d",4,"e",5,"f",6,
  "g",7,"h",8,"i",9,"j",10,11));
 @s("tmplen",@switch(@g("ship"),"A",5,"B",4,"C",3,"S",3,"D",2));
 @strloop(@substr("_abcdefghij",@g("tmpoff"),@g("tmplen")),"x",
  @s("line_%x",@print(
   @substr(@g("line_%x"),0,@mul(2,@g("col"))),
   @g("ship"),
   @substr(@g("line_%x"),@add(1,@mul(2,@g("col"))))
  ))
 );
 @s(@print("placed_",@g("ship")),1);
 @call(11813,"desc2");
// mid-game functions
@field #11813 = clear_waves :
 @strloop("abcdefghij","x",@print(
  @s("oppo_tmp",""),
  @strloop(@g("oppo_%x"),"y",@switch("%y",{"(",")"},
   @s("oppo_tmp",@print(@g("oppo_tmp")," ")),
   @s("oppo_tmp",@print(@g("oppo_tmp"),"%y"))
  )),
  @s("oppo_%x",@g("oppo_tmp")),
  @s("line_tmp",""),
  @strloop(@getfield(11812,"line_%x"),"y",@switch("%y",{"(",")"},
   @s("line_tmp",@print(@g("line_tmp")," ")),
   @s("line_tmp",@print(@g("line_tmp"),"%y"))
  )),
  @setfield(11812,"line_%x",@g("line_tmp"))
 ));
@field #11813 = do_shoot :
 @call(11813,"clear_waves");
 @s("ship",@lc(@substr(@getfield(11812,@print("line_",@g("row"))),
  @mul(2,@g("col")),1)));
 @switch(@g("ship"),".",@call(11813,"shot_missed"),
  @call(11813,"shot_hit"));
@field #11813 = shot_missed :
 @s(@print("oppo_",@g("row")),@print(
  @substr(@g(@print("oppo_",@g("row"))),0,@sub(@mul(2,@g("col")),1)),
  "(o)",
  @substr(@g(@print("oppo_",@g("row"))),@add(@mul(2,@g("col")),2))
 ));
 @setfield(11812,@print("line_",@g("row")),@print(
  @substr(@getfield(11812,@print("line_",@g("row"))),0,@sub(@mul(2,@g("col")),1)),
  "(o)",
  @substr(@getfield(11812,@print("line_",@g("row"))),@add(@mul(2,@g("col")),2))
 ));
 @setfield(11812,"phase",1);
 @tell("%#",@print("You shoot ",
  @g("row"),@g("col"),". Miss. ",@shortname(@location(11812)),"'s turn.%c"));
 @tell(@location(11812),@print("%n shoots ",
  @g("row"),@g("col"),". Miss. Your turn.%c",
  @call(11812,"desc2")));
 @fieldloop(11896,"w_",@tell(@substr("%f",2),@print("[shipwatch] %n shoots ",
  @g("row"),@g("col"),". Miss.")));
@field #11813 = shot_hit :
 @s(@print("oppo_",@g("row")),@print(
  @substr(@g(@print("oppo_",@g("row"))),0,@sub(@mul(2,@g("col")),1)),
  "(@)",
  @substr(@g(@print("oppo_",@g("row"))),@add(@mul(2,@g("col")),2))
 ));
 @setfield(11812,@print("line_",@g("row")),@print(
  @substr(@getfield(11812,@print("line_",@g("row"))),0,@sub(@mul(2,@g("col")),1)),
  "(",@lc(@g("ship")),")",
  @substr(@getfield(11812,@print("line_",@g("row"))),@add(@mul(2,@g("col")),2))
 ));
 @setfield(11812,@print("hits_",@g("ship")),
  @add(@getfield(11812,@print("hits_",@g("ship"))),1));
 // test if a ship sank
 @s("shipsank",@eq(
  @getfield(11812,@print("hits_",@g("ship"))),
  @switch(@g("ship"),"a",5,"b",4,"c",3,"s",3,"d",2)
 ));
 // if ship sank, copy over ship letters to oppo_*
 @switch(@g("shipsank"),1,@call(11813,"do_shipsank"));
 // test if won
 @s("youwon",@and(
  @eq(@getfield(11812,"hits_a"),5),@eq(@getfield(11812,"hits_b"),4),
  @eq(@getfield(11812,"hits_c"),3),@eq(@getfield(11812,"hits_s"),3),
  @eq(@getfield(11812,"hits_d"),2)
 ));
 @switch(@g("youwon"),1,@print(@setfield(11812,"phase",3),
  @strloop("abcdefghij","x",@print(
   @s("oppo_%x",@getfield(11812,"line_%x")),
   @setfield(11812,"oppo_%x",@g("line_%x"))
  ))),@setfield(11812,"phase",1));
 @call(11813,"do_hit_results");
@field #11813 = do_hit_results :
 @tell("%#",@print("You shoot ",@g("row"),@g("col"),". Hit!",
  @switch(1,@g("shipsank"),@print(" You sank ",@shortname(@location(11812)),"'s ",
   @switch(@g("ship"),"a","Aircraft Carrier!","b","Battleship!",
   "c","Cruiser!","s","Submarine!","d","Destroyer!"))),
  @switch(1,@g("youwon"),"%c*** You are victorious ***%c"," Blue's turn.%c"),
  @switch(1,@g("youwon"),@call(11813,"desc2"))
 ));
 @tell(@location(11812),@print("%n shoots ",@g("row"),@g("col"),". Hit!",
  @switch(1,@g("shipsank"),@print(" %n sank your ",
   @switch(@g("ship"),"a","Aircraft Carrier!","b","Battleship!",
   "c","Cruiser!","s","Submarine!","d","Destroyer!"))),
  @switch(1,@g("youwon"),"%c*** You have lost ***%c"," Your turn.%c"),
  @call(11812,"desc2")
 ));
 @fieldloop(11896,"w_",@tell(@substr("%f",2),@print(
  "[shipwatch] %n shoots ",@g("row"),@g("col"),". Hit!",
  @switch(1,@g("shipsank"),@print(" %n sank ",@shortname(@location(11812)),"'s ",
   @switch(@g("ship"),"a","Aircraft Carrier!","b","Battleship!",
   "c","Cruiser!","s","Submarine!","d","Destroyer!"))),
  @switch(1,@g("youwon"),"%c[shipwatch] *** %n is victorious ***")
 )));
 @switch(1,@g("youwon"),@call(11813,"addtoladder"));
----
@field #11813 = do_hit_results : @tell("%#",@print("You shoot ",@g("row"),@g("col"),". Hit!", @switch(1,@g("shipsank"),@print(" You sank ",@shortname(@location(11812)),"'s ", @switch(@g("ship"),"a","Aircraft Carrier!","b","Battleship!", "c","Cruiser!","s","Submarine!","d","Destroyer!"))), @switch(1,@g("youwon"),"%c*** You are victorious ***%c"," Blue's turn.%c"), @switch(1,@g("youwon"),@call(11813,"desc2")))); @tell(@location(11812),@print("%n shoots ",@g("row"),@g("col"),". Hit!", @switch(1,@g("shipsank"),@print(" %n sank your ", @switch(@g("ship"),"a","Aircraft Carrier!","b","Battleship!", "c","Cruiser!","s","Submarine!","d","Destroyer!"))), @switch(1,@g("youwon"),"%c*** You have lost ***%c"," Your turn.%c"), @call(11812,"desc2"))); @fieldloop(11896,"w_",@tell(@substr("%f",2),@print( "[shipwatch] %n shoots ",@g("row"),@g("col"),". Hit!", @switch(1,@g("shipsank"),@print(" %n sank ",@shortname(@location(11812)),"'s ", @switch(@g("ship"),"a","Aircraft Carrier!","b","Battleship!", "c","Cruiser!","s","Submarine!","d","Destroyer!"))), @switch(1,@g("youwon"),"%c[shipwatch] *** %n is victorious ***")))); @switch(1,@g("youwon"),@call(11813,"addtoladder"));
====
@field #11813 = addtoladder :
 @setfield(1049,"who_%#","%#");
 @setfield(1049,"nwin_%#",@add(1,@getfield(1049,"nwin_%#")));
 @setfield(1049,"nlos_%#",@add(0,@getfield(1049,"nlos_%#")));
 @setfield(1049,"ngam_%#",@add(1,@getfield(1049,"ngam_%#")));
 @setfield(1049,"ratio_%#",
  @idiv(@mul(@getfield(1049,"nwin_%#"),1000),@getfield(1049,"ngam_%#")));
 @setfield(1049,@print("who_",@location(11812)),@location(11812));
 @setfield(1049,@print("nwin_",@location(11812)),
  @add(0,@getfield(1049,@print("nwin_",@location(11812)))));
 @setfield(1049,@print("nlos_",@location(11812)),
  @add(1,@getfield(1049,@print("nlos_",@location(11812)))));
 @setfield(1049,@print("ngam_",@location(11812)),
  @add(1,@getfield(1049,@print("ngam_",@location(11812)))));
 @setfield(1049,@print("ratio_",@location(11812)),
  @idiv(@mul(@getfield(1049,@print("nwin_",@location(11812)))
  ,1000),@getfield(1049,@print("ngam_",@location(11812)))));
---
@field #11813 = addtoladder : @setfield(1049,"who_%#","%#"); @setfield(1049,"nwin_%#",@add(1,@getfield(1049,"nwin_%#"))); @setfield(1049,"nlos_%#",@add(0,@getfield(1049,"nlos_%#"))); @setfield(1049,"ngam_%#",@add(1,@getfield(1049,"ngam_%#"))); @setfield(1049,"ratio_%#", @idiv(@mul(@getfield(1049,"nwin_%#"),1000),@getfield(1049,"ngam_%#"))); @setfield(1049,@print("who_",@location(11812)),@location(11812)); @setfield(1049,@print("nwin_",@location(11812)), @add(0,@getfield(1049,@print("nwin_",@location(11812))))); @setfield(1049,@print("nlos_",@location(11812)), @add(1,@getfield(1049,@print("nlos_",@location(11812))))); @setfield(1049,@print("ngam_",@location(11812)), @add(1,@getfield(1049,@print("ngam_",@location(11812))))); @setfield(1049,@print("ratio_",@location(11812)), @idiv(@mul(@getfield(1049,@print("nwin_",@location(11812))) ,1000),@getfield(1049,@print("ngam_",@location(11812)))));
===
@field #11813 = do_shipsank :
 @strloop("abcdefghij","x",@print(
  @s("tmp",""),@s("i",0),
  @strloop(@getfield(11812,"line_%x"),"y",@print(
   @s("tmp",@print(@g("tmp"),@switch("%y",@g("ship"),
    @g("ship"),
    @substr(@g("oppo_%x"),@g("i"),1)
   ))),
   @s("i",@add(1,@g("i")))
  )),
  @s("oppo_%x",@g("tmp"))
 ));

rbb put * at * across(dbref #11822)

@action put * across from *;put * across at *;put * at * across;put * from * across;
 place * across from *;place * across at *;place * at * across;place * from * across;
 rbb put * across from *;rbb put * across at *;rbb put * at * across;rbb put * from * across
 = #11813 : nowhere
@set #11822 = puzzle
@set #11822 = dark
@field #11822 = varobj : 11813
@desc #11822 = @call(11818,"description");
@succ #11822 =
 @s("ship",@switch("%0",
  {"aircraft carrier","aircraft","air car","aircar","air","aship","ac","a","aaaaa"},"A",
  {"battleship","battle","bat","bship","b","bbbb"},"B",
  {"cruiser","cru","cship","c","ccc"},"C",
  {"submarine","sub","sship","s","sss"},"S",
  {"destroyer","des","dship","d","dd"},"D",
  0));
 @s("row",@substr("%1",0,1));
 @s("col",@substr("%1",1));
 @switch(0,
  @eq(@getfield(11812,"phase"),"0"),
   "(Sorry, but you only place ships during the setup phase.)",
  @g("ship"),
   "(Which ship? Ship abbreviations are A, B, C, S, and D.)",
  @not(@g(@print("placed_",@g("ship")))),
   "(But that ship's already on the board! If you want to move it,
   you must clear it first.)",
  @switch(@g("row"),{"a","b","c","d","e","f","g","h","i","j"},1,0),
   "(Which row? Rows are from a to j.)",
  @and(@lt(0,@g("col")),@lt(@g("col"),11)),
   "(Which column? Columns are from 1 to 10.)",
  @call(11813,"test_fit_across"),
   "(Sorry, I can't. That would put the ship partway off the board.)",
  @call(11813,"test_free_across"),
   "(Sorry, I can't. There's another ship in the way there.)",
  @call(11813,"put_ship_across")
 );

rbb put * down from * (dbref #11823)

@action put * down from *;put * down at *;put * at * down;put * from * down;
 place * down from *;place * down at *;place * at * down;place * from * down;
 rbb put * down from *;rbb put * down at *;rbb put * at * down;rbb put * from * down
 = #11813 : nowhere
@set #11823 = puzzle
@set #11823 = dark
@field #11823 = varobj : 11813
@desc #11823 = @call(11819,"description");
@succ #11823 =
 @s("ship",@switch("%0",
  {"aircraft carrier","aircraft","air car","aircar","air","aship","ac","a","aaaaa"},"A",
  {"battleship","battle","bat","bship","b","bbbb"},"B",
  {"cruiser","cru","cship","c","ccc"},"C",
  {"submarine","sub","sship","s","sss"},"S",
  {"destroyer","des","dship","d","dd"},"D",
  0));
 @s("row",@substr("%1",0,1));
 @s("col",@substr("%1",1));
 @switch(0,
  @eq(@getfield(11812,"phase"),"0"),
   "(Sorry, but you only place ships during the setup phase.)",
  @g("ship"),
   "(Which ship? Ship abbreviations are A, B, C, S, and D.)",
  @not(@g(@print("placed_",@g("ship")))),
   "(But that ship's already on the board! If you want to move it,
   you must clear it first.)",
  @switch(@g("row"),{"a","b","c","d","e","f","g","h","i","j"},1,0),
   "(Which row? Rows are from a to j.)",
  @and(@lt(0,@g("col")),@lt(@g("col"),11)),
   "(Which column? Columns are from 1 to 10.)",
  @call(11813,"test_fit_down"),
   "(Sorry, I can't. That would put the ship partway off the board.)",
  @call(11813,"test_free_down"),
   "(Sorry, I can't. There's another ship in the way there.)",
  @call(11813,"put_ship_down")
 );

rbb clear * (dbref #11824)

@action clear *;remove *;rbb clear *;rbb remove * = #11813 : nowhere
@set #11824 = puzzle
@set #11824 = dark
@field #11824 = varobj : 11813
@desc #11824 = @call(11821,"description");
@succ #11824 =
 @switch(0,
  @eq(@location(11813),"%#"),
   "(Sorry, you must be holding the board in order to use it.)",
  @eq(@getfield(11812,"phase"),0),
   "(Sorry, you can only clear ships during setup.)",
  @eq(@g("committed"),0),
   "(Sorry, you cannot clear ships after you've committed your setup.)",
  @print(
   @s("ship",@switch("%0",
    {"aircraft carrier","aircraft","air car","aircar","air","aship","ac","a","aaaaa"},"A",
    {"battleship","battle","bat","bship","b","bbbb"},"B",
    {"cruiser","cru","cship","c","ccc"},"C",
    {"submarine","sub","sship","s","sss"},"S",
    {"destroyer","des","dship","d","dd"},"D",
    {"all","board"},"*", 0)),
   @switch(@g("ship"),
    0,"(I don't understand. You can clear either a ship, or \"clear all\".)",
    "*",@call(11813,"clear_board"),
    @call(11813,"clear_ship"))
 ));

rbb commit (dbref #11825)

@action commit;start game;rbb commit;rbb start game = red Battleship board : nowhere
@desc #11825 = @getfield(11831,"description");
@field #11825 = varobj : 11813
@set #11825 = dark
@old_succ #11825 =
 @switch(0,
  @eq(@location(11813),"%#"),
   "(Sorry, you must be holding the board in order to use it.)",
  @eq(@getfield(11812,"phase"),0),
   "(Sorry, you can only commit during setup.)",
  @and(@g("placed_a"),@g("placed_b"),@g("placed_c"),@g("placed_s"),
  @g("placed_d")),
   "(You haven't finished placing all of your ships yet.)",
  @and(@getfield(11812,"placed_a"),@getfield(11812,"placed_b"),
  @getfield(11812,"placed_c"),@getfield(11812,"placed_s"),
  @getfield(11812,"placed_d")),
   "(Your opponent hasn't finished placing the blue ships yet.)",
  @call(11812,"do_commit")
 );
@succ #11825 =
 @switch(0,
  @eq(@location(11813),"%#"),
   "(Sorry, you must be holding the board in order to use it.)",
  @eq(@getfield(11812,"phase"),0),
   "(Sorry, you can only commit during setup.)",
  @and(@g("placed_a"),@g("placed_b"),@g("placed_c"),@g("placed_s"),
  @g("placed_d")),
   "(You haven't finished placing all of your ships yet.)",
  @call(11813,"do_commit")
 );

rbb shoot * (dbref #11832)

@action shoot *;fire *;hit *;try *;call *;
 rbb shoot *;rbb fire *;rbb hit *;rbb try *;rbb call * = #11813 : nowhere
@set #11832 = puzzle
@set #11832 = dark
@field #11832 = varobj : 11813
@desc #11832 = @getfield(11814,"description");
@succ #11832 = @s("row",@substr("%0",0,1)); @s("col",@substr("%0",1));
 @switch(0,
  @eq(@location(11813),"%#"),
   "(Sorry, you must be holding the board in order to use it.)",
  @eq(@getfield(11812,"phase"),2),
   "(Sorry, but you can only shoot during your turn.)",
  @switch(@g("row"),{"a","b","c","d","e","f","g","h","i","j"},1,0),
   "(Which row? Rows are from a to j.)",
  @and(@lt(0,@g("col")),@lt(@g("col"),11)),
   "(Which column? Columns are from 1 to 10.)",
  @eq(@substr(@getfield(11813,@print("oppo_",@g("row"))),
    @mul(2,@g("col")),1),"."),
   @print("(You've already shot ",@g("row"),@g("col"),". Try another location.)"),
  @call(11813,"do_shoot")
 );

rbb end game (dbref #11833)

@action end game;rbb end game = #11813 : nowhere
@set #11833 = dark
@desc #11833 = @getfield(11820,"description")
@succ #11833 = @call(11820,"success")

rules (dbref #11870)

@action rules;rbb rules;battleship rules = #11813 : nowhere
@set #11870 = dark
@succ #11870 = @call(11686,"description")
@desc #11870 = @call(11686,"description")

public Battleship viewer (dbref #11896)

@name #11896 = public Battleship viewer;public viewer;Battleship viewer;viewer;pbv
@create public Battleship viewer;public viewer;Battleship viewer;viewer;pbv
@set #11896 = expert
@desc #11896 = 
 @switch("%#",
  @location(11812),"Hey! You're playing blue! You can't look at the viewer!",
  @location(11813),"Hey! You're playing red! You can't look at the viewer!",
 @print(
 @s("lgnd__",@getfield(11812,"lgnd__")),
 @strloop("_abcdefghijk","x",@print(
  @getfield(11812,"line_%x"),@getfield(11813,"line_%x"),@g("lgnd_%x"),"%c"
 ))));
@field #11896 = lgnd__ : Phase: ???
@field #11896 = lgnd_a : ======== SHIPS =========
@field #11896 = lgnd_b : AAAAA = Aircraft Carrier
@field #11896 = lgnd_c : BBBB = Battleship
@field #11896 = lgnd_d : CCC = Cruiser
@field #11896 = lgnd_e : SSS = Submarine
@field #11896 = lgnd_f : DD = Destroyer
@field #11896 = lgnd_g : ==== VIEWER ACTIONS ====
@field #11896 = lgnd_h : rules, shipladder
@field #11896 = lgnd_i : join shipwatch
@field #11896 = lgnd_j : leave shipwatch
@field #11896 = lgnd_k : stat shipwatch

pbv rules (dbref #11897)

@action rules;pbv rules;battleship rules = public Battleship viewer : nowhere
@set #11897 = dark
@succ #11897 = @call(11686,"description")
@desc #11897 = @call(11686,"description")

join shipwatch (dbref #11898)

@action join shipwatch = public Battleship viewer : nowhere
@set #11898 = dark
@field #11898 = varobj : 11896
@desc #11898 = Type "join shipwatch" to receive the hit, miss,
 and win messages from the Battleship boards. These messages will
 be prefixed with [shipwatch], as if they were coming from a channel.
 Use "leave shipwatch" or take a Battleship board to stop these messages.
@succ #11898 = @switch(1,
 @g("w_%#"),
  "You are already on the shipwatch.",
 @or(@eq(@location(11812),"%#"),@eq(@location(11813),"%#")),
  "Sorry. Board holders may not join shipwatch.",
 @print(
  @s("w_%#",1),
  @fieldloop(11896,"w_",@tell(@substr("%f",2),"[shipwatch] %n joins the shipwatch."))
 ));
---
TEST
@succ #11898 = @switch(1, @g("w_%#"), "You are already on the shipwatch.", @or(@eq(@location(11812),"%#"),@eq(@location(11813),"%#")), "Sorry. Board holders may not join shipwatch.", @print( @s("w_%#",1), @fieldloop(11896,"w_",@tell(@substr("%f",2),"[shipwatch] %n joins the shipwatch."))));
===

leave shipwatch (dbref #11899)

@action leave shipwatch;mute shipwatch = public Battleship viewer : nowhere
@set #11899 = dark
@field #11899 = varobj : 11896
@desc #11899 = Type "leave shipwatch" or "mute shipwatch" to stop
 receiving the hit, miss, and win messages from the Battleship boards.
 %cAlso: To remove someone else, eg: Floyd, type "kick Floyd off shipwatch".
@succ #11899 = @switch(@g("w_%#"),
 1,@print(
  @s("w_%#",""),"You are no longer on the shipwatch.",
  @fieldloop(11896,"w_",@tell(@substr("%f",2),"[shipwatch] %n leaves the shipwatch."))
 ),"You are not a member of the shipwatch.");

stat shipwatch (dbref #11900)

@action stat shipwatch = public Battleship viewer : nowhere
@set #11900 = dark
@field #11900 = varobj : 11896
@desc #11900 = Type "stat shipwatch" to see who's on [shipwatch].
@succ #11900 = @print("Shipwatchers:",
 @fieldloop(11896,"w_",@print(" ",@shortname(@substr("%f",2)))));

kick * off shipwatch (dbref #987)

@action kick * off shipwatch = public Battleship viewer : nowhere
@set #987 = dark
@set #987 = puzzle
@field #987 = varobj : 11896
@desc #987 = Eg: "kick guest1 off shipwatch" removes Guest1 from the
 shipwatch. Only players on the shipwatch (or DavidW) may use this command.
@succ #987 = @s("tmp",@player("%0"));
 @switch(0,
  @or(@eq("%#",8796),@eq(@g("w_%#"),1)),
   "Only players on the shipwatch (or DavidW) may use this command.",
  @eq(@type(@g("tmp")),2),
   "But %0 isn't a player.",
  @eq(@g(@print("w_",@g("tmp"))),1),
   @print("But ",@shortname(@g("tmp"))," isn't a member of the shipwatch."),
  @print(
   @s(@print("w_",@g("tmp")),""),
   @tell(@g("tmp"),"%n kicks you off the shipwatch."),
   @fieldloop(11896,"w_",@tell(@substr("%f",2),@print(
    "[shipwatch] %n kicks ",@shortname(@g("tmp"))," off the shipwatch."
   )))
 ));
---
@succ #987 = @s("tmp",@player("%0")); @switch(0, @or(@eq("%#",8796),@eq(@g("w_%#"),1)), "Only players on the shipwatch (or DavidW) may use this command.", @eq(@type(@g("tmp")),2),"But %0 isn't a player.", @eq(@g(@print("w_",@g("tmp"))),1), @print("But ",@shortname(@g("tmp"))," isn't a member of the shipwatch."), @print( @s(@print("w_",@g("tmp")),""), @tell(@g("tmp"),"%n kicks you off the shipwatch."), @fieldloop(11896,"w_",@tell(@substr("%f",2),@print("[shipwatch] %n kicks ",@shortname(@g("tmp"))," off the shipwatch.")))));
===

shipladder (#1049)

@action shipladder = public Battleship viewer : nowhere
@set #1049 = dark
@desc #1049 = Type "shipladder" to list the Battleship ladder board.
@field #1049 = fn_rerank :
 @s("xs","");
 @s("i",1);
 @fieldloop(1049,"who_",@print(
  @s("xs",@print(@g("xs"),"x"))),
  @s("ngam_%v",@add(@g("nwin_%v"),@g("nlos_%v"))),
  @s("ratio_%v",@idiv(@mul(@g("nwin_%#"),1000),@g("ngam_%#"))),
  @s(@print("rank_",@g("i")),"%v"),
  @s("i",@add(@g("i"),1))
 ));
 @s("i",1);
 @strloop(@substr(@g("xs"),0,@sub(@strlen(@g("xs"),1)),@print(
  @s("j",@add(1,@g("i"))),
  @strloop(@substr(@g("xs"),?,?),@print(
   @switch(1,@or(
     @lt(@g(@print("ratio_",@g(@print("rank_",@g("i"))))), @g(@print("ratio_",@g(@print("rank_",@g("j")))))),
     @and(@eq(@g(@print("ratio_",@g(@print("rank_",@g("i"))))), @g(@print("ratio_",@g(@print("rank_",@g("j")))))),
     @lt(@g(@print("ngam_",@g(@print("rank_",@g("i"))))), @g(@print("ngam_",@g(@print("rank_",@g("j")))))))
    ),@print(
     @s("tmp",@g(@print("rank_",@g("i")))),
     @s(@print("rank_",@g("i")),@g(@print("rank_",@g("j")))),
     @s(@print("rank_",@g("j")),@g("tmp"))
   )),
   @s("j",@add(1,@g("j")))
  )),
  @s("i",@add(1,@g("i")))
 ));
@succ #1049 =
 @print(
  "Rank Player       #Wins #Lost #Game  %Won  Score",
  @fieldloop(1049,"who_",@print("%c",
   @substr(@print("    ",@g("rank_%v")),"-4")," ",
   @substr(@print(@shortname("%v"),"            "),0,12)," ",
   @substr(@print("     ",@g("nwin_%v")),"-5")," ",
   @substr(@print("     ",@g("nlos_%v")),"-5")," ",
   @substr(@print("     ",@g("ngam_%v")),"-5"),"  ",
   @substr(@print("   ",@idiv(@g("ratio_%v"),10)),-3),".",
   @substr(@print("0",@mod(@g("ratio_%v"),10)),"-1"),"  ",
   @s("score_%v",@div(@mul(@g("ratio_%v"), @switch(@g("ngam_%v"),
    1,25,2,50,3,75,100) ),100)),
   @substr(@print("   ",@idiv(@g("score_%v"),10)),-3),".",
   @substr(@print("0",@mod(@g("score_%v"),10)),"-1")
  ))
 );
----
ADD
@succ #1049 = @print("Rank Player       #Wins #Lost #Game  %Won   Score", @fieldloop(1049,"who_",@print("%c", @substr(@print("    ",@g("rank_%v")),"-4")," ", @substr(@print(@shortname("%v"),"            "),0,12)," ", @substr(@print("     ",@g("nwin_%v")),"-5")," ", @substr(@print("     ",@g("nlos_%v")),"-5")," ", @substr(@print("     ",@g("ngam_%v")),"-5"),"  ", @substr(@print("   ",@idiv(@g("ratio_%v"),10)),-3),".", @substr(@print("0",@mod(@g("ratio_%v"),10)),"-1"),"  ", @s("score_%v",@div(@mul(@g("ratio_%v"), @switch(@g("ngam_%v"), 1,25,2,50,3,75,100) ),100)), @substr(@print("   ",@idiv(@g("score_%v"),10)),-3),".", @substr(@print("0",@mod(@g("score_%v"),10)),"-1"))));
====