{-# LANGUAGE UnicodeSyntax #-}moduleSoccerFun.RefereeActionwhereimportSoccerFun.TypesimportSoccerFun.GeometryimportSoccerFun.FielddataRefereeAction=ReprimandPlayerPlayerIDReprimand-- ^ player with given name receives reprimand|HandsPlayerID-- ^ person is seen for doing hands|TackleDetectedPlayerID-- ^ person is seen for doing tackle|SchwalbeDetectedPlayerID-- ^ person is seen for doing schwalbe|TheaterDetectedPlayerID|DangerousPlayPlayerID-- ^ person is seen for doing dangerous actions|GameOver-- ^ end of game|PauseGame-- ^ game is paused|AddTimeExtraTime-- ^ extra time is added to the game|EndHalf-- ^ first half is over, teams go for a second half|GoalATeam-- ^ team playing at home has scored|OffsidePlayerID-- ^ player is offside at Home|DirectFreeKickATeamPosition-- ^ a direct free kick is granted for team home at given position|GoalKickATeam-- ^ a goal kick is granted for team home|CornerATeamEdge-- ^ a corner kick is granted for team home|ThrowInATeamPosition-- ^ a throw in ball is granted for team home at given position|PenaltyATeam-- ^ penalty at homeside|CenterKickATeam-- ^ team playing at home may start from the center|AdvantageATeam-- ^ referee gives advantages to home-team|OwnBallIllegallyPlayerID-- ^ ball was for the other team|DisplacePlayersDisplacements-- ^ displaces all players at the provided position (used with free kicks)|ContinueGame|TellMessageString-- ^ no effect on match, message is displayed by refereederiving(Show,Eq)isReprimandPlayer∷RefereeAction→BoolisReprimandPlayer(ReprimandPlayer__)=TrueisReprimandPlayer_=FalseisHands∷RefereeAction→BoolisHands(Hands_)=TrueisHands_=FalseisTackleDetected∷RefereeAction→BoolisTackleDetected(TackleDetected_)=TrueisTackleDetected_=FalseisSchwalbeDetected∷RefereeAction→BoolisSchwalbeDetected(SchwalbeDetected_)=TrueisSchwalbeDetected_=FalseisTheaterDetected∷RefereeAction→BoolisTheaterDetected(TheaterDetected_)=TrueisTheaterDetected_=FalseisDangerousPlay∷RefereeAction→BoolisDangerousPlay(DangerousPlay_)=TrueisDangerousPlay_=FalseisGameOver∷RefereeAction→BoolisGameOverGameOver=TrueisGameOver_=FalseisPauseGame∷RefereeAction→BoolisPauseGamePauseGame=TrueisPauseGame_=FalseisAddTime∷RefereeAction→BoolisAddTime(AddTime_)=TrueisAddTime_=FalseisEndHalf∷RefereeAction→BoolisEndHalfEndHalf=TrueisEndHalf_=FalseisGoal∷RefereeAction→BoolisGoal(Goal_)=TrueisGoal_=FalseisOffside∷RefereeAction→BoolisOffside(Offside_)=TrueisOffside_=FalseisDirectFreeKick∷RefereeAction→BoolisDirectFreeKick(DirectFreeKick__)=TrueisDirectFreeKick_=FalseisGoalKick∷RefereeAction→BoolisGoalKick(GoalKick_)=TrueisGoalKick_=FalseisCorner∷RefereeAction→BoolisCorner(Corner__)=TrueisCorner_=FalseisThrowIn∷RefereeAction→BoolisThrowIn(ThrowIn__)=TrueisThrowIn_=FalseisPenalty∷RefereeAction→BoolisPenalty(Penalty_)=TrueisPenalty_=FalseisCenterKick∷RefereeAction→BoolisCenterKick(CenterKick_)=TrueisCenterKick_=FalseisAdvantage∷RefereeAction→BoolisAdvantage(Advantage_)=TrueisAdvantage_=FalseisOwnBallIllegally∷RefereeAction→BoolisOwnBallIllegally(OwnBallIllegally_)=TrueisOwnBallIllegally_=FalseisDisplacePlayers∷RefereeAction→BoolisDisplacePlayers(DisplacePlayers_)=TrueisDisplacePlayers_=FalseisContinueGame∷RefereeAction→BoolisContinueGameContinueGame=TrueisContinueGame_=FalseisTellMessage∷RefereeAction→BoolisTellMessage(TellMessage_)=TrueisTellMessage_=FalseisGoal4ATeam∷ATeam→RefereeAction→BoolisGoal4ATeamt(Goalt')=t==t'isGoal4ATeam__=False-- | Position of a referee-granted action like a throw-in, a corner kick, etc.getKickPos∷Field→Half→RefereeAction→MaybePositiongetKickPosfieldhalf(GoalKickteam)=Just$Position{py=(fwidthfield)/2.0,px=if(team==Team1&&half==FirstHalf||team==Team2&&half==SecondHalf)thenpenaltyAreaDepthelse(flengthfield)-penaltyAreaDepth}getKickPosfieldhalf(Cornerteamedge)=Just$Position{px=if(team==Team1&&half==SecondHalf||team==Team2&&half==FirstHalf)thenhalfRadiusCornerKickAreaelse((flengthfield)-halfRadiusCornerKickArea),py=if(edge==North)thenhalfRadiusCornerKickAreaelse((fwidthfield)-halfRadiusCornerKickArea)}wherehalfRadiusCornerKickArea=radiusCornerKickArea/2.0getKickPosfieldhalf(Penaltyteam)=Just$Position{py=(fwidthfield)/2.0,px=if(team==Team1&&half==SecondHalf||team==Team2&&half==FirstHalf)thenpenaltySpotDepthelse((flengthfield)-penaltySpotDepth)}getKickPosfield_(CenterKick_)=Just$Position{px=(flengthfield)/2.0,py=(fwidthfield)/2.0}getKickPos__(DirectFreeKick_pos)=JustposgetKickPos__(ThrowIn_pos)=JustposgetKickPos___=Nothing