예제 #1
0
    def __init__(self, screen, messages_to_send, our_team,
                 our_team_first_move):
        self.game_state = STATE_PREPARING
        self.images = {
            'ocean': pygame.image.load('ocean.jpg').convert(),
            'explosion': pygame.image.load('explosion.jpg').convert(),
            'ship': pygame.image.load('battleship.jpg').convert()
        }
        self.our_board = Board(pygame.freetype.Font, GAME_SIZE, 5, 0,
                               self.images)

        self.load_positions_button = Button(
            "Load", 10, 750, self.our_board.load_positions_from_file)
        self.messages_to_send = messages_to_send
        self.our_team = our_team
        self.our_team_first_move = our_team_first_move
        self.save_positions_button = Button(
            "Save", 70, 750, self.our_board.save_positions_to_file)
        self.start_game_button = Button("Start", 130, 750, self.start_game)
        self.status_bar = StatusBar()
        self.screen = screen
        self.selected_their_team = None
        self.selected_their_team_first_move = None
        self.start_game_button.set_enabled(False)
        self.status_bar.update_text(
            'Choose your positions, an opponent, and click Start.')
        self.teams = Teams()
        self.their_board = Board(pygame.freetype.Font, GAME_SIZE, 580, 0,
                                 self.images)
        self.their_team = None
예제 #2
0
파일: engine.py 프로젝트: alan412/CheckMeIn
    def __init__(self, dbPath, dbName):
        self.database = dbPath + dbName
        self.dataPath = dbPath
        self.visits = Visits()
        self.guests = Guests()
        self.reports = Reports(self)
        self.teams = Teams()
        self.accounts = Accounts()
        self.devices = Devices()
        self.unlocks = Unlocks()
        # needs path since it will open read only
        self.customReports = CustomReports(self.database)
        self.certifications = Certifications()
        self.members = Members()
        self.logEvents = LogEvents()

        if not os.path.exists(self.database):
            if not os.path.exists(dbPath):
                os.mkdir(dbPath)
            with self.dbConnect() as c:
                self.migrate(c, 0)
        else:
            with self.dbConnect() as c:
                data = c.execute('PRAGMA schema_version').fetchone()
                if data[0] != SCHEMA_VERSION:
                    self.migrate(c, data[0])
 def __init__(self, dict_info={}):
     if dict_info != {}:
         if "gameCreation" in dict_info.keys():
             self.gameCreation = dict_info["gameCreation"]
         if "gameDuration" in dict_info.keys():
             self.gameDuration = dict_info["gameDuration"]
         if "gameId" in dict_info.keys():
             self.gameId = dict_info["gameId"]
         if "gameMode" in dict_info.keys():
             self.gameMode = dict_info["gameMode"]
         if "gameType" in dict_info.keys():
             self.gameType = dict_info["gameType"]
         if "gameVersion" in dict_info.keys():
             self.gameVersion = dict_info["gameVersion"]
         if "mapId" in dict_info.keys():
             self.mapId = dict_info["mapId"]
         if "platformId" in dict_info.keys():
             self.platformId = dict_info["platformId"]
         if "queueId" in dict_info.keys():
             self.queueId = dict_info["queueId"]
         if "seasonId" in dict_info.keys():
             self.seasonId = dict_info["seasonId"]
         if "participantIdentities" in dict_info.keys():
             self.participantIdentities = [ParticipantIdentities(p) for p in dict_info["participantIdentities"]]
         if "participants" in dict_info.keys():
             self.participants = [Participants(p) for p in dict_info["participants"]]
         if "teams" in dict_info.keys():
             self.teams = [Teams(p) for p in dict_info["teams"]]
예제 #4
0
def generate_teams(player_list):
    team_list = []
    for i in range(simulations):
        random.shuffle(player_list)
        team = Teams(player_list[:len(player_list) // 2],
                     player_list[len(player_list) // 2:], i)
        if team.valid():
            team_list.append(team)
    return team_list
예제 #5
0
def lambda_handler(event, context):
    teams = Teams()
    try:
        domain = os.environ.get('BACKLOG_DOMAIN', '')

        for record in event['Records']:
            message_body = json.loads(record['body'])
            message = json.loads(message_body['Message'])

            logger.info(message)

            project = get_value(message, 'project')
            content = get_value(message, 'content')
            createdUser = get_value(message, 'createdUser')

            project_name = get_value(project, 'name')
            projectKey = get_value(project, 'projectKey')
            key_id = get_value(content, 'key_id')
            summary = get_value(content, 'summary')
            milestone_array = get_value(content, 'milestone')
            if len(milestone_array) > 0:
                milestone = get_value(milestone_array[0], 'name')
            else:
                milestone = ''
            estimatedHours = round(get_value(content, 'estimatedHours'), 2)
            actualHours = round(get_value(content, 'actualHours'), 2)
            comment = get_value(get_value(content, 'comment'), 'content')
            status = get_value(get_value(content, 'status'), 'name')
            user = get_value(createdUser, 'name')
            assignee = get_value(get_value(content, 'assignee'), 'name')

            changes = get_value(content, 'changes')

            url = 'https://{domain}/view/{projectKey}-{key_id}'.format(
                domain=domain, projectKey=projectKey, key_id=key_id)
            url_tag = '<a href="{url}">{url}</a>'.format(url=url)

            response = teams.send_message(
                '{summary} ({milestone})'.format(summary=summary,
                                                 milestone=milestone),
                '<b>対応状況:</b> {status}<br><b>担当:</b> {assignee}<br><b>実績時間:</b> {actualHours}<br><b>予定時間:</b> {estimatedHours}<br>{url}<br><b>更新者:</b> {user}<br>{comment}{changes}'
                .format(status=status,
                        user=user,
                        comment=get_comment(comment),
                        actualHours=actualHours,
                        estimatedHours=estimatedHours,
                        url=url_tag,
                        assignee=assignee,
                        changes=get_changes(changes)))

            logger.info(response)
            logger.info(response.text)

    except:
        logger.error(traceback.format_exc())
        raise Exception(traceback.format_exc())
예제 #6
0
def lambda_handler(event, context):
    teams = Teams()
    try:
        domain = os.environ.get('BACKLOG_DOMAIN', '')
        milestone = int(os.environ.get('QA_MILESTONE', '0'))

        for record in event['Records']:
            message_body = json.loads(record['body'])
            message = json.loads(message_body['Message'])

            project = get_value(message, 'project')
            content = get_value(message, 'content')
            createdUser = get_value(message, 'createdUser')

            milestone_array = get_value(content, 'milestone')
            if len(milestone_array) > 0:
                milestone_id = get_value(milestone_array[0], 'id')
            else:
                return

            if milestone_id != milestone:
                return

            projectKey = get_value(project, 'projectKey')
            key_id = get_value(content, 'key_id')

            description = get_value(content, 'description')

            comment = get_value(get_value(content, 'comment'), 'content')
            user = get_value(createdUser, 'name')

            url = 'https://{domain}/view/{projectKey}-{key_id}'.format(
                domain=domain,
                projectKey=projectKey,
                key_id=key_id
            )
            url_tag = '<a href="{url}">{url}</a>'.format(
                url=url
            )

            teams.send_message(
                '回答',
                '**質問**:{description}<br><br>**{user}の回答**:{comment}<br><br>{url}'.format(
                    description=description,
                    user=user,
                    comment=comment,
                    url=url_tag
                )
            )
    except:
        logger.error(traceback.format_exc())
        raise Exception(traceback.format_exc())
class CompleteGame:
    gameCreation = 0
    gameDuration = 0
    gameId = 0
    gameMode = ""
    gameType = ""
    gameVersion = ""
    mapId = 0
    platformId = ""
    queueId = 0
    seasonId = 0
    participantIdentities = [ParticipantIdentities()]
    teams = [Teams()]
    participants = [Participants()]

    def __init__(self, dict_info={}):
        if dict_info != {}:
            if "gameCreation" in dict_info.keys():
                self.gameCreation = dict_info["gameCreation"]
            if "gameDuration" in dict_info.keys():
                self.gameDuration = dict_info["gameDuration"]
            if "gameId" in dict_info.keys():
                self.gameId = dict_info["gameId"]
            if "gameMode" in dict_info.keys():
                self.gameMode = dict_info["gameMode"]
            if "gameType" in dict_info.keys():
                self.gameType = dict_info["gameType"]
            if "gameVersion" in dict_info.keys():
                self.gameVersion = dict_info["gameVersion"]
            if "mapId" in dict_info.keys():
                self.mapId = dict_info["mapId"]
            if "platformId" in dict_info.keys():
                self.platformId = dict_info["platformId"]
            if "queueId" in dict_info.keys():
                self.queueId = dict_info["queueId"]
            if "seasonId" in dict_info.keys():
                self.seasonId = dict_info["seasonId"]
            if "participantIdentities" in dict_info.keys():
                self.participantIdentities = [ParticipantIdentities(p) for p in dict_info["participantIdentities"]]
            if "participants" in dict_info.keys():
                self.participants = [Participants(p) for p in dict_info["participants"]]
            if "teams" in dict_info.keys():
                self.teams = [Teams(p) for p in dict_info["teams"]]

    def __str__(self):
        return "GameId: " + str(self.gameId) + "\n" + \
               "GameDuration: " + duration_game_str(self.gameDuration) + "\n" + \
               "GameMode: " + str(self.gameMode) + "\n" + \
               "GameType: " + str(self.gameType) + "\n" + \
               "QueueId: " + queue_str(self.queueId) + "\n" + \
               "SeasonId: " + season_str(self.seasonId)
예제 #8
0
def main():

    team = Teams(input('Name player 1:'))
    dice_rolls = int(input('How many dice would you like to roll? '))
    dice_size = int(input('How many sides are th dice? '))
    dice_sum = 0

    for i in range(0, dice_rolls):
        roll = random.randint(1, dice_size)
        dice_sum += roll
        team.team_score += roll
        if (roll == 1):
            print(f'You rolled a {roll}! Critical Fail.')
        elif (roll == dice_size):
            print(f'You rolled a {roll}! Critical Success!.')
        else:
            print(f'You rolled a {roll}')
    print(f'You have rolled a total of {dice_sum}!')
    team.description()
    input('Press any key to Exit')
def main():
    print("""######\tTests players.py\t######""")
    a = Players()
    a.see_all()

    print("""######\tTests PlayerStats\t######""")
    b = PlayerStats(a)
    b.see_all()
    print()

    print("""######\tTests Events\t######""")
    d = Events()
    d.see_all()
    print()

    print("""######\tTests Teams\t######""")
    c = Teams(a, d)
    c.see_all()
    print()

    print("""######\tTests Awards\t######""")
    e = Awards()
    e.see_all()
    print()
예제 #10
0
 def __init__(self, app):
     self.app = app
     self.app.teams = Teams(app)
     self.app.players = Players(app)
     self.app.seasons = Seasons2(app)
예제 #11
0
        )
        rows = cursor.fetchall()
        for row in rows:
            if row[1] != "pg_stat_statements":
                cursor.execute("drop table " + row[1] + " cascade")

        connection.commit()
    return redirect(url_for('create_tables'))


if __name__ == '__main__':
    '''Container objects'''

    app.coaches = Coaches2(app)
    app.coaching = Coaching2(app)
    app.teams = Teams(app)
    app.players = Players(app)
    app.countries = Countries(app)
    app.leagues = Leagues(app)
    app.stadiums = Stadiums(app)
    app.officials = Officials(app)
    app.seasons = Seasons2(app)
    app.matches = Matches(app)
    app.statisticsTeam = StatisticsT(app)
    app.statisticsPlayer = StatisticsP(app)
    app.fixtures = Fixtures(app)
    app.squads = Squads(app)
    app.transfers = Transfers(app)

    VCAP_APP_PORT = os.getenv('VCAP_APP_PORT')
    if VCAP_APP_PORT is not None:
예제 #12
0
def lambda_handler(event, context):
    teams = Teams()
    try:
        s3 = boto3.resource('s3')
        bucket_name = os.environ.get('BUCKET_NAME', None)

        for record in event['Records']:
            message_body = json.loads(record['body'])
            message = json.loads(message_body['Message'])

            project = get_value(message, 'project')
            content = get_value(message, 'content')

            projectKey = get_value(project, 'projectKey')
            key_id = get_value(content, 'key_id')

            object_key = '{projectKey}-{key_id}.json'.format(
                projectKey=projectKey,
                key_id=key_id
            )

            obj = s3.Object(
                bucket_name,
                object_key
            )

            milestone_array = get_value(content, 'milestone')
            if len(milestone_array) > 0:
                milestone = get_value(milestone_array[0], 'name')
            else:
                milestone = ''
            estimatedHours = get_value(content, 'estimatedHours')
            actualHours = get_value(content, 'actualHours')
            status = get_value(get_value(content, 'status'), 'name')
            assignee = get_value(get_value(content, 'assignee'), 'name')
            issueType = get_value(get_value(content, 'issueType'), 'name')
            startDate = get_value(content, 'startDate')
            dueDate = get_value(content, 'dueDate')
            summary = get_value(content, 'summary')

            ticket_json = {
                'milestone': milestone,
                'estimatedHours': estimatedHours,
                'actualHours': actualHours,
                'status': status,
                'assignee': assignee,
                'issueType': issueType,
                'startDate': startDate,
                'dueDate': dueDate,
                'summary': summary
            }

            response = obj.put(
                Body=json.dumps(ticket_json)
            )

            logger.info(response)

    except:
        logger.error(traceback.format_exc())
        teams.send_message(
            'Error',
            traceback.format_exc()
        )
        raise Exception(traceback.format_exc())
예제 #13
0
for table in range(int(len(st_body) / 2)):
    team_list = st_body[table].find_all('tr')[2:]

    for t in team_list:
        name = t.find('a').contents[0]
        link = t.find('a')['href']
        team_id = link[link.find('teamId=') +
                       len('teamId='):link.find('seasonId') - 1]
        title = t.find('a')['title']
        owner = title[title.find('(') + 1:title.find(')')]
        wins = t.find_all('td')[1].contents[0]
        losses = t.find_all('td')[2].contents[0]
        ties = t.find_all('td')[3].contents[0]
        win_perc = t.find_all('td')[4].contents[0]
        ffl_teams.append(
            Teams(name, owner, link, team_id, wins, losses, ties, win_perc))
#        print(name)

#end t for
#end table for

#sort teams by team_id
ffl_teams = sorted(ffl_teams, key=lambda teams: teams.team_id)

t_id = []
t_name = []
t_actual_wlp = []
for t in ffl_teams:
    #    print(t)
    t_id.append(t.team_id)
    t_name.append(t.name)
예제 #14
0
            p.add_match_with_player(q, False)


if __name__ == "__main__":
    # load history
    print(
        "\nBalance   Strength  Adv             Azul X Vermelho      Winner   AA  AD  AS  VA  VD  VS  Avg."
    )
    for game in games:
        blue = [[q for q in players if q.name == p][0]
                for p in game['Azul']['players']]
        red = [[q for q in players if q.name == p][0]
               for p in game['Vermelho']['players']]
        score_blue = game['Azul']['score']
        score_red = game['Vermelho']['score']
        teams = Teams(blue, red, 0, [score_blue, score_red])
        tie = []
        if score_blue == score_red:
            blue_result = 0
            red_result = 0
        else:
            blue_result = 1 if score_blue > score_red else -1
            red_result = 1 if score_red > score_blue else -1
        for p in blue:
            p.add_match_result(blue_result)
        for p in red:
            p.add_match_result(red_result)
        update_matches(teams.team_a, teams.team_b)
        update_matches(teams.team_b, teams.team_a)
        print(teams)
예제 #15
0
 def __init__(self, app):
     self.app = app
     self.app.teams = Teams(app)
     self.app.officials = Officials(app)
     self.app.seasons = Seasons2(app)
예제 #16
0
 def team_ids_dict(self):
     team_ids_dict = dict(
         zip(list(Teams().teams_dataframe()['team_name']),
             list(Teams().teams_dataframe().index)))
     return team_ids_dict
예제 #17
0
def lambda_handler(event, context):
    teams = Teams()
    try:
        s3 = boto3.resource('s3')
        bucket_name = os.environ.get('BUCKET_NAME', None)
        api_url = os.environ.get('API_URL', None)
        api_key = os.environ.get('API_KEY', None)
        project_id = os.environ.get('PROJECT_ID', None)
        offset = 0

        backlog_url = '{api_url}?apiKey={api_key}&projectId[]={project_id}&statusId[]=4&count=100&sort=keyId&order=asc&offset='.format(
            api_url=api_url, api_key=api_key, project_id=project_id)

        issues = requests.get(backlog_url + str(offset))

        while len(issues) > 0:

            for record in issues:
                message_body = json.loads(record['body'])
                message = json.loads(message_body['Message'])

                project = get_value(message, 'project')
                content = get_value(message, 'content')

                projectKey = get_value(project, 'projectKey')
                key_id = get_value(content, 'key_id')
                offset = key_id

                object_key = '{projectKey}-{key_id}.json'.format(
                    projectKey=projectKey, key_id=key_id)

                obj = s3.Object(bucket_name, object_key)

                milestone_array = get_value(content, 'milestone')
                if len(milestone_array) > 0:
                    milestone = get_value(milestone_array[0], 'name')
                else:
                    milestone = ''
                estimatedHours = get_value(content, 'estimatedHours')
                actualHours = get_value(content, 'actualHours')
                status = get_value(get_value(content, 'status'), 'name')
                assignee = get_value(get_value(content, 'assignee'), 'name')
                issueType = get_value(get_value(content, 'issueType'), 'name')
                startDate = get_value(content, 'startDate')
                dueDate = get_value(content, 'dueDate')
                summary = get_value(content, 'summary')

                ticket_json = {
                    'milestone': milestone,
                    'estimatedHours': estimatedHours,
                    'actualHours': actualHours,
                    'status': status,
                    'assignee': assignee,
                    'issueType': issueType,
                    'startDate': startDate,
                    'dueDate': dueDate,
                    'summary': summary
                }

                response = obj.put(Body=json.dumps(ticket_json))

                logger.info(response)

            issues = requests.get(backlog_url + str(offset))
            teams.send_message(str(offset))

    except:
        logger.error(traceback.format_exc())
        teams.send_message('Error', traceback.format_exc())
        raise Exception(traceback.format_exc())