rspeer / dominiate

A simulator for Dominion card game strategies
http://rspeer.github.com/dominiate
MIT License
121 stars 43 forks source link

@rspeer I've never written coffee code before so please go over this, es... #54

Closed Jorbles closed 12 years ago

Jorbles commented 12 years ago

...pecially how i implemented the card drawing for the reaction to being attacked. I've gotta get going for now, but I'll give this some more thought once I've got time to pour over where the ai.choose code is implemented.

rspeer commented 12 years ago

Okay, here's my feedback.

Indentation is important in CoffeeScript, just like in Python, and whether you use tabs or spaces to indent has to be consistent from one line to the next. Your code had tabs and spaces mixed together, preventing it from running. Text editors can usually be configured to only use spaces even when you hit "tab", which avoids this problem.

There was a bug here that it took me a while to catch: the player playing Secret Chamber was drawing two cards into their own deck, but then the attacker was being forced to put back two cards from their hand. (That's one heck of a reaction!) In a reaction, "player" is the player being attacked, and "state.current" is the attacker.

When choosing a card and then doing something with it, you have to check if the card was null (meaning there were no choices and the action failed). This hardly affects Secret Chamber, though. I think it would have crashed if a player whose entire deck consisted of a Secret Chamber in hand got attacked. So not something to worry about.

Despite that there were bugs, thanks for writing this code. Now Secret Chamber is in Dominiate.

Jorbles commented 12 years ago

I'm glad you got it to work. Sorry about the tab/space errors, some codebases care about that, and some don't, I probably should have read more about coffeeScript before attempting anything. woops on the bug though, that would be a crazy reaction, that's a non-intuitive mistake. If I have time I'll work on some other cards in the future.

Jordie

On 19 December 2011 03:45, Rob Speer reply@reply.github.com wrote:

Okay, here's my feedback.

Indentation is important in CoffeeScript, just like in Python, and whether you use tabs or spaces to indent has to be consistent from one line to the next. Your code had tabs and spaces mixed together. Text editors can usually be configured to only use spaces even when you hit "tab", which avoids this problem.

There was a bug here that it took me a while to catch: the player playing Secret Chamber was drawing two cards into their own deck, but then choosing two cards from their opponent's hand to put back on their opponent's deck. (That's one heck of a reaction!) In a reaction, "player" is the player being attacked, and "state.current" is the attacker.

When choosing a card and then doing something with it, you have to check if the card was null (meaning there were no choices and the action failed). This hardly affects Secret Chamber, though. I think it would have crashed if a player whose entire deck consisted of a Secret Chamber in hand got attacked. So not something to worry about.

Despite that there were bugs, thanks for writing this code. Now Secret Chamber is in Dominiate.


Reply to this email directly or view it on GitHub: https://github.com/rspeer/dominiate/pull/54#issuecomment-3202209