;var p, new; if(!(| valid($thing_153) |)) { new = $thing.spawn(); new.set_objname('thing_153);} ;as $thing_153<$root>;manager = $user_andrew; ;as $thing_153<$root>;flags = ['variables, 'methods, 'code]; ;as $thing_153<$root>;created_on = 849140174; ;as $thing_153<$root>;owners = [$user_andrew]; ;as $thing_153<$root>;inited = 1; @av $thing_153,board = [["R", "P", ".", ".", ".", ".", "p", "r"], ["N", "P", ".", ".", ".", ".", "p", "n"], ["B", "P", ".", ".", ".", ".", "p", "b"], ["K", "P", ".", ".", ".", ".", "p", "k"], ["Q", "P", ".", ".", ".", ".", "p", "q"], ["B", "P", ".", ".", ".", ".", "p", "b"], ["N", "P", ".", ".", ".", ".", "p", "n"], ["R", "P", ".", ".", ".", ".", "p", "r"]] ;as $thing_153<$thing_153>;board = [["R", "P", ".", ".", ".", ".", "p", "r"], ["N", "P", ".", ".", ".", ".", "p", "n"], ["B", "P", ".", ".", ".", ".", "p", "b"], ["K", "P", ".", ".", ".", ".", "p", "k"], ["Q", "P", ".", ".", ".", ".", "p", "q"], ["B", "P", ".", ".", ".", ".", "p", "b"], ["N", "P", ".", ".", ".", ".", "p", "n"], ["R", "P", ".", ".", ".", ".", "p", "r"]]; @av $thing_153,players = [$user_andrew, $user_andy] ;as $thing_153<$thing_153>;players = [$user_andrew, $user_andy]; @av $thing_153,turn = 1 ;as $thing_153<$thing_153>;turn = 1; @av $thing_153,driver = $thing_152 ;as $thing_153<$thing_153>;driver = $thing_152; @av $thing_153,sequence = 0 ;as $thing_153<$thing_153>;sequence = 0; @av $thing_153,old_board = [] ;as $thing_153<$thing_153>;old_board = []; ;as $thing_153<$has_settings>;defined_settings = #[]; ;as $thing_153<$has_settings>;local_settings = #[]; ;as $thing_153<$has_settings>;settings = #[]; ;as $thing_153<$has_name>;name = ['prop, "Chess Board", "Chess Board"]; ;as $thing_153<$has_name>;name_aliases = []; ;as $thing_153<$has_gender>;gender = $gender_neuter; ;as $thing_153<$has_commands>;shortcuts = #[]; ;as $thing_153<$has_commands>;remote = #[["init", [["init", "*", "init ", 'init, #[[1, ['this, []]]]]]], ["play", [["play", "*", "play ", 'play, #[[1, ['this, []]]]]]], ["leave", [["leave", "*", "leave ", 'leave, #[[1, ['this, []]]]]]], ["move", [["move", "* on *", "move on ", 'move, #[[1, ['any, []]], [3, ['this, []]]]]]]]; ;as $thing_153<$has_commands>;local = #[]; ;as $thing_153<$described>;prose = []; ;as $thing_153<$located>;location = $the_pit; ;as $thing_153<$located>;obvious = 1; @program $thing_153.play() +access=public arg foo, bar, baz; var people; // first person to join plays as white... if (sender() in players) { sender().tell("You're already playing chess."); .show_board(sender()); return; } if (players.length() > 1) { people = $list.to_english(players.mmap('name)); sender().tell("Sorry, " + people + " are already playing chess."); return; } players = [@players, sender()]; sender().tell("You're now playing chess."); .show_board(sender()); // $#Edited: 28 Nov 96 00:18 $user_andrew // $#Edited: 28 Nov 96 01:35 $user_andrew . @program $thing_153.leave() +access=public arg foo, bar, baz; var psn; psn = sender() in players; if (!psn) { sender().tell("You weren't playing chess anyway."); return; } // if one player leaves then both do players = []; sender().tell("You're no longer playing chess."); // $#Edited: 28 Nov 96 00:18 $user_andrew // $#Edited: 28 Nov 96 01:44 $user_andrew . @program $thing_153.show_board() +access=public arg who; var b, c, r, kv, your_turn, colour; b = ""; for c in [1 .. 8] { for r in [1 .. 8] b = b + board[c][r]; } kv = []; kv = [@kv, ["object", tostr(this())]]; kv = [@kv, ["board", b]]; // is it your turn, whoever you are? colour = ["white", "black"][who in players]; if (colour == "white" && turn || colour == "black" && !turn) your_turn = 1; else your_turn = 0; kv = [@kv, ["turn", tostr(your_turn)]]; kv = [@kv, ["colour", colour]]; kv = [@kv, ["sequence", tostr(sequence)]]; driver.client_notify(who, "chess-board", kv); // $#Edited: 28 Nov 96 00:18 $user_andrew // $#Edited: 28 Nov 96 01:34 $user_andrew . @program $thing_153.init() +access=public arg cmdstr, foo, bar; var player; sequence = 0; // white moves first... turn = 1; // board... .make might not be in databases older than ColdCore3a5 board = $list.make(8, $list.make(8, ".")); // set out the pieces, sub optimal board = board.replace(1, board[1].replace(1, "R")); board = board.replace(2, board[2].replace(1, "N")); board = board.replace(3, board[3].replace(1, "B")); board = board.replace(4, board[4].replace(1, "K")); board = board.replace(5, board[5].replace(1, "Q")); board = board.replace(6, board[6].replace(1, "B")); board = board.replace(7, board[7].replace(1, "N")); board = board.replace(8, board[8].replace(1, "R")); board = board.replace(1, board[1].replace(2, "P")); board = board.replace(2, board[2].replace(2, "P")); board = board.replace(3, board[3].replace(2, "P")); board = board.replace(4, board[4].replace(2, "P")); board = board.replace(5, board[5].replace(2, "P")); board = board.replace(6, board[6].replace(2, "P")); board = board.replace(7, board[7].replace(2, "P")); board = board.replace(8, board[8].replace(2, "P")); board = board.replace(1, board[1].replace(8, "r")); board = board.replace(2, board[2].replace(8, "n")); board = board.replace(3, board[3].replace(8, "b")); board = board.replace(4, board[4].replace(8, "k")); board = board.replace(5, board[5].replace(8, "q")); board = board.replace(6, board[6].replace(8, "b")); board = board.replace(7, board[7].replace(8, "n")); board = board.replace(8, board[8].replace(8, "r")); board = board.replace(1, board[1].replace(7, "p")); board = board.replace(2, board[2].replace(7, "p")); board = board.replace(3, board[3].replace(7, "p")); board = board.replace(4, board[4].replace(7, "p")); board = board.replace(5, board[5].replace(7, "p")); board = board.replace(6, board[6].replace(7, "p")); board = board.replace(7, board[7].replace(7, "p")); board = board.replace(8, board[8].replace(7, "p")); old_board = []; // **** // **** // **** hack, remember to remove this... // **** // **** // players = [$user_andrew, $user_andrew]; // players = []; // **** for player in (players) .show_board(player); // $#Edited: 28 Nov 96 00:19 $user_andrew // $#Edited: 28 Nov 96 01:02 $user_andrew // $#Edited: 28 Nov 96 01:14 $user_andrew // $#Edited: 28 Nov 96 02:46 $user_andrew . @program $thing_153.move() +access=public arg cmdstr, move, coords_seq, on, this; var person, lcoords, x1, x2, y1, y2, seq; // some perms checks needed naturally... // move 1 2 3 4 5 on chess lcoords = $string.explode(coords_seq); x1 = toint(lcoords[1]); y1 = toint(lcoords[2]); x2 = toint(lcoords[3]); y2 = toint(lcoords[4]); seq = toint(lcoords[5]); if (seq != sequence) { sender().tell("our client is out of sync with the game, updating..."); .show_board(sender()); return; } if (((((((x1 < 1 || x1 > 8) || y1 < 1) || y1 > 8) || x2 < 1) || x2 > 8) || y2 < 1) || y2 > 8) { sender().tell("Can't move off the board..."); return; } // keep one level of undo, not actually used by the game yet... old_board = board; board = board.replace(x2, board[x2].replace(y2, board[x1][y1])); board = board.replace(x1, board[x1].replace(y1, ".")); sequence++; if (turn) turn = 0; else turn = 1; for person in (players) .show_board(person); // $#Edited: 28 Nov 96 00:19 $user_andrew // $#Edited: 28 Nov 96 02:43 $user_andrew // $#Edited: 28 Nov 96 02:46 $user_andrew .