chiark / gitweb /
wip purple
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 3 Dec 2020 18:05:23 +0000 (18:05 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 3 Dec 2020 18:05:23 +0000 (18:05 +0000)
pumpkin-books.ps.pl

index 6713d801a533d16d738dd1fa9d6b660e47071c86..b558b7f6e60c576349ccebd28afd9d22a8cbb88d 100755 (executable)
@@ -41,6 +41,24 @@ END
   $o;
 }
 
+sub veepsspot ($) {
+  my ($chip) = @_;
+  <<END;
+gsave
+  0 chip -0.5 mul translate
+  $black
+  newpath 0 0 chip 0.5 mul 0 360 arc stroke
+  /Times-Bold findfont 7 scalefont setfont
+  -1 -5 translate
+  0 0 moveto (?) show
+  newpath
+   -1 -1 moveto 6 0 rlineto 0 7 rlineto -6 0 rlineto
+    closepath 0.5 setlinewidth stroke
+grestore
+  $chip
+END
+}
+
 sub anychip ($) {
   my ($pips) = @_;
   my $fsz = 10;
@@ -125,14 +143,23 @@ newpath
                               %
 } def
 
+END
+
+  $o .= <<END if @$costs == 3;
 1 thirddivline
 2 thirddivline
-
 END
 
   foreach my $costi (0..2) {
-    my $cost = $costs->[$costi];
-    my $pips = qw(1 2 4)[$costi];
+    my ($cost, $pips);
+    if (@$costs == 3) {
+      $cost = $costs->[$costi];
+      $pips = qw(1 2 4)[$costi];
+    } else {
+      next unless $costi == 1;
+      $cost = $costs->[0];
+      $pips = $costs->[1];
+    }
     $o .= <<END
   costfont setfont
   -2.5 $costi add 3 div
@@ -278,70 +305,23 @@ END
 }
 
 sub purple_book () {
-  my $o = general_book($purple, [qw(10)]);
+  my $o = general_book($purple, [10, 1]);
 
   $o .= <<END;
 /Times-Bold findfont 15 scalefont setfont $black
-END
-
-  my $exchip = sub {
-    my ($that, $pips) = @_;
-    <<END;
-  gsave ${\ chip($that, $pips) } grestore
-END
-  };
-  my $exslash = sub {
-    <<END;
-    8 -5 moveto (/) show
-    20 0 translate
-END
-  };
-  
-  my $exchline = sub {
-    my ($y, $pips, $content) = @_;
-    <<END;
-gsave 
-  0.16 0.15 0.16 $y mul add dc translate
+gsave
+  0.16 0.15  dc translate
   0.60 dup scale
-  gsave ${\ chip($blue,$pips) } grestore
-  8 -3 moveto (:) show
-  3 0 translate
-  0.8 dup scale
-  21 0 translate
-$content
-grestore
 
-gsave
-  0.50 0.65 dc translate
-  0.65 dup scale
-  gsave -10 0 translate ${\ chip($pumpkin,1) } grestore
-  arrow
+  gsave ${\ veepsspot(chip($pumpkin, 0)) } grestore
 grestore
-END
-  };
-
-  $o .= $exchline->(2, 1, <<END);
-  ${\ $exchip->($green,1) }  ${\ $exslash->() }
-  ${\ $exchip->($red,  1) }  ${\ $exslash->() }
-  ${\ $exchip->($blue, 1) }  ${\ $exslash->() }
-  ${\ $exchip->($yellow, 1) }
-END
-
-  $o .= $exchline->(1, 2, <<END);
-  ${\ $exchip->($moth,1) }  ${\ $exslash->() }
-  ${\ $exchip->($purple,1) }  ${\ $exslash->() }
-  ${\ anychip(2) }
-END
-
-  $o .= $exchline->(0, 4, <<END);
-  ${\ anychip(4) }
 END
 
   $o .= exposition(<<END);
-If the previous chip placed was a pumpkin,
-you may exchange it as follows:
-
+For each pumpkin in the pot (but
+ not more than the number of purple chips),
+add up the VPs of the covered spaces.
+Buy 1/2 chips of up to that total value.
 END
 
   $o;