From: <no...@so...> - 2002-11-25 11:10:44
|
Bugs item #643393, was opened at 2002-11-25 06:56 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=509508&aid=643393&group_id=65029 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Michael Lever (leverm) Assigned to: Michael Lever (leverm) Summary: Problems when players transfer Prem team Initial Comment: In the TOT v LEE game this weekend (24/11/02) Robbie Keane of TOT scored against LEE. However, TOT defenders, not LEE defenders were deducted points for conceeding! Robbie Keane used to be a LEE player, but transferred at the bginning of the season. In Fanfoot he is still registered as a LEE player (this is because of the rule where you cannot have more than two players from one Premiership team in your squad. If a manager had him as a LEE player at the beginning of the season and also two TOT players, when he was transferred to TOT it would be unfair to penalise the manager for now having three TOT players in their squad). This is why there are two team entries per player in the players.xml file. <registeredTeam> should be used when choosing players for a squad. <team> should be used when calculating scores. ---------------------------------------------------------------------- >Comment By: Ross Gardler (rgardler) Date: 2002-11-25 11:10 Message: Logged In: YES user_id=88713 OK, I'll walk you through the debug process (ScoringConfig.xsl is where we are looking) The first thing to do is to find out where the points are being deducted for conceeding goals and how since this is where the problem lies (we could equally start with the fact that the team for Robbie Keane is wrong, but I'm deliverately doing it the long way as you don't have the knowledge of the stylesheets like I do). Do a keyword searrch for things like "conceed" "defender" etc. until you find a likely looking candidate. You will eventually find a comment that says: <!-- Goalkeepers, Full Backs and Centre Backs will lose 1 point for every goal conceded whilst they are on the pitch. --> and another that says: <!-- Deduct points from defenders and goalkeepers who have conceeded a goal --> These look like potentials to start our search. lets focus on the second (because the problem you have identified was not an own goal). The template for this is: <xsl:template name="deductDefenderPoints"> In this template you will see that there is a for-each loop that iterates over all players in the conceeding team: <xsl:for-each select="//event[type='teamStarter' and team=$conceedingTeam] | //event[type='substituteStarter' and team=$conceedingTeam]"> In English the select portion of this statement says: "Select all events of type team starter where the team name is the name of the conceeding team also select all the events of type substituteStarter where the team name is the same of the conceedingTeam and join the two sets together" | - means joind the two sets of elements $conceedingTeam is a parameter that is set earlier in the tempalte So, the work of deducting points is done inside this loop. Most of the time this is done OK so the problem probably isn't in the loop. itself. It's in the fact that the wrong players are having points deducted i this special case. So what's the difference. As you point out Keane has switched teams and his old team is being deducted the points. Therefore the $conceedingTeam parameter must be set wrong. So where is it set? Well it must be set before this for-each loop, so lets take a look... The only other place it is mentioned is in the line: <xsl:param name="conceedingTeam" /> What this means is that "conceedingTeam" is a parameter that has no default value (if it had a default value it would not be an empty element).. Therefore, the value of conceedingTeam must be being passed into this template. Therefore, we need to find out where the template is called from. Do a search for the template neame deductDefenderPoints. You will find the following lines with it in: line 405: <xsl:call-template name="deductDefenderPoints"> line 473: <xsl:call-template name="deductDefenderPoints"> The first of theses is inside the template: <xsl:template name="goalsConceeded"> The second is in the template: <xsl:template name="ownGoalsConceeded"> Lets focus on the first appearance, the whole element is: <xsl:call-template name="deductDefenderPoints"> <xsl:with-param name="goalMinutes"> <xsl:value-of select="$goalMinutes" /> </xsl:with-param> <xsl:with-param name="scoringTeam"> <xsl:value-of select="$scoringTeam" /> </xsl:with-param> <xsl:with-param name="conceedingTeam"> <xsl:value-of select="$conceedingTeam" /> </xsl:with-param> <xsl:with-param name="conceedingTeamID"> <xsl:value-of select="$conceedingTeamID" /> </xsl:with-param> </xsl:call-template> So you can see that this calls the template deductPlayerPoints and passes to it a set of parameters, one of which is called conceedingTeam, which is given the value of a local parameter, which is also called conceedingTeam. So we must see where the local value is set. Look back up this template and you will find: <xsl:variable name="conceedingTeam"> <xsl:choose> <xsl:when test="//event[type='result']/homeTeam = $scoringTeam"> <xsl:value-of select="//event[type='result']/awayTeam" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="//event[type='result']/homeTeam" /> </xsl:otherwise> </xsl:choose> </xsl:variable> This time it is a variable not a pramater. The only difference is that variables cannot have their values passed in to the template. We can see from this snippet that the value is either set according to the value of another variable/parameter called $scroingTeam and that it will be set to either <xsl:value-of select="//event[type='result']/awayTeam" /> <xsl:value-of select="//event[type='result']/homeTeam" /> So, if you are still with me, there are now two places the problem might lie. Either in the value of scoringTeam or in the value of the team name in the event of type result. If you were to check to see how the event of type result is created (in footballEvents.xml) you would discover it is taken from the commentary directly and so cannot be wrong. Therefore, it must be $scoringTeam that is wrong. So we have to look back to see where this value is set. Again look back in this template, you will find: <xsl:variable name="scoringTeam"> <xsl:call-template name="getTeamName"> <xsl:with-param name="teamID"> <xsl:value-of select="$scoringTeamID" /> </xsl:with-param> </xsl:call-template> </xsl:variable> So scoring team is set from ScoringTeamID. If you were to lookup the template getTeamName that is used here you would see it is a simple lookup in teams.xml, since that file is correct the problem must be with the setting of scoringTeamID. SO look back again and you will find: <xsl:variable name="scoringTeamID"> <xsl:call-template name="getPlayerTeam"> <xsl:with-param name="playerFullName"> <xsl:value-of select="player" /> </xsl:with-param> </xsl:call-template> </xsl:variable> So... scoringTeamID is set with a call to a template called getPlayerTeam which is passed the value of the players name. Since the name of the goal scorer is correct but his team is wrong this is getting closer. Find this template: If you can work out what's going on in here you will see that <xsl:value-of select="document($playersDataSource)/players/player[surname=$playerSurname]/team" /> is where the value is set, in english it says: use the document indicated by the parameter $playersDataSource and give me the value of the element team in the element player where the surname element is equal to out players name. So here's our problem, as you said we should be using registered team not team. However, we can't just change "team" in the above statement to "registeredTeam" because other templates might be using this tamplate for other purposes and changing it will break them. What we must do is create a new template "getPlayersRegisteredTeam" that does the same thing, but returns the registeredTeam element rather than the team element. We then need to go through all the places where this template is called and if necessary change it so that the correct one is called. So do you feel brave enough to try? When experimenting remember to set you config so it is using a local version of this file, only commit to CVS when you know it works OK. (Of course once you understand how this works you wouldn;t need to work all the way backwards like that. You have learnt quite alot in doing the debugging steps and so next time you find an error you may already know where the problem is likely to be). ---------------------------------------------------------------------- Comment By: Michael Lever (leverm) Date: 2002-11-25 07:01 Message: Logged In: YES user_id=631335 Can this be fixed by editing the 'ScoringConfig.xsl' file (if so, i've not quite worked out how), or is this info kept elsewhere? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=509508&aid=643393&group_id=65029 |