private void RemoveActiveStrategy()
        {
            if (_activeStrategy == null)
            {
                return;
            }

            var revokePerPlayer = EventMap.Instance.RevokeStrategyEvents(_activeStrategy.strategyId, Time.CurrentTurn);

            foreach (int playerId in revokePerPlayer.Keys)
            {
                if (revokePerPlayer.TryGetValue(playerId, out List <TimedEvent> events))
                {
                    Incentives incentives = new Incentives(events)
                    {
                        UserId = playerId
                    };
                    BackendWorker.GetInstance().SendReliable(incentives);
                }
            }

            EventMap.Instance.CleanupWithStrategyId(_activeStrategy.strategyId);

            _activeStrategy.Deinitialize();
            _activeStrategy = null;
        }
 public static void CreateInstance()
 {
     if (_instance == null)
     {
         _instance = new BackendWorker();
     }
 }
        internal ConflictStrategy ChangeActiveStrategy()
        {
            RemoveActiveStrategy();

            _activeStrategy = new StateStrategy(BackendWorker.GetInstance(), PlayerData.Instance);

            return(_activeStrategy);
        }
Esempio n. 4
0
        private void _run(string[] args)
        {
            Logger.SetLevel(Logger.Level.Debug);

            BackendWorker.CreateInstance();

            Logger.Info("Starting backend worker");
            BackendWorker.Start();

            // run until threads die
            BackendWorker.Join();
            Logger.Info("Worker thread stopped");
        }
 public FrontendPrinter(BackendWorker worker)
 {
     _worker = worker;
 }