public CometClientProcessor()
 {
     // Dependency Injection (design pattern ) implementation/realization other class in Constructor
     this._questionService = new QuestionService();
     this._answerService = new AnswerService();
     this._gameService = new GameService();
 }
        //
        // GET: /Game/
        public ActionResult Index()
        {
            var gameService = new GameService();
            var gamesDetails = gameService.GetGamesDetails(10, 10);

            return View(gamesDetails);
        }
        /// <summary>
        /// Implements the execution of the sendMousePoint command.
        /// </summary>
        /// <param name="current">Current service instance.</param>
        /// <param name="sessions">Collection of all sessions.</param>
        /// <param name="message">Command arguments.</param>
        public void Execute(GameService current, GameSessions sessions, string message)
        {
            if (null == current.Context.BuddyInstance)
            {
                sessions.SendMessage(current, "SendMousePointResponse:Failure;Buddy not found.");
                return;
            }
            else
            {
                if (string.IsNullOrEmpty(message))
                {
                    sessions.SendMessage(current, "SendMousePointResponse:Failure;Co-ordinates are not found in the request.");
                    return;
                }

                string[] location = message.Split(new char[] { ';' });

                if (location.Length != 2)
                {
                    sessions.SendMessage(current, "SendMousePointResponse:Failure;Co-ordinates are in incorrect format.");
                    return;
                }

                sessions.SendMessage(current.Context.BuddyInstance, "FixMousePoint:" + location[0] + ";" + location[1]);
                sessions.SendMessage(current, "SendMousePointResponse:Successful");
            }
        }
Beispiel #4
0
        /// <summary>
        /// Implements execution of this command.
        /// </summary>
        /// <param name="current">Current gameservice instance.</param>
        /// <param name="sessions">Collection of all sessons.</param>
        /// <param name="message">Command parameters.</param>
        public void Execute(GameService current, GameSessions sessions, string message)
        {
            if (null == current.Context.BuddyInstance)
            {
                sessions.SendMessage(current, "GameCompleteResponse:Failure;Buddy does not exist.");
                return;
            }
            else
            {
                GameService buddyInstance = current.Context.BuddyInstance;
                lock (gameCompleteLock)
                {
                    if (null != buddyInstance)
                    {
                        buddyInstance.Context.BuddyInstance = null;
                    }

                    if (null != current)
                    {
                        current.Context.BuddyInstance = null;
                    }

                    // Need to send gameComplete response to the current service, gameComplete to buddyInstance
                    // and also we need to braodcast gameCompleteResponse to all other sessions.
                    sessions.BroadcastMessage(BroadcastMessageType.GameCompleteResponse, current, buddyInstance, "GameCompleteResponse:Successful", "GameComplete");
                    return;
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Implements the execution of login command.
        /// </summary>
        /// <param name="current">Current service instance.</param>
        /// <param name="sessions">Collection of all sessions.</param>
        /// <param name="message">Command arguments.</param>
        public void Execute(GameService current, GameSessions sessions, string message)
        {
            if (!string.IsNullOrEmpty(current.Context.LogOnName))
            {
                sessions.SendMessage(current, "LoginResponse:Failure;Loggedin");
                return;
            }

            if (string.IsNullOrEmpty(message))
            {
                sessions.SendMessage(current, "LoginResponse:Failure;LoginNameEmpty");
                return;
            }

            var service = sessions.FindSession(message);

            if (null == service && loggedInUsers < MaxUsers)
            {
                Interlocked.Increment(ref loggedInUsers);
                current.Context.LogOnName = message;

                // Need to send successful response to the current service and LogOn response to all other sessions.
                // so that other sessions can also see that this user is logged in.
                sessions.BroadcastMessage(BroadcastMessageType.LogOnResponse, current, null, "LoginResponse:Successful", null);
            }
            else if (MaxUsers == loggedInUsers)
            {
                sessions.SendMessage(current, "LoginResponse:Failure;LoginLimitReached");
            }
            else
            {
                sessions.SendMessage(current, "LoginResponse:Failure;LoginNameTaken");
            }
        }
Beispiel #6
0
        /// <summary>
        /// Implements the execution of the sendDotPoint command.
        /// </summary>
        /// <param name="current">Current service instance.</param>
        /// <param name="sessions">Collection of all sessions.</param>
        /// <param name="message">Command arguments.</param>
        public void Execute(GameService current, GameSessions sessions, string message)
        {
            if (null == current.Context.BuddyInstance)
            {
                sessions.SendMessage(current, "SendDotPointResponse:Failure;BuddyNotFound.");
                return;
            }
            else
            {
                if (string.IsNullOrEmpty(message))
                {
                    sessions.SendMessage(current, "SendDotPointResponse:Failure;WrongFormat.");
                    return;
                }

                string[] location = message.Split(new char[] { ';' });

                if (location.Length != 2)
                {
                    sessions.SendMessage(current, "SendDotPointResponse:Failure;WrongFormat.");
                    return;
                }

                sessions.SendMessage(current.Context.BuddyInstance, "FixDotPoint:" + location[0] + ";" + location[1]);
                sessions.SendMessage(current, "SendDotPointResponse:Successful");
            }
        }
        protected SessionViewModel(NetworkService network)
        {
            Subscriptions = new ObservableCollection<SubscriptionViewModel> ();

            User = new UserViewModel (new User());
            UserAuth = new UserService(network);
            GameService = new GameService(network);
        }
Beispiel #8
0
        public Accessor Value; // 属性新值

        #endregion Fields

        #region Methods

        public override void Run(GameService game)
        {
            object holder = Holder.Access(game);
            object value = Value.Access(game);

            if (Holder.IsEnumerable)
                foreach (object obj in (IEnumerable<object>)holder)
                    runOnOne(obj, value);
            else
                runOnOne(holder, value);
        }
Beispiel #9
0
        public override object Access(GameService game)
        {
            Object caller = Caller.Access(game);

            // 产生参数表
            Object[] parameters = new Object[Parameters.Count];
            for (int i = 0; i < Parameters.Count; i++)
                parameters[i] = Parameters[i].Access(game);

            // 执行访问调用
            return NETFramework.FuncCall(caller, AccessorFuncName, parameters);
        }
        /// <summary>
        /// Implements the execution of getbuddyPlayer command.
        /// </summary>
        /// <param name="current">Current service instance.</param>
        /// <param name="sessions">Collection of all sessions.</param>
        /// <param name="message">Command arguments.</param>
        public void Execute(GameService current, GameSessions sessions, string message)
        {
            var players = string.Empty;
            players = sessions.GetOtherLoggedInSessionsList(current);

            // Removes last semicolon from players string.
            if (!string.IsNullOrEmpty(players))
            {
                players = players.Substring(0, players.Length - 1);
            }

            sessions.SendMessage(current, "GetBuddyPlayersResponse:" + players);
        }
 /// <summary>
 /// Implements the execution of the UILoadComplete command.
 /// </summary>
 /// <param name="current">Current service instance.</param>
 /// <param name="sessions">Collection of all sessions.</param>
 /// <param name="message">Command arguments.</param>
 public void Execute(GameService current, GameSessions sessions, string message)
 {
     if (null == current.Context.BuddyInstance)
     {
         sessions.SendMessage(current, "UILoadCompleteResponse:Failure;Buddy not found.");
         return;
     }
     else
     {
         sessions.SendMessage(current.Context.BuddyInstance, "CompleteUILoad:" + current.Context.LogOnName);
        sessions.SendMessage(current, "UILoadCompleteResponse:Successful");
     }
 }
Beispiel #12
0
 /// <summary>
 /// Implements execution of this command.
 /// </summary>
 /// <param name="current">Current gameservice instance.</param>
 /// <param name="sessions">Collection of all sessons.</param>
 /// <param name="message">Command parameters.</param>
 public void Execute(GameService current, GameSessions sessions, string message)
 {
     if (null == current.Context.PlayerInstance)
     {
         sessions.SendMessage(current, "WinGameResponse:Failure;PlayerNotFound.");
         return;
     }
     else
     {
         sessions.SendMessage(current.Context.PlayerInstance, "WinGame");
         sessions.SendMessage(current, "WinGameResponse:Successful");
     }
 }
 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);
 }
Beispiel #14
0
        public List<Accessor> Params; // 函数参数

        #endregion Fields

        #region Methods

        public override void Run(GameService game)
        {
            Object caller = Caller.Access(game);
            Object[] param = new Object[Params.Count];
            for(int i=0; i<Params.Count; i++)
            {
                param[i] = Params[i].Access(game);
            }

            if (Caller.IsEnumerable)
                foreach (object obj in (IEnumerable<object>)caller)
                    runOnOne(obj, param);
            else
                runOnOne(caller, param);
        }
Beispiel #15
0
 // 由Trigger调用来开启这个事件
 public void Enable(GameService game, bool enabled)
 {
     if (enabled)
     {
         Occured = false;        // 事件真正发生时才为true
         Object pub = Publisher.Access(game);
         pub.GetType().GetEvent(EventName).AddEventHandler(pub, new ObjectEventHandler(EventHandler));
     }
     else
     {
         Occured = true;         // 取消检查始终为true
         Object pub = Publisher.Access(game);
         pub.GetType().GetEvent(EventName).RemoveEventHandler(pub, new ObjectEventHandler(EventHandler));
     }
 }
        public ActionResult Create(Game game)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var gameservice = new GameService();
                    gameservice.Create(game);

                }
                return RedirectToAction("Index");
            }
            catch (Exception)
            {

                throw;
            }
        }
Beispiel #17
0
        /// <summary>
        /// Implements the execution of selectBuddy command.
        /// </summary>
        /// <param name="current">Current service instance.</param>
        /// <param name="sessions">Collection of all sessions.</param>
        /// <param name="message">Command arguments.</param>
        public void Execute(GameService current, GameSessions sessions, string message)
        {
            if (null != current.Context.BuddyInstance)
            {
                sessions.SendMessage(current, "SelectBuddyResponse:Failure;BuddyExist.");
                return;
            }
            else
            {
                if (string.IsNullOrEmpty(message))
                {
                    sessions.SendMessage(current, "SelectBuddyResponse:Failure;WrongRequest.");
                    return;
                }

                var buddyInstance = sessions.FindSession(message);

                if (null == buddyInstance)
                {
                    sessions.SendMessage(current, "SelectBuddyResponse:Failure;BuddyDoesNotExist" + message);
                    return;
                }
                else
                {
                    // Associate both players and then send all responses in the same atomic operation.
                    lock (selectBuddyLock)
                    {
                        if (null == buddyInstance.Context.BuddyInstance && null == current.Context.BuddyInstance)
                        {
                            current.Context.BuddyInstance = buddyInstance;
                            buddyInstance.Context.BuddyInstance = current;

                            // Need to send selectBuddy response to the current service, fixedbuddyresponse to buddyInstance
                            // and also we need to braodcast selectBuddyResposne to other sessions.
                            sessions.BroadcastMessage(BroadcastMessageType.SelectBuddyResponse, current, buddyInstance, "SelectBuddyResponse:Successful", "FixedBuddyResponse:" + current.Context.LogOnName);
                            return;
                        }
                    }

                    // Selected player is already a buddy.
                    sessions.SendMessage(current, "SelectBuddyResponse:Failure;BusyBuddy;" + message);
                }
            }
        }
Beispiel #18
0
        /// <summary>
        /// Implements the execution of the updateScore command.
        /// </summary>
        /// <param name="current">Current service instance.</param>
        /// <param name="sessions">Collection of all sessions.</param>
        /// <param name="message">Command arguments.</param>
        public void Execute(GameService current, GameSessions sessions, string message)
        {
            if (null == current.Context.BuddyInstance)
            {
                sessions.SendMessage(current, "UpdateScoreResponse:Failure;Buddy not found.");
                return;
            }
            else
            {
                if (string.IsNullOrEmpty(message))
                {
                    sessions.SendMessage(current, "UpdateScoreResponse:Failure;Score is not found.");
                    return;
                }

                 sessions.SendMessage(current.Context.BuddyInstance, "FixBuddyScore:" + message);
                 sessions.SendMessage(current, "UpdateScoreResponse:Successful");
            }
        }
Beispiel #19
0
 // 访问变量值
 public virtual Object Access(GameService game)
 {
     return null;
 }
Beispiel #20
0
 public override object Access(GameService game)
 {
     // TODO 触发器的参数化模块访问
     return null;
 }
Beispiel #21
0
 public void SetupServices()
 {
     TeamService = new TeamService(TeamDataService);
     GameService = new GameService(TeamService, GameDataService, TeamDataService);
 }
Beispiel #22
0
 void Awake()
 {
     gameService = FindObjectOfType <GameService>();
     value       = int.Parse(btn.GetComponentInChildren <TMP_Text>().text);
     btn.onClick.AddListener(delegate { OnClick(); });
 }
 public ActionResult PlayGames(string id)
 {
     var playerService = new PlayerService();
     var gameService = new GameService();
     var player1 = playerService.GetById(id);
     var availableGames = gameService.List(100, 0).ToList();
     var playergames = new PlayerGames()
     {
         Player = player1,
         AvailableGames = availableGames
     };
     return View(playergames);
 }
 public GameServiceUnitTests()
 {
     gameService = new GameService(mockAdventureService.Object, mockCharacterService.Object, mockMessageHandler.Object);
 }
        public void TestInitializer()
        {
            #region initialization entities

            const int GenreId1 = 1;
            const int GenreId2 = 2;
            const int GenreId3 = 3;
            const int GenreId4 = 4;

            genres = new[]
            {
                new Genre {
                    Id = GenreId1, Name = "Genre1"
                },
                new Genre {
                    Id = GenreId2, Name = "Genre2"
                },
                new Genre {
                    Id = GenreId3, Name = "SubGenre1", ParentGenreId = GenreId2
                },
                new Genre {
                    Id = GenreId4, Name = "SubSubGenre1", ParentGenreId = GenreId3
                }
            };

            platformTypes = new[]
            {
                new PlatformType {
                    Id = 1, Type = "Platform1"
                },
                new PlatformType {
                    Id = 2, Type = "Platform2"
                },
                new PlatformType {
                    Id = 3, Type = "Platform3"
                },
                new PlatformType {
                    Id = 4, Type = "Platform4"
                }
            };

            publishers = new[]
            {
                new Publisher
                {
                    Id          = 1,
                    CompanyName = "Company1",
                    Description = "Description1",
                    HomePage    = "page.com"
                }
            };

            games = new[]
            {
                new Game
                {
                    Id            = 1,
                    Name          = "Game1",
                    Description   = "Description1",
                    Key           = "game_1",
                    Genres        = new[] { genres[0], genres[2] },
                    PlatformTypes = new[] { platformTypes[0], platformTypes[2] },
                    Publisher     = publishers[0]
                },
                new Game
                {
                    Id            = 2,
                    Name          = "Game2",
                    Description   = "Description2",
                    Key           = "game_2",
                    Genres        = new[] { genres[2] },
                    PlatformTypes = new[] { platformTypes[1] },
                    Publisher     = publishers[0]
                },
                new Game
                {
                    Id            = 3,
                    Name          = "Game3",
                    Description   = "Description3",
                    Key           = "game_3",
                    Genres        = new[] { genres[0], genres[1] },
                    PlatformTypes = new[] { platformTypes[0], platformTypes[2] },
                    Publisher     = publishers[0]
                }
            };

            _rightPlatformTypeInputs = new List <GetDeletePlatformTypeInput>
            {
                new GetDeletePlatformTypeInput
                {
                    Id   = platformTypes[0].Id,
                    Type = platformTypes[0].Type
                },
                new GetDeletePlatformTypeInput
                {
                    Id   = platformTypes[2].Id,
                    Type = platformTypes[2].Type
                }
            };

            _wrongPlatformTypeInputs = new List <GetDeletePlatformTypeInput>
            {
                new GetDeletePlatformTypeInput
                {
                    Id   = 301,
                    Type = "Wrong1"
                },
                new GetDeletePlatformTypeInput
                {
                    Id   = 302,
                    Type = "Wrong2"
                }
            };
            _rightGenreInputs = new List <GetDeleteGenreInput>
            {
                new GetDeleteGenreInput
                {
                    Id   = genres[0].Id,
                    Name =
                        genres[0].Name
                },
                new GetDeleteGenreInput
                {
                    Id   = genres[1].Id,
                    Name =
                        genres[1].Name
                }
            };

            _wrongGenreInputs = new List <GetDeleteGenreInput>
            {
                new GetDeleteGenreInput
                {
                    Id   = 501,
                    Name = "Wrong1"
                },
                new GetDeleteGenreInput
                {
                    Id   = 502,
                    Name = "Wrong2"
                },
                new GetDeleteGenreInput
                {
                    Id   = 503,
                    Name = "Wrong3"
                }
            };

            #endregion

            #region initialization repositories, unit of work, logger, validation factory and game service

            _gameRepositoryMock = new Mock <IGameRepository>();
            _gameRepositoryMock.Setup(_ => _.Get()).Returns(games);
            _gameRepositoryMock.Setup(_ => _.Get(It.IsAny <int>()))
            .Returns((int id) => games.FirstOrDefault(_ => _.Id == id));
            _gameRepositoryMock.Setup(_ => _.Find(It.IsAny <Func <Game, bool> >()))
            .Returns((Func <Game, bool> predicate) => games.Where(predicate));

            _genreRepositoryMock = new Mock <IGenreRepository>();
            _genreRepositoryMock.Setup(_ => _.Get()).Returns(genres.ToList());
            _genreRepositoryMock.Setup(_ => _.Find(It.IsAny <Func <Genre, bool> >()))
            .Returns((Func <Genre, bool> predicate) => genres.ToList().Where(predicate));

            _platformTypeRepositoryMock = new Mock <IPlatformTypeRepository>();
            _platformTypeRepositoryMock.Setup(_ => _.Get()).Returns(platformTypes);
            _platformTypeRepositoryMock.Setup(_ => _.Find(It.IsAny <Func <PlatformType, bool> >()))
            .Returns(
                (Expression <Func <PlatformType, bool> > predicate) => platformTypes.Where(predicate.Compile()));

            _unitOfWorkMock = new Mock <IUnitOfWork>();
            _unitOfWorkMock.Setup(_ => _.GetGames()).Returns(_gameRepositoryMock.Object);
            _unitOfWorkMock.Setup(_ => _.GetGenres()).Returns(_genreRepositoryMock.Object);
            _unitOfWorkMock.Setup(_ => _.GetPlatformTypes()).Returns(_platformTypeRepositoryMock.Object);

            _validationFactoryMock = new Mock <IValidatorFactory>();
            _validationFactoryMock.Setup(_ => _.GetValidator <CreateUpdateGameInput>())
            .Returns(new CreateUpdateGameInputValidator());

            // .Returns(new CreateGameInputValidator(this._unitOfWorkMock.Object));
            _validationFactoryMock.Setup(_ => _.GetValidator <GetDeleteGameInput>())
            .Returns(new GetDeleteGameInputValidator(_unitOfWorkMock.Object));

            _validationFactoryMock.Setup(_ => _.GetValidator <CreateUpdateGenreInput>())
            .Returns(new CreateUpdateGenreInputValidator(_unitOfWorkMock.Object));

            _validationFactoryMock.Setup(_ => _.GetValidator <GetDeleteGenreInput>())
            .Returns(new GetDeleteGenreInputValidator(_unitOfWorkMock.Object));

            _validationFactoryMock.Setup(_ => _.GetValidator <GetDeletePlatformTypeInput>())
            .Returns(new GetDeletePlatformTypeInputValidator(_unitOfWorkMock.Object));

            _loggerMock = new Mock <ILogger>();

            _gameService = new GameService(
                _unitOfWorkMock.Object,
                _validationFactoryMock.Object,
                _loggerMock.Object);

            #endregion
        }
Beispiel #26
0
 public ServicePreloader(GameService games, AutoReactionTrainer reactionTrainer, IReminderSender reminders, ISentimentEvaluator sentiment, IUptime uptime, ISpacexNotificationsSender spacexReminders)
 {
     // Parameters to this services cause those other services to be eagerly initialised.
 }
Beispiel #27
0
 public MatchViewModel()
 {
     this.gameService  = new GameService();
     this.matchService = new MatchService();
     this.LoadData();
 }
        protected override async Task OnInitializedAsync()
        {
            DisableStartButton       = false;
            ChangeDurationOfToast    = 3;
            ShowToastForStartingGame = true;
            string userName     = HttpContextAccessor.HttpContext.User.Identity.Name;
            var    roomResponse = await RoomService.CreateAndJoinPracticeRoomAsync(userName);

            if (roomResponse.IsNew)
            {
                await GameService.AddRoomToGame(roomResponse.Room.Id);
            }
            else
            {
                if (roomResponse.Room.RoomType != RoomType.Practice.ToString())
                {
                    if (roomResponse.Room.RoomType == RoomType.Party.ToString())
                    {
                        NavigationManager.NavigateTo("/party");
                    }
                    else
                    {
                        NavigationManager.NavigateTo("/room");
                    }
                }
            }
            Room = new RoomVM(roomResponse.Room);
            ShowToastForOnePlayer = Room.RoomPlayers.Count() == 1 ? true : false;
            Username      = userName;
            RoomPlayer    = Room.RoomPlayers.FirstOrDefault(rp => rp.UserName == userName);
            hubConnection = new HubConnectionBuilder()
                            .WithUrl(NavigationManager.ToAbsoluteUri("/whoIsFasterSignalRHub"), conf =>
            {
                conf.HttpMessageHandlerFactory = (x) => new HttpClientHandler
                {
                    ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator,
                };
            })
                            .Build();

            hubConnection.On <string>("ReceiveRoom", (roomObject) =>
            {
                RoomDTO room = JsonSerializer.Deserialize <RoomDTO>(roomObject);
                var player   = room.RoomPlayers.FirstOrDefault(rp => rp.UserName == Username);

                if (player != null)
                {
                    Room       = new RoomVM(room);
                    RoomPlayer = new RoomPlayerVM(player);
                    if (Room.HasFinished)
                    {
                        hubConnection.DisposeAsync();
                    }
                    if (CurrentTextIndex == 0)
                    {
                        CurrentTextIndex = RoomPlayer.CurrentTextIndex;
                    }
                    StateHasChanged();
                }
            });

            await hubConnection.StartAsync();

            await EventService.AddConnectionToSignalRGroup(hubConnection.ConnectionId, Room.Id.ToString());
        }
Beispiel #29
0
 private List <IUnit> GetUnitsFromCurrentScene()
 {
     return(GameService.GetService <ISceneService>().CurrentScene.GetEntitiesOfType <IUnit>());
 }
Beispiel #30
0
 public override Object Access(GameService game)
 {
     return Data;
 }
Beispiel #31
0
    void Initialize()
    {
        DontDestroyOnLoad(gameObject);

        Application.targetFrameRate = targetFrameRate;

        RestartSessionMetrics();

        // soomla store stuff
        StoreEvents.OnItemPurchased += onItemPurchased;
        StoreEvents.OnRestoreTransactionsFinished += onRestoreTransactionsFinished;
        if (!SoomlaStore.Initialized)
        {
            SoomlaStore.Initialize(new SoomlaStoreAssets());
        }

        gameDataBlob = new GameDataBlob();
        gameDataBlob.Init(saveDataFormatVersion);

        // create generic game service class
        #if UNITY_IOS
        gameService = new AppleGameCenterAPI();
        gameService.Initialize();
        #endif
        #if UNITY_ANDROID
        gameService = new GooglePlayAPI();
        #endif
        #if UNITY_EDITOR
        gameService = new GameServiceMock();
        #endif
        gameService.Initialize();

        // callback is managed in gameService API
        pendingCloudSaveOperation = 1;
    }
Beispiel #32
0
 public Items(GameService gameService)
 {
     _gameService = gameService;
 }
Beispiel #33
0
 public Gambling(GameService gameService)
 {
     _gameService = gameService;
 }
 public GameValuesController(GameService gameService)
 {
     _gameService = gameService;
 }
    public bool continueGame(Boolean nextIsPressed, int scoreForQuestion)
    {
        GameService _gameService = new GameService();
        if (nextIsPressed && (!StaticMembers._questionList.Count().Equals(0)))
        {
            StaticMembers.question = StaticMembers._questionList.First();
            StaticMembers._questionNumber += 1;
            nextIsPressed = false;
            StaticMembers._questionList.Remove(StaticMembers.question);
            if (!scoreForQuestion.Equals(0))
            {
                StaticMembers._game.number_right_questions += 1;
                StaticMembers._game.score += scoreForQuestion;
                _gameService.Update(StaticMembers._game);
            }
        }

        if (nextIsPressed && StaticMembers._questionList.Count().Equals(0))
        {
            return false;
        }
        return true;
    }
 public void OnOnlineGame()
 {
     Hide();
     GameService.PlayOnline();
 }
 public GamesController(IHostingEnvironment env, GameService gameService, CardChargeService cardChargeService) : base(env)
 {
     _gameService       = gameService;
     _cardChargeService = cardChargeService;
 }
 public SelectAverageRatingOfGame(ReviewService reviewService, GameService gameService)
 {
     this.reviewService = reviewService;
     this.gameService   = gameService;
 }
 /// <summary>
 /// Initialize the controller
 /// </summary>
 /// <param name="_service">GameService singleton instance</param>
 public GameController(GameService _service)
 {
     gameServiceInstance = _service;
 }
Beispiel #40
0
 public GameController(ILogger <GameController> logger)
 {
     _logger     = logger;
     gameService = new GameService();
 }
Beispiel #41
0
        public String PropertyName; // 访问属性名

        #endregion Fields

        #region Methods

        public override Object Access(GameService game)
        {
            // NOTE 注意这里是访问器,取得的属性不能够直接修改,因为对于值类型数据,对其装箱返回值的修改无法影响原对象
            Object obj = Holder.Access(game);
            return NETFramework.GetPropertyByName(obj, PropertyName);
        }
Beispiel #42
0
 public void InitTest()
 {
     this._algorithm = new GameService();
     this._bigArea   = _algorithm.CreateGame();
 }
Beispiel #43
0
 public override Object Access(GameService game)
 {
     return Variable.GetValue();
 }
Beispiel #44
0
 public SearchViewModel(GameService gs)
 {
     this.gs = gs;
     InitCommands();
 }
Beispiel #45
0
 public JobController(JobService jobService, GameService gameService)
 {
     this.jobService  = jobService;
     this.gameService = gameService; //HACK: to instantiate as singelton
 }
Beispiel #46
0
 public HomeController()
 {
     this.loginManager = new LoginManager(Data.Data.Context);
     this.homeService  = new HomeService(Data.Data.Context);
     this.gameService  = new GameService(Data.Data.Context);
 }
Beispiel #47
0
    // Use this for initialization
    void Start()
    {
        //App42Log.SetDebug(true);

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

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

        if (loadScoreOnLoad)
            loadScore (true);
    }
Beispiel #48
0
        /// <summary>
        /// Handle the sending of a player's character list.
        /// </summary>
        public override void Execute()
        {
            var localPlayer = _player;

            var dbClient = GameService.GetDbClient();

            var bldr = new PacketBuilder(Common.Database.Opcodes.GET_CHARACTER_LIST_DATA);

            bldr.WriteInt(localPlayer.index);

            bldr.WriteByte((byte)GameService.GetServerId());

            dbClient.Write(bldr.ToPacket(), (_data, _length) =>
            {
                int characterCount = BitConverter.ToInt32(_data);

                List <Common.Database.Structs.Game.Character> characters = Serializer.Deserialize <List <Common.Database.Structs.Game.Character> >(_data.Skip(4).ToArray());

                List <int> slots = new List <int>(new int[] { 0, 1, 2, 3, 4 });

                foreach (var character in characters)
                {
                    slots.Remove(character.slot);

                    var responseBldr = new PacketBuilder(Common.Packets.Opcodes.CHARACTER_LIST);

                    responseBldr.WriteByte(character.slot);

                    responseBldr.WriteInt(character.characterId);

                    // Unknown (Character creation time?)
                    responseBldr.WriteInt(0);

                    responseBldr.WriteShort(character.level);

                    responseBldr.WriteByte(character.race);

                    responseBldr.WriteByte(character.gameMode);

                    responseBldr.WriteByte(character.hair);

                    responseBldr.WriteByte(character.face);

                    responseBldr.WriteByte(character.height);

                    responseBldr.WriteByte(character.profession);

                    responseBldr.WriteByte(character.sex);

                    responseBldr.WriteShort(character.map);

                    responseBldr.WriteShort(character.strength);
                    responseBldr.WriteShort(character.dexterity);
                    responseBldr.WriteShort(character.resistance);
                    responseBldr.WriteShort(character.intelligence);
                    responseBldr.WriteShort(character.wisdom);
                    responseBldr.WriteShort(character.luck);

                    // Unknown array
                    for (int j = 0; j < 11; j++)
                    {
                        responseBldr.WriteByte(0);
                    }

                    // The item types
                    responseBldr.WriteBytes(character.itemTypes);

                    // The item type ids
                    responseBldr.WriteBytes(character.itemTypeIds);

                    // Write 535 null bytes
                    for (int j = 0; j < 535; j++)
                    {
                        responseBldr.WriteByte(0);
                    }

                    responseBldr.WriteBytes(character.name);

                    // Write the character deletion flag
                    responseBldr.WriteByte(0);

                    localPlayer.Write(responseBldr.ToPacket());
                }

                // Loop through the empty slots
                foreach (byte slot in slots)
                {
                    var responseBldr = new PacketBuilder(Common.Packets.Opcodes.CHARACTER_LIST);

                    responseBldr.WriteByte(slot);

                    // Write the empty character id
                    responseBldr.WriteInt(0);

                    localPlayer.Write(responseBldr.ToPacket());
                }
            });
        }
 public GameController(GameService gameService, RoundOfGame roundOfGame)
 {
     _gameService = gameService;
     _roundOfGame = roundOfGame;
 }
Beispiel #50
0
 public RegisterCompletedGame(IOutputWriter outputWriter, GameService gameService)
 {
     this.outputWriter = outputWriter;
     this.gameService  = gameService;
 }
 public void Setup()
 {
     _testRepo = new GameRepo();
     _gameService = new GameService(_testRepo);
 }
Beispiel #52
0
 public override void use(Room room, Planet planet, Player player, GameService game)
 {
     Console.WriteLine("\n\tYou are hiding behind the large bolder.");
     room.PlaceToChange = true;
 }
        public static string GameAbbreviation(GameService svc)
        {
            if (svc == GameService.Elemental_Kingdoms) return "EK";
            if (svc == GameService.Lies_of_Astaroth) return "LoA";
            if (svc == GameService.Magic_Realms) return "MR";
            if (svc == GameService.Elves_Realm) return "ER";
            if (svc == GameService.Shikoku_Wars) return "SW";

            return "?";
        }
Beispiel #54
0
        /// <summary>
        ///     Initialization of our service provider and bot
        /// </summary>
        /// <returns>
        ///     The <see cref="Task" />.
        /// </returns>
        public static async Task StartAsync()
        {
            // This ensures that our bots setup directory is initialized and will be were the database config is stored.
            if (!Directory.Exists(Path.Combine(AppContext.BaseDirectory, "setup/")))
            {
                Directory.CreateDirectory(Path.Combine(AppContext.BaseDirectory, "setup/"));
            }

            LogHandler.LogMessage("Loading initial provider", LogSeverity.Verbose);
            var services = new ServiceCollection()
                           .AddSingleton <DatabaseHandler>()
                           .AddSingleton(x => x.GetRequiredService <DatabaseHandler>().Execute <ConfigModel>(DatabaseHandler.Operation.LOAD, id: "Config"))
                           .AddSingleton(new CommandService(new CommandServiceConfig
            {
                ThrowOnError    = false,
                IgnoreExtraArgs = false,
                DefaultRunMode  = RunMode.Async
            }))
                           .AddSingleton(
                x =>
            {
                if (File.Exists(Path.Combine(AppContext.BaseDirectory, "setup/DBConfig.json")))
                {
                    var Settings = JsonConvert.DeserializeObject <DatabaseObject>(File.ReadAllText("setup/DBConfig.json"));
                    return(Settings);
                }

                return(new DatabaseObject());
            })
                           .AddSingleton(x =>
            {
                if (File.Exists(Path.Combine(AppContext.BaseDirectory, "setup/DBConfig.json")))
                {
                    var Settings = JsonConvert.DeserializeObject <DatabaseObject>(File.ReadAllText("setup/DBConfig.json"));
                    if (!string.IsNullOrEmpty(Settings.ProxyUrl))
                    {
                        return(new HttpClientHandler {
                            Proxy = new WebProxy(Settings.ProxyUrl), UseProxy = true
                        });
                    }
                }

                return(new HttpClientHandler());
            })
                           .AddSingleton(x => new HttpClient(x.GetRequiredService <HttpClientHandler>()))
                           .AddSingleton <BotHandler>()
                           .AddSingleton <EventHandler>()
                           .AddSingleton <Events>()
                           .AddSingleton(x => x.GetRequiredService <DatabaseHandler>().InitializeAsync().Result)
                           .AddSingleton(new Random(Guid.NewGuid().GetHashCode()))
                           .AddSingleton(x =>
                                         new DiscordShardedClient(
                                             new DiscordSocketConfig
            {
                MessageCacheSize    = 0,
                AlwaysDownloadUsers = false,
                LogLevel            = LogSeverity.Info,
                TotalShards         = x.GetRequiredService <ConfigModel>().Shards
            }))
                           .AddSingleton(
                x =>
            {
                var config = x.GetRequiredService <ConfigModel>().Prefix;
                var store  = x.GetRequiredService <IDocumentStore>();
                return(new PrefixService(config, store));
            })
                           .AddSingleton <TagService>()
                           .AddSingleton <PartnerService>()
                           .AddSingleton <LevelService>()
                           .AddSingleton <ChannelService>()
                           .AddSingleton <HomeService>()
                           .AddSingleton <ChannelHelper>()
                           .AddSingleton <PartnerHelper>()
                           .AddSingleton <Interactive>()
                           .AddSingleton(
                x =>
            {
                var limits = new TranslateLimitsNew(x.GetRequiredService <IDocumentStore>());
                limits.Initialize();
                return(limits);
            })
                           .AddSingleton(x => new TranslateMethodsNew(x.GetRequiredService <DatabaseObject>(), x.GetRequiredService <TranslateLimitsNew>(), x.GetRequiredService <ConfigModel>()))
                           .AddSingleton <LevelHelper>()
                           .AddSingleton <TranslationService>()
                           .AddSingleton(
                x =>
            {
                var birthdayService = new BirthdayService(x.GetRequiredService <DiscordShardedClient>(), x.GetRequiredService <IDocumentStore>());
                birthdayService.Initialize();
                return(birthdayService);
            })
                           .AddSingleton(
                x =>
            {
                var gameService = new GameService(x.GetRequiredService <IDocumentStore>(), x.GetRequiredService <DatabaseObject>());
                gameService.Initialize();
                return(gameService);
            })
                           .AddSingleton <TimerService>()
                           .AddSingleton <DBLApiService>()
                           .AddSingleton <WaitService>();

            var provider = services.BuildServiceProvider();

            LogHandler.LogMessage("Initializing HomeService", LogSeverity.Verbose);
            provider.GetRequiredService <HomeService>().Update();
            LogHandler.LogMessage("Initializing PrefixService", LogSeverity.Verbose);
            await provider.GetRequiredService <PrefixService>().InitializeAsync();

            LogHandler.LogMessage("Initializing BotHandler", LogSeverity.Verbose);
            await provider.GetRequiredService <BotHandler>().InitializeAsync();

            LogHandler.LogMessage("Initializing EventHandler", LogSeverity.Verbose);
            await provider.GetRequiredService <EventHandler>().InitializeAsync();


            // Indefinitely delay the method from finishing so that the program stays running until stopped.
            await Task.Delay(-1);
        }
 public GameHub(GameService gameService)
 {
     _gameService = gameService;
 }
Beispiel #56
0
 public CardController(GameService gameService, CardService cardService)
 {
     _gameService = gameService;
     _cardService = cardService;
 }
Beispiel #57
0
    /// <summary>
    /// Connect To GameService -> Login Or SignUp
    /// It May Throw Exception
    /// </summary>
    private async Task ConnectToGamesService()
    {
        //connecting to GamesService
        Status.text = "Status : Connecting...";
        startGameBtn.interactable = false;
        SwitchToRegisterOrLogin.GetComponent <Button>().onClick.AddListener(() =>
        {
            if (NickName.IsActive())
            {
                NickName.gameObject.SetActive(false);
                SwitchToRegisterOrLogin.GetComponent <Text>().text = "Dont have an account? Register!";
            }
            else
            {
                NickName.gameObject.SetActive(true);
                SwitchToRegisterOrLogin.GetComponent <Text>().text = "Have an Account? Login!";
            }
        });

        if (FileUtil.IsLoginBefore())
        {
            try
            {
                await GameService.Login(FileUtil.GetUserToken());

                // Disable LoginUI
                startMenu.enabled   = true;
                LoginCanvas.enabled = false;
            }
            catch (Exception e)
            {
                Status.color = Color.red;
                if (e is GameServiceException)
                {
                    Status.text = "GameServiceException : " + e.Message;
                }
                else
                {
                    Status.text = "InternalException : " + e.Message;
                }
            }
        }
        else
        {
            // Enable LoginUI
            startMenu.enabled   = false;
            LoginCanvas.enabled = true;

            Submit.onClick.AddListener(async() =>
            {
                try
                {
                    if (NickName.IsActive()) // is SignUp
                    {
                        var nickName = NickName.text.Trim();
                        var email    = Email.text.Trim();
                        var pass     = Password.text.Trim();

                        if (string.IsNullOrEmpty(nickName) &&
                            string.IsNullOrEmpty(email) &&
                            string.IsNullOrEmpty(pass))
                        {
                            LoginErr.text = "Invalid Input!";
                        }
                        else
                        {
                            var userToken = await GameService.SignUp(nickName, email, pass);
                            FileUtil.SaveUserToken(userToken);
                        }
                    }
                    else
                    {
                        var email = Email.text.Trim();
                        var pass  = Password.text.Trim();

                        if (string.IsNullOrEmpty(email) && string.IsNullOrEmpty(pass))
                        {
                            LoginErr.text = "Invalid Input!";
                        }
                        else
                        {
                            var userToken = await GameService.Login(email, pass);
                            FileUtil.SaveUserToken(userToken);

                            // Disable LoginUI
                            startMenu.enabled   = true;
                            LoginCanvas.enabled = false;
                        }
                    }
                }
                catch (Exception e)
                {
                    if (e is GameServiceException)
                    {
                        LoginErr.text = "GameServiceException : " + e.Message;
                    }
                    else
                    {
                        LoginErr.text = "InternalException : " + e.Message;
                    }
                }
            });
        }
    }
Beispiel #58
0
 /// <summary>
 /// 初始化外部系统
 /// </summary>
 static void initializeSystems()
 {
     gameSys  = gameSys ?? GameSystem.Get();
     sceneSys = sceneSys ?? SceneSystem.Get();
     gameSer  = gameSer ?? GameService.Get();
 }
Beispiel #59
0
 public void Setup()
 {
     _gameStateRepository = new InMemoryGameStateRepository();
     _gameService = new GameService(_gameStateRepository);
 }
 public GameStoreApp()
 {
     this.cart        = new HashSet <Game>();
     this.userService = new UserService();
     this.gameService = new GameService();
 }