From ca3e05b5754c115092e4e66545cc666a28ebe453 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 4 Mar 2010 10:57:33 -0600 Subject: [PATCH] changed cnames to future simpledb version --- lib/Lacuna/Body.pm | 2 +- lib/Lacuna/DB/Body.pm | 4 ++-- lib/Lacuna/DB/Empire.pm | 4 ++-- lib/Lacuna/DB/Species.pm | 4 ++-- lib/Lacuna/DB/Star.pm | 4 ++-- lib/Lacuna/Empire.pm | 4 ++-- lib/Lacuna/Inbox.pm | 2 +- lib/Lacuna/Map.pm | 2 +- lib/Lacuna/Species.pm | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/Lacuna/Body.pm b/lib/Lacuna/Body.pm index d963bab3..34c3e35d 100644 --- a/lib/Lacuna/Body.pm +++ b/lib/Lacuna/Body.pm @@ -21,7 +21,7 @@ sub rename { ->length_lt(31) ->no_restricted_chars ->no_profanity - ->not_ok($self->simpledb->domain('body')->count(where => {cname=>Lacuna::Util::cname($name), 'itemName()'=>['!=',$body_id]}, consistent=>1)); # name available + ->not_ok($self->simpledb->domain('body')->count(where => {name_cname=>Lacuna::Util::cname($name), 'itemName()'=>['!=',$body_id]}, consistent=>1)); # name available my $body = $self->simpledb->domain('body')->find($body_id); if (defined $body) { my $empire = $self->get_empire_by_session($session_id); diff --git a/lib/Lacuna/DB/Body.pm b/lib/Lacuna/DB/Body.pm index f660e6f8..404d81dc 100644 --- a/lib/Lacuna/DB/Body.pm +++ b/lib/Lacuna/DB/Body.pm @@ -9,10 +9,10 @@ __PACKAGE__->add_attributes( name => { isa => 'Str', trigger => sub { my ($self, $new, $old) = @_; - $self->cname(Lacuna::Util::cname($new)); + $self->name_cname(Lacuna::Util::cname($new)); }, }, - cname => { isa => 'Str' }, + name_cname => { isa => 'Str' }, star_id => { isa => 'Str' }, orbit => { isa => 'Int' }, x => { isa => 'Int' }, # indexed here to speed up diff --git a/lib/Lacuna/DB/Empire.pm b/lib/Lacuna/DB/Empire.pm index df0ee5b8..930ba85e 100644 --- a/lib/Lacuna/DB/Empire.pm +++ b/lib/Lacuna/DB/Empire.pm @@ -10,10 +10,10 @@ __PACKAGE__->add_attributes( name => { isa => 'Str', trigger => sub { my ($self, $new, $old) = @_; - $self->cname(Lacuna::Util::cname($new)); + $self->name_cname(Lacuna::Util::cname($new)); }, }, - cname => { isa => 'Str' }, + name_cname => { isa => 'Str' }, date_created => { isa => 'DateTime' }, description => { isa => 'Str' }, home_planet_id => { isa => 'Str' }, diff --git a/lib/Lacuna/DB/Species.pm b/lib/Lacuna/DB/Species.pm index 321ce2e9..6d0ce172 100644 --- a/lib/Lacuna/DB/Species.pm +++ b/lib/Lacuna/DB/Species.pm @@ -9,10 +9,10 @@ __PACKAGE__->add_attributes( name => { isa => 'Str', trigger => sub { my ($self, $new, $old) = @_; - $self->cname(Lacuna::Util::cname($new)); + $self->name_cname(Lacuna::Util::cname($new)); } , }, - cname => { isa => 'Str' }, + name_cname => { isa => 'Str' }, description => { isa => 'Str' }, habitable_orbits => { isa => 'Int' }, construction_affinity => { isa => 'Int' }, # cost of building new stuff diff --git a/lib/Lacuna/DB/Star.pm b/lib/Lacuna/DB/Star.pm index 287a68bd..cd4cef03 100644 --- a/lib/Lacuna/DB/Star.pm +++ b/lib/Lacuna/DB/Star.pm @@ -9,10 +9,10 @@ __PACKAGE__->add_attributes( name => { isa => 'Str', trigger => sub { my ($self, $new, $old) = @_; - $self->cname(Lacuna::Util::cname($new)); + $self->name_cname(Lacuna::Util::cname($new)); }, }, - cname => { isa => 'Str' }, + name_cname => { isa => 'Str' }, is_named => { isa => 'Str', default => '0' }, date_created => { isa => 'DateTime' }, color => { isa => 'Str' }, diff --git a/lib/Lacuna/Empire.pm b/lib/Lacuna/Empire.pm index 080107ec..1e1162bd 100644 --- a/lib/Lacuna/Empire.pm +++ b/lib/Lacuna/Empire.pm @@ -20,7 +20,7 @@ sub is_name_available { return 0; } else { - my $count = $self->simpledb->domain('empire')->count(where=>{cname=>cname($name)}, consistent=>1); + my $count = $self->simpledb->domain('empire')->count(where=>{name_cname=>cname($name)}, consistent=>1); return ($count) ? 0 : 1; } } @@ -33,7 +33,7 @@ sub logout { sub login { my ($self, $name, $password) = @_; - my $empire = $self->simpledb->domain('empire')->search(where=>{cname=>cname($name)})->next; + my $empire = $self->simpledb->domain('empire')->search(where=>{name_cname=>cname($name)})->next; if (defined $empire) { if ($empire->password eq $self->encrypt_password($password)) { return { session_id => $empire->start_session->id, status => $empire->get_full_status }; diff --git a/lib/Lacuna/Inbox.pm b/lib/Lacuna/Inbox.pm index 9e7c9c46..c0468609 100644 --- a/lib/Lacuna/Inbox.pm +++ b/lib/Lacuna/Inbox.pm @@ -76,7 +76,7 @@ sub send_message { my @to; foreach my $name (split /\s*,\s*/, $recipients) { next if $name eq ''; - my $user = $self->simpledb->domain('empire')->search(where=>{cname => cname($name)})->next; + my $user = $self->simpledb->domain('empire')->search(where=>{name_cname => cname($name)})->next; if (defined $user) { push @sent, $user->name; push @to, $user; diff --git a/lib/Lacuna/Map.pm b/lib/Lacuna/Map.pm index 7c11e1a3..fcff9422 100644 --- a/lib/Lacuna/Map.pm +++ b/lib/Lacuna/Map.pm @@ -20,7 +20,7 @@ sub rename_star { ->length_lt(31) ->no_restricted_chars ->no_profanity - ->not_ok($self->simpledb->domain('star')->count(where=>{cname=>Lacuna::Util::cname($name), 'itemName()'=>['!=',$star_id]})); # name available + ->not_ok($self->simpledb->domain('star')->count(where=>{name_cname=>Lacuna::Util::cname($name), 'itemName()'=>['!=',$star_id]})); # name available my $empire = $self->get_empire_by_session($session_id); my $star = $self->simpledb->domain('star')->find($star_id); if (defined $star) { diff --git a/lib/Lacuna/Species.pm b/lib/Lacuna/Species.pm index ec133672..84a84181 100644 --- a/lib/Lacuna/Species.pm +++ b/lib/Lacuna/Species.pm @@ -15,7 +15,7 @@ sub is_name_available { return 0; } else { - my $count = $self->simpledb->domain('species')->count(where=>{cname=>cname($name)}, consistent=>1); + my $count = $self->simpledb->domain('species')->count(where=>{name_cname=>cname($name)}, consistent=>1); warn $name . " = ". $count; return ($count) ? 0 : 1; } -- 2.51.2