Double Bench Liga Portugal 24

From Diogo Simões, 1 Year ago, written in Python, viewed 54 times.
URL https://paste.afonso.co/view/494f2cf8 Embed
Download Paste or View Raw
  1. # -*- encoding: utf-8 -*-
  2.  
  3. import footballstatshelper
  4. import helper
  5.  
  6. HOME_TEAM = Game.HomeTeam
  7. AWAY_TEAM = Game.AwayTeam
  8.  
  9.  
  10. class PlayerInfo:
  11.     def __init__(
  12.         self,
  13.         index,
  14.         isHomeTeam,
  15.         number=0,
  16.         name="",
  17.         function="",
  18.         card=False,
  19.     ):
  20.         _homeOrAway = "Home" if isHomeTeam else "Away"
  21.         _index = index + 1
  22.  
  23.         self._number = (
  24.             "t{}PlayerNumber{:02d}".format(_homeOrAway, _index),
  25.             str(number),
  26.         )
  27.         self._name = ("t{}PlayerName{:02d}".format(_homeOrAway, _index), name)
  28.         self._function = (
  29.             "t{}PlayerFunction{:02d}".format(_homeOrAway, _index),
  30.             function,
  31.         )
  32.         self._card = (
  33.             "v{}PlayerAtRiskVisibility{:02d}".format(_homeOrAway, _index),
  34.             card,
  35.         )
  36.  
  37.     def getNumber(self):
  38.         return self._number
  39.  
  40.     def getName(self):
  41.         return self._name
  42.  
  43.     def getFunction(self):
  44.         return self._function
  45.  
  46.     def getCard(self):
  47.         return self._card
  48.  
  49.  
  50. def isValidGame(team, teamName):
  51.     if not team.Coach:
  52.         return -1, "{} has no coach".format(teamName)
  53.  
  54.     captain = filter(lambda player: player.IsCaptain, team.Players)[0]
  55.     if captain.State.ToString() == "InBench":
  56.         return -1, "{} Captain in Bench! Please remove it!".format(teamName)
  57.  
  58.     diffBenchAmount = (
  59.         len(team.InBench) != 9
  60.         and UserInteraction.ShowMessageBoxYesNo(
  61.             "{} Bench".format(teamName),
  62.             "{} bench players are different than 9.\n\nContinue anyway?".format(
  63.                 teamName
  64.             ),
  65.         ).ToString()
  66.         != "Yes"
  67.     )
  68.     if diffBenchAmount:
  69.         return -1, "Canceled"
  70.  
  71.     return 0, ""
  72.  
  73.  
  74. def __onStart(graphicOnAirItem, momentExecution, workFlowtype):
  75.     if workFlowtype == IntelliflowController.EWorkflowType.PreviewToProgram:
  76.         return
  77.  
  78.     if (
  79.         workFlowtype != IntelliflowController.EWorkflowType.Preview
  80.         and GameOnline.IsOnAir
  81.     ):
  82.         momentExecution.Message = "Online Is On Air"
  83.         momentExecution.Cancel = True
  84.         return
  85.  
  86.     status, message = isValidGame(HOME_TEAM, "Home Team")
  87.     if status == -1:
  88.         momentExecution.Message = message
  89.         momentExecution.Cancel = True
  90.         return
  91.  
  92.     status, message = isValidGame(AWAY_TEAM, "Away Team")
  93.     if status == -1:
  94.         momentExecution.Message = message
  95.         momentExecution.Cancel = True
  96.         return
  97.  
  98.  
  99. def fillInBench(view, playersInBench, isHomeTeam):
  100.     """
  101.    Fills graphic tags correspondent to InBench.
  102.  
  103.    Args:
  104.        view (TagsViewBag): Reference for Graphic Template Tags
  105.        playersInBench (list[FootballGamePlayers], optional): List of players InBench. Defaults to `CURRENT_TEAM.InBench`.
  106.    """
  107.  
  108.     def _getPlayerFunctions(player):
  109.         playerFunction = ""
  110.         if player.IsGoalKeeper:
  111.             playerFunction += "{{(GK)}} "
  112.  
  113.         if player.IsCaptain:
  114.             playerFunction += "{{(C)}} "
  115.  
  116.         return playerFunction
  117.  
  118.     view.SetFloat("v{}Lines".format("Home" if isHomeTeam else "Away"), len(playersInBench))
  119.  
  120.     inBench = []
  121.     for i, player in enumerate(playersInBench):
  122.         inBench.append(
  123.             PlayerInfo(
  124.                 i,
  125.                 isHomeTeam,
  126.                 player.Number,
  127.                 player.ShortName.upper(),
  128.                 _getPlayerFunctions(player).upper(),
  129.                 player.AtRisk
  130.             )
  131.         )
  132.  
  133.     for player in inBench:
  134.         (numberKey, numberValue) = player.getNumber()
  135.         (nameKey, nameValue) = player.getName()
  136.         (functionKey, functionValue) = player.getFunction()
  137.         (cardKey, cardValue) = player.getCard()
  138.  
  139.         view.SetString(numberKey, numberValue)
  140.         view.SetString(nameKey, nameValue)
  141.         view.SetTranslatedText(functionKey, functionValue)
  142.         view.SetVisibility(cardKey, cardValue)
  143.  
  144.  
  145. def fillTeamInfo(view, team, isHomeTeam):
  146.     """
  147.    Fills graphic tags correspondent to InBench.
  148.  
  149.    Args:
  150.        view (TagsViewBag): Reference for Graphic Template Tags
  151.        team (FootballGameTeam): Football Team. Defaults to CURRENT_TEAM.
  152.    """
  153.     homeOrAway = "Home" if isHomeTeam else "Away"
  154.  
  155.     view.SetImage(
  156.         "lg{}TeamBadge".format(homeOrAway),
  157.         "Images\LigaPortugal\Badges\{}.png".format(team.RefName),
  158.     )
  159.     view.SetImage(
  160.         "lg{}TeamBadgeOutline".format(homeOrAway),
  161.         "Images\LigaPortugal\Badges_Outline\{}.png".format(team.RefName),
  162.     )
  163.  
  164.     view.SetString("t{}TeamName".format(homeOrAway), team.ShortName.upper())
  165.     view.SetString(
  166.         "v{}TeamColor.RGB".format(homeOrAway), helper._get_base_color(team.RefName)
  167.     )
  168.  
  169.  
  170. def fillCoachInfo(view, coach, isHomeTeam):
  171.     """
  172.    Fills graphic tags correspondent to InBench.
  173.  
  174.    Args:
  175.        view (TagsViewBag): Reference for Graphic Template Tags
  176.        coach (FootballGameCoach): Football Team's Coach. Defaults to CURRENT_TEAM.
  177.    """
  178.     homeOrAway = "Home" if isHomeTeam else "Away"
  179.  
  180.     view.SetString("t{}CoachName".format(homeOrAway), coach.ShortName.upper())
  181.     view.SetTranslatedText(
  182.         "t{}CoachFunction".format(homeOrAway),
  183.         "{{%s}}" % coach.Function.ToString().upper(),
  184.     )
  185.  
  186. def fillCompetitionInfo(view):
  187.  
  188.     view.SetImage(
  189.         "lgCompetitionBadge_In",
  190.         "Images/LigaPortugal/CompetitionBadge/In/LogoBetclic_In_5_11.png",
  191.     )
  192.     view.SetImage(
  193.         "lgCompetitionBadge_Out",
  194.         "Images/LigaPortugal/CompetitionBadge/Out/LogoBetclic_Out_5_9.png",
  195.     )
  196.  
  197. def __getData(graphicOnAirItem, viewBag, momentExecution):
  198.     viewBag.Clear()
  199.  
  200.     # Fill HomeTeam
  201.     fillInBench(viewBag, HOME_TEAM.InBenchByKeeperAndShirt, True)
  202.     fillTeamInfo(viewBag, HOME_TEAM, True)
  203.     fillCoachInfo(viewBag, HOME_TEAM.Coach, True)
  204.  
  205.     # Fill AwayTeam
  206.     fillInBench(viewBag, AWAY_TEAM.InBenchByKeeperAndShirt, False)
  207.     fillTeamInfo(viewBag, AWAY_TEAM, False)
  208.     fillCoachInfo(viewBag, AWAY_TEAM.Coach, False)
  209.  
  210.     # Fill Competition Info
  211.     fillCompetitionInfo(viewBag)
  212.  

Replies to Double Bench Liga Portugal 24 rss

Title Name Language When
list of subdomains labapreces.eu python 1 Week ago.
list of subdomains labaspreces.eu text 1 Month ago.

Reply to "Double Bench Liga Portugal 24"

Here you can reply to the paste above