Rock, Paper, Scissors Game by HK

HegemonKhan
here's a simple "rock, paper, scissors" game that I made for fun (and a test of my basic coding ability, lol), and you can enjoy it too (or if you're noobie to beginning at coding like me, you can also study it):

<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Rock, Paper, and Scissors Game">
<gameid>14940bcf-bfa0-45ad-8c7c-4ec787b5586b</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<attr name="game_quantity_that_you_want_to_play" type="int">0</attr>
<attr name="games_count_integer" type="int">0</attr>
<attr name="wins_count_integer" type="int">0</attr>
<attr name="losses_count_integer" type="int">0</attr>
<attr name="draws_count_integer" type="int">0</attr>
<attr name="comp_choice_integer" type="int">0</attr>
<attr name="your_choice_integer" type="int">0</attr>
<statusattributes type="stringdictionary">
<item>
<key>games_count_integer</key>
<value>Games: !</value>
</item>
<item>
<key>wins_count_integer</key>
<value>Wins: !</value>
</item>
<item>
<key>losses_count_integer</key>
<value>Losses: !</value>
</item>
<item>
<key>draws_count_integer</key>
<value>Draws: !</value>
</item>
</statusattributes>
<your_choice_conversion_string_dictionary type="stringdictionary">
<item>
<key>1</key>
<value>"rock"</value>
</item>
<item>
<key>2</key>
<value>"paper"</value>
</item>
<item>
<key>3</key>
<value>"scissors"</value>
</item>
</your_choice_conversion_string_dictionary>
<start type="script">
msg ("Welcome to my 'Rock, Paper, and Scissors Game' game. I hope you enjoy it!")
msg ("")
msg ("Click on the blue hypertext link 'continue', seen just below this line, or just hit the enter key, to play this game of mine.")
msg ("")
wait {
msg ("How many games would you like to play?")
msg ("")
msg ("Type in a number for the amount of games you'd like to play, please")
msg ("")
get input {
game.game_quantity_that_you_want_to_play = ToInt (result)
msg ("Click on the blue hypertext link 'continue', seen just below this line, or just hit the enter key, to begin this game of mine.")
msg ("")
wait {
rock_paper_scissors_function
}
}
}
</start>
<author>HegemonKhan</author>
<autodescription type="boolean">false</autodescription>
<showdescriptiononenter type="boolean">false</showdescriptiononenter>
<category>Simulation</category>
</game>
<object name="room">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
<function name="rock_paper_scissors_function">
if (game.games_count_integer = game.game_quantity_that_you_want_to_play) {
msg ("You've played the number of games that you chose to play, so now it's over.")
msg ("")
msg ("Games: " + game.games_count_integer)
msg ("Wins: " + game.wins_count_integer)
msg ("Losses: " + game.losses_count_integer)
msg ("Draws: " + game.draws_count_integer)
finish
}
else {
game.comp_choice_integer = GetRandomInt (1,3)
msg ("What is your choice?")
msg ("")
msg ("(1) Rock, (2) Paper, or (3) Scissors")
msg ("")
msg ("Type in the number of~for your choice, please")
msg ("")
get input {
game.your_choice_integer = ToInt (result)
switch (game.your_choice_integer) {
case ("1") {
switch (game.comp_choice_integer) {
case ("1") {
msg ("You chose: Rock")
msg ("Comp chose: Rock")
msg ("The game's a draw.")
msg ("")
game.draws_count_integer = game.draws_count_integer + 1
}
case ("2") {
msg ("You chose: Rock")
msg ("Comp chose: Paper")
msg ("You lost the game.")
msg ("")
game.losses_count_integer = game.losses_count_integer + 1
}
case ("3") {
msg ("You chose: Rock")
msg ("Comp chose: Scissors")
msg ("You won the game!")
msg ("")
game.wins_count_integer = game.wins_count_integer + 1
}
}
}
case ("2") {
switch (game.comp_choice_integer) {
case ("1") {
msg ("You chose: Paper")
msg ("Comp chose: Rock")
msg ("You won the game!")
msg ("")
game.wins_count_integer = game.wins_count_integer + 1
}
case ("2") {
msg ("You chose: Paper")
msg ("Comp chose: Paper")
msg ("The game's a draw.")
msg ("")
game.draws_count_integer = game.draws_count_integer + 1
}
case ("3") {
msg ("You chose: Paper")
msg ("Comp chose: Scissors")
msg ("You lost the game!")
msg ("")
game.losses_count_integer = game.losses_count_integer + 1
}
}
}
case ("3") {
switch (game.comp_choice_integer) {
case ("1") {
msg ("You chose: Scissors")
msg ("Comp chose: Rock")
msg ("You lost the game.")
msg ("")
game.losses_count_integer = game.losses_count_integer + 1
}
case ("2") {
msg ("You chose: Scissors")
msg ("Comp chose: Paper")
msg ("You won the game.")
msg ("")
game.wins_count_integer = game.wins_count_integer + 1
}
case ("3") {
msg ("You chose: Scissors")
msg ("Comp chose: Scissors")
msg ("The game's a draw!")
msg ("")
game.draws_count_integer = game.draws_count_integer + 1
}
}
}
}
}
on ready {
msg ("Click on the blue hypertext link 'continue', seen just below this line, or just hit the enter key, to play the next game.")
msg ("")
wait {
game.games_count_integer = game.games_count_integer + 1
ClearScreen
rock_paper_scissors_function
}
}
}
</function>
</asl>


for fun, see if you can crack~discover the "GetRandomInt" function's algorithm used (so you can win every game), hehe ;)

enjoy :D

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums