示例#1
0
 def is_eng_action_valid(self):
     road_known = is_tech_known(self.focus.pplayer, 8)
     tile_no_river = not TileState.tile_has_extra(self.focus.ptile,
                                                  EXTRA_RIVER)
     no_road_yet = not TileState.tile_has_extra(self.focus.ptile,
                                                EXTRA_ROAD)
     return road_known and tile_no_river and no_road_yet
示例#2
0
    def can_player_build_unit_direct(pplayer, punittype):
        """
        Whether player can build given unit somewhere,
        ignoring whether unit is obsolete and assuming the
        player has a coastal city.
        """

        if not is_tech_known(pplayer, punittype['tech_requirement']):
            return False

        #FIXME: add support for global advances, check for building reqs etc.*/

        return True
示例#3
0
    def is_dipl_action_valid(self):
        self._prep_tech_tree()
        if not ActSpySteal.is_dipl_action_valid():
            return self.tech_valid

        for tech_id in self.focus.rule_ctrl.techs:
            tgt_kn = is_tech_known(city_owner(self.pcity), tech_id)

            if not tgt_kn:
                continue
            """ Can steal a tech if the target player knows it and the actor player
            * has the pre requirements. Some rulesets allows the player to steal
            * techs the player don't know the prereqs of."""

            #/* Actor and target player tech known state. */
            self.tech_valid[tech_id] = is_tech_prereq_known(
                self.focus.pplayer, tech_id)

        return self.tech_valid
示例#4
0
    def is_tech_in_range(target_player, trange, tech):
        """Is there a source tech within range of the target?"""

        if trange == REQ_RANGE_PLAYER:
            target = TRI_YES if is_tech_known(target_player, tech) else TRI_NO
            return target_player != None and target

        elif trange in [REQ_RANGE_TEAM, REQ_RANGE_ALLIANCE, REQ_RANGE_WORLD]:
            #/* FIXME: Add support for the above ranges. Freeciv's implementation
            #* currently (25th Jan 2017) lives in common/requirements.c */
            freelog("Unimplemented tech requirement range " + range)
            return TRI_MAYBE
        elif trange in [
                REQ_RANGE_LOCAL, REQ_RANGE_CADJACENT, REQ_RANGE_ADJACENT,
                REQ_RANGE_CITY, REQ_RANGE_TRADEROUTE, REQ_RANGE_CONTINENT,
                REQ_RANGE_COUNT
        ]:

            freelog("Invalid tech req range " + range)
            return TRI_MAYBE
        else:
            return TRI_MAYBE
 def is_action_valid(self):
     if not self.rule_ctrl.game_info["trading_tech"]:
         return False
     return is_tech_known(self.giver, self.value) and \
            player_invention_state(self.taker, self.value) in [TECH_UNKNOWN,
                                                               TECH_PREREQS_KNOWN]
示例#6
0
 def is_eng_action_valid(self):
     railroad_known = is_tech_known(self.focus.pplayer, 65)
     already_road = TileState.tile_has_extra(self.focus.ptile, EXTRA_ROAD)
     no_rail_yet = TileState.tile_has_extra(self.focus.ptile, EXTRA_RAIL)
     return railroad_known and already_road and no_rail_yet
示例#7
0
 def is_eng_action_valid(self):
     return is_tech_known(self.focus.pplayer, 64)