tstellar wrote: ↑Tue Oct 20, 2020 12:17 am
For this bug, it is a bug in the code and not the definitions. The code was assuming that when a round finished with only 1 winner that the cup was over. It was ignoring the fact that there were still teams in the cup that had byes.
tstellar...Before I begin my reply, I should clarify for everyone that your explanation is not completely clear, to a point. The bug in the code was assuming that when a round finished with only 1 winner, with no more teams being loaded in future rounds, that the cup was over, even if teams who had yet to play were loaded in that round but given byes to play in those future rounds. So if teams were to be loaded in future rounds, the cup would continue. If teams would be loaded in the same round and given byes to play in those future rounds with no other teams being loaded in those same future rounds, then the cup would be over after the round was played with only 1 winner in that round.
I'll admit that I never quite thought of this as potentially being a bug until I tried it myself. When I think of it, this seems like such a rare case but I think I can see other potential instances like this pop up, like if you have 3 teams left in a cup that are already loaded and two of the three teams play in a round and the following round you will have the winner play the third team, but alas, with a bug like this, it likely would stop after those first two teams play. So my question to you tstellar is that after "fixing" this bug with the code, did you try to test it with your fixed version of bygfoot and did it work? Would it play the second round if in the first round, you loaded up 17 teams and gave 15 of them byes, so that in the second round, no other teams would be loaded but for those 17, of which now 16 would be left? That is the question. If your fix works, that is good and we need to have it added to bygfoot for this very issue, although rare as it may seem.
Now onto this particular issue that billys_boots had, I actually came up with a workable solution. As this example from billys_boots is actually from his 2019/2020 definitions for Scotland, although he doesn't have this particular cup activated or it isn't played, I got the relevant files from there and modified them accordingly, calling the country file country_test1.xml. Basically I modified the country file (country_scotland.xml), the relevant cup file (cup_scotland_highland.xml), and the relevant league file (league_scotland5b.xml), and then modified them to fit in with the country name of test1.
The relevant cup file (cup_test1_highland.xml) that is working is below:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<cup>
<name>Highland League Cup</name>
<short_name>HL Cup</short_name>
<symbol>flag_scotland.png</symbol>
<sid>test1_highland</sid>
<last_week>7</last_week>
<week_gap>1</week_gap>
<group>77</group>
<property>national</property>
<cup_rounds>
<!-- Round 1 -->
<cup_round>
<round_name>1st Round</round_name>
<home_away>0</home_away>
<byes>0</byes>
<choose_teams>
<choose_team>
<choose_team_sid>test1</choose_team_sid>
<number_of_teams>2</number_of_teams>
<start_idx>1</start_idx>
<end_idx>17</end_idx>
<randomly>1</randomly>
</choose_team>
</choose_teams>
</cup_round>
<!-- Round 2 -->
<cup_round>
<round_name>2nd Round</round_name>
<home_away>0</home_away>
<byes>0</byes>
<choose_teams>
<choose_team>
<choose_team_sid>test1</choose_team_sid>
<number_of_teams>15</number_of_teams>
<start_idx>1</start_idx>
<end_idx>17</end_idx>
<randomly>1</randomly>
</choose_team>
</choose_teams>
</cup_round>
<!-- Round 3 -->
<cup_round>
<round_name>Quarter Final</round_name>
<home_away>0</home_away>
</cup_round>
<!-- Round 4 -->
<cup_round>
<round_name>Semi Final</round_name>
<home_away>0</home_away>
</cup_round>
<!-- Round 5 -->
<cup_round>
<round_name>Final</round_name>
<home_away>0</home_away>
<neutral>1</neutral>
</cup_round>
</cup_rounds>
</cup>
As I knew how many teams would be loaded into this cup (17 teams), I loaded up 2 teams in the first round and the remaining teams in the second round. This was the only real way that this bug wouldn't affect the cup continuing past the first round. By using the code I did for the first and second rounds, it allowed me to randomly select the teams for both rounds, so that the same teams would not appear in the first round, time after time. This was one of the requirements that billys_boots mentioned. I'd say that normally, the teams might be selected based upon their league standing or such, but in this case, it sounded like the selection would be totally random in general. To make this coding work, I had to assign it to a group which I did in the header part of the cup file. If you want to try the code for yourself, you can download the attached zip file and give it a try.
I'll say that with this issue, it was odd and another bug was exposed from it, so that's a good thing as bugs are bad.
Although it truly caused frustration, as bugs normally would. But thankfully the bug was understood by someone and hopefully a fix will make its way to the code tree eventually, so that this bug can't bother us again. So thank you tstellar for finding the logic behind this bug and for anyone running into something similar in the future, you can either use my workaround or wait until the bug is fixed in a future update.
Enjoy...
Will aka will_the_canuck