コード例 #1
0
    def test_act__resets_locks(self):
        init_state = State(locks=[Lock(), Lock()], game=0)
        target = RestartAction(init_state)

        actual = target.act(State(locks=[], game=3))

        assert 2 == len(actual.locks)
コード例 #2
0
    def test_open__operator_or_none_is_solved__state_is_closed(self):
        puzzle1 = Puzzle(6, 1)
        puzzle2 = Puzzle(6, 2)
        puzzle3 = Puzzle(6, 3)
        target = Lock('six', 0x3F, 6, [puzzle1, puzzle2, puzzle3], LockOperator.OR)

        assert target.state is LockState.CLOSED
コード例 #3
0
    def test_open__operator_or_one_is_solved__state_is_open(self):
        puzzle1 = Puzzle(6, 1)
        puzzle2 = Puzzle(6, 2)
        puzzle2.state = PuzzleState.SOLVED
        puzzle3 = Puzzle(6, 3)
        target = Lock('six', 0x3F, 6, [puzzle1, puzzle2, puzzle3], LockOperator.OR)

        assert target.state is LockState.OPEN
コード例 #4
0
    def test_open__operator_or_one_is_not_solved__state_is_closed(self):
        puzzle1 = Puzzle(6, 1)
        puzzle2 = Puzzle(6, 2)
        puzzle2.state = PuzzleState.SOLVED
        puzzle3 = Puzzle(6, 3)
        puzzle3.state = PuzzleState.SOLVED
        target = Lock('six', 0x3F, 6, [puzzle1, puzzle2, puzzle3], LockOperator.AND)

        assert target.state is LockState.CLOSED
コード例 #5
0
import pytest
from unittest import TestCase
from unittest.mock import Mock, call

from src.game.store import Store
from src.game.actions import Action
from src.game.queries import Query
from src.game.models import State, Puzzle, Lock

test_state = State(locks=[
    Lock('first', 0x3F, 1, [
        Puzzle(1, 1),
        Puzzle(1, 2)
    ]),
    Lock('two', 0x3F, 2, [
        Puzzle(2, 5)
    ]),
    Lock('three', 0x3F, 3, [
        Puzzle(3, 6)
    ]),
    Lock('four', 0x3F, 4, [
        Puzzle(4, 7)
    ]),
    Lock('five', 0x3F, 5, [
    ]),
    Lock('six', 0x3F, 6, [
        Puzzle(6, 1),
        Puzzle(6, 2),
        Puzzle(6, 3)
    ])
])
コード例 #6
0
        self.trigger()

    def trigger(self):
        if self._subscriber:
            self._subscriber(self.state)

    def perform_query(self, query: Query):
        return query.perform(self.state)

    def subscribe(self, subscriber):
        self._subscriber = subscriber


init_state = State(locks=[
    Lock('Гнев', 56, 0, [Puzzle('62:01:94:70:63:9d', 8)]),
    Lock('Уныние', 56, 1, [Puzzle('a2:20:a6:02:08:b4', 11)]),
    Lock('Гордыня - свет', 56, 2, [Puzzle('5e:cf:7f:89:2a:9a', 12)]),
    Lock('Гордыня - код', 56, 3, [Puzzle('5e:cf:7f:89:2a:9a', 13)]),
    Lock('Алчность', 56, 4, [Puzzle('a2:20:a6:13:2d:80', 14)]),
    Lock('Обжорство - конфеты', 56, 7, [Puzzle('62:01:94:70:67:b3', 21)]),
    Lock('Обжорство - фрукты', 57, 0,
         [Puzzle('62:01:94:70:67:b3', 22),
          Puzzle('62:01:94:70:67:b3', 23)]),
    Lock('Сцена КОД', 57, 7, [Puzzle('a2:20:a6:02:67:a9', 25)]),
    Lock('Театр ВЫХОД ', 57, 6, [Puzzle('a2:20:a6:12:2a:9b', 24)]),
    Lock('темная комната ВЫХОД', 57, 5, [Puzzle('5e:cf:7f:1a:b6:2e', 9)]),
    Lock('Крест', 61, 5, [Puzzle('5e:cf:7f:87:56:5c', 20)]),
    Lock('сундук 1', 58, 2, [Puzzle('5e:cf:7f:87:56:52', 15)]),
    Lock('сундук 2', 58, 5, [Puzzle('5e:cf:7f:1a:ba:df', 16)]),
    Lock('сундук 3', 58, 1, [Puzzle('5e:cf:7f:1b:60:98', 17)]),