5 our $black = '0 0 0 1 setcmykcolor';
7 my $pumpkin = ["0 .50 0 1.00 0", "0 0 0 1"];
8 my $green = ["1 0 1 0", "0 0 0 0"];
9 my $red = ["0 1 1 0", "0 0 0 1"];
10 my $blue = ["0.6 0.6 0 0", "0 0 0 0"];
11 my $yellow = ["0 0 1 0", "0 0 0 1"];
12 my $moth = ["0 0 0 1", "0 0 0 0"];
13 my $purple = ["0 1 0 0", "0 0 0 1"];
16 my ($cary, $pips) = @_; # put in a gsave translate
19 0 0 chip 0.5 mul 0 360 arc
20 gsave 1 setlinewidth $black stroke grestore
21 $cary->[0] setcmykcolor fill
22 $cary->[1] setcmykcolor
28 spot 0.5 sqrt mul 1.1 mul dup
35 $spot->( 0, 0) if $pips & 1;
36 $spot->(-1,-1) if $pips & 6;
37 $spot->(+1,+1) if $pips & 6;
38 $spot->(-1,+1) if $pips & 4;
39 $spot->(+1,-1) if $pips & 4;
44 sub ruby () { # put in gsave translate
52 0 1 0.5 0 setcmykcolor gsave fill grestore
53 $black 1 setlinewidth stroke
61 /Times-Roman findfont $fontsz scalefont setfont $black
64 my @lines = split /\n/, $text;
65 foreach my $y (0..$#lines) {
67 $l =~ s/[()\\]/\\$&/g;
68 my $yd = $fontsz * (0.5*@lines - $y);
72 ($l) dup stringwidth pop -0.5 mul 0 rmoveto
80 sub general_book ($$) { # put in a gsave
81 my ($this, $costs) = @_;
86 0 0 0 0.2 setcmykcolor
103 0 thirdlineh dc rlineto
104 -1 thirdlineh dc lineto stroke
106 /thirddivline { % xprop
108 dup -3 div 0 dc moveto
109 -3 div thirdlineh dc lineto stroke
118 foreach my $costi (0..2) {
119 my $cost = $costs->[$costi];
120 my $pips = qw(1 2 4)[$costi];
123 -2.5 $costi add 3 div
125 dup costcirch dc translate
126 ${\ chip($this,$pips) }
128 costtexth exch costtextdx add exch dc moveto
131 dup stringwidth pop -0.5 mul costtextsz neg rmoveto
140 my $o = general_book($green, [qw(5 9 15)]);
143 gsave 0.25 0.15 dc translate ${\ chip($pumpkin,0) } grestore
144 gsave 0.25 0.40 dc translate ${\ chip($green,0) } grestore
149 0.40 0.17 dc moveto (last) show
152 0.40 0.09 dc moveto (3) show
153 /Times-Roman findfont
155 0.45 0.14 dc moveto (}) show
158 0.85 0.275 dc translate
163 $o .= exposition(<<END);
164 For each pumpkin in the last 3 chips,
166 But, not more rubies than the number
167 of green chips in your pot.
174 my $o = general_book($red, [qw(4 9 16)]);
177 gsave 0.35 0.30 dc translate ${\ chip($pumpkin,0) } grestore
181 0.50 0.24 dc moveto (+1) show
185 $o .= exposition(<<END);
186 The next 1/2/4 pumpkins you place are
187 each moved one extra space.
188 (After applying any other special effects;
189 one extra space no matter how many reds)
196 my $o = general_book($blue, [qw(4 9 16)]);
199 /Times-Bold findfont 15 scalefont setfont $black
203 my ($that, $pips) = @_;
205 gsave ${\ chip($that, $pips) } grestore
216 my ($y, $pips, $content) = @_;
219 0.16 0.15 0.16 $y mul add dc translate
221 gsave ${\ chip($blue,$pips) } grestore
231 $o .= $exchline->(2, 1, <<END);
232 ${\ $exchip->($green,1) } ${\ $exslash->() }
233 ${\ $exchip->($red, 1) } ${\ $exslash->() }
234 ${\ $exchip->($blue, 1) } ${\ $exslash->() }
235 ${\ $exchip->($yellow, 1) }
238 $o .= $exchline->(1, 2, <<END);
239 ${\ $exchip->($moth,1) } ${\ $exslash->() }
240 ${\ $exchip->($purple,1) } ${\ $exslash->() }
243 $o .= $exchline->(0, 4, <<END);
246 $o .= exposition(<<END);
247 If the previous chip placed was a pumpkin,
248 you may exchange it as follows:
263 while (my $d = shift @_) {
273 0 th 10 add $pos mul translate
278 dup th add 0 translate
280 $pos 3 sub mul 0 translate
293 print <<END or die $!;
296 72 25.4 div dup scale
313 /costtextdx -0.03 def
314 /costfont /Heletica-BoldOblique findfont costtextsz scalefont def
318 % diagonal conversion
320 dup th mul % xprop yprop y
321 3 1 roll % y xprop yprop
322 bdiag mul neg % y xprop x-margin-at-this-height
323 tw add % y xprop x-width-at-this-height
324 exch mul % y x-width-at-this-height xprop
329 $black 1 setlinewidth
331 0 0 moveto arrowlen 0 rlineto
332 arrowhead dup neg exch rmoveto
333 arrowhead dup neg rlineto
334 arrowhead neg dup rlineto