Ejemplo n.º 1
0
def create_teams():
    session = Session()
    Base.metadata.create_all()
    session.commit()
    t1 = Team()
    t1.name = 'Matematici'
    t2 = Team()
    t2.name = 'Fisici'
    session.add(t1)
    session.add(t2)
    session.commit()
Ejemplo n.º 2
0
def update_team(n_clicks, teamname):

    print('updating team')
    global TEAM
    TEAM = Team(teamname)

    return teamname
Ejemplo n.º 3
0
def team_request(tour_id: int):
    form = TeamForm()
    session = create_session()
    tour = session.query(Tournament).get(tour_id)
    if not tour:
        abort(404)
    try:
        if form.validate_on_submit():  # Validate posted data
            team = Team().fill(
                name=form.name.data,
                motto=form.motto.data,
                trainer_id=current_user.id,
                tournament_id=tour.id,
            )
            emails = set()
            vk_uids = []
            for field in form.players.entries:  # Check players
                email = field.data.lower()
                if email in emails:
                    field.errors.append("Участник указан несколько раза")
                    raise ValidationError
                emails.add(email)
                user = session.query(User).filter(User.email == email).first()
                if not user:
                    field.errors.append("Пользователь не найден.")
                    raise ValidationError
                team.players.append(user)
                if user.integration_with_VK:
                    vk_uids.append(user.id)
            session.add(team)
            session.commit()

            # Send notifications to players
            msg = Message(subject='Участие в турнире MatBoy',
                          recipients=list(emails),
                          sender=config.MAIL_DEFAULT_SENDER,
                          html=render_template('mails/email/invite_team.html',
                                               team=team,
                                               tour=tour))
            thr_email = Thread(target=send_message, args=[msg])
            thr_vk = Thread(target=bot.notification_message,
                            args=[
                                render_template('mails/vk/invite_team.vkmsg',
                                                team=team,
                                                tour=tour), vk_uids
                            ])
            thr_email.start()
            thr_vk.start()
            return redirect(team.link)
    except ValidationError:
        pass

    return render_template("team_form.html",
                           edit=False,
                           tour=tour,
                           form=form,
                           menu=make_menu(session,
                                          tour_id=tour_id,
                                          now='Командная заявка'))
Ejemplo n.º 4
0
def parse_data(json_data):
    """parse the json file into Event object
        * Qualy: starting grid is based on qualy
        * Race: starting grid is based on the selected lap

       the method may ask for user input

    Args:
        json_data ([type]): json dict of server dump

    Returns:
        [type]: Event Object
    """

    ev = Event()
    ev.name = json_data['trackName']

    leaders = json_data['sessionResult']['leaderBoardLines']

    i = 1
    for team_json in leaders:
        car = team_json['car']

        team = Team()
        team.defaultGridPosition = i
        team.forcedCarModel = car['carModel']
        team.raceNumber = car['raceNumber']
        team.carId = car['carId']
        
        for driver in car['drivers']:
            d = Driver()
            d.firstName = driver['firstName']
            d.lastName = driver['lastName']
            d.shortName = driver['shortName']
            d.playerID = driver['playerId']

            team.drivers.append(d)

        ev.teams.append(team)
        i += 1





    if json_data['sessionType'] == 'Q':
        print('detected Qualy session')
        return ev
    elif json_data['sessionType'] == 'R':
        print('detected Race session')
        return parse_race_abort(json_data, ev)
    else:
        print('unsupported session type, applying qualy procedure')
        return ev
        
        
    return ev
Ejemplo n.º 5
0
def team_request(tour_id: int):
    form = TeamForm()
    session = create_session()
    tour = session.query(Tournament).get(tour_id)
    if not tour:
        abort(404)
    if form.validate_on_submit():
        team = Team().fill(
            name=form.name.data,
            motto=form.motto.data,
            trainer_id=current_user.id,
            tournament_id=tour.id,
        )

        for email in form.players.data:
            user = session.query(User).filter(User.email == email).first()
            if not user:
                return render_template("team_request.html", tour=tour, form=form)
            team.players.append(user)
        session.add(team)
        session.commit()
        return redirect(f"/team/{team.id}")

    return render_template("team_request.html", tour=tour, form=form)
Ejemplo n.º 6
0
from data import Team
import subprocess

e = Team('Elf')
d = Team('Dwarf')
de = Team('DarkElf')
o  = Team('Ork')
g  = Team('Gnome')

e.from_toml()
d.from_toml()
de.from_toml()
o.from_toml()
g.from_toml()

e.write_pdf()
d.write_pdf()
de.write_pdf()
o.write_pdf()
g.write_pdf()


subprocess.call(['pdflatex', 'armies.tex'])
subprocess.call(['pdflatex', 'armies.tex'])




Ejemplo n.º 7
0
from data import Team

elf = Team('Elf')
elf.from_toml()

knut = Team('StandarElf')

knut.units['Tattoo Ink'] = elf.units['Tattoo Ink']
knut.units['Bear Rider'] = elf.units['Bear Rider']
knut.units['Elf Infantry'] = elf.units['Elf Infantry']
knut.units['Illusion'] = elf.units['Illusion']

knut.weapons['Camuflouflage'] = elf.weapons['Camuflouflage']
knut.weapons['Enhanced Rifle'] = elf.weapons['Enhanced Rifle']
knut.weapons['Small grenade'] = elf.weapons['Small grenade']

knut.copy_weapons_from(elf)

knut.write_pdf()

de = Team('DarkElf')
de.from_toml()

bjorn = Team('StandarDarkElf')

bjorn.units['Mechanical Assault Spider'] = de.units[
    'Mechanical Assault Spider']
bjorn.units['Elite Mechanical Cavalry'] = de.units['Elite Mechanical Cavalry']
bjorn.units['Infantry'] = de.units['Infantry']

bjorn.weapons['Mechanical Imp'] = de.weapons['Mechanical Imp']
Ejemplo n.º 8
0
import re

#steampunkFantazy imports
import build
from data import Team

# Ask for input, team name should correspond to a TOML file
team_name = input("Choose team: ")
team = Team(team_name)
try:
    team.from_toml()
except FileNotFoundError:
    team_files = pathlib.Path.cwd().glob("[A-Z]*.toml")
    teams = sorted(t.stem for t in team_files)
    print(f"Unknown team {team_name!r}. Choose one of {', '.join(teams)}")
    raise SystemExit()

# Team numbers can be a list of numbers, pick a random team if none is given
team_numbers = input("Choose team numbers: ")
if team_numbers:
    team_numbers = [int(n) for n in re.split(r"[\s,]+", team_numbers)]
else:
    team_numbers = [random.randint(0, 1_000_000)]
    print(f"Using team number {team_numbers[0]}")

# Choose armies and print them out
for team_number in team_numbers:
    units = build.pick_units(team, seed=team_number)
    build.print_units(team, units)