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"];
14 my ($cary, $pips) = @_; # put in a gsave translate
17 0 0 chip 0.5 mul 0 360 arc
18 gsave 1 setlinewidth $black stroke grestore
19 $cary->[0] setcmykcolor fill
20 $cary->[1] setcmykcolor
26 spot 0.5 sqrt mul 1.1 mul dup
33 $spot->( 0, 0) if $pips & 1;
34 $spot->(-1,-1) if $pips & 6;
35 $spot->(+1,+1) if $pips & 6;
36 $spot->(-1,+1) if $pips & 4;
37 $spot->(+1,-1) if $pips & 4;
42 sub ruby () { # put in gsave translate
50 0 1 0.5 0 setcmykcolor gsave fill grestore
51 $black 1 setlinewidth stroke
59 /Times-Roman findfont $fontsz scalefont setfont $black
62 my @lines = split /\n/, $text;
63 foreach my $y (0..$#lines) {
65 $l =~ s/[()\\]/\\$&/g;
66 my $yd = $fontsz * (0.5*@lines - $y);
70 ($l) dup stringwidth pop -0.5 mul 0 rmoveto
78 sub general_book ($$) { # put in a gsave
79 my ($this, $costs) = @_;
84 0 0 0 0.2 setcmykcolor
101 0 thirdlineh dc rlineto
102 -1 thirdlineh dc lineto stroke
104 /thirddivline { % xprop
106 dup -3 div 0 dc moveto
107 -3 div thirdlineh dc lineto stroke
116 foreach my $costi (0..2) {
117 my $cost = $costs->[$costi];
118 my $pips = qw(1 2 4)[$costi];
121 -2.5 $costi add 3 div
123 dup costcirch dc translate
124 ${\ chip($this,$pips) }
126 costtexth exch costtextdx add exch dc moveto
129 dup stringwidth pop -0.5 mul costtextsz neg rmoveto
138 my $o = general_book($green, [qw(5 9 15)]);
141 gsave 0.25 0.15 dc translate ${\ chip($pumpkin,0) } grestore
142 gsave 0.25 0.40 dc translate ${\ chip($green,0) } grestore
147 0.40 0.17 dc moveto (last) show
150 0.40 0.09 dc moveto (3) show
151 /Times-Roman findfont
153 0.45 0.14 dc moveto (}) show
156 0.85 0.275 dc translate
161 $o .= exposition(<<END);
162 For each pumpkin in the last 3 chips,
164 But, not more rubies than the number
165 of green chips in your pot.
172 my $o = general_book($red, [qw(4 9 16)]);
175 gsave 0.35 0.30 dc translate ${\ chip($pumpkin,0) } grestore
179 0.50 0.24 dc moveto (+1) show
183 $o .= exposition(<<END);
184 The next 1/2/4 pumpkins you place are
185 each moved one extra space.
186 (After applying any other special effects;
187 one extra space no matter how many reds)
194 my $o = general_book($blue, [qw(4 9 16)]);
197 /Times-Bold findfont 15 scalefont setfont $black
201 my ($that, $pips) = @_;
203 gsave ${\ chip($that, $pips) } grestore
214 my ($y, $pips, $content) = @_;
217 0.16 0.15 0.16 $y mul add dc translate
219 gsave ${\ chip($blue,1) } grestore
229 $o .= $exchline->(2, 1, <<END);
230 ${\ $exchip->($green,1) } ${\ $exslash->() }
231 ${\ $exchip->($red, 1) } ${\ $exslash->() }
232 ${\ $exchip->($blue, 1) } ${\ $exslash->() }
233 ${\ $exchip->($yellow, 1) }
238 0.16 0.15 dc translate
240 gsave ${\ chip($blue,4) } grestore
245 $o .= exposition(<<END);
246 If the previous chip placed was a pumpkin,
247 you may exchange it as follows:
262 while (my $d = shift @_) {
272 0 th 10 add $pos mul translate
277 dup th add 0 translate
279 $pos 3 sub mul 0 translate
292 print <<END or die $!;
295 72 25.4 div dup scale
312 /costtextdx -0.03 def
313 /costfont /Heletica-BoldOblique findfont costtextsz scalefont def
317 % diagonal conversion
319 dup th mul % xprop yprop y
320 3 1 roll % y xprop yprop
321 bdiag mul neg % y xprop x-margin-at-this-height
322 tw add % y xprop x-width-at-this-height
323 exch mul % y x-width-at-this-height xprop
328 $black 1 setlinewidth
330 0 0 moveto arrowlen 0 rlineto
331 arrowhead dup neg exch rmoveto
332 arrowhead dup neg rlineto
333 arrowhead neg dup rlineto