My Shortie: Ray Camden's Beginner ColdFusion Contest (Monster Maker)

<!--- Kill extra output. --->
<cfsilent>
 
	<!--- Param the url variables. --->
	<cfparam
		name="URL.interaction"
		type="string"
		default=""
		/>
 
 
	<!---
		Check to see if there was a valid interation
		sent. If there was one, then store the name
		of the target CFC back into the URL.
	--->
	<cfswitch expression="#URL.interaction#">
		<cfcase value="ILoveYou">
			<cfset URL.interaction = "ILoveYou" />
		</cfcase>
		<cfcase value="SlapAround">
			<cfset URL.interaction = "SlapAround" />
		</cfcase>
		<cfcase value="Sleep">
			<cfset URL.interaction = "Sleep" />
		</cfcase>
		<cfcase value="TakeToDinner">
			<cfset URL.interaction = "TakeToDinner" />
		</cfcase>
		<cfcase value="TurnTrick">
			<cfset URL.interaction = "TurnTrick" />
		</cfcase>
 
		<!---
			This special case will Labotomize the
			shortie - thereby resetting her properties.
		--->
		<cfcase value="Labotomize">
 
			<!--- Erase memory. --->
			<cfset APPLICATION.Shortie.Labotomize() />
 
			<!--- Clear the interaction value. --->
			<cfset URL.interaction = "" />
 
		</cfcase>
		<cfdefaultcase>
			<cfset URL.interaction = "" />
		</cfdefaultcase>
	</cfswitch>
 
 
	<!---
		Check to see if we have a valid interaction
		that we can use to interact with the Shorite.
	--->
	<cfif Len( URL.interaction )>
 
		<!--- Create the interaction object. --->
		<cfset objInteraction = CreateObject(
			"component",
			URL.interaction
			).Init()
			/>
 
		<!--- Interact with the shortie. --->
		<cfset APPLICATION.Shortie.Interact(
			objInteraction
			) />
 
	</cfif>
 
 
	<!---
		ASSERT: At this point, we may or may NOT have done
		any valid interaction with the Shorite. We can,
		however, get her properties that may have been updated.
	--->
 
 
	<!---
		Now that we may or may not have interacted with the
		Shortie, adjust her internal time.
	--->
	<cfset APPLICATION.Shortie.AdjustTime() />
 
 
	<!--- Get the shorties properties. --->
	<cfset objProperties = APPLICATION.Shortie.GetProperties() />
 
 
	<!---
		Loop over the properties to format the numbers.
		Formatting numbers is easier in ColdFusion than
		it is in Javascript, so I would rather do it here,
		before we go to JSON.
	--->
	<cfloop
		item="strKey"
		collection="#objProperties#">
 
		<cfset objProperties[ strKey ] = NumberFormat(
			objProperties[ strKey ],
			"0.00"
			) />
 
	</cfloop>
 
 
	<!---
		To the existing properties, we are going to append
		some additional data values from the shortie.
	--->
 
	<!---
		This is the number of minutes that we must delay until
		the next interaction can take place.
	--->
	<cfset objProperties.Delay = DateDiff(
		"n",
		APPLICATION.Shortie.GetTime(),
		APPLICATION.Shortie.GetNextInteractionTime()
		) />
 
	<!--- Get the current time.--->
	<cfset objProperties.Time = (
		DateFormat( APPLICATION.Shortie.GetTime(), "mmm d, yyyy" ) &
		" | " &
		TimeFormat( APPLICATION.Shortie.GetTime(), "h:mm TT" )
		) />
 
 
 
	<!--- Return the Shortie properties as JSON data. --->
	<cfcontent
		type="text/plain"
		variable="#ToBinary( ToBase64( APPLICATION.UDFLib.CFToJSON( objProperties ) ) )#"
		/>
 
</cfsilent>

For Cut-and-Paste