public PacMan(Game game) : base(game) { // TODO: Construct any child components her pi = 0; input = (InputHandler)game.Services.GetService(typeof(IInputHandler)); //Make sure input service exists if (input == null) { throw new Exception("PacMan Depends on Input service please add input service before you add PacMan."); } console = (GameConsole)game.Services.GetService(typeof(IGameConsole)); //Make sure input service exists if (console == null) { throw new Exception("PacMan Depends on Console service please add Console service before you add PacMan."); } score = (ScoreService)game.Services.GetService(typeof(IScoreService)); //Make sure input service exists if (console == null) { throw new Exception("PacMan Depends on Score service please add Score service before you add PacMan."); } }
public void GetAspectScores_InputIsAnswers_AspectScores() { var answers = new List <AnsweredQuestionDTO>() { new AnsweredQuestionDTO { Aspect = 1, Multiplier = 0.3f }, new AnsweredQuestionDTO { Aspect = 1, Multiplier = 0.2f }, new AnsweredQuestionDTO { Aspect = 2, Multiplier = 0.1f } }; var scoreService = new ScoreService(); var scores = scoreService.GetAspectScores(answers); Assert.Equal(0.25f, scores[1], 1); Assert.Equal(0.1f, scores[2], 1); }
public void StoryRuleShouldReturn0WhenAllVotesCorrect() { var storyTeller = player4; var storyCard = card4; var votes = new List <Vote> { new Vote(player1, storyCard), new Vote(player2, storyCard), new Vote(player3, storyCard) }; var rules = new List <IScoringRule> { new BonusRule(), new CorrectRule(), new StoryTellerRule() }; var scoreService = new ScoreService(rules); var scoreBoard = scoreService.VallyVotes(votes, player4, storyCard); var player1Score = scoreBoard.Find(board => board.Player == player1); var player2Score = scoreBoard.Find(board => board.Player == player2); var player3Score = scoreBoard.Find(board => board.Player == player3); var player4Score = scoreBoard.Find(board => board.Player == player4); player1Score.Score.Should().Be(2); player2Score.Score.Should().Be(2); player3Score.Score.Should().Be(2); player4Score.Should().BeNull(); }
/// <summary> /// 根据成绩ID修改成绩分数 /// </summary> /// <param name="scoreId"></param> /// <param name="result"></param> /// <returns></returns> public static async Task ChangeScore(Guid scoreId, int result) { using (var scoreSvc = new ScoreService()) { await scoreSvc.ChangeScore(scoreId, result); } }
public ScoreApi(RequestContext request) { _request = request; IScoreService scoreService = new ScoreService(); _scoreController = new ScoreController(scoreService); }
private void Awake() { YouLose.gameObject.SetActive(false); InstanceCache.Flush(); gameRepository = InstanceCache.GetOrInstanciate <InMemoryGameRepository>(() => new InMemoryGameRepository()); resultRepository = InstanceCache.GetOrInstanciate <InMemoryResultRepository>(() => new InMemoryResultRepository()); scoreService = InstanceCache.GetOrInstanciate <LocalScoreService>(() => new LocalScoreService()); resultRepository.Clear(); gameRepository.Clear(); scoreService.Reset(); gamePresenter = InstanceCache.GetOrInstanciate <GamePresenter>( () => { resultGenerator = new ResultGenerator(4, new AdditionOperator(), new RandomNumberGenerator(5, 15)); return(new GamePresenter( this, new CreateGame(gameRepository, new FixedInitialNumber(), resultGenerator, resultRepository), new Guess(gameRepository, resultRepository, resultGenerator, scoreService), scoreService)); }); }
static void Main(string[] args) { var userProvider = new UsersDataProvider(_connection); var scoreProvider = new ScoreDataProvider(_connection); var scoreService = new ScoreService(scoreProvider, userProvider); Stopwatch watch = new Stopwatch(); watch.Start(); for (int i = 0; i < 100; i++) { scoreService.AddScore($"Player_{i}", $"Victim_{i}", getRandWeapon(), getRandBodyPart()).Wait(); for (int j = 0; j < 10 + i; j++) { scoreService.AddSuicide("Nub").Wait(); scoreService.AddTeamKill($"Player_{i}", $"Victim_{i}", getRandWeapon(), getRandBodyPart()).Wait(); scoreService.AddSpawnKill($"Player_{i}", $"Victim_{i}", getRandWeapon(), getRandBodyPart()).Wait(); } } watch.Stop(); Console.WriteLine($"Done\nTime elapsed: {watch.Elapsed}"); Console.Read(); }
private ScoreService CreateScoreService() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new ScoreService(userId); return(service); }
public ActionResult <IEnumerable <string> > Get() { ScoreService scoreService = new ScoreService(_dbConnectionFactory); var highscores = scoreService.GetHighscores(); return(highscores.Select(x => x.Name).ToArray()); }
public GamePresenter(MainComponent mainComponent, CreateGame createGame, Guess guess, ScoreService scoreService) { this.mainComponent = mainComponent; this.createGame = createGame; this.guess = guess; this.scoreService = scoreService; }
void Awake() { ScoreService.NewGame(this.maps.Length); this.music = GetComponent <LevelAudio>(); this.music.Initialize(); Initialize(); }
private IScoreService ScoreService() { var scoreService = new ScoreService(); scoreService.ClearScores(); return(scoreService); }
public PacMan(Game game) : base(game) { // TODO: Construct any child components her playerIndex = 0; //PacMan Depends on some game sevices #region Dependancy Services input = (InputHandler)game.Services.GetService(typeof(IInputHandler)); //Make sure input service exists if (input == null) //if it doesn't add it this is lazy loading { throw new Exception("PacMan Depends on Input service please add input service before you add PacMan."); } console = (GameConsole)game.Services.GetService(typeof(IGameConsole)); //Make sure input service exists if (console == null) //if it doesn't add it { throw new Exception("PacMan Depends on Console service please add Console service before you add PacMan."); } score = (ScoreService)game.Services.GetService(typeof(IScoreService)); //Make sure input service exists if (console == null) //if it doesn't add it { throw new Exception("PacMan Depends on Score service please add Score service before you add PacMan."); } #endregion }
static void Main(string[] args) { const string dbFileName = "Scores.sqlite"; Console.WriteLine("Hello World!"); // todo: Use dependency injection var dbConnectionFactor = new SqliteDbConnectionFactory(dbFileName); if (!File.Exists(dbFileName)) { dbConnectionFactor.CreateDatabase(); } ScoreService scoreService = new ScoreService(dbConnectionFactor); scoreService.AddHighscore(new Highscore() { Name = "Fred", Score = 123 }); scoreService.AddHighscore(new Highscore() { Name = "Frank", Score = 999 }); var highscores = scoreService.GetHighscores(); foreach (var highscore in highscores) { Console.WriteLine(highscore); } Console.ReadLine(); }
public Score(string category) { scoreService = new ScoreService(category); highestStreak = scoreService.GetScore(HIGHEST_STREAK); answered = scoreService.GetScore(ANSWERED); correct = scoreService.GetScore(CORRECT); }
public ActionResult <string> Get(int id) { ScoreService scoreService = new ScoreService(_dbConnectionFactory); var highscores = scoreService.GetHighscores(); var highscore = highscores.Single(x => x.Id == id); return(highscore.Name); }
// GET: Score public ActionResult Index() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new ScoreService(userId); var model = service.GetScores(); return(View(model)); }
internal static ScoreService getInstance() { if (instance == null) { instance = new ScoreService(); } return(instance); }
public override void Execute() { Retain(); ScoreService.Dispatcher.AddListener(Demo1ServiceEvent.RequsetScore, OnComplete); ScoreService.RequestScore("http://xxx.xxx.xxx"); }
public void ShouldReturnIntForAnyCPF() { var serviceProvider = new ServiceCollection().AddHttpClient().BuildServiceProvider(); var httpClientFactory = serviceProvider.GetService <IHttpClientFactory>(); var scoreService = new ScoreService(httpClientFactory); var result = scoreService.GetScore("teste").Result; Assert.NotNull(result); }
private void buttonCompute_Click(object sender, EventArgs e) { List <miniScore> GetSelect = GetCheckBoxSelect(); GPAInfo StuGPA = ScoreService.ComputeUI(GetSelect); labelGPA.Text = StuGPA.GPA.ToString(); labelAverage.Text = StuGPA.AverageScore.ToString(); labelCreditAll.Text = StuGPA.CreditSum.ToString(); }
public Experience(IExperienceUi experienceUi, ScoreService score, ExperienceService experienceService, IGameEvents gameEvents) { _experienceUi = experienceUi; _score = score; _experienceService = experienceService; _gameEvents = gameEvents; Init(); }
public ActionResult <string> ShowMoney() { var idClaim = User.Claims.FirstOrDefault(x => x.Type.Equals(JwtRegisteredClaimNames.Jti, StringComparison.InvariantCultureIgnoreCase)); if (idClaim != null) { Guid tokenGuid = Guid.Parse(idClaim.ToString().Remove(0, 5)); var scService = new ScoreService(); var workerCount = 0; var oldCount = 1; int count = 2; string[] numStringNew = new string[count]; string[] numString = new string[count]; while (workerCount != oldCount) { try { var showScore = scService.ReturnScore(new ScoreModel { ClientId = tokenGuid, Id = workerCount }, "SELECT * FROM viewscores WHERE clientid = @clientid AND id >= @id AND exist = TRUE;"); oldCount = workerCount; workerCount = showScore.Id + 1; numString = new string[count]; numStringNew[count - 2] = showScore.NumScore; numStringNew[count - 1] = showScore.Cash.ToString(); for (int i = 0; i < count; i++) { numString[i] = numStringNew[i]; } count = count + 2; numStringNew = new string[count]; for (int i = 0; i < count - 2; i++) { numStringNew[i] = numString[i]; } } catch { workerCount = oldCount; } } List <Scores> scores = new List <Scores>(); for (int i = 0; i < count / 2 - 1; i++) { Scores num = new Scores() { Number = numString[i * 2], Amount = numString[i * 2 + 1] }; scores.Add(num); } return(Ok(scores)); } return(BadRequest("No claim")); }
public FormScores() { InitializeComponent(); _scoreService = new ScoreService(); EnableButtonEditAndDelete(false); LoadData(); }
public Guess(GameRepository gameRepository, IResultRepository resultRepository, ResultGenerator resultGenerator, ScoreService scoreService) { this.gameRepository = gameRepository; this.resultRepository = resultRepository; this.resultGenerator = resultGenerator; this.scoreService = scoreService; }
private void UpdateRanking() { Ranking.Clear(); var games = new ResultService().GetGamesThatArePlayed(); var ranking = new ScoreService().GetRanking(Users, games); foreach (var score in ranking) { Ranking.Add(score); } }
private void Get_Info() { int userid = int.Parse(Session["UserID"].ToString()); DataTable dt = ScoreService.SelectAll(userid); if (dt != null && dt.Rows.Count != 0) { ListView1.DataSource = dt; ListView1.DataBind(); } }
public void GetScore_OnExecuteWith5Hints_SetsOverallScoreTo0() { var scoreService = new ScoreService(); var pageAnalysis = new PageAnalysis() { SummaryResults = { new SummaryResult() { Analysis = new Analysis() { Results = new List <AnalyzeResult>() { new AnalyzeResult() { ResultRules = new List <ResultRule>() { new ResultRule() { Type = ResultType.Hint }, new ResultRule() { Type = ResultType.Hint }, new ResultRule() { Type = ResultType.Hint }, new ResultRule() { Type = ResultType.Hint }, new ResultRule() { Type = ResultType.Hint }, } } } } } } }; var result = scoreService.GetScore(pageAnalysis); Assert.IsNotNull(result); Assert.AreEqual(0, result.ErrorCount); Assert.AreEqual(0, result.WarningCount); Assert.AreEqual(5, result.HintCount); Assert.AreEqual(0, result.SuccessCount); Assert.AreEqual(0, result.OverallScore); }
public Result <IList <Score> > GetAll() { var result = new Result <IList <Score> >(); ScoreService ScoreService = new ScoreService(); var lstClient = ScoreService.Get(); result.Value = (IList <Score>)lstClient; result.IsSuccess = true; return(result); }
public static void Initialize(GameContext context) { _scoreService = new ScoreService(); // Gets each day's stats the number of days before today int daysFromToday = 5; Calculate(context, daysFromToday); JobManager.AddJob(() => UserScoreSeed.Initialize(context), s => s.WithName("userScore") .ToRunNow()); }
public void Should_allow_to_save_current_statistics() { // Arrange var repository = Substitute.For<IRepository>(); var scorerService = new ScoreService(repository); // Act scorerService.Roll(5); scorerService.Roll(5); var statistics = scorerService.GetStatistics(); scorerService.SaveStatistics(); // Assert repository.Received(1) .Save(statistics); }
public void Should_load_statistics_from_file() { // Arrange var service = new ScoreService(new XmlRepository()); int?[] fakeStatistics = new int?[21]; fakeStatistics[0] = 10; fakeStatistics[2] = 5; fakeStatistics[3] = 1; using (var writer = File.OpenWrite(Path.Combine(Path.GetTempPath(), "statistics.xml"))) { XmlSerializer serializer = new XmlSerializer(typeof(int?[])); serializer.Serialize(writer, fakeStatistics); writer.Close(); } // Act service.LoadStatistics(); var score = service.CalculateScore(); // Assert score.Should().Be(22); }
public void Should_save_statistics_to_xml_file() { // Arrange var scoreService = new ScoreService(new XmlRepository()); // Act scoreService.Roll(3); scoreService.SaveStatistics(); // Assert string path = Path.Combine(Path.GetTempPath(), "statistics.xml"); using (var reader = File.OpenText(path)) { XmlSerializer serializer = new XmlSerializer(typeof(int?[])); var statistics = (int?[])serializer.Deserialize(reader); statistics.Should().ContainSingle(s => s.HasValue, "Only one record should be saved"); reader.Close(); } // Tear down File.Delete(path); }