Exemplo n.º 1
0
        private IBMBAgent AgentFor(IBMBCharacter character, string party = "testParty")
        {
            var mock = new Mock <IBMBAgent>();

            mock.Setup(m => m.Character)
            .Returns(character);
            mock.Setup(m => m.PartyName)
            .Returns(party);
            mock.Setup(m => m.IsDefender)
            .Returns(!_isAttacking);
            mock.Setup(m => m.IsAttacker)
            .Returns(_isAttacking);

            return(mock.Object);
        }
        /// <summary>
        /// Keeps track of agents in dictionaries and decides if they get banners
        /// </summary>
        /// <param name="agent"></param>
        /// <returns>true if the agent should receive a banner</returns>
        public bool AgentGetsBanner(IBMBAgent agent)
        {
            string              agentParty     = agent.PartyName;
            IBMBCharacter       agentCharacter = agent.Character;
            TroopSpecialization agentSpec      = agent.Character.Type;
            FormationGroup      agentFormation = agent.Formation;

            /* Caravan masters bypass count if they lead caravans */
            if (_settings.AllowCaravanGuards == CaravanAssignMode.OnlyMasters && agent.IsInCaravanParty)
            {
                if (agent.IsCaravanPartyLeader)
                {
                    CountBannerGivenToParty(agentParty);
                    return(true);
                }
                return(false);//Other caravan guards in the caravan party don't get banner
            }

            /* Add to maps */
            if (!_processedByTroop.ContainsKey(agentParty))
            {
                _processedByTroop.Add(agentParty, new Dictionary <IBMBCharacter, List <IBMBAgent> >());
            }
            if (!_processedByTroop[agentParty].ContainsKey(agentCharacter))
            {
                _processedByTroop[agentParty].Add(agentCharacter, new List <IBMBAgent>());
            }

            if (!_processedByFormation.ContainsKey(agentParty))
            {
                _processedByFormation.Add(agentParty, new Dictionary <FormationGroup, List <IBMBAgent> >());
            }
            if (!_processedByFormation[agentParty].ContainsKey(agentFormation))
            {
                _processedByFormation[agentParty].Add(agentFormation, new List <IBMBAgent>());
            }

            if (!_processedBySpec.ContainsKey(agentParty))
            {
                _processedBySpec.Add(agentParty, new Dictionary <TroopSpecialization, List <IBMBAgent> >());
            }
            if (!_processedBySpec[agentParty].ContainsKey(agentSpec))
            {
                _processedBySpec[agentParty].Add(agentSpec, new List <IBMBAgent>());
            }

            _processedBySpec[agentParty][agentSpec].Add(agent);
            _processedByFormation[agentParty][agentFormation].Add(agent);
            _processedByTroop[agentParty][agentCharacter].Add(agent);

            /* Give banner or skip */
            //int processedTroops = _settings.UnitCountMode == UnitCountMode.Type ? _processedByType[agentParty][agentSpec].Count : _processedByTroop[agentParty][agentCharacter].Count;
            int processedTroops = GetProcessedTroopsByMode(agentParty, agentSpec, agentFormation, agentCharacter);

            if (agentCharacter.IsHero || processedTroops % _settings.BearerToTroopRatio == 0)
            {
                CountBannerGivenToParty(agentParty);
                return(true);
            }
            return(false);
        }
        private int GetProcessedTroopsByMode(string agentParty, TroopSpecialization agentSpec, FormationGroup agentFormation, IBMBCharacter agentCharacter)
        {
            switch (_settings.UnitCountMode)
            {
            case UnitCountMode.Spec:
            default:
                return(_processedBySpec[agentParty][agentSpec].Count);

            case UnitCountMode.Formation:
                return(_processedByFormation[agentParty][agentFormation].Count);

            case UnitCountMode.Troop:
                return(_processedByTroop[agentParty][agentCharacter].Count);
            }
        }
Exemplo n.º 4
0
        public PartyBuilder AddTroops(IBMBCharacter character, int count)
        {
            _agents.AddRange(Enumerable.Repeat(AgentFor(character, _name), count));

            return(this);
        }