5 my $pumpkin = ["255/185/15", "0 0 0"];
6 my $green = ["0/238/118", "1 1 1"];
7 my $red = ["1 0 0", "0 0 0"];
8 my $blue = ["0 .4 1 ", "1 1 1"];
9 my $yellow = ["1 1 0", "0 0 0"];
10 my $moth = [" 0 0 0", "1 1 1"];
11 my $purple = ["145/44/238", "0 0 0"];
12 my $lotus = [" 0 .6 .6", ".5 .5 0"];
14 my $anychip = ['0.8', '0'];
18 if ($c =~ m{^(\d+)/(\d+)/(\d+)$}) {
19 return (join ' ', map { $_ / 255.0 } ($1,$2,$3)).' setrgbcolor';
20 } elsif ($c =~ m/[^ 0-9.]/) {
22 } elsif ($c =~ m/^\s*\S+\s*$/) {
24 } elsif ($c =~ m/./) {
25 return "$c setrgbcolor";
31 our $black = colour('0');
34 my ($cary, $pips) = @_; # put in a gsave translate
37 0 0 chip 0.5 mul 0 360 arc
38 gsave 1 setlinewidth $black stroke grestore
39 ${\ colour($cary->[0]) } fill
43 ${\ colour($cary->[1]) }
50 spot 0.5 sqrt mul 1.1 mul dup
57 $spot->( 0, 0) if $pips & 1;
58 $spot->(-1,-1) if $pips & 6;
59 $spot->(+1,+1) if $pips & 6;
60 $spot->(-1,+1) if $pips & 4;
61 $spot->(+1,-1) if $pips & 4;
70 0 chip -0.5 mul translate
72 newpath 0 0 chip 0.5 mul 0 360 arc stroke
73 /Times-Bold findfont 7 scalefont setfont
77 -1 -1 moveto 6 0 rlineto 0 7 rlineto -6 0 rlineto
78 closepath 0.5 setlinewidth stroke
89 chip -0.5 mul $fsz -0.30 mul moveto
90 /Helvetica-Bold findfont $fsz scalefont setfont
91 (Any) dup stringwidth 3 2 roll show
94 ${\ chip($anychip, $pips) }
99 sub ruby () { # put in gsave translate
107 ${\ colour('1 .2 .2') } gsave fill grestore
108 $black 1 setlinewidth stroke
116 /Times-Roman findfont $fontsz scalefont setfont $black
119 my @lines = split /\n/, $text;
120 foreach my $y (0..$#lines) {
122 $l =~ s/[()\\]/\\$&/g;
123 my $yd = $fontsz * (0.5*@lines - $y);
127 ($l) dup stringwidth pop -0.5 mul 0 rmoveto
135 sub general_book ($$) { # put in a gsave
136 my ($this, $costs) = @_;
158 0 thirdlineh dc rlineto
159 -1 thirdlineh dc lineto stroke
161 /thirddivline { % xprop
163 dup -3 div 0 dc moveto
164 -3 div thirdlineh dc lineto stroke
170 $o .= <<END if @$costs == 3;
175 foreach my $costi (0..2) {
178 $cost = $costs->[$costi];
179 $pips = qw(1 2 4)[$costi];
181 next unless $costi == 1;
187 -2.5 $costi add 3 div
189 dup costcirch dc translate
190 ${\ chip($this,$pips) }
192 costtexth exch costtextdx add exch dc moveto
195 dup stringwidth pop -0.5 mul costtextsz neg rmoveto
204 my $o = general_book($green, [qw(5 9 15)]);
207 gsave 0.25 0.15 dc translate ${\ chip($pumpkin,0) } grestore
208 gsave 0.25 0.40 dc translate ${\ chip($green,0) } grestore
213 0.40 0.17 dc moveto (last) show
216 0.40 0.09 dc moveto (3) show
217 /Times-Roman findfont
219 0.45 0.14 dc moveto (}) show
222 0.85 0.275 dc translate
227 $o .= exposition(<<END);
228 For each pumpkin in the last 3 chips,
230 But, not more rubies than the number
231 of green chips in your pot.
238 my $o = general_book($red, [qw(4 9 16)]);
241 gsave 0.35 0.30 dc translate ${\ chip($pumpkin,0) } grestore
245 0.50 0.24 dc moveto (+1) show
249 $o .= exposition(<<END);
250 The next 1/2/4 pumpkins you place are
251 each moved one extra space.
252 (After applying any other special effects;
253 one extra space no matter how many reds)
260 my $o = general_book($blue, [qw(4 10 18)]);
263 /Times-Bold findfont 15 scalefont setfont $black
267 my ($that, $pips) = @_;
269 gsave ${\ chip($that, $pips) } grestore
280 my ($y, $pips, $content) = @_;
283 0.16 0.15 0.16 $y mul add dc translate
285 gsave ${\ chip($blue,$pips) } grestore
294 0.50 0.65 dc translate
296 gsave -10 0 translate ${\ chip($pumpkin,1) } grestore
302 $o .= $exchline->(2, 1, <<END);
303 ${\ $exchip->($green,1) } ${\ $exslash->() }
304 ${\ $exchip->($red, 1) } ${\ $exslash->() }
305 ${\ $exchip->($blue, 1) } ${\ $exslash->() }
306 ${\ $exchip->($yellow, 1) }
309 $o .= $exchline->(1, 2, <<END);
310 ${\ $exchip->($moth,1) } ${\ $exslash->() }
311 ${\ $exchip->($purple,1) } ${\ $exslash->() }
315 $o .= $exchline->(0, 4, <<END);
319 $o .= exposition(<<END);
320 If the previous chip placed was a pumpkin,
321 you may exchange it as follows:
330 my $o = general_book($lotus, [8, 0]);
333 /Times-Bold findfont 15 scalefont setfont $black
336 0.36 0.38 dc translate
338 gsave ${\ chip($lotus,0) } grestore
343 0.20 0.15 dc translate
345 gsave ${\ chip($pumpkin,0) } grestore
346 chip 0.5 mul 0 translate
347 gsave ${\ chip($pumpkin,0) } grestore
349 10 -4.5 moveto (... +1) show
355 0.16 0.20 dc translate
358 gsave ${\ veepsspot(chip($pumpkin, 0)) } grestore
359 gsave 0 20 translate ${\ chip($purple, 1) } grestore
365 $o .= exposition(<<END);
366 The value of this chip is
367 1 higher than the number of pumpkins
368 previously placed in the pot (but max.4)
375 my $o = general_book($purple, [10, 1]);
378 gsave ${\ veepsspot(chip($pumpkin, 0)) } grestore
379 gsave 0 20 translate ${\ chip($purple, 1) } grestore
383 /Times-Bold findfont 15 scalefont setfont $black
385 0.16 0.20 dc translate
389 8 -12 moveto (...) show
395 /Times-Roman findfont
397 0.48 0.14 dc moveto (}) show
401 0.83 0.25 dc translate
403 ${\ chip($anychip, 0) }
407 0.72 0.22 dc translate
409 $black 0 0 moveto (?+?) show
413 $o .= exposition(<<END);
414 For each pumpkin in the pot (but
415 not more than the number of purple chips),
416 add up the VPs of the covered spaces.
417 Buy 1/2 chips of up to that total value.
424 my $index = scalar @_;
432 while (my $d = pop @_) {
442 0 th 10 add $pos mul translate
447 dup th add 0 translate
449 $pos 3 sub mul 0 translate
455 /Courier-Bold findfont 6 scalefont setfont
468 print <<END or die $!;
471 72 25.4 div dup scale
488 /costtextdx -0.03 def
489 /costfont /Heletica-BoldOblique findfont costtextsz scalefont def
493 % diagonal conversion
495 dup th mul % xprop yprop y
496 3 1 roll % y xprop yprop
497 bdiag mul neg % y xprop x-margin-at-this-height
498 tw add % y xprop x-width-at-this-height
499 exch mul % y x-width-at-this-height xprop
504 $black 1 setlinewidth
506 0 0 moveto arrowlen 0 rlineto
507 arrowhead dup neg exch rmoveto
508 arrowhead dup neg rlineto
509 arrowhead neg dup rlineto