Script: Achievement

All achievement scripts are instantiated after the server has been initialized and all players added to the game. All events that are generated by the engine are passed to each script. The script then decides whether a player has earned the achievement, and if yes then awards it.

The script must not modify the game state, it's purely an observer of the running game. In particular, use of eventSchedule and similar functions is forbidden.

self in achievement scripts refers to the Achievement. Use it as the second argument of awardAchievement.

handleEvent :: (Event) -> ignored

The script must implement this function. It is passed each event that is generated by the game. This example awards each player in the game the achievement when the game ends:

handleEvent: (e) ->
    if (eventName e) == 'finishGame'
        forEach players, (x) -> awardAchievement x, self