Пример #1
0
    def find_all(cls, available=None):
        query = session.query(cls)

        if available is not None:
            query = query.filter(cls.available == available)

        return query.all()
Пример #2
0
	def open(self):
		global all_players
		global decks
		global player_decks
		global decks_pointers
		global players_opponents
		print "WebSocket opened"
		self.id = uuid.uuid4()
		all_players[self.id] = self
		if len(decks) >= 1:
			decks.pop()
		cards = session.query(Cards).options(joinedload(Cards.card_aspects)).join(Sets).filter(Sets.set_code.in_(['DGM', 'GTC', 'RTR'])).all()
		card_data = self.map_card_data(cards)
		random.shuffle(card_data)
		decks.append(card_data[0:90])
		decks_pointers[self.id] = len(decks) - 1
		self.init_piles()
		player_decks[self.id] = []
		for key, value in player_decks.iteritems():
			player_decks[key] = []
		for key, value in all_players.iteritems():
			if self.id == key:
				pass
			else:
				players_opponents[self.id] = key
				players_opponents[key] = self.id
		if len(all_players) > 1:
			self.init_priority()
			self.update_priority()
		card_back = base64.b64encode(open("D:\\Users\\Roderick\\workspace\\magic_app\\magicimages\\Basics\\Back.full.jpg", "rb").read())
		self.write_message(json.dumps({"message_type": "card_back", "payload": card_back}), False)
Пример #3
0
def get_transactions():
    delivered = request.args.get('delivered', 'true') == 'true'
    query = session.query(Transaction)
    
    if delivered is not None:
        query = query.filter(Transaction.delivered == delivered)

    transactions = query.all()


    payload = [transaction.to_json() for transaction in transactions]

    return make_response(jsonify(payload), 200)
Пример #4
0
	if loyalty:
		aspect.loyalty = loyalty.getText()

	for card_type in card_data.find('typelist').findAll('type'):
		dbtype = CardTypes()
		dbtype.type_type = card_type['type']
		dbtype.type_name = card_type.getText()
		card_types.append(dbtype)

	aspect.card_types = card_types

	return [aspect]

soup = BeautifulSoup(open('../../../mtg-data/setinfo.xml').read())

blocks = dict([(row.block_name, row) for row in session.query(Blocks).all()])
sets = dict([(row.set_name, row) for row in session.query(Sets).all()])

for curr_set in soup.setlist.findAll('set'):
	block_name = curr_set.find('block')
	set_code = curr_set.find('code')
	set_name = curr_set.find('name')
	if not set_name:
		continue
	release_date = curr_set.find('release_date')
	dbset = Sets(set_name.getText())

	if dbset.set_name in sets:
		continue

	if(set_code):
Пример #5
0
# -*- coding: utf-8 -*-
import sys
import os

sys.path.append(os.path.abspath('../'))

from models.cards import CardAspects
from lib.db import session
import re

#Script to calculate and update all card aspect's
#converted mana costs

cards = session.query(CardAspects)

for card in cards:
	costs = str(card.mana_cost).split('}')
	cmc = 0
	costs.pop()
	# print costs
	for cost in costs:
		tmp_str = cost.translate(None, '{')
		if tmp_str == 'X':
			pass
		elif tmp_str.isdigit():
			cmc += int(tmp_str)
		else:
			cmc += 1

	card.converted_mana_cost = cmc
Пример #6
0
import sys
import os

sys.path.append(os.path.abspath("../"))

from bs4 import BeautifulSoup

from models.cards import Cards
from models.decks import Decks
from lib.db import session
import re

# loads a .deck format card deck into the database
# card deck format

session.query(Decks).delete()
session.commit()
cards = session.query(Cards)
cards_map = {}
for card in cards:
    if card.card_type == "double":
        cards_map[re.sub(u" // ", "_", card.full_name)] = card
    else:
        cards_map[re.sub(u"Æ", "AE", card.name)] = card

soup = BeautifulSoup(open("../../../mtg-data/tempcube.deck").read())

cards_list = soup.findAll("deck")[0].findAll("section")[0].findAll("item")

for card in cards_list:
    deck = Decks()