Skip to content

Commit

Permalink
Merge pull request #22 from lemming552/develop
Browse files Browse the repository at this point in the history
Mission Glyph Fix
  • Loading branch information
lemming552 committed Jul 17, 2012
2 parents 6ee85cb + b2a773b commit 2bb73e2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/Lacuna/DB/Result/Building/Archaeology.pm
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ sub make_plan {
$count{$type} = $self->body->use_glyph($type, $quantity);
$min_used = $count{$type} if ($min_used < $count{$type});
}
# Check if all glyphs were used
# Check if all glyphs were used in case of timing issues.
if ($min_used < $quantity) {
for my $type (@{$glyphs}) {
if ($min_used < $count{$type}) {
Expand Down
18 changes: 14 additions & 4 deletions lib/Lacuna/DB/Result/Mission.pm
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ sub add_rewards {
$body->update;

# glyphs
# Need to restructure glyphs in Missions to account for quantity
if (exists $rewards->{glyphs}) {
foreach my $glyph (@{$rewards->{glyphs}}) {
$body->add_glyph($glyph);
Expand All @@ -135,6 +136,7 @@ sub add_rewards {
}

# plans
# Need to restructure plans in Missions to account for quantity
if (exists $rewards->{plans}) {
foreach my $plan (@{$rewards->{plans}}) {
$body->add_plan($plan->{classname}, $plan->{level}, $plan->{extra_build_level});
Expand Down Expand Up @@ -166,7 +168,7 @@ sub spend_objectives {
# glyphs
if (exists $objectives->{glyphs}) {
foreach my $glyph (@{$objectives->{glyphs}}) {
$body->glyphs->search({ type => $glyph },{rows => 1})->single->delete;
$body->use_glyph( $glyph, 1);
}
}

Expand Down Expand Up @@ -239,9 +241,17 @@ sub check_objectives {
foreach my $glyph (@{$objectives->{glyphs}}) {
$glyphs{$glyph}++;
}
foreach my $glyph (keys %glyphs) {
if ($body->glyphs->search({ type => $glyph })->count < $glyphs{$glyph} ) {
confess [1013, 'You do not have enough '.$glyph.' glyphs needed to complete this mission.'];
foreach my $type (keys %glyphs) {
my $glyph = Lacuna->db->resultset('Lacuna::DB::Result::Glyph')->search({
type => $type,
body_id => $body->id,
})->single;
unless (defined($glyph)) {
confess [ 1002, "You don't have any glyphs of $type."];
}
if ($glyph->quantity < $glyphs{$type}) {
confess [ 1002,
"You don't have $glyphs{$type} glyphs of $type, you only have ".$glyph->quantity];
}
}
}
Expand Down

0 comments on commit 2bb73e2

Please sign in to comment.