5 my $pumpkin = ["1 .55 0", "0 0 0"]; # xxx check printout vs green
6 my $green = [" 0 .5 0", "1 1 1"];
7 my $red = ["1 0 0", "0 0 0"];
8 my $blue = ["0 .4 1 ", "1 1 1"];
9 my $yellow = [".9 .9 0", "0 0 0"];
10 my $moth = [" 0 0 0", "1 1 1"];
11 my $purple = [".8 0 .8", "0 0 0"];
12 my $lotus = [" 0 .6 .6", ".5 .5 0"];
14 my $anychip = ['0.8', '0'];
18 if ($c =~ m/[^ 0-9.]/) {
20 } elsif ($c =~ m/^\s*\S+\s*$/) {
22 } elsif ($c =~ m/./) {
23 return "$c setrgbcolor";
29 our $black = colour('0');
32 my ($cary, $pips) = @_; # put in a gsave translate
35 0 0 chip 0.5 mul 0 360 arc
36 gsave 1 setlinewidth $black stroke grestore
37 ${\ colour($cary->[0]) } fill
41 ${\ colour($cary->[1]) }
48 spot 0.5 sqrt mul 1.1 mul dup
55 $spot->( 0, 0) if $pips & 1;
56 $spot->(-1,-1) if $pips & 6;
57 $spot->(+1,+1) if $pips & 6;
58 $spot->(-1,+1) if $pips & 4;
59 $spot->(+1,-1) if $pips & 4;
68 0 chip -0.5 mul translate
70 newpath 0 0 chip 0.5 mul 0 360 arc stroke
71 /Times-Bold findfont 7 scalefont setfont
75 -1 -1 moveto 6 0 rlineto 0 7 rlineto -6 0 rlineto
76 closepath 0.5 setlinewidth stroke
87 chip -0.5 mul $fsz -0.30 mul moveto
88 /Helvetica-Bold findfont $fsz scalefont setfont
89 (Any) dup stringwidth 3 2 roll show
92 ${\ chip($anychip, $pips) }
97 sub ruby () { # put in gsave translate
105 ${\ colour('1 0.5 0.5') } gsave fill grestore
106 $black 1 setlinewidth stroke
114 /Times-Roman findfont $fontsz scalefont setfont $black
117 my @lines = split /\n/, $text;
118 foreach my $y (0..$#lines) {
120 $l =~ s/[()\\]/\\$&/g;
121 my $yd = $fontsz * (0.5*@lines - $y);
125 ($l) dup stringwidth pop -0.5 mul 0 rmoveto
133 sub general_book ($$) { # put in a gsave
134 my ($this, $costs) = @_;
156 0 thirdlineh dc rlineto
157 -1 thirdlineh dc lineto stroke
159 /thirddivline { % xprop
161 dup -3 div 0 dc moveto
162 -3 div thirdlineh dc lineto stroke
168 $o .= <<END if @$costs == 3;
173 foreach my $costi (0..2) {
176 $cost = $costs->[$costi];
177 $pips = qw(1 2 4)[$costi];
179 next unless $costi == 1;
185 -2.5 $costi add 3 div
187 dup costcirch dc translate
188 ${\ chip($this,$pips) }
190 costtexth exch costtextdx add exch dc moveto
193 dup stringwidth pop -0.5 mul costtextsz neg rmoveto
202 my $o = general_book($green, [qw(5 9 15)]);
205 gsave 0.25 0.15 dc translate ${\ chip($pumpkin,0) } grestore
206 gsave 0.25 0.40 dc translate ${\ chip($green,0) } grestore
211 0.40 0.17 dc moveto (last) show
214 0.40 0.09 dc moveto (3) show
215 /Times-Roman findfont
217 0.45 0.14 dc moveto (}) show
220 0.85 0.275 dc translate
225 $o .= exposition(<<END);
226 For each pumpkin in the last 3 chips,
228 But, not more rubies than the number
229 of green chips in your pot.
236 my $o = general_book($red, [qw(4 9 16)]);
239 gsave 0.35 0.30 dc translate ${\ chip($pumpkin,0) } grestore
243 0.50 0.24 dc moveto (+1) show
247 $o .= exposition(<<END);
248 The next 1/2/4 pumpkins you place are
249 each moved one extra space.
250 (After applying any other special effects;
251 one extra space no matter how many reds)
258 my $o = general_book($blue, [qw(4 10 18)]);
261 /Times-Bold findfont 15 scalefont setfont $black
265 my ($that, $pips) = @_;
267 gsave ${\ chip($that, $pips) } grestore
278 my ($y, $pips, $content) = @_;
281 0.16 0.15 0.16 $y mul add dc translate
283 gsave ${\ chip($blue,$pips) } grestore
292 0.50 0.65 dc translate
294 gsave -10 0 translate ${\ chip($pumpkin,1) } grestore
300 $o .= $exchline->(2, 1, <<END);
301 ${\ $exchip->($green,1) } ${\ $exslash->() }
302 ${\ $exchip->($red, 1) } ${\ $exslash->() }
303 ${\ $exchip->($blue, 1) } ${\ $exslash->() }
304 ${\ $exchip->($yellow, 1) }
307 $o .= $exchline->(1, 2, <<END);
308 ${\ $exchip->($moth,1) } ${\ $exslash->() }
309 ${\ $exchip->($purple,1) } ${\ $exslash->() }
313 $o .= $exchline->(0, 4, <<END);
317 $o .= exposition(<<END);
318 If the previous chip placed was a pumpkin,
319 you may exchange it as follows:
328 my $o = general_book($lotus, [8, 0]);
331 /Times-Bold findfont 15 scalefont setfont $black
334 0.36 0.38 dc translate
336 gsave ${\ chip($lotus,0) } grestore
341 0.20 0.15 dc translate
343 gsave ${\ chip($pumpkin,0) } grestore
344 chip 0.5 mul 0 translate
345 gsave ${\ chip($pumpkin,0) } grestore
347 10 -4.5 moveto (... +1) show
353 0.16 0.20 dc translate
356 gsave ${\ veepsspot(chip($pumpkin, 0)) } grestore
357 gsave 0 20 translate ${\ chip($purple, 1) } grestore
363 $o .= exposition(<<END);
364 The value of this chip is
365 1 higher than the number of pumpkins
366 previously placed in the pot (but max.4)
373 my $o = general_book($purple, [10, 1]);
376 gsave ${\ veepsspot(chip($pumpkin, 0)) } grestore
377 gsave 0 20 translate ${\ chip($purple, 1) } grestore
381 /Times-Bold findfont 15 scalefont setfont $black
383 0.16 0.20 dc translate
387 8 -12 moveto (...) show
393 /Times-Roman findfont
395 0.48 0.14 dc moveto (}) show
399 0.83 0.25 dc translate
401 ${\ chip($anychip, 0) }
405 0.72 0.22 dc translate
407 $black 0 0 moveto (?+?) show
411 $o .= exposition(<<END);
412 For each pumpkin in the pot (but
413 not more than the number of purple chips),
414 add up the VPs of the covered spaces.
415 Buy 1/2 chips of up to that total value.
422 my $index = scalar @_;
430 while (my $d = pop @_) {
440 0 th 10 add $pos mul translate
445 dup th add 0 translate
447 $pos 3 sub mul 0 translate
453 /Courier-Bold findfont 6 scalefont setfont
466 print <<END or die $!;
469 72 25.4 div dup scale
486 /costtextdx -0.03 def
487 /costfont /Heletica-BoldOblique findfont costtextsz scalefont def
491 % diagonal conversion
493 dup th mul % xprop yprop y
494 3 1 roll % y xprop yprop
495 bdiag mul neg % y xprop x-margin-at-this-height
496 tw add % y xprop x-width-at-this-height
497 exch mul % y x-width-at-this-height xprop
502 $black 1 setlinewidth
504 0 0 moveto arrowlen 0 rlineto
505 arrowhead dup neg exch rmoveto
506 arrowhead dup neg rlineto
507 arrowhead neg dup rlineto