Пример #1
0
    def __init__(self):


        #p3 setup stuff
        if len(sys.argv) != 2:
            sys.exit('Usage: ' + sys.argv[0] + ' dolphin-home')
        home = sys.argv[1]

        state = State()
        sm = StateManager(state)
        
        locationsTxt = ''
        for i in sm.locations():
            locationsTxt += i + '\n'

        with open(home + '/MemoryWatcher/Locations.txt', 'w') as file:
            file.write(locationsTxt)

        #qt stuff
        app = QtGui.QApplication(sys.argv)

        #handle closing
        done = False
        def exitHandler():
            nonlocal done
            done = True

        #create container
        cont = Container(2000,500,exitHandler)
        cont.show()

        #spawn fastfall counter
        ffc = FastFallCounter(state)

        ffc.setParent(cont)
        ffc.show()
        ffc.resize(1000,100)

        #p3 run loop
        mw = MemoryWatcher(home + '/MemoryWatcher/MemoryWatcher')
        for returnValue in mw:
            if returnValue is not None:
                address, value = returnValue
                sm.handle(address,value)
            app.processEvents()
            if done:
                break
Пример #2
0
def start(setup):

    if len(sys.argv) != 2:
        sys.exit('Usage: ' + sys.argv[0] + ' dolphin-home')
    home = sys.argv[1]

    state = State()
    sm = StateManager(state)

    # state.players[0].hitlag_counter_changed.append(listener)

    locationsTxt = ''
    for i in sm.locations():
        locationsTxt += i + '\n'

    with open(home + '/MemoryWatcher/Locations.txt', 'w') as file:
        file.write(locationsTxt)

    done = False

    def exitHandler():
        nonlocal done
        done = True

    app = QtGui.QApplication(sys.argv)

    board = Melee()

    fi = FrameIndicator()
    fi.center = 0
    state.players[0].vertical_velocity_changed.append(
        lambda x: listener(x, fi))

    cont = Container(board, exitHandler, fi)
    cont.show()
    setup(state, board, cont)
    # board.texts.append((200,350,"hello"))

    mww = MemoryWatcher(home + '/MemoryWatcher/MemoryWatcher')
    for returnValue in mww:
        if returnValue is not None:
            address, value = returnValue
            sm.handle(address, value)
        app.processEvents()
        if done:
            break
Пример #3
0
class StateManagerTest(unittest.TestCase):
    def setUp(self):
        self.state = State()
        self.state_manager = StateManager(self.state)

    def test_state_manager_basic(self):
        self.assertEqual(self.state.frame, 0)
        self.state_manager.handle('80479D60', b'\x00\x00\x00\x01')
        self.assertEqual(self.state.frame, 1)

    def test_state_manager_player(self):
        self.assertEqual(self.state.players[0].character, Character.Unselected)
        self.assertEqual(self.state.players[0].type, PlayerType.Unselected)
        self.state_manager.handle('803F0E08', b'\x00\x00\x0A\x00')
        self.assertEqual(self.state.players[0].character, Character.Fox)
        self.assertEqual(self.state.players[0].type, PlayerType.Human)

    def test_state_manager_asserts(self):
        with self.assertRaises(AssertionError):
            self.state_manager.handle('missing', 12345)

    def test_state_manager_locations(self):
        for location in self.state_manager.locations():
            self.assertIsNotNone(
                re.fullmatch('[0-9A-F]{8}( [0-9A-F]+)*', location))
Пример #4
0
class StateManagerTest(unittest.TestCase):
    def setUp(self):
        self.state = State()
        self.state_manager = StateManager(self.state)

    def test_state_manager_basic(self):
        self.assertEqual(self.state.frame, 0)
        self.state_manager.handle('80479D60', b'\x00\x00\x00\x01')
        self.assertEqual(self.state.frame, 1)

    def test_state_manager_player(self):
        self.assertEqual(self.state.players[0].character, Character.Unselected)
        self.assertEqual(self.state.players[0].type, PlayerType.Unselected)
        self.state_manager.handle('803F0E08', b'\x00\x00\x0A\x00')
        self.assertEqual(self.state.players[0].character, Character.Fox)
        self.assertEqual(self.state.players[0].type, PlayerType.Human)

    def test_state_manager_asserts(self):
        with self.assertRaises(AssertionError):
            self.state_manager.handle('missing', 12345)

    def test_state_manager_locations(self):
        for location in self.state_manager.locations():
            self.assertIsNotNone(re.fullmatch('[0-9A-F]{8}( [0-9A-F]+)*', location))
Пример #5
0
 def setUp(self):
     self.state = State()
     self.state_manager = StateManager(self.state)
Пример #6
0
 def setUp(self):
     self.state = State()
     self.state_manager = StateManager(self.state)