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/245/255",) x 2];
13 my $white = ["1 1 1", "0 0 0"];
15 my $anychip = ['0.8', '0'];
17 our $page_pre = <<END;
26 if ($c =~ m{^(\d+)/(\d+)/(\d+)$}) {
27 return (join ' ', map { $_ / 255.0 } ($1,$2,$3)).' setrgbcolor';
28 } elsif ($c =~ m/[^ 0-9.]/) {
30 } elsif ($c =~ m/^\s*\S+\s*$/) {
32 } elsif ($c =~ m/./) {
33 return "$c setrgbcolor";
39 our $black = colour('0');
42 my ($cary, $pips) = @_; # put in a gsave translate
45 0 0 chip 0.5 mul 0 360 arc
46 gsave 1 setlinewidth $black stroke grestore
47 ${\ colour($cary->[0]) } fill
51 ${\ colour($cary->[1]) }
58 spot 0.5 sqrt mul 1.1 mul dup
65 $spot->( 0, 0) if $pips & 1;
66 $spot->(-1,-1) if $pips & 6;
67 $spot->(+1,+1) if $pips & 6;
68 $spot->(-1,+1) if $pips & 4;
69 $spot->(+1,-1) if $pips & 4;
78 0 chip -0.5 mul translate
80 newpath 0 0 chip 0.5 mul 0 360 arc stroke
81 /Times-Bold findfont 7 scalefont setfont
85 -1 -1 moveto 6 0 rlineto 0 7 rlineto -6 0 rlineto
86 closepath 0.5 setlinewidth stroke
97 chip -0.5 mul $fsz -0.30 mul moveto
98 /Helvetica-Bold findfont $fsz scalefont setfont
99 (Any) dup stringwidth 3 2 roll show
102 ${\ chip($anychip, $pips) }
107 sub ruby () { # put in gsave translate
115 ${\ colour('1 .2 .2') } gsave fill grestore
116 $black 1 setlinewidth stroke
124 /Times-Roman findfont $fontsz scalefont setfont $black
127 my @lines = split /\n/, $text;
128 foreach my $y (0..$#lines) {
130 $l =~ s/[()\\]/\\$&/g;
131 my $yd = $fontsz * (0.5*@lines - $y);
135 ($l) dup stringwidth pop -0.5 mul 0 rmoveto
143 sub general_book ($$) { # put in a gsave
144 my ($this, $costs) = @_;
166 0 thirdlineh dc rlineto
167 -1 thirdlineh dc lineto stroke
169 /thirddivline { % xprop
171 dup -3 div 0 dc moveto
172 -3 div thirdlineh dc lineto stroke
178 $o .= <<END if @$costs == 3;
183 foreach my $costi (0..2) {
186 $cost = $costs->[$costi];
187 $pips = qw(1 2 4)[$costi];
189 next unless $costi == 1;
195 -2.5 $costi add 3 div
197 dup costcirch dc translate
198 ${\ chip($this,$pips) }
200 costtexth exch costtextdx add exch dc moveto
203 dup stringwidth pop -0.5 mul costtextsz neg rmoveto
212 my $o = general_book($green, [qw(5 9 15)]);
215 gsave 0.25 0.15 dc translate ${\ chip($pumpkin,0) } grestore
216 gsave 0.25 0.40 dc translate ${\ chip($green,0) } grestore
221 0.40 0.17 dc moveto (last) show
224 0.40 0.09 dc moveto (3) show
225 /Times-Roman findfont
227 0.45 0.14 dc moveto (}) show
230 0.85 0.275 dc translate
235 $o .= exposition(<<END);
236 For each pumpkin in the last 3 chips,
238 But, not more rubies than the number
239 of green chips in your pot.
246 my $o = general_book($red, [qw(4 9 16)]);
249 gsave 0.35 0.30 dc translate ${\ chip($pumpkin,0) } grestore
253 0.50 0.24 dc moveto (+1) show
257 $o .= exposition(<<END);
258 The next 1/2/4 pumpkins you place are
259 each moved one extra space.
260 (After applying any other special effects;
261 one extra space no matter how many reds)
268 my $o = general_book($blue, [qw(4 10 18)]);
271 /Times-Bold findfont 15 scalefont setfont $black
274 0.50 0.65 dc translate
276 gsave -10 0 translate ${\ chip($pumpkin,1) } grestore
282 my ($that, $pips) = @_;
284 gsave ${\ chip($that, $pips) } grestore
295 my ($y, $pips, $content) = @_;
298 0.16 0.15 0.16 $y mul add dc translate
300 gsave ${\ chip($blue,$pips) } grestore
310 $o .= $exchline->(2, 1, <<END);
311 ${\ $exchip->($green,1) } ${\ $exslash->() }
312 ${\ $exchip->($red, 1) } ${\ $exslash->() }
313 ${\ $exchip->($blue, 1) } ${\ $exslash->() }
314 ${\ $exchip->($yellow, 1) }
317 $o .= $exchline->(1, 2, <<END);
318 ${\ $exchip->($moth,1) } ${\ $exslash->() }
319 ${\ $exchip->($purple,1) } ${\ $exslash->() }
323 $o .= $exchline->(0, 4, <<END);
327 $o .= exposition(<<END);
328 If the previous chip placed was a pumpkin,
329 you may exchange it as follows:
338 my $o = general_book($lotus, [8, 0]);
341 /Times-Bold findfont 15 scalefont setfont $black
344 0.36 0.38 dc translate
346 gsave ${\ chip($lotus,0) } grestore
351 0.20 0.15 dc translate
353 gsave ${\ chip($pumpkin,0) } grestore
354 chip 0.5 mul 0 translate
355 gsave ${\ chip($pumpkin,0) } grestore
357 10 -4.5 moveto (... +1) show
363 0.16 0.20 dc translate
366 gsave ${\ veepsspot(chip($pumpkin, 0)) } grestore
367 gsave 0 20 translate ${\ chip($purple, 1) } grestore
373 $o .= exposition(<<END);
374 The value of this chip is
375 1 higher than the number of pumpkins
376 previously placed in the pot (but max.4)
383 my $o = general_book($purple, [10, 1]);
386 gsave ${\ veepsspot(chip($pumpkin, 0)) } grestore
387 gsave 0 20 translate ${\ chip($purple, 1) } grestore
391 /Times-Bold findfont 15 scalefont setfont $black
393 0.16 0.20 dc translate
397 8 -12 moveto (...) show
403 /Times-Roman findfont
405 0.48 0.14 dc moveto (}) show
409 0.83 0.25 dc translate
411 ${\ chip($anychip, 0) }
415 0.72 0.22 dc translate
417 $black 0 0 moveto (?+?) show
421 $o .= exposition(<<END);
422 For each pumpkin in the pot (but
423 not more than the number of purple chips),
424 add up the VPs of the covered spaces.
425 Buy 1/2 chips of up to that total value.
432 my $index = scalar @_;
441 while (my $d = pop @_) {
451 0 th 10 add $pos mul translate
456 dup th add 0 translate
458 $pos 3 sub mul 0 translate
464 /Courier-Bold findfont 6 scalefont setfont
478 my $o = general_book($yellow, [qw(7 12 19)]);
482 0.50 0.62 dc translate
485 gsave 26 0 translate ${\ chip($anychip,0) } grestore
486 gsave 46 0 translate ${\ chip($pumpkin,0) } grestore
491 my ($that, $pips) = @_;
493 gsave ${\ chip($that, $pips) } grestore
504 my ($y, $pips, $content) = @_;
507 0.20 0.12 0.16 $y mul add dc translate
509 gsave ${\ chip($yellow,$pips) } grestore
519 $o .= $exchline->(2, 1, <<END);
520 ${\ $exchip->($white,1) } ${\ $exslash->() }
521 ${\ $exchip->($anychip,1) } ${\ $exslash->() }
522 ${\ $exchip->($lotus,0) }
525 $o .= $exchline->(1, 2, <<END);
526 ${\ $exchip->($white,2) } ${\ $exslash->() }
527 ${\ $exchip->($anychip,2) }
530 $o .= $exchline->(0, 4, <<END);
531 ${\ $exchip->($white,3) } ${\ $exslash->() }
532 ${\ $exchip->($anychip,4) }
535 $o .= exposition(<<END);
536 Put a chip, no bigger than the yellow,
537 where the next placed chip is a pumpkin,
546 print <<END or die $!;
563 /costtextdx -0.03 def
564 /costfont /Heletica-BoldOblique findfont costtextsz scalefont def
568 % diagonal conversion
570 dup th mul % xprop yprop y
571 3 1 roll % y xprop yprop
572 bdiag mul neg % y xprop x-margin-at-this-height
573 tw add % y xprop x-width-at-this-height
574 exch mul % y x-width-at-this-height xprop
579 $black 1 setlinewidth
581 0 0 moveto arrowlen 0 rlineto
582 arrowhead dup neg exch rmoveto
583 arrowhead dup neg rlineto
584 arrowhead neg dup rlineto
590 print "gsave\n" or die $!;