Skip to content

Commit

Permalink
Merge pull request #87 from project-neon/feat/advance_when_penaly
Browse files Browse the repository at this point in the history
Advance when penalty
  • Loading branch information
Alexsandr0x authored Oct 11, 2021
2 parents 7e34afb + b782bcd commit de8e573
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
16 changes: 13 additions & 3 deletions entities/coach/larc2021.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,30 @@ def __init__(self, match):
penalty_play = plays.larc2021.PenaltyPlay(self)
goalkick_play = plays.larc2021.GoalKickPlay(self)

defend_penalty_play = plays.larc2021.DefendPenaltyPlay(self)

penalty_trigger = plays.OnPenaltyKick(self.match.game.referee, self.match.team_color)
seven_seconds_trigger = plays.WaitForTrigger(7)
penalty_seconds_trigger = plays.WaitForTrigger(12)
goalkick_seconds_trigger = plays.WaitForTrigger(9)
defendpenalty_seconds_trigger = plays.WaitForTrigger(9)

goalkick_trigger = plays.OnGoalKick(self.match.game.referee, self.match.team_color)

defend_penalty_trigger = plays.OnPenaltyKick(self.match.game.referee, self.match.opposite_team_color)

self.playbook.add_play(main_play)
self.playbook.add_play(penalty_play)
self.playbook.add_play(goalkick_play)
self.playbook.add_play(defend_penalty_play)

main_play.add_transition(penalty_trigger, penalty_play)
penalty_play.add_transition(seven_seconds_trigger, main_play)
penalty_play.add_transition(penalty_seconds_trigger, main_play)

main_play.add_transition(goalkick_trigger, goalkick_play)
goalkick_play.add_transition(seven_seconds_trigger, main_play)
goalkick_play.add_transition(goalkick_seconds_trigger, main_play)

main_play.add_transition(defend_penalty_trigger, defend_penalty_play)
defend_penalty_play.add_transition(defendpenalty_seconds_trigger, main_play)

self.playbook.set_play(main_play)

Expand Down
4 changes: 3 additions & 1 deletion entities/plays/larc2021/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from entities.plays.larc2021.mainPlay import MainPlay
from entities.plays.larc2021.penaltyPlay import PenaltyPlay
from entities.plays.larc2021.goalKickPlay import GoalKickPlay
from entities.plays.larc2021.goalKickPlay import GoalKickPlay

from entities.plays.larc2021.defendPenaltyPlay import DefendPenaltyPlay
4 changes: 2 additions & 2 deletions entities/plays/larc2021/goalKickPlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def get_positions(self, foul, team_color, foul_color, quadrant):
replacements.append(
{
"robot_id": 0,
"x": -field_size[0]/2 + 0.05,
"x": -field_size[0]/2 + 0.1,
"y": 0.2,
"orientation": 45
"orientation": 60
}
)
else:
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def update(self):
} for r in commands
]
self.comm.send(commands)

if self.referee.get_foul() != "STOP" and self.referee.get_foul() != 7 and self.referee.get_foul() != None:
if self.match.coach.get_positions( self.referee.get_foul(), self.match.team_color.upper(), self.referee.get_color(), self.referee.get_quadrant() ):
self.referee.send_replacement(
Expand Down

0 comments on commit de8e573

Please sign in to comment.