Skip to content
Snippets Groups Projects
Select Git revision
  • 9a18248fe0327760d3404b2e7ed4110505a48b40
  • master default protected
2 results

fuzz_target_4.rs

Blame
  • services.js 1.88 KiB
    'use strict';
    
    /* Services */
    
    
    // Demonstrate how to register services
    // In this case it is a simple value service.
    angular.module('myApp.services', []).
      value('version', 'Jan-7-2014')
        .factory('GameService', function($http) {
    
            var s4 = function() {
                return Math.floor(Math.random() * 0x10000).toString();
            }
            var guid = function(){
                return s4() + s4() + "-" + s4() + "-" + s4() + "-" + s4() + "-" + s4() + s4() + s4();
            };
            var pId = guid();
    
            return {
                playerName: '',
                playerId : pId,
                newGameId : guid(),
                currentGameId: undefined,
                initName: function() {
                    if(this.playerName.length === 0) {
                        this.playerName = 'anonymous ' + s4();
                    }
                },
                getGames: function() {
                    return $http.get('/list');
                },
                createGame: function() {
                    return $http.post('/add', { id: guid(), name: this.playerName + "'s game" });
                },
                joinGame: function(gameId, playerId, name) {
                    $http.post("/joingame", { gameId: gameId, playerId: playerId, playerName: name });
                },
                departGame: function(gameId, playerId) {
                    $http.post('/departgame', { gameId: gameId, playerId: playerId});
                },
                selectCard: function(gameId, playerId, selectedCard){
                    $http.post("/selectCard", { gameId: gameId, playerId: playerId, whiteCardId: selectedCard });
                },
                selectWinner: function(gameId, selectedCard) {
                    $http.post("/selectWinner", { gameId: gameId, cardId: selectedCard });
                },
                readyForNextRound: function(gameId, playerId) {
                    $http.post("readyForNextRound",  { playerId: playerId, gameId: gameId });
                }
            }
        });