Exemple #1
0
        /// <summary>
        /// Judges "_that".<br/>
        /// Gets the "opinion" of character "this" towards character "_that".
        /// </summary>
        /// <param name="_that"></param>
        /// <returns></returns>
        public int Judgement(CCharacter _that, CCharacterTraitDictionary _dictionary)
        {
            List <CCharacterTrait> likeList = new List <CCharacterTrait>();
            List <CCharacterTrait> hateList = new List <CCharacterTrait>();

            foreach (CCharacterTrait trait in this.traits_)
            {
                likeList.AddRange(trait.Likes(_dictionary));
                hateList.AddRange(trait.Hates(_dictionary));
            }

            int evaluation = 0;

            foreach (CCharacterTrait trait in _that.traits_)
            {
                if (likeList.Contains(trait))
                {
                    evaluation++;
                }
                if (hateList.Contains(trait))
                {
                    evaluation--;
                }
            }
            return(evaluation);
        }
Exemple #2
0
        public void CreateGame(int _width, int _height)
        {
            if (_width > 0 && _height > 0)
            {
                this.gameTurn_ = 1;
                this.map_.CreateMap(_width, _height);

                int cityCount      = _width * _height;
                int factionCount   = (int)(cityCount * 0.75);
                int characterCount = cityCount * 5;

                this.cities_.Clear();
                this.factions_.Clear();
                this.characters_.Clear();

                for (int i = 0; i < factionCount; i++)
                {
                    CFaction faction = new CFaction(this.factions_.Count + 1, false);
                    this.factions_.Add(faction);

                    CCity city = new CCity(this.cities_.Count + 1, faction);
                    this.cities_.Add(city);
                    faction.AddCity(city);
                    this.map_.PlaceCity(city);

                    for (int j = 0; j < 5; j++)
                    {
                        CCharacter character = new CCharacter(this.characters_.Count + 1, faction, city);
                        character.RandomGeneration(this.traitDictionary_);
                        this.characters_.Add(character);
                        faction.AddCharacter(character);
                        city.AddCharacter(character);
                    }

                    // create big faction
                    // big faction has one more city
                    if (cityCount - this.cities_.Count > factionCount - this.factions_.Count)
                    {
                        city = new CCity(this.cities_.Count + 1, faction);
                        this.cities_.Add(city);
                        faction.AddCity(city);
                        this.map_.PlaceCity(city);

                        for (int j = 0; j < 5; j++)
                        {
                            CCharacter character = new CCharacter(this.characters_.Count + 1, faction, city);
                            character.RandomGeneration(this.traitDictionary_);
                            this.characters_.Add(character);
                            faction.AddCharacter(character);
                            city.AddCharacter(character);
                        }
                    }
                }
            }
        }
Exemple #3
0
        public void AddCharacter(CCharacter _character)
        {
            bool canAddCharacter = true;

            foreach (CCharacter character in this.characters_)
            {
                if (character.Equals(_character))
                {
                    canAddCharacter = false;
                }
            }

            if (canAddCharacter)
            {
                this.characters_.Add(_character);
            }
        }
Exemple #4
0
        /// <summary>
        /// Evaluates "_that"<br/>
        /// Gets the evaluation of attributes of character "_that", based on the judgement value.
        /// </summary>
        /// <param name="_that"></param>
        /// <returns></returns>
        public List <int> Evaluate(CCharacter _that, CCharacterTraitDictionary _dictionary)
        {
            List <int> evals = new List <int>();

            evals.Add(_that.leaderShip_);
            evals.Add(_that.combatSkill_);
            evals.Add(_that.stratagem_);
            evals.Add(_that.politics_);

            int   judgement = this.Judgement(_that, _dictionary);
            int   sign      = Math.Sign(judgement);
            float error     = (20 - this.stratagem_) / 50.0f;

            for (int i = 0; i < evals.Count; i++)
            {
                evals[i] += (int)(evals[i] * error + sign * judgement) * sign;
                if (evals[i] < 1)
                {
                    evals[i] = 1;
                }
            }

            return(evals);
        }