From 4a9cc5bddc03393898650e402582b38b163e8dbf Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 9 Sep 2010 12:13:51 -0500 Subject: [PATCH] automated the tutorial process so you don't need to reply --- lib/Lacuna/DB/Result/Building.pm | 3 +++ lib/Lacuna/DB/Result/Empire.pm | 3 +++ lib/Lacuna/DB/Result/Spies.pm | 3 +++ lib/Lacuna/RPC/Body.pm | 3 +++ lib/Lacuna/RPC/Empire.pm | 6 ++++++ lib/Lacuna/RPC/Inbox.pm | 2 +- lib/Lacuna/Tutorial.pm | 8 +++++--- var/messages/tutorial/counter_spy.txt | 2 +- var/messages/tutorial/drinking_water.txt | 2 +- var/messages/tutorial/energy.txt | 4 +--- var/messages/tutorial/essentia.txt | 4 ++-- var/messages/tutorial/explore.txt | 2 -- var/messages/tutorial/fool.txt | 4 ++-- var/messages/tutorial/get_food.txt | 4 +--- var/messages/tutorial/keep_the_lights_on.txt | 2 +- var/messages/tutorial/mine.txt | 2 -- var/messages/tutorial/more_resources.txt | 2 -- var/messages/tutorial/news.txt | 2 +- var/messages/tutorial/observatory.txt | 5 ++++- var/messages/tutorial/pawn.txt | 4 ++-- var/messages/tutorial/rogue.txt | 2 -- var/messages/tutorial/shipyard.txt | 2 +- var/messages/tutorial/storage.txt | 4 +--- var/messages/tutorial/the_300.txt | 4 ++-- var/messages/tutorial/university.txt | 2 +- var/messages/welcome.txt | 4 ++-- 26 files changed, 47 insertions(+), 38 deletions(-) diff --git a/lib/Lacuna/DB/Result/Building.pm b/lib/Lacuna/DB/Result/Building.pm index 75c0b53c..1100ed11 100644 --- a/lib/Lacuna/DB/Result/Building.pm +++ b/lib/Lacuna/DB/Result/Building.pm @@ -817,6 +817,9 @@ sub finish_upgrade { my %levels = (5=>'a quiet',10=>'an extravagant',15=>'a lavish',20=>'a magnificent',25=>'a historic',30=>'an epic',35=>'a miraculous',40=>'a magical'); $self->body->add_news($self->level*5,"In %s ceremony, %s unveiled its newly augmentented %s.", $levels{$self->level}, $empire->name, $self->name); } + if ($empire->tutorial_stage ne 'turing') { + Lacuna::Tutorial->new(empire=>$empire)->finish; + } } diff --git a/lib/Lacuna/DB/Result/Empire.pm b/lib/Lacuna/DB/Result/Empire.pm index 0c437b5a..7bf4310a 100644 --- a/lib/Lacuna/DB/Result/Empire.pm +++ b/lib/Lacuna/DB/Result/Empire.pm @@ -458,6 +458,9 @@ sub add_probe { } $self->clear_probed_stars; + if ($self->tutorial_stage ne 'turing') { + Lacuna::Tutorial->new(empire=>$self)->finish; + } return $self; } diff --git a/lib/Lacuna/DB/Result/Spies.pm b/lib/Lacuna/DB/Result/Spies.pm index 73fee3a5..1935a2c5 100644 --- a/lib/Lacuna/DB/Result/Spies.pm +++ b/lib/Lacuna/DB/Result/Spies.pm @@ -205,6 +205,9 @@ sub assign { # run mission if ($assignment ~~ ['Idle','Counter Espionage']) { $self->update; + if ($self->empire->tutorial_stage ne 'turing') { + Lacuna::Tutorial->new(empire=>$self->empire)->finish; + } return {result => 'Accepted', reason => random_element(['I am ready to serve.','I\'m on it.','Consider it done.','Will do.','Yes.'])}; } else { diff --git a/lib/Lacuna/RPC/Body.pm b/lib/Lacuna/RPC/Body.pm index 7628c40f..5642d71b 100644 --- a/lib/Lacuna/RPC/Body.pm +++ b/lib/Lacuna/RPC/Body.pm @@ -47,6 +47,9 @@ sub rename { $body->add_news(200,"In a bold move to show its growing power, %s renamed %s to %s.",$empire->name, $body->name, $name); } $body->update({name => $name}); + if ($empire->tutorial_stage ne 'turing') { + Lacuna::Tutorial->new(empire=>$empire)->finish; + } return 1; } diff --git a/lib/Lacuna/RPC/Empire.pm b/lib/Lacuna/RPC/Empire.pm index 53a02241..8fdd6563 100644 --- a/lib/Lacuna/RPC/Empire.pm +++ b/lib/Lacuna/RPC/Empire.pm @@ -293,6 +293,9 @@ sub edit_profile { ->no_restricted_chars ->no_profanity; $empire->description($profile->{description}); + if ($empire->tutorial_stage ne 'turing') { + Lacuna::Tutorial->new(empire=>$empire)->finish; + } } if (exists $profile->{notes}) { Lacuna::Verify->new(content=>\$profile->{notes}, throws=>[1005,'Notes must be less than 1024 characters and cannot contain special characters or profanity.', 'notes']) @@ -475,6 +478,9 @@ sub boost { $empire->planets->update({needs_recalc=>1}); $empire->$type($start); $empire->update; + if ($empire->tutorial_stage ne 'turing') { + Lacuna::Tutorial->new(empire=>$empire)->finish; + } return { status => $self->format_status($empire), $type => format_date($empire->$type), diff --git a/lib/Lacuna/RPC/Inbox.pm b/lib/Lacuna/RPC/Inbox.pm index 2ddd1351..5fd0cc01 100644 --- a/lib/Lacuna/RPC/Inbox.pm +++ b/lib/Lacuna/RPC/Inbox.pm @@ -118,7 +118,7 @@ sub send_message { } foreach my $to (@to) { if ($to->id == 1) { - Lacuna::Tutorial->new(empire=>$empire)->finish; + Lacuna::Tutorial->new(empire=>$empire)->finish(1); } else { $to->send_message( diff --git a/lib/Lacuna/Tutorial.pm b/lib/Lacuna/Tutorial.pm index 29776a5d..7aabb691 100644 --- a/lib/Lacuna/Tutorial.pm +++ b/lib/Lacuna/Tutorial.pm @@ -9,13 +9,15 @@ has empire => ( ); sub finish { - my ($self) = @_; + my ($self, $reply) = @_; my $method = $self->empire->tutorial_stage; if (my $can = $self->can($method)) { # safely call my $out = $can->($self, 1); if (ref $out eq 'HASH') { # not finished - $out->{body_prefix} = "It doesn't look like you've completed my last request yet. Complete that first and then email me again. What I said was:\n\n"; - $self->send($out); + if ($reply) { + $out->{body_prefix} = "It doesn't look like you've completed my last request yet, complete that first. What I said was:\n\n"; + $self->send($out); + } return 0; } return 1; diff --git a/var/messages/tutorial/counter_spy.txt b/var/messages/tutorial/counter_spy.txt index 453a8d6e..67f1fc60 100644 --- a/var/messages/tutorial/counter_spy.txt +++ b/var/messages/tutorial/counter_spy.txt @@ -6,7 +6,7 @@ I'm unsure how much longer I can keep helping you. Unfortunately, I believe they Regards, -Tou Re Ell (I'm evil, you just don't know it yet!) +Not Tou Re Ell (I'm evil, you just don't know it yet!) Lacuna Expanse Corp Task: Train another spy and assign them duties. diff --git a/var/messages/tutorial/drinking_water.txt b/var/messages/tutorial/drinking_water.txt index 533b2a37..67c871e4 100644 --- a/var/messages/tutorial/drinking_water.txt +++ b/var/messages/tutorial/drinking_water.txt @@ -6,7 +6,7 @@ We will talk more about resource storage soon, but for now we should use some of I see that your planet has a good supply of about %s%% fresh water. Build a Water Purification Plant. It will produce the water needed to keep your empire on the upward trend and give your citizens something to drink with all that delicious Malcud Fungus from your new farm. -Feel free to build anything else you think you might need. For now don't worry about depleting your resources. We will ensure you have everything you need as you need it. Reply to me once you have finished this task. +Feel free to build anything else you think you might need. For now don't worry about depleting your resources. We will ensure you have everything you need as you need it. Regards, diff --git a/var/messages/tutorial/energy.txt b/var/messages/tutorial/energy.txt index cdb70ac7..ffbaf4d7 100644 --- a/var/messages/tutorial/energy.txt +++ b/var/messages/tutorial/energy.txt @@ -2,11 +2,9 @@ Need More Power ~~~ Well done. I'm sure you'll appreciate the free expansion I've given so you can upgrade your Food Reserve to store all the extra food you're producing. You should do the same for your energy output. Upgrade it so that you're producing %s per hour. -As you've done in the past, reply to me so I know you're making the progress I'd expect. - Regards, -Tou Re Ell (if he only knew what mailing lists I've signed him up for) +Not Tou Re Ell (if he only knew what mailing lists I've signed him up for) Lacuna Expanse Corp Task: Build energy to %s per hour. diff --git a/var/messages/tutorial/essentia.txt b/var/messages/tutorial/essentia.txt index 16b7a8e5..70eb3b74 100644 --- a/var/messages/tutorial/essentia.txt +++ b/var/messages/tutorial/essentia.txt @@ -4,11 +4,11 @@ You may remember I told you that the entire Lacunan economy depends upon Essenti Essentia is both rare and powerful. Our entire race spends their waking hours trying to acquire more. If you have it, you're the most powerful species in the Expanse. Essentia has rare properties that allow plants to grow more hearty and machinery to work more efficiently. It can even be used in various chemical processes to transform one element into another. It's the closest thing I've seen to magic. -Spend some of the Essentia I've given you to boost your production of water, energy, food, and ore. Once you've done this reply to me. +Spend some of the Essentia I've given you to boost your production of water, energy, food, and ore. Regards, -Tou Re Ell (TRE in TLE working for LEC, and that's enough initials for me! Hey that rhymes!) +Not Tou Re Ell (TRE in TLE working for LEC, and that's enough initials for me! Hey that rhymes!) Lacuna Expanse Corp Task: Spend some essentia to boost your production of water, energy, food, and ore. diff --git a/var/messages/tutorial/explore.txt b/var/messages/tutorial/explore.txt index 21e1a528..a02c6b24 100644 --- a/var/messages/tutorial/explore.txt +++ b/var/messages/tutorial/explore.txt @@ -4,8 +4,6 @@ Probes are an excellent way for you to explore the surrounding star systems. You Send out the probe we gave you so you can see what or who may be nearby. -Continue to keep me updated on your progress. - Regards, Tou Re Ell diff --git a/var/messages/tutorial/fool.txt b/var/messages/tutorial/fool.txt index e042e88d..36067cdd 100644 --- a/var/messages/tutorial/fool.txt +++ b/var/messages/tutorial/fool.txt @@ -6,11 +6,11 @@ If you're ever going to stand up against Lacuna Expanse Corp you'll need some he You've got a nice start to your infrastructure, but you really need to start building it up a bit. Without a steady income of your basic resources your empire's growth will slow to a crawl. Build up your food income so that it's at least %s per hour. -Reply to me when that's done. I'm not against "gifts" to forward my cause, and it certainly appears you're not against receiving them to forward your empire, so I'll have a present waiting for you *if* you can complete this task. +I'm not against "gifts" to forward my cause, and it certainly appears you're not against receiving them to forward your empire, so I'll have a present waiting for you *if* you can complete this task. Regards, -Tou Re Ell (or at least his stolen email account) +Not Tou Re Ell (or at least his stolen email account) Lacuna Expanse Corp Task: Build to %s food per hour. diff --git a/var/messages/tutorial/get_food.txt b/var/messages/tutorial/get_food.txt index c0074b8d..81ea7c57 100644 --- a/var/messages/tutorial/get_food.txt +++ b/var/messages/tutorial/get_food.txt @@ -4,12 +4,10 @@ I am delighted that you've chosen to use my vast knowledge of the Expanse to you Resources are the key to expanding your empire. Without them, your species will perish. The most vital of all the resources is food. You'll want to gather more food right away. Not every planet has the right climate to create every type of food so you'll have to use what's available to you. -As a token of our lasting friendship, the Lacuna Expanse Corp has sent emissaries to your world to build a free Malcud Fungus Farm for your people. This particular source of food is one of our favorites as it is cheap to build and does not promote waste. Don't worry if you already have one of these, you can always benefit from more of them. +As a token of our lasting friendship, Lacuna Expanse Corp has sent emissaries to your world to build a free Malcud Fungus Farm for your people. This particular source of food is one of our favorites as it is cheap to build and does not promote waste. Don't worry if you already have one of these, you can always benefit from more of them. To build, click or tap the 'build' icon in an empty space. Then choose the Malcud Fungus Farm from the available list. -Reply to me when you have completed the building. - Regards, Tou Re Ell diff --git a/var/messages/tutorial/keep_the_lights_on.txt b/var/messages/tutorial/keep_the_lights_on.txt index 4c158d6f..9a3cddf7 100644 --- a/var/messages/tutorial/keep_the_lights_on.txt +++ b/var/messages/tutorial/keep_the_lights_on.txt @@ -2,7 +2,7 @@ Keep The Lights On ~~~ You're doing well. Next we need to make sure we can "keep the lights on". I've sent some resources to you so you can build a Geo Energy Plant. This will provide you with the energy needed to power your economy. There are several types of energy plants that will be available to you as your knowledge grows. Each type has drawbacks and benefits, but for a fledgling empire like yours, it's good just to get the juice moving. -Reply to me when you've got that built, and don't worry if you've already built one. You can always use more power. +Don't worry if you've already built one. You can always use more power. Regards, diff --git a/var/messages/tutorial/mine.txt b/var/messages/tutorial/mine.txt index 3ae968f0..3e8db18e 100644 --- a/var/messages/tutorial/mine.txt +++ b/var/messages/tutorial/mine.txt @@ -6,8 +6,6 @@ As long as your empire remains limited to this planet your citizens will never b Now we need to get you gathering some of the precious minerals on your planet. Once that's completed you'll be harvesting all the main resources you need to expand your empire to the farthest reaches of the Expanse. Build yourself a Mine so that you can begin harvesting the ore that this planet has to offer. -As always, reply to me when you're done. - Regards, Tou Re Ell diff --git a/var/messages/tutorial/more_resources.txt b/var/messages/tutorial/more_resources.txt index 41469018..5ea2d2ae 100644 --- a/var/messages/tutorial/more_resources.txt +++ b/var/messages/tutorial/more_resources.txt @@ -4,8 +4,6 @@ You're doing well, but we're going to need a lot more resource production than t If you can get your production to more than 100 of each resource (ore, water, food, and energy) per hour, then we'll be in a good position to do other more interesting things. Build more farms, mines, water purification plants, and energy plants to get your resource production going. -As always, reply to me when you're done. - Regards, Tou Re Ell diff --git a/var/messages/tutorial/news.txt b/var/messages/tutorial/news.txt index e9d83398..1774d205 100644 --- a/var/messages/tutorial/news.txt +++ b/var/messages/tutorial/news.txt @@ -8,7 +8,7 @@ I'll see if I can get you some resources to help you build it. Unfortunately the Regards, -Tou Re Ell (2+2=3 and Pi is for eating) +Not Tou Re Ell (2+2=3 and Pi is for eating) Lacuna Expanse Corp Task: Build a Network 19 Affiliate. diff --git a/var/messages/tutorial/observatory.txt b/var/messages/tutorial/observatory.txt index 79e89e98..b64cebee 100644 --- a/var/messages/tutorial/observatory.txt +++ b/var/messages/tutorial/observatory.txt @@ -6,7 +6,10 @@ By the way, we finally caught the traitor who has been interrupting our conversa Now where were we? Oh yes, now I remember. There's very little left for me to teach you, but before I leave you to tend to your empire, there is one more thing that you should know. In order to explore the Expanse you need to start producing probes, and in order to do that you'll need to build an Observatory. This shouldn't be too difficult a task for you given your rate of expansion, but it's a necessary step. -As usual reply when you've completed this. +Regards, + +Tou Re Ell +Lacuna Expanse Corp Task: Build an Observatory. Reward: A probe. diff --git a/var/messages/tutorial/pawn.txt b/var/messages/tutorial/pawn.txt index 826d78db..e827cec6 100644 --- a/var/messages/tutorial/pawn.txt +++ b/var/messages/tutorial/pawn.txt @@ -4,11 +4,11 @@ Couldn't Tou Re Ell pick a more original password than his pet Beeldeban's name? Do you command your own empire or are you just Tou Re Ell's pawn? You're playing with fire you know. I guess it's up to you, but I can help you so that you don't have worry about him or his overlords at Lacuna Expanse Corp. You'll need to build something first. The Intelligence Ministry will be almost as important as your resources. Without it other empires will be able to steal your hard earned resources and technologies, and who knows what else! -Reply to me when it's done. I'd hate to see you fall prey to further advances from Tou Re Ell. +I'd hate to see you fall prey to further advances from Tou Re Ell. Regards, -Tou Re Ell (I wonder if he was called "towel" when he was a child?) +Not Tou Re Ell (I wonder if he was called "towel" when he was a child?) Lacuna Expanse Corp Task: Build the Intelligence Ministry. diff --git a/var/messages/tutorial/rogue.txt b/var/messages/tutorial/rogue.txt index 90da35b2..1931d925 100644 --- a/var/messages/tutorial/rogue.txt +++ b/var/messages/tutorial/rogue.txt @@ -4,8 +4,6 @@ It seems you've been busy. We realize you've been cooperating with someone else In the meantime you've done a nice job continuing to build your empire. You'll soon be in contact with other empires in the Expanse. You should make sure that they know who you are and what you stand for. Describe your empire in the Description field of your profile so other empires know what they can expect from you. Also feel free to update your status if you want to keep everyone up to date with what you're up to. -As always keep us apprised of your status with this task by responding to this message. - Regards, Tou Re Ell diff --git a/var/messages/tutorial/shipyard.txt b/var/messages/tutorial/shipyard.txt index 845dba62..d46e26c0 100644 --- a/var/messages/tutorial/shipyard.txt +++ b/var/messages/tutorial/shipyard.txt @@ -2,7 +2,7 @@ Shipyard ~~~ Now that you've got the Space Port you can start on the Shipyard. Your Shipyard will allow you to build ships so that you can explore the Expanse and even colonize other planets. Build the Shipyard now and we'll soon have you scouring the galaxy for more resources. -Reply to me when your Shipyard is ready and I'll tell you what else needs to be done. I've just sent some more resources to you. They should arrive by the time your Shipyard is complete. +I've just sent some more resources to you. They should arrive by the time your Shipyard is complete. Regards, diff --git a/var/messages/tutorial/storage.txt b/var/messages/tutorial/storage.txt index e836e023..a3252c77 100644 --- a/var/messages/tutorial/storage.txt +++ b/var/messages/tutorial/storage.txt @@ -6,12 +6,10 @@ Click or tap your Planetary Command Center. You should see how many of each reso In order to prevent resource loss, build Ore Storage Tanks, a Food Reserve, an Energy Reserve, and Water Storage Tanks. -Reply to me when you're done. I've got a gift for you. - Regards, Tou Re Ell Lacuna Expanse Corp Task: Build Ore Storage Tank, Food Reserve, Energy Reserve, and Water Storage Tanks. -Reward: 100 of each resource. +Reward: Free resources. diff --git a/var/messages/tutorial/the_300.txt b/var/messages/tutorial/the_300.txt index 7f999f6d..7b54bd34 100644 --- a/var/messages/tutorial/the_300.txt +++ b/var/messages/tutorial/the_300.txt @@ -2,11 +2,11 @@ Almost There ~~~ I've given you the necessary resources to allow you to upgrade your Energy Reserve to level 2, so you should do that right away. As you've probably guessed you'll need to upgrade your water and ore production one more time each. -Reply to me when you're done. I'll give you the resources to upgrade your storage for both of those to level 2 as well. +I'll give you the resources to upgrade your storage for both of those to level 2 as well when you're done. Regards, -Tou Re Ell (I wonder if he uses the same password for his financial accounts?) +Not Tou Re Ell (I wonder if he uses the same password for his financial accounts?) Lacuna Expanse Corp Task: Build more water and ore production. diff --git a/var/messages/tutorial/university.txt b/var/messages/tutorial/university.txt index eabf20c7..cee1ec13 100644 --- a/var/messages/tutorial/university.txt +++ b/var/messages/tutorial/university.txt @@ -4,7 +4,7 @@ Excellent work! Now you're collecting all the precious resources we need to keep The University is key for your continued expansion. Without it you won't be able to gain the knowledge necessary to expand your empire. Build a University so your scholars have a place to study. No building in your empire can ever be more than one level higher than your University, so make sure you keep upgrading it as needed. -Once you've done that reply to me. You're doing well so far, keep up the good work. Before long %s will be a powerful empire. +You're doing well so far, keep up the good work. Before long %s will be a powerful empire. Regards, diff --git a/var/messages/welcome.txt b/var/messages/welcome.txt index d4826d26..10d27751 100644 --- a/var/messages/welcome.txt +++ b/var/messages/welcome.txt @@ -4,12 +4,12 @@ Allow me to introduce myself. I am Tou Re Ell, diplomat for the Lacuna Expanse C Since you are new I'd like to offer you an arrangment to help get your empire started. In return for completing some simple tasks, I will assist you in building the necessary components to ensure your survival. -Your first task is to gather some information for me about your star system. Locate your planet in the star map and rename it. When you have completed this task, send me a message by replying to this one. Your reply will serve as an indication that you want my help. +I'll assume you want my help. If that's true, your first task is to gather some information for me about your star system. Locate your planet in the star map and rename it. Regards, Tou Re Ell Lacuna Expanse Corp -Task: Rename your planet and reply to this message. +Task: Rename your planet. Reward: A free building. -- 2.51.2