colbyga / pychess

Automatically exported from code.google.com/p/pychess
GNU General Public License v3.0
0 stars 0 forks source link

"Offer Rematch" button doesn't handle cases where game didn't end in a win/loss #393

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. start a game in pychess with a guest login in a telnet window
2. abort the game in the guest login the telnet window
3. in the game window in pychess click the "Offer Rematch" button

Result:
Traceback (most recent call last):
  File
"/home/gatto/code/svn/pychess-read-only/lib/pychess/widgets/gamenanny.py",
line 107, in cb
    nameDic["loser"].offerRematch()
KeyError: 'loser'

Attached patch fixes it (and also changes behavior of button such that you
can offer a rematch regardless of whether you won or lost).

Original issue reported on code.google.com by mattgatto on 14 Feb 2009 at 6:52

Attachments:

GoogleCodeExporter commented 9 years ago
I was wrong when I said that the patch changes the behavior of the button (which
already allowed you to offer a rematch regardless of whether you won or lost), 
but it
does stop this kind of crash too:

Traceback (most recent call last):
  File "/home/gatto/code/svn/pychess-read-only/lib/pychess/widgets/gamenanny.py",
line 108, in cb
    nameDic["loser"].offerRematch()
AttributeError: 'Human' object has no attribute 'offerRematch'

Apply lobais?

Original comment by mattgatto on 18 Feb 2009 at 11:58

GoogleCodeExporter commented 9 years ago
I see the line has a problem.
Instead of 

nameDic["loser"].offerRematch()

it should be

if gamemodel.players[0].__type__ == REMOTE:
    gamemodel.players[0].offerRematch()
else: gamemodel.players[1].offerRematch()

I think that would work in all cases.

Original comment by lobais on 19 Feb 2009 at 12:05

GoogleCodeExporter commented 9 years ago
The FICS command 'rematch' only works when the game has been won or lost. This 
is
because it looks up the last player with whom you had a game (in your history) 
and
offers a challenge to them with the same parameters as the last game. If the 
game
wasn't won or lost, if it was aborted for example, it won't be in your game 
history,
and when you issue the 'rematch' command, it will issue a rematch to the wrong 
player
(the one with whom you last had a game ending in a win or loss). So I think the 
patch
is right.

Original comment by mattgatto on 19 Feb 2009 at 11:46

GoogleCodeExporter commented 9 years ago
So if you don't surround the button adding code with
+    if nameDic.has_key("winner"):

then when the game has been aborted, clicking the "Offer Rematch" button simply 
won't
do anything.

Original comment by mattgatto on 19 Feb 2009 at 11:50

GoogleCodeExporter commented 9 years ago
That is correct. The rematch button doesn't really work for fics yet.
We need to avoid the rematch command, first because of the problem you 
described, and
then because if the user has played two games (in tabs) and presses the rematch
button in the first tab, then he well offer a rematch to his seccond opponent.

Original comment by lobais on 21 Feb 2009 at 1:24

GoogleCodeExporter commented 9 years ago
Issue 398 has been merged into this issue.

Original comment by mattgatto on 24 Feb 2009 at 11:51

GoogleCodeExporter commented 9 years ago

Original comment by gbtami on 19 Mar 2009 at 8:18

GoogleCodeExporter commented 9 years ago
Issue 431 has been merged into this issue.

Original comment by mattgatto on 23 Mar 2009 at 9:35

GoogleCodeExporter commented 9 years ago
I've got a fix for this that uses the FICS match command rather than the rematch
command but it's depedent on some separate FICS variant work I've done that 
needs to
be committed first (which I'll do soon :).

Original comment by mattgatto on 24 Mar 2009 at 11:48

GoogleCodeExporter commented 9 years ago
Excellent :)
As you say, Fics rematch needs to utilize the match command, because there is a 
'bug'
in fics, which makes 'rematch gameno' unusable. Thus the use of rematch was 
always a
temporary solution.

As I remember, the problem of FICS rematch was, that the necessary game data 
wasn't
available where it was needed.
Looking forward to your commit :)

Original comment by lobais on 25 Mar 2009 at 3:11

GoogleCodeExporter commented 9 years ago

Original comment by mattgatto on 28 Mar 2009 at 11:05

GoogleCodeExporter commented 9 years ago
Fixed in revision 1444.

Original comment by mattgatto on 30 Mar 2009 at 10:37