def fDefend(team): """ Formation for one missing field player """ # gets teammate that is chaser (could be me) chaser_mate = team.determineChaser() # if i am chaser if chaser_mate.playerNumber == team.brain.my.playerNumber: team.me.role = PBConstants.CHASER return ["fOneDown"] + Roles.rChaser(team) other_teammates = team.getNonChaserTeammates(chaser_mate) # get fellow teammate who isn't chaser for mate in other_teammates: if not mate.inactive: otherMate = mate else: mate.role = PBConstants.OFFENDER defInfo = Roles.rDefender(team) defPlayer = team.determineSupporter([otherMate], defInfo) if defPlayer.playerNumber == team.brain.my.playerNumber: return ["fOneDownDefend"] + defInfo return ["fOneDownDefend"] + Roles.rMiddie(team)
def aggressive_defense(me, my_teammate, opponent1, opponent2, ball): section = Utilities.get_field_section(ball.xhat) if me.ally1: if section == 1: return Roles.defensive_defender(me, my_teammate, opponent1, opponent2, ball) elif section == 2: return Roles.offensive_defender(me, my_teammate, opponent1, opponent2, ball) elif section == 3: return Roles.defensive_attacker(me, my_teammate, opponent1, opponent2, ball) elif section == 4: return Roles.defensive_attacker(me, my_teammate, opponent1, opponent2, ball) else: return (me.xhat, me.yhat, me.thetahat) #default, returns current pos else: if section == 1: return Roles.offensive_goalie(me, my_teammate, opponent1, opponent2, ball) elif section == 2: return Roles.offensive_goalie(me, my_teammate, opponent1, opponent2, ball) #This used to be offensive defender, but i want to see the goalie do it's thing elif section == 3: return Roles.defensive_attacker(me, my_teammate, opponent1, opponent2, ball) elif section == 4: return Roles.defensive_attacker(me, my_teammate, opponent1, opponent2, ball) else: return (me.xhat, me.yhat, me.thetahat) #default, returns current pos
def aggressive_offense(me, my_teammate, opponent1, opponent2, ball): global _beginning_trick_shot section = Utilities.get_field_section(ball.xhat) if me.ally1: # if not Plays.beginning_trick_shot_done(): # return Plays.shoot_off_the_wall(me, ball) if section == 1: return Roles.offensive_defender(me, my_teammate, opponent1, opponent2, ball) elif section == 2: return Roles.offensive_defender(me, my_teammate, opponent1, opponent2, ball) elif section == 3: return Roles.offensive_attacker(me, my_teammate, opponent1, opponent2, ball) elif section == 4: return Roles.offensive_attacker(me, my_teammate, opponent1, opponent2, ball) else: return (me.xhat, me.yhat, me.thetahat) #default, returns current pos else: if section == 1: return Roles.offensive_goalie(me, my_teammate, opponent1, opponent2, ball) elif section == 2: return Roles.offensive_goalie(me, my_teammate, opponent1, opponent2, ball) #This used to be offensive defender, but i want to see the goalie do it's thing elif section == 3: return Roles.offensive_attacker(me, my_teammate, opponent1, opponent2, ball) elif section == 4: return Roles.offensive_attacker(me, my_teammate, opponent1, opponent2, ball) else: return (me.xhat, me.yhat, me.thetahat) #default, returns current pos
def passive_aggressive(me, my_teammate, opponent1, opponent2, ball): #AKA, mild offense/defense section = Utilities.get_field_section(ball.xhat) if me.ally1: if section == 1: return Roles.neutral_defender(me, my_teammate, opponent1, opponent2, ball) elif section == 2: return Roles.neutral_defender(me, my_teammate, opponent1, opponent2, ball) elif section == 3: return Roles.neutral_attacker(me, my_teammate, opponent1, opponent2, ball) elif section == 4: return Roles.neutral_attacker(me, my_teammate, opponent1, opponent2, ball) else: return (me.xhat, me.yhat, me.thetahat) #default, returns current pos else: if section == 1: return Roles.neutral_goalie(me, my_teammate, opponent1, opponent2, ball) elif section == 2: return Roles.neutral_defender(me, my_teammate, opponent1, opponent2, ball) elif section == 3: return Roles.neutral_defender(me, my_teammate, opponent1, opponent2, ball) elif section == 4: return Roles.neutral_attacker(me, my_teammate, opponent1, opponent2, ball) else: return (me.xhat, me.yhat, me.thetahat) #default, returns current pos
def fOneDown(team): """ Formation for one missing field player """ # gets teammate that is chaser (could be me) chaser_mate = team.determineChaser() # if i am chaser if chaser_mate.playerNumber == team.brain.my.playerNumber: team.me.role = PBConstants.CHASER return ["fOneDown"] + Roles.rChaser(team) else: other_teammates = team.getNonChaserTeammates(chaser_mate) # If two robots are inactive, we become defender team.me.role = PBConstants.DEFENDER other_teammates[0].role = PBConstants.OFFENDER other_teammates[1].role = PBConstants.MIDDIE return ["fOneDown"] + Roles.rDefender(team)
def fKickoffPlay(team): """time immediately after kickoff""" if team.brain.my.playerNumber == 2: return ["fKickoffPlay", PBConstants.DEFENDER] + SubRoles.pKickoffPlaySweeper(team) elif team.brain.my.playerNumber == 3: return ["fKickoffPlay"] + Roles.rChaser(team) # elif team.brain.my.playerNumber == 4: else: return ["fKickoffPlay", PBConstants.OFFENDER] + SubRoles.pKickoffPlayStriker(team)
def fSpread(team): # gets teammate that is chaser (could be me) chaser_mate = team.determineChaser() chaser_mate.role = PBConstants.CHASER # if i am chaser if chaser_mate.playerNumber == team.brain.my.playerNumber: return ["fSpread"] + Roles.rChaser(team) # We now figure out the roles of non-chasers posPlayers = team.getNonChaserTeammates(chaser_mate) # Get where the defender should be defInfo = Roles.rDefender(team) defPlayer = team.determineSupporter(posPlayers, defInfo) if defPlayer.playerNumber == team.brain.my.playerNumber: return ["fSpread"] + defInfo return ["fSpread"] + Roles.rOffender(team)
def one_on_one(me, opponent1, ball): my_teammate = None opponent2 = None section = Utilities.get_field_section(ball.xhat) # print ("section = {}" .format(section)) # if Utilities.i_am_stuck(me): # return Skills.get_unstuck(me) # else: # if not Plays.beginning_trick_shot_done(): # return Plays.shoot_off_the_wall(me, ball) if section == 1: return Roles.offensive_goalie(me, my_teammate, opponent1, opponent2, ball, True) elif section == 2: return Roles.offensive_defender(me, my_teammate, opponent1, opponent2, ball, True) elif section == 3: return Roles.offensive_attacker(me, my_teammate, opponent1, opponent2, ball, True) elif section == 4: return Roles.offensive_attacker(me, my_teammate, opponent1, opponent2, ball, True) else: return (me.xhat, me.yhat, me.thetahat) #default, returns current pos
def fTwoKickoff(team): """ Kickoff for only two field players """ other_teammate = team.getOtherActiveTeammate() if team.me.playerNumber > other_teammate.playerNumber: team.me.role = PBConstants.CHASER return ["fTwoKickoff"] + (Roles.rChaser(team)) else: team.me.role = PBConstants.DEFENDER return ["fTwoKickoff", PBConstants.DEFENDER] + SubRoles.pKickoffSweeper(team)
def fKickoff(team): """time immediately after kickoff""" if team.me.playerNumber == 2: team.me.role = PBConstants.DEFENDER return ["fKickoff", PBConstants.DEFENDER] + SubRoles.pKickoffSweeper(team) elif team.me.playerNumber == 3: team.me.role = PBConstants.CHASER return ["fKickoff"] + Roles.rChaser(team) elif team.playerNumber == 4: team.me.role = PBConstants.OFFENDER return ["fKickoff", PBConstants.OFFENDER] + SubRoles.pKickoffStriker(team)
def aggressive_offense(me, my_teammate, opponent1, opponent2, ball): global _beginning_trick_shot section = Utilities.get_field_section(ball.xhat) if me.ally1: # if not Plays.beginning_trick_shot_done(): # return Plays.shoot_off_the_wall(me, ball) if section == 1: return Roles.offensive_defender(me, my_teammate, opponent1, opponent2, ball) elif section == 2: return Roles.offensive_defender(me, my_teammate, opponent1, opponent2, ball) elif section == 3: return Roles.offensive_attacker(me, my_teammate, opponent1, opponent2, ball) elif section == 4: return Roles.offensive_attacker(me, my_teammate, opponent1, opponent2, ball) else: return (me.xhat, me.yhat, me.thetahat ) #default, returns current pos else: if section == 1: return Roles.offensive_goalie(me, my_teammate, opponent1, opponent2, ball) elif section == 2: return Roles.offensive_goalie( me, my_teammate, opponent1, opponent2, ball ) #This used to be offensive defender, but i want to see the goalie do it's thing elif section == 3: return Roles.offensive_attacker(me, my_teammate, opponent1, opponent2, ball) elif section == 4: return Roles.offensive_attacker(me, my_teammate, opponent1, opponent2, ball) else: return (me.xhat, me.yhat, me.thetahat ) #default, returns current pos
def aggressive_defense(me, my_teammate, opponent1, opponent2, ball): section = Utilities.get_field_section(ball.xhat) if me.ally1: if section == 1: return Roles.defensive_defender(me, my_teammate, opponent1, opponent2, ball) elif section == 2: return Roles.offensive_defender(me, my_teammate, opponent1, opponent2, ball) elif section == 3: return Roles.defensive_attacker(me, my_teammate, opponent1, opponent2, ball) elif section == 4: return Roles.defensive_attacker(me, my_teammate, opponent1, opponent2, ball) else: return (me.xhat, me.yhat, me.thetahat ) #default, returns current pos else: if section == 1: return Roles.offensive_goalie(me, my_teammate, opponent1, opponent2, ball) elif section == 2: return Roles.offensive_goalie( me, my_teammate, opponent1, opponent2, ball ) #This used to be offensive defender, but i want to see the goalie do it's thing elif section == 3: return Roles.defensive_attacker(me, my_teammate, opponent1, opponent2, ball) elif section == 4: return Roles.defensive_attacker(me, my_teammate, opponent1, opponent2, ball) else: return (me.xhat, me.yhat, me.thetahat ) #default, returns current pos
def passive_aggressive(me, my_teammate, opponent1, opponent2, ball): #AKA, mild offense/defense section = Utilities.get_field_section(ball.xhat) if me.ally1: if section == 1: return Roles.neutral_defender(me, my_teammate, opponent1, opponent2, ball) elif section == 2: return Roles.neutral_defender(me, my_teammate, opponent1, opponent2, ball) elif section == 3: return Roles.neutral_attacker(me, my_teammate, opponent1, opponent2, ball) elif section == 4: return Roles.neutral_attacker(me, my_teammate, opponent1, opponent2, ball) else: return (me.xhat, me.yhat, me.thetahat ) #default, returns current pos else: if section == 1: return Roles.neutral_goalie(me, my_teammate, opponent1, opponent2, ball) elif section == 2: return Roles.neutral_defender(me, my_teammate, opponent1, opponent2, ball) elif section == 3: return Roles.neutral_defender(me, my_teammate, opponent1, opponent2, ball) elif section == 4: return Roles.neutral_attacker(me, my_teammate, opponent1, opponent2, ball) else: return (me.xhat, me.yhat, me.thetahat ) #default, returns current pos
return await render("accounts/errors/not_in_guild.html") elif e == "already_own_role": return await render("accounts/errors/already_own_role.html") abort(404) @app.errorhandler(404) async def not_found(e): return await render("not_found.html") def check_user(): try: dc.fetch_user() except: return False else: return True app.jinja_env.globals.update(check_user=check_user) client.add_cog(Roles.Role(client)) client.add_cog(City.City(client)) client.add_cog(Osu.Osu(client)) print("http://ydna.themichael-cheng.com") # Asyncio Running. app.run(host=gethostbyname(gethostname()), port=80, use_reloader=False, debug=True, loop=loop, start_now=False) client.run(data["DISCORD_BOT_TOKEN"])
def fOneKickoff(team): """ kickoff for only having one field player """ team.me.role = PBConstants.CHASER return ["fOneKickoff"] + Roles.rChaser(team)
def fTestDefender(team): return ["fTestDefender"] + Roles.rDefender(team)
def fTestOffender(team): return ["fTestOffender"] + Roles.rOffender(team)
def fTestMiddie(team): return ["fTestMiddie"] + Roles.rMiddie(team)
def fTestChaser(team): return ["fTestChaser"] + Roles.rChaser(team)
def fTwoDown(team): """ Formation for missing two robots """ return ["fTwoDown"] + Roles.rChaser(team)
def fFinder(team): """no one knows where the ball is""" team.me.role = PBConstants.SEARCHER return ["fFinder"] + Roles.rSearcher(team)