OSDN Git Service

revise amulet search to consider of seed1 value,
[amulettoolsmh4/main.git] / model / skillplaceholder.py
1 # -*- coding: utf-8 -*-
2
3 # お守りのスキルの出現枠の位置とスキル
4 # 2013/12/18 written by kei9 
5
6 import db_supports
7
8 class SkillPlaceHolder(object):
9     u""" スキルの出現場所とスキルidを保持するクラス """
10     def __init__(self, place_ids, skill_id):
11         u""" place_ids: (0-6 's list) """
12         self._place_ids = place_ids
13         self._skill_id = skill_id
14
15     def get_skill1_where_or_sql(self, amulet_id, remove_where=False):
16         u""" 第1スキルのSQLのWhere文に変換する(OR結合) """
17         valid_eqls = []
18         for x in self._place_ids:
19             amu_col = db_supports.SEED1_TENUN_COL_AMULET_LIST[x]
20             skill_col = db_supports.SEED1_TENUN_COL_SKILL1_LIST[x]
21             valid_eqls.append(u"({amu_col}={amu_id} and {skill_col}={skill_id})".format(
22                 amu_col=amu_col,
23                 amu_id=amulet_id,
24                 skill_col=skill_col,
25                 skill_id=self._skill_id)) 
26
27         if len(valid_eqls) > 0:
28             if remove_where:
29                 return u" or ".join(valid_eqls)
30             else:
31                 return u" where " + u" or ".join(valid_eqls)
32         else:
33             return ""
34
35     def get_skill2_where_or_sql(self, remove_where=False):
36         u""" 第2スキルのSQLのWhere文に変換する(OR結合) """
37         valid_eqls = []
38         for x in self._place_ids:
39             col = db_supports.SEED2_SKILL2_COL_SKILL2_LIST[x]
40             valid_eqls.append(u"{col}={skill_id}".format(col=col,skill_id=self._skill_id)) 
41         if len(valid_eqls) > 0:
42             if remove_where:
43                 return u" or ".join(valid_eqls)
44             else:
45                 return u" where " + u" or ".join(valid_eqls)
46         else:
47             return ""