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


Python Helpers.setLetterPoints方法代码示例

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


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

示例1: __init__

# 需要导入模块: from Helpers import Helpers [as 别名]
# 或者: from Helpers.Helpers import setLetterPoints [as 别名]
class JJB9:
    def __init__(self):
        self.h = Helpers()
        self.board = [[' ' for x in range(15)] for x in range(15)]
        self.staticTiles = [[0 for x in range(15)] for x in range(15)]

    def getLetterPoints(self, ruleset):
        assert(self.cookie != None)
        url         = "http://game03.wordfeud.com/wf/tile_points/%s/" % ruleset
        messageJSON = "{}"

        response = self.h.doPost(url, self.cookie, messageJSON)
        response = json.loads(response.read())
        self.h.setLetterPoints(response['content']['tile_points'])

        self.h.debug(response)

    def setStaticTiles(self, number):
        assert(self.cookie != None)
        url         = "http://game03.wordfeud.com/wf/board/%s/" % number
        messageJSON = "{}"

        response = self.h.doPost(url, self.cookie, messageJSON)
        response = json.loads(response.read())
        self.staticTiles = response['content']['board']
        self.h.debug(response)

    def sendMessage(self, game, message):
        assert(self.cookie != None)
        url         = "http://game03.wordfeud.com/wf/game/%s/chat/send/" % game
        messageJSON = "{\"message\": \"%s\"}" % message

        response = self.h.doPost(url, self.cookie, messageJSON)
        self.h.debug(response.read())
    
    """
    Returns a list of games
    """
    def getGames(self):
        assert(self.cookie != None)
        url         = "http://game03.wordfeud.com/wf/user/games/"
        message     = ""
        response    = self.h.doPost(url, self.cookie, message).read()
        return json.loads(response)['content']['games']

    def getGame(self, game):
        assert(self.cookie != None)
        url         = "http://game06.wordfeud.com/wf/game/%s/" % game
        message     = ""
        response    = self.h.doPost(url, self.cookie, message)
        response    = response.read()
        js          = json.loads(response)
        content     = js['content']['game']
        board       = content['tiles']
        staticTiles = content['board']
        ruleSet     = content['ruleset']
       
        self.setStaticTiles(staticTiles)
        self.getLetterPoints(ruleSet)
        self.buildBoard(board)
        self.h.printBoard(self.board)

        return response

    def buildBoard(self, newBoard):
        for w in newBoard:
            self.board[w[1]][w[0]] = w[2]

    def playPieces(self, game, moves):
        assert(self.cookie != None)
        words = self.h.getWords(moves, self.board)
        url         = "http://game06.wordfeud.com/wf/game/%s/move/" % game
        message     = { 'words'     : words,
                        'ruleset'   : 4,
                        'move'      : moves }
        message = json.dumps(message)
        self.h.debug(message)
        response    = self.h.doPost(url, self.cookie, message)
        return response.read()


    # Sets proper member variables on successful login, throws exception on failed 
    # login.
    def login(self, email, password):
        url = "http://game03.wordfeud.com/wf/user/login/email/"
        data = "{\"password\": \"%s\",\
                 \"email\": \"%s\"}" % (password, email)
        response = self.h.doPost(url, {}, data)
        dictedResponse = json.loads(response.read())
        if (dictedResponse['status'] == 'success'):
            cookie = self.h.getCookie(response.info().headers)
            self.cookie     = {"Cookie" : "%s=%s" % (cookie[0],cookie[1])}
            content         = dictedResponse['content']
            self.uid        = content['id']
            self.username   = content['username']
            self.email      = content['email']
            self.h.debug(self.cookie)
            self.h.debug(dictedResponse)
            self.h.debug(self.uid)
        else:
#.........这里部分代码省略.........
开发者ID:jonte,项目名称:JarJar9,代码行数:103,代码来源:JarJar9.py


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