def test_total_score_function_works_as_expected_with_all_zero_pins(self):

        frames = Game(
            [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])

        score = frames.result()

        self.assertEqual(score, 0)
    def test_total_score_function_returns_expected_result_with_all_ten_pins(
            self):

        frames = Game([10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10])

        score = frames.result()

        self.assertEqual(score, 300)
    def test_total_score_function_works_as_expected(self):

        frames = Game(
            [1, 4, 4, 5, 6, 3, 5, 1, 1, 0, 1, 7, 3, 6, 4, 3, 2, 1, 6, 2])

        score = frames.result()

        self.assertEqual(score, 65)
    def test_if_frames_are_spares(self):

        frames = Game(
            [1, 2, 10, 6, 4, 1, 2, 5, 2, 4, 3, 5, 7, 4, 2, 5, 2, 8, 1, 2])

        result = frames._is_spare(3)

        self.assertTrue(result, 'Frames are not spire')
    def test_if_frames_are_not_spares(self):

        frames = Game(
            [1, 2, 10, 6, 4, 1, 2, 5, 2, 4, 3, 5, 7, 4, 2, 5, 2, 8, 1, 2])

        result = frames._is_spare(5)

        self.assertFalse(result, 'Frames are spire')
    def test_if_frame_is_strike(self):

        frames = Game(
            [1, 2, 10, 1, 5, 1, 2, 5, 2, 4, 3, 5, 7, 4, 2, 5, 2, 8, 1, 2])

        result = frames._is_strike(2)

        self.assertTrue(result, 'This frame is not strike')
    def test_if_frame_is_not_strike(self):

        frames = Game(
            [1, 2, 10, 1, 5, 1, 2, 5, 2, 4, 3, 5, 7, 4, 5, 2, 8, 1, 2, 2])

        result = frames._is_strike(12)

        self.assertFalse(result, 'This frame is strike')
    def test_validating_frames_function_works_correctly_with_all_pins(self):

        exc = None

        try:
            frames = Game([10, 1, 2, 2, 3, 3, 4, 6, 4, 2, 5, 6, 3, 2, 5, 6, 3])
        except Exception as err:
            exc = err

        self.assertIsNotNone(exc)
        self.assertEqual(str(exc), 'Invalid number of frames')
    def test_validating_frames_function_with_value_bigger_than_10(self):

        exc = None

        try:
            frames = Game(
                [10, 12, 2, 3, 1, 2, 2, 3, 3, 4, 6, 4, 2, 5, 6, 3, 2, 5, 6, 3])
        except Exception as err:
            exc = err

        self.assertIsNotNone(exc)
        self.assertEqual(str(exc), 'Inavalid frames values')
    def playTour(self):

        # Если тур не последний
        if self.tourNow != (self.countTeams - 1) * 2:

            gamesTemp = []

            # Идем по расписанию, составляя матчи по нему
            for teams in self.timetable[self.tourNow * (self.countTeams //
                                                        2):(self.tourNow + 1) *
                                        (self.countTeams // 2)]:

                # Создаем игру с 2 командами из расписания
                game = Game(self.teams[teams[0] - 1], self.teams[teams[1] - 1])

                # Выбираем состав
                game.choiceSelection()

                # Играем матч
                game.match()

                # Добавляем проигранный матч в архив сезона
                gamesTemp.append(game)
                self.teams[teams[0] - 1].arrayOfGames.append(game)
                self.teams[teams[1] - 1].arrayOfGames.append(game)

            self.games.append(gamesTemp)
示例#11
0
# from classPlayer import *
# from classDisplay import *
# from classWord import *
from classGame import Game
import logging

from ConfigParser import SafeConfigParser


parser = SafeConfigParser()
parser.read("ConfigParser.ini")
SHOTS = parser.getint("Tries", "guess")

logging.info("# word, name, category, guesses ")


# ob = Word()
# category = ob.category()

# player = Player()
# playerName = player.name()
# filename = "%s.log" % playerName
# logging.basicConfig(filename=filename,level=logging.DEBUG,format="%(message)s")
# logging.info("@@@@The user start game")

# word = ob.currentWord()
# print word

playGame = Game()
playGame.play()
示例#12
0
from threading import Thread
from classGame import Game

if __name__ == "__main__":
    G = Game()
    while True:
        socJogador = G.S.conectar()
        Thread(target=G.palavra_do_jogo, args=(socJogador,)).start()