Example #1
0
 internal UpgradesModel(Game g, Village v)
     : base(g)
 {
     _isActivated = new HistorizedValue<bool, UpgradesModel>(this, "IsActivated", 5);
     _owner = v;
     IsActivated = false;
 }
Example #2
0
 public BuildingsModel(Village v)
     : base(v.Game)
 {
     _hp = new HistorizedValue<int, BuildingsModel>(this, @"_hp", 20);
     _justCreated = true;
     _horizontalPos = 0;
     _verticalPos = 0;
     _addedHappiness = 0;
     _addedFaith = 0;
     _enterPrice = 0;
     _isBought = false;//old code
     _village = v;
     AddToList();
 }
Example #3
0
 public Villager(Game g, Genders gender, string name)
     : base(g)
 {
     _faith = new HistorizedValue<double, Villager>(this, "_faith", 20);
     _happiness = new HistorizedValue<double, Villager>(this, "_happiness", 20);
     _health = new HistorizedValue<Healths, Villager>(this, "_health", 20);
     _statusInFamily = new HistorizedValue<Status, Villager>(this, "_statusInFamily", 20);
     g.VillagerAdded();
     _faith.Current = 100;
     _happiness.Current = 80;
     _lifeExpectancy = 85 * 12;
     _gender = gender;
     _statusInFamily.Current = Status.SINGLE;
     _name = name;
     Game.Villages[0].VillagerAdded();
     Game.Villages[0].JobsList.Farmer.AddPerson(this);
 }
Example #4
0
        internal Villager(Game g, Family parentFamily, string name)
            : base(g)
        {
            _faith = new HistorizedValue<double, Villager>(this, "_faith", 20);
            _happiness = new HistorizedValue<double, Villager>(this, "_happiness", 20);
            _health = new HistorizedValue<Healths, Villager>(this, "_health", 20);
            _statusInFamily = new HistorizedValue<Status, Villager>(this, "_statusInFamily", 20);
            _statusInFamily.Current = Status.SINGLE;

            g.VillagerAdded();
            parentFamily.OwnerVillage.VillagerAdded();
            Debug.Assert(g != null);
            if (Game.Rand.Next(101) < 2)
                _faith.Current = 13;
            else
                _faith.Current = parentFamily.FaithAverage();
            if (_faith.Current <= 15)
                _health.Current = Healths.HERETIC;
            switch (Game.Rand.Next(2))
            {
                case 0: _gender = Genders.MALE;
                    if (parentFamily.Father != null)
                        if (parentFamily.Father.Job != null)
                            parentFamily.Father.Job.AddPerson(this);
                    g.AddSingleMan(this); break;
                case 1: _gender = Genders.FEMALE;
                    if (parentFamily.Mother != null)
                        if (parentFamily.Mother.Job != null)
                            parentFamily.Mother.Job.AddPerson(this);
                    Engage(this, parentFamily); break;
            }
            if (parentFamily.OwnerVillage.Meeting != null)
            {
                if (parentFamily.OwnerVillage.Meeting.Family == parentFamily)
                {
                    MeetingStarted();
                }
            }
            _happiness.Current = parentFamily.HappinessAverage();
            _age = 0;
            _lifeExpectancy = 85 * 12;
            _name = name;
        }
Example #5
0
        internal Family(Game game, Villager mother, Villager father, string name)
            : base(game)
        {
            // Initialized historized value for gold
            _goldStash = new HistorizedValue<int, Family>(this, @"_goldstash", 20);
            _hungry = new HistorizedValue<bool, Family>(this, @"_hungry", 5);

            if (mother.ParentFamily != null && father.ParentFamily != null)
            {
                _goldStash.Current = mother.ParentFamily.TakeFromGoldStash(mother.ParentFamily.GoldStash / 10); //10%
                _goldStash.Current += father.ParentFamily.TakeFromGoldStash(father.ParentFamily.GoldStash / 10); //10%
                RemoveFromFamily(mother, mother.ParentFamily);
                RemoveFromFamily(father, father.ParentFamily);
            }
            else
                _goldStash.Current = 20;

            game.GoldAdded(_goldStash.Current);

            if (mother.StatusInFamily == Status.SINGLE && father.StatusInFamily == Status.SINGLE)
                mother.Engage(father);

            var firstNamesPath = File.ReadAllLines(@"Extra\nameList.txt");
            _firstNameGenerator = new NameGenerator(firstNamesPath, 1, 1);

            _name = name;
            _mother = mother;
            _father = father;
            _mother.StatusInFamily = Status.MARRIED;
            _father.StatusInFamily = Status.MARRIED;

            _familyMembersList = new FamilyMemberList(this);
            _familyMembersList.Add(_mother);
            _familyMembersList.Add(_father);
            _mother.ParentFamily = this;
            _father.ParentFamily = this;

            //=> marriage pendant convocation ? ils s'enfuyent.
            _mother.ActivityStatus = _mother.ActivityStatus & ~ActivityStatus.CONVOCATED;
            _father.ActivityStatus = _father.ActivityStatus & ~ActivityStatus.CONVOCATED;
        }
Example #6
0
        internal Village(Game game, string name)
            : base(game)
        {
            Debug.Assert(!String.IsNullOrWhiteSpace(name));
            Debug.Assert(game != null, @"(village, Village) Game is null");

            // Initialize village's grid
            _villageGrid = new Board();

            // Initilize village's lists
            BuildingsList = new Buildings.BuildingsList(this);
            EmptyHouseList = new List<Buildings.House>();
            JobsList = new JobList(this);
            _familiesList = new FamilyInVillageList(this);
            _upgrades = new UpgradesList(this);

            // Initialize historized values
            _offeringsPointsPerTick = new HistorizedValue<int, Village>(this, @"_offeringsPointsPerTick", 20);
            _villagePop = new HistorizedValue<int, Village>(this, @"_villagePop", 20);

            // Set values
            _name = name;
            _offeringsPointsPerTick.Current = 1;
        }
Example #7
0
        // NEW GAME
        public Game(double timeStep = 0)
        {
            // Created "windows values"
            _totalGold = new HistorizedValue<int, Game>(this, @"_totalGold", 20);
            _totalPop = new HistorizedValue<int, Game>(this, @"_totalPop", 20);
            _offerings = new HistorizedValue<int, Game>(this, @"_offerings", 20);

            // Created lists
            _items = new List<GameItem>();
            _singleMenList = new List<Villager>();
            _villagesList = new List<Village>();
            _eventList = new List<IEvent>();

            // FamilyNames Generator
            var namesPath = File.ReadAllLines(@"Extra\nameList.txt");
            _nameGenerator = new NameGenerator(namesPath, 1, 1);
            var firstNamesPath = File.ReadAllLines(@"Extra\firstNameList.txt");
            _firstNameGenerator = new NameGenerator(namesPath, 1, 1);

            // GodSpell Initialization
            _currentEpidemicList = new List<GodSpell.Epidemic>();

            // BirthDates Initialisation
            _regularBirthDates = new double[5];
            #region To Be CHANGED
            //_ageTickTime = 0.0834;//time(years) between each tick.
            _ageTickTime = 1;
            Rand = new Random();//to be moved elsewhere.

            int j = 216; // j = 18
            for (int i = 0; i < 5; i++) // Must be kept orderly
            {
                _regularBirthDates[i] = j;
                j = j + 4 * 12; // j = j + 4
            }
            #endregion

            // Create Village
            Village village = CreateVillage(@"Ragnar");

            // Create Table
            new TablePlace(village);

            // Create default jobs buildings
            Farm farm = new Farm(village, village.JobsList.Farmer);
            village.JobsList.Farmer.Building = farm;
            Forge forge = new Forge(village, village.JobsList.Blacksmith);
            village.JobsList.Blacksmith.Building = forge;
            UnionOfCrafter uoc = new UnionOfCrafter(village, village.JobsList.Construction_Worker);
            village.JobsList.Construction_Worker.Building = uoc;

            // Create 5 families
            Family FamilyA = village.CreateFamilyFromScratch(village.JobsList.Farmer, village.JobsList.Blacksmith);
            Family FamilyB = village.CreateFamilyFromScratch(village.JobsList.Farmer, village.JobsList.Construction_Worker);
            Family FamilyC = village.CreateFamilyFromScratch();
            Family FamilyD = village.CreateFamilyFromScratch();
            Family FamilyE = village.CreateFamilyFromScratch();

            // Set player's offerings
            _offerings.Current = 100;
        }