当前位置: 首页>>代码示例>>Python>>正文


Python Species.convertSpecies方法代码示例

本文整理汇总了Python中species.Species.convertSpecies方法的典型用法代码示例。如果您正苦于以下问题:Python Species.convertSpecies方法的具体用法?Python Species.convertSpecies怎么用?Python Species.convertSpecies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在species.Species的用法示例。


在下文中一共展示了Species.convertSpecies方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parse_choice

# 需要导入模块: from species import Species [as 别名]
# 或者: from species.Species import convertSpecies [as 别名]
    def parse_choice(choice):
        """
        Parse a choice into a [PlayerState, listOf(Species), listOf(Species]
        :param choice: json list representing [playerstate, listof species, listof species]
        :return: [PlayerState, listOf(Species), listOf(Species)]
        """
        ps = PlayerState.convertPlayerState(choice[0])
        prev_species = [Species.convertSpecies(species) for species in [prev for prev in choice[1]]]
        later_species = [Species.convertSpecies(species) for species in [late for late in choice[2]]]

        return [ps, prev_species, later_species]
开发者ID:ajdcolcord,项目名称:Evolution,代码行数:13,代码来源:player.py

示例2: parse_cj_dj

# 需要导入模块: from species import Species [as 别名]
# 或者: from species.Species import convertSpecies [as 别名]
 def parse_cj_dj(json_cj_dj):
     """
     Parse a json cj_dj into a [listOf(listOf(Species)), listOf(listOf(Species))]
     :param json_cj_dj: json list representing [listof species, listof species]
                     - First list of species is each specieslist of all players acting before this player
                     - Second list of species is each specieslist of all players who's turns come after this player
     :return: (listOf(Species), listOf(Species))
     """
     prev_species, later_species = [], []
     for prev in json_cj_dj[0]:
         prev_species.append([Species.convertSpecies(species) for species in prev])
     for later in json_cj_dj[1]:
         later_species.append([Species.convertSpecies(species) for species in later])
     return prev_species, later_species
开发者ID:ajdcolcord,项目名称:Evolution,代码行数:16,代码来源:player.py

示例3: from_json_state

# 需要导入模块: from species import Species [as 别名]
# 或者: from species.Species import convertSpecies [as 别名]
 def from_json_state(json_state):
     """
     Takes in a json 'state' of a Player, converting it into a new PlayerState object
     :param json_state: JSON List -  [Natural, [Species+, ..., Species+], Cards]
     :return: PlayerState - the new PlayerState object created from the json representation
     """
     food_bag = json_state[0]
     species_list = [Species.convertSpecies(species) for species in json_state[1]]
     trait_cards = [TraitCard.from_json(trait) for trait in json_state[2]]
     return PlayerState(bag=food_bag, speciesList=species_list, trait_cards=trait_cards)
开发者ID:ajdcolcord,项目名称:Evolution,代码行数:12,代码来源:playerState.py

示例4: from_json_gamestate

# 需要导入模块: from species import Species [as 别名]
# 或者: from species.Species import convertSpecies [as 别名]
 def from_json_gamestate(json_state):
     """
     Takes in a json game state, converting it into a list that contains the PlayerState, WateringHole, and other species
     :param json_state: JSON List - [Natural, [Species+, ..., Species+], Cards, Natural+, LOB]
     :return: [PlayerState, Nat, List of Species]
     """
     ps = PlayerState.from_json_state(json_state[:3])
     watering_hole = json_state[3]
     all_species = []
     for species_list in json_state[4]:
         all_species.append([Species.convertSpecies(species) for species in species_list])
     return [ps, watering_hole, all_species]
开发者ID:ajdcolcord,项目名称:Evolution,代码行数:14,代码来源:playerState.py

示例5: convertPlayerState

# 需要导入模块: from species import Species [as 别名]
# 或者: from species.Species import convertSpecies [as 别名]
    def convertPlayerState(state):
        """
        Creates a PlayerState from from the given JSON representation
        :param state: JSON list - represents the playerState
        :return: PlayerState - with attributes contained in 'state'
        """
        playerTraitCards = []

        if state[0][0] == ID_LABEL and state[1][0] == SPECIES_LABEL and state[2][0] == BAG_LABEL:
            id = state[0][1]
            speciesList = [Species.convertSpecies(species) for species in state[1][1]]
            bag = state[2][1]
            if len(state) == 4 and state[3][0] == CARDS_LABEL:
                playerTraitCards = [TraitCard.from_json(card) for card in state[3][1]]
            if id < 1 or bag < 0:
                raise Exception("Bad JSON PlayerState Data")

            return PlayerState(id, bag, speciesList, playerTraitCards)

        else:
            raise Exception("Bad JSON PlayerState input")
开发者ID:ajdcolcord,项目名称:Evolution,代码行数:23,代码来源:playerState.py


注:本文中的species.Species.convertSpecies方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。