Exemple #1
0
def provinceGeometryEdit(events: list, province: Province,
                         mapsurface: pygame.Surface) -> None:
    for event in events:
        if event.type == pygame.MOUSEBUTTONDOWN:
            if event.button == 1 and mapsurface.collides(
                    event.pos):  #editing borders
                province.addPolygon(toScreenCoords(event.pos), mapsurface)
            elif event.button == 2 and mapsurface.collides(
                    event.pos):  #editing capitals
                # Log.d("Got it");
                capital_coords = event.pos
                map_capital_coords = toScreenCoords(
                    capital_coords).toMapCoords(mapsurface.get_scale(),
                                                mapsurface.get_coords())
                if len(world.list_of_capitals) != len(world.list_of_province):
                    world.add_capital(map_capital_coords, province)
                else:
                    province.set_capital_coords(map_capital_coords)
                    world.list_of_capitals[-1] = map_capital_coords
Exemple #2
0
def addStateMode(events: list, state: State,
                 mapsurface: pygame.Surface) -> None:
    for event in events:
        if event.type == pygame.MOUSEBUTTONDOWN:
            if event.button == 1 and mapsurface.collides(event.pos):
                variable_click = event.pos
                variable_capital_id = check_capitals(world, variable_click,
                                                     mapsurface)
                # Log.d("got ok")
                # try: Log.d(world.get_province(variable_capital_id).get_state().name);
                # except Exception : Log.d('no name');
                if variable_capital_id is not None and world.get_province(
                        variable_capital_id).get_state() is not state:
                    state.addProvince(world.get_province(variable_capital_id))
        if event.type == pygame.KEYDOWN:
            if event.key in map(ord, list('ZzЯя')):
                # Log.i("Caught");
                try:
                    province = state.list_of_province.pop()
                    province.state = province.previous_state
                except Exception:
                    pass