             @config.game.characters[name] = base
         return {'game': base, 'visual': visualBase}
 
-    #Callback for games
     gameLost: ->
+        ###
+            External Function (used by something outside of this file)
+
+            Updates the game statistics on the loss, plays the losing sound,
+            and summons the game lost cloud.
+        ###
         @updateGameLostStats()
         playAudio 'defeat.ogg'
-        
+
         messages = ["Try Again!"]
         window.objCloud(400,messages,"body","30%","30%",3,"none",@gameManager)
         @gameRunFinished()
-    
-    #Callback for games
-    gameWon: ->
-        @updateGameWonStats()
+
+    gameWon: (score, stars) ->
+        ###
+            External Function (used by something outside of this file)
+
+            Updates the game statistics on the win, plays the winning sound,
+            and summons the game won cloud.
+
+            @param score
+                The score the player achieved during this play of the game.
+            @param stars
+                How many stars the player earned during this play of the game.
+        ###
+        @updateGameWonStats score, stars
         playAudio 'victory.ogg'
 
         gameName = @gameName()

        return

    commandsValid: (valid) =>
        if valid
            jQuery('#compileAndRun').attr 'disabled', false
            @canRun = true

    log = (mesg) -> console.log(mesg)
else
    log = (mesg) -> null

log("GameManager log")

# Some browsers have a deepcopy function, others do not.
# For those who do not, we use the JQuery deepcopy function.
if not deepcopy?
    deepcopy = (src) -> $.extend(true, {}, src)

class window.GameManager
    constructor: (@environment) ->
        ###
            External Function (used by something outside of this file)

            Takes in the game environment and sets up the code editor and
            the game visual and the game logic.

            @param environment
                The environment and configuration required for this game.
        ###
        @config = deepcopy @environment.description
        @gameStateBase = @environment.gameState

