def is_skill_active(_skill,player_on_cards): if player_on_cards: on_cards = player_on_cards.get_on_r_cards(_skill.card_type) if on_cards: on_card_list = on_cards.split(",") active_card_list = Skill.get_active_card_list(_skill) return _is_list_in(active_card_list,on_card_list) return False
def skill_list(request, cur_page=1, template="admin/skill/list.tpl"): skill_all_list = Skill.get_all() if skill_all_list: count = len(skill_all_list) if count > 0: page = int(cur_page) page_start = (page-1)*config.default_page_size page_end = page*config.default_page_size if page_end > (count-1): page_end = (count-1) skill_list = skill_all_list[page_start:page_end] p = Paginator(page, count, page_size=config.default_page_size) return render_response(template, request=request, skill_list=skill_list, p=p) return render_response(template, request=None, skill_list=None, p=None)
def _do_import(import_skill_list): # 先清空 Skill.clear() all_general_list = General.get_all() all_weapon_list = Weapon.get_all() all_shield_list = Shield.get_all() all_secretbook_list = SecretBook.get_all() all_treasure_list = Treasure.get_all() error = False line_number = 0 import_count = 0 for _skill in import_skill_list: line_number += 1 skill_card_type = _skill.card_type if skill_card_type == "G": _card_names = _skill.general_names.split(",") _general_ids = [] for _card_name in _card_names: if _card_name: _general_id = _card_name_exist(_card_name,all_general_list) if not _general_id: _general = General.get_by_name(_card_name) if not _general: print line_number,_card_name,"数据库不存在" error = True break else: _general_id = _general.id else: _general_ids.append(_general_id) if _general_ids: _skill.general_ids = _long_list_2_str(_general_ids) elif skill_card_type == "W": _general_name = _skill.general_names _card_name = _skill.card_names if _general_name: _general_id = _card_name_exist(_general_name,all_general_list) if not _general_id: _general = General.get_by_name(_general_name) if not _general: print line_number,_general_name,"数据库不存在" error = True break else: _general_id = _general.id else: _skill.general_ids = str(_general_id) if _card_name: _card_id = _card_name_exist(_card_name,all_weapon_list) if not _card_id: _card = Weapon.get_by_name(_card_name) if not _card: print line_number,_card_name,"数据库不存在" error = True break else: _card_id = _card.id else: _skill.card_ids = str(_card_id) elif skill_card_type == "S": _general_name = _skill.general_names _card_name = _skill.card_names if _general_name: _general_id = _card_name_exist(_general_name,all_general_list) if not _general_id: _general = General.get_by_name(_general_name) if not _general: print line_number,_general_name,"数据库不存在" error = True break else: _general_id = _general.id else: _skill.general_ids = str(_general_id) if _card_name: _card_id = _card_name_exist(_card_name,all_shield_list) if not _card_id: _card = Shield.get_by_name(_card_name) if not _card: print line_number,_card_name,"数据库不存在" error = True break else: _card_id = _card.id else: _skill.card_ids = str(_card_id) elif skill_card_type == "SB": _general_name = _skill.general_names _card_name = _skill.card_names if _general_name: _general_id = _card_name_exist(_general_name,all_general_list) if not _general_id: _general = General.get_by_name(_general_name) if not _general: print line_number,_general_name,"数据库不存在" error = True break else: _general_id = _general.id else: _skill.general_ids = str(_general_id) if _card_name: _card_id = _card_name_exist(_card_name,all_secretbook_list) if not _card_id: _card = SecretBook.get_by_name(_card_name) if not _card: print line_number,_card_name,"数据库不存在" error = True break else: _card_id = _card.id else: _skill.card_ids = str(_card_id) elif skill_card_type == "T": _general_name = _skill.general_names _card_name = _skill.card_names if _general_name: _general_id = _card_name_exist(_general_name,all_general_list) if not _general_id: _general = General.get_by_name(_general_name) if not _general: print line_number,_general_name,"数据库不存在" error = True break else: _general_id = _general.id else: _skill.general_ids = str(_general_id) if _card_name: _card_id = _card_name_exist(_card_name,all_treasure_list) if not _card_id: _card = Treasure.get_by_name(_card_name) if not _card: print line_number,_card_name,"数据库不存在" error = True break else: _card_id = _card.id else: _skill.card_ids = str(_card_id) if error: break _skill.save() import_count += 1 print "import_count=",import_count