Ejemplo n.º 1
0
        bool operator() (const UnitInfo::CorporationNode& node) const
        {
            if (node.prereqCorporation != NO_CORPORATION)
            {
                CityIter cityIter(*player_.getCvPlayer());
                CvCity* pCity;

                while (pCity = cityIter())
                {
                    if (pCity->isHasCorporation(node.prereqCorporation))
                    {
                        return true;
                    }
                }
            }

            return node.prereqCorporation == NO_CORPORATION;
        }
bool CvGameObjectPlot::hasGOM(GOMTypes eType, int iID)
{
    switch (eType)
    {
    case GOM_BUILDING:
    {
        // return true if the building is present in the city on this plot and active
        BuildingTypes eBuilding = (BuildingTypes) iID;
        CvCity* pCity = m_pPlot->getPlotCity();
        if (pCity)
        {
            return pCity->getNumActiveBuilding(eBuilding) > 0;
        }
        else
        {
            return false;
        }
        break;
    }

    case GOM_PROMOTION:
    {
        // Defer to units on the plot, combine with OR
        bool bHasGOM = false;
        foreach(GAMEOBJECT_UNIT, boost::bind(aggregateHasGOM, _1, eType, iID, &bHasGOM));
        return bHasGOM;
        break;
    }

    case GOM_TRAIT:
    {
        // Return true if the owner has the trait
        TraitTypes eTrait = (TraitTypes) iID;
        PlayerTypes ePlayer = m_pPlot->getOwnerINLINE();
        if (ePlayer != NO_PLAYER)
        {
            return GET_PLAYER(ePlayer).hasTrait(eTrait);
        }
        else
        {
            return false;
        }
        break;
    }

    case GOM_FEATURE:
    {
        // Check feature type
        FeatureTypes eFeature = (FeatureTypes) iID;
#ifdef MULTI_FEATURE_MOD
        return m_pPlot->getHasFeature(eFeature);
#else
        return m_pPlot->getFeatureType() == eFeature;
#endif
        break;
    }

    case GOM_OPTION:
    {
        GameOptionTypes eOption = (GameOptionTypes) iID;
        return GC.getGameINLINE().isOption(eOption);
        break;
    }

    case GOM_TERRAIN:
    {
        // Check terrain type
        TerrainTypes eTerrain = (TerrainTypes) iID;
        return m_pPlot->getTerrainType() == eTerrain;
        break;
    }

    case GOM_GAMESPEED:
    {
        GameSpeedTypes eSpeed = (GameSpeedTypes) iID;
        return GC.getGameINLINE().getGameSpeedType() == eSpeed;
        break;
    }

    case GOM_ROUTE:
    {
        // Check route type
        RouteTypes eRoute = (RouteTypes) iID;
        return m_pPlot->getRouteType() == eRoute;
        break;
    }

    case GOM_BONUS:
    {
        // Check bonus type
        BonusTypes eBonus = (BonusTypes) iID;
        return m_pPlot->getBonusType() == eBonus;
        break;
    }

    case GOM_UNITTYPE:
    {
        // Defer to units on the plot, combine with OR
        bool bHasGOM = false;
        foreach(GAMEOBJECT_UNIT, boost::bind(aggregateHasGOM, _1, eType, iID, &bHasGOM));
        return bHasGOM;
        break;
    }

    case GOM_TECH:
    {
        // If the team has researched that tech, return true
        TechTypes eTech = (TechTypes) iID;
        TeamTypes eTeam = m_pPlot->getTeam();
        if (eTeam != NO_TEAM)
        {
            return GET_TEAM(eTeam).isHasTech(eTech);
        }
        else
        {
            return false;
        }
        break;
    }

    case GOM_CIVIC:
    {
        // Return true if the owning player has the civic active
        CivicTypes eCivic = (CivicTypes) iID;
        PlayerTypes ePlayer = m_pPlot->getOwnerINLINE();
        if (ePlayer != NO_PLAYER)
        {
            return GET_PLAYER(ePlayer).isCivic(eCivic);
        }
        else
        {
            return false;
        }
        break;
    }

    case GOM_RELIGION:
    {
        // return true if the religion is present in the city on this plot
        CvCity* pCity = m_pPlot->getPlotCity();
        if (pCity)
        {
            return pCity->isHasReligion((ReligionTypes)iID);
        }
        else
        {
            return false;
        }
        break;
    }

    case GOM_CORPORATION:
    {
        // return true if the corporation is present in the city on this plot
        CvCity* pCity = m_pPlot->getPlotCity();
        if (pCity)
        {
            return pCity->isHasCorporation((CorporationTypes)iID);
        }
        else
        {
            return false;
        }
        break;
    }

    case GOM_IMPROVEMENT:
    {
        // Check improvement type
        ImprovementTypes eImprovement = (ImprovementTypes) iID;
        return m_pPlot->getImprovementType() == eImprovement;
        break;
    }
    }
    return false;
}