values[$value_name])) throw new Exception("Enum '{$this->name}' already has value with name '{$value_name}'"); if(in_array($value, $this->values)) throw new Exception("Enum '{$this->name}' already has value '{$value}'"); $this->values[$value_name] = $value; } function calcOrValue($or_keys) { $res = 0; foreach($or_keys as $value_name) { if(!isset($this->values[$value_name])) throw new Exception("Enum '{$this->name}' has no value '{$value_name}'"); $res |= $this->values[$value_name]; } return $res; } function addOrValues($values) { foreach($values as $value_name => $or_keys) $this->addValue($value_name, $this->calcOrValue($or_keys)); } function getValues() { return $this->values; } function override(mtgMetaEnum $other) { $this->tokens = array_merge($this->tokens, $other->getTokens()); $this->values = array_merge($this->values, $other->getValues()); } function replace(mtgMetaEnum $other) { $this->tokens = $other->getTokens(); $this->values = $other->getValues(); } }