Example #1
0
    def __init__(self, N, depth):

        self.bots = {}
        self.buildings = {}
        self.maps = maps.Maps(N, depth)
        self.schedule = collections.defaultdict(collections.deque)
        self.score = 0
        self.resources = [100] * 5
        self.year = 2025.0
        self.season = (self.year % 1) * 4
        self.t_per_season = 100
Example #2
0
def GAME():
    map = maps.Maps()

    welcome = interface.Label(700, 100, 400, 200, None, background)
    welcome.add_text("ANGRY BIRDS", 80, "Fonts/arfmoochikncheez.ttf",
                     (236, 240, 241))

    start = interface.Button(500, 400, 300, 100, start_game, (244, 208, 63),
                             (247, 220, 111))
    start.add_text("START GAME", 60, "Fonts/arfmoochikncheez.ttf", background)

    exit = interface.Button(1000, 400, 300, 100, close, (241, 148, 138),
                            (245, 183, 177))
    exit.add_text("QUIT", 60, "Fonts/arfmoochikncheez.ttf", background)

    mandav = interface.Button(width - 300, height - 80, 300, 100, None,
                              background)
    mandav.add_text("MANDAV", 60, "Fonts/arfmoochikncheez.ttf", (41, 41, 41))

    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                close()
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_q:
                    close()

            if event.type == pygame.MOUSEBUTTONDOWN:
                if exit.isActive():
                    exit.action()
                if start.isActive():
                    start_game(map)

        display.fill(background)

        start.draw()
        exit.draw()
        welcome.draw()
        mandav.draw()

        pygame.display.update()
        clock.tick(60)
Example #3
0
 def load_user_info(self, user_dict):
     # os.system('nohup python3 APIs.py &')
     # user_destinations = ["305 Swindon Way, West Lafayette, Indiana", "222 West Wood St, West Lafayette, Indiana", "West Madison Street, Chicago, Illinois"]
     self.rt = maps.Maps(user_dict["address"], user_dict['freqDests'])
     self.calendarEvents = googleCalendar.Calendar() # fix to take in user id and get user's token
     self.weather = weather.Weather(user_dict["address"])
     self.datetime = DateTime.DateTime()
     self.feed = feeds.Feeds()
     # Init
     newsapi = NewsApiClient(api_key='33ff7834a7ee40928e7bb90746c8b6e5')
     # top_headlines = newsapi.get_top_headlines(category=user_dict["newsCategories"][0]
     #                                         language='en',
     #                                           country='us')
     news_sources = newsapi.get_sources()
     news_url = ('https://newsapi.org/v2/top-headlines?'
            'category=%s&'
            'country=us&'
            'apiKey=33ff7834a7ee40928e7bb90746c8b6e5' %(user_dict["newsCategories"][0]))
     # print(news_url)
     news_response = requests.get(news_url)
     self.news_data = news_response.json()
    def init_ui(self):
        # self.qt.showFullScreen()
        self.analog = analog.AnalogClock()
        self.rt = maps.Maps()
        self.calendarEvents = googleCalendar.Calendar()

        self.qt.resize(800, 800)

        datetime = QDateTime.currentDateTime()

        font = QFont('Helvetica', 18)
        font.setWeight(1)

        # Set background black
        self.darkPalette = QPalette()
        self.darkPalette.setColor(QPalette.Background, Qt.black)
        self.qt.setPalette(self.darkPalette)

        effect = QGraphicsDropShadowEffect()
        effect2 = QGraphicsDropShadowEffect()
        effect.setOffset(1, 1)
        effect2.setOffset(1, 1)
        effect.setBlurRadius(30)
        effect.setColor(QColor(255,255,255))
        effect2.setBlurRadius(20)
        effect2.setColor(QColor(255,255,255))
        # self.qt.setGraphicsEffect(effect)

        #
        self.qt.msb = QPushButton('Main screen')
        self.qt.gmb = QPushButton('Groom mode')
        self.qt.lsb = QPushButton('Lock screen')
        self.qt.l = QLabel()
        self.qt.time = QLabel("<font color='white'>" + datetime.toString("MMM d, yyyy hh:mm:ss AP") + "</font")
        self.qt.time.setFont(font)
        self.analog.setGraphicsEffect(effect)
        self.qt.time.setGraphicsEffect(effect2)

        # Main screen layout
        self.TimeWeatherBox = QHBoxLayout()
        self.welcomeBox = QHBoxLayout()
        self.appListBox = QHBoxLayout()
        self.appBox = QHBoxLayout()

        ###
        self.weather = weather.Weather()
        self.weather.weatherBox.setAlignment(Qt.AlignLeft)
        self.weather.setFixedHeight(150)
        self.TimeWeatherBox.addWidget(self.weather)

        self.datetime = DateTime.DateTime()
        self.datetime.setFixedHeight(150)
        self.TimeWeatherBox.addWidget(self.datetime)

        ###
        self.welcomeLabel = QLabel("<font color='white'>" + "Welcome, Amjad!" + "</font")
        self.welcomeLabel.setAlignment(Qt.AlignCenter)
        self.welcomeLabel.setFixedHeight(100)
        self.welcomeBox.addWidget(self.welcomeLabel)

        ###
        self.feed = feeds.Feeds()
        self.feed.setFixedWidth(800)
        self.appBox.addWidget(self.feed)

        ###
        self.appList = []
        self.news = QPushButton('News')
        self.calendar = QPushButton('Calendar')
        self.routes = QPushButton('Routes')
        self.appList.append(self.news)
        self.appList.append(self.calendar)
        self.appList.append(self.routes)
        self.appList.append(self.qt.gmb)


        for app in self.appList:
            self.appListBox.addWidget(app)





        self.qt.digitaltime = QHBoxLayout()
        self.qt.analogclock = QHBoxLayout()



        # self.qt.welcomebox = QHBoxLayout()

        self.qt.digitaltime.addWidget(self.qt.time)
        self.qt.analogclock.addWidget(self.analog)
        # self.qt.feedBox.addWidget(self.qt.l)

        self.qt.h_box = QHBoxLayout()
        # self.qt.h_box.addStretch()
        self.qt.h_box.addWidget(self.qt.msb)
        # self.qt.h_box.addWidget(self.qt.gmb)
        # self.qt.h_box.addStretch()

        self.qt.v_box = QVBoxLayout()
        # self.qt.v_box.addWidget(self.qt.msb)
        self.qt.v_box.addLayout(self.qt.h_box)
        # self.qt.spacer = QSpacerItem(150, 150)
        # self.qt.v_box.addSpacerItem(self.qt.spacer)
        self.qt.v_box.addSpacing(150)
        self.qt.v_box.addLayout(self.qt.analogclock)
        self.qt.v_box.addLayout(self.qt.digitaltime)
        # self.qt.v_box.addSpacing(50)
        # self.qt.v_box.addLayout(self.qt.welcomebox)


        self.qt.setLayout(self.qt.v_box)
        self.qt.setWindowTitle('Lock screen')

        self.qt.digitaltime.setAlignment(Qt.AlignCenter)

        self.qt.msb.clicked.connect(self.msd)
        self.qt.gmb.clicked.connect(self.gmd)
        self.qt.lsb.clicked.connect(self.lsd)
        self.news.clicked.connect(self.news_headlines)
        self.calendar.clicked.connect(self.calendar_events)
        self.routes.clicked.connect(self.routes_info)

        self.init_timer()


        self.qt.showFullScreen()
Example #5
0
    def onInit(self):
        BaseWindow.onInit(self)
        self.setProperty('loading', '1')
        self._winID = xbmcgui.getCurrentWindowId()
        self.pushList = self.getControl(101)
        token = util.getSetting('pb_access_token')
        if not token: return

        loadVideoThumbs = util.getSetting('load_video_thumbs', False)
        kodiDevice = devices.getDefaultKodiDevice(
            util.getSetting('pb_client_iden'),
            util.getSetting('pb_client_nickname'))
        if not kodiDevice: return
        self.pushes = []
        pushes = self.client.pushes()
        if not pushes: return
        items = []
        cacheIDs = []
        self.pushes = []

        for p in pushes:  #Keep all IDs cached so that we don't cause a delay when changing view
            if p.get('active'):
                cacheIDs.append(p.get('iden'))

        if self.viewMode == 'SELF':
            self.pushes = [
                p for p in pushes if p.get('active')
                and p.get('target_device_iden') == kodiDevice.ID
            ]
        elif self.viewMode == 'ALL':
            self.pushes = [p for p in pushes if p.get('active')]
        elif self.viewMode:
            self.pushes = [
                p for p in pushes if p.get('active')
                and p.get('target_device_iden') == self.viewMode
            ]

        for push in self.pushes:
            iden = push.get('iden')

            title = push.get('title',
                             push.get('name', push.get('file_name', '')))
            bg = push.get('image_url', '')
            info = push.get('url', '')
            mediaIcon = ''
            media = ''

            if push.get('type') == 'address':
                bg = maps.Maps().getMap(urllib.quote(push.get('address', '')),
                                        'None',
                                        marker=True,
                                        return_url_only=True)
            elif push.get('type') == 'link':
                url = push.get('url')
                if StreamExtractor.mightHaveVideo(url):
                    media = 'video'
                    if loadVideoThumbs:
                        bg = getCachedData(iden)
                        if not bg:
                            bg = StreamExtractor.getVideoInfo(url).thumbnail
                            cacheData(iden, bg)
                else:
                    media = pushhandler.getURLMediaType(url)
                if not title:
                    title = url.rsplit('/', 1)[-1]
            elif push.get('type') == 'file':
                info = urllib.unquote(push.get('file_url', ''))
                if push.get('file_type', '').startswith('image/'):
                    media = 'image'
                elif push.get('file_type', '').startswith('audio/'):
                    media = 'music'
                elif push.get('file_type', '').startswith('video/'):
                    media = 'video'
            if media:
                mediaIcon = 'service-pushbullet-com-icon_{0}.png'.format(media)

            item = xbmcgui.ListItem(
                title,
                iconImage='service-pushbullet-com-{0}.png'.format(
                    push.get('type', '')))

            desc = push.get('body', push.get('address', ''))
            if push.get('type') == 'list':
                li = []
                ct = 0
                for i in push.get('items', []):
                    li.append(i.get('text', ''))
                    ct += 1
                    if ct > 50: break
                desc = ', '.join(li)
            desc = '[CR]'.join(desc.splitlines()[:4])
            item.setProperty('description', desc)
            item.setProperty('info', info)
            item.setProperty(
                'sender', push.get('sender_name', push.get('sender_email',
                                                           '')))
            item.setProperty('media_icon', mediaIcon)
            item.setProperty('background', bg)
            #item.setProperty('date',time.strftime('%m-%d-%Y %H:%M',time.localtime(push.get('created',0))))
            item.setProperty(
                'date', '{0} {1}'.format(
                    util.durationToShortText(time.time() -
                                             push.get('created', 0)),
                    T(32053)))
            items.append(item)

        self.setProperty('loading', '0')
        self.pushList.reset()
        self.pushList.addItems(items)

        if items: self.setFocusId(101)
        self.reSelect()
        cleanCache(cacheIDs)
Example #6
0
    SEEDCIV = 6
    EXPAND = 7
    DONE = 8


class Manager:
    def __init__(self):
        self.currentStage = GameStage.INITIAL

x_max = 200
y_max = 200

pygame.init()
manager = Manager()

land_layer = maps.Maps(x_max, y_max, 5)
civ_layer = maps.Maps(x_max, y_max, 5)

windowSize = [800, 800]

land_layer.make_empty()
civ_layer.make_empty()

# Plains, Coast, Hills, Neumann, Moore
civ1Mods = [2, 1, 3, 30, 30]
civ2Mods = [1, 1, 1, 1, 1]

civ_1 = civilization.Civilization(cell.CellType.CIV1, civ2Mods)

screen = pygame.display.set_mode(windowSize)
start_time = time.clock()
    def setup(self):
        self.signalStubs = SignalStubs()
        self.mapInstance = maps.Maps()

        # results =
        self.emptyResults = {'results': {'bindings': []}}
Example #8
0
    def maps(self):
        import maps
        if self._map_obj is None:
            self._map_obj = maps.Maps(libdfhack.Context_getMaps(self._c_ptr))

        return self._map_obj
Example #9
0
            return cha
        if type.lower() == 'm':
            cha = character.createMage(i)
            return cha
        if type.lower() == 'k':
            cha = character.createKnight(i)
            return cha
        if type.lower() == 'w':
            cha = character.createWarrior(i)
            return cha
        print("Invalid input, please try again.")


if __name__ == '__main__':
    number_random_card = 10
    map = maps.Maps()
    map.create_map()
    map.set_random_card(number_random_card)
    map.set_random_box(number_random_card)
    print_welcome()
    players_num = number_players()
    players = []
    for i in range(players_num):
        players.append(create_player(i))
        position = players[i].getPosition()
        x = position.getx()
        y = position.gety()
        map.coordinate[x][y].set_obj(players[i], "Player")
        map.picture[x] = map.picture[x][:y - 1] + "P" + map.picture[x][y:]
        map.coordinate[x][y].terrain.stepable = False
    map.print_map()