/* This implements a per-game-element property cache */
function gameprop(obj, property) {
    var map = jQuery.data(obj, "game.properties") || {};
    var prop = map[property];
    return prop;
}

function gamepropSet(obj, property, newValue) {
    var map = jQuery.data(obj, "game.properties") || {};
    var oldValue = map[property];
    map[property] = newValue;
    jQuery.data(obj, "game.properties", map);
    return oldValue;
}

function gamepropEquals(obj, property, value) {
    return gameprop(obj, property) == value;
}

function gamepropToggle(obj, property) {
    var oldValue = gameprop(obj, property);
    return gamepropSet(obj, property, !oldValue);
}
