def saveCardType(): print 'start save card type' ids = [6,3,10,8,4,5,9,7] names = [u'强化', u'英雄', u'英雄技能', u'物品', u'随从', u'法术', u'替代物', u'武器'] enUSS = [u'Enchantment', u'Hero', u'HeroPower', u'Item', u'Minion', u'Spell', u'Token', u'Weapon'] zhTWS = [u'附魔', u'英雄', u'英雄能力', u'物品', u'手下', u'法術', u'印記', u'武器'] for i in range(0,8): ct = CardType() ct.typeId = ids[i] ct.name = names[i] ct.enUS = enUSS[i] ct.zhTW = zhTWS[i] save(ct)
def create_CardType(supers, normal, subs): super_types = [] for x in supers: super_types.append(SuperType.objects.get_or_create(name=x)[0]) sub_types = [] for x in subs: sub_types.append(SubType.objects.get_or_create(name=x)[0]) normal_type = Type.objects.get_or_create(name=normal)[0] q = Q(type=normal_type) q = q and Q(super_types__name__in=supers) q = q and Q(sub_types__name__in=subs) r = CardType.objects.filter(q) if r.count(): return r[0] else: ct = CardType(type=normal_type) ct.save() ct.super_types = super_types ct.sub_types = sub_types ct.save() return ct
def saveCardType(): print 'start save card type' ids = [6, 3, 10, 8, 4, 5, 9, 7] names = [u'强化', u'英雄', u'英雄技能', u'物品', u'随从', u'法术', u'替代物', u'武器'] enUSS = [ u'Enchantment', u'Hero', u'HeroPower', u'Item', u'Minion', u'Spell', u'Token', u'Weapon' ] zhTWS = [u'附魔', u'英雄', u'英雄能力', u'物品', u'手下', u'法術', u'印記', u'武器'] for i in range(0, 8): ct = CardType() ct.typeId = ids[i] ct.name = names[i] ct.enUS = enUSS[i] ct.zhTW = zhTWS[i] save(ct)