def setDoubleBet(receiptID, bet_value, bet_odd, match1_ID, match2_ID, result_1,
                 result_2):
    '''
    @param receiptID:string, receipt ID which Winner issue
    @param bet_value:float, amount of money that place on the bet
    @param bet_odd:float, the odds that the bets holds, given by Winner
    @param match1_ID:string, the ID of the first match that the bet place on
    @param match2_ID:string, the ID of the second match that the bet place on
    @param result_1:string, the outcome of the first match we expect ('1','X','2')
    @param result_2:string, the outcome of the second match we expect ('1','X','2')
    @return:None
    '''
    try:
        match1: Match = DBController.findMatch(match1_ID)
        match2: Match = DBController.findMatch(match2_ID)
        result1 = enumDICT[result_1]
        result2 = enumDICT[result_2]
        form = BetForm(receiptID=receiptID,
                       bet_value=bet_value,
                       bet_odd=bet_odd,
                       bets_list=[(match1, result1), (match2, result2)])
        match1.associateBetForm(receiptID)
        match2.associateBetForm(receiptID)
        DBController.saveBetForm(form.toDTO())
        return True
    except KeyError:
        print("Could not find the associate ENUM")
        return False
    except:
        print("An error has been occurred")
        return False
Exemplo n.º 2
0
 def test_saveMatch(self):
     db.DBConnection.Matches.remove({})
     newMatch = Match(matchID='{}_TeamA_TeamB'.format(today),
                      date=today,
                      league='league',
                      home_team='TeamA',
                      away_team='TeamB',
                      result=Result.Home)
     db.saveMatch(newMatch.toDTO())
     found = db.findMatch(matchID='{}_TeamA_TeamB'.format(today))
     self.assertEqual(newMatch, found)
def setMatchResult(matchID, result):
    '''
    @param matchID:string, the ID of the match
    @param result:string, the result of the match ('1','X','2')
    @return: Match object that represent the match
    '''
    try:
        match = DBController.findMatch(matchID)
        result = enumDICT[result]
        match.setResult(result)
        DBController.updateMatch(match.toDTO())
        for receiptID in match._associateBets:
            DBController.findBetForm(receiptID).checkWin()
        return match
    except KeyError:
        print("Could not find the associate ENUM")
        return False
    except:
        print("An error has been occurred")
        return False