Skip to content

Instantly share code, notes, and snippets.

@nthx
Created October 9, 2012 01:42
Show Gist options
  • Save nthx/3856082 to your computer and use it in GitHub Desktop.
Save nthx/3856082 to your computer and use it in GitHub Desktop.
Example of a glue
class WebGlue
constructor: (@usecase, @gui, @soundAPI)->
@memory = @usecase.memoryGame
applyMemoryGameGlue: =>
Before(@usecase, 'startMemoryGame',
=> @gui.showWelcome(@memory.timeLimit))
After(@memory, 'readyToStart', @gui.showStart)
After(@memory, 'teachHowToPlay', @gui.showTutorial)
After(@memory, 'start', @gui.showGamePlay)
After(@memory, 'generateBoard',=> @gui.showNewBoard(#.....)
After(@gui, 'finishedTutorialBtnClicked', @memory.playerFinishedTutorial)
After(@gui, 'startBtnClicked', @memory.playerRequestsStart)
After(@gui, 'slotClicked', (x, y) => @memory.playerPicksSlot(x, y))
Around(@memory, 'correctSlot',
(proceed, slot) => @gui.showCorrectSlot(proceed, slot.x, slot.y))
Around(@memory, 'wrongSlot',
(proceed, slot) => @gui.showWrongSlot(proceed, slot.x, slot.y, #...
Around(@memory, 'completedWholeBoard',
(proceed, board) => @gui.showCompletedBoard(proceed, board))
After(@memory, 'nextSecondElapsed',
=> @gui.updateTimer(@memory.secondsLeft()))
After(@memory, 'end',
=> @gui.stopGameAndShowResults(@memory.currentGame()))
After(@gui, 'resultsSeen', @usecase.playerSeenResults)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment