buttonmen-dev / buttonmen

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

Can't pass in game 36 #285

Closed AdmiralJota closed 10 years ago

AdmiralJota commented 10 years ago

Game 36, which you may recall from such previous issues as #272 and Troy McClure vs. Tess, is still behaving oddly. It's still on the same turn as it was before the berserk/skill fix, and it's still showing up on my list of games waiting for me. However, when I go to the game's page, instead of letting me pass now that I have no valid attacks, it instead says "It is your opponent's turn to attack right now."

cgolubi1 commented 10 years ago

For me (Jota's opponent), the game shows up as under my opponent's list of games requiring moves (not my own list), but when i go to the actual game page, it gives me an attack box.

Here's the game data from firebug for http://alpha.buttonweavers.com/ui/game.html?game=36 (response to loadGameData for game=36):

{
  "data":{
    "currentPlayerIdx":0,
    "gameData":{
      "status":"ok",
      "data":{
        "gameId":"36",
        "gameState":40,
        "roundNumber":1,
        "maxWins":"3",
        "activePlayerIdx":0,
        "playerWithInitiativeIdx":"1",
        "playerIdArray":["1","4"],
        "buttonNameArray":["Tess","Synthia"],
        "waitingOnActionArray":[true,false],
        "nDieArray":[1,2],
        "valueArrayArray":[["4"],["1","3"]],
        "sidesArrayArray":[[4],[4,3]],
        "dieRecipeArrayArray":[["n(4)"],["B(4)","(3)"]],
        "swingRequestArrayArray":[["X"],["T"]],
        "validAttackTypeArray":{"Power":"Power"},
        "roundScoreArray":[18,27.5],
        "gameScoreArrayArray":[{"W":0,"L":0,"D":0},{"W":0,"L":0,"D":0}]
      }
    },
    "playerNameArray":["glassonion","AdmiralJota"],
    "timestamp":"Sat, 07 Dec 2013 16:51:51 +0000",
    "gameActionLog":[
      {"timestamp":"2013-12-10 01:13:04","message":"glassonion performed Power attack using [n(4):4] against [(12):3]; Defender (12) was captured, recipe changed from (12) to n(12); Attacker n(4) rerolled 4 => 4"},
      {"timestamp":"2013-12-10 01:02:03","message":"AdmiralJota performed Power attack using [(12):11] against [(X):4]; Defender (X) was captured; Attacker (12) rerolled 11 => 3"},
      {"timestamp":"2013-12-10 00:41:33","message":"glassonion performed Power attack using [(X):1] against [(T):1]; Defender (T) was captured; Attacker (X) rerolled 1 => 4"},
      {"timestamp":"2013-12-08 23:08:18","message":"AdmiralJota performed Skill attack using [(T):2,(3):3] against [(8):5]; Defender (8) was captured; Attacker (T) rerolled 2 => 1; Attacker (3) rerolled 3 => 3"},
      {"timestamp":"2013-12-08 18:02:51","message":"glassonion performed Power attack using [(X):2] against [(12):1]; Defender (12) was captured; Attacker (X) rerolled 2 => 1"}]
  },
  "message":"Loaded data for game 36.",
  "status":"ok"
}

Here's the game data from firebug for my index page (response to loadActiveGames):

{
  "data":{
    "gameIdArray":["1","2","4","18","22","23","24","27","29","30","32","35","36","39","40"],
    "opponentIdArray":["2","4","5","6","8","7","9","4","11","5","12","2","4","9","11"],
    "opponentNameArray":["blackshadowshade","AdmiralJota","ElihuRoot","Caligari","irilyth","RCW","schwa","AdmiralJota","yawetag","ElihuRoot","jimmosk1","blackshadowshade","AdmiralJota","schwa","yawetag"],
    "myButtonNameArray":["Peace","Bane","Reaver","Nickie","Iago","Peace","Jellybean","Simon","Nightmare","Faith","Eiko","Shepherd","Tess","O-Lass","Synthia"],
    "opponentButtonNameArray":["Bunnies","Tess","Jellybean","Morgan","Dirgo","Hope","Changeling","Simon","Bane","Patience","Faith","Jellybean","Synthia","Brigid","Chris"],
    "nWinsArray":["2","3","2","2","0","0","0","3","0","0","1","1","0","0","0"],
    "nDrawsArray":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],
    "nLossesArray":["5","0","3","0","0","2","3","1","3","2","1","0","0","0","0"],
    "nTargetWinsArray":["5","3","3","3","3","3","3","3","3","3","3","3","3","3","3"],
    "isAwaitingActionArray":["0","0","0","0","0","0","0","0","0","1","1","1","0","0","1"],
    "gameStateArray":["60","60","60","40","40","40","60","60","60","40","40","40","40","40","40"],
    "statusArray":["OPEN","OPEN","OPEN","OPEN","OPEN","OPEN","OPEN","OPEN","OPEN","OPEN","OPEN","OPEN","OPEN","OPEN","OPEN"]
  },
  "message":"All game details retrieved successfully.",
  "status":"ok"
}

In other words, loadActiveGames isAwaitingActionArray says 0 for this game, whereas loadGameData waitingOnActionArray for my position says true. That should never happen (afaik), so if nothing else, that's a bug.

blackshadowshade commented 10 years ago

I'm pretty sure I know what's going on here.

During BMInterface->load_game(), there is a call to BMGame->proceed_to_next_user_action. Thus, when you actually go to the game page, it advances, playing an auto-pass from Jota, so that the next action is Chaos'.

However, during BMInterface->get_all_active_games(), there is no implicit proceed_to_next_user_action. It is ASSUMED that this has already occurred in BMInterface->save_game(). Thus, we are simply displaying what is in the database.

I think that this is the same problem as #218.

When we have implemented to ability to choose whether autopass is on or not, we will need to force all active games for that player to load and save, which will force the database to be at the latest state possible.

blackshadowshade commented 10 years ago

OK, I've thought of a better solution. Basically, we remove the call to BMGame->proceed_to_next_user_action() in BMInterface->load_game(). In this way, we always load exactly what is in the database, which means that the summary page will always match exactly with the game page. I'll implement this in the next couple of days.