buttonmen-dev/buttonmen — pull request #325 by cgolubi1 (2013-12-23 23:25:00+00:00)
Title: frontend for chance/focus attacks

Okay, here's the deal:
* I made a frontend for chance/focus. I *think* it does the right things, it passes all of my unit tests, and i can operate on it in the right ways using live data. I fixed up a couple of BMInterface bugs so that the processing gets at least that far.
* However, there are a number of dealbreaker bugs in the logic which i don't know how to find. What i've seen so far:
* Rerolling chance dice does actually work, as in the backend will reroll a die for you. But, as far as i can tell, nothing advances the game state, period. If you fail to get initiative, it's still your turn to try. If you succeed in getting initiative, it's your opponent's turn to try and this goes back and forth without limit (again, afaict)
* Turning down focus dice does not appear to work. I get an error (return value false/null) with game message "Loaded data for game 6.". I poked around in the UI enough to figure out that $isSuccessful = $game->react_to_initiative($argArray); is returning false, but i didn't sleuth any further than that.
* The backend doesn't tell the frontend whether what you did caused you to gain initiative, so i can't pass that along as part of the message (this one is not a dealbreaker, but it would be nice if i didn't have to do the math, and in fact writing the logic in the chance case would be hard. The backend knows whether or not initiative was gained --- it should pass along:
* data = False/Null: the action failed for a reason (i.e. the action was invalid or an error occurred)
* data = ('gained_initiative' => boolean): the action succeeded, and either did or didn't lead to the played gaining initiative
* I made a responderTest function, test_request_reactToInitiative(), which fails because of the logic issues with focus. So i left the logic in there, but marked it incomplete and returned early, so that the unit tests would succeed.

My recommendation to James is that you approve this pull request (provided it passes unit tests for you too), and i hand off back to you. Even if there are further bugs in the new UI (likely), it should still give you enough to work with that you can test the backend more easily. Yes, it means more broken UI for our alpha testers, but games with chance and focus already don't work, so they'll just... not work differently.