コード例 #1
0
    def test_one_winner_with_one_multiple_same_value_card(self):
        #init player 1
        cards_player1 = []
        cards_player1.append(Card(0, 1))
        cards_player1.append(Card(3, 10))
        hand_player1 = Hand(cards_player1)
        player1 = Player("Player 1", hand_player1)

        # init player 2
        cards_player2 = []
        cards_player2.append(Card(2, 9))
        cards_player2.append(Card(1, 8))
        hand_player2 = Hand(cards_player2)
        player2 = Player("Player 2", hand_player2)

        #init Table
        cards_table = []
        cards_table.append(Card(0, 3))
        cards_table.append(Card(1, 8))
        cards_table.append(Card(2, 4))
        cards_table.append(Card(0, 7))
        cards_table.append(Card(0, 2))

        players = []
        players.append(player1)
        players.append(player2)

        pack = Pack()

        table = Table(players, pack)
        table.set_cards(cards_table)

        expected_winner = []
        expected_winner.append(player2)
        self.assertEqual(expected_winner, get_winners(players, table))
コード例 #2
0
    def read_player(self):
        if not self.read_boolean():
            return None

        return Player(self.read_long(), self.read_boolean(),
                      self.read_string(), self.read_boolean(), self.read_int(),
                      self.read_enum(Faction))
コード例 #3
0
    def __init__(self):
        self.world = World(10)
        self.gridWidth = 15
        self.gridHeight = 20
        self.playerSize = 0.5

        self.speed = 0.03
        self.killLine = -0.1

        self.platforms = [Platform(PhysicsVector(0, 0, 0), PhysicsVector(gridWidth, 0, 0))]

        self.minPlatformWidth = 1.0
        self.maxPlatformWidth = 6.0
        self.maxPlatformGaps = 8.0
        self.probabilityOfNoPlatforms = 0.2
        self.gapProbability = 0.8

        self.lastLevelGenerated = 0

        self.skipped = 0
        self.maxConsecutiveSkips = 2

        self.player = Player(
            PhysicsVector(self.gridWidth / 3.0, 0, self.gridHeight / 2.0),
            PhysicsVector(0, 0, 0)
        )
        self.world.objects = [self.player]

        self.generateUntilLevel(int(self.gridHeight) - 5)
コード例 #4
0
ファイル: test_valid_func.py プロジェクト: arturblch/Conway
def test_valid():
    factory = WorldGetter(3)

    player = Player(factory.get_player())
    map_graph = Map(factory.get_map())
    objects = Objects(factory.get_objects())

    strategy = Strategy(player, map_graph, objects)
    strategy.get_invalid_pos = lambda x: {}

    reserv_pos = {
        1: {
            0: Position(None, 1, 3),
            1: Position(2),
            2: Position(None, 12, 1)
        },
        2: {
            0: Position(None, 2, 2),
            1: Position(None, 2, 1),
            2: Position(None, 2, 2)
        }
    }

    strategy.trains_reservations = reserv_pos
    train = objects.trains[1]
    print(strategy.valid(train, Position(None, 1, 1), Position(1)))
コード例 #5
0
    def __init__(self, base, mapNo):
        self.isListening = False

        # Holds rigid bodies, joints, controls global params
        self.world = OdeWorld()
        self.world.setGravity(0, 0, -9.8)

        st = SurfaceType()
        st.load(self.world)
        del st

        self.contactgroup = OdeJointGroup()

        self.space = OdeHashSpace()
        self.space.setAutoCollideWorld(self.world)
        self.space.setAutoCollideJointGroup(self.contactgroup)
        self.space.setCollisionEvent(EventType.ODE_COLLISION)
        base.accept(EventType.ODE_COLLISION, self.onCollision)

        self.ball = Ball(self.world, self.space, "Johanneksen pallo")

        self.level = Level(self, mapNo)
        self.player = Player("Johannes")

        self.camera = Camera(base, self.ball)
コード例 #6
0
def test_base():
    factory = WorldGetter(3)
    _map = Map(factory.get_map())
    _map.pos = factory.get_pos()
    objects = Objects(factory.get_objects())
    player = Player(factory.get_player())
    i = 30
    gui = GUI(player, _map, objects, None)
    gui.fps = 30
    gui.paused = True
    while player.is_alive:
        gui.turn()
        if gui.paused == False:
            objects.trains[1].line_idx = 1
            if objects.trains[1].position == 4:
                objects.trains[1].speed = -1
            elif objects.trains[1].position == 0:
                objects.trains[1].speed = 1
            objects.trains[1].position += objects.trains[1].speed
            objects.trains[1].line_idx = 10
            if objects.trains[2].position == 5:
                objects.trains[2].speed = -1
            elif objects.trains[2].position == 0:
                objects.trains[2].speed = 1
            objects.trains[2].position += objects.trains[2].speed
            if i > 0:
                i -= 1
            else:
                player.is_alive = False

    gui.close()
コード例 #7
0
def testGetMinutesMalikBeasley():
    player = Player("1627736", "Malik Beasley", "Minnesota Timberwolves")
    actual = playerService.get2020Minutes(player.id)

    assert actual == [
        TeamMinutes('Minnesota Timberwolves', 463),
        TeamMinutes('Denver Nuggets', 746)
    ]
コード例 #8
0
ファイル: board.py プロジェクト: blondleine/SimpleMonopoly
def create_player(nicks, tokens):

    players = []

    for i in range(len(nicks)):
        players.append(Player(nicks[i], tokens[i]))

    return players
コード例 #9
0
ファイル: AccountManager.py プロジェクト: SKADAD/Dungeon_Run
 def create_new_character(self, name, classtype):
     # Kolla ifall namnet redan finns. Om ja, returnera False. Annars skapa ny player och returnera True
     if self.get_character_by_name(name):
         return False
     else:
         self.list_of_characters.append(Player(name, classtype))
         self.save_list_characters()
         return True
コード例 #10
0
ファイル: World.py プロジェクト: arturblch/Conway
def get_world():
    factory = WorldGetter(3)

    player = Player(factory.get_player())
    map_ = Map(factory.get_map())
    map_.pos = factory.get_pos()
    objects = Objects(factory.get_objects())

    return World(player, map_, objects)
コード例 #11
0
ファイル: GameFactory.py プロジェクト: siwells/ADAMANT
 def enterPlayer(self, ctx: dgdlParser.PlayerContext):
     data = str(ctx.getText())
     player = Player()
     if str(ctx.NAME()) in data:
         player.name = StringParser.between(data, str(ctx.NAME()) + COLON,
                                            COMMA if (ctx.roles()) else CLOSE_BRACE)
     if ctx.roles():
         roles = self.visit(ctx.roles())
         player.roles = roles
     self.game.players.list.append(player)
コード例 #12
0
 def __init__(self):
     self.fps = 60
     self.towers_position = []
     self.enemies_positions = []
     self.game_player = Player("Player 1", 0, 100)
     self.main_window = MainWindow(self.game_player)
     self.timer = QTimer()
     self.timer.timeout.connect(self.main_window.updateUI)
     self.timer.start(self.REFRESH_RATE)
     self.start_game()
コード例 #13
0
ファイル: Game.py プロジェクト: elsa02/poker
def init_table(number_players):
    #initialise pack of card"""
    pack = init_pack()
    #initialise players"""
    i = 1
    players = []
    while i <= number_players:
        players.append(Player("Player " + str(i), Hand(remove_cards(2, pack))))
        i += 1
    return Table(players, pack)
コード例 #14
0
 def multi_login(self,
                 name,
                 game_name='Conway',
                 num_players=4,
                 security_key=None):
     message = {"name": name, "game": game_name, "num_players": num_players}
     if security_key:
         message.update({"security_key": security_key})
     response = self.write_message('LOGIN', message)
     assert (response[0] == 0)
     return Player(response[1])
コード例 #15
0
    def read_player(self):
        if not self.read_boolean():
            return None

        return Player(self.read_long(),
                      self.read_boolean(), self.read_string(), self.read_int(),
                      self.read_boolean(), self.read_double(),
                      self.read_double(), self.read_double(),
                      self.read_double(), self.read_double(),
                      self.read_double(), self.read_boolean(),
                      self.read_boolean())
コード例 #16
0
ファイル: MyGameLogic.py プロジェクト: bryantfhayes/ProjectRL
	def init(self):
		Logic.init(self)

		# Init state of the game...
		self.player = Player(50, 50, "@", self.msgBus)#, aiType=AIType.AIType_Zombie)
		self.addEntity(self.player)

		# Force camera to follow player entity
		msg = Message(sender=self, target=None, msgType=MsgType.eMsgType_CameraFollowEntity, data=self.player)
		self.msgBus.postMessage(msg)

		self.generateMap(100, 100)
コード例 #17
0
    def read_player(self):
        flag = self.read_signed_byte()

        if flag == 0:
            return None

        if flag == 127:
            return self.previous_player_by_id[self.read_long()]

        player = Player(self.read_long(), self.read_boolean(),
                        self.read_boolean(), self.read_int(), self.read_int())
        self.previous_player_by_id[player.id] = player
        return player
コード例 #18
0
    def read_player(self):
        flag = self.read_signed_byte()

        if flag == 0:
            return None

        if flag == 100:
            return self.player_by_id[self.read_long()]

        player = Player(self.read_long(), self.read_boolean(),
                        self.read_string(), self.read_boolean(),
                        self.read_int(), self.read_enum(Faction))
        self.player_by_id[player.id] = player
        return player
コード例 #19
0
def game_on():
    deck = Deck()
    deck.shuffleCards()
    playerOne = Player('Tom')
    playerTwo = Player('Jerry')
    playerOne.addCards(deck.all_cards[:26])
    playerTwo.addCards(deck.all_cards[26:])
    playerOne.displayCards()
    playerTwo.displayCards()
    print("Game On")
    round = 0
    war = []
    while True:
        round += 1
        print(f'Round {round}')
        war.extend([playerOne.all_cards[0], playerTwo.all_cards[0]])
        if playerOne.all_cards[0].value == playerTwo.all_cards[0].value:
            pass
        elif playerOne.all_cards[0].value > playerTwo.all_cards[0].value:
            print(f"Advantage for player {playerOne.name}")
            playerOne.addCards(war)
            war = []
        else:
            print(f"Advantage for player {playerTwo.name}")
            playerTwo.addCards(war)
            war = []
        playerOne.removeCard()
        playerTwo.removeCard()
        print(
            f"{playerOne.name}: {len(playerOne.all_cards)}, {playerTwo.name}: {len(playerTwo.all_cards)}"
        )
        if len(playerOne.all_cards) == 0:
            print(f"{playerTwo.name} wins!")
            break
        elif len(playerTwo.all_cards) == 0:
            print(f"{playerOne.name} wins!")
            break
コード例 #20
0
    def test_updateWorld(self):
        physics = Physics()
        location = PhysicsVector(5, 0, 50)
        velocity = PhysicsVector(0, 0, 0)
        player = Player(location, velocity)
        world = World(5)
        dt = 3

        world.objects.append(player)

        physics.updateWorld(player, world, dt)

        self.assertTrue(player.velocity.x == 0)
        self.assertTrue(player.velocity.y == 0)
        self.assertTrue(player.velocity.z == -15)
コード例 #21
0
    def getAllPlayers(_):
        players = {}
        stats = NbaStats(
            requests.get(ALL_PLAYERS_PATH, headers=NBA_STATS_HEADERS).json())
        idColumnIndex = stats.getColumnIndex('PERSON_ID')
        nameColumnIndex = stats.getColumnIndex('DISPLAY_FIRST_LAST')
        teamCityColumnIndex = stats.getColumnIndex('TEAM_CITY')
        teamNameColumnIndex = stats.getColumnIndex('TEAM_NAME')

        for row in stats.getRows():
            playerName = row[nameColumnIndex]
            players[playerName] = Player(
                row[idColumnIndex], playerName,
                row[teamCityColumnIndex] + ' ' + row[teamNameColumnIndex])
        return players
コード例 #22
0
    def __init__(self, num_tiles, num_mines):
        super(MineSweeper, self).__init__()
        self.n = num_tiles
        self.num_mines = num_mines
        self.player = Player()
        self.setWindowTitle("Minesweeper")

        squareGame = QAction("&Square", self)
        squareGame.triggered.connect(self.generate_square_map)

        hexGame = QAction("&Hexagonal", self)
        hexGame.triggered.connect(self.generate_hex_map)

        coloredGame = QAction("&Colored", self)
        coloredGame.triggered.connect(self.generate_colored_map)

        quitGame = QAction("&Quit", self)
        quitGame.triggered.connect(self.quit_game)

        self.statusBar()

        mainMenu = self.menuBar()
        gameMenu = mainMenu.addMenu('&Game')
        gameMenu.addAction(squareGame)
        gameMenu.addAction(hexGame)
        gameMenu.addAction(coloredGame)
        gameMenu.addAction(quitGame)

        w = QWidget()

        

        self.clock = QLabel()
        self.clock.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)

        self.clock.setText("000")
        self.grid = QGridLayout()
        self.grid.setSpacing(5)

        self.gameStatus = 1

        vb = QVBoxLayout()
        vb.addWidget(self.clock)
        vb.addLayout(self.grid)
        w.setLayout(vb)
        self.setCentralWidget(w)

        self.show()
コード例 #23
0
    def read_players(self):
        player_count = self.read_int()
        if player_count < 0:
            return None

        players = []

        for player_index in range(player_count):
            if self.read_boolean():
                player = Player(self.read_string(), self.read_int(),
                                self.read_boolean())
                players.append(player)
            else:
                players.append(None)

        return players
コード例 #24
0
    def read_player(self):
        flag = self.read_signed_byte()

        if flag == 0:
            return None

        if flag == 127:
            return self.previous_player_by_id[self.read_long()]

        player = RemoteProcessClient.PLAYER_STRUCT.unpack(self.read_bytes(50))

        player = Player(player[0], player[1] != 0, player[2] != 0, player[3],
                        player[4], player[5], player[6], player[7], player[8],
                        player[9])
        self.previous_player_by_id[player.id] = player
        return player
コード例 #25
0
    def test_detectPlatformCollision(self):
        physics = Physics()

        platform_start = PhysicsVector(3, 0, 5)
        platform_end = PhysicsVector(6, 0, 5)

        platform = Platform(platform_start, platform_end, 0)

        dt = 3

        location = PhysicsVector(4, 0, 6)
        velocity = PhysicsVector(0, 0, -1)
        player = Player(location, velocity)
        potentialLocation = physics.computePotentialLocation(player, dt)

        actual = physics.detectPlatformCollision(player, potentialLocation,
                                                 platform)

        self.assertTrue(actual)
コード例 #26
0
    def read_player(self):
        flag = self.read_signed_byte()

        if flag == 0:
            return None

        if flag == 127:
            return self.previous_player_by_id[self.read_long()]

        byte_array = self.read_bytes(50)
        player = struct.unpack(
            RemoteProcessClient.BYTE_ORDER_FORMAT_STRING + "q2b3iqi2d",
            byte_array)

        player = Player(player[0], player[1] != 0, player[2] != 0, player[3],
                        player[4], player[5], player[6], player[7], player[8],
                        player[9])
        self.previous_player_by_id[player.id] = player
        return player
コード例 #27
0
 def _get_players(self, details):
     """
     Get all of the player names, heroes, IDs, team affiliation, and win/loss.
     """
     parsed_players = []
     players = details['m_playerList']
     for player in players:
         name = player['m_name']
         hero = player['m_hero']
         team_id = player['m_teamId']
         working_slot_id = player['m_workingSetSlotId']
         result = player['m_result']
         parsed_player = Player(
             name=name,
             hero=hero,
             team=team_id,
             id=working_slot_id,
             winner=(result == 1),
         )
         parsed_players.append(parsed_player)
     return parsed_players
コード例 #28
0
 def initialize_players(n_players, start_square):
     players = []
     for i in range(n_players):
         new_player = Player(i, start_square)
         players.append(new_player)
     return players
コード例 #29
0
 def login(self, name):
     response = self.write_message('LOGIN', {"name": name})[1]
     return Player(response)
コード例 #30
0
 def playerSoupToPlayer(self, soupPlayer, teamName):
     name = soupPlayer.contents[1].find_all(
         'span')[1].contents[0].contents[0]
     rating = int(soupPlayer.contents[2].contents[0].contents[0])
     return Player(name, teamName, rating)