rspeer / dominiate

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

Prevent Array.prototype.toString from interfering with other modules #69

Closed bilts closed 12 years ago

bilts commented 12 years ago

The CoffeeScript compiler depends on the output from Array::toString being formatted in a specific way. Our changes, which wrapped the output in square brackets, were causing the CoffeeScript compiler to double-wrap some arrays (particularly the ones returned by player strategies).

This commit makes it so that the change to Array::toString is applied when the program enters Dominiate's top-level API methods and is reverted when program control leaves those methods.

Fixes #56 Fixes #59

rspeer commented 12 years ago

Thank you so much.

I should keep in mind that the problem with deep JavaScript magic is that it might react badly with other deep JavaScript magic.