chiark / gitweb /
WIP gem limit: commodity flags in database
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Fri, 25 Dec 2009 18:58:57 +0000 (18:58 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Fri, 25 Dec 2009 19:05:29 +0000 (19:05 +0000)
yarrg/Commods.pm
yarrg/db-idempotent-populate
yarrg/source-info.txt

index 91781126d319a32c5f0a5d15f3ec499c82af1fbb..af03a6497b9a7760be5b55cbee867680ffd2d25a 100644 (file)
@@ -207,6 +207,7 @@ sub parse_info1 ($$$) {
            $commods{$ucname}{Srcs} .= $ss;
            my $c= $commods{$ucname};
            $c->{Volume}= 1000;
+           $c->{Flags}= '';
            my ($ordval, $ordclassval);
            foreach my $prop (defined $props ? split /\s+/, $props : ()) {
                if ($prop =~ m/^([1-9]\d*)(k?)g$/) {
@@ -220,6 +221,8 @@ sub parse_info1 ($$$) {
                } elsif ($prop =~ m/^\@(\d+\+?)$/) {
                    $ordval= $1;
                    $ordval =~ s/^(\d+)\+$/ $1 + $lnoix * 10 /e;
+               } elsif ($prop =~ m/^\!([a-z]+)$/) {
+                   $c->{Flags} .= $prop;
                } else {
                    die "unknown property $prop for $ucname";
                }
index bb0448ce478389c1c030220514c1cdabe648f588..eb1a30b43a581047e330b4f226670083366e3fb0 100755 (executable)
@@ -229,6 +229,7 @@ table_maycompact('commods', 'commodid',
        commodclassid   INTEGER                 NOT NULL
        ordval          INTEGER                 NOT NULL
        posinclass      INTEGER                 NOT NULL
+       flags           TEXT                    NOT NULL
 END
 
 table_maycompact('islands', 'islandid',
@@ -343,6 +344,7 @@ END
                        commodclassid
                        ordval
                        posinclass
+                       flags
                        );
     my $insert= $dbh->prepare("
  INSERT OR IGNORE INTO $table{commods}
@@ -370,7 +372,8 @@ END
                          $c->{Volume},
                          $clid,
                          commodsortkey($commod),
-                         $posincl{$commod}
+                         $posincl{$commod},
+                         $c->{Flags}
                          );
        $insert->execute($commod, @valuevalues);
        $update->execute(@valuevalues, $commod);
index effc2213bc04968d7b6e559d93715397cedb6ccc..d591ac0c1afee09617268e6526caf7c6c44ead56 100644 (file)
@@ -120,15 +120,15 @@ commods
  persimmon                                                     @200000+
 
 commods
- %g gems               10kg            *forageables            @0
- diamonds              10kg            *forageables            @200000+
- emeralds              10kg            *forageables            @200000+
- moonstones            10kg            *forageables            @200000+
- opals                 10kg            *forageables            @200000+
- pearls                        10kg            *forageables            @200000+
- rubies                        10kg            *forageables            @200000+
- sapphires             10kg            *forageables            @200000+
- topazes               10kg            *forageables            @200000+
+ %g gems               10kg    !g      *forageables            @0
+ diamonds              10kg    !g      *forageables            @200000+
+ emeralds              10kg    !g      *forageables            @200000+
+ moonstones            10kg    !g      *forageables            @200000+
+ opals                 10kg    !g      *forageables            @200000+
+ pearls                        10kg    !g      *forageables            @200000+
+ rubies                        10kg    !g      *forageables            @200000+
+ sapphires             10kg    !g      *forageables            @200000+
+ topazes               10kg    !g      *forageables            @200000+
 
 %g
  amber                                                         @200000+