| Category: | Fun Stuff |
| Author/Contact Info | /msg sulfericacid |
| Description: | I am an avid player of www.neopets.com and I know a lot of people keep asking what events happen at what times so I designed a script to count down to key events that happen throughout the course of the day. The script tracks three events (snowager, jobs and the new day). I doubt many of you would have much interest in this script but who knows, maybe some of you play on that site too. From this script I learned: Calculate time between times and operations. Problems: I know there is a lot of repetitive code but it's the best I could do. |
#!/usr/bin/perl
use warnings;
use strict;
use CGI qw(:standard);
print header, start_html;
print "<center><H2>Important Neopets Times</H2></center>";
print "<br>";
my ($sec, $min, $hour) = localtime(time);
print "The current server time is $hour:$min:$sec";
print "<table>";
print "<tr>";
#
# Job time
#
print qq(<td width="15" bgcolor="gray">);
print "Jobs";
print "</td>";
print "<td>";
if ($min <= 10) {
my $newjobtime;
$newjobtime = 10 - $min;
print "There are <font color=blue>$newjobtime</font> minute(s) until j
+obs are replenished.";
print qq( <a href="http://www.neopets.com/faerieland/employ/employm
+ent.phtml" target="new">get a job!);
}
elsif ($min <= 20) {
my $newjobtime;
$newjobtime = 20 - $min;
print "There are <font color=blue>$newjobtime</font> minute(s) until j
+obs are replenished.";
print qq( <a href="http://www.neopets.com/faerieland/employ/employm
+ent.phtml" target="new">get a job!</a>);
}
elsif ($min <= 30) {
my $newjobtime;
$newjobtime = 30 - $min;
print "There are <font color=blue>$newjobtime</font> minute(s) until j
+obs are replenished.";
print qq( <a href="http://www
+.neopets.com/faerieland/employ/employment.phtml" target="new">get a j
+ob!</a>);
}
elsif ($min <= 40) {
my $newjobtime;
$newjobtime = 40 - $min;
print "There are <font color=blue>$newjobtime</font> minute(s) until j
+obs are replenished.";
print qq( <a href="http://www.neopets.com/faerieland/employ/employm
+ent.phtml" target="new">get a job!</a>);
}
elsif ($min <= 50) {
my $newjobtime;
$newjobtime = 50 - $min;
print "There are <font color=blue>$newjobtime</font> minute(s) until j
+obs are replenished.";
print qq( <a href="http://www.neopets.com/faerieland/employ/employm
+ent.phtml" target="new">get a job!</a>);
}
elsif ($min <= 60) {
my $newjobtime;
$newjobtime = 60 - $min;
print "There are <font color=blue>$newjobtime</font> minute(s) until j
+obs are replenished.";
print qq( <a href="http://www.neopets.com/faerieland/employ/employm
+ent.phtml" target="new">get a job!</a>);
}
print "</td>";
print "</tr>";
print "<tr>";
#
# Snowager Time
#
print qq(<td width="15" bgcolor="gray">);
print "Snowager";
print "</td>";
print "<td>";
my ($sec1, $min1, $hour1) = localtime(time);
if ($hour1 = 1) {
print qq(<font color=blue>The snowager is sleeping!</font>
+ &nb
+sp;
+ <a href="http://www.neopet
+s.com/winter/snowager2.phtml" location="new">steal your keep!</a>);
}
elsif ($hour1 >= 1 && $hour1 > 9) {
my $snowagertime;
my $snowagertime2;
$snowagertime = 9 - $hour1;
$snowagertime2 = 60 - $min1;
print "There are $snowagertime hours(s) and $snowagertime2 minute(s) l
+eft until he awakens!";
}
elsif ($hour1 = 9) {
print qq(<font color=blue>The snowager is sleeping!</font>
+ <a href="http://www.neopets.com/winter/snowa
+ger2.phtml" location="new">Steal your keep!</a>);
}
elsif ($hour1 > 9 && $hour1 < 17) {
my $snowagertime;
my $snowagertime2;
$snowagertime = 9 - $hour1;
$snowagertime2 = 60 - $min1;
print "There are $snowagertime hours(s) and $snowagertime2 minute(s) l
+eft until he awakens!";
}
elsif ($hour1 = 17) {
print qq(<font color=blue>The snowager is sleeping!</font>
+ <a href="http://www.neopets.com/winter/snowa
+ger2.phtml" location="new">Steal your keep!</a>);
}
elsif ($hour1 > 17 && $hour1 < 24) {
my $snowagertime;
my $snowagertime2;
$snowagertime = 24 - $hour1;
$snowagertime2 = 60 - $min1; # calculate minutes to make hours match u
+p
print "There are $snowagertime hours(s) and $snowagertime2 minute(s) l
+eft until he awakens!";
}
elsif ($hour1 >= 24 && $hour > 1) {
print qq(<font color=blue>The snowager is sleeping!</font>
+ <a href="http://www.neopets.com/winter/snowa
+ger2.phtml" location="new">Steal your keep!</a>);}
print "</td>";
print "</tr>";
print "<tr>";
print qq(<td witdh="20" bgcolor="gray">);
print "New Day";
print "</td><td>";
my ($sec2, $min2, $hour2) = localtime(time);
if ($hour2 < 2) {
my $newday;
my $newday2;
$newday = 2 - $hour2;
$newday2 = 60 - $min2;
print "There are $newday hour(s) and $newday2 minute(s) until the new
+day.";
print "</td>";
print "</tr>";
print "</table>";
print end_html;
}
elsif ($hour2 >= 2) {
my $newday;
my $newday2;
$newday = 24 - $hour2;
$newday2 = 60 - $min2;
print "There are $newday hour(s) and $newday2 minute(s) until the new
+day.";
print "</td>";
print "</tr>";
print "</table>";
print end_html;
}
|
|
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Neopets Times
by TVSET (Chaplain) on Jun 05, 2003 at 09:49 UTC | |
|
Re: Neopets Times (program repair shop)
by Aristotle (Chancellor) on Jun 06, 2003 at 23:01 UTC |