 
 Template.challenge.helpers
   opponent: ->
-    opponent = Meteor.users.findOne currentChallenge().challengeeId
+    opponent = null
+    if currentPlayerRole() is 'challengee'
+      opponent = Meteor.users.findOne currentChallenge().challengerId
+    else
+      opponent = Meteor.users.findOne currentChallenge().challengeeId
     opponent.username
 
   answered: ->


# methods

currentPlayerRole = ->
  isChallenger = currentPlayerId() is currentChallenge().challengerId
  isChallengee = currentPlayerId() is currentChallenge().challengeeId

  # check for error
  if isChallenger and isChallengee
    throw new Meteor.Error 500, 'Cannot be challenger and challengee'

  # return the players role
  if isChallenger
    'challenger'
  else if isChallengee
    'challengee'



      winner = 'tie'

    if winner is 'tie'
      "Wow, der ble uafgjort!"
    else if currentPlayerRole() is winner
      "Tillykke, du har vundet!"
    else
