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 9178112..af03a64 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 bb0448c..eb1a30b 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 effc221..d591ac0 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+