buttonmen-dev / buttonmen

Buttonmen - an online dice game
Other
16 stars 23 forks source link

Error when calling submitTurn #920

Closed jimmosk closed 10 years ago

jimmosk commented 10 years ago

I just had this crop up in game 516, when I won the first round:

screen shot 2014-06-02 at 5 32 25 pm

Nothing seemed to actually go wrong with the game, though, so I'm not sure this is worth a ticket...

cgolubi1 commented 10 years ago

It's absolutely worth a ticket when you get an internal error. I'll investigate.

cgolubi1 commented 10 years ago

Here's the log entry:

[Mon Jun 02 21:26:30 2014] [error] [client X.X.X.X] PHP Notice:  Undefined offset: 0 in /var/www/engine/BMGame.php on line 251, referer: http://dev.buttonweavers.com/ui/game.html?game=516
[Mon Jun 02 21:26:30 2014] [error] [client X.X.X.X] PHP Warning:  array_key_exists() expects parameter 2 to be array, null given in /var/www/engine/BMGame.php on line 252, referer: http://dev.buttonweavers.com/ui/game.html?game=516
cgolubi1 commented 10 years ago

Shadowshade: i'm suspicious because Notorious (and Zomulgustar, for that matter) is a button with option and reserve dice. The error is being triggered in a function, do_next_step_add_available_dice_to_game(), iterating over swing dice in some fashion. Maybe something not quite implemented right in the intersection of option and reserve dice?

blackshadowshade commented 10 years ago

Okay, I'll take a look at this one.

cgolubi1 commented 10 years ago

I have a test case for this.

Add these two buttons:

test1: (1) (1) r(Z)
test2: (1,1) r(1)

Create a game between them, and play the first round. Button test1 will necessarily gain initiative and win the round, triggering the internal error, like so:

submitturn_error_simple_case

As noted above, the log error is:

[Tue Jun 17 15:17:34 2014] [error] [client 10.0.2.2] PHP Warning:  array_key_exists() expects parameter 2 to be array, null given in /var/www/engine/BMGame.php on line 303, referer: http://localhost:8080/ui/game.html?game=16

Things i learned in the 16 games it took me to find a working test case:

cgolubi1 commented 10 years ago

I think this would be good to fix, especially since it might affect more circumstances than the test case i was able to find. However, i've verified in vagrant that it doesn't appear to affect Hooloovoo (played Hooloovoo vs. Cammy Neko, and Hooloovoo vs. Sailor Mercury, made sure Hooloovoo won the first round each time, and at least once made sure Hooloovoo took the last attack before winning the round).

In other words, afaict this one only affects buttons with swing in reserve dice but not in starting dice, and that's only a handful of fanatics, none of which are considered "implemented", so no one is going to trip over them by accident on prod.

So my take is, not a blocker.

blackshadowshade commented 10 years ago

OK, I can replicate this bug:

Zomulgastar vs Cammy Neko, set swing option for Zomulgastar, then Cammy Neko surrenders as soon as possible.