Example #1
0
 public Appl(IStrategyFactory strategyFactory, IStrategySelector strategySelector,
             IWorldSource worldSource)
 {
     _strategyFactory  = strategyFactory;
     _strategySelector = strategySelector;
     _worldSource      = worldSource;
 }
Example #2
0
 public TicketService(ITicketRepository tickRepo, IReservationRepository resRepo,
                      IStrategyFactory strategyFactory, IRunRepository runRepository)
 {
     _tickRepo        = tickRepo;
     _resRepo         = resRepo;
     _strategyFactory = strategyFactory;
     _runRepository   = runRepository;
 }
Example #3
0
        private void FormStrategy_Load(object sender, EventArgs e)
        {
            _Factory = StrategyFactoryCreater.Instance().CreateFactory(StrategyFactoryType.Normal);

            foreach (string val in _Factory.AllStrategyNames)
            {
                checkedListBoxStrategy.Items.Add(val, CheckState.Checked);
            }
        }
Example #4
0
        private const double INITCASH = 100000; // 初始化的账户金额

        public void Go(IStockHistory history, IStrategyFactory strategies)
        {
            History_ = history;

            foreach (IFinanceStrategy strategy in strategies.AllStrategies)
            {
                ExecTask(strategy);
            }
        }
Example #5
0
        public void Go(IStockHistory history, IStrategyFactory strategies)
        {
            History_ = history;

            foreach (IFinanceStrategy strategy in strategies.AllStrategies)
            {
                ExecTask(strategy);
            }
        }
Example #6
0
 public BetStrategyService(IGameRepository gameRepository, IBetRepository betRepository, IStrategyRepository strategyRepository, 
     IStrategyFactory strategyFactory,IRankingRepository rankingRepository, IScorer scorer)
 {
     this._gameRepository = gameRepository;
     this._betRepository = betRepository;
     this._strategyRepository = strategyRepository;
     this._strategyFactory = strategyFactory;
     this._rankingRepository = rankingRepository;
     this._scorer = scorer;
 }
Example #7
0
 public BetStrategyService(IGameRepository gameRepository, IBetRepository betRepository, IStrategyRepository strategyRepository,
                           IStrategyFactory strategyFactory, IRankingRepository rankingRepository, IScorer scorer)
 {
     this._gameRepository     = gameRepository;
     this._betRepository      = betRepository;
     this._strategyRepository = strategyRepository;
     this._strategyFactory    = strategyFactory;
     this._rankingRepository  = rankingRepository;
     this._scorer             = scorer;
 }
        void TestFactory(StrategyFactoryType tp)
        {
            ScoresCalculator calc = new ScoresCalculator();

            IStrategyFactory factory = StrategyFactoryCreater.Instance().CreateFactory(tp);

            FakeStockHistory fsh = new FakeStockHistory();

            fsh.Init();
            calc.Calc(fsh, factory, new FakeIBonusProcessor());
        }
Example #9
0
        /// <summary>
        /// Calculate score of each strategy
        /// </summary>
        /// <param name="history">One stock history</param>
        /// <param name="factory">Strategy Factory</param>
        /// <param name="reader">Bonus imformation</param>
        public void Calc(IStockHistory history, IStrategyFactory factory, IBonusProcessor reader)
        {
            FinanceRunner runner = new FinanceRunner();
            runner.CurrentBonusProcessor = reader;
            runner.Go(history, factory);

            IStrategyJudger judger = new StrategyJudger();
            judger.Judge(runner.Results);

            IStrategyJudger judger2 = new ValidationJudger();
            judger2.Judge(runner.Results);

            AllScores_.AddRange(judger.ScoresArr);
            AllScores_.AddRange(judger2.ScoresArr);
        }
Example #10
0
 public RunController(ITicketRepository tick, IRunRepository run,
                      IReservationService resServ,
                      ITicketService tickServ,
                      IStrategyFactory strategyFactory,
                      IReservationRepository reservationRepo,
                      ITrainRepository trainRepo)
 {
     _tickRepo        = tick;
     _runRepo         = run;
     _resServ         = resServ;
     _tickServ        = tickServ;
     _strategyFactory = strategyFactory;
     _reservationRepo = reservationRepo;
     _trainRepo       = trainRepo;
 }
Example #11
0
        /// <summary>
        /// Calculate score of each strategy
        /// </summary>
        /// <param name="history">One stock history</param>
        /// <param name="factory">Strategy Factory</param>
        /// <param name="reader">Bonus imformation</param>
        public void Calc(IStockHistory history, IStrategyFactory factory, IBonusProcessor reader)
        {
            FinanceRunner runner = new FinanceRunner();

            runner.CurrentBonusProcessor = reader;
            runner.Go(history, factory);

            IStrategyJudger judger = new StrategyJudger();

            judger.Judge(runner.Results);

            IStrategyJudger judger2 = new ValidationJudger();

            judger2.Judge(runner.Results);

            AllScores_.AddRange(judger.ScoresArr);
            AllScores_.AddRange(judger2.ScoresArr);
        }
Example #12
0
        private void RunStrategy()
        {
            SetUserDefinedDate();
            log_.Info("==>AutoCompare start. Start Date = " + History_.MinDate.ToLongDateString()
                      + ", End Date = " + History_.MaxDate.ToLongDateString());

            if (History_.MinDate >= History_.MaxDate)
            {
                log_.Error("Stock histroy not correct!");
                return;
            }

            IStrategyFactory factory = StrategyFactoryCreater.Instance().CreateFactory(StrategyFactoryType.Normal);

            ScoresCalculator calc = new ScoresCalculator();

            calc.Calc(History_, factory, BonusProcessor_);
            calc.ShowResult();
        }
Example #13
0
        public void Go()
        {
            FakeStockHistory hist = new FakeStockHistory();

            hist.Init();

            LogMgr.Logger = new DummyLog();

            FinanceRunner runner = new FinanceRunner();

            runner.CurrentBonusProcessor = new FakeIBonusProcessor();
            IStrategyFactory factory = StrategyFactoryCreater.Instance().CreateFactory(StrategyFactoryType.Normal);

            runner.Go(hist, factory);

            StrategyResults results = runner.Results;

            Assert.IsTrue(results.AllStrategyNames.Count > 0);

            LogMgr.Logger.Close();
        }
        public Task Invoke(HttpContext httpContext,
                           IActor actor,
                           StoreHolder holder,
                           IStrategyFactory factory)
        {
            using (var session = holder.Store.OpenSession())
            {
                actor.System = LoadSystem(session);
                actor.Me     = LoadMe(httpContext, session);

                if (actor.HasSystemRole(SystemRoles.ContentManager) ||
                    actor.HasSystemRole(SystemRoles.ConventionManager) ||
                    actor.HasSystemRole(SystemRoles.ReceptionManager) ||
                    actor.HasSystemRole(SystemRoles.UsersManager))
                {
                    actor.ManagedConvention = LoadConvention(actor.System.ManagersConventionId, session);
                    if (actor.ManagedConvention != null)
                    {
                        actor.ManagedDropDowns = LoadDropDowns(factory, actor.ManagedConvention, actor.System);
                    }
                }

                if (actor.ManagedConvention != null &&
                    actor.System.DisplayConventionId == actor.System.ManagersConventionId)
                {
                    actor.DisplayConvention = actor.ManagedConvention;
                    actor.DisplayDropDowns  = actor.ManagedDropDowns;
                }
                else
                {
                    actor.DisplayConvention = LoadConvention(actor.System.DisplayConventionId, session);
                    if (actor.DisplayConvention != null)
                    {
                        actor.DisplayDropDowns = LoadDropDowns(factory, actor.DisplayConvention, actor.System);
                    }
                }
            }

            return(_next(httpContext));
        }
Example #15
0
        /// <summary>
        /// Calculates all relevant data and puts them in a container
        /// </summary>
        /// <param name="startLevel">The start level.</param>
        /// <param name="targetLevel">The target level.</param>
        /// <param name="gainedExpPercentage">The gained exp percentage.</param>
        /// <param name="startBossStage">The start boss stage.</param>
        /// <param name="endBossStage">The end boss stage.</param>
        /// <param name="isClanArena">if set to <c>true</c> [is clan arena].</param>
        /// <param name="isBaium">if set to <c>true</c> [is baium].</param>
        /// <param name="isZaken">if set to <c>true</c> [is zaken].</param>
        /// <param name="isAntharas">if set to <c>true</c> [is antharas].</param>
        /// <param name="isDailyQuest">if set to <c>true</c> [is DailyQuest].</param>
        /// <param name="instanceEntranceFee">The instance entrance fee.</param>
        /// <param name="strategyFactory">The strategyFactory. For unit testing purposes</param>
        /// <returns>returns data container if arguments are valid. Otherwise returns light weight container with total experience only</returns>
        public ILevelingContainer CalculateExping(
            int startLevel,
            int targetLevel,
            double gainedExpPercentage,
            int startBossStage,
            int endBossStage,
            bool isClanArena                 = false,
            bool isBaium                     = false,
            bool isZaken                     = false,
            bool isAntharas                  = false,
            bool isDailyQuest                = false,
            int instanceEntranceFee          = 0,
            IStrategyFactory strategyFactory = null)
        {
            if (startLevel > targetLevel)
            {
                return(null);
            }
            var factory = strategyFactory ?? new StrategyFactory();
            IReadOnlyCollection <IStrategy> strategies = factory.CreateStrategies(
                isClanArena,
                isBaium,
                isAntharas,
                isZaken,
                isDailyQuest,
                startBossStage,
                endBossStage);
            ulong totalExperience = CalculateTotalExp(startLevel, targetLevel, gainedExpPercentage);

            if (strategies.Count == 0)
            {
                return(new LevelingContainer(totalExperience, startLevel));
            }
            var container = new LevelingContainer(totalExperience, startLevel);

            return(ApplyStrategies(
                       strategies,
                       container));
        }
Example #16
0
        private void RunStrategyOnMultiStocks()
        {
            // Load from DB
            IEnumerable <int> allStockId = new List <int> {
                600238, 600239, 600240, 600007,
                600008, 600009, 600010, 600019, 600020, 600021, 600022
            };

            StocksHistory histories = new StocksHistory();

            histories.Load(allStockId);

            IStrategyFactory factory = StrategyFactoryCreater.Instance().CreateFactory(StrategyFactoryType.Normal);

            ScoresCalculator calc = new ScoresCalculator();

            foreach (IStockHistory hist in histories.GetAllHistories())
            {
                calc.Calc(hist, factory, null);
            }

            calc.ShowResult();
        }
Example #17
0
        public GameSetter(IConfigurationSetter languageSet, ISecondaryInputProvider inputProvider,
                          IPlayerFactory playerFactory, IStrategyFactory strategyFactory)
        {
            if (languageSet == null || playerFactory == null || strategyFactory == null || inputProvider == null)
            {
                throw new NullReferenceException(nameof(GameSetter));
            }

            LanguageSet     = languageSet;
            PlayerFactory   = playerFactory;
            StrategyFactory = strategyFactory;
            InputProvider   = inputProvider;

            GameType = inputProvider.ReturnTypeOfGame();
            if (GameType == 1)
            {
                CreatePlayersFor36CardGame();
            }

            if (GameType == 2)
            {
                CreatePlayersFor54CardGame();
            }
        }
Example #18
0
 public ActorDropDowns(IStrategyFactory factory, ActorConventionState convention, ActorSystemState system)
 {
     _convention = convention;
     _system     = system;
     _factory    = factory;
 }
Example #19
0
 public IProcess Create(IStrategyFactory strategyFactory, List <IPageReference> clone)
 {
     throw new System.NotImplementedException();
 }
Example #20
0
 public StrategyEngine(IStrategyFactory strategyFactory)
 {
     _strategyFactory = strategyFactory;
 }
 public MyController(IStrategyFactory factory)
 {
     _factory = factory;
 }
Example #22
0
 public BergerPairing(IStrategyFactory strategyFactory, int singleRounds)
 {
     _strategyFactory = strategyFactory;
     SingleRounds     = singleRounds;
 }
Example #23
0
 public void Setup()
 {
     _factory        = new StrategyFactory();
     _sessionFactory = new SessionFactory(new MsSql2008CustomConfiguration());
 }
 public PrimitiveCalculator(IStrategy strategy, IStrategyFactory strategyFactory)
 {
     this.Strategy        = strategy;
     this.StrategyFactory = strategyFactory;
 }
Example #25
0
 public GildedRoseStore(IStrategyFactory strategyFactory)
 {
     _strategyFactory = strategyFactory;
 }
Example #26
0
 public Process(IStrategyFactory strategyFactory, List <IPageReference> pageReferenceList)
 {
     PageReferenceList = pageReferenceList;
     Strategy          = strategyFactory.Create(this);
     _pagesToLoad      = GetPagesEnumerable().GetEnumerator();
 }
Example #27
0
 public ValuesController(IStrategyFactory strategyFactory)
 {
     _strategyFactory = strategyFactory;
 }
 private Actor.ActorDropDowns LoadDropDowns(IStrategyFactory factory, Actor.ActorConventionState convention, Actor.ActorSystemState system)
 {
     return(new Actor.ActorDropDowns(factory, convention, system));
 }
Example #29
0
 public GameRunner(IGame <GameState> game, IUserInterface ui, IStrategyFactory strategyFactory)
 {
     _game            = game;
     _ui              = ui;
     _strategyFactory = strategyFactory;
 }