예제 #1
0
        public void RetreatUnits_RetreatsStationedUnitsThatAreNotInTribeThatOwnsStronghold(
            IStronghold stronghold, 
            [FrozenMock] IActionFactory actionFactory,
            [FrozenMock] ITroopObjectInitializerFactory troopInitializerFactory,
            ITroopObjectInitializer troopInitializer,
            ITroopStub stub,
            ITribe tribe,
            ITribe shTribe,
            RetreatChainAction retreatAction,
            StrongholdManager strongholdManager)
        {
            stub.State.Returns(TroopState.Stationed);
            stub.City.Owner.IsInTribe.Returns(true);
            stub.City.Id.Returns<uint>(1234);
            stub.TroopId.Returns<ushort>(2);
            stub.City.Owner.Tribesman.Tribe.Returns(tribe);

            stronghold.MainBattle.Returns((IBattleManager)null);
            stronghold.Tribe.Returns(shTribe);
            stronghold.Troops.StationedHere().Returns(new[] { stub });

            troopInitializerFactory.CreateStationedTroopObjectInitializer(stub).Returns(troopInitializer);
            actionFactory.CreateRetreatChainAction(stub.City.Id, troopInitializer).Returns(retreatAction);

            strongholdManager.RetreatUnits(stronghold);
            
            stub.City.Worker.Received(1).DoPassive(stub.City, retreatAction, true);
        }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandMessage"/> class.
 /// </summary>
 public CommandMessage()
 {
     if (!PresentationFrameworkModule.IsInDesignMode)
     {
         _actionFactory = ServiceLocator.Current.GetInstance <IActionFactory>();
     }
 }
예제 #3
0
파일: Action.cs 프로젝트: agamat/Ribbon-1
 /// <summary>
 /// Initializes property host.
 /// </summary>
 /// <param name="controller">The controller.</param>
 /// <param name="actionFactory">The action factory.</param>
 /// <param name="serviceLocator">The service locator.</param>
 public static void Initialize(IRoutedMessageController controller, IActionFactory actionFactory,
                               IServiceLocator serviceLocator)
 {
     _controller     = controller;
     _actionFactory  = actionFactory;
     _serviceLocator = serviceLocator;
 }
예제 #4
0
파일: Action.cs 프로젝트: Mrding/Ribbon
 /// <summary>
 /// Initializes property host.
 /// </summary>
 /// <param name="controller">The controller.</param>
 /// <param name="actionFactory">The action factory.</param>
 /// <param name="serviceLocator">The service locator.</param>
 public static void Initialize(IRoutedMessageController controller, IActionFactory actionFactory,
                               IServiceLocator serviceLocator)
 {
     _controller = controller;
     _actionFactory = actionFactory;
     _serviceLocator = serviceLocator;
 }
예제 #5
0
 public CombatStructure(uint id,
                        uint battleId,
                        IStructure structure,
                        BattleStats stats,
                        decimal hp,
                        ushort type,
                        byte lvl,
                        string theme,
                        Formula formula,
                        IActionFactory actionFactory,
                        IBattleFormulas battleFormulas,
                        ITileLocator tileLocator,
                        IRegionManager regionManager,
                        IDbManager dbManager)
     : base(id, battleId, battleFormulas, dbManager)
 {
     Structure          = structure;
     this.formula       = formula;
     this.actionFactory = actionFactory;
     this.tileLocator   = tileLocator;
     this.regionManager = regionManager;
     this.stats         = stats;
     this.hp            = hp;
     this.type          = type;
     this.lvl           = lvl;
     this.Theme         = theme;
 }
예제 #6
0
        public StrongholdManager(IStrongholdConfigurator strongholdConfigurator,
                                 IStrongholdFactory strongholdFactory,
                                 IRegionManager regionManager,
                                 Chat chat,
                                 IDbManager dbManager,
                                 ISimpleStubGeneratorFactory simpleStubGeneratorFactory,
                                 Formula formula,
                                 ICityManager cityManager,
                                 IActionFactory actionFactory,
                                 ITileLocator tileLocator,
                                 ITroopObjectInitializerFactory troopInitializerFactory)
        {
            idGenerator = new LargeIdGenerator(Config.stronghold_id_max, Config.stronghold_id_min);
            strongholds = new ConcurrentDictionary <uint, IStronghold>();

            this.strongholdConfigurator = strongholdConfigurator;
            this.strongholdFactory      = strongholdFactory;
            this.regionManager          = regionManager;
            this.chat                    = chat;
            this.dbManager               = dbManager;
            this.formula                 = formula;
            this.actionFactory           = actionFactory;
            this.tileLocator             = tileLocator;
            this.troopInitializerFactory = troopInitializerFactory;

            cityManager.CityAdded += CityManagerCityAdded;
            simpleStubGenerator    = simpleStubGeneratorFactory.CreateSimpleStubGenerator(formula.StrongholdUnitRatio(), formula.StrongholdUnitType());
        }
예제 #7
0
 public LoginCommandsModule(IActionFactory actionFactory,
                            ITribeManager tribeManager,
                            IDbManager dbManager,
                            ILocker locker,
                            IWorld world,
                            Procedure procedure,
                            ICityFactory cityFactory,
                            ILocationStrategyFactory locationStrategyFactory,
                            IBarbarianTribeManager barbarianTribeManager,
                            CallbackProcedure callbackProcedure,
                            IChannel channel,
                            IThemeManager themeManager,
                            IPlayerFactory playerFactory,
                            ILoginHandler loginHandler)
 {
     this.actionFactory           = actionFactory;
     this.tribeManager            = tribeManager;
     this.dbManager               = dbManager;
     this.locker                  = locker;
     this.world                   = world;
     this.procedure               = procedure;
     this.callbackProcedure       = callbackProcedure;
     this.channel                 = channel;
     this.themeManager            = themeManager;
     this.playerFactory           = playerFactory;
     this.loginHandler            = loginHandler;
     this.cityFactory             = cityFactory;
     this.locationStrategyFactory = locationStrategyFactory;
     this.barbarianTribeManager   = barbarianTribeManager;
 }
예제 #8
0
 public GoToActivity(IActionFactory actionFactory, NavigationData navigationData, INavigator navigator, string name) : base(name)
 {
     _actionFactory  = actionFactory;
     _navigationData = navigationData;
     _destination    = navigationData.Destination;
     _navigator      = navigator;
 }
예제 #9
0
 public void RegisterFactory(IActionFactory factory, params string[] actionNames)
 {
     foreach (string actionName in GetValidActionNames(actionNames))
     {
         factories[actionName] = factory;
     }
 }
예제 #10
0
    public async Task <bool> ResolveAction(Phase speed, Present present, SelfCtx ctx)
    {
        // -------------
        // Select Actions to resolve
        // -------------
        IActionFactory[] options = this.GetAvailableActions(speed).ToArray();
        IActionFactory   option  = await this.SelectFactory("Select " + speed + " to resolve:", options, present);

        if (option == null)
        {
            return(false);
        }

        // if user clicked a slow card that was made fast, // slow card won't be in the options
        if (!options.Contains(option))
        {
            // find the fast version of the slow card that was clicked
            option = options.Cast <IActionFactory>()
                     .First(factory => factory == option);
        }

        if (!options.Contains(option))
        {
            throw new Exception("Dude! - You selected something that wasn't an option");
        }

        await TakeAction(option, ctx);

        return(true);
    }
예제 #11
0
        public GeneralDataFlow(IURIDiscovery uriDiscovery, ICacheService cacheServcie, IActionFactory actionFactory)
        {
            _URIDiscovery = uriDiscovery;

            _cacheService = cacheServcie;

            _actionFactory = actionFactory;
        }
예제 #12
0
        public GeneralDataFlow(IURIDiscovery uriDiscovery, ICacheService cacheServcie, IActionFactory actionFactory)
        {
            _URIDiscovery = uriDiscovery;

            _cacheService = cacheServcie;

            _actionFactory = actionFactory;
        }
예제 #13
0
 public AiActionResolver(IActionFactory actionFactory, IUtilityAi utilityAi,
                         IActivityCreationContext activityCreationContext, IActivityResolver activityResolver)
 {
     _actionFactory           = actionFactory;
     _utilityAi               = utilityAi;
     _activityCreationContext = activityCreationContext;
     _activityResolver        = activityResolver;
 }
예제 #14
0
 public void SetActionFactory(IActionFactory actionFactory)
 {
     if (actionFactory == null)
     {
         throw new ArgumentNullException("actionFactory");
     }
     _factoryActivator = () => actionFactory;
 }
예제 #15
0
 public static Menu FromConfig(MenuConfiguration config, IActionFactory actionFactory)
 {
     return(new Menu(
                CommandBindingCollection.FromCollection(config.CommandBindings, actionFactory),
                config.Pages.Select((p, i) => MenuPage.FromConfig(p, i, actionFactory)),
                config.Help,
                config.Help2));
 }
예제 #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandMessage"/> class.
        /// </summary>
        public CommandMessage()
        {
            if (!PresentationFrameworkModule.IsInDesignMode)
            {
                _actionFactory = ServiceLocator.Current.GetInstance <IActionFactory>();
            }

            SetValue(ParametersProperty, new FreezableCollection <Parameter>());
        }
예제 #17
0
 public InventoryService(IActionFactory actionFactory, IInventoryRepository inventoryRepository, IUserService userService, ISlackWebApi slack, ITargetActionFactory targetFactory, IEquipmentRepository equipmentRepository)
 {
     _actionFactory       = actionFactory;
     _inventoryRepository = inventoryRepository;
     _userService         = userService;
     _slack               = slack;
     _targetFactory       = targetFactory;
     _equipmentRepository = equipmentRepository;
 }
예제 #18
0
 public override async Task TakeAction(IActionFactory factory, SelfCtx ctx)
 {
     actionElements = null;         // make sure these are cleared out for every action
     try {
         await base.TakeAction(factory, ctx);
     } finally {
         actionElements = null;
     }
 }
예제 #19
0
 public static long GetSize(IActionFactory actionFactory)
 {
     using (Stream s = new MemoryStream())
     {
         BinaryFormatter formatter = new BinaryFormatter();
         formatter.Serialize(s, actionFactory);
         return(s.Length);
     }
 }
예제 #20
0
 public static MenuPage FromConfig(PageConfiguration config, int index, IActionFactory actionFactory)
 {
     return(new MenuPage(
                index,
                config.Help,
                config.Help2,
                CommandBindingCollection.FromCollection(config.CommandBindings, actionFactory),
                config.Items.Select((item, i) => PageItem.FromConfig(item, i, config.Items.Count, actionFactory))));
 }
예제 #21
0
 public CityCommandLineModule(Procedure procedure,
                              IActionFactory actionFactory,
                              ILocker locker,
                              IWorld world)
 {
     this.procedure     = procedure;
     this.actionFactory = actionFactory;
     this.locker        = locker;
     this.world         = world;
 }
예제 #22
0
        public ApproachActivity(IActionFactory actionFactory, INavigator navigator, Func <Position> targetPositionGetter, int turnsLimit, string name)
            : base(name)
        {
            _actionFactory        = actionFactory;
            _navigator            = navigator;
            _targetPositionGetter = targetPositionGetter;
            _turnsLimit           = turnsLimit;

            _lastTargetPosition = targetPositionGetter();
        }
예제 #23
0
 public ResourceGatherActiveAction(ILocker locker,
                                   IObjectTypeFactory objectTypeFactory,
                                   IWorld world,
                                   IActionFactory actionFactory)
 {
     this.locker            = locker;
     this.objectTypeFactory = objectTypeFactory;
     this.world             = world;
     this.actionFactory     = actionFactory;
 }
        public override void Initialize()
        {
            foreach (var behavior in behaviors)
                behavior.Value.Initialize();

            actionManager = GameServiceManager.GetService<IActionManager>();
            ActionFactory = GameServiceManager.GetService<IActionFactory>();
            behaviorFactory = GameServiceManager.GetService<IBehaviorFactory>();

            base.Initialize();
        }
예제 #25
0
        /// <summary>
        /// Adds the actions from the specified factory.
        /// </summary>
        /// <param name="actionFactory">The action factory.</param>
        public void Add(IActionFactory actionFactory)
        {
            if (actionFactory == null)
            {
                throw new ArgumentNullException("actionFactory");
            }

            ICollection <Action> newActions = actionFactory.CreateActions();

            Add(newActions);
        }
예제 #26
0
 public ResourceGatherActiveAction(uint cityId,
                                   uint objectId,
                                   ILocker locker,
                                   IObjectTypeFactory objectTypeFactory,
                                   IWorld world,
                                   IActionFactory actionFactory)
     : this(locker, objectTypeFactory, world, actionFactory)
 {
     this.cityId   = cityId;
     this.objectId = objectId;
 }
예제 #27
0
 public BarbarianTribeAttackChainAction(IActionFactory actionFactory,
                                        Procedure procedure,
                                        ILocker locker,
                                        IGameObjectLocator gameObjectLocator,
                                        BattleProcedure battleProcedure)
 {
     this.actionFactory     = actionFactory;
     this.procedure         = procedure;
     this.locker            = locker;
     this.gameObjectLocator = gameObjectLocator;
     this.battleProcedure   = battleProcedure;
 }
예제 #28
0
 public CityDefenseChainAction(BattleProcedure battleProcedure,
                               IActionFactory actionFactory,
                               ILocker locker,
                               IWorld world,
                               Procedure procedure)
 {
     this.battleProcedure = battleProcedure;
     this.actionFactory   = actionFactory;
     this.locker          = locker;
     this.world           = world;
     this.procedure       = procedure;
 }
예제 #29
0
 private IAction CreateActionInstance(IActionFactory factory)
 {
     try
     {
         return(factory.Build());
     }
     catch (Exception exception)
     {
         logger.Warn($"Error on action instanciation.", factory, exception);
         return(null);
     }
 }
예제 #30
0
파일: ActionHost.cs 프로젝트: Mrding/Ribbon
        /// <summary>
        /// Initializes a new instance of the <see cref="ActionHost"/> class.
        /// </summary>
        /// <param name="targetType">Type of the target.</param>
        /// <param name="factory">The factory.</param>
        /// <param name="serviceLocator">The container</param>
        public ActionHost(Type targetType, IActionFactory factory, IServiceLocator serviceLocator)
        {
            _targetType = targetType;
            _serviceLocator = serviceLocator;

            AddMetadataFrom(targetType);

            _filters = new FilterManager(_targetType, this, serviceLocator);

            foreach(var action in factory.CreateFor(this))
            {
                _actions[action.Name] = action;
            }
        }
예제 #31
0
 public RequestController(IActionFactory actionFactory, IRequest request)
 {
     this.actionFactory = actionFactory;
     this.request = request;
 }
예제 #32
0
 public Controller(IActionFactory actionFactory)
 {
     _actionFactory = actionFactory;
 }
예제 #33
0
파일: Dispacher.cs 프로젝트: yanyitec/yitec
 public Dispacher(IActionFactory commandFactory) {
     this.ActionFactory = commandFactory;
     //this.BinderFactory = binderFactory;
 }
예제 #34
0
 public FinTsService(IActionFactory actionFactory, ITanSourceFactory tanSourceFactory, IInputOutput io)
 {
     this.actionFactory = actionFactory;
     this.tanSourceFactory = tanSourceFactory;
     this.io = io;
 }
예제 #35
0
 public void SetActionFactory(IActionFactory actionFactory) {
     if (actionFactory == null) {
         throw new ArgumentNullException("actionFactory");
     }
     _factoryActivator = () => actionFactory;
 }
예제 #36
0
 /// <summary>
 /// register a new action
 /// </summary>
 /// <param name="id">the id of the action</param>
 /// <param name="factory">factory to construct the action</param>
 public void registerAction(XnaScrapId id, IActionFactory factory)
 {
     if (!m_registeredAction.Keys.Contains(id))
         m_registeredAction.Add(id, factory);
     else
     {
         // TODO throw exception
     }
 }
예제 #37
0
        /// <summary>
        /// Adds the actions from the specified factory.
        /// </summary>
        /// <param name="actionFactory">The action factory.</param>
        public void Add(IActionFactory actionFactory)
        {
            if (actionFactory == null)
            {
                throw new ArgumentNullException("actionFactory");
            }

            ICollection<Action> newActions = actionFactory.CreateActions();

            Add(newActions);
        }
예제 #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultBinder"/> class.
 /// </summary>
 /// <param name="serviceLocator">The service locator.</param>
 /// <param name="actionFactory">The action factory.</param>
 /// <param name="messageBinder">The message binder.</param>
 public DefaultBinder(IServiceLocator serviceLocator, IActionFactory actionFactory, IMessageBinder messageBinder)
 {
     _serviceLocator = serviceLocator;
     _actionFactory = actionFactory;
     _messageBinder = messageBinder;
 }
예제 #39
0
 public HelloWorldController(IActionFactory actionFactory)
 {
     this.actionFactory = actionFactory;
 }
예제 #40
0
 public RequestController(IActionFactory actionFactory, IRequest request, IFingerprintFactory fingerprintFactory)
 {
     this.actionFactory = actionFactory;
     this.request = request;
     this.fingerprintFactory = fingerprintFactory;
 }