コード例 #1
0
ファイル: utils.py プロジェクト: yankyn/dom_api
def cards(request, dominion_fix):
    '''
    A fixture for creating example cards.
    '''
    if not Card.objects(name=COPPER): #@UndefinedVariable
        create_card(name=COPPER, cost=0, type=TREASURE, money=1)
    if not Card.objects(name=ESTATE): #@UndefinedVariable
        create_card(name=ESTATE, cost=2, type=VICTORY, victory=1)
コード例 #2
0
def cards(request, dominion_fix):
    '''
    A fixture for creating example cards.
    '''
    if not Card.objects(name=COPPER):  #@UndefinedVariable
        create_card(name=COPPER, cost=0, type=TREASURE, money=1)
    if not Card.objects(name=ESTATE):  #@UndefinedVariable
        create_card(name=ESTATE, cost=2, type=VICTORY, victory=1)
コード例 #3
0
ファイル: utils.py プロジェクト: yankyn/dom_api
def full_ruleset(request, cards, ruleset):
    '''
    A Fixture for creating rule_sets with content.
    '''
    ruleset.starting_deck = [Card.objects(name=COPPER)[0]] * 7 #@UndefinedVariable
    ruleset.starting_deck += [Card.objects(name=ESTATE)[0]] * 3 #@UndefinedVariable
    for value in request.param:
        srs = create_specific_rule_set(parent=ruleset, player_number=value)
    return ruleset
コード例 #4
0
def full_ruleset(request, cards, ruleset):
    '''
    A Fixture for creating rule_sets with content.
    '''
    ruleset.starting_deck = [Card.objects(name=COPPER)[0]
                             ] * 7  #@UndefinedVariable
    ruleset.starting_deck += [Card.objects(name=ESTATE)[0]
                              ] * 3  #@UndefinedVariable
    for value in request.param:
        srs = create_specific_rule_set(parent=ruleset, player_number=value)
    return ruleset
コード例 #5
0
ファイル: utils.py プロジェクト: yankyn/dom_api
def turn_card_dict_to_list(dictionary):
    '''
    Turns a dictionary of cards to numbers to a list of cards where each card's 
    number of instances is equal to its mapped value in the dictionary.
    '''
    cardlist = []
    for cardname in dictionary:
        card = Card.objects(name=cardname)[0] #@UndefinedVariable
        cardlist.extend([card] * dictionary[cardname])
    return cardlist
コード例 #6
0
def turn_card_dict_to_list(dictionary):
    '''
    Turns a dictionary of cards to numbers to a list of cards where each card's 
    number of instances is equal to its mapped value in the dictionary.
    '''
    cardlist = []
    for cardname in dictionary:
        card = Card.objects(name=cardname)[0]  #@UndefinedVariable
        cardlist.extend([card] * dictionary[cardname])
    return cardlist
コード例 #7
0
def create_card(name, cost, type, *args, **kwargs):
    '''
    Writes a card to the database.
    '''
    return Card(name=name, cost=cost, type=type, *args, **kwargs)