예제 #1
0
 def test_play():
     app = ELiDEApp()
     app.config = {'ELiDE': {'boardchar': 'foo'}}
     app.spotcfg = SpotConfigScreen()
     app.pawncfg = PawnConfigScreen()
     app.statcfg = StatScreen()
     char = Facade()
     char.name = 'foo'
     app.character = char
     app.engine = app.statcfg.engine = MockEngine()
     char.character = SimpleNamespace(engine=app.engine)
     app.engine.character['foo'] = char
     entity = ListenableDict()
     entity.engine = app.engine
     entity.name = 'name'
     app.selected_proxy = app.proxy = app.statcfg.proxy = entity
     screen = MainScreen(app=app, graphboards={'foo': GraphBoard(
         character=char, app=app)}, gridboards={
         'foo': GridBoard(character=char)
     }, play_speed=1.0)
     win = window_with_widget(screen)
     idle_until(lambda: 'timepanel' in screen.ids)
     timepanel = screen.ids['timepanel']
     idle_until(lambda: timepanel.size != [100, 100])
     turnfield = timepanel.ids['turnfield']
     turn_before = int(turnfield.hint_text)
     playbut = timepanel.ids['playbut']
     x, y = playbut.center
     sx = x / win.width
     sy = y / win.height
     motion = MockTouch("unittest", 1, {'sx': sx, 'sy': sy})
     EventLoop.post_dispatch_input("begin", motion)
     EventLoop.post_dispatch_input("end", motion)
     idle_until(lambda: int(turnfield.hint_text) == 3, 300, "Time didn't advance fast enough")
예제 #2
0
    def test_layout_grid():
        spots_wide = 3
        spots_tall = 3
        graph = nx.grid_2d_graph(spots_wide, spots_tall)
        char = Facade(graph)
        app = ELiDEApp()
        spotlayout = FinalLayout()
        arrowlayout = FinalLayout()
        board = GraphBoard(app=app,
                           character=char,
                           spotlayout=spotlayout,
                           arrowlayout=arrowlayout)
        spotlayout.pos = board.pos
        board.bind(pos=spotlayout.setter('pos'))
        spotlayout.size = board.size
        board.bind(size=spotlayout.setter('size'))
        board.add_widget(spotlayout)
        arrowlayout.pos = board.pos
        board.bind(pos=arrowlayout.setter('pos'))
        arrowlayout.size = board.size
        board.bind(size=arrowlayout.setter('size'))
        board.add_widget(arrowlayout)
        board.update()
        boardview = GraphBoardView(board=board)
        EventLoop.ensure_window()
        win = EventLoop.window
        win.add_widget(boardview)

        def all_spots_placed():
            for x in range(spots_wide):
                for y in range(spots_tall):
                    if (x, y) not in board.spot:
                        return False
            return True

        while not all_spots_placed():
            EventLoop.idle()
        # Don't get too picky about the exact proportions of the grid; just make sure the
        # spots are positioned logically with respect to one another
        for name, spot in board.spot.items():
            x, y = name
            if x > 0:
                assert spot.x > board.spot[x - 1, y].x
            if y > 0:
                assert spot.y > board.spot[x, y - 1].y
            if x < spots_wide - 1:
                assert spot.x < board.spot[x + 1, y].x
            if y < spots_tall - 1:
                assert spot.y < board.spot[x, y + 1].y
예제 #3
0
 def test_select_spot():
     char = Facade()
     char.add_place(0, _x=0.1, _y=0.1)
     app = ELiDEApp()
     board = GraphBoard(app=app, character=char)
     boardview = GraphBoardView(board=board)
     win = window_with_widget(boardview)
     idle_until(lambda: 0 in board.spot and board.spot[0] in board.
                spotlayout.children)
     x, y = board.spot[0].center
     motion = MockTouch("unittest", 1, {
         'sx': x / win.width,
         'sy': y / win.height
     })
     EventLoop.post_dispatch_input("begin", motion)
     EventLoop.post_dispatch_input("end", motion)
     assert app.selection == board.spot[0]
예제 #4
0
 def test_select_arrow():
     char = Facade()
     char.add_place(0, _x=0.1, _y=0.1)
     char.add_place(1, _x=0.2, _y=0.1)
     char.add_portal(0, 1)
     app = ELiDEApp()
     board = GraphBoard(app=app, character=char)
     boardview = GraphBoardView(board=board)
     win = window_with_widget(boardview)
     idle_until(lambda: 0 in board.arrow and 1 in board.arrow[0] and board.
                arrow[0][1] in board.arrowlayout.children)
     ox, oy = board.spot[0].center
     dx, dy = board.spot[1].center
     motion = MockTouch("unittest", 1, {
         'sx': (ox + ((dx - ox) / 2)) / win.width,
         'sy': dy / win.height
     })
     EventLoop.post_dispatch_input("begin", motion)
     EventLoop.post_dispatch_input("end", motion)
     assert app.selection == board.arrow[0][1]
예제 #5
0
 def test_pawn_relocate():
     char = Facade()
     char.add_place(0, _x=0.1, _y=0.1)
     char.add_place(1, _x=0.2, _y=0.1)
     char.add_thing('that', location=0)
     app = ELiDEApp()
     board = GraphBoard(app=app, character=char)
     boardview = GraphBoardView(board=board)
     win = window_with_widget(boardview)
     idle_until(lambda: 0 in board.spot and board.spot[
         0] in board.spotlayout.children and 1 in board.spot and board.spot[
             1] in board.spotlayout.children and 'that' in board.pawn and
                board.pawn['that'] in board.spot[0].children)
     that = board.pawn['that']
     one = board.spot[1]
     # In a real ELiDE session, the following would happen as a
     # result of a Board.update() call
     char.thing['that']['location'] = that.loc_name = 1
     idle_until(lambda: that in one.children, 1000,
                "pawn did not relocate within 1000 ticks")
예제 #6
0
파일: guitest.py 프로젝트: LogicalDash/LiSE
# This file is part of LiSE, a framework for life simulation games.
# Copyright (c) Zachary Spector,  [email protected]
"""Initialize the kobold test and launch the GUI."""
from ELiDE.app import ELiDEApp
from kobold import clear_off, mkengine, inittest

clear_off()
with mkengine() as engine:
    inittest(engine)


app = ELiDEApp()
app.run()
예제 #7
0
from multiprocessing import freeze_support
import sys
import os
wd = os.getcwd()
sys.path.extend([wd + '/LiSE', wd + '/ELiDE'])


def get_application_config(*args):
    return wd + '/ELiDE.ini'


if __name__ == '__main__':
    freeze_support()

    from ELiDE.app import ELiDEApp
    app = ELiDEApp()
    app.get_application_config = get_application_config
    app.run()
예제 #8
0
# This file is part of LiSE, a framework for life simulation games.
# Copyright (c) Zachary Spector,  [email protected]
"""Initialize the kobold test and launch the GUI."""
from ELiDE.app import ELiDEApp
from kobold import clear_off, mkengine, inittest

clear_off()
with mkengine() as engine:
    inittest(engine)

app = ELiDEApp()
app.run()
예제 #9
0
def elide():
    from ELiDE.app import ELiDEApp
    app = ELiDEApp()
    app.run()
예제 #10
0
def elide():
    from ELiDE.app import ELiDEApp
    app = ELiDEApp()
    app.run()
예제 #11
0
파일: main.py 프로젝트: LogicalDash/LiSE
from multiprocessing import freeze_support
import sys
import os
wd = os.getcwd()
sys.path.extend([wd + '/LiSE', wd + '/ELiDE', wd + '/allegedb'])


def get_application_config(*args):
    return wd + '/ELiDE.ini'


if __name__ == '__main__':
    freeze_support()

    from ELiDE.app import ELiDEApp
    app = ELiDEApp()
    app.get_application_config = get_application_config
    app.run()