[Web+ Bubble Sort [Web+ Bubble Sort | Example Applications ]


Overview

In this exciting game of strategy, you must choose either rock, scissors, or paper. The Web+ server will do likewise. After you have both chosen, a winner is determined:
  • Rock beats Scissors;
  • Scissors beats Paper;
  • Paper beats Rock.

Web+ will use persistent variables to keep track of how well you are doing. Whenever you play, Web+ will recognize you and display the correct score.


Implementation File

File Name Type Function
RSP.WML Template

Rsp.wml

<webNoOutput>
<!---
| Description: Examples of Games using Web+.
|
| CVS History:
| $Log: rsp.wml,v $
| Revision 1.3 2006/04/04 13:43:44 vidyar
| no message
|
| Revision 1.2 2006/04/03 18:09:54 vidyar
| daily commit
|
| Revision 1.1 2006/03/29 02:34:17 vidyar
| adding files
|
| Revision 1.4 2006/03/20 16:50:42 vidyar
| daily commit
|
| Revision 1.3 2006/03/09 14:44:53 vidyar
| daily commit
|
|
|
--->
<webCall script=#application.FUNCPATH & "/geturl.wml"# destScript="rsp.wml" url=#nextURL# byref sessionID="">
<!--- generate text strings --->
<webCall script=#application.FUNCPATH & "/gettext.wml"# textString="functionality" result=#functionality# byref lang=#client.lang# langFile=#langFile#>
<webCall script=#application.FUNCPATH & "/gettext.wml"# textString="rockfirst" result=#rockfirst# byref lang=#client.lang# langFile=#langFile#>
<webCall script=#application.FUNCPATH & "/gettext.wml"# textString="scissorsfirst" result=#scissorsfirst# byref lang=#client.lang# langFile=#langFile#>
<webCall script=#application.FUNCPATH & "/gettext.wml"# textString="paperfirst" result=#paperfirst# byref lang=#client.lang# langFile=#langFile#>
</webNoOutput>

<webCall script=#application.FUNCPATH & "/gettext.wml"# textString="welcome_msg" result=#welcome_msg# byref lang=#client.lang# langFile=#langFile#>
<webInclude script=#application.SCRIPTPATH & "/template.wml"#>

Rsp-p.wml

<webSet #HeaderPageTitle# = "Web+ Game">
<webSet #HeaderBigTitle# = "Web+<sup>&##174;</sup>Game">
<webSet #dir# = "/rock">
<webSet #CGIPath# = "#path##dir#">
<webInclude Script="#path#/header.wml">
<webInclude Script="#path#/gearbox.wml">


<webClient name = "RSP">
<webSet #Choices[]# = ",Rock,Scissors,Paper">
<webSet #rsp# = "developers/examples/rock/rsp.wml?hits=#Client.HitCount#">


<webIf #not ParameterExists (Client.Wins) or ParameterExists (NewGame)#>
<!--- New game; we set wins, losses, and ties = 0 --->
<webSet #Client.Wins# = 0>
<webSet #Client.Losses# = 0>
<webSet #Client.Ties# = 0>
<webSet #NewGame# = 1>
<webElse>
<webSet #NewGame# = 0>
</webIf>

<webIf #ParameterExists (Choice)#>
<!--- Make the computer's choice --->
<webSet #ComputerChoice# = #int (10000 * rnd (4)) mod 3#>
<webPrint>
<p>You picked #Choices [Choice]#, computer picked #Choices [ComputerChoice]#...</p>
</webPrint>

<!--- Determine the winner --->
<webSet #Winner# = #(Choice - ComputerChoice + 3) mod 3#>
<webIf #Winner = 0#>
It's a tie!</p>
<webSet #Client.Ties# = #Client.Ties + 1#>
<webElseIf #Winner = 1#>
you lose.</p>
<webSet #Client.Losses# = #Client.Losses + 1#>
<webElse>
You win!</p>
<webSet #Client.Wins# = #Client.Wins + 1#>
</webIf>
<webElse>
<!--- User is not in the middle of a game; we display the welcome message --->
<webInclude script = "/developers/examples/rock/rspmsg.wml">
</webIf>

<webIf #not NewGame#>
<!--- If the user is not beginning a new game, display the standings --->
<webPrint>
<p class="textstyle"> You have won #Client.Wins# game#If (Client.Wins = 1, "", "s")#,
lost #Client.Losses#, and tied #Client.Ties#.</p>
</webPrint>

</webIf>

<!--- Draw the board --->

<webPrint>
<br/><br/>
<p class="textstyle">Make your choice:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href = "/#rsp#&Choice=0"><b>Rock</b></a> ...
<a href = "/#rsp#&Choice=1"><b>Scissors</b></a> ...
<a href = "/#rsp#&Choice=2"><b>Paper</b></a></p>

</webPrint>

<webIf #not NewGame#>
<!--- If the user is not beginning a new game, we give an option to do so --->
<webPrint>
<ul>
<li><p class="textstyle"><a href = "/#rsp#&NewGame=1">Start a new game</a></p></li>
</ul>
</webPrint>
</webIf>


 

Copyright © 2009 Webplus, Inc. (talentsoft). All Rights Reserved.
webmaster@webplus.com