import StaticLib from Wtvision.Sports.Models.Football import FootballEventAttributes def __onStart(graphicOnAirItem, momentExecution, workFlowtype): if workFlowtype.ToString() != "PreviewToProgram": if not Game.Clock.ActivePart.Number == 9: momentExecution.Message = "You're not on Penalties part!" momentExecution.Cancel = True return def __getData(graphicOnAirItem, viewBag, momentExecution): hometeam = Game.HomeTeam awayteam = Game.AwayTeam homePenaltysEvent = filter(lambda e: e.Team and (e.Team.RefName == hometeam.RefName) and (e.GamePart == 9) and (e.Name == "Penalty"), list(Game.OrderedGameEvents)) awayPenaltysEvent = filter(lambda e: e.Team and (e.Team.RefName == awayteam.RefName) and (e.GamePart == 9) and (e.Name == "Penalty"), list(Game.OrderedGameEvents)) # currentPenalty= max(len(homePenaltysEvent),len(awayPenaltysEvent)) # # viewBag.SetFloat("vPenaltyPosition", 1) # homeGoals,awayGoals = __getGoals(homePenaltysEvent,awayPenaltysEvent) # if currentPenalty > 5: # if homeGoals == awayGoals: # viewBag.SetFloat("vPenaltyPosition", currentPenalty-3) # else: # viewBag.SetFloat("vPenaltyPosition", currentPenalty-4) # elif currentPenalty == 5: # if homeGoals == awayGoals: # viewBag.SetFloat("vPenaltyPosition", 2) # # print homePenaltysEvent print awayPenaltysEvent __showPenalties(viewBag,homePenaltysEvent,awayPenaltysEvent) def __showPenalties(viewBag,homePenaltysEvent,awayPenaltysEvent): hometeam = Game.HomeTeam awayteam = Game.AwayTeam viewBag.SetString("tHomeTeamScore", GameOnline.HomeTeamPenaltiesScore) viewBag.SetString("tAwayTeamScore", GameOnline.AwayTeamPenaltiesScore) total = len(homePenaltysEvent) + len(awayPenaltysEvent) if total == 0: for i in range(1,6): viewBag.SetString("vHomePenaltie%02d" % i,1) viewBag.SetString("vAwayPenaltie%02d" % i,1) # else: # if Globals["PenaltiesForm"].IsHomeStarting: # # if (total % 2) == 0: # viewBag.SetString("vHomePenalty%02d" % (len(homePenaltysEvent)+1),2) # else: # viewBag.SetString("vAwayPenalty%02d" % (len(awayPenaltysEvent)+1),2) # else: # if (total % 2) == 0: # viewBag.SetString("vAwayPenalty%02d" % (len(awayPenaltysEvent)+1),2) # else: # viewBag.SetString("vHomePenalty%02d" % (len(homePenaltysEvent)+1),2) homePenaltysEvent = list(homePenaltysEvent)[-30:] awayPenaltysEvent = list(awayPenaltysEvent)[-30:] for i, homePenaltyEvent in enumerate(homePenaltysEvent): penaltyKickResult = next((pAttribute for pAttribute in list(homePenaltyEvent.Attributes) if pAttribute.Name == FootballEventAttributes.PenaltyKickResultName), None) if not penaltyKickResult: continue isGoal = (penaltyKickResult.Value == "Goal") viewBag.SetFloat("vHomePenaltie01", 2) if isGoal: viewBag.SetFloat("vHomePenaltie%02d" % (i+1), 2) viewBag.SetString("tHomeTeamScore", GameOnline.HomeTeamPenaltiesScore) else: viewBag.SetString("vHomePenaltie%02d" % (i+1), 3) for i, awayPenaltyEvent in enumerate(awayPenaltysEvent): penaltyKickResult = next((pAttribute for pAttribute in list(awayPenaltyEvent.Attributes) if pAttribute.Name == FootballEventAttributes.PenaltyKickResultName), None) if not penaltyKickResult: continue isGoal = (penaltyKickResult.Value == "Goal") if isGoal: viewBag.SetString("vAwayPenaltie%02d" % (i+1), 2) viewBag.SetString("tAwayTeamScore", GameOnline.AwayTeamPenaltiesScore) else: viewBag.SetString("vAwayPenaltie%02d" % (i+1), 3) onairItems = IntelliflowController.GetGraphicOnAirItems(OutputManager.ActiveChannelOutput) for item in onairItems: graphName = item.Graphic.Name if "PENALTIES" in graphName: graphic = item graphic.Scene.FillTags(viewBag) def __updatePenalties(): graphic = GraphicTemplatesManager.GetGraphicByName("PENALTIES") graphicOnAirItems = IntelliflowController.GetGraphicOnAirItems(graphic, OutputManager.ActiveChannelOutput) if not graphicOnAirItems:return viewBag = IntelliflowController.CreateViewBag() hometeam = Game.HomeTeam awayteam = Game.AwayTeam homePenaltysEvent = filter(lambda e: e.Team and (e.Team.RefName == hometeam.RefName) and (e.GamePart == 9) and (e.Name == "Penalty"), list(Game.OrderedGameEvents)) awayPenaltysEvent = filter(lambda e: e.Team and (e.Team.RefName == awayteam.RefName) and (e.GamePart == 9) and (e.Name == "Penalty"), list(Game.OrderedGameEvents)) __showPenalties(viewBag,homePenaltysEvent,awayPenaltysEvent) #IntelliflowController.FillData(graphicOnAirItems, viewBag, True) maxPen = max(len(homePenaltysEvent),len(awayPenaltysEvent)) homeGoals,awayGoals = __getGoals(homePenaltysEvent,awayPenaltysEvent) # if len(homePenaltysEvent) >= 5 and len(awayPenaltysEvent) >=5 and len(homePenaltysEvent) == len(awayPenaltysEvent) and homeGoals == awayGoals: # if maxPen >=30:return # IntelliflowController.Continue(graphic, OutputManager.ActiveChannelOutput) def __getGoals(homePenaltysEvent,awayPenaltysEvent): homeGoals = 0 for i, homePenaltyEvent in enumerate(homePenaltysEvent): penaltyKickResult = next((pAttribute for pAttribute in list(homePenaltyEvent.Attributes) if pAttribute.Name == FootballEventAttributes.PenaltyKickResultName), None) if not penaltyKickResult: continue isGoal = (penaltyKickResult.Value == "Goal") if isGoal: homeGoals+=1 awayGoals = 0 for i, awayPenaltyEvent in enumerate(awayPenaltysEvent): penaltyKickResult = next((pAttribute for pAttribute in list(awayPenaltyEvent.Attributes) if pAttribute.Name == FootballEventAttributes.PenaltyKickResultName), None) if not penaltyKickResult: continue isGoal = (penaltyKickResult.Value == "Goal") if isGoal: awayGoals+=1 return homeGoals,awayGoals def __beforeProgram(graphicOnAirItem, momentExecution): hometeam = Game.HomeTeam awayteam = Game.AwayTeam homePenaltysEvent = filter(lambda e: e.Team and (e.Team.RefName == hometeam.RefName) and (e.GamePart == 9) and (e.Name == "Penalty"), list(Game.OrderedGameEvents)) awayPenaltysEvent = filter(lambda e: e.Team and (e.Team.RefName == awayteam.RefName) and (e.GamePart == 9) and (e.Name == "Penalty"), list(Game.OrderedGameEvents)) viewbag = graphicOnAirItem.Graphic.ViewData __showPenalties(viewbag,homePenaltysEvent,awayPenaltysEvent)