Ejemplo n.º 1
0
    private void Collaboration()
    {
        //now combine the farmer's harvest if they collab and then halve it and give each collab farmer the half of the collab.Harvest
        Farmer fa = farmers.First(x => !x.HasNoCollabFarmer()); //this should find in any case a farmer. if not, the simulation is corrupt xD
        //get the collab farmer
        float harvestF      = fa.GetField().GetHarvest();
        int   allFarmers    = fa.GetCollabFarmer().Count + 1; //+1 bc we have the first bauer
        float collabHarvest = 0;

        foreach (Farmer collabF in fa.GetCollabFarmer())
        {
            collabHarvest += collabF.GetField().GetHarvest();
        }
        collabHarvest = (harvestF + collabHarvest) / allFarmers;

        fa.GetField().SetHarvest(collabHarvest);         // set the harvest now to the half of the collab harvest
        foreach (Farmer collabF in fa.GetCollabFarmer()) // set the harvest now to the half of the collab harvest
        {
            collabF.GetField().SetHarvest(collabHarvest);
        }
        // set the harvest now to tzhe half of the collab harvest
        allCollabHarvest.Add(collabHarvest);
    }