Ejemplo n.º 1
0
def rule_matcher(condition, action, constraints):
    if not isinstance(action, list) or not isinstance(constraints, str):
        raise TypeError
    stacks = GameModel.get_env()['stacks'] 
    registers = GameModel.get_env()['registers']
    if boolean_matcher(condition, stacks, registers):
        if check(constraints):
            fire(action)
            GameModel.clean_reg()
            return True
    GameModel.clean_reg()
    return False
Ejemplo n.º 2
0
def test_boolean_match_truefalse_regex():
    assert not boolean_matcher([first, second], stacks, registers)
Ejemplo n.º 3
0
def test_boolean_match_singlefalse_regex():
    assert not boolean_matcher([second], stacks, registers)
Ejemplo n.º 4
0
def test_boolean_match_copy_regex():
    assert boolean_matcher([first, first], stacks, registers)
Ejemplo n.º 5
0
def test_boolean_match_singletrue_regex():
    assert boolean_matcher([first], stacks, registers)