<commit_before>﻿using System;
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Interfaced;
using Akka.Interfaced.LogFilter;
using Common.Logging;
using Domain;

namespace GameServer
{
    [Log]
    public class GameBotActor : InterfacedActor, IGameObserver
    {
        private ILog _logger;
        private GameRef _game;
        private long _userId;
        private string _userName;
        private GamePlayerRef _gamePlayer;
        private int _playerId;
        private int[,] _boardGridMarks = new int[Rule.BoardSize, Rule.BoardSize];
        private bool _isPlaying;

        public GameBotActor(ClusterNodeContext clusterContext,
                            GameRef game, long userId, string userName)
        {
            _logger = LogManager.GetLogger($"GameBotActor({userId}, {userName})");
            _game = game;
            _userId = userId;
            _userName = userName;
        }

        protected override async Task OnStart(bool restarted)
        {
            try
            {
                var observer = CreateObserver<IGameObserver>();
                var ret = await _game.Join(_userId, _userName, observer, null);
                _gamePlayer = _game.Cast<GamePlayerRef>().WithRequestWaiter(this);
                _playerId = ret.Item1;
            }
            catch (Exception e)
            {
                _logger.ErrorFormat("Failed to join game({0})", e, _game.CastToIActorRef().Path);
                Self.Tell(InterfacedPoisonPill.Instance);
            }
        }

        protected override async Task OnGracefulStop()
        {
            try
            {
                await _game.Leave(_userId);
            }
            catch (Exception e)
            {
                _logger.ErrorFormat("Failed to leave game({0})", e, _game.CastToIActorRef().Path);
            }
        }
<commit_msg>Remove bot's unnecessary leave from room.<commit_after>﻿using System;
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Interfaced;
using Akka.Interfaced.LogFilter;
using Common.Logging;
using Domain;

namespace GameServer
{
    [Log]
    public class GameBotActor : InterfacedActor, IGameObserver
    {
        private ILog _logger;
        private GameRef _game;
        private long _userId;
        private string _userName;
        private GamePlayerRef _gamePlayer;
        private int _playerId;
        private int[,] _boardGridMarks = new int[Rule.BoardSize, Rule.BoardSize];
        private bool _isPlaying;

        public GameBotActor(ClusterNodeContext clusterContext,
                            GameRef game, long userId, string userName)
        {
            _logger = LogManager.GetLogger($"GameBotActor({userId}, {userName})");
            _game = game;
            _userId = userId;
            _userName = userName;
        }

        protected override async Task OnStart(bool restarted)
        {
            try
            {
                var observer = CreateObserver<IGameObserver>();
                var ret = await _game.Join(_userId, _userName, observer, null);
                _gamePlayer = _game.Cast<GamePlayerRef>().WithRequestWaiter(this);
                _playerId = ret.Item1;
            }
            catch (Exception e)
            {
                _logger.ErrorFormat("Failed to join game({0})", e, _game.CastToIActorRef().Path);
                Self.Tell(InterfacedPoisonPill.Instance);
            }
        }

        protected override async Task OnGracefulStop()
        {
            try
            {
                if (_gamePlayer != null)
                    await _game.Leave(_userId);
            }
            catch (Exception e)
            {
                _logger.ErrorFormat("Failed to leave game({0})", e, _game.CastToIActorRef().Path);
            }
        }

{'fraction_non_alphanumeric': 0.08436593725283417, 'fraction_numerical': 0.0015818613234906407, 'mean_word_length': 1.7917586460632817, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1759498', 'n_tokens_mistral': 1006, 'n_tokens_neox': 993, 'n_words': 238}