Beispiel #1
0
    def __init__(self, use_network=False):
        self.players = None

        if use_network:
            self.players = NetworkPlayers()
        else:
            self.players = Players()
Beispiel #2
0
def eric(config_file):
    ardUniverse = ArdUniverse(config_file)        
    ardUniverse.connect_all()
    players = Players(config)

    while True:
        for sensor in ardUniverse.sensors:
            status = sensor.get_status()
            player = players.find_player_for_rfid(status)
            for event in sensor.events:
                handle_event(event, player, sensor)
Beispiel #3
0
 def __init__(self):
     """ Initializer """
     # Call the parent class initializer
     super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
     # Set the working directory (where we expect to find files) to the same
     # directory this .py file is in. You can leave this out of your own
     # code, but it is needed to easily run the examples using "python -m"
     # as mentioned at the top of this program.
     file_path = os.path.dirname(os.path.abspath(__file__))
     os.chdir(file_path)
     arcade.set_background_color(arcade.color.AMAZON)
     self.players = Players()
Beispiel #4
0
 def sortPlayers(self):
     """sort by wind order. Place ourself at bottom (idx=0)"""
     self.players.sort(key=lambda x: x.wind)
     self.activePlayer = self.players[East]
     if Internal.scene:
         if self.belongsToHumanPlayer():
             while self.players[0] != self.myself:
                 self.players = Players(self.players[1:] + self.players[:1])
             for idx, player in enumerate(self.players):
                 player.front = self.wall[idx]
                 player.sideText.board = player.front
             # we want names to move simultaneously
             self.players[1].sideText.refreshAll()
Beispiel #5
0
    def assignPlayers(self, playerNames):
        """
        The server tells us the seating order and player names.

        @param playerNames: A list of 4 tuples. Each tuple holds wind and name.
        @type playerNames: The tuple contents must be C{str}
        @todo: Can we pass L{Players} instead of that tuple list?
        """
        if not self.players:
            self.players = Players()
            for idx in range(4):
                # append each separately: Until they have names, the current length of players
                # is used to assign one of the four walls to the player
                self.players.append(self.playerClass(self,
                                                     playerNames[idx][1]))
        for wind, name in playerNames:
            self.players.byName(name).wind = wind
        if self.client and self.client.name:
            self.myself = self.players.byName(self.client.name)
        self.sortPlayers()
Beispiel #6
0
    def __init__(self,
                 names,
                 ruleset,
                 gameid=None,
                 wantedGame=None,
                 client=None):
        """a new game instance. May be shown on a field, comes from database
        if gameid is set.

        Game.lastDiscard is the tile last discarded by any player. It is
        reset to None when a player gets a tile from the living end of the
        wall or after he claimed a discard.
        """
        # pylint: disable=too-many-statements
        assert self.__class__ != Game, 'Do not directly instantiate Game'
        for wind, name in names:
            assert isinstance(wind, Wind), 'Game.__init__ expects Wind objects'
            assert isinstance(
                name,
                str), 'Game.__init__: name must be string and not {}'.format(
                    type(name))
        self.players = Players()
        # if we fail later on in init, at least we can still close the program
        self.myself = None
        # the player using this client instance for talking to the server
        self.__shouldSave = False
        self._client = None
        self.client = client
        self.rotated = 0
        self.notRotated = 0  # counts hands since last rotation
        self.ruleset = None
        self.roundsFinished = 0
        self._currentHandId = None
        self._prevHandId = None
        self.wantedGame = wantedGame
        self.moves = []
        self.gameid = gameid
        self.playOpen = False
        self.autoPlay = False
        self.handctr = 0
        self.roundHandCount = 0
        self.handDiscardCount = 0
        self.divideAt = None
        self.__lastDiscard = None  # always uppercase
        self.visibleTiles = IntDict()
        self.discardedTiles = IntDict(self.visibleTiles)
        # tile names are always lowercase
        self.dangerousTiles = list()
        self.csvTags = []
        self.randomGenerator = CountingRandom(self)
        self._setHandSeed()
        self.activePlayer = None
        self.__winner = None
        self._setGameId()
        self.__useRuleset(ruleset)
        # shift rules taken from the OEMC 2005 rules
        # 2nd round: S and W shift, E and N shift
        self.shiftRules = 'SWEN,SE,WE'
        self.wall = self.wallClass(self)
        self.assignPlayers(names)
        if self.belongsToGameServer():
            self.__shufflePlayers()
        self._scanGameOption()
        for player in self.players:
            player.clearHand()
Beispiel #7
0
target_host = "localhost"

target_port = 1212  # create a socket object
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((target_host, target_port))

INSTRUKCJA = pygame.image.load('Instrukcje.png')
TEXT = pygame.image.load('txt.png')

pygame.font.init()
myfont = pygame.font.SysFont('monospace', 25)
small_font = pygame.font.SysFont('monospace', 15)

while (1):
    done = False
    p = Players(pygame)
    b = Bullets()
    m = Meteors(pygame)
    e = Enemies(pygame)
    bo = Bonus(pygame)
    g = Game()

    while (1):
        menu_ret = Menu()
        if menu_ret == 1:
            break
        elif menu_ret == 2:
            instrukcja()
        elif menu_ret == 3:
            exit()
Beispiel #8
0
def player():
    return Players()
Beispiel #9
0
room['outside'].n_to = room['foyer']
room['foyer'].s_to = room['outside']
room['foyer'].n_to = room['overlook']
room['foyer'].e_to = room['narrow']
room['overlook'].s_to = room['foyer']
room['narrow'].w_to = room['foyer']
room['narrow'].n_to = room['treasure']
room['treasure'].s_to = room['narrow']

# #
# Main
#

# Make a new player object that is currently in the 'outside' room.
player = Players(input('Player name:'), room['outside'])
print(f"Hello {player.name}")

# Write a loop that:
#
# * Prints the current room name
# * Prints the current description (the textwrap module might be useful here).
# * Waits for user input and decides what to do.
#
# If the user enters a cardinal direction, attempt to move to the room there.
# Print an error message if the movement isn't allowed.
#
# If the user enters "q", quit the game.

# LOOP
# READ
Beispiel #10
0
#everyWhere snakeCase
import random
from dealer import Dealer
from player import Players

random.seed(0)

if __name__ == '__main__':
    numPlayers = 2
    players = Players(numPlayers)
    dealer = Dealer()
    dealer.initialiseCards()
    dealer.shuffleCards()
    # print(len(dealer.drawPile), set(dealer.drawPile))
    # print(dealer.discardedCards)

    dealer.distributeCards(players.players)
    playerChance = 0
    player = players.players[playerChance]
    while (not player.hasWon()):
        print('+++++++++++++++++++++++++++++')
        print(f'Player - {player.id}')
        print('+++++++++++++++++++++++++++++')
        # print(player.handCards,player.propertyCollection, player.bankCollection)
        player.chance = True
        player.drawCards(dealer)

        print(len(dealer.drawPile), len(player.handCards))

        player.chanceNo = 1
        while player.chanceNo <= player.cardsToPlay:
Beispiel #11
0
 def genPlayers(self):
     """generate four default VisiblePlayers"""
     return Players([VisiblePlayer(self.game, idx) for idx in range(4)])
Beispiel #12
0
from player import Player
from player import Players
from teamroster import TeamRoster
from draft import Draft
from team import Teams

#max year should be current -1
minYear = 2010
maxYear = 2020
keeperDraftDate = "2021-09-19"

playerList = Players()
teamRoster = TeamRoster()
draftPick = Draft()
#teams = Teams()

#min 2007, max 2017
# should get season 2017-2018 to 2008-2009
# should get draft 2008
for currentYear in range(maxYear, minYear, -1):
    season = str(currentYear) + "" + str(currentYear + 1)
    draft = str(currentYear + 1)
    print("Season : " + season + "   draft: " + str(draft))
    teamRoster.getTeamRoster(season, keeperDraftDate, playerList)
    draftPick.getDraftPlayers(draft, keeperDraftDate, playerList)

playerListFile = ".\playerList.txt"
open(playerListFile, 'w').close()
playerList.writePlayerList(playerListFile)
print("Done")