public async Task TellGameEventAsync(gameInfo evt)
        {
            var resp = $"For {_gameId} :: INN {evt.inning}  COUNT {evt.balls}-{evt.strikes}-{evt.outs}  {evt.home_team} {evt.home_score} - {evt.visiting_team} {evt.visitor_score}";

            Console.WriteLine(resp);

            await Helpers.DaprClient.PublishEventAsync <gameInfo>("pubsub", "gameEvent", evt);

            if (evt.is_end_game == "T")
            {
                var homeTeamProxy     = ActorProxy.Create <ITeam>(new ActorId(evt.home_team), "Team");
                var visitingTeamProxy = ActorProxy.Create <ITeam>(new ActorId(evt.visiting_team), "Team");

                var homeMsg = new completedGame
                {
                    game_count = 1,
                    team       = evt.home_team,
                    is_win     = (evt.home_score > evt.visitor_score)
                };

                var visitMsg = new completedGame
                {
                    game_count = 1,
                    team       = evt.visiting_team,
                    is_win     = evt.visitor_score > evt.home_score
                };

                await homeTeamProxy.TellHandleGameCompleted(homeMsg);

                await visitingTeamProxy.TellHandleGameCompleted(visitMsg);
            }
        }
Exemple #2
0
        public async Task TellHandleGameCompleted(completedGame msg)
        {
            _games  += 1;
            _wins   += msg.is_win ? 1 : 0;
            _losses += msg.is_win ? 0 : 1;

            Console.WriteLine($"{_teamId}: {_wins} - {_losses} out of {_games}.\nThey have {_hits} hits in {_atBats} ABs with {_homeruns} HRs and {_rbis} RBIs");
        }