コード例 #1
0
ファイル: creation_center.py プロジェクト: Ghloin/tweeria
	def printCreationCenter(self, fields, params):

		fields.update({self.title: 'Creation center'})

		if not self.cur_player:
			return self.sbuilder.throwWebError(1002)

		items = self.model.items.getCraftedItems(self.cur_player['login_id'])
		spells = self.model.spells.getSpellsPattern(self.cur_player['login_id'])
		artworks = self.model.misc.getAllArtworksByPlayer(self.cur_player['login_id'])

		fields.update({
			'stat_names': self.balance.stats_name,
			'can_create': self.balance.MIN_LEVEL_TO_CREATE <= self.cur_player['login_lvl']
		})

		if self.core.debug['create_by_invite']:
			fields['can_create'] = self.cur_player and self.cur_player['login_ugc_enabled']

		items += spells + artworks

		sell_statuses = {
			'sell': 'Selling',
		    'not_sell': 'Not Selling',
		    'waiting': 'Waiting',
		    'rejected': 'Rejected'
		}

		for item in items:
			if 'reject' in item:
				status = 'rejected'

			elif item['approve'] and item['approve']['approved']:
				if item['sale_info']['active']:
					status = 'sell'
				else:
					status = 'not_sell'
			else:
				status = 'waiting'

			# Если заклинание, то ставим соответствующий тип
			if 'spell_actions' in item:
				item['view'] = 'Spell'
				item['img'] += '_fit.png'

			# если артворк
			elif 'faction' in item:
				item['img'] += '_fit.png'
				item['view'] = 'Artwork'
			# если предмет, то сделаем красивый вывод стат
			else:
				item['view'] = item['view'].title()
				item.update(prettyItemBonus(item, self.balance.stats_name))
				item['img'] = '/' + item['img'] + '_fit.png'

			item.update({'status': sell_statuses[status], 'raw_status': status})

		fields.update({'items': items})

		return basic.defaultController._printTemplate(self, 'creation_center', fields)
コード例 #2
0
ファイル: shop.py プロジェクト: Ghloin/tweeria
    def getPlayersItems(self, params, items_on_page=20, search={}, sort={}, total_pages=0):
        if self.cur_player:
            str_class = str(self.cur_player['login_class'])
        else:
            str_class = False

        page = 1

        if 'pi' in params:
            try:
                page = int(params['pi'])
            except Exception:
                pass

        if page > total_pages:
            page = 1

        players_items = self.model.items.getAllSellingCraftedItems(limit=items_on_page, skip=(page - 1) * items_on_page,
                                                                   query=search, sort_query=sort)

        authors_ids = Set()
        items_ids = Set()

        for item in players_items:
            authors_ids.add(item['author'])
            items_ids.add(item['_id'])

        players_names = self.model.players.getPlayersList(authors_ids, ['_id', 'name'])
        item_likes = self.getLikesDict(items_ids)

        for item in players_items:

            if item['type'] == 1 and str_class:
                if not item['view'] in self.sbuilder.balance.available_weapons[str_class]:
                    item['cant_use'] = True

            for player in players_names:
                if player['_id'] == item['author']:
                    item['author_name'] = player['name']
                    break

            item['img'] = '/' + item['img'] + '_fit.png'

            item.update(prettyItemBonus(item, self.balance.stats_name))
            if "stat_parsed" in item:
                item.update({"bonus_parsed": json.dumps(item['stat_parsed'])})

            if "img" in item:
                item.update({"share_img": item["img"][3:]})

            item.update(self.getLike(item_likes, item['_id']))
            item.update({
            'create_date_f': getReadbleTime(item['create_time'])
            })

        return players_items
コード例 #3
0
	def printItemEditPage(self, fields, params):

		item = self.getItem(params, logged_check=True, self_item_check=True)

		item.update(prettyItemBonus(item, self.balance.stats_name))

		if item['type'] == 1:
			item['type'] = '1:'+item['view']
		else:
			item['type'] = str(item['type'])

		fields.update({self.title: 'Edit '+item['name']+' page'})
		fields.update(item)


		return basic.defaultController._printTemplate(self, 'item_edit_page', fields)
コード例 #4
0
        def getLastItems(last_count=8):
            last_items = self.model.items.getLastApprovedItems(last_count)

            if self.cur_player:
                str_class = str(self.cur_player['login_class'])
            else:
                str_class = False

            authors_ids = Set()
            items_ids = Set()
            for item in last_items:
                authors_ids.add(item['author'])
                items_ids.add(item['_id'])
                item.update(prettyItemBonus(item, self.balance.stats_name))

                if item['type'] == 1 and str_class:
                    if not item[
                            'view'] in self.sbuilder.balance.available_weapons[
                                str_class]:
                        item['cant_use'] = True

                item['img'] += '_fit.png'

            players_names = self.model.players.getPlayersList(
                authors_ids, ['_id', 'name'])
            item_likes = self.model.items.getItemsLikes(items_ids)

            for item in last_items:
                for player in players_names:
                    if player['_id'] == item['author']:
                        item['author_name'] = player['name']
                        break

                for likes in item_likes:
                    if likes['item_id'] == item['_id']:
                        item['likes'] = len(likes['people'])
                        is_like = False
                        if self.cur_player:
                            is_like = self.cur_player['login_id'] in likes[
                                'people']

                        item['is_like'] = is_like
                        break
                else:
                    item['likes'] = 0

            return last_items
コード例 #5
0
ファイル: player.py プロジェクト: MHM5000/tweeria
        def formatItems(likes, items):
            for item in items:

                item['img'] = '/' + item['img'] + '_fit.png'

                item['author_name'] = player['name']

                item.update(prettyItemBonus(item, self.balance.stats_name))
                if "stat_parsed" in item:
                    item.update({"bonus_parsed": json.dumps(item['stat_parsed'])})

                if "img" in item:
                    item.update({"share_img": item["img"][3:]})

                item.update(getLike(likes, item['_id']))

            return items
コード例 #6
0
ファイル: misc.py プロジェクト: Ghloin/tweeria
		def getLastItems(last_count = 8):
			last_items = self.model.items.getLastApprovedItems(last_count)

			if self.cur_player:
				str_class = str(self.cur_player['login_class'])
			else:
				str_class = False

			authors_ids = Set()
			items_ids = Set()
			for item in last_items:
				authors_ids.add(item['author'])
				items_ids.add(item['_id'])
				item.update(prettyItemBonus(item, self.balance.stats_name))

				if item['type'] == 1 and str_class:
					if not item['view'] in self.sbuilder.balance.available_weapons[str_class]:
						item['cant_use'] = True

				item['img'] += '_fit.png'

			players_names = self.model.players.getPlayersList(authors_ids, ['_id', 'name'])
			item_likes = self.model.items.getItemsLikes(items_ids)

			for item in last_items:
				for player in players_names:
					if player['_id'] == item['author']:
						item['author_name'] = player['name']
						break

				for likes in item_likes:
					if likes['item_id'] == item['_id']:
						item['likes'] = len(likes['people'])
						is_like = False
						if self.cur_player:
							is_like = self.cur_player['login_id'] in likes['people']

						item['is_like'] = is_like
						break
				else:
					item['likes'] = 0

			return last_items
コード例 #7
0
	def printItemPage(self, fields, params):

		item = self.getItem(params)
		if 'error' in item:
			return self.sbuilder.throwWebError(item['error'], 'item')

		item.update(prettyItemBonus(item, self.balance.stats_name))

		author = self.model.players.getPlayerBy_ID(item['author'], {'name':1})
		if author:
			item.update({'author_name': author['name']})

		item['img'] = '/'+item['img']+'_fit.png'

		item['img_info'] = miscController.formatArtworkInfo(item['img_info'])

		fields.update(item)

		likes = self.model.items.getItemLikes(item['_id'])

		if 'reject' in item:
			try:
				rejecter = self.model.players.getPlayerBy_ID(item['reject']['rejecter_id'], {'name':1})
				fields.update({'reject_name': rejecter['name']})
			except Exception:
				fields.update({'reject_name': 'game'})

		if self.cur_player:
			fields.update({
				'inventory_count': self.model.items.getInventoryCount(self.cur_player['login_id']),
			    'inventory_max': self.sbuilder.balance.INVENTORY_SIZE
			})

		fields.update({
			self.title: item['name']+' page',
		    'likes': len(likes['people']),
		    'is_like': self.cur_player and self.cur_player['login_id'] in likes['people'],
		    'is_reported': self.cur_player and self.model.items.isReportItem(item['_id'], self.cur_player['login_id']),
		    'reasons': self.balance.getRejectReasons(self.balance.item_reject_reasons),
		    'categories': self.balance.categories
		})

		return basic.defaultController._printTemplate(self, 'item_page', fields)
コード例 #8
0
    def printCreationCenter(self, fields, params):

        fields.update({self.title: 'Creation center'})

        if not self.cur_player:
            return self.sbuilder.throwWebError(1002)

        items = self.model.items.getCraftedItems(self.cur_player['login_id'])
        spells = self.model.spells.getSpellsPattern(
            self.cur_player['login_id'])
        artworks = self.model.misc.getAllArtworksByPlayer(
            self.cur_player['login_id'])

        fields.update({
            'stat_names':
            self.balance.stats_name,
            'can_create':
            self.balance.MIN_LEVEL_TO_CREATE <= self.cur_player['login_lvl']
        })

        if self.core.debug['create_by_invite']:
            fields['can_create'] = self.cur_player and self.cur_player[
                'login_ugc_enabled']

        items += spells + artworks

        sell_statuses = {
            'sell': 'Selling',
            'not_sell': 'Not Selling',
            'waiting': 'Waiting',
            'rejected': 'Rejected'
        }

        for item in items:
            if 'reject' in item:
                status = 'rejected'

            elif item['approve'] and item['approve']['approved']:
                if item['sale_info']['active']:
                    status = 'sell'
                else:
                    status = 'not_sell'
            else:
                status = 'waiting'

            # Если заклинание, то ставим соответствующий тип
            if 'spell_actions' in item:
                item['view'] = 'Spell'
                item['img'] += '_fit.png'

            # если артворк
            elif 'faction' in item:
                item['img'] += '_fit.png'
                item['view'] = 'Artwork'
            # если предмет, то сделаем красивый вывод стат
            else:
                item['view'] = item['view'].title()
                item.update(prettyItemBonus(item, self.balance.stats_name))
                item['img'] = '/' + item['img'] + '_fit.png'

            item.update({
                'status': sell_statuses[status],
                'raw_status': status
            })

        fields.update({'items': items})

        return basic.defaultController._printTemplate(self, 'creation_center',
                                                      fields)
コード例 #9
0
ファイル: player.py プロジェクト: MHM5000/tweeria
        def getPlayerItems(player, fields):
            all_items = self.model.players.getPlayerHaveItems(player['_id'])
            items = {}
            wealth_items = []
            inventory = []
            ring1_exists = False

            if self.cur_player:
                str_class = str(self.cur_player['login_class'])
            else:
                str_class = False

            authors_ids = Set()
            for item in all_items:
                if "author" in item:
                    authors_ids.add(item['author'])

            players_names = self.model.players.getPlayersList(authors_ids, ['_id', 'name'])
            for item in all_items:
                item['type'] = int(item['type'])

                # после type 100 начинаются неигровые предметы
                # которые учитывать не нужно

                if item['type'] < 100:

                    if 'author' in item:
                        item.update({
                        'img': item['img'] + '_thumb.png',
                        'big_img': item['img'] + '_fit.png'
                        })
                    else:
                        item['img'] = '/data/items/' + item['img'] + '.jpg'

                    if item['equipped'] and item['type'] == 6:
                        if ring1_exists:
                            item['type'] = 66
                        else:
                            ring1_exists = True

                    if 'UID' in item and 'pooled_date' in item and item['img'][:2] != './':
                        item['img'] = '/data/items/' + item['img'][:-10] + '.jpg'

                    if 'UID' in item and not 'author' in item:
                        item_uid_str = str(int(item['UID']))
                        created_by_player = False
                    else:
                        item_uid_str = str(item['_id'])
                        item['color'] = 1
                        created_by_player = True

                    can_use_item = '0'
                    if self.cur_player and 'lvl_min' in item and int(item['lvl_min']) <= int(
                            self.cur_player['login_lvl']):
                        can_use_item = '1'

                    item.update(prettyItemBonus(item, self.balance.stats_name))

                    record = item
                    record.update({
                        'link': '/obj/1/' + item_uid_str + '/' + can_use_item,
                        'id': str(item['_id']),
                        'created_by_player': created_by_player,
                    })

                    if item['type'] == 1 and str_class:
                        if not item['view'] in self.sbuilder.balance.available_weapons[str_class]:
                            item['cant_use'] = True

                    if item['type'] == 1:
                        item['str_type'] = item['view']
                    else:
                        item['str_type'] = self.sbuilder.balance.item_types[item['type'] % 60]

                    for player in players_names:
                        if "author" in item and player['_id'] == item['author']:
                            item['author_name'] = player['name']

                    if item['equipped']:
                        items.update({'slot' + str(item['type']): record})

                    else:
                        inventory.append(record)

                # shop items
                else:
                    wealth_items.append(item)

            fields.update({
                'items': items,
                'inventory': inventory,
                'wealth': wealth_items
            })
コード例 #10
0
ファイル: shop.py プロジェクト: MicroWorldwide/tweeria
    def getPlayersItems(self,
                        params,
                        items_on_page=20,
                        search={},
                        sort={},
                        total_pages=0):
        if self.cur_player:
            str_class = str(self.cur_player['login_class'])
        else:
            str_class = False

        page = 1

        if 'pi' in params:
            try:
                page = int(params['pi'])
            except Exception:
                pass

        if page > total_pages:
            page = 1

        players_items = self.model.items.getAllSellingCraftedItems(
            limit=items_on_page,
            skip=(page - 1) * items_on_page,
            query=search,
            sort_query=sort)

        authors_ids = Set()
        items_ids = Set()

        for item in players_items:
            authors_ids.add(item['author'])
            items_ids.add(item['_id'])

        players_names = self.model.players.getPlayersList(
            authors_ids, ['_id', 'name'])
        item_likes = self.getLikesDict(items_ids)

        for item in players_items:

            if item['type'] == 1 and str_class:
                if not item['view'] in self.sbuilder.balance.available_weapons[
                        str_class]:
                    item['cant_use'] = True

            for player in players_names:
                if player['_id'] == item['author']:
                    item['author_name'] = player['name']
                    break

            item['img'] = '/' + item['img'] + '_fit.png'

            item.update(prettyItemBonus(item, self.balance.stats_name))
            if "stat_parsed" in item:
                item.update({"bonus_parsed": json.dumps(item['stat_parsed'])})

            if "img" in item:
                item.update({"share_img": item["img"][3:]})

            item.update(self.getLike(item_likes, item['_id']))
            item.update({'create_date_f': getReadbleTime(item['create_time'])})

        return players_items