public MainWindow()
        {
            logger          = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
            telemetryWriter = new TelemetryWriter();
            logger.Info("\n\nApp start");
            telemetryWriter.WriteAppStart();
            messageBoxService  = new MessageBoxService();
            dbService          = new DbService();
            drawService        = new DrawService(logger);
            throwService       = new ThrowService(logger);
            configService      = new ConfigService(logger, dbService);
            scoreBoardService  = new ScoreBoardService(logger, configService, drawService);
            camsDetectionBoard = new CamsDetectionBoard(configService, logger, drawService);
            fileSystemService  = new FileSystemService();
            versionChecker     = new VersionChecker(appVersion, fileSystemService, dbService, configService, messageBoxService);
            detectionService   = new DetectionService(drawService, configService, throwService, logger, camsDetectionBoard);
            manualThrowPanel   = new ManualThrowPanel(logger, detectionService);
            gameService        = new GameService(scoreBoardService, camsDetectionBoard, detectionService, logger, dbService, manualThrowPanel);

            InitializeComponent();
            viewModel = new MainWindowViewModel(logger,
                                                messageBoxService,
                                                dbService,
                                                versionChecker,
                                                scoreBoardService,
                                                camsDetectionBoard,
                                                drawService,
                                                detectionService,
                                                manualThrowPanel,
                                                gameService,
                                                configService);
            DataContext = viewModel;
        }
Exemple #2
0
 private void Initialize()
 {
     if (scoreBoardService == null)
     {
         scoreBoardService = serviceAPI.BuildScoreBoardService();
     }
 }
        protected ProcessorBase(Domain.Game game,
                                List <Player> players,
                                DBService dbService,
                                ScoreBoardService scoreBoard,
                                int legs = 0,
                                int sets = 0)
        {
            this.dbService  = dbService;
            this.scoreBoard = scoreBoard;
            this.legs       = legs;
            this.sets       = sets;

            if (players.Count == 1) //  todo maybe do another way cuz ugly
            {
                players[0].Order = PlayerOrder.First;
            }
            else
            {
                players[1].Order = PlayerOrder.Second;
            }

            Game          = game;
            Players       = players;
            PlayerOnThrow = Players.First();
            PlayerOnLeg   = Players.First();
        }
Exemple #4
0
    public void getScore()
    {
        App42API.Initialize("47675efb1d62deab9e46b9d43795e45c381c341bec9033abb9622fa1a88e5720", "256e86ad5fe1038aaf20334d51c894f1dfa9839996dbaa2e92376141761a07f0");
        ScoreBoardService scoreBoardService = App42API.BuildScoreBoardService();

        scoreBoardService.GetScoresByUser(gameName, TestUser._testUser.UserName, new UnityCallBack());
    }
Exemple #5
0
    public void setScore(double userScore)
    {
        App42API.Initialize("47675efb1d62deab9e46b9d43795e45c381c341bec9033abb9622fa1a88e5720", "256e86ad5fe1038aaf20334d51c894f1dfa9839996dbaa2e92376141761a07f0");
        ScoreBoardService scoreBoardService = App42API.BuildScoreBoardService();

        scoreBoardService.EditScoreValueById(scoreID, userScore, new UnityCallBack());
    }
Exemple #6
0
    // Use this for initialization

    void Start()
    {
        goRank   = false;
        ranks    = new List <Text>();
        names    = new List <Text>();
        score    = new List <Text>();
        texts    = new List <GameObject>();
        reload   = relo;
        scorenew = false;
        otherMetaHeaders.Add("orderByDescending", "score");
        App42API.Initialize(key, secretkey);
        App42Log.SetDebug(true);
        gameserv       = App42API.BuildGameService();
        scoreboardserv = App42API.BuildScoreBoardService();
        scoreboardserv.SetOtherMetaHeaders(otherMetaHeaders);
        scoreboardserv.GetTopNRankers(gamename, maxplayers, new toprankMenu());
        if (texts.Count < 20)
        {
            for (int i = 0; i < 20; i++)
            {
                texts.Add(GameObject.Find("Text" + (i + 1)));
            }
            for (int i = 0; i < texts.Count; i++)
            {
                ranks.Add(texts [i].transform.FindChild("ran").GetComponent <Text> ());
                names.Add(texts [i].transform.FindChild("nome").GetComponent <Text> ());
                score.Add(texts [i].transform.FindChild("pt").GetComponent <Text> ());
            }
            //Debug.Log ("veioaquiDENOVO");
        }
        render    = GameObject.Find("hsImg").GetComponent <Image> ();
        error [0] = bla [0];
        error [1] = bla [1];
    }
    string[] GetScores()
    {
        scoreBoardService = sp.BuildScoreBoardService(); // Initializing scoreBoardService.
        string[] score_table = new string[max_players_returned * 3];

        try
        {
            //Getting Top Scorers , By Using App42 Scoreboard Service.
            //Method Name->GetTopNRankers(game_name, max);
            //Param->game_name(Name Of The Game, Which Is Created By You In AppHQ.)
            //Param->max(Provide Max Number "N" Of Scorers.)
            Game top_rankers = scoreBoardService.GetTopNRankers(game_name, max_players_returned);

            for (int i = 0; i < top_rankers.GetScoreList().Count; i++)
            {
                // player_rank, player_name, player_score
                score_table [(0 + i * 3)] = (i + 1).ToString();
                score_table [(1 + i * 3)] = top_rankers.GetScoreList() [i].userName;
                score_table [(2 + i * 3)] = top_rankers.GetScoreList() [i].value.ToString();
            }

        } catch (App42Exception e)
        {
            error = errors.get_error_code(e);
        }

        return score_table;
    }
 public FreeThrowsSingleFreePointsProcessor(Domain.Game game,
                                            List <Player> players,
                                            DBService dbService,
                                            ScoreBoardService scoreBoard)
     : base(game, players, dbService, scoreBoard)
 {
 }
 public ScoreBoardController(ScoreBoardService scoreboardService, GameService gameService, RequestContext context, IHubContext <ScoreBoardHub> hub)
 {
     this.scoreboardService = scoreboardService;
     this.gameService       = gameService;
     this.context           = context;
     this.hub = hub;
 }
Exemple #10
0
 public void GetLeaderBoard(int count, App42CallBack callback)
 {
     if (scoreBoardService == null)
     {
         scoreBoardService = App42API.BuildScoreBoardService();
     }
     scoreBoardService.GetTopNRankers(GAME_NAME, count, callback);
 }
Exemple #11
0
    void GetLeaderboardUsers()
    {
        DeleteChilds();
        App42API.Initialize("47675efb1d62deab9e46b9d43795e45c381c341bec9033abb9622fa1a88e5720", "256e86ad5fe1038aaf20334d51c894f1dfa9839996dbaa2e92376141761a07f0");
        ScoreBoardService scoreBoardService = App42API.BuildScoreBoardService();

        scoreBoardService.GetTopRankings(gameName, new UnityCallBack());
    }
    public int GetPlayerRank(string player_name)
    {
        scoreBoardService = sp.BuildScoreBoardService(); // Initializing scoreBoardService.
        Game player_rank = scoreBoardService.GetUserRanking(game_name, player_name);
        string rank = player_rank.GetScoreList() [0].GetRank();

        return System.Convert.ToInt16(rank);
    }
Exemple #13
0
    public void registerPlayer()
    {
        userUsername    = uName.text;
        userEmail       = eMail.text;
        userPass        = password.text;
        userPassConfirm = passConfirm.text;

        //clearAll();

        if (userUsername != "" && userUsername.Length < 10)
        {
            if (userEmail != "")
            {
                if (userPass != "" && userPassConfirm != "")
                {
                    if (userPass == userPassConfirm)
                    {
                        if (ValidateEmail(userEmail) == true)
                        {
                            App42API.Initialize("47675efb1d62deab9e46b9d43795e45c381c341bec9033abb9622fa1a88e5720", "256e86ad5fe1038aaf20334d51c894f1dfa9839996dbaa2e92376141761a07f0");
                            UserService userService = App42API.BuildUserService();

                            ScoreBoardService scoreBoardService = App42API.BuildScoreBoardService();
                            scoreBoardService.SaveUserScore(gameName, userUsername, gameScore, new UnityCallBack());
                            userService.CreateUser(userUsername, userPass, userEmail, new UnityCallBack());
                            passwordCheck.text = "";
                        }

                        else
                        {
                            clearLabels();
                            eMailCheck.text = "Invalid Email";
                        }
                    }
                    else
                    {
                        clearLabels();
                        passwordCheck.text = "Password do not match";
                    }
                }
                else
                {
                    clearLabels();
                    passwordCheck.text = "Enter password";
                }
            }
            else
            {
                clearLabels();
                eMailCheck.text = "Enter your email";
            }
        }
        else
        {
            clearLabels();
            uNameCheck.text = "Enter username";
        }
    }
Exemple #14
0
        protected ProcessorBase(Domain.Game game,
                                ScoreBoardService scoreBoard)
        {
            this.scoreBoard = scoreBoard;
            Game            = game;
            GameSnapshots   = new Stack <GameSnapshot>();

            PrepareGame();
        }
Exemple #15
0
 public FreeThrowsDoubleWriteOffPointsProcessor(Game game,
                                                List <Player> players,
                                                DBService dbService,
                                                ScoreBoardService scoreBoard,
                                                int writeOffPoints)
     : base(game, players, dbService, scoreBoard)
 {
     this.writeOffPoints = writeOffPoints;
     players.ForEach(p => p.LegPoints = writeOffPoints);
 }
 public static void GlobalLeaderBoard()
 {
     errorMessage = false;
     LeaderBoardCallBack.fList.Clear ();
     FriendsLeaderBoardCallBack.friendList.Clear ();
     LeaderBoardCallBack.fromLeaderBoard = true;
     scoreBoardService = App42API.BuildScoreBoardService ();
     Query q = QueryBuilder.Build ("userId","",Operator.LIKE);
     scoreBoardService.SetQuery (AppConstants.collectionName,q);
     scoreBoardService.GetTopNRankers(AppConstants.gameName, 10, new LeaderBoardCallBack ());
 }
Exemple #17
0
    // Update is called once per frame
    void Update()
    {
        if (createUser)
        {
            createUser = false;
            UserService userService = App42API.BuildUserService();
            userService.CreateUser(userName, "passwordboka", userName + "@gmail.com", new UnityCallBackCreateUser());
        }

        if (saveScore)
        {
            saveScore = false;
            if (PlayerPrefs.HasKey("user") && PlayerPrefs.HasKey("score"))
            {
                ScoreBoardService scoreBoardService = App42API.BuildScoreBoardService();
                scoreBoardService.SaveUserScore("mordenSenta", PlayerPrefs.GetString("user"), PlayerPrefs.GetInt("score"), new UnityCallBackSaveScore());
            }
        }

        if (getUserRank)
        {
            Debug.Log("user klicem");
            getUserRank = false;
            if (PlayerPrefs.HasKey("user"))
            {
                ScoreBoardService scoreBoardService = App42API.BuildScoreBoardService();
                scoreBoardService.GetUserRanking("mordenSenta", PlayerPrefs.GetString("user"), new UnityCallBackGetUserRank());
                Debug.Log("user klicem");
            }
        }

        if (getTopNRanks)
        {
            getTopNRanks = false;
            ScoreBoardService scoreBoardService = App42API.BuildScoreBoardService();
            scoreBoardService.GetTopNRankers("mordenSenta", 10, new UnityCallBackGetTopRanks());
        }

        if (recivedUser != null)
        {
            saveScore = true;
            PlayerPrefs.SetString("user", userName);
            recivedUser = null;
            signIn.SetActive(false);
            //leaderTabela.SetActive(true);

            menuSkripta.userVpisan = true;
        }
        if (recivedScore != null)
        {
            recivedScore = null;
            getUserRank  = true;
        }
    }
Exemple #18
0
        public void Init()
        {
            sbService = new ScoreBoardService();

            InitLayout();
            ScoreResult1.Anchor = AnchorStyles.None;
            ScoreResult2.Anchor = AnchorStyles.None;

            PanelScore1.Controls.Add(ScoreResult1);
            PanelScore2.Controls.Add(ScoreResult2);
        }
        private void RegisterContainer()
        {
            logger.Debug("Services container register start");

            var cb = new ContainerBuilder();

            cb.Register(r => logger).AsSelf().SingleInstance();

            cb.Register(r => telemetryWriter).AsSelf().SingleInstance();

            var messageBoxService = new MessageBoxService();

            cb.Register(r => messageBoxService).AsSelf().SingleInstance();

            var dbService = new DBService();

            cb.Register(r => dbService).AsSelf().SingleInstance();

            var configService = new ConfigService(logger, dbService);

            cb.Register(r => configService).AsSelf().SingleInstance();

            var versionChecker = new VersionChecker(dbService, configService, messageBoxService);

            cb.Register(r => versionChecker).AsSelf().SingleInstance();

            var scoreBoardService = new ScoreBoardService();

            cb.Register(r => scoreBoardService).AsSelf().SingleInstance();

            var drawService = new DrawService(this, configService, logger);

            cb.Register(r => drawService).AsSelf().SingleInstance();

            var throwService = new ThrowService(drawService, logger);

            cb.Register(r => throwService).AsSelf().SingleInstance();

            var detectionService = new DetectionService(this, drawService, configService, throwService, logger);

            cb.Register(r => detectionService).AsSelf().SingleInstance();

            var manualThrowPanel = new ManualThrowPanel(logger, detectionService);

            cb.Register(r => manualThrowPanel).AsSelf().SingleInstance();

            var gameService = new GameService(this, scoreBoardService, detectionService, configService, drawService, logger, dbService);

            cb.Register(r => gameService).AsSelf().SingleInstance();

            ServiceContainer = cb.Build();

            logger.Debug("Services container register end");
        }
        /// <summary>
        /// Test Method for saving the user score in App42 Cloud.
        /// </summary>
        public static void SaveUserScore()
        {
            /// Enter your Public Key and Private Key Here in Constructor. You can
            /// get it once you will create a app in app42 console.

            ServiceAPI sp = new ServiceAPI("<Your_API_Key>", "<Your_Secret_Key>");

            String gameName    = "PokerGame";
            String userName    = "******";
            double gameScore   = 3500;
            String description = "description";
            /// Create Instance of ScoreBoard Service
            ScoreBoardService scoreBoardService = sp.BuildScoreBoardService();
            GameService       gameService       = sp.BuildGameService();

            try
            {
                Game saveScore = scoreBoardService.SaveUserScore(gameName, userName, gameScore);
                Console.WriteLine("gameName is " + saveScore.GetName());
                for (int i = 0; i < saveScore.GetScoreList().Count; i++)
                {
                    Console.WriteLine("userName is : " + saveScore.GetScoreList()[i].GetUserName());
                    Console.WriteLine("score is : " + saveScore.GetScoreList()[i].GetValue());
                    Console.WriteLine("scoreId is : " + saveScore.GetScoreList()[i].GetScoreId());
                }
            }
            catch (App42Exception ex)
            {
                /// Exception Caught
                /// Do exception Handling of Score Board Service functions.
                if (ex.GetAppErrorCode() == 3002)
                {
                    Game createGame = gameService.CreateGame(gameName, description);
                    Console.WriteLine("gameName is " + createGame.GetName());
                    Game game = scoreBoardService.SaveUserScore(gameName, userName, gameScore);
                    Console.WriteLine("gameName is " + game.GetName());
                    for (int i = 0; i < game.GetScoreList().Count; i++)
                    {
                        Console.WriteLine("userName is : " + game.GetScoreList()[i].GetUserName());
                        Console.WriteLine("score is : " + game.GetScoreList()[i].GetValue());
                        Console.WriteLine("scoreId is : " + game.GetScoreList()[i].GetScoreId());
                    }
                }
                else if (ex.GetAppErrorCode() == 1401)
                {
                    Console.WriteLine("Please verify your API_KEY and SECRET_KEY From AppHq Console (Apphq.shephertz.com).");
                }
                else
                {
                    Console.WriteLine("Exception is : " + ex.ToString());
                }
            }
            Console.ReadKey();
        }
Exemple #21
0
 public ClassicDoubleProcessor(Game game,
                               List <Player> players,
                               DBService dbService,
                               ScoreBoardService scoreBoard,
                               int legPoints,
                               int legs,
                               int sets)
     : base(game, players, dbService, scoreBoard, legs, sets)
 {
     this.legPoints = legPoints;
     players.ForEach(p => p.LegPoints = legPoints);
 }
    public static void SaveScore()
    {
        LeaderBoardCallBack.fromSaveScore = true;
        scoreBoardService = App42API.BuildScoreBoardService ();

        Dictionary<string,object> playerFBProfile = new Dictionary<string, object> ();
        playerFBProfile.Add ("userId",LeaderBoardCallBack.fbUserId);
        playerFBProfile.Add ("name",LeaderBoardCallBack.fbUserName);
        playerFBProfile.Add ("profilePic",LeaderBoardCallBack.fbUserProfilePic);
        scoreBoardService.AddJSONObject (AppConstants.collectionName,playerFBProfile);
        scoreBoardService.SaveUserScore(AppConstants.gameName, LeaderBoardCallBack.fbUserId, MyGame.scoreValue,new LeaderBoardCallBack ());
    }
Exemple #23
0
 public GameService(ScoreBoardService scoreBoardService,
                    CamsDetectionBoard camsDetectionBoard,
                    DetectionService detectionService,
                    Logger logger,
                    DBService dbService)
 {
     this.logger             = logger;
     this.scoreBoardService  = scoreBoardService;
     this.camsDetectionBoard = camsDetectionBoard;
     this.detectionService   = detectionService;
     this.dbService          = dbService;
 }
    public static void GlobalLeaderBoard()
    {
        errorMessage = false;
        LeaderBoardCallBack.fList.Clear();
        FriendsLeaderBoardCallBack.friendList.Clear();
        LeaderBoardCallBack.fromLeaderBoard = true;
        scoreBoardService = App42API.BuildScoreBoardService();
        Query q = QueryBuilder.Build("userId", "", Operator.LIKE);

        scoreBoardService.SetQuery(AppConstants.collectionName, q);
        scoreBoardService.GetTopNRankers(AppConstants.gameName, 10, new LeaderBoardCallBack());
    }
    public static void SaveScore()
    {
        LeaderBoardCallBack.fromSaveScore = true;
        scoreBoardService = App42API.BuildScoreBoardService();

        Dictionary <string, object> playerFBProfile = new Dictionary <string, object> ();

        playerFBProfile.Add("userId", LeaderBoardCallBack.fbUserId);
        playerFBProfile.Add("name", LeaderBoardCallBack.fbUserName);
        playerFBProfile.Add("profilePic", LeaderBoardCallBack.fbUserProfilePic);
        scoreBoardService.AddJSONObject(AppConstants.collectionName, playerFBProfile);
        scoreBoardService.SaveUserScore(AppConstants.gameName, LeaderBoardCallBack.fbUserId, MyGame.scoreValue, new LeaderBoardCallBack());
    }
        public void UpdateScore_ScoreUpdated_Verify()
        {
            int runScored = 5;
            var expectedBallsRemaining = _currentMatch.BallsRemaining - 1;
            var runsNeedToWin          = _currentMatch.RunsNeedToWin - runScored;

            ScoreBoardService.UpdateScore(_currentMatch, striker, runScored, currentOver);

            Assert.Equal(expectedBallsRemaining, _currentMatch.BallsRemaining);
            Assert.Equal(runsNeedToWin, _currentMatch.RunsNeedToWin);
            Assert.Equal(1, striker.BallsFaced);
            Assert.Equal(5, striker.RunsScored);
        }
    public static void OnlyFriendsLeaderBoard()
    {
        LeaderBoardCallBack.fList.Clear ();
        scoreBoardService.SetQuery (AppConstants.collectionName, null);
        scoreBoardService = App42API.BuildScoreBoardService ();
        if (LeaderBoardCallBack.fbAccessToken.Equals ("") || LeaderBoardCallBack.fbAccessToken == null) {
                        errorMessage = true;
                        exceptionMessage = "Firstly you Login to facebook.";
                }
         else

            scoreBoardService.GetTopNRankersFromFacebook (AppConstants.gameName, LeaderBoardCallBack.fbAccessToken, 10, new FriendsLeaderBoardCallBack ());
    }
Exemple #28
0
        protected ProcessorBase(Game game,
                                List <Player> players,
                                DBService dbService,
                                ScoreBoardService scoreBoard)
        {
            this.dbService  = dbService;
            this.scoreBoard = scoreBoard;

            Game          = game;
            Players       = players;
            PlayerOnThrow = Players.First();
            PlayerOnSet   = Players.First();
        }
Exemple #29
0
        public CricketMatchRepositoryTest()
        {
            repository = new CricketMatchRepository(new CricketMatchResults());
            service    = new ScoreBoardService(repository);

            List <CricketMatch> results = new List <CricketMatch>
            {
                new CricketMatch
                {
                    Team         = "SA",
                    RunsScored   = 250,
                    WicketsTaken = 7,
                    Result       = "Lost By 10 Runs",
                    Venue        = "Mumbai"
                },
                new CricketMatch
                {
                    Team         = "Pakistan",
                    RunsScored   = 350,
                    WicketsTaken = 7,
                    Result       = "Won By 5 Wickets",
                    Venue        = "Delhi"
                },
                new CricketMatch
                {
                    Team         = "England",
                    RunsScored   = 220,
                    WicketsTaken = 3,
                    Result       = "Won By 10 Runs",
                    Venue        = "Bangaluru"
                },
                new CricketMatch
                {
                    Team         = "West Indies",
                    RunsScored   = 280,
                    WicketsTaken = 4,
                    Result       = "Lost By 20 Runs",
                    Venue        = "Chandigarh"
                },
                new CricketMatch
                {
                    Team         = "Australia",
                    RunsScored   = 310,
                    WicketsTaken = 7,
                    Result       = "Won By 1 Run",
                    Venue        = "Mumbai"
                }
            };

            repository.AddResults(results);
        }
 public GameService(ScoreBoardService scoreBoardService,
                    CamsDetectionBoard camsDetectionBoard,
                    DetectionService detectionService,
                    Logger logger,
                    DbService dbService,
                    ManualThrowPanel manualThrowPanel)
 {
     this.logger             = logger;
     this.scoreBoardService  = scoreBoardService;
     this.camsDetectionBoard = camsDetectionBoard;
     this.detectionService   = detectionService;
     this.dbService          = dbService;
     this.manualThrowPanel   = manualThrowPanel;
 }
 public static void OnlyFriendsLeaderBoard()
 {
     LeaderBoardCallBack.fList.Clear();
     scoreBoardService.SetQuery(AppConstants.collectionName, null);
     scoreBoardService = App42API.BuildScoreBoardService();
     if (LeaderBoardCallBack.fbAccessToken.Equals("") || LeaderBoardCallBack.fbAccessToken == null)
     {
         errorMessage     = true;
         exceptionMessage = "Firstly you Login to facebook.";
     }
     else
     {
         scoreBoardService.GetTopNRankersFromFacebook(AppConstants.gameName, LeaderBoardCallBack.fbAccessToken, 10, new FriendsLeaderBoardCallBack());
     }
 }
 public ServicesPage()
 {
     App42API.Initialize(Constants.apiKey,Constants.secretKey );
     App42Log.SetDebug(true);
     InitializeComponent();
     userService = App42API.BuildUserService();
     storageService = App42API.BuildStorageService();
     gameService = App42API.BuildGameService();
     scoreBoardService = App42API.BuildScoreBoardService();
     uploadService = App42API.BuildUploadService();
     photoChooserTask = new PhotoChooserTask();
     photoChooserTask.Completed += new EventHandler<PhotoResult>(photoChooserTask_Completed);
     photoChooserTask2 = new PhotoChooserTask();
     photoChooserTask2.Completed += new EventHandler<PhotoResult>(photoChooserTask2_Completed);
 }
Exemple #33
0
 public ServicesPage()
 {
     App42API.Initialize(Constants.apiKey, Constants.secretKey);
     App42Log.SetDebug(true);
     InitializeComponent();
     userService                  = App42API.BuildUserService();
     storageService               = App42API.BuildStorageService();
     gameService                  = App42API.BuildGameService();
     scoreBoardService            = App42API.BuildScoreBoardService();
     uploadService                = App42API.BuildUploadService();
     photoChooserTask             = new PhotoChooserTask();
     photoChooserTask.Completed  += new EventHandler <PhotoResult>(photoChooserTask_Completed);
     photoChooserTask2            = new PhotoChooserTask();
     photoChooserTask2.Completed += new EventHandler <PhotoResult>(photoChooserTask2_Completed);
 }
        public void UpdateWicket_ScoreUpdated_Verify()
        {
            var expectedBallsRemaining = _currentMatch.BallsRemaining - 1;
            var runsNeedToWin          = _currentMatch.RunsNeedToWin;
            var wicketsLeft            = _currentMatch.WicketsLeft - 1;
            var currentStriker         = striker;

            ScoreBoardService.UpdateWicket(_currentMatch, ref striker, nonStriker, currentOver);

            Assert.Equal(expectedBallsRemaining, _currentMatch.BallsRemaining);
            Assert.Equal(runsNeedToWin, _currentMatch.RunsNeedToWin);
            Assert.NotEqual(currentStriker, striker);
            Assert.Equal(wicketsLeft, _currentMatch.WicketsLeft);
            Assert.True(currentStriker.IsOut);
            Assert.False(currentStriker.IsOnField);
        }
 public void saveScore()
 {
     if (playerName != null && LeveliManeger._instance.getIdScore() == null)
     {
         Debug.Log(name);
         App42Log.SetDebug(true);
         scoreBoardService = sp.BuildScoreBoardService();              // Initializing ScoreBoard Service.
         Debug.Log(LeveliManeger._instance.getSkupniCas() + "skupni cassss");
         scoreBoardService.SaveUserScore(gameName, playerName, Mathf.Floor(LeveliManeger._instance.getSkupniCas() * 10), saveScoreCall);
     }
     else if (LeveliManeger._instance.getIdScore() != null)
     {
         scoreBoardService = sp.BuildScoreBoardService();
         scoreBoardService.EditScoreValueById(LeveliManeger._instance.getIdScore(), Mathf.Floor(LeveliManeger._instance.getSkupniCas() * 10), saveScoreCall);
     }
 }
 void SubmitScore(int score, string name)
 {
     scoreBoardService = sp.BuildScoreBoardService(); // Initializing scoreBoardService.
     try
     {
         //Saving User Score , By Using App42 Scoreboard Service.
         //Method Name->SaveUserScore(game_name, userName, score);
         //Param->game_name(Name Of The Game, Which Is Created By You In AppHQ.)
         //Param->userName(Name Of The User For Which You Want To Save Score.)
         //Param->score( Data Type "double" Value Of Score.)
         Game savedScore = scoreBoardService.SaveUserScore(game_name, name, score);
     } catch (App42Exception e)
     {
         error = errors.get_error_code(e);
     }
 }
 public GameService(MainWindow mainWindow,
                    ScoreBoardService scoreBoardService,
                    DetectionService detectionService,
                    ConfigService configService,
                    DrawService drawService,
                    Logger logger,
                    DBService dbService)
 {
     this.mainWindow        = mainWindow;
     this.scoreBoardService = scoreBoardService;
     this.detectionService  = detectionService;
     this.configService     = configService;
     this.drawService       = drawService;
     this.logger            = logger;
     this.dbService         = dbService;
 }
 // Use this for initialization
 void Start()
 {
     scoreBoardService = App42API.BuildScoreBoardService ();
     //	socialService = App42API.BuildSocialService ();
 }
 private void Initialize()
 {
     scoreBoardService = serviceAPI.BuildScoreBoardService();
 }
 public static void SaveUserScore(double _score, App42ApiResultCallback callBack)
 {
     try
     {
         App42ApiCallback _sCallback = new App42ApiCallback(callBack);
         if (mScoreBoardService == null)
         {
             mScoreBoardService = GlobalContext.SERVICE_API.BuildScoreBoardService();
         }
         mScoreBoardService.SaveUserScore(GlobalContext.gameName, GlobalContext.g_UserProfile.UserID, _score, _sCallback);
         //mScoreBoardService.GetTopNRankersFromFacebook(GlobalContext.gameName, GlobalContext.AccessToken, 10, _sCallback);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
    // Use this for initialization
    void Start()
    {
        mHighScore = PlayerPrefs.GetInt("highscore", 0);

        // Build Shephertz services
        socialService = App42API.BuildSocialService();
        scoreBoardService = App42API.BuildScoreBoardService();

        DontDestroyOnLoad(this.gameObject);
    }
 public static void GetTopNGlobalScores(int count, App42ApiResultCallback callBack)
 {
     try
     {
         App42ApiCallback _sCallback = new App42ApiCallback(callBack);
         if (mScoreBoardService == null)
         {
             mScoreBoardService = GlobalContext.SERVICE_API.BuildScoreBoardService();
         }
         mScoreBoardService.GetTopNRankers(GlobalContext.gameName, count, _sCallback);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
 public static void GetUserRanking(App42ApiResultCallback callBack)
 {
     try
     {
         App42ApiCallback _sCallback = new App42ApiCallback(callBack);
         if (mScoreBoardService == null)
         {
             mScoreBoardService = GlobalContext.SERVICE_API.BuildScoreBoardService();
         }
         mScoreBoardService.GetUserRanking(GlobalContext.gameName, GlobalContext.g_UserProfile.UserID, _sCallback);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
 public void SocialConnectWithApp42(string userId, string fbAccessToken)
 {
     sp = AppConstant.GetServce();
      scoreService = AppConstant.GetScoreService(sp);
      storageService = AppConstant.GetStorageService(sp);
      storageService.FindAllDocuments(AppConstant.DBName,AppConstant.CollectionName,this);
      AppConstant.GetInstance().ExecuteGet("https://graph.facebook.com/"+userId);
 }
	void Start () {
		api = new ServiceAPI(API_KEY, SECRET_KEY);  
		scoreBoardService = api.BuildScoreBoardService();    
	}
Exemple #46
0
    // Use this for initialization
    void Start()
    {
        //App42Log.SetDebug(true);

        App42API.Initialize("ca4db85228af0c40bbb7ae3ff63c9e2060d4394c1b9ea7ca6202c9691347d3b5","aa6f7deb1366c230429a849f91371d15d03a75b307653a147b2475c76d9bf955");

        gameService = App42API.BuildGameService();
        scoreBoardService = App42API.BuildScoreBoardService();

        if (loadScoreOnLoad)
            loadScore (true);
    }
    void OnGUI()
    {
        // For Setting Up ResponseBox.
        GUI.Box (new Rect (450, 40, 250, 175), box);
        GUI.Label (new Rect (470, 50, 200, 200), columnName);
        GUI.Label (new Rect (470, 70, 200, 200), success);
        GUI.Label (new Rect (470, 70, 200, 200), playerRank);
        GUI.Label (new Rect (540, 70, 200, 200), playerName);
        GUI.Label (new Rect (620, 70, 200, 200), playerScore);

        if (GUI.Button (new Rect (470, 250, 200, 50), "QUIT")) {
            Application.Quit();
        }

        // Label For EXCEPTION Message .
        GUI.Label (new Rect (250, 250, 700, 400), errorLable);

        //======================================================================================
        //---------------------------- Saving User Score.---------------------------------------
        //======================================================================================
        GUI.Label (new Rect (20, 40, 200, 20), "User Name");
        txt_user = GUI.TextField (new Rect (100, 40, 200, 20), txt_user);
        GUI.Label (new Rect (20, 70, 200, 20), "Score");
        txt_score = GUI.TextField (new Rect (100, 70, 200, 20), txt_score, 4);
        txt_score = Regex.Replace (txt_score, @"[^0-9]", "");

        if (GUI.Button (new Rect (100, 100, 200, 50), "Save User Score")) {
            // Clearing Data From Response Box.
            success = "";
            box = "";
            playerRank = "";
            playerName = "";
            playerScore = "";
            columnName = "";
            errorLable = "";

            if (txt_user == null || txt_user.Equals ("")) {
                box = "User Name Can Not Be Blank: ";
                return;
            }
            string userName = txt_user;  // Name Of The USER Who Wants To Save Score.
            if (txt_score == null || txt_score.Equals ("")) {
                box = "Score Value Can Not Be Blank: ";
                return;
            }
            double score = double.Parse (txt_score);		// Value Of The Score.

            scoreBoardService = App42API.BuildScoreBoardService (); // Initializing scoreBoardService.
            //Saving User Score , By Using App42 Scoreboard Service.
            //Method Name->SaveUserScore(gameName, userName, score);
            //Param->gameName(Name Of The Game, Which Is Created By You In AppHQ.)
            //Param->userName(Name Of The User For Which You Want To Save Score.)
            //Param->score( Data Type "double" Value Of Score.)
            //Param->Callback(callback for success/exception.);
            scoreBoardService.SaveUserScore (cons.gameName, userName, score, this);
            saveButton = true;
        }

        //=======================================================================================
        //---------------------------Getting Top N Rankers.--------------------------------------
        //=======================================================================================
        GUI.Label (new Rect (850, 40, 200, 20), "Game Name Is :");
        GUI.Label (new Rect (950, 41, 200, 20), cons.gameName);
        GUI.Label (new Rect (850, 70, 200, 20), "Select Max No.");
        txt_max = (int)GUI.HorizontalSlider (new Rect (945, 75, 100, 30), txt_max, 0, 9);
        GUI.Label (new Rect (1050, 70, 200, 20), txt_max.ToString ());

        if (GUI.Button (new Rect (860, 100, 200, 50), "GetTop N Rankers")) {
            // Clearing Data From Response Box.
            success = "";
            playerRank = "";
            playerName = "";
            playerScore = "";
            box = "";
            errorLable = "";

            if (txt_max == 0) {
                box = "Max Must Be Greater Than Zero: ";
                return;
            }

            scoreBoardService = App42API.BuildScoreBoardService (); // Initializing scoreBoardService.
            int max = txt_max;	// Maximum Number Of TOP RANKERS.

            //Getting Top Scorers , By Using App42 Scoreboard Service.
            //Method Name->GetTopNRankers(gameName, max);
            //Param->gameName(Name Of The Game, Which Is Created By You In AppHQ.)
            //Param->max(Provide Max Number "N" Of Scorers.)
            //Param->Callback(callback for success/exception.);
            scoreBoardService.GetTopNRankers (cons.gameName, max, this);
            leaderBoardButton = true;
        }
    }
    void OnGUI()
    {
        if (Time.time % 2 < 1) {
            success = callBack.getResult ();
        }
        // For Setting Up ResponseBox.
        GUI.TextArea (new Rect (10, 5, 1300, 175), success);

        //======================================{{{{************}}}}================================
        if (GUI.Button (new Rect (50, 200, 200, 30), "SaveUserScore")) {
            App42Log.SetDebug (true);
            scoreBoardService = sp.BuildScoreBoardService (); // Initializing ScoreBoard Service.
            scoreBoardService.SaveUserScore (cons.gameName, cons.userName, userScore, callBack);
        }

        //======================================{{{{************}}}}=================================
        if (GUI.Button (new Rect (260, 200, 200, 30), "GetScoresByUser")) {
            scoreBoardService = sp.BuildScoreBoardService (); // Initializing ScoreBoard Service.
            scoreBoardService.GetScoresByUser (cons.gameName, cons.userName, callBack);
        }

        //======================================{{{{************}}}}==========================================
        if (GUI.Button (new Rect (470, 200, 200, 30), "GetHighestScoreByUser")) {
            scoreBoardService = sp.BuildScoreBoardService (); // Initializing ScoreBoard Service.
            scoreBoardService.GetHighestScoreByUser (cons.gameName, cons.userName, callBack);
        }

        //======================================{{{{************}}}}==========================================
        if (GUI.Button (new Rect (680, 200, 200, 30), "GetLowestScoreByUser")) {
            scoreBoardService = sp.BuildScoreBoardService (); // Initializing ScoreBoard Service.
            scoreBoardService.GetLowestScoreByUser (cons.gameName, cons.userName, callBack);
        }

        //======================================{{{{************}}}}==========================================
        if (GUI.Button (new Rect (890, 200, 200, 30), "GetTopRankings")) {
            scoreBoardService = sp.BuildScoreBoardService (); // Initializing ScoreBoard Service.
            scoreBoardService.GetTopRankings (cons.gameName, callBack);
        }

        //======================================{{{{************}}}}==========================================
        if (GUI.Button (new Rect (50, 250, 200, 30), "GetAverageScoreByUser")) {
            scoreBoardService = sp.BuildScoreBoardService (); // Initializing ScoreBoard Service.
            scoreBoardService.GetAverageScoreByUser (cons.gameName, cons.userName, callBack);
        }

        //======================================{{{{************}}}}==========================================
        if (GUI.Button (new Rect (260, 250, 200, 30), "GetLastScoreByUser")) {
            scoreBoardService = sp.BuildScoreBoardService (); // Initializing ScoreBoard Service.
            scoreBoardService.GetLastScoreByUser (cons.gameName, cons.userName, callBack);
        }

        //======================================{{{{************}}}}==========================================
        if (GUI.Button (new Rect (470, 250, 200, 30), "GetTopRankings")) {
            scoreBoardService = sp.BuildScoreBoardService (); // Initializing ScoreBoard Service.
            scoreBoardService.GetTopRankings (cons.gameName, callBack);
        }

        //======================================{{{{************}}}}==========================================
        if (GUI.Button (new Rect (680, 250, 200, 30), "GetTopNRankings")) {
            scoreBoardService = sp.BuildScoreBoardService (); // Initializing ScoreBoard Service.
            scoreBoardService.GetTopNRankings (cons.gameName, max, callBack);
        }

        //======================================{{{{************}}}}==========================================
        if (GUI.Button (new Rect (890, 250, 200, 30), "GetTopNRankers")) {
            scoreBoardService = sp.BuildScoreBoardService (); // Initializing ScoreBoard Service.
            scoreBoardService.GetTopNRankers (cons.gameName, max, callBack);
        }

        //======================================{{{{************}}}}==========================================
        if (GUI.Button (new Rect (50, 300, 200, 30), "GetTopRankingsByGroup")) {
            scoreBoardService = sp.BuildScoreBoardService (); // Initializing ScoreBoard Service.
            IList<string> userList = new List<string> ();
            userList.Add (cons.userName);
            userList.Add (cons.userName1);
            scoreBoardService.GetTopRankingsByGroup (cons.gameName, userList, callBack);
        }

        //======================================{{{{************}}}}==========================================
        if (GUI.Button (new Rect (260, 300, 200, 30), "GetTopNRankersByGroup")) {
            scoreBoardService = sp.BuildScoreBoardService (); // Initializing ScoreBoard Service.
            IList<string> userList = new List<string> ();
            userList.Add (cons.userName);
            userList.Add (cons.userName1);
            scoreBoardService.GetTopNRankersByGroup (cons.gameName, userList, callBack);
        }

        //======================================{{{{************}}}}==========================================
        if (GUI.Button (new Rect (470, 300, 200, 30), "EditScoreValueById")) {
            scoreBoardService = sp.BuildScoreBoardService (); // Initializing ScoreBoard Service.
            IList<string> userList = new List<string> ();
            userList.Add (cons.userName);
            userList.Add (cons.userName1);
            scoreBoardService.EditScoreValueById (cons.scoreId, userScore, callBack);
        }
    }
 public void SaveScore()
 {
     FacebookLoginController FBLC = new FacebookLoginController();
         FBLC.CheckFacebookLogin();
         var aToken = Facebook.Unity.AccessToken.CurrentAccessToken;
         if(aToken.UserId!=null)
         userName = PlayerPrefs.GetString("FirstName") + " " + aToken.UserId + "";		//
     //	userName = aToken.UserId + "";  // Name Of The USER Who Wants To Save Score. //FACEBOOK USERNAME OF THE PLAYER
         int score = PlayerPrefs.GetInt("Highscore");
         scoreBoardService = App42API.BuildScoreBoardService (); // Initializing scoreBoardService.
         scoreBoardService.SaveUserScore (FBgameName, userName, score, this);
         saveButton = true;
         Debug.Log("Posted High score");
     //	}
 }
 public void GetTopScorers()
 {
     leaderBoardButton = true;
     SocialService socialService = App42API.BuildSocialService();
     var aToken = Facebook.Unity.AccessToken.CurrentAccessToken;
     scoreBoardService = App42API.BuildScoreBoardService();   //For FACEBOOK
     scoreBoardService.GetTopNRankers(FBgameName, 20, new LeaderboardController());
 }