changeset 37:81e7cfcc36b9

No longer showing spent ?0 minutes? when you spent less than 59 seconds at the mailbox. When you only opened a single mail, the summary will show ?from time mail? rather than ?from these mails?.
author Zerotorescue
date Sat, 11 Sep 2010 01:37:13 +0200
parents a918ec27126f
children 5dd069184eb9
files Modules/Collected.lua
diffstat 1 files changed, 48 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/Modules/Collected.lua	Sat Sep 11 00:17:31 2010 +0200
+++ b/Modules/Collected.lua	Sat Sep 11 01:37:13 2010 +0200
@@ -235,21 +235,40 @@
 	if mailOpened and mailOpened > 0 then
 		-- Time Spent
 		if timeSpent and timeSpent > 0 then
-			printMessage = printMessage .. format("Collected a total of %d mails within %d minutes and %d seconds. ", mailOpened, floor( timeSpent / 60 ), ( timeSpent % 60 ));
+			local timeSpentMinutes = floor( timeSpent / 60 );
+			local timeSpentSeconds = ( timeSpent % 60 );
+			if timeSpentMinutes ~= 0 then
+				printMessage = printMessage .. format("Collected a total of %d mails within %d minutes and %d seconds. ", mailOpened, timeSpentMinutes, timeSpentSeconds);
+			else
+				printMessage = printMessage .. format("Collected a total of %d mails within %d seconds. ", mailOpened, timeSpentSeconds);
+			end
 		else
 			printMessage = printMessage .. format("Collected a total of %d mails. ", mailOpened);
 		end
 	elseif timeSpent and timeSpent > 0 then
-		printMessage = printMessage .. format("Spent %d minutes and %d seconds collecting mail. ", floor( timeSpent / 60 ), ( timeSpent % 60 ));
+		local timeSpentMinutes = floor( timeSpent / 60 );
+		local timeSpentSeconds = ( timeSpent % 60 );
+		if timeSpentMinutes ~= 0 then
+			printMessage = printMessage .. format("Spent %d minutes and %d seconds collecting mail. ", mailOpened, timeSpentMinutes, timeSpentSeconds);
+		else
+			printMessage = printMessage .. format("Spent %d seconds collecting mail. ", mailOpened, timeSpentSeconds);
+		end
+	end
+		
+	local mailsPrefix = "";
+	if mailOpened == 1 then
+		mailsPrefix = "From this mail";
+	else
+		mailsPrefix = "From these mails";
 	end
 	
 	-- Did we record any items or gold being looted?
 	if (itemsGained and itemsGained > 0) and (earned and earned > 0) then
-		printMessage = printMessage .. format("From these mails you gained %d items and %s.", itemsGained, MailOpener:FormatMoney(earned));
+		printMessage = printMessage .. format("%s you gained %d items and %s.", mailsPrefix, itemsGained, MailOpener:FormatMoney(earned));
 	elseif itemsGained and itemsGained > 0 then
-		printMessage = printMessage .. format("From these mails you gained %d items.", itemsGained);
+		printMessage = printMessage .. format("%s you gained %d items.", mailsPrefix, itemsGained);
 	elseif earned and earned > 0 then
-		printMessage = printMessage .. format("From these mails you gained %s.", MailOpener:FormatMoney(earned));
+		printMessage = printMessage .. format("%s you gained %s.", mailsPrefix, MailOpener:FormatMoney(earned));
 	end
 	
 	-- Did we record anything? print that!
@@ -265,21 +284,40 @@
 		if sessionMailOpened and sessionMailOpened > 0 then
 			-- Time Spent
 			if sessionTimeSpent and sessionTimeSpent > 0 then
-				printMessage = printMessage .. format("Collected a total of %d mails within %d minutes and %d seconds this session. ", sessionMailOpened, floor( sessionTimeSpent / 60 ), ( sessionTimeSpent % 60 ));
+				local timeSpentMinutes = floor( sessionTimeSpent / 60 );
+				local timeSpentSeconds = ( sessionTimeSpent % 60 );
+				if timeSpentMinutes ~= 0 then
+					printMessage = printMessage .. format("Collected a total of %d mails within %d minutes and %d seconds this session. ", mailOpened, timeSpentMinutes, timeSpentSeconds);
+				else
+					printMessage = printMessage .. format("Collected a total of %d mails within %d seconds this session. ", mailOpened, timeSpentSeconds);
+				end
 			else
 				printMessage = printMessage .. format("Collected a total of %d mails this session. ", sessionMailOpened);
 			end
 		elseif sessionTimeSpent then
-			printMessage = printMessage .. format("Spent %d minutes and %d seconds collecting mail this session. ", floor( sessionTimeSpent / 60 ), ( sessionTimeSpent % 60 ));
+			local timeSpentMinutes = floor( sessionTimeSpent / 60 );
+			local timeSpentSeconds = ( sessionTimeSpent % 60 );
+			if timeSpentMinutes ~= 0 then
+				printMessage = printMessage .. format("Spent %d minutes and %d seconds collecting mail this session. ", mailOpened, timeSpentMinutes, timeSpentSeconds);
+			else
+				printMessage = printMessage .. format("Spent %d seconds collecting mail this session. ", mailOpened, timeSpentSeconds);
+			end
+		end
+		
+		local mailsPrefix = "";
+		if sessionMailOpened == 1 then
+			mailsPrefix = "From this mail";
+		else
+			mailsPrefix = "From these mails";
 		end
 		
 		-- Did we record any items or gold being looted?
 		if (sessionItemsgained and sessionItemsgained > 0) and (sessionEarned and sessionEarned > 0) then
-			printMessage = printMessage .. format("From these mails you gained %d items and %s.", sessionItemsgained, MailOpener:FormatMoney(sessionEarned));
+			printMessage = printMessage .. format("%s you gained %d items and %s.", mailsPrefix, sessionItemsgained, MailOpener:FormatMoney(sessionEarned));
 		elseif sessionItemsgained and sessionItemsgained > 0 then
-			printMessage = printMessage .. format("From these mails you gained %d items.", sessionItemsgained);
+			printMessage = printMessage .. format("%s you gained %d items.", mailsPrefix, sessionItemsgained);
 		elseif sessionEarned and sessionEarned > 0 then
-			printMessage = printMessage .. format("From these mails you gained %s.", MailOpener:FormatMoney(sessionEarned));
+			printMessage = printMessage .. format("%s you gained %s.", mailsPrefix, MailOpener:FormatMoney(sessionEarned));
 		end
 	
 		-- Did we record anything? print that!