Skip to content

Commit

Permalink
upgrade to all rules_descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
zach morgan committed Jun 3, 2009
1 parent 61b8ba4 commit 231280b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 37 deletions.
3 changes: 3 additions & 0 deletions lib/basilisk/Schema/Ruleset.pm
Expand Up @@ -147,6 +147,9 @@ sub generate_rules_description{

my $desc = $h . 'x' . $w;
$desc .= ", $topo" if $topo ne 'plane';
if ($cycle ne '2-FFA'){
$desc .= ", $cycle";
}
if ($heisenChance){
$desc .= ', HeisenGo';
$desc .= '(' . to_percent($heisenChance) . ')' if $heisenChance != 1;
Expand Down
4 changes: 3 additions & 1 deletion lib/basilisk/Util.pm
Expand Up @@ -135,11 +135,13 @@ my %cycle_descs = (
'0b 1b 2w 0w 1r 2r' => '3-player perverse',
'0b 1w 2r 1b 2w 0r' => '3-player skewed perverse',
'0b 1w 2r 2r 1w 0b' => '3-player skewed FFA',
'0b 1w 0r 1b 0w 1r' => 'inverted zen',
);

sub cycle_desc{
my $pd = shift;
return $cycle_descs{$pd};
return $cycle_descs{$pd} if $cycle_descs{$pd};
return "cycle: ($pd)"; #TODO: try harder with basis & aberrations
}

sub to_percent{
Expand Down
29 changes: 29 additions & 0 deletions script/update_all_rules_descriptions.pl
@@ -0,0 +1,29 @@
#!/usr/bin/perl

use strict;
use warnings;
use 5.10.0;
use FindBin '$Bin';
use lib "$Bin/../lib";
use basilisk::Schema;
use basilisk::Util;
use JSON;
my $dbfile = "$Bin/../basilisk.db";
my ($dsn, $user, $pass) = ("dbi:SQLite:$dbfile");

my $schema = basilisk::Schema->connect($dsn, $user, $pass) or
die "Failed to connect to database";


my $rulesets = $schema->resultset('Ruleset');

#dangerous--will erase other_rules unless extra_rules still exist for them
for my $ruleset ($rulesets->all){
#say $ruleset->id;
#say $ruleset->rules_description;
#say $ruleset->generate_rules_description. "\n";
$ruleset->set_column (rules_description => $ruleset->generate_rules_description);
$ruleset->update;
}


36 changes: 0 additions & 36 deletions script/whoops_rules.pl

This file was deleted.

0 comments on commit 231280b

Please sign in to comment.