From dfe788c98a2d17f211ae50ae46d7d7437a6de635 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 10 Nov 2010 11:17:03 -0600 Subject: [PATCH] various mission improvements --- bin/add_missions.pl | 29 ++++++++++++------- .../DB/Result/Building/MissionCommand.pm | 2 +- lib/Lacuna/DB/Result/Mission.pm | 1 + var/missions/a-fair-trade.mission | 2 +- var/missions/apathetic-youth.mission | 2 +- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/bin/add_missions.pl b/bin/add_missions.pl index 4fe910ee..543a2318 100644 --- a/bin/add_missions.pl +++ b/bin/add_missions.pl @@ -18,27 +18,34 @@ my $start = time; out('Finding Mission Files'); my @mission_files = get_mission_files(); -out('Loading DB'); +out('Loading DB...'); our $db = Lacuna->db; our $missions = $db->resultset('Lacuna::DB::Result::Mission'); our $news = $db->resultset('Lacuna::DB::Result::News'); -out('Adding missions'); +out('Deleting missions nobody has completed...'); +$missions->search({ + date_posted => { '<' => DateTime->now->subtract( hours => 72 )} +})->delete; + +out('Adding missions...'); my @zones = $db->resultset('Lacuna::DB::Result::Map::Body')->search( { empire_id => { '>' => 0 }}, { distinct => 1 })->get_column('zone')->all; foreach my $zone (@zones) { out($zone); if ($missions->search({zone=>$zone})->count < 51) { - my $mission = $missions->new({ - zone => $zone, - mission_file_name => $mission_files[rand @mission_files], - })->insert; - say $mission->params->get('name'); - $news->new({ - zone => $zone, - headline => $mission->params->get('network_19_headline'), - })->insert; + foreach (1..3) { + my $mission = $missions->new({ + zone => $zone, + mission_file_name => $mission_files[rand @mission_files], + })->insert; + say $mission->params->get('name'); + $news->new({ + zone => $zone, + headline => $mission->params->get('network_19_headline'), + })->insert; + } } } diff --git a/lib/Lacuna/DB/Result/Building/MissionCommand.pm b/lib/Lacuna/DB/Result/Building/MissionCommand.pm index c5e2fca6..a686d6d3 100644 --- a/lib/Lacuna/DB/Result/Building/MissionCommand.pm +++ b/lib/Lacuna/DB/Result/Building/MissionCommand.pm @@ -48,7 +48,7 @@ sub missions { return Lacuna->db->resultset('Lacuna::DB::Result::Mission')->search({ zone => $self->body->zone, },{ - order_by => 'date_posted', + order_by => ['max_university_level','date_posted'], }); } diff --git a/lib/Lacuna/DB/Result/Mission.pm b/lib/Lacuna/DB/Result/Mission.pm index a8dfabaa..36f83778 100644 --- a/lib/Lacuna/DB/Result/Mission.pm +++ b/lib/Lacuna/DB/Result/Mission.pm @@ -13,6 +13,7 @@ __PACKAGE__->add_columns( mission_file_name => { data_type => 'varchar', size => 100, is_nullable => 0 }, zone => { data_type => 'varchar', size => 16, is_nullable => 0 }, date_posted => { data_type => 'datetime', is_nullable => 0, set_on_create => 1 }, + max_university_level => { data_type => 'tinyint', is_nullable => 0 }, scratch => { data_type => 'mediumblob', is_nullable => 1, 'serializer_class' => 'JSON' }, ); diff --git a/var/missions/a-fair-trade.mission b/var/missions/a-fair-trade.mission index 06733f79..cc372ef4 100755 --- a/var/missions/a-fair-trade.mission +++ b/var/missions/a-fair-trade.mission @@ -1,2 +1,2 @@ # config-file-type: JSON 1 -{"mission_objective":{"resources":{"cider":5000,"energy":10000,"gold":10000}},"network_19_headline":"For Sale: New fighter craft, never used, great price!","mission_reward":{"ships":[{"speed":0,"hold_size":0,"type":"fighter","stealth":3}]},"network_19_completion":"Sold: figher craft to %s, details confidential.","name":"A Fair Trade","mission_type":"trade","description":"Uhm, hi. This is a little embarassing, it's personal, and I'm not sure how to explain... You see, my husband and I are pregnant with our first children, but ever since I transferred the embryos to his abdominal sac, he's been very emotional. I spent some of our resources on this cool new fighter craft, and I haven't even been able to fly it! Anyway, in the interests of marital harmony, if you'd like to take this off my hands in exchange for some gold, cider, and energy, I think I'll be able to use it to make it up to him before the babies are born. Don't ask how, I think I've given enough details already... you have no idea how grumpy a man with several dozen spawn growing inside him can be!","max_university_level":"20"} \ No newline at end of file +{"mission_objective":{"resources":{"cider":5000,"energy":10000,"gold":10000}},"network_19_headline":"For Sale: New fighter craft, never used, great price!","mission_reward":{"ships":[{"speed":0,"hold_size":0,"type":"fighter","stealth":3}]},"network_19_completion":"Sold: fighter craft to %s, details confidential.","name":"A Fair Trade","mission_type":"trade","description":"Uhm, hi. This is a little embarassing, it's personal, and I'm not sure how to explain... You see, my husband and I are pregnant with our first children, but ever since I transferred the embryos to his abdominal sac, he's been very emotional. I spent some of our resources on this cool new fighter craft, and I haven't even been able to fly it! Anyway, in the interests of marital harmony, if you'd like to take this off my hands in exchange for some gold, cider, and energy, I think I'll be able to use it to make it up to him before the babies are born. Don't ask how, I think I've given enough details already... you have no idea how grumpy a man with several dozen spawn growing inside him can be!","max_university_level":"20"} \ No newline at end of file diff --git a/var/missions/apathetic-youth.mission b/var/missions/apathetic-youth.mission index f855a166..1fe7218b 100755 --- a/var/missions/apathetic-youth.mission +++ b/var/missions/apathetic-youth.mission @@ -1,2 +1,2 @@ # config-file-type: JSON 1 -{"mission_objective":{"ships":[{"stealth":5000,"hold_size":3500,"speed":1750,"type":"dory"},{"stealth":5000,"hold_size":3500,"speed":1750,"type":"dory"}]},"max_university_level":"12","mission_reward":{"resources":{"cider":20000}},"description":"Now I enjoy a good apple cider as much as the next guy, but this young generation has totally fallen into the bottle. We finished our trade ministry just before most of us retired. It's too bad we were too busy to have too many kids until too late. Now we have got to inspire the other end of this generation gap into action! Perhaps if you send us a couple of dories they would be inspired by the prospect of expansive trade opportunities. If that doesn't work, we'll just ship you all of their cider! Then they'll have to get off of their rumps. Thanks, in advance.","network_19_headline":"Will the new generation of Cider Town fulfill their elder's dreams?","network_19_completion":"As the aging population of Cider Town worked so hard to develop their export, their kids only developed a knack for drinking it.","name":"Apathetic youth","mission_type":"trade"} \ No newline at end of file +{"network_19_completion":"As the aging population of Cider Town worked so hard to develop their export, their kids only developed a knack for drinking it.","mission_type":"trade","mission_objective":{"ships":[{"hold_size":0,"type":"dory","speed":0,"stealth":0},{"hold_size":0,"type":"dory","speed":0,"stealth":0}]},"description":"Now I enjoy a good apple cider as much as the next guy, but this young generation has totally fallen into the bottle. We finished our trade ministry just before most of us retired. It's too bad we were too busy to have too many kids until too late. Now we have got to inspire the other end of this generation gap into action! Perhaps if you send us a couple of dories they would be inspired by the prospect of expansive trade opportunities. If that doesn't work, we'll just ship you all of their cider! Then they'll have to get off of their rumps. Thanks, in advance.","mission_reward":{"resources":{"cider":20000}},"name":"Apathetic youth","network_19_headline":"Will the new generation of Cider Town fulfill their elder's dreams?","max_university_level":"12"} \ No newline at end of file -- 2.51.2