Transaction Bug? Delay?
Posted: 11 October 2020, 02:24
Dear smart people of BGA Studio,
I have to ask about a problem I thought I already solved. But I received a bug report about it, so I'll need to look into it again. There is also a chance that only the admins can help me out. Let's see
My (now in beta) game Boomerang: Australia has a drafting mechanism, similar to Sushi-Go for example. You simply pick a card from your hand and after all players did that, the chosen card are evaluated and the hand moves to the next player.
So, during alpha development, I set a flag to the card with the player_id in the 'card' table. After that, the player is set to not-multiactive.
After the last player, the game moves on to the evaluation process, where I now select all these cards with the player_id flags.
That seemed to work as is should, but I received some bug reports that one of the cards, that got selected, wasn't included in the evaluation process, as if one player never selected a card. So I looked into it and after a couple of tests I was able to reproduce the problem: it only happened, when the two remaining players to select their card did it at the exact same time. The game moved on to the evaluation part, while one of the transactions wasn't comitted yet. So, in the selection of the cards, that one card was missing, which of course leads to some problems.
I approached the admins and received some snippets from Sushi-Go, which basically does it the exact same way, but instead of a flag on the 'card' table, they save the selected card id in the 'player' table. So I changed my code to do it also this way and the problem seemed to have gone. Weird, but ok.
Now that the game is in beta, I received another report about this problem (if you'd like to have a look: #116599092, pick player Kris10pie, move 40). So I have to seek for a different solution.
I build a small test project just for this purpose (xcidbugtest, feel free to try it yourself) and played around a little. I save a flag in a test-table and do the same in the player-table, afterwards I select these flags again. (The flags are increasing in value each round). Now, here is what happens (remember, this only happens when both players click the card at the same time):
In move 117, everything is OK, the flags in both tables are stored just fine. But in move 118, the flag for player 2321660 has been committed to the 'player' - table, but not to the 'test' table. Even though everything happened in the same transaction. Looking at the table with the phpMyAdmin reveals that eventually the test-table is also updated, but too late. So, using the 'player' table (like I do in the actual game) seems to cause no problems, but since I got the new bug report, it appears that it can also happen with the player table. Not really sure. Sushi-Go does not have any bug report like that.
As a workaround, I will check for the amount of selected cards before I continue and throw a BGA exception if it's not fitting the players number, so that the whole transaction will be cancelled and that one player has to pick that card again, but that feels a bit 'dirty'
Any ideas?
I have to ask about a problem I thought I already solved. But I received a bug report about it, so I'll need to look into it again. There is also a chance that only the admins can help me out. Let's see
My (now in beta) game Boomerang: Australia has a drafting mechanism, similar to Sushi-Go for example. You simply pick a card from your hand and after all players did that, the chosen card are evaluated and the hand moves to the next player.
So, during alpha development, I set a flag to the card with the player_id in the 'card' table. After that, the player is set to not-multiactive.
After the last player, the game moves on to the evaluation process, where I now select all these cards with the player_id flags.
That seemed to work as is should, but I received some bug reports that one of the cards, that got selected, wasn't included in the evaluation process, as if one player never selected a card. So I looked into it and after a couple of tests I was able to reproduce the problem: it only happened, when the two remaining players to select their card did it at the exact same time. The game moved on to the evaluation part, while one of the transactions wasn't comitted yet. So, in the selection of the cards, that one card was missing, which of course leads to some problems.
I approached the admins and received some snippets from Sushi-Go, which basically does it the exact same way, but instead of a flag on the 'card' table, they save the selected card id in the 'player' table. So I changed my code to do it also this way and the problem seemed to have gone. Weird, but ok.
Now that the game is in beta, I received another report about this problem (if you'd like to have a look: #116599092, pick player Kris10pie, move 40). So I have to seek for a different solution.
I build a small test project just for this purpose (xcidbugtest, feel free to try it yourself) and played around a little. I save a flag in a test-table and do the same in the player-table, afterwards I select these flags again. (The flags are increasing in value each round). Now, here is what happens (remember, this only happens when both players click the card at the same time):
In move 117, everything is OK, the flags in both tables are stored just fine. But in move 118, the flag for player 2321660 has been committed to the 'player' - table, but not to the 'test' table. Even though everything happened in the same transaction. Looking at the table with the phpMyAdmin reveals that eventually the test-table is also updated, but too late. So, using the 'player' table (like I do in the actual game) seems to cause no problems, but since I got the new bug report, it appears that it can also happen with the player table. Not really sure. Sushi-Go does not have any bug report like that.
As a workaround, I will check for the amount of selected cards before I continue and throw a BGA exception if it's not fitting the players number, so that the whole transaction will be cancelled and that one player has to pick that card again, but that feels a bit 'dirty'
Any ideas?