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


Python Convert.feeding_to_json方法代码示例

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


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

示例1: decode

# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import feeding_to_json [as 别名]
 def decode(self, msg):
     """
     Decides which type of message the server has sent and verifies that the
     timing of the message is valid and communicates to the player if the
     message is valid.
     :param msg: the message from the server to decode.
     :return: the message to send to the Dealer, if any.
     """
     if msg == "ok":
         return
     if "feeding" in possible_next_states[self.state] and len(msg) == 5:
         player = Convert.json_to_player_state(msg[0:3])
         opponents = Convert.json_to_listof_listof_species(msg[4])
         feeding = self.player.next_feeding(player, msg[3], opponents)
         self.state = "feeding"
         return Convert.feeding_to_json(feeding)
     (player, wh) = self.decode_start(msg)
     if player and "start" in possible_next_states[self.state]:
         print("Got start message")
         self.player.start(player, wh)
         self.state = "start"
         return
     decode_choose = self.decode_choose(msg)
     if decode_choose and "choose" in possible_next_states[self.state]:
         print("Choosing action")
         choice = self.player.choose(decode_choose)
         self.state = "choose"
         return Convert.action_to_json(choice)
     raise Exception
开发者ID:lydiaauch,项目名称:software-dev-2016,代码行数:31,代码来源:proxy_dealer.py

示例2: test_feeding_to_json

# 需要导入模块: from convert import Convert [as 别名]
# 或者: from convert.Convert import feeding_to_json [as 别名]
 def test_feeding_to_json(self):
     self.assertEqual(Convert.feeding_to_json(self.feed_1), self.json_feed_1)
     self.assertEqual(Convert.feeding_to_json(self.feed_2), self.json_feed_2)
     self.assertEqual(Convert.feeding_to_json(self.feed_3), self.json_feed_3)
     self.assertEqual(Convert.feeding_to_json(self.feed_4), self.json_feed_4)
开发者ID:lydiaauch,项目名称:software-dev-2016,代码行数:7,代码来源:convert_tests.py


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