siegel@booga.Eng.Sun.COM (Josh Siegel) (04/18/91)
[I logged in and didn't see any TNT code!]
Here is a game I whipped together a while back after visiting grasshopper.
--josh
P.S. Needs a option where you can hit a key and a spread sheet pops up... :-)
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 1 (of 1)."
# Contents: MANIFEST TODO mahjongg
# Wrapped by siegel@booga on Wed Apr 17 14:30:48 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'MANIFEST' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(207 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X File Name Archive # Description
X-----------------------------------------------------------
X MANIFEST 1 This shipping list
X TODO 1
X mahjongg 1
END_OF_FILE
if test 207 -ne `wc -c <'MANIFEST'`; then
echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'TODO' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'TODO'\"
else
echo shar: Extracting \"'TODO'\" \(1835 characters\)
sed "s/^X//" >'TODO' <<'END_OF_FILE'
XThanks to Hugh Daniels for whining alot...
X
X%
X% TODO list...
X%
X% Bugs & Todo list
X% why do the tiles try to display themselvs where they were first
X% created? (you see them flicker away when you quit or newgame)
X% About box needs to be better, Make the box scale fulley!
X% Everything needs to scale... (So I can do the whole screen when I am
X% very tired!)
X% Visual balance of tiles needs work:
X%* Tiles ought to be on off white background
X% Dots have to be de-empthasized so the dont swamp the others
X% The corners and intersetions are black, somehow not right...
X% Maybe rounded corners would fix edges problem (what unfun!)
X% The horizontal lines of the 1,2, & 3 craks are too week
X% Color background ought to be a picture or a mahongy pattern
X% or maroon color
X% Many of the single character kanji tiles need to be bigger
X% Soffen cracks to yellow or outline them in black like dots
X% Tile chooser (Just Kanji, english also, etc.)
X% ?Save/Load a game (what fun, it gets a droped file from file-munger...)
X% Tiles need to go away quicker after they have been clicked
X% Tiles map window, a window where we are intoduced to the different
X% tiles, also part of the help system. Lets us see the tiles!
X% ?Middle button lights up all of this tile that are visable
X% Play this game again option
X% When tiles are going away moses gets locked,
X% could we fix this with pauses in our code?
X% When window size changes tiles stay in the middle
X% (This all changes with scroll bars I know)
X% When game over or whatever shift select to remove any tile
X% Icont ought to look like a tile (maybe a random one!)
Xd Is there reson to keep sending /Color messages insted of defining
X% /isColor? in our localdict?
X% Set up a dict with all the different colors in it, so that we can
X% tell different games apart, different users etc.
X
END_OF_FILE
if test 1835 -ne `wc -c <'TODO'`; then
echo shar: \"'TODO'\" unpacked with wrong size!
fi
# end of 'TODO'
fi
if test -f 'mahjongg' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'mahjongg'\"
else
echo shar: Extracting \"'mahjongg'\" \(24253 characters\)
sed "s/^X//" >'mahjongg' <<'END_OF_FILE'
X#!/usr/local/openwin/bin/psh
X
X%
X% By Josh Siegel
X%
X% It isn't pretty but it gets the job done... :-)
X%
X
Xtrue setpacking
X
X/drag_and_drop true def % Accept dragged canvases
X
X/forfit false def
X
X/AboutPanel ClassPanel []
Xclassbegin
X /minsize {356 256} def
X /Paint {
X /Paint super send
X
X /ZapfChancery-MediumItalic findfont 20 scalefont setfont
X
X 0 0 0 rgbcolor setcolor
X 50 230 moveto (Mahjongg version 1.0) show
X 10 200 moveto (Written by Josh Siegel) show
X 50 170 moveto (with help from:) show
X 10 140 moveto (Keiko Ohkawa (She knew japanese!)) show
X 10 110 moveto (Kira Siegel (UI design and documentation)) show
X 10 20 moveto (Copyright (c) 1991, Sun Microsystems, Inc) show
X } def
Xclassend def
X
X/about_panel /Calculated framebuffer /new AboutPanel send def
X
X/buttons /Spaced about_panel /new ClassButtons send def
X[(How to play Mahjongg)] /setitemlist buttons send
X/buttons buttons [ /Center { /South PARENT POSITION 60 add} ]
X /addclient about_panel send
X{
X pop pop
X /pin help_win send
X /map help_win send
X /totop help_win send
X} /setnotifier buttons send
X
X/about_popup about_panel framebuffer /new ClassPopupWindow send def
X(About mahjongg...) /setlabel about_popup send
X/place about_popup send
X
X
X/about_list framebuffer /new ClassScrollList send def
X[
X (The goal of the game is to clear the entire table of)
X (mahjongg pieces. This is accomplished by removing )
X (pairs of matching pieces from the game board. Each)
X (piece has 3 other tiles it can be paired with.)
X ()
X (Flowers and Seasons are the exception to the rule in )
X (that there are only 4 pieces total of each type and)
X (they are matched against each other. For example,)
X (a bamboo can be matched against orchid or a mum.)
X ()
X (Mahjongg pieces can only be removed if they are)
X (currently not blocked on the top or on the left or the)
X (right. Clicking on a blocked piece will generate)
X (a beep as a warning message.)
X ()
X (Please note, not all boards are winable.)
X] /setitemlist about_list send
X
X/minsize about_list send pop
X5 /heightfromrows about_list send 2 array astore cvx
X/preferredsize exch /promote about_list send
X
X% instantiate a vertical scrollbar
X/scrollbar framebuffer /new ClassVScrollbar send def
X
X% ensure that the scrollbar notifies the scrolling list
Xabout_list /settarget scrollbar send
X/scroll /setnotifier scrollbar send
X/scroll /setpreviewer scrollbar send
X
X% ensure that the scrolling list can move the scrollbar
Xscrollbar /setscrollbar about_list send
X
X% instantiate a window and insert the list
X/help_win about_list framebuffer /new ClassPopupWindow send def
X(How to play) /setlabel help_win send
X/West scrollbar /addclient help_win send
X0 0 0 5 /setgaps help_win send
X
X/place help_win send
X
X/main_menu /Grid framebuffer /new ClassMenu send def
X
X[
X [ (New Game)
X { finish_old_game new_game }
X ]
X [(About Mahjongg...)
X {
X /reshaped? about_popup send not {
X /place about_popup send
X } if
X /pin about_popup send
X /totop about_popup send
X /map about_popup send
X }
X ]
X [ (Find Matches) {
X pop pop
X forfit false eq {
X [currentcursorlocation] /open notice send
X } {
X locate_match
X } ifelse
X }
X ]
X] /setitemlist main_menu send
X
X(Mahjongg) /setlabel main_menu send
X
Xtrue /setpinnable main_menu send
X
X% Create a window and the notice
X/notice null framebuffer /new ClassNotice send def
X
X(When scoring is implemented, selecting this\
X will invalidate your score. You sure?)
X /settext notice send
X
X% Create the buttongroup that will appear in the notice
X/noticebuttons /Spaced framebuffer /new ClassButtons send def
X[(Yes) (No)] /setitemlist noticebuttons send
X1 /setdefault noticebuttons send
X{
X /close notice send
X pause % to let the savebehind repair
X pop 0 eq {
X /forfit true store
X locate_match
X } if
X} /setnotifier noticebuttons send
X10 0 /setgaps noticebuttons send
X
Xnoticebuttons /setbuttons notice send
X
X/locate_match {
X 144 dict begin
X tiles {
X dup /Mapped exch send {
X dup /Blocked? exch send {
X pop
X } {
X dup /whoami exch send currentdict 1 index known {
X currentdict exch get
X {
X 2 copy /invert exch send /invert exch send
X 1 60 div
X sleep /invert exch send /invert exch send
X } fork pop pop pop
X 20
X exit
X } {
X special_matches 1 index known {
X special_matches exch get
X {
X pop 1 index def
X } forall
X pop
X } {
X exch def
X } ifelse
X } ifelse
X } ifelse
X } {
X pop
X } ifelse
X } forall
X dup 20 ne {
X pop
X (Sorry, no matches left) (Game over.) /setfooter win send pause
X } if
X end
X} def
X
X/ClassTile ClassCanvas [/whoami /whereami]
Xclassbegin
X /x_size 54 def
X /y_size 64 def
X /ts 15 def
X
X /Transparent false def
X /Trackable? true def
X
X /setwhereiam {
X /whereami exch def
X } def
X
X /special_cases 50 dict dup begin
X /1-3-0 {
X /Mapped /ClientDict panel send /0-3.5-0 get send
X } def
X /1-4-0 {
X /Mapped /ClientDict panel send /0-3.5-0 get send
X } def
X /12-3-0 {
X /Mapped /ClientDict panel send /13-3.5-0 get send
X } def
X /12-4-0 {
X /Mapped /ClientDict panel send /13-3.5-0 get send
X } def
X /13-3.5-0 {
X /Mapped /ClientDict panel send /14-3.5-0 get send
X } def
X end def
X
X /Blocked? {
X whereami 2 get 4 eq { % the top piece is simple
X false
X } {
X whereami 2 get 3 eq { % similerly the second from top pieces
X /Mapped /ClientDict panel send /6.5-3.5-4 get send
X } {
X /Mapped /ClientDict panel send
X whereami aload pop 1 add exch 3 -1 roll (%-%-%) sprintf cvn
X 2 copy known {
X get send
X } {
X pop pop pop false
X } ifelse
X dup false eq {
X pop
X /special_cases self send (%-%-%) whereami sprintf cvn 2 copy known {
X get exec
X } {
X pop pop
X /Mapped /ClientDict panel send
X (%-%-%) [ whereami aload pop 3 -1 roll 1 add 3 1 roll ] sprintf cvn
X 2 copy known {
X get send
X dup true eq {
X pop
X /Mapped /ClientDict panel send
X (%-%-%) [ whereami aload pop 3 -1 roll 1 sub 3 1 roll ]
X sprintf cvn
X 2 copy known {
X get send
X } {
X pop pop pop false
X } ifelse
X } if
X } {
X pop pop pop false
X } ifelse
X } ifelse
X } if
X } ifelse
X } ifelse
X } def
X
X /invert {
X self setcanvas
X currentrasteropcode
X 5 setrasteropcode
X clippath fill
X setrasteropcode
X } def
X
X /TrackStart {
X pop /Default true
X /Blocked? self send {
X beep
X } {
X piece1 null eq {
X /piece1 self store
X /invert piece1 send
X } {
X piece1 self eq {
X /invert piece1 send
X /piece1 null store
X } {
X /piece2 self store
X pieces_match? {
X /unmap piece1 send
X /unmap piece2 send
X /tile_count tile_count 2 sub store
X tile_count 0 ne {
X (Tiles left: %) [tile_count] sprintf ()
X /setfooter win send
X } {
X % Note, the game has been won!
X (Have a Cow Man! You WON!)(Next time though...)
X /setfooter win send
X % Do neet things here ,sevral sets thereof!
X } ifelse
X /piece1 null store
X /piece2 null store
X } {
X beep
X } ifelse
X } ifelse
X } ifelse
X } ifelse
X } def
X
X /new {
X /new super send
X dup /whoami 4 -1 roll put
X } def
X
X /minsize { 65 75 } def
X
X /path { % x y w h
X pop pop moveto
X x_size 1 add 0 rlineto
X 10 10 rlineto
X 0 y_size rlineto
X x_size neg 1 sub 0 rlineto
X -10 -10 rlineto
X closepath
X } def
X
X /Paint {
X whoami draw_piece pause
X } def
X
X /draw_dot { % r
X /Color self send {
X 0 .5 .7 rgbcolor setcolor
X } {
X .8 setgray
X } ifelse
X
X currentpoint newpath 3 -1 roll 0 360 5 copy arc fill
X 0 setgray arc stroke
X } def
X
X /draw_bam { %
X 2 0 rlineto
X 2 2 rlineto
X 0 2 rlineto
X -2 2 rlineto
X
X 0 2 rlineto
X 2 2 rlineto
X 0 2 rlineto
X -2 2 rlineto
X
X 0 2 rlineto
X 2 2 rlineto
X 0 2 rlineto
X -2 2 rlineto
X
X -4 0 rlineto
X
X -2 -2 rlineto
X 0 -2 rlineto
X
X 2 -2 rlineto
X 0 -2 rlineto
X -2 -2 rlineto
X 0 -2 rlineto
X
X 2 -2 rlineto
X 0 -2 rlineto
X -2 -2 rlineto
X 0 -2 rlineto
X
X closepath
X
X /Color self send {
X .7 .35 0 rgbcolor setcolor
X } if
X fill
X } def
X
X
X /upper_right { % c
X /Courier findfont ts scalefont setfont
X x_size 1 index stringwidth pop sub y_size currentfont fontascent sub moveto
X show
X } def
X
X /special_images
X dictbegin
X dictend def
X
X /pieces dictbegin
X /red_dragon {
X (C) upper_right
X /Kanji findfont 24 scalefont setfont
X 17 20 moveto (\303\346) show
X } def
X /white_dragon {
X /Courier findfont ts scalefont setfont
X x_size (P) stringwidth pop sub 2 div y_size currentfont fontascent sub 2 div moveto
X (P) show
X } def
X /green_dragon {
X (F) upper_right
X /Kanji findfont 24 scalefont setfont
X 17 20 moveto (\342\244) show
X } def
X /north_wind {
X (N) upper_right
X /Kanji findfont 24 scalefont setfont
X 17 20 moveto (\313\314) show
X } def
X /east_wind {
X (E) upper_right
X /Kanji findfont 24 scalefont setfont
X 17 20 moveto (\305\354) show
X } def
X /south_wind {
X (S) upper_right
X /Kanji findfont 24 scalefont setfont
X 17 20 moveto (\306\356) show
X } def
X /west_wind {
X (W) upper_right
X /Kanji findfont 24 scalefont setfont
X 17 20 moveto (\300\276) show
X } def
X /1st_dot {
X (1) upper_right
X x_size 2 div y_size 2 div moveto 20 draw_dot
X } def
X /2nd_dot {
X (2) upper_right
X x_size 2 div dup
X 19 moveto 13 draw_dot
X 47 moveto 13 draw_dot
X } def
X /3rd_dot {
X (3) upper_right
X x_size 2 div y_size 2 div moveto 10 draw_dot
X 12 y_size 12 sub moveto 10 draw_dot
X x_size 12 sub 12 moveto 10 draw_dot
X } def
X /4th_dot {
X x_size (4) stringwidth pop sub 2 div y_size currentfont fontascent sub
X moveto (4) show
X 12 y_size 18 sub moveto 10 draw_dot
X 12 12 moveto 10 draw_dot
X x_size 12 sub y_size 18 sub moveto 10 draw_dot
X x_size 12 sub 12 moveto 10 draw_dot
X } def
X
X /5th_dot {
X x_size (5) stringwidth pop sub 2 div y_size currentfont fontascent sub
X moveto (5) show
X 12 y_size 18 sub moveto 10 draw_dot
X 12 12 moveto 10 draw_dot
X x_size 12 sub y_size 18 sub moveto 10 draw_dot
X x_size 12 sub 12 moveto 10 draw_dot
X x_size 2 div y_size 2 div 3 sub moveto 10 draw_dot
X } def
X /6th_dot {
X (6) upper_right
X 15 10 moveto 8 draw_dot
X 15 30 moveto 8 draw_dot
X 15 50 moveto 8 draw_dot
X 35 10 moveto 8 draw_dot
X 35 30 moveto 8 draw_dot
X 35 50 moveto 8 draw_dot
X } def
X
X /7th_dot {
X (7) upper_right
X 15 10 moveto 7 draw_dot
X 15 27 moveto 7 draw_dot
X 35 10 moveto 7 draw_dot
X 35 27 moveto 7 draw_dot
X 38 44 moveto 7 draw_dot
X 24 49 moveto 7 draw_dot
X 10 54 moveto 7 draw_dot
X } def
X
X /8th_dot {
X (8) upper_right
X 15 10 moveto 7 draw_dot
X 15 25 moveto 7 draw_dot
X 15 40 moveto 7 draw_dot
X 15 55 moveto 7 draw_dot
X 35 10 moveto 7 draw_dot
X 35 25 moveto 7 draw_dot
X 35 40 moveto 7 draw_dot
X 35 55 moveto 7 draw_dot
X } def
X
X /9th_dot {
X x_size (9) stringwidth pop sub 14 add 2 div y_size 31 sub moveto (9) show
X 10 10 moveto 7 draw_dot
X 27 10 moveto 7 draw_dot
X 44 10 moveto 7 draw_dot
X
X 10 26 moveto 7 draw_dot
X 27 26 moveto 7 draw_dot
X 44 26 moveto 7 draw_dot
X
X 10 52 moveto 7 draw_dot
X 27 52 moveto 7 draw_dot
X 44 52 moveto 7 draw_dot
X } def
X /1st_bam {
X (1) upper_right
X 28 20 moveto draw_bam
X } def
X
X /2nd_bam {
X (2) upper_right
X 0 setgray
X 28 6 moveto draw_bam
X 28 36 moveto draw_bam
X } def
X
X /3rd_bam {
X (3) upper_right
X 0 setgray
X 28 6 moveto draw_bam
X 18 36 moveto draw_bam
X 38 36 moveto draw_bam
X } def
X
X /4th_bam {
X (4) upper_right
X 0 setgray
X 18 36 moveto draw_bam
X 38 36 moveto draw_bam
X 18 6 moveto draw_bam
X 38 6 moveto draw_bam
X } def
X /5th_bam {
X (5) upper_right
X 0 setgray
X 18 36 moveto draw_bam
X 38 36 moveto draw_bam
X 18 6 moveto draw_bam
X 38 6 moveto draw_bam
X 28 22 moveto draw_bam
X } def
X
X /6th_bam {
X (6) upper_right
X 0 setgray
X 18 36 moveto draw_bam
X 38 36 moveto draw_bam
X 28 36 moveto draw_bam
X
X 18 10 moveto draw_bam
X 38 10 moveto draw_bam
X 28 10 moveto draw_bam
X } def
X /7th_bam {
X (7) upper_right
X 0 setgray
X 1 .9 scale
X 28 47 moveto draw_bam
X
X 18 24 moveto draw_bam
X 38 24 moveto draw_bam
X 28 24 moveto draw_bam
X
X 18 1 moveto draw_bam
X 38 1 moveto draw_bam
X 28 1 moveto draw_bam
X } def
X /8th_bam {
X x_size (8) stringwidth pop sub 2 div y_size currentfont fontascent sub 2 div moveto
X (8) show
X
X 0 setgray
X
X 10 40 moveto draw_bam
X 46 40 moveto draw_bam
X 10 1 moveto draw_bam
X 46 1 moveto draw_bam
X
X 12 28 moveto -135 rotate draw_bam 135 rotate
X 44 28 moveto 135 rotate draw_bam -135 rotate
X
X 12 34 moveto -45 rotate draw_bam 45 rotate
X 44 34 moveto 45 rotate draw_bam -45 rotate
X } def
X
X /9th_bam {
X (9) upper_right
X 0 setgray
X 1 .9 scale
X
X 18 47 moveto draw_bam
X 38 47 moveto draw_bam
X 28 47 moveto draw_bam
X
X 18 24 moveto draw_bam
X 38 24 moveto draw_bam
X 28 24 moveto draw_bam
X
X 18 1 moveto draw_bam
X 38 1 moveto draw_bam
X 28 1 moveto draw_bam
X } def
X
X /1st_crak {
X (1) upper_right /Kanji findfont 24 scalefont setfont
X 18 5 moveto (\350\337) show
X /Color self send {
X 0 .7 0 rgbcolor setcolor
X } if
X 18 32 moveto (\260\354) show
X } def
X /2nd_crak {
X (2) upper_right /Kanji findfont 24 scalefont setfont
X 18 5 moveto (\350\337) show
X /Color self send {
X 0 .7 0 rgbcolor setcolor
X } if
X 18 32 moveto (\306\363) show
X } def
X /3rd_crak {
X (3) upper_right /Kanji findfont 24 scalefont setfont
X 18 5 moveto (\350\337) show
X /Color self send {
X 0 .7 0 rgbcolor setcolor
X } if
X 18 32 moveto (\273\260) show
X } def
X /4th_crak {
X (4) upper_right /Kanji findfont 24 scalefont setfont
X 18 5 moveto (\350\337) show
X /Color self send {
X 0 .7 0 rgbcolor setcolor
X } if
X 18 32 moveto (\273\315) show
X } def
X /5th_crak {
X (5) upper_right /Kanji findfont 24 scalefont setfont
X 18 5 moveto (\350\337) show
X /Color self send {
X 0 .7 0 rgbcolor setcolor
X } if
X 18 32 moveto (\270\336) show
X } def
X /6th_crak {
X (6) upper_right /Kanji findfont 24 scalefont setfont
X 18 5 moveto (\350\337) show
X /Color self send {
X 0 .7 0 rgbcolor setcolor
X } if
X 18 32 moveto (\317\273) show
X } def
X /7th_crak {
X (7) upper_right /Kanji findfont 24 scalefont setfont
X 18 5 moveto (\350\337) show
X /Color self send {
X 0 .7 0 rgbcolor setcolor
X } if
X 18 32 moveto (\274\267) show
X } def
X /8th_crak {
X (8) upper_right /Kanji findfont 24 scalefont setfont
X 18 5 moveto (\350\337) show
X /Color self send {
X 0 .7 0 rgbcolor setcolor
X } if
X 18 32 moveto (\310\254) show
X } def
X /9th_crak {
X (9) upper_right /Kanji findfont 24 scalefont setfont
X 18 5 moveto (\350\337) show
X /Color self send {
X 0 .7 0 rgbcolor setcolor
X } if
X 18 32 moveto (\266\345) show
X } def
X
X /winter {
X (winter) upper_right
X /Kanji findfont 24 scalefont setfont
X
X 17 20 moveto (\305\337) show
X } def
X /summer {
X (summer) upper_right
X /Kanji findfont 24 scalefont setfont
X 17 20 moveto (\262\306) show
X } def
X /fall {
X (fall) upper_right
X /Kanji findfont 24 scalefont setfont
X 17 20 moveto (\275\251) show
X } def
X /spring {
X (spring) upper_right
X /Kanji findfont 24 scalefont setfont
X 17 20 moveto (\275\325) show
X } def
X
X /plum {
X (plum) upper_right
X } def
X /bamboo {
X (bamboo) upper_right
X /Kanji findfont 24 scalefont setfont
X 17 20 moveto (\303\335) show
X } def
X /orchid {
X (orchid) upper_right
X } def
X /mum {
X (mum) upper_right
X /Kanji findfont 24 scalefont setfont
X 17 20 moveto (\265\306) show
X } def
X dictend def
X
X
X /draw_piece {
X /Courier findfont 12 scalefont setfont
X .6 setgray
X {0 0 moveto 10 10 rlineto 0 y_size rlineto -10 -10 rlineto closepath} dup exec fill
X 0 setgray exec stroke
X
X .6 setgray
X {0 0 moveto 10 10 rlineto x_size 0 rlineto -10 -10 rlineto closepath} dup exec fill
X 0 setgray exec stroke
X
X 10 10 translate
X /Color self send {.2 .15 .95 hsbcolor setcolor }
X { 1 setgray } ifelse
X 0 0 moveto x_size 0 rlineto 0 y_size rlineto x_size neg 0 rlineto closepath fill
X 0 setgray
X 0 0 moveto x_size 0 rlineto 0 y_size rlineto x_size neg 0 rlineto closepath stroke
X dup special_images exch known {
X special_images exch get
X x_size y_size scale
X imagecanvas
X } {
X pieces exch get exec
X } ifelse
X } def
X
X drag_and_drop {
X /Receptible? true def
X
X /HandleReception { % event selection => bool
X exch /begintransfer 2 index send % sel event
X
X 10 dict dup begin % sel event requestdict
X /Canvas dup def
X /ContentsAscii dup def
X end
X /request 3 index send % sel event replydict
X begin % sel event
X ContentsAscii type /stringtype eq {
X ContentsAscii /AsciiReception self send % sel bool
X } { % sel event
X Canvas type /canvastype eq {
X Canvas /CanvasReception self send % sel bool
X } { pop false } ifelse
X } ifelse
X end
X dup /endtransfer 4 -1 roll % bool bool /et sel
X send % bool
X } def
X
X /AsciiReception { % event string => bool
X (\n) search { % Clear off any returns!
X 3 1 roll pop pop
X } if
X {
X readcanvas
X } stopped {
X pop pop beep false
X } {
X /CanvasReception self send
X } ifelse
X } def
X
X /CanvasReception { % event canvas => bool
X exch pop
X special_images /whoami self send 3 -1 roll put
X tiles {
X dup /whoami exch send /whoami self send eq {
X /paint exch send
X } {
X pop
X } ifelse
X } forall
X true
X } def
X } if
Xclassend def
X
X/MyPanel ClassPanel []
Xclassbegin
X /minsize {846 612} def
Xclassend def
X
X/deck [
X /1st_bam /1st_bam /1st_bam /1st_bam
X /1st_crak /1st_crak /1st_crak /1st_crak
X /1st_dot /1st_dot /1st_dot /1st_dot
X /2nd_bam /2nd_bam /2nd_bam /2nd_bam
X /2nd_crak /2nd_crak /2nd_crak /2nd_crak
X /2nd_dot /2nd_dot /2nd_dot /2nd_dot
X /3rd_bam /3rd_bam /3rd_bam /3rd_bam
X /3rd_crak /3rd_crak /3rd_crak /3rd_crak
X /3rd_dot /3rd_dot /3rd_dot /3rd_dot
X /4th_bam /4th_bam /4th_bam /4th_bam
X /4th_crak /4th_crak /4th_crak /4th_crak
X /4th_dot /4th_dot /4th_dot /4th_dot
X /5th_bam /5th_bam /5th_bam /5th_bam
X /5th_crak /5th_crak /5th_crak /5th_crak
X /5th_dot /5th_dot /5th_dot /5th_dot
X /6th_bam /6th_bam /6th_bam /6th_bam
X /6th_crak /6th_crak /6th_crak /6th_crak
X /6th_dot /6th_dot /6th_dot /6th_dot
X /7th_bam /7th_bam /7th_bam /7th_bam
X /7th_crak /7th_crak /7th_crak /7th_crak
X /7th_dot /7th_dot /7th_dot /7th_dot
X /8th_bam /8th_bam /8th_bam /8th_bam
X /8th_crak /8th_crak /8th_crak /8th_crak
X /8th_dot /8th_dot /8th_dot /8th_dot
X /9th_bam /9th_bam /9th_bam /9th_bam
X /9th_crak /9th_crak /9th_crak /9th_crak
X /9th_dot /9th_dot /9th_dot /9th_dot
X
X /spring /winter /summer /fall
X /bamboo /mum /orchid /plum
X
X /green_dragon /green_dragon /green_dragon /green_dragon
X /red_dragon /red_dragon /red_dragon /red_dragon
X /white_dragon /white_dragon /white_dragon /white_dragon
X
X /east_wind /east_wind /east_wind /east_wind
X /north_wind /north_wind /north_wind /north_wind
X /south_wind /south_wind /south_wind /south_wind
X /west_wind /west_wind /west_wind /west_wind
X] def
X
X% Try to get more random layouts
X currenttime dup truncate sub 10000 mul truncate cvi srand
X
X/random_tiles { % - => tiles'array
X [
X 144 dict dup begin
X deck {
X {
X rand dup currentdict exch known not {
X exit
X } if
X } loop
X exch panel /new ClassTile send def
X } forall
X end
X { exch pop } forall
X ]
X} def
X
X/init_tiles {
X /tiles random_tiles def
X /tiles_off 0 def
X} def
X
X/get_tile {
X tiles tiles_off get
X /tiles_off tiles_off 1 add store
X} def
X
X/fill_row { % x1 x2 y1 z
X pause
X 10 dict begin
X /z exch def
X /z1 z 10 mul def
X /y exch def
X /y1 520 y 64 mul sub def
X /x2 exch def
X /x1 exch def
X /prev null def
X
X x2 -1 x1 {
X /x exch def
X /ti get_tile def
X [x y z] /setwhereiam ti send
X (%-%-%) [x y z] sprintf ti [x 54 mul z1 add y1 z1 add] /addclient panel send
X /totop ti send
X pause
X } for
X end
X} def
X
X/MyBaseWindow ClassBaseWindow []
Xclassbegin
X /QuitFromUser {
X {
X /unmap self send
X /ClientDict panel send {
X pop /removeclient panel send {
X pop
X } if
X pause
X } forall
X /QuitFromUser super send
X } fork pop
X } def
Xclassend
Xdef
X
X/panel /Absolute framebuffer /new MyPanel send def
X
X/win panel framebuffer /new MyBaseWindow send def
X
X/place win send
X/new ClassEventMgr send dup /activate win send
X/activate notice send
X
Xwin /setbasewindow notice send
X
X(Mahjongg) /setlabel win send
X[(\313\343\277\375) /Kanji findfont 24 scalefont] /seticonlabel win send
X
X/map win send
X
Xabout_popup /addsubwindow win send
Xhelp_win /addsubwindow about_popup send
X
Xmain_menu /setmenu panel send
Xtrue /setmenuable panel send
X
Xwin /Colormap get /Installed true put
X
X/seasons 4 dict dup begin
X [ /spring /winter /summer /fall ] { dup def } forall
Xend def
X/flowers 4 dict dup begin
X [ /bamboo /mum /orchid /plum ] { dup def } forall
Xend def
X
X/special_matches 8 dict dup begin
X seasons {
X pop seasons def
X } forall
X
X flowers {
X pop flowers def
X } forall
Xend def
X
X/pieces_match? { %
X special_matches /whoami piece1 send known {
X special_matches /whoami piece1 send get /whoami piece2 send known
X } {
X /whoami piece1 send /whoami piece2 send eq
X } ifelse
X} def
X
X/piece1 null def
X/piece2 null def
X
X/tile_count 0 def
X
X/setup_board {
X /Busy /setvisualstate win send
X
X () (Getting tiles) /setfooter win send
X pause
X init_tiles
X pause
X
X % Ground floor
X (Right most tile) (Building pile) /setfooter win send pause
X
X % Here is where a second game breaks... bet its the addclient...
X /ti get_tile def
X (14-3.5-0) ti [ 14 54 mul 520 3.5 64 mul sub ] /addclient panel send
X [14 3.5 0] /setwhereiam ti send
X /totop ti send
X
X (Right side tile) (Building pile) /setfooter win send pause
X /ti get_tile def
X (13-3.5-0) ti [ 13 54 mul 520 3.5 64 mul sub ] /addclient panel send
X [13 3.5 0] /setwhereiam ti send
X /totop ti send
X
X (Ground floor) (Building pile) /setfooter win send pause
X 1 12 0 0 fill_row
X 3 10 1 0 fill_row
X 2 11 2 0 fill_row
X 1 12 3 0 fill_row
X 1 12 4 0 fill_row
X 2 11 5 0 fill_row
X 3 10 6 0 fill_row
X 1 12 7 0 fill_row
X
X % First floor
X (First floor) (Building pile) /setfooter win send pause
X
X 4 9 1 1 fill_row
X 4 9 2 1 fill_row
X 4 9 3 1 fill_row
X 4 9 4 1 fill_row
X 4 9 5 1 fill_row
X 4 9 6 1 fill_row
X
X % Second floor
X (Second floor) (Building pile) /setfooter win send pause
X
X 5 8 2 2 fill_row
X 5 8 3 2 fill_row
X 5 8 4 2 fill_row
X 5 8 5 2 fill_row
X
X % Third floor
X (Third floor) (Building pile) /setfooter win send pause
X
X 6 7 3 3 fill_row
X 6 7 4 3 fill_row
X
X (Left Blocker) (Building pile) /setfooter win send pause
X /ti get_tile def
X (0-3.5-0) ti [ 0 520 3.5 64 mul sub ] /addclient panel send
X [0 3.5 0] /setwhereiam ti send
X /totop ti send
X
X (Top Tile) (Building pile) /setfooter win send pause
X /ti get_tile def
X (6.5-3.5-4) ti [
X 6.5 54 mul 40 add 520 3.5 65 mul sub 40 add
X ] /addclient panel send
X [6.5 3.5 4] /setwhereiam ti send
X /totop ti send
X pause
X
X () (Laying tiles out) /setfooter win send pause
X
X /validate panel send
X pause
X () (Displaying tiles) /setfooter win send pause
X tiles {
X /map exch send
X } forall
X /Active /setvisualstate win send
X (Tiles left: 144) () /setfooter win send pause
X} def
X
X
X% Remove all the tiles as clients
X/finish_old_game {
X /Busy /setvisualstate win send
X (Cleaning up old game...) () /setfooter win send pause
X /ClientDict panel send {
X pop /removeclient panel send {
X pop
X } if
X pause
X } forall
X /Active /setvisualstate win send
X} def
X
X/new_game {
X /tile_count 144 def
X /forfit false def
X setup_board
X} def
Xnew_game
Xnewprocessgroup currentfile closefile
X
X
X
END_OF_FILE
if test 24253 -ne `wc -c <'mahjongg'`; then
echo shar: \"'mahjongg'\" unpacked with wrong size!
fi
chmod +x 'mahjongg'
# end of 'mahjongg'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have the archive.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0