• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python models.Move类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中models.Move的典型用法代码示例。如果您正苦于以下问题:Python Move类的具体用法?Python Move怎么用?Python Move使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: make_move

def make_move(request, game_id):

    if not request.user.is_authenticated():
        return HttpResponse('Unauthorized', status=401)

    if request.method == 'POST':
       # make sure authed & joined
        try:
            json_data = json.loads(request.body)
            #so check that the pile is valid
            game = Game.objects.get(id = game_id)

            usernames = [player.username for player in list(game.players.all())]
            if (request.user.username not in usernames):
                return HttpResponseServerError("Error, you havent joined this game")

            #check that it's this users turn to go
            moves = game.move_set.all().order_by('date')
            
            if (len(moves) > 0 and moves.last().user.username == request.user.username):
                #then this user went last, error pls
                return HttpResponseServerError("Error, wait for the other play to move")

            #expecting a "move"
            # {
            #     pile : 0
            #     taken : 5
            # }
            # By default, this Manager is named FOO_set, where FOO is the source model name, lowercased.
            piles = game.pile_set.all() # Returns all pile objects related to game.
            pile_pos = json_data['pile']
            if not (pile_pos >=0 and pile_pos < len(piles)):
                #invalid pile id
                return HttpResponseServerError("invalid pile id")
            pile_pull = game.pile_set.get(position=pile_pos)
            taken = int(json_data['taken'])
            if (taken > pile_pull.amount):
                return HttpResponseServerError("invalid, trying to take more than %s available" % (str(pile_pull.amount)))
            if (taken <= 0):
                return HttpResponseServerError("invalid, trying to take 0 or less")
            #we should be good
            #update the pile

            pile_pull.amount = pile_pull.amount - taken
            pile_pull.save()
            #create a move
            new_move = Move(
                #start at 0th move
                order = len(moves),
                game = game,
                pile = pile_pull,
                taken = taken,
                user = request.user
            )
            new_move.save()
            return get_json(Game.objects.get(id = game_id)) 
        except Game.DoesNotExist:
            return HttpResponseNotFound("Game doesnt exist")
        except Exception, e:
            return HttpResponseServerError("Malformed data!")
开发者ID:nznelson,项目名称:anran-python,代码行数:60,代码来源:views.py


示例2: guess_answer

    def guess_answer(self, request):
        """Guesses the answer. Returns a game state with message"""
        game = utils.get_by_urlsafe(request.urlsafe_game_key, Game)
        if game.game_over:
            return game.to_form('Game already over!')

        if not utils.valid_word_guess(request.word_guess):
            return game.to_form('Sorry, %s is an invalid guess!' % request.guess)

        game.attempts_remaining -= 1
        move = Move(game=game.key, move=request.word_guess, move_index=game.attempts_allowed - game.attempts_remaining)
        move.put()

        if request.word_guess == game.target:
            game.end_game(True)
            return game.to_form('You win!')
        else:
            msg = 'Oops! That is not the word! Remaining %s' % utils.show_hyphenated_progress(game.guessed_letters, game.target)

        if game.attempts_remaining < 1:
            game.end_game(False)
            return game.to_form(msg + ' Game over!')
        else:
            game.put()
            return game.to_form(msg)
开发者ID:12protons,项目名称:udacity-game,代码行数:25,代码来源:api.py


示例3: linkCooldown

def linkCooldown(movesGraph, difficulty = 1) -> None:
    """Links cooldown moves in."""
    movesGraph['twistedHeadToKnee'] = Move.twoSides("Twisted Head To Knee", "Take your %(same)s hand and grab the inside of your %(same)s foot.\
            Lean sideways over your %(same)s leg.", 30, movesGraph['seatedMeditation'], movesGraph['staff'], movesGraph['lieOnBack'])
    movesGraph['preztel'] = Move.twoSides("Preztel", "Take your %(same)s foot and put it in front of your %(other)s knee. Pull your \
            %(other)s knee towards you", 30, movesGraph['lieOnBack'])
    movesGraph['four'] = Move.twoSides("Four", "Four pose, %(same)s side", 30, movesGraph['supportedShoulderStand'])
    for i in movesGraph['four']: i.addLateMove(movesGraph['lieOnBack'])
    Move.moveReverse(movesGraph['four'], movesGraph['preztel'], movesGraph['twistedHeadToKnee'])

    movesGraph['child'].addMove(*movesGraph['childsPoseSideStretch'])
    movesGraph['downwardDog'].addMove(movesGraph['table'], movesGraph['child'], movesGraph['lieOnBack'])
    movesGraph['vinyasa'].addMove(movesGraph['child'], movesGraph['lieOnBack'], movesGraph['staff'], movesGraph['upwardDog'])
    movesGraph['staff'].addMove(movesGraph['hero'])
    movesGraph['seatedMeditation'].addMove(*movesGraph['cowFace'])
    movesGraph['seatedMeditation'].addMove(*movesGraph['seatedTwist'])
    movesGraph['seatedMeditation'].addMove(*movesGraph['twistedHeadToKnee'])
    movesGraph['mountain'].addMove(movesGraph['backBend'], *movesGraph['standingSideStretch'])
    movesGraph['mountain'].addMove(*movesGraph['standingTwist'])
    movesGraph['backBend'].removeMove(*movesGraph['standingSideStretch'])
    movesGraph['crow'].addMove(movesGraph['child'])
    movesGraph['lieOnBack'].addMove(*movesGraph['preztel'])
    movesGraph['supportedShoulderStand'].addMove(*movesGraph['four'])
    for i in movesGraph['birdOfParadise']: i.addMove(movesGraph['mountain'])
    for i in movesGraph['sidePlank']: i.addMove(movesGraph['lieOnFront'])
    for i in movesGraph['sidePlankLegUp']: i.addMove(movesGraph['lieOnFront'])
    for i in movesGraph['standingLegLift1']: i.addMove(movesGraph['mountain'])
    if difficulty >= 1: movesGraph['wheel'].promoteLate()
开发者ID:shulinye,项目名称:yoga,代码行数:28,代码来源:stretches.py


示例4: resetGameState

    def resetGameState(self, request):
      # Remove move ownership for all users
      # Resets move availablities to True
      game_id = request.game_id

      # for the moment, resets every move for provided game_id
      moves = Move.query().fetch()
      moves_deleted = Move.query(Move.game_id == game_id).fetch()


      game = Game.query(Game.game_id == game_id).get()

      if game == None:
        return StringMessage(message = "No Game found for ID:  {0} ".format(game_id))

      print("game id is {0} {1}".format(game_id, moves[0].game_id ))

      # Deleting Game
      game.key.delete()

      # Deleting Moves
      for move in moves_deleted:
        print("Deleting moves, {0}".format(move))
        move.key.delete()

      return StringMessage(message = "Game Reset Complete, deleted {0} moves for Game:  {1} ".format(len(moves_deleted), game_id))
开发者ID:Ascariel,项目名称:UdacityGameDesignProject4,代码行数:26,代码来源:api.py


示例5: make_move

    def make_move(self, request):
        """Makes a move. Returns a game state with message"""
        game = utils.get_by_urlsafe(request.urlsafe_game_key, Game)
        if game.game_over:
            return game.to_form('Game already over!')

        if not utils.valid_letter_guess(request.letter_guess, game.guessed_letters):
            return game.to_form('Sorry, %s is an invalid guess!' % request.letter_guess)

        game.attempts_remaining -= 1
        game.guessed_letters = game.guessed_letters + request.letter_guess

        move = Move(game=game.key, move=request.letter_guess, move_index=game.attempts_allowed - game.attempts_remaining)
        move.put()

        if utils.guessed_letters_are_correct(game.guessed_letters, game.target):
            game.end_game(True)
            return game.to_form('You win!')

        if request.letter_guess in game.target:
            msg = 'That letter is in the word! Remaining %s' % utils.show_hyphenated_progress(game.guessed_letters, game.target)
        else:
            msg = 'Oops! That letter is not in the word! Remaining %s' % utils.show_hyphenated_progress(game.guessed_letters, game.target)

        if game.attempts_remaining < 1:
            game.end_game(False)
            return game.to_form(msg + ' Game over!')
        else:
            game.put()
            return game.to_form(msg)
开发者ID:12protons,项目名称:udacity-game,代码行数:30,代码来源:api.py


示例6: _check_game_state

    def _check_game_state(game_id):
      """ Checks whether there's a victory condition, losing condition, or no more available moves """

      print("\n\nInside check game state, game_id: " + game_id)

      moves = Move.query(Move.game_id == game_id).fetch()
      available_moves = Move.query(Move.available == True, Move.game_id == game_id).fetch()
      
      if len(moves) == 0:
        print("\n\n game_id not found {0} \n\n".format(game_id))
        return "game_id_not_found"

      winner_id = GuessANumberApi._check_winning_condition(game_id)

      if winner_id != False:
        print("\n\n############### Game won by:" + winner_id + " ###############\n\n") 
        return winner_id        

      if len(available_moves) == 0:
        print("\n\n Game Ended, No more moves left {0} \n\n".format(game_id))
        return "no_more_moves"

           
      print("\n\nNo winners yet for game: {0} \n\n".format(game_id))
      return "no_winners_yet"
开发者ID:Ascariel,项目名称:UdacityGameDesignProject4,代码行数:25,代码来源:api.py


示例7: defineStretches

def defineStretches(movesGraph, difficulty = 1) -> None:
    """Add in a few stretches?"""
    movesGraph['upwardDogStretches'] = Move.twoSides('Upward Dog Stretch', 'Push your %(same)s shoulder forward', 10, movesGraph['upwardDog'])
    Move.moveReverse(movesGraph['upwardDogStretches'])
    movesGraph['halfSplits'] = Move.twoSides('Half Splits', 'Half Splits', 10) #add better description?
    movesGraph['splits'] = Move.twoSides('Splits', 'Splits, %(same)s foot forward', 10)
    if difficulty < 1:
        movesGraph['upwardDog'].addMove(*movesGraph['upwardDogStretches'])
开发者ID:shulinye,项目名称:yoga,代码行数:8,代码来源:stretches.py


示例8: makeMove

    def makeMove(self, request):
      """ Asigns specific move to a user for a specific game_id, as long as its available """
      x = request.x   
      y = request.y
      game_id = request.game_id
      user_id = request.user_id

      game = Game.query(Game.game_id == game_id).get()
      queried_move = Move.query(Move.x == x, Move.y == y, 
                        Move.game_id == game_id).fetch(1)

      if game == None :
        print("\n\nInvalid Move, Wrong Game ID\n\n")
        return StringMessage(message = "Invalid Move, Wrong Game ID" )
 
      winner_id = GuessANumberApi._check_winning_condition(game_id) 

      if winner_id != False:
        print("\n\n Game Won By {0} \n\n".format(winner_id))
        return StringMessage(message = "\n\n Game Won By {0} \n\n".format(winner_id))             

      available_moves = Move.query(Move.available == True, Move.game_id == game_id).fetch()
      
      if len(available_moves) == 0:
        print("\n\n Game Ended, No more moves left {0} \n\n".format(game_id))
        return "no_more_moves"        

      if user_id == None or user_id not in [game.player1, game.player2]:
        print("\n\nInvalid move parameters\n\n")
        return StringMessage(message = "Invalid Move, Wrong User ID" )

      if len(queried_move) == 0:
        print("\n\nInvalid move parameters\n\n")
        return StringMessage(message = "Invalid move parameters, Wrong Game ID or Move out of range" )

      if user_id == game.last_play_user_id:
        print("\n\n This Player already moved\n\n")
        return StringMessage(message = "Invalid move, This Player already moved" )        

      move = queried_move[0]
      if move.available != True:
        print("\n\nMove already done by: {0} \n\n".format(move.user_id))
        return StringMessage(message = "Move {0} has already been made by User with ID: : {1}"
                             .format(move.description, move.user_id) )        

      move.user_id = user_id
      move.available = False
      move.put()

      game.last_play_user_id = user_id
      game.put()

      GuessANumberApi._show_game_picture(game_id)
      GuessANumberApi._check_game_state(game_id)

      return StringMessage(message = "Move {0} assign to {1} for game_id: {2}, x:{3} and y:{4}".format(move.description, user_id, game_id, x, y) )
开发者ID:Ascariel,项目名称:UdacityGameDesignProject4,代码行数:56,代码来源:api.py


示例9: test_save_move_normal

 def test_save_move_normal(self):
   ''' Tests a simple move to valid location.
       Expected: no exceptions.
   '''
   game = Game.objects.get(id=1)
   player1 = Player.objects.get(id=1)
   move = Move(game=game, player=player1, position_x=1, position_y=1)
   move.save()
   from_db = Move.objects.get(id=1)
   self.assertEqual(from_db.position_x, 1)
开发者ID:benrose3d,项目名称:Tic-Tac-Toe,代码行数:10,代码来源:tests.py


示例10: test_simple_game

    def test_simple_game(self):

        game = Game.objects.get()
        #create 3 piles - 2,3,4
        for i, p in enumerate([2,3,4]):
            new_pile = Pile(
                position = i,
                amount = p,
                game = game
            )
            new_pile.save()
        self.assertEqual(len(game.pile_set.all()), 3)

        #create a couple users
        user_one = User.objects.create_user("one", password="one")
        user_one.save()
        user_two = User.objects.create_user("two", password="two")
        user_two.save()
        
        #add them to the game
        game.players.add(user_one)
        game.players.add(user_two)
        game.save()

        #reget the game
        game = Game.objects.get()
        self.assertEqual(len(game.players.all()), 2)

        #test a basic set of three moves, each player taking the max on each
        for i, (user, take) in enumerate([(user_one, 2), (user_two, 3), (user_one, 4)]):

            pile = game.pile_set.get(position = i)
            self.assertEqual(pile.amount, take)
            pile.amount = 0
            pile.save()
            #create a corresponding move
            new_move = Move(
                #start at 0th move
                order = i,
                game = game,
                pile = pile,
                taken = take,
                user = user
            )
            new_move.save()
        
        #check it went user 1, user 2, user 1
        moves = game.move_set.all().order_by('date')
        self.assertEqual(len(moves), 3)
        # print moves[0]
        # print moves[1]
        # print moves[2]
        self.assertEqual(moves[0].user, user_one)
        self.assertEqual(moves[1].user, user_two)
        self.assertEqual(moves[2].user, user_one)
开发者ID:nznelson,项目名称:anran-python,代码行数:55,代码来源:tests.py


示例11: _show_game_picture

    def _show_game_picture(game_id):

      """ Print visual representation of game state """

      moves = Move.query(Move.game_id == game_id).order(Move.x, Move.y).fetch()

      if len(moves) == 0:
        print("\n\nCant print game state, Invalid game_id {0}\n\n".format(game_id))
        return StringMessage(message = "Invalid move parameters. no game found" )

      player1,player2 = GuessANumberApi._get_players_in_game(game_id)

      print("Current Players for Game ID {0}: {1}, {2}".format(game_id, player1, player2) )


      m_00 = Move.query(Move.x == 0, Move.y == 0, 
                        Move.game_id == game_id).fetch(1)[0]
      m_01 = Move.query(Move.x == 0, Move.y == 1, 
                        Move.game_id == game_id).fetch(1)[0] 
      m_02 = Move.query(Move.x == 0, Move.y == 2, 
                        Move.game_id == game_id).fetch(1)[0] 
      m_10 = Move.query(Move.x == 1, Move.y == 0, 
                        Move.game_id == game_id).fetch(1)[0] 
      m_11 = Move.query(Move.x == 1, Move.y == 1, 
                        Move.game_id == game_id).fetch(1)[0] 
      m_12 = Move.query(Move.x == 1, Move.y == 2, 
                        Move.game_id == game_id).fetch(1)[0] 
      m_20 = Move.query(Move.x == 2, Move.y == 0, 
                        Move.game_id == game_id).fetch(1)[0] 
      m_21 = Move.query(Move.x == 2, Move.y == 1, 
                        Move.game_id == game_id).fetch(1)[0] 
      m_22 = Move.query(Move.x == 2, Move.y == 2, 
                        Move.game_id == game_id).fetch(1)[0] 

      m_00 = m_00.user_id or m_00.description
      m_01 = m_01.user_id or m_01.description
      m_02 = m_02.user_id or m_02.description
      m_10 = m_10.user_id or m_10.description
      m_11 = m_11.user_id or m_11.description
      m_12 = m_12.user_id or m_12.description
      m_20 = m_20.user_id or m_20.description
      m_21 = m_21.user_id or m_21.description
      m_22 = m_22.user_id or m_22.description

      print("\n\n\n")
      print("TIC TAC TOE GAME")
      print("\n")
      print(" {0} | {1} | {2} ".format(m_00, m_01, m_02))
      print("-----------------------------")
      print(" {0} | {1} | {2} ".format(m_10, m_11, m_12))
      print("-----------------------------")
      print(" {0} | {1} | {2} ".format(m_20, m_21, m_22))
      print("\n\n\n")
开发者ID:Ascariel,项目名称:UdacityGameDesignProject4,代码行数:53,代码来源:api.py


示例12: linkHarder

def linkHarder(movesGraph, difficulty=1) -> None:
    """Links some harder moves."""
    if difficulty >= 2:
        for i in movesGraph['revolvedHalfMoon']: i.time += 5
        movesGraph['downwardDog'].addLateMove(movesGraph['handstandHops'])
        movesGraph['vinyasa'].addMove(movesGraph['forwardFold'])
        Move.doubleAdd(movesGraph['runningMan'], movesGraph['chinStand'])
        Move.doubleAdd(movesGraph['triangle'], movesGraph['boundHalfMoon'], late=True)
        for i in movesGraph['cresent']: i.addLateMove(movesGraph['handstandHops'])
        movesGraph['crow'].addLateMove(movesGraph['crane'])
    if difficulty >= 1:
        movesGraph['vinyasa'].time = max(0, movesGraph['vinyasa'].time - 2)
        movesGraph['mountain'].time = max(0, movesGraph['mountain'].time - 2)
        for i in movesGraph['eagle']: i.time += 5
        for i in movesGraph['halfMoon']: i.time += 5
        movesGraph['star'].time += 5
        movesGraph['chair'].time += 5
        for i in movesGraph['warrior1']: i.time -= 2
        for i in movesGraph['warrior2']: i.time -= 2
        for i in movesGraph['chairTwist']: i.time += 5
        movesGraph['forwardFold'].addMove(movesGraph['crow'])
        movesGraph['seatedMeditation'].addMove(movesGraph['frog'])
        movesGraph['staff'].addMove(movesGraph['frog'])
        movesGraph['child'].addLateMove(movesGraph['supportedHeadstand'])
        movesGraph['downwardDog'].addLateMove(movesGraph['supportedHeadstand'])
        Move.doubleAdd(movesGraph['threeLeggedDog'], movesGraph['pigeon'])
        for i in movesGraph['twoLeggedDog']: i.addLateMove(movesGraph['plank'])
        Move.moveReverse(movesGraph['sidePlank'])
    for i in movesGraph['warrior3']: i.time += 5*max(difficulty,0)
    for i in ['warrior1', 'warrior2', 'standingLegLift4', 'threeLeggedDog']:
        for j in movesGraph[i]: j.promoteLate()
    for i in ['star', 'mountain', 'downwardDog']:
        movesGraph[i].promoteLate()
    movesGraph['mountain'].promoteLate(n=max(1, difficulty+1))
开发者ID:shulinye,项目名称:yoga,代码行数:34,代码来源:moves.py


示例13: _get_players_in_game

    def _get_players_in_game(game_id):

      moves = Move.query(Move.game_id == game_id).fetch()

      if len(moves) == 0:
        return StringMessage(message = "Invalid move parameters. no game found" )


      print("Getting players in game...")
      user_ids = []

      for move in moves:
        user_id = move.user_id
        # print("checking for ID: {0}".format( user_id) )

        if user_id not in user_ids and user_id != None:
          # print("ID: {0} was inserted".format( user_id) )
          user_ids.append(user_id)

      print(user_ids)
      if len(user_ids) == 2:
        player1 = user_ids[0]
        player2 = user_ids[1]
      elif len(user_ids) == 1:
        player1 = user_ids[0]
        player2 = None 
      else:
        player1 = None
        player2 = None                 
        
      print(player2, player1) 
      return [player1, player2]     
开发者ID:Ascariel,项目名称:UdacityGameDesignProject4,代码行数:32,代码来源:api.py


示例14: _prepReminder

 def _prepReminder():
     games = Game.query(
         Game.gameCurrentMove < 9 and Game.gameCurrentMove > 0).fetch()
     remindees = ''
     if games:
         # If there are games ready for sign up,
         # format announcement and set it in memcache for each game
         for game in games:
             last_move = Move.query(
                 Move.moveNumber==game.gameCurrentMove-1).get()
             if last_move:
                 current_time = datetime.utcnow()
                 if last_move.moveTime and (current_time - last_move.moveTime > timedelta(days=5)):
                     next_player = Player.query(Player.displayName == game.nextPlayer).get()
                     if next_player.mainEmail:
                         print 'next_player.mainEmail', next_player.mainEmail
                         remindees.join(next_player.displayName)
                         mail.send_mail(
                             '[email protected]{}.appspotmail.com' .format(
                                 app_identity.get_application_id()),
                             next_player.mainEmail,
                             'Coming back to tic-tac-toe?',
                             'It has been 5 days since the last move on:\r\n\r\n{}' .format(
                                 game.name)
                         )
     return remindees
开发者ID:zhangtreefish,项目名称:Project-4-for-Full-Stack-Nanodegree-at-Udacity,代码行数:26,代码来源:api.py


示例15: linkAerobics

def linkAerobics(movesGraph, difficulty = 1, aerobics = 0):
    """Adds in aerobics moves"""
    movesGraph['jumpingJacks'] = Move("Jumping Jacks", 0, "Jumping Jacks!", 40 + 20*difficulty, movesGraph['mountain'], countReps=True, countdown=True)
    movesGraph['runInPlace'] = Move("Running In Place", 0, "Run In Place", 40 + 20*difficulty, movesGraph['mountain'], movesGraph['jumpingJacks'], countdown=True)
    movesGraph['burpies'] = Move("Burpies!", 0, "Burpies", 30+10*difficulty, movesGraph['vinyasa'], movesGraph['forwardFold'], movesGraph['plank'], \
            extended=Move.reDifficultyTimes([60,75,90], 10, difficulty+aerobics), countReps=True, countdown=True)
    movesGraph['situps'] = Move("Situps", 0, "Situps", 30 + 10*difficulty, movesGraph['vinyasa'], extended=Move.reDifficultyTimes([40,50],10,difficulty + aerobics//2), \
            lateMove=set([movesGraph['boat']]), countReps=True)
    movesGraph['shuffle'] = Move("Shuffle", 0, "Shuffle", 30+10*difficulty, movesGraph['vinyasa']) #//TODO: better description
    movesGraph['highKnees'] = Move("High Knees", 0, "High Knees", 30+10*difficulty, movesGraph['vinyasa'])
    #linking here
    movesGraph['mountain'].addLateMove(movesGraph['jumpingJacks'], movesGraph['runInPlace'], movesGraph['burpies'])
    movesGraph['jumpingJacks'].addLateMove(movesGraph['runInPlace'])
    movesGraph['downwardDog'].addLateMove(movesGraph['burpies'])
    movesGraph['lieOnBack'].addLateMove(movesGraph['situps'])
    movesGraph['staff'].addLateMove(movesGraph['situps'])
    if aerobics >= 2:
        movesGraph['star'].addLateMove(movesGraph['jumpingJacks'])
        for i in movesGraph['eagle']: i.addLateMove(movesGraph['runInPlace'])
    if difficulty >= 1:
        movesGraph['seatedMeditation'].addLateMove(movesGraph['situps'])
        movesGraph['runInPlace'].addMove(movesGraph['vinyasa'])
    else:
        movesGraph['burpies'].addMove(movesGraph['mountain'])
    if aerobics + difficulty >= 3:
        movesGraph['mountain'].addLateMove(movesGraph['highKnees'])
        movesGraph['boat'].addLateMove(movesGraph['situps'])
        movesGraph['flatBack'].addLateMove(movesGraph['plank'])
        movesGraph['wideLegStance'].addLateMove(movesGraph['jumpingJacks'])
        movesGraph['jumpingJacks'].addMove(movesGraph['vinyasa'])
开发者ID:shulinye,项目名称:yoga,代码行数:30,代码来源:strengthaerobics.py


示例16: historyForGame

 def historyForGame(self, game):
     """return list of moves from this game"""
     list = Move.query(Move.gameKey == game.key).fetch()
     for move in list:
         move.game = game
         move.user = self.getPlayer(game, move)
     return list
开发者ID:rastaehli,项目名称:wordwars,代码行数:7,代码来源:repositories.py


示例17: linkEnding

def linkEnding(movesGraph) -> None:
    #Allow me to just go from one arm balance to the opposite side, to increase the chances I get balanced
    Move.moveReverse(movesGraph['runningMan'], movesGraph['sideCrow'], movesGraph['flyingPigeon'], \
            movesGraph['revolvedRunningMan'], movesGraph['chinStand'], movesGraph['twoLeggedDog'], \
            movesGraph['oneLeggedPlank'], movesGraph['warrior1'], movesGraph['warrior2'])
    for i in movesGraph['runningMan']: i.addMove(movesGraph['child'])
    for i in movesGraph['revolvedRunningMan']: i.addMove(movesGraph['child'])
    for i in movesGraph['sideCrow']: i.addMove(movesGraph['child'])
    for i in movesGraph['flyingPigeon']: i.addMove(movesGraph['child'])
    for i in movesGraph['twoLeggedDog']: i.addMove(movesGraph['child'], movesGraph['downwardDog'])
    for i in movesGraph['threeLeggedDog']:
        i.addMove(movesGraph['plank'])
        i.time += 1
    for i in movesGraph['pyramid']: i.addMove(movesGraph['wideLegForwardFold'])
    movesGraph['wideLegForwardFold'].addMove(*movesGraph['pyramid'])
    movesGraph['forwardFold'].addMove(*movesGraph['lowLunge'])
开发者ID:shulinye,项目名称:yoga,代码行数:16,代码来源:moves.py


示例18: test_moves_1

 def test_moves_1(self):
     move = Move.get_id(1)
     p = {c.name: getattr(move, c.name) for c in move.__table__.columns}
     self.assertEqual(p["MOVE_ID"], 1)
     self.assertEqual(p["MOVE_NAME"], "Pound")
     self.assertEqual(p["MOVE_POWER"], 40)
     self.assertEqual(p["MOVE_ACCURACY"], 100)
     self.assertEqual(p["MOVE_PP"], 35)
开发者ID:RobinsonNguyen,项目名称:cs373-idb,代码行数:8,代码来源:tests.py


示例19: getGameHistory

 def getGameHistory(self, request):
     """ shows a list of all the moves for each game"""
     game_key = ndb.Key(urlsafe=request.websafeGameKey)
     moves = Move.query(ancestor=game_key).fetch()
     if not moves:
         raise endpoints.NotFoundException('No moves found')
     else:
         return MovesForm(items=[move._copyMoveToForm for move in moves])
开发者ID:zhangtreefish,项目名称:Project-4-for-Full-Stack-Nanodegree-at-Udacity,代码行数:8,代码来源:api.py


示例20: test_moves_3

 def test_moves_3(self):
     moves = Move.get_all()
     p = []
     for move in moves:
         p.append({c.name: getattr(move, c.name) for c in move.__table__.columns})
     self.assertEqual(p[0]["MOVE_ID"], 1)
     self.assertEqual(p[0]["MOVE_NAME"], "Pound")
     self.assertEqual(p[1]["MOVE_ID"], 2)
     self.assertEqual(p[1]["MOVE_NAME"], "Karate-chop")
开发者ID:RobinsonNguyen,项目名称:cs373-idb,代码行数:9,代码来源:tests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Movie类代码示例发布时间:2022-05-27
下一篇:
Python models.Message类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap