OSDN Git Service

rename database_ids & some variables in order to understand easily
authorkei9 <kei9@users.sourceforge.jp>
Sun, 8 Dec 2013 16:26:01 +0000 (01:26 +0900)
committerkei9 <kei9@users.sourceforge.jp>
Sun, 8 Dec 2013 16:26:01 +0000 (01:26 +0900)
amulettool.py
data.zip
model/amuletskillsholder.py
model/db_accessor.py
model/db_generator.py
model/db_supports.py
model/seedsholder.py [moved from model/randomseedsholder.py with 76% similarity]
model/sufficientsholder.py
view/constnumbers.py
view/mainframeview.py

index 565d39d..3f8d6a5 100644 (file)
@@ -16,7 +16,7 @@ import view
 import model
 
 SETTING_FILE = u"settings"
 import model
 
 SETTING_FILE = u"settings"
-SETTING_THRESHOLD = u"threshold"
+SETTING_THRESHOLD1 = u"threshold1"
 SETTING_SKILLS = u"skills"
 
 def _get_base_dir():
 SETTING_SKILLS = u"skills"
 
 def _get_base_dir():
@@ -151,28 +151,28 @@ class AmuletToolController(wx.App):
 
     def _set_skill_list_from_amulet(self, amulet_id):
         u""" お守り種類の選択が変わった時の動作 """
 
     def _set_skill_list_from_amulet(self, amulet_id):
         u""" お守り種類の選択が変わった時の動作 """
-        skill_selected = []
         for i, (combo, skill_dict) in enumerate(zip(
                 [self.frame_view.combo_box_amulet_search_skill1, 
                     self.frame_view.combo_box_amulet_search_skill2], 
                 [self._amulet_id2skill1_id_dict, self._amulet_id2skill2_id_dict]
                 )):
         for i, (combo, skill_dict) in enumerate(zip(
                 [self.frame_view.combo_box_amulet_search_skill1, 
                     self.frame_view.combo_box_amulet_search_skill2], 
                 [self._amulet_id2skill1_id_dict, self._amulet_id2skill2_id_dict]
                 )):
+            skill_ids = skill_dict[amulet_id]
             combo.Clear()
             if i == 1:
                 combo.Append(view.VAL_NO_SKILL)
             combo.Clear()
             if i == 1:
                 combo.Append(view.VAL_NO_SKILL)
-            skill_ids = skill_dict[amulet_id]
+            else:
+                skill1_selected = skill_ids[0]
             for skill_id in skill_ids:
                 combo.Append(self._skill_id2name_dict[skill_id])
             for skill_id in skill_ids:
                 combo.Append(self._skill_id2name_dict[skill_id])
-            skill_selected.append(skill_ids[i])
             combo.SetSelection(0)   # combo1 = skill1, combo2 = No Skill
             combo.SetSelection(0)   # combo1 = skill1, combo2 = No Skill
-        self._set_spin_range(amulet_id, skill_selected[0], skill_selected[1])
+        self._set_spin_range(amulet_id, skill1_selected, None)
 
     def _set_spin_views(self):
         u""" Spin Ctrlの最大最小をセット"""
         min1, max1, min2, max2 = self.db_accessor.get_skill_minmax()
         self.frame_view.spin_ctrl_amulet_search_slot_num.SetRange(view.SLOT_MIN, view.SLOT_MAX)
 
     def _set_spin_views(self):
         u""" Spin Ctrlの最大最小をセット"""
         min1, max1, min2, max2 = self.db_accessor.get_skill_minmax()
         self.frame_view.spin_ctrl_amulet_search_slot_num.SetRange(view.SLOT_MIN, view.SLOT_MAX)
-        self.frame_view.spin_ctrl_highlight.SetRange(view.THRESHOLD2_MIN, view.THRESHOLD2_MAX)
-        self.frame_view.spin_ctrl_highlight.SetValue(self._highlight_threshold)
+        self.frame_view.spin_ctrl_highlight.SetRange(view.THRESHOLD1_MIN, view.THRESHOLD1_MAX)
+        self.frame_view.spin_ctrl_highlight.SetValue(self._highlight_threshold1)
 
     def _set_check_list_views(self):
         u""" CheckListBoxの値のセット """
 
     def _set_check_list_views(self):
         u""" CheckListBoxの値のセット """
@@ -210,6 +210,7 @@ class AmuletToolController(wx.App):
         seed_sets = self.db_accessor.select_seeds(amu_id2skill_id_list_dict)
         self.frame_view.text_ctrl_seed_result.SetValue(u"""Seedの候補は{0}個です。""".format(len(seed_sets)))
 
         seed_sets = self.db_accessor.select_seeds(amu_id2skill_id_list_dict)
         self.frame_view.text_ctrl_seed_result.SetValue(u"""Seedの候補は{0}個です。""".format(len(seed_sets)))
 
+        self.frame_view.list_box_seed.Clear()
         if len(seed_sets) > 0:
             for seed in seed_sets:
                 self.frame_view.list_box_seed.Append(u"{0}".format(seed))
         if len(seed_sets) > 0:
             for seed in seed_sets:
                 self.frame_view.list_box_seed.Append(u"{0}".format(seed))
@@ -238,7 +239,7 @@ class AmuletToolController(wx.App):
         seed = self.frame_view.text_ctrl_seed_select.GetValue()
         if seed.isdigit():
             seed = int(seed)
         seed = self.frame_view.text_ctrl_seed_select.GetValue()
         if seed.isdigit():
             seed = int(seed)
-            skill_dict, threshold2_dict = self.db_accessor.select_skills_from_seeds([seed])
+            skill_dict, threshold1_dict = self.db_accessor.select_skills_from_seeds([seed])
 
             try:
                 text_ctrl_dict = self.frame_view.text_ctrl_seed_skill_dict
 
             try:
                 text_ctrl_dict = self.frame_view.text_ctrl_seed_skill_dict
@@ -247,8 +248,8 @@ class AmuletToolController(wx.App):
                     amu_id = self._amulet_name2id_dict[amu_name]
                     for txt_ctr, skill_id in zip(text_ctrl_dict[amu_key], skill_dict[amu_id][seed]):
                         txt_ctr.SetValue(self._skill_id2name_dict[skill_id])
                     amu_id = self._amulet_name2id_dict[amu_name]
                     for txt_ctr, skill_id in zip(text_ctrl_dict[amu_key], skill_dict[amu_id][seed]):
                         txt_ctr.SetValue(self._skill_id2name_dict[skill_id])
-                for txt_ctr, threshold2 in zip(text_ctrl_dict[view.KEY_THRESHOLD2], threshold2_dict[seed]):
-                    txt_ctr.SetValue(u"{0}".format(threshold2))
+                for txt_ctr, threshold1 in zip(text_ctrl_dict[view.KEY_THRESHOLD1], threshold1_dict[seed]):
+                    txt_ctr.SetValue(u"{0}".format(threshold1))
                 self._update_highlight()
 
             except KeyError, e:
                 self._update_highlight()
 
             except KeyError, e:
@@ -264,7 +265,7 @@ class AmuletToolController(wx.App):
             amu_id = self._amulet_name2id_dict[amu_name]
             for txt_ctr in text_ctrl_dict[amu_key]:
                 txt_ctr.Clear()
             amu_id = self._amulet_name2id_dict[amu_name]
             for txt_ctr in text_ctrl_dict[amu_key]:
                 txt_ctr.Clear()
-        for txt_ctr in text_ctrl_dict[view.KEY_THRESHOLD2]:
+        for txt_ctr in text_ctrl_dict[view.KEY_THRESHOLD1]:
             txt_ctr.Clear()
         self.frame_view.list_box_seed_skill_amulet_prospect.Clear() 
 
             txt_ctr.Clear()
         self.frame_view.list_box_seed_skill_amulet_prospect.Clear() 
 
@@ -300,7 +301,6 @@ class AmuletToolController(wx.App):
             raise IndexError(u"amulet id is unknown")
         self._set_spin_range(amu_id, skill1_id, skill2_id)
 
             raise IndexError(u"amulet id is unknown")
         self._set_spin_range(amu_id, skill1_id, skill2_id)
 
-
     def OnClickAmuletSearch(self, evt):
         u""" search seeds from amulet condition """
         skill1_name = self.frame_view.combo_box_amulet_search_skill1.GetStringSelection()
     def OnClickAmuletSearch(self, evt):
         u""" search seeds from amulet condition """
         skill1_name = self.frame_view.combo_box_amulet_search_skill1.GetStringSelection()
@@ -372,7 +372,7 @@ class AmuletToolController(wx.App):
 
     def OnClickSettingOK(self, evt):
         u""" get settings of setting tab """
 
     def OnClickSettingOK(self, evt):
         u""" get settings of setting tab """
-        self._highlight_threshold = self.frame_view.spin_ctrl_highlight.GetValue()
+        self._highlight_threshold1 = self.frame_view.spin_ctrl_highlight.GetValue()
         self._highlight_skills = set([self._skill_name2id_dict[x] for x in 
                 self.frame_view.check_list_box_highlight_skill.GetCheckedStrings()
                 if x in self._skill_name2id_dict])
         self._highlight_skills = set([self._skill_name2id_dict[x] for x in 
                 self.frame_view.check_list_box_highlight_skill.GetCheckedStrings()
                 if x in self._skill_name2id_dict])
@@ -380,8 +380,8 @@ class AmuletToolController(wx.App):
 
     def OnClickSettingClear(self, evt):
         u""" reset settings of setting tab """
 
     def OnClickSettingClear(self, evt):
         u""" reset settings of setting tab """
-        self._highlight_threshold = view.HIGHLIGHT_THRESHOLD
-        self.frame_view.spin_ctrl_highlight.SetValue(view.HIGHLIGHT_THRESHOLD)
+        self._highlight_threshold1 = view.HIGHLIGHT_THRESHOLD1
+        self.frame_view.spin_ctrl_highlight.SetValue(view.HIGHLIGHT_THRESHOLD1)
         self._highlight_skills = set()
         for idx in self.frame_view.check_list_box_highlight_skill.GetChecked():
             self.frame_view.check_list_box_highlight_skill.Check(idx, False)
         self._highlight_skills = set()
         for idx in self.frame_view.check_list_box_highlight_skill.GetChecked():
             self.frame_view.check_list_box_highlight_skill.Check(idx, False)
@@ -398,9 +398,9 @@ class AmuletToolController(wx.App):
                     text_ctrl.SetBackgroundColour("Yellow")
                 else:
                     text_ctrl.SetBackgroundColour(wx.NullColor)
                     text_ctrl.SetBackgroundColour("Yellow")
                 else:
                     text_ctrl.SetBackgroundColour(wx.NullColor)
-        for text_ctrl in text_dict[view.KEY_THRESHOLD2]:
+        for text_ctrl in text_dict[view.KEY_THRESHOLD1]:
             val = text_ctrl.GetValue()
             val = text_ctrl.GetValue()
-            if val.isdigit() and int(val) >= self._highlight_threshold:
+            if val.isdigit() and int(val) >= self._highlight_threshold1:
                 text_ctrl.SetBackgroundColour("Yellow")
             else:
                 text_ctrl.SetBackgroundColour(wx.NullColor)
                 text_ctrl.SetBackgroundColour("Yellow")
             else:
                 text_ctrl.SetBackgroundColour(wx.NullColor)
@@ -446,7 +446,7 @@ class AmuletToolController(wx.App):
 
     def _write_settings(self):
         with open(SETTING_FILE, mode="w") as f:
 
     def _write_settings(self):
         with open(SETTING_FILE, mode="w") as f:
-            data = {SETTING_THRESHOLD:self._highlight_threshold
+            data = {SETTING_THRESHOLD1:self._highlight_threshold1
                     SETTING_SKILLS:self._highlight_skills}
             pickle.dump(data, f)
 
                     SETTING_SKILLS:self._highlight_skills}
             pickle.dump(data, f)
 
@@ -455,13 +455,13 @@ class AmuletToolController(wx.App):
             with open(SETTING_FILE, mode="r") as f:
                 try:
                     data = pickle.load(f)
             with open(SETTING_FILE, mode="r") as f:
                 try:
                     data = pickle.load(f)
-                    self._highlight_threshold = data[SETTING_THRESHOLD
+                    self._highlight_threshold1 = data[SETTING_THRESHOLD1
                     self._highlight_skills = data[SETTING_SKILLS]
                 except EOFError, e:
                     self._highlight_skills = data[SETTING_SKILLS]
                 except EOFError, e:
-                    self._highlight_threshold = view.HIGHLIGHT_THRESHOLD
+                    self._highlight_threshold1 = view.HIGHLIGHT_THRESHOLD1
                     self._highlight_skills = set()
         else:
                     self._highlight_skills = set()
         else:
-            self._highlight_threshold = view.HIGHLIGHT_THRESHOLD
+            self._highlight_threshold1 = view.HIGHLIGHT_THRESHOLD1
             self._highlight_skills = set()
 
 if __name__ == "__main__":
             self._highlight_skills = set()
 
 if __name__ == "__main__":
index 252ac8a..04f799f 100644 (file)
Binary files a/data.zip and b/data.zip differ
index 355f5dc..a7effe8 100644 (file)
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 # お守りのスキル保持用クラス
 # -*- coding: utf-8 -*-
 
 # お守りのスキル保持用クラス
-# 2013/12/04 written by kei9 
+# 2013/12/09 written by kei9 
 
 import db_supports
 
 
 import db_supports
 
@@ -20,11 +20,11 @@ class AmuletSkillsHolder(object):
         else:
             return False
 
         else:
             return False
 
-    def get_where_sql(self, remove_where=False):
+    def get_where_and_sql(self, remove_where=False):
         u""" SQLのWhere文に変換する(AND結合) """
         if any([x is not None for x in self.skill_id_list]):
             valid_eqls = []
         u""" SQLのWhere文に変換する(AND結合) """
         if any([x is not None for x in self.skill_id_list]):
             valid_eqls = []
-            for col, skill_id in zip(db_supports.SECOND_COL_SKILL_LIST, self.skill_id_list):
+            for col, skill_id in zip(db_supports.SEED2_SKILL2_COL_SKILL2_LIST, self.skill_id_list):
                 if skill_id is not None:
                     valid_eqls.append(u"{col}={skill_id}".format(col=col,skill_id=skill_id)) 
             if remove_where:
                 if skill_id is not None:
                     valid_eqls.append(u"{col}={skill_id}".format(col=col,skill_id=skill_id)) 
             if remove_where:
index 97d77b5..50171e2 100644 (file)
@@ -8,7 +8,7 @@ import sys
 
 import db_supports
 from amuletskillsholder import AmuletSkillsHolder
 
 import db_supports
 from amuletskillsholder import AmuletSkillsHolder
-from randomseedsholder import RandomSeedsHolder
+from seedsholder import SeedsHolder
 from sufficientsholder import SufficientsHolder
 
 class DataBaseAccessor(object):
 from sufficientsholder import SufficientsHolder
 
 class DataBaseAccessor(object):
@@ -21,8 +21,8 @@ class DataBaseAccessor(object):
 
         self._skill_id2name_dict, self._skill_name2id_dict = self._get_skill_dict()
         (self._amulet_id2name_dict, self._amulet_name2id_dict, 
 
         self._skill_id2name_dict, self._skill_name2id_dict = self._get_skill_dict()
         (self._amulet_id2name_dict, self._amulet_name2id_dict, 
-            self._amulet_id2minmax_table_dict, self._amulet_id2second_table_dict,
-            self._amulet_id2suff_table_dict,
+            self._amulet_id2minmax_table_dict, self._amulet_id2skill2_table_dict,
+            self._amulet_id2sufficient_table_dict,
             self._amulet_id2skill1_id_dict, self._amulet_id2skill2_id_dict) = self._get_amulet_dict()
 
     def _print_dicts(self):
             self._amulet_id2skill1_id_dict, self._amulet_id2skill2_id_dict) = self._get_amulet_dict()
 
     def _print_dicts(self):
@@ -32,8 +32,8 @@ class DataBaseAccessor(object):
         print self._amulet_id2name_dict
         print self._amulet_name2id_dict
         print self._amulet_id2minmax_table_dict
         print self._amulet_id2name_dict
         print self._amulet_name2id_dict
         print self._amulet_id2minmax_table_dict
-        print self._amulet_id2second_table_dict
-        print self._amulet_id2suff_table_dict
+        print self._amulet_id2skill2_table_dict
+        print self._amulet_id2sufficient_table_dict
         print self._amulet_id2skill1_id_dict
         print self._amulet_id2skill2_id_dict
 
         print self._amulet_id2skill1_id_dict
         print self._amulet_id2skill2_id_dict
 
@@ -76,13 +76,13 @@ class DataBaseAccessor(object):
         return skill_id2name_dict, skill_name2id_dict
 
     def _get_amulet_dict(self):
         return skill_id2name_dict, skill_name2id_dict
 
     def _get_amulet_dict(self):
-        u""" create id2name, name2id, id2minmax_table, id2second_table, id2suff_table,
+        u""" create id2name, name2id, id2minmax_table, id2skill2_table, id2sufficient_table,
             id2skill1_ids, id2skill2_id dict of amulet 
         return (dict_id2name, dict_name2id, 
             id2skill1_ids, id2skill2_id dict of amulet 
         return (dict_id2name, dict_name2id, 
-            id2minmax_table, id2second_table, id2suff_table, id2skill1_ids, id2skill2_ids)
+            id2minmax_table, id2skill2_table, id2sufficient_table, id2skill1_ids, id2skill2_ids)
         """
         amulet_id2name_dict, amulet_name2id_dict = {}, {}
         """
         amulet_id2name_dict, amulet_name2id_dict = {}, {}
-        id2minmax_table, id2second_table, id2suff_table = {}, {}, {}
+        id2minmax_table, id2skill2_table, id2sufficient_table = {}, {}, {}
         id2skill1_ids, id2skill2_ids = {}, {}
         self._cursor.execute(db_supports.AMULET_TABLE_SELECT_ALL_SQL)
         for val in self._cursor.fetchall():
         id2skill1_ids, id2skill2_ids = {}, {}
         self._cursor.execute(db_supports.AMULET_TABLE_SELECT_ALL_SQL)
         for val in self._cursor.fetchall():
@@ -96,17 +96,17 @@ class DataBaseAccessor(object):
             amulet_id, table = val[0], val[1]
             id2minmax_table[amulet_id] = table
  
             amulet_id, table = val[0], val[1]
             id2minmax_table[amulet_id] = table
  
-        # id 2 second table name
-        self._cursor.execute(db_supports.SECOND_MASTER_TABLE_SELECT_ALL_SQL)
+        # id 2 skill2 table name
+        self._cursor.execute(db_supports.SEED2_SKILL2_MASTER_TABLE_SELECT_ALL_SQL)
         for val in self._cursor.fetchall():
             amulet_id, table = val[0], val[1]
         for val in self._cursor.fetchall():
             amulet_id, table = val[0], val[1]
-            id2second_table[amulet_id] = table
+            id2skill2_table[amulet_id] = table
 
         # id 2 sufficient table name
         self._cursor.execute(db_supports.SUFFICIENT_MASTER_TABLE_SELECT_ALL_SQL)
         for val in self._cursor.fetchall():
             amulet_id, table = val[0], val[1]
 
         # id 2 sufficient table name
         self._cursor.execute(db_supports.SUFFICIENT_MASTER_TABLE_SELECT_ALL_SQL)
         for val in self._cursor.fetchall():
             amulet_id, table = val[0], val[1]
-            id2suff_table[amulet_id] = table
+            id2sufficient_table[amulet_id] = table
 
         # id 2 non zero skill1 ids
         # id 2 non zero skill2 ids
 
         # id 2 non zero skill1 ids
         # id 2 non zero skill2 ids
@@ -123,7 +123,7 @@ class DataBaseAccessor(object):
             id2skill2_ids[amu_id] = tuple(ls)
 
         return (amulet_id2name_dict, amulet_name2id_dict, 
             id2skill2_ids[amu_id] = tuple(ls)
 
         return (amulet_id2name_dict, amulet_name2id_dict, 
-                id2minmax_table, id2second_table, id2suff_table,
+                id2minmax_table, id2skill2_table, id2sufficient_table,
                 id2skill1_ids, id2skill2_ids)
 
     def select_seeds(self, amu_id2skill_id_list_dict):
                 id2skill1_ids, id2skill2_ids)
 
     def select_seeds(self, amu_id2skill_id_list_dict):
@@ -132,14 +132,14 @@ class DataBaseAccessor(object):
         """
         seed_set = None
         for key, val in amu_id2skill_id_list_dict.items():
         """
         seed_set = None
         for key, val in amu_id2skill_id_list_dict.items():
-            if key in self._amulet_id2second_table_dict:
-                second_skill_table = self._amulet_id2second_table_dict[key]
+            if key in self._amulet_id2skill2_table_dict:
+                second_skill_table = self._amulet_id2skill2_table_dict[key]
                 amulet_skill = AmuletSkillsHolder(val)
 
                 if amulet_skill.is_empty():
                     continue
 
                 amulet_skill = AmuletSkillsHolder(val)
 
                 if amulet_skill.is_empty():
                     continue
 
-                sql = db_supports.SECOND_TABLE_SELECT_SEED_SQL.format(table_name=second_skill_table) + amulet_skill.get_where_sql()
+                sql = db_supports.SEED2_SKILL2_TABLE_SELECT_SEED_SQL.format(table_name=second_skill_table) + amulet_skill.get_where_and_sql()
                 self._cursor.execute(sql)
 
                 if seed_set is None:
                 self._cursor.execute(sql)
 
                 if seed_set is None:
@@ -157,25 +157,25 @@ class DataBaseAccessor(object):
         is skill2_id is None, search all skills
         """
         if amu_id in self._amulet_id2name_dict.keys():
         is skill2_id is None, search all skills
         """
         if amu_id in self._amulet_id2name_dict.keys():
-            table = self._amulet_id2suff_table_dict[amu_id]
-            sql = db_supports.SUFFICIENT_TABLE_SELECT_THRESHOLDS_SQL.format(
+            table = self._amulet_id2sufficient_table_dict[amu_id]
+            sql = db_supports.SUFFICIENT_TABLE_SELECT_THRESHOLD1_SQL.format(
                     table_name=table, sufficient_val=sufficient_val)
             self._cursor.execute(sql)
             try:
                     table_name=table, sufficient_val=sufficient_val)
             self._cursor.execute(sql)
             try:
-                threshold2 = self._cursor.fetchone()[slot_num-1]
+                threshold1 = self._cursor.fetchone()[slot_num-1]
             except TypeError, e:
             except TypeError, e:
-                threshold2 = None
+                threshold1 = None
 
 
-            if threshold2 is not None:
-                table = self._amulet_id2second_table_dict[amu_id]
+            if threshold1 is not None:
+                table = self._amulet_id2skill2_table_dict[amu_id]
                 if skill2_id is not None:
                 if skill2_id is not None:
-                    sql = db_supports.SECOND_SLOT_TABLE_SELECT_SEEDS_FROM_THRESHOLD_AND_SKILL2_SQL.format(
-                        threshold=threshold2,
+                    sql = db_supports.SEED2_THRESHOLD1_TABLE_SELECT_SEEDS_FROM_THRESHOLD1_AND_SKILL2_SQL.format(
+                        threshold1=threshold1,
                         skill_table=table,
                         skill_id=skill2_id)
                 else:
                         skill_table=table,
                         skill_id=skill2_id)
                 else:
-                    sql = db_supports.SECOND_SLOT_TABLE_SELECT_SEEDS_FROM_THRESHOLD_SQL.format(
-                        threshold=threshold2)
+                    sql = db_supports.SEED2_THRESHOLD1_TABLE_SELECT_SEEDS_FROM_THRESHOLD1_SQL.format(
+                        threshold1=threshold1)
                 self._cursor.execute(sql)
                 return set([x[0] for x in self._cursor.fetchall()])
             else:
                 self._cursor.execute(sql)
                 return set([x[0] for x in self._cursor.fetchall()])
             else:
@@ -198,11 +198,11 @@ class DataBaseAccessor(object):
                 result_dict[row[0]] = tuple(row[1:])
         return result_dict
 
                 result_dict[row[0]] = tuple(row[1:])
         return result_dict
 
-    def select_threshold_from_sufficient(self, amulet_id, sufficient_vals):
-        u""" お守りのidと充足値のリストから、充足値とスロットごとの判定値の辞書を得る
-            return dict({sufficient_val:(slot1_th, slot2_th, slot3_th)})
+    def select_threshold1_from_sufficient(self, amulet_id, sufficient_vals):
+        u""" お守りのidと充足値のリストから、充足値とスロットごとの判定値1の辞書を得る
+            return dict({sufficient_val:(slot1_th1, slot2_th1, slot3_th1)})
         """
         """
-        suff_table = self._amulet_id2suff_table_dict[amulet_id]
+        suff_table = self._amulet_idsufficient_table_dict[amulet_id]
         amulet_skill = SufficientsHolder(sufficient_vals)
         result_dict = {}
         if amulet_skill.is_empty() is False:
         amulet_skill = SufficientsHolder(sufficient_vals)
         result_dict = {}
         if amulet_skill.is_empty() is False:
@@ -214,30 +214,30 @@ class DataBaseAccessor(object):
         return result_dict
 
     def select_skills_from_seeds(self, seed_set):
         return result_dict
 
     def select_skills_from_seeds(self, seed_set):
-        u""" get amulet id to (random_seed to skill ids dict) dict,
-        and random_seed to slot value dict
-        return: skill_dict, slot_dict
+        u""" get amulet id to (random_seed2 to skill ids dict) dict,
+        and random_seed2 to threshold1 dict
+        return: skill_dict, threshold1_dict
         """
         """
-        skill_dict, slot_dict = {}, {}
+        skill_dict, threshold1_dict = {}, {}
 
         # skill dict
 
         # skill dict
-        seeds = RandomSeedsHolder(seed_set)
-        for amu_id, table in self._amulet_id2second_table_dict.items():
-            sql = db_supports.SECOND_TABLE_SELECT_ALL_SQL.format(
-                    table_name=table) + seeds.get_where_sql()
+        seeds = SeedsHolder(seed_set)
+        for amu_id, table in self._amulet_id2skill2_table_dict.items():
+            sql = db_supports.SEED2_SKILL2_TABLE_SELECT_ALL_SQL.format(
+                    table_name=table) + seeds.get_where_in_sql()
             self._cursor.execute(sql)
             seed2skills_dic = {}
             for row in self._cursor.fetchall():
                 seed2skills_dic[row[0]] = [x for x in row[1:]]
             skill_dict[amu_id] = seed2skills_dic
 
             self._cursor.execute(sql)
             seed2skills_dic = {}
             for row in self._cursor.fetchall():
                 seed2skills_dic[row[0]] = [x for x in row[1:]]
             skill_dict[amu_id] = seed2skills_dic
 
-        # slot dict
-        sql = db_supports.SECOND_SLOT_TABLE_SELECT_ALL_SQL + seeds.get_where_sql()
+        # threshold1 dict
+        sql = db_supports.SEED2_THRESHOLD1_TABLE_SELECT_ALL_SQL + seeds.get_where_in_sql()
         self._cursor.execute(sql)
         for row in self._cursor.fetchall():
         self._cursor.execute(sql)
         for row in self._cursor.fetchall():
-            slot_dict[row[0]] = [x for x in row[1:]]
+            threshold1_dict[row[0]] = [x for x in row[1:]]
 
 
-        return skill_dict, slot_dict
+        return skill_dict, threshold1_dict
 
     def get_sufficient_value(self, amu_id, skill1_id, skill2_id, skill1_val, skill2_val):
         u""" 充足値を計算する。
 
     def get_sufficient_value(self, amu_id, skill1_id, skill2_id, skill1_val, skill2_val):
         u""" 充足値を計算する。
index 3a41379..5558717 100644 (file)
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
 
 # databaseの生成用スクリプト
 # -*- coding: utf-8 -*-
 
 # databaseの生成用スクリプト
-# 2013/12/04 written by kei9 
+# 2013/12/09 written by kei9 
 
 import sqlite3
 import csv
 
 import sqlite3
 import csv
@@ -44,7 +44,8 @@ class DataBaseGenerator(object):
         # db generation
         self._create_skill_table()
         self._create_amulet_table()
         # db generation
         self._create_skill_table()
         self._create_amulet_table()
-        self._create_second_skill_table()
+        self._create_seed2_skill2_table()
+        self._create_seed2_threshold1_table()
         self._create_min_max_table()
         self._create_sufficient_value_table()
 
         self._create_min_max_table()
         self._create_sufficient_value_table()
 
@@ -218,9 +219,9 @@ class DataBaseGenerator(object):
 
                     file_minmax.close()
                 else:
 
                     file_minmax.close()
                 else:
-                    print "file2 ", fname, " doesn't exist!"
+                    print "file2 ", fname, " doesn't exist, all of the skill2 become zero"
             else:
             else:
-                print "file2 ", fname, " doesn't exist!"
+                print "file2 ", fname, " doesn't exist, all of the skill2 become zero"
 
             # insert to minmax table
             insert_sql = db_supports.MIN_MAX_TABLE_INSERT_SQL.format(table_name=table_name)
 
             # insert to minmax table
             insert_sql = db_supports.MIN_MAX_TABLE_INSERT_SQL.format(table_name=table_name)
@@ -232,22 +233,22 @@ class DataBaseGenerator(object):
         self._connect.commit()
         f.close()
 
         self._connect.commit()
         f.close()
 
-    def _create_second_skill_table(self):
-        u"""csvファイルから第2スキルの表を生成する
+    def _create_seed2_skill2_table(self):
+        u"""csvファイルからSEED2から第2スキルへの表を生成する
         """
         print "load Second skill"
         """
         print "load Second skill"
-        # create master table of Second skill
-        self._cursor.execute(db_supports.SECOND_MASTER_TABLE_CREATE_SQL)
+        # create master table of seed2 to skill2
+        self._cursor.execute(db_supports.SEED2_SKILL2_MASTER_TABLE_CREATE_SQL)
         # read from zip file with StringIO wrapper
         # read from zip file with StringIO wrapper
-        f = cStringIO.StringIO(self._zipfile.read(db_supports.SECOND_SKILL_FILE_NAME, "r"))
+        f = cStringIO.StringIO(self._zipfile.read(db_supports.SEED2_SKILL2_FILE_NAME, "r"))
         reader = csv.reader(f)  # (omamori_name, filename of Second_skill)
 
         reader.next()   # skip header row
         cnt = 0
         for row in reader:
         reader = csv.reader(f)  # (omamori_name, filename of Second_skill)
 
         reader.next()   # skip header row
         cnt = 0
         for row in reader:
-            table_name = db_supports.SECOND_TABLE_NAME.format(id=cnt)
-            create_sql = db_supports.SECOND_TABLE_CREATE_SQL.format(table_name=table_name)
-            insert_sql = db_supports.SECOND_MASTER_TABLE_INSERT_SQL
+            table_name = db_supports.SEED2_SKILL2_TABLE_NAME.format(id=cnt)
+            create_sql = db_supports.SEED2_SKILL2_TABLE_CREATE_SQL.format(table_name=table_name)
+            insert_sql = db_supports.SEED2_SKILL2_MASTER_TABLE_INSERT_SQL
             amu_id = self._get_amulet_id(row[0].strip())
             if amu_id is None:
                 print "amulet name:", row[0].decode("utf-8")
             amu_id = self._get_amulet_id(row[0].strip())
             if amu_id is None:
                 print "amulet name:", row[0].decode("utf-8")
@@ -258,10 +259,10 @@ class DataBaseGenerator(object):
             if fname_skill in self._zipfile.namelist(): 
                 # read from zip file with StringIO wrapper
                 file_skill = cStringIO.StringIO(self._zipfile.read(fname_skill, "r"))
             if fname_skill in self._zipfile.namelist(): 
                 # read from zip file with StringIO wrapper
                 file_skill = cStringIO.StringIO(self._zipfile.read(fname_skill, "r"))
-                reader_skill = csv.reader(file_skill)  # (random seed, skill1, skil2, ..., skill7)
+                reader_skill = csv.reader(file_skill)  # (seed2, skill1, skil2, ..., skill7)
 
                 reader_skill.next()  # skip header
 
                 reader_skill.next()  # skip header
-                insert_sql = db_supports.SECOND_TABLE_INSERT_SQL.format(table_name=table_name)
+                insert_sql = db_supports.SEED2_SKILL2_TABLE_INSERT_SQL.format(table_name=table_name)
                 for row1 in reader_skill:
                     seed = row1[0]
                     vals = [seed]
                 for row1 in reader_skill:
                     seed = row1[0]
                     vals = [seed]
@@ -278,15 +279,22 @@ class DataBaseGenerator(object):
 
             cnt += 1
         f.close()
 
             cnt += 1
         f.close()
+        self._connect.commit()
 
 
-        # for Slot table
-        self._cursor.execute(db_supports.SECOND_SLOT_TABLE_CREATE_SQL)    # create slot table of Second skill
+    def _create_seed2_threshold1_table(self):
+        u""" csvファイルよりSEED2から判定値1へのテーブルを作成する
+        """
+        print "load Threshold1"
+        # for threshold1 table
+        # create threshold1 table from seed2
+        self._cursor.execute(db_supports.SEED2_THRESHOLD1_TABLE_CREATE_SQL)    
+        
         # read from zip file with StringIO wrapper
         # read from zip file with StringIO wrapper
-        f = cStringIO.StringIO(self._zipfile.read(db_supports.SECOND_SLOT_FILE_NAME, "r"))
-        reader = csv.reader(f)  # (random_seed, slot1, slot2, ..., slot7)
+        f = cStringIO.StringIO(self._zipfile.read(db_supports.SEED2_THRESHOLD1_FILE_NAME, "r"))
+        reader = csv.reader(f)  # (seed2, threshold1_1, threshold1_2, ..., threshold1_7)
 
         reader.next()   # skip header row
 
         reader.next()   # skip header row
-        insert_sql = db_supports.SECOND_SLOT_TABLE_INSERT_SQL
+        insert_sql = db_supports.SEED2_THRESHOLD1_TABLE_INSERT_SQL
         for row in reader:
             val_tup = tuple([int(x.strip()) for x in row])
             self._cursor.execute(insert_sql, val_tup)
         for row in reader:
             val_tup = tuple([int(x.strip()) for x in row])
             self._cursor.execute(insert_sql, val_tup)
index ababf69..ffb37ce 100644 (file)
@@ -2,11 +2,9 @@
 
 # constant numbers of database
 # データベース関連の定数値など
 
 # constant numbers of database
 # データベース関連の定数値など
-# 2013/12/04 written by kei9 
+# 2013/12/09 written by kei9 
 
 # import modules
 
 # import modules
-import os.path
-import codecs
 
 # --- filenames ---
 ZIP_FILE = "data.zip"
 
 # --- filenames ---
 ZIP_FILE = "data.zip"
@@ -15,8 +13,8 @@ SKILL_FILE_NAME = "skill.csv"
 AMULET_FILE_NAME = "amulet.csv"
 MIN_MAX_FILE_NAME = "minmax.csv"
 SUFFICIENT_FILE_NAME = "sufficient.csv"
 AMULET_FILE_NAME = "amulet.csv"
 MIN_MAX_FILE_NAME = "minmax.csv"
 SUFFICIENT_FILE_NAME = "sufficient.csv"
-SECOND_SKILL_FILE_NAME = "2ndskill.csv"
-SECOND_SLOT_FILE_NAME = "2ndskill_slot.csv"
+SEED2_SKILL2_FILE_NAME = "seed2_skill2.csv"
+SEED2_THRESHOLD1_FILE_NAME = "seed2_threshold1.csv"
 
 # --- sql sentences of database ---
 # for skill table
 
 # --- sql sentences of database ---
 # for skill table
@@ -135,37 +133,29 @@ MIN_MAX_TABLE_SELECT_MAX2_OF_SKILL_SQL = u"""select max({col}) from {{table_name
     where skill_id={{skill_id}}""".format(
         col=MIN_MAX_COL_MAX2)
 
     where skill_id={{skill_id}}""".format(
         col=MIN_MAX_COL_MAX2)
 
-# for Second skill
-SECOND_MASTER_TABLE_NAME = u"skill_second_master"
-SECOND_TABLE_NAME = u"skill_second_{id}"
-SECOND_SLOT_TABLE_NAME = u"skill_second_slot"
-SECOND_COL_AMULET_ID = u"amulet_id"
-SECOND_COL_SECOND_TABLE_NAME = u"second_table_name"
-SECOND_COL_RANDOM_SEED = u"random_seed"
-SECOND_COL_SKILL_ID1 = u"skill_id1"
-SECOND_COL_SKILL_ID2 = u"skill_id2"
-SECOND_COL_SKILL_ID3 = u"skill_id3"
-SECOND_COL_SKILL_ID4 = u"skill_id4"
-SECOND_COL_SKILL_ID5 = u"skill_id5"
-SECOND_COL_SKILL_ID6 = u"skill_id6"
-SECOND_COL_SKILL_ID7 = u"skill_id7"
-SECOND_COL_SKILL_LIST = [SECOND_COL_SKILL_ID1, SECOND_COL_SKILL_ID2, SECOND_COL_SKILL_ID3, SECOND_COL_SKILL_ID4, SECOND_COL_SKILL_ID5, SECOND_COL_SKILL_ID6, SECOND_COL_SKILL_ID7]
-SECOND_COL_SLOT1 = u"slot1"
-SECOND_COL_SLOT2 = u"slot2"
-SECOND_COL_SLOT3 = u"slot3"
-SECOND_COL_SLOT4 = u"slot4"
-SECOND_COL_SLOT5 = u"slot5"
-SECOND_COL_SLOT6 = u"slot6"
-SECOND_COL_SLOT7 = u"slot7"
-SECOND_COL_SLOT_LIST = [SECOND_COL_SLOT1, SECOND_COL_SLOT2, SECOND_COL_SLOT3, SECOND_COL_SLOT4, SECOND_COL_SLOT5, SECOND_COL_SLOT6, SECOND_COL_SLOT7]
-SECOND_MASTER_TABLE_CREATE_SQL = u"""create table if not exists {master}
+# for Seed2 to skill2
+u""" SEED2から各お守りの第2スキルへのテーブル """
+SEED2_SKILL2_MASTER_TABLE_NAME = u"seed2_skill2_master"
+SEED2_SKILL2_TABLE_NAME = u"seed2_skill2_{id}"
+SEED2_SKILL2_COL_AMULET_ID = u"amulet_id"
+SEED2_SKILL2_COL_SEED2_SKILL2_TABLE_NAME = u"seed2_skill2_table_name"
+SEED2_SKILL2_COL_SEED2 = u"random_seed2"
+SEED2_SKILL2_COL_SKILL2_ID1 = u"skill2_id1"
+SEED2_SKILL2_COL_SKILL2_ID2 = u"skill2_id2"
+SEED2_SKILL2_COL_SKILL2_ID3 = u"skill2_id3"
+SEED2_SKILL2_COL_SKILL2_ID4 = u"skill2_id4"
+SEED2_SKILL2_COL_SKILL2_ID5 = u"skill2_id5"
+SEED2_SKILL2_COL_SKILL2_ID6 = u"skill2_id6"
+SEED2_SKILL2_COL_SKILL2_ID7 = u"skill2_id7"
+SEED2_SKILL2_COL_SKILL2_LIST = [SEED2_SKILL2_COL_SKILL2_ID1, SEED2_SKILL2_COL_SKILL2_ID2, SEED2_SKILL2_COL_SKILL2_ID3, SEED2_SKILL2_COL_SKILL2_ID4, SEED2_SKILL2_COL_SKILL2_ID5, SEED2_SKILL2_COL_SKILL2_ID6, SEED2_SKILL2_COL_SKILL2_ID7]
+SEED2_SKILL2_MASTER_TABLE_CREATE_SQL = u"""create table if not exists {master}
     (id integer primary key, {amulet_id} integer, {table_name} varchar,
     foreign key(amulet_id) references {amulet_table}(id));""".format(
     (id integer primary key, {amulet_id} integer, {table_name} varchar,
     foreign key(amulet_id) references {amulet_table}(id));""".format(
-        master=SECOND_MASTER_TABLE_NAME,
-        amulet_id=SECOND_COL_AMULET_ID,
+        master=SEED2_SKILL2_MASTER_TABLE_NAME,
+        amulet_id=SEED2_SKILL2_COL_AMULET_ID,
         amulet_table=AMULET_TABLE_NAME,
         amulet_table=AMULET_TABLE_NAME,
-        table_name=SECOND_COL_SECOND_TABLE_NAME)
-SECOND_TABLE_CREATE_SQL = u"""create table if not exists {{table_name}} 
+        table_name=SEED2_SKILL2_COL_SEED2_SKILL2_TABLE_NAME)
+SEED2_SKILL2_TABLE_CREATE_SQL = u"""create table if not exists {{table_name}} 
     (id integer primary key, {seed} integer unique, 
     {skill_id1} integer, {skill_id2} integer, {skill_id3} integer, 
     {skill_id4} integer, {skill_id5} integer, {skill_id6} integer, {skill_id7} integer, 
     (id integer primary key, {seed} integer unique, 
     {skill_id1} integer, {skill_id2} integer, {skill_id3} integer, 
     {skill_id4} integer, {skill_id5} integer, {skill_id6} integer, {skill_id7} integer, 
@@ -176,129 +166,145 @@ SECOND_TABLE_CREATE_SQL = u"""create table if not exists {{table_name}}
     foreign key({skill_id5}) references {skill_table}(id),
     foreign key({skill_id6}) references {skill_table}(id),
     foreign key({skill_id7}) references {skill_table}(id));""".format(
     foreign key({skill_id5}) references {skill_table}(id),
     foreign key({skill_id6}) references {skill_table}(id),
     foreign key({skill_id7}) references {skill_table}(id));""".format(
-        seed=SECOND_COL_RANDOM_SEED,
-        skill_id1=SECOND_COL_SKILL_ID1,
-        skill_id2=SECOND_COL_SKILL_ID2,
-        skill_id3=SECOND_COL_SKILL_ID3,
-        skill_id4=SECOND_COL_SKILL_ID4,
-        skill_id5=SECOND_COL_SKILL_ID5,
-        skill_id6=SECOND_COL_SKILL_ID6,
-        skill_id7=SECOND_COL_SKILL_ID7,
+        seed=SEED2_SKILL2_COL_SEED2,
+        skill_id1=SEED2_SKILL2_COL_SKILL2_ID1,
+        skill_id2=SEED2_SKILL2_COL_SKILL2_ID2,
+        skill_id3=SEED2_SKILL2_COL_SKILL2_ID3,
+        skill_id4=SEED2_SKILL2_COL_SKILL2_ID4,
+        skill_id5=SEED2_SKILL2_COL_SKILL2_ID5,
+        skill_id6=SEED2_SKILL2_COL_SKILL2_ID6,
+        skill_id7=SEED2_SKILL2_COL_SKILL2_ID7,
         skill_table=SKILL_TABLE_NAME)
         skill_table=SKILL_TABLE_NAME)
-SECOND_SLOT_TABLE_CREATE_SQL = u"""create table if not exists {table} 
-    (id integer primary key, {seed} integer unique,
-    {slot1} integer, {slot2} integer, {slot3} integer,
-    {slot4} integer, {slot5} integer, {slot6} integer, {slot7} integer);""".format(
-        table=SECOND_SLOT_TABLE_NAME,
-        seed=SECOND_COL_RANDOM_SEED,
-        slot1=SECOND_COL_SLOT1,
-        slot2=SECOND_COL_SLOT2,
-        slot3=SECOND_COL_SLOT3,
-        slot4=SECOND_COL_SLOT4,
-        slot5=SECOND_COL_SLOT5,
-        slot6=SECOND_COL_SLOT6,
-        slot7=SECOND_COL_SLOT7)
-SECOND_MASTER_TABLE_INSERT_SQL = u"""insert into {table}
+SEED2_SKILL2_MASTER_TABLE_INSERT_SQL = u"""insert into {table}
     ({amulet_col}, {table_col}) values(?,?);""".format(
     ({amulet_col}, {table_col}) values(?,?);""".format(
-        table=SECOND_MASTER_TABLE_NAME,
-        table_col=SECOND_COL_SECOND_TABLE_NAME,
-        amulet_col=SECOND_COL_AMULET_ID)
-SECOND_TABLE_INSERT_SQL = u"""insert into {{table_name}}
+        table=SEED2_SKILL2_MASTER_TABLE_NAME,
+        table_col=SEED2_SKILL2_COL_SEED2_SKILL2_TABLE_NAME,
+        amulet_col=SEED2_SKILL2_COL_AMULET_ID)
+SEED2_SKILL2_TABLE_INSERT_SQL = u"""insert into {{table_name}}
     ({seed}, {skill_id1}, {skill_id2}, {skill_id3}, 
     {skill_id4}, {skill_id5}, {skill_id6}, {skill_id7}) values(?,?,?,?,?,?,?,?)""".format(
     ({seed}, {skill_id1}, {skill_id2}, {skill_id3}, 
     {skill_id4}, {skill_id5}, {skill_id6}, {skill_id7}) values(?,?,?,?,?,?,?,?)""".format(
-        seed=SECOND_COL_RANDOM_SEED,
-        skill_id1=SECOND_COL_SKILL_ID1,
-        skill_id2=SECOND_COL_SKILL_ID2,
-        skill_id3=SECOND_COL_SKILL_ID3,
-        skill_id4=SECOND_COL_SKILL_ID4,
-        skill_id5=SECOND_COL_SKILL_ID5,
-        skill_id6=SECOND_COL_SKILL_ID6,
-        skill_id7=SECOND_COL_SKILL_ID7)
-SECOND_SLOT_TABLE_INSERT_SQL = u"""insert into {table}
-    ({seed}, {slot1}, {slot2}, {slot3}, {slot4}, {slot5}, {slot6}, {slot7})
-    values(?,?,?,?,?,?,?,?);""".format(
-        table=SECOND_SLOT_TABLE_NAME,
-        seed=SECOND_COL_RANDOM_SEED,
-        slot1=SECOND_COL_SLOT1,
-        slot2=SECOND_COL_SLOT2,
-        slot3=SECOND_COL_SLOT3,
-        slot4=SECOND_COL_SLOT4,
-        slot5=SECOND_COL_SLOT5,
-        slot6=SECOND_COL_SLOT6,
-        slot7=SECOND_COL_SLOT7)
-SECOND_MASTER_TABLE_SELECT_ALL_SQL = u"""select {amu_id}, {table_col} from {table}""".format(
-        amu_id=SECOND_COL_AMULET_ID,
-        table_col=SECOND_COL_SECOND_TABLE_NAME,
-        table=SECOND_MASTER_TABLE_NAME)
-SECOND_TABLE_SELECT_SEED_SQL = u"""select {seed} from {{table_name}} """.format(
-        seed=SECOND_COL_RANDOM_SEED)
-SECOND_TABLE_SELECT_ALL_SQL = u"""select {seed}, {skill_id1}, {skill_id2}, 
+        seed=SEED2_SKILL2_COL_SEED2,
+        skill_id1=SEED2_SKILL2_COL_SKILL2_ID1,
+        skill_id2=SEED2_SKILL2_COL_SKILL2_ID2,
+        skill_id3=SEED2_SKILL2_COL_SKILL2_ID3,
+        skill_id4=SEED2_SKILL2_COL_SKILL2_ID4,
+        skill_id5=SEED2_SKILL2_COL_SKILL2_ID5,
+        skill_id6=SEED2_SKILL2_COL_SKILL2_ID6,
+        skill_id7=SEED2_SKILL2_COL_SKILL2_ID7)
+SEED2_SKILL2_MASTER_TABLE_SELECT_ALL_SQL = u"""select {amu_id}, {table_col} from {table}""".format(
+        amu_id=SEED2_SKILL2_COL_AMULET_ID,
+        table_col=SEED2_SKILL2_COL_SEED2_SKILL2_TABLE_NAME,
+        table=SEED2_SKILL2_MASTER_TABLE_NAME)
+SEED2_SKILL2_TABLE_SELECT_SEED_SQL = u"""select {seed} from {{table_name}} """.format(
+        seed=SEED2_SKILL2_COL_SEED2)
+SEED2_SKILL2_TABLE_SELECT_ALL_SQL = u"""select {seed}, {skill_id1}, {skill_id2}, 
     {skill_id3}, {skill_id4}, {skill_id5}, {skill_id6}, {skill_id7} from {{table_name}} """.format(
     {skill_id3}, {skill_id4}, {skill_id5}, {skill_id6}, {skill_id7} from {{table_name}} """.format(
-        seed=SECOND_COL_RANDOM_SEED,
-        skill_id1=SECOND_COL_SKILL_ID1,
-        skill_id2=SECOND_COL_SKILL_ID2,
-        skill_id3=SECOND_COL_SKILL_ID3,
-        skill_id4=SECOND_COL_SKILL_ID4,
-        skill_id5=SECOND_COL_SKILL_ID5,
-        skill_id6=SECOND_COL_SKILL_ID6,
-        skill_id7=SECOND_COL_SKILL_ID7)
-SECOND_SLOT_TABLE_SELECT_ALL_SQL = u"""select {seed}, {slot1}, {slot2},
-    {slot3}, {slot4}, {slot5}, {slot6}, {slot7} from {table} """.format(
-        table=SECOND_SLOT_TABLE_NAME,
-        seed=SECOND_COL_RANDOM_SEED,
-        slot1=SECOND_COL_SLOT1,
-        slot2=SECOND_COL_SLOT2,
-        slot3=SECOND_COL_SLOT3,
-        slot4=SECOND_COL_SLOT4,
-        slot5=SECOND_COL_SLOT5,
-        slot6=SECOND_COL_SLOT6,
-        slot7=SECOND_COL_SLOT7)
-SECOND_SLOT_TABLE_SELECT_SEEDS_FROM_THRESHOLD_AND_SKILL2_SQL = u"""
-    select {slot_table}.{seed} from {slot_table} 
-    inner join {{skill_table}} on {slot_table}.{seed} = {{skill_table}}.{seed}
-    where ({{skill_table}}.{skill_id1} == {{skill_id}} and {slot_table}.{slot1} >= {{threshold}}) or 
-    ({{skill_table}}.{skill_id2} == {{skill_id}} and {slot_table}.{slot2} >= {{threshold}}) or 
-    ({{skill_table}}.{skill_id3} == {{skill_id}} and {slot_table}.{slot3} >= {{threshold}}) or 
-    ({{skill_table}}.{skill_id4} == {{skill_id}} and {slot_table}.{slot4} >= {{threshold}}) or 
-    ({{skill_table}}.{skill_id5} == {{skill_id}} and {slot_table}.{slot5} >= {{threshold}}) or 
-    ({{skill_table}}.{skill_id6} == {{skill_id}} and {slot_table}.{slot6} >= {{threshold}}) or 
-    ({{skill_table}}.{skill_id7} == {{skill_id}} and {slot_table}.{slot7} >= {{threshold}})
+        seed=SEED2_SKILL2_COL_SEED2,
+        skill_id1=SEED2_SKILL2_COL_SKILL2_ID1,
+        skill_id2=SEED2_SKILL2_COL_SKILL2_ID2,
+        skill_id3=SEED2_SKILL2_COL_SKILL2_ID3,
+        skill_id4=SEED2_SKILL2_COL_SKILL2_ID4,
+        skill_id5=SEED2_SKILL2_COL_SKILL2_ID5,
+        skill_id6=SEED2_SKILL2_COL_SKILL2_ID6,
+        skill_id7=SEED2_SKILL2_COL_SKILL2_ID7)
+
+# for seed2 to threshold1
+u""" SEED2から判定値1へのテーブル """
+SEED2_THRESHOLD1_TABLE_NAME = u"seed2_threshold1"
+SEED2_THRESHOLD1_COL_SEED2 = u"random_seed2"
+SEED2_THRESHOLD1_COL_THRESHOLD1_1 = u"threshold1_1"
+SEED2_THRESHOLD1_COL_THRESHOLD1_2 = u"threshold1_2"
+SEED2_THRESHOLD1_COL_THRESHOLD1_3 = u"threshold1_3"
+SEED2_THRESHOLD1_COL_THRESHOLD1_4 = u"threshold1_4"
+SEED2_THRESHOLD1_COL_THRESHOLD1_5 = u"threshold1_5"
+SEED2_THRESHOLD1_COL_THRESHOLD1_6 = u"threshold1_6"
+SEED2_THRESHOLD1_COL_THRESHOLD1_7 = u"threshold1_7"
+SEED2_THRESHOLD1_COL_THRESHOLD1_LIST = [SEED2_THRESHOLD1_COL_THRESHOLD1_1, SEED2_THRESHOLD1_COL_THRESHOLD1_2, SEED2_THRESHOLD1_COL_THRESHOLD1_3, SEED2_THRESHOLD1_COL_THRESHOLD1_4, SEED2_THRESHOLD1_COL_THRESHOLD1_5, SEED2_THRESHOLD1_COL_THRESHOLD1_6, SEED2_THRESHOLD1_COL_THRESHOLD1_7]
+SEED2_THRESHOLD1_TABLE_CREATE_SQL = u"""create table if not exists {table} 
+    (id integer primary key, {seed} integer unique,
+    {threshold1_1} integer, {threshold1_2} integer, {threshold1_3} integer,
+    {threshold1_4} integer, {threshold1_5} integer, {threshold1_6} integer, {threshold1_7} integer);""".format(
+        table=SEED2_THRESHOLD1_TABLE_NAME,
+        seed=SEED2_THRESHOLD1_COL_SEED2,
+        threshold1_1=SEED2_THRESHOLD1_COL_THRESHOLD1_1,
+        threshold1_2=SEED2_THRESHOLD1_COL_THRESHOLD1_2,
+        threshold1_3=SEED2_THRESHOLD1_COL_THRESHOLD1_3,
+        threshold1_4=SEED2_THRESHOLD1_COL_THRESHOLD1_4,
+        threshold1_5=SEED2_THRESHOLD1_COL_THRESHOLD1_5,
+        threshold1_6=SEED2_THRESHOLD1_COL_THRESHOLD1_6,
+        threshold1_7=SEED2_THRESHOLD1_COL_THRESHOLD1_7)
+SEED2_THRESHOLD1_TABLE_INSERT_SQL = u"""insert into {table}
+    ({seed}, {threshold1_1}, {threshold1_2}, {threshold1_3}, {threshold1_4}, {threshold1_5}, {threshold1_6}, {threshold1_7})
+    values(?,?,?,?,?,?,?,?);""".format(
+        table=SEED2_THRESHOLD1_TABLE_NAME,
+        seed=SEED2_THRESHOLD1_COL_SEED2,
+        threshold1_1=SEED2_THRESHOLD1_COL_THRESHOLD1_1,
+        threshold1_2=SEED2_THRESHOLD1_COL_THRESHOLD1_2,
+        threshold1_3=SEED2_THRESHOLD1_COL_THRESHOLD1_3,
+        threshold1_4=SEED2_THRESHOLD1_COL_THRESHOLD1_4,
+        threshold1_5=SEED2_THRESHOLD1_COL_THRESHOLD1_5,
+        threshold1_6=SEED2_THRESHOLD1_COL_THRESHOLD1_6,
+        threshold1_7=SEED2_THRESHOLD1_COL_THRESHOLD1_7)
+SEED2_THRESHOLD1_TABLE_SELECT_ALL_SQL = u"""select {seed}, {threshold1_1}, {threshold1_2},
+    {threshold1_3}, {threshold1_4}, {threshold1_5}, {threshold1_6}, {threshold1_7} from {table} """.format(
+        table=SEED2_THRESHOLD1_TABLE_NAME,
+        seed=SEED2_THRESHOLD1_COL_SEED2,
+        threshold1_1=SEED2_THRESHOLD1_COL_THRESHOLD1_1,
+        threshold1_2=SEED2_THRESHOLD1_COL_THRESHOLD1_2,
+        threshold1_3=SEED2_THRESHOLD1_COL_THRESHOLD1_3,
+        threshold1_4=SEED2_THRESHOLD1_COL_THRESHOLD1_4,
+        threshold1_5=SEED2_THRESHOLD1_COL_THRESHOLD1_5,
+        threshold1_6=SEED2_THRESHOLD1_COL_THRESHOLD1_6,
+        threshold1_7=SEED2_THRESHOLD1_COL_THRESHOLD1_7)
+SEED2_THRESHOLD1_TABLE_SELECT_SEEDS_FROM_THRESHOLD1_SQL = u"""
+    select {seed} from {threshold1_table} 
+    where {threshold1_1} >= {{threshold1}} or 
+    {threshold1_2} >= {{threshold1}} or 
+    {threshold1_3} >= {{threshold1}} or 
+    {threshold1_4} >= {{threshold1}} or 
+    {threshold1_5} >= {{threshold1}} or 
+    {threshold1_6} >= {{threshold1}} or 
+    {threshold1_7} >= {{threshold1}}
     """.format(
     """.format(
-        slot_table=SECOND_SLOT_TABLE_NAME,
-        seed=SECOND_COL_RANDOM_SEED,
-        skill_id1=SECOND_COL_SKILL_ID1,
-        skill_id2=SECOND_COL_SKILL_ID2,
-        skill_id3=SECOND_COL_SKILL_ID3,
-        skill_id4=SECOND_COL_SKILL_ID4,
-        skill_id5=SECOND_COL_SKILL_ID5,
-        skill_id6=SECOND_COL_SKILL_ID6,
-        skill_id7=SECOND_COL_SKILL_ID7,
-        slot1=SECOND_COL_SLOT1,
-        slot2=SECOND_COL_SLOT2,
-        slot3=SECOND_COL_SLOT3,
-        slot4=SECOND_COL_SLOT4,
-        slot5=SECOND_COL_SLOT5,
-        slot6=SECOND_COL_SLOT6,
-        slot7=SECOND_COL_SLOT7)
-SECOND_SLOT_TABLE_SELECT_SEEDS_FROM_THRESHOLD_SQL = u"""
-    select {seed} from {slot_table} 
-    where {slot1} >= {{threshold}} or 
-    {slot2} >= {{threshold}} or 
-    {slot3} >= {{threshold}} or 
-    {slot4} >= {{threshold}} or 
-    {slot5} >= {{threshold}} or 
-    {slot6} >= {{threshold}} or 
-    {slot7} >= {{threshold}}
+        threshold1_table=SEED2_THRESHOLD1_TABLE_NAME,
+        seed=SEED2_THRESHOLD1_COL_SEED2,
+        threshold1_1=SEED2_THRESHOLD1_COL_THRESHOLD1_1,
+        threshold1_2=SEED2_THRESHOLD1_COL_THRESHOLD1_2,
+        threshold1_3=SEED2_THRESHOLD1_COL_THRESHOLD1_3,
+        threshold1_4=SEED2_THRESHOLD1_COL_THRESHOLD1_4,
+        threshold1_5=SEED2_THRESHOLD1_COL_THRESHOLD1_5,
+        threshold1_6=SEED2_THRESHOLD1_COL_THRESHOLD1_6,
+        threshold1_7=SEED2_THRESHOLD1_COL_THRESHOLD1_7)
+
+
+# inner join of seed2 -> skill2 & tthreshol1
+SEED2_THRESHOLD1_TABLE_SELECT_SEEDS_FROM_THRESHOLD1_AND_SKILL2_SQL = u"""
+    select {threshold1_table}.{seed} from {threshold1_table} 
+    inner join {{skill_table}} on {threshold1_table}.{seed} = {{skill_table}}.{seed}
+    where ({{skill_table}}.{skill_id1} == {{skill_id}} and {threshold1_table}.{threshold1_1} >= {{threshold1}}) or 
+    ({{skill_table}}.{skill_id2} == {{skill_id}} and {threshold1_table}.{threshold1_2} >= {{threshold1}}) or 
+    ({{skill_table}}.{skill_id3} == {{skill_id}} and {threshold1_table}.{threshold1_3} >= {{threshold1}}) or 
+    ({{skill_table}}.{skill_id4} == {{skill_id}} and {threshold1_table}.{threshold1_4} >= {{threshold1}}) or 
+    ({{skill_table}}.{skill_id5} == {{skill_id}} and {threshold1_table}.{threshold1_5} >= {{threshold1}}) or 
+    ({{skill_table}}.{skill_id6} == {{skill_id}} and {threshold1_table}.{threshold1_6} >= {{threshold1}}) or 
+    ({{skill_table}}.{skill_id7} == {{skill_id}} and {threshold1_table}.{threshold1_7} >= {{threshold1}})
     """.format(
     """.format(
-        slot_table=SECOND_SLOT_TABLE_NAME,
-        seed=SECOND_COL_RANDOM_SEED,
-        slot1=SECOND_COL_SLOT1,
-        slot2=SECOND_COL_SLOT2,
-        slot3=SECOND_COL_SLOT3,
-        slot4=SECOND_COL_SLOT4,
-        slot5=SECOND_COL_SLOT5,
-        slot6=SECOND_COL_SLOT6,
-        slot7=SECOND_COL_SLOT7)
+        threshold1_table=SEED2_THRESHOLD1_TABLE_NAME,
+        seed=SEED2_THRESHOLD1_COL_SEED2,
+        skill_id1=SEED2_SKILL2_COL_SKILL2_ID1,
+        skill_id2=SEED2_SKILL2_COL_SKILL2_ID2,
+        skill_id3=SEED2_SKILL2_COL_SKILL2_ID3,
+        skill_id4=SEED2_SKILL2_COL_SKILL2_ID4,
+        skill_id5=SEED2_SKILL2_COL_SKILL2_ID5,
+        skill_id6=SEED2_SKILL2_COL_SKILL2_ID6,
+        skill_id7=SEED2_SKILL2_COL_SKILL2_ID7,
+        threshold1_1=SEED2_THRESHOLD1_COL_THRESHOLD1_1,
+        threshold1_2=SEED2_THRESHOLD1_COL_THRESHOLD1_2,
+        threshold1_3=SEED2_THRESHOLD1_COL_THRESHOLD1_3,
+        threshold1_4=SEED2_THRESHOLD1_COL_THRESHOLD1_4,
+        threshold1_5=SEED2_THRESHOLD1_COL_THRESHOLD1_5,
+        threshold1_6=SEED2_THRESHOLD1_COL_THRESHOLD1_6,
+        threshold1_7=SEED2_THRESHOLD1_COL_THRESHOLD1_7)
 
 # for sufficient value for slots
 SUFFICIENT_MASTER_TABLE_NAME = u"sufficient_master"
 
 # for sufficient value for slots
 SUFFICIENT_MASTER_TABLE_NAME = u"sufficient_master"
@@ -344,7 +350,7 @@ SUFFICIENT_TABLE_SELECT_ALL_SQL = u"""select {sufficient_val}, {slot1_val}, {slo
         slot1_val=SUFFICIENT_COL_SLOT1_THRESHOLD,
         slot2_val=SUFFICIENT_COL_SLOT2_THRESHOLD,
         slot3_val=SUFFICIENT_COL_SLOT3_THRESHOLD)
         slot1_val=SUFFICIENT_COL_SLOT1_THRESHOLD,
         slot2_val=SUFFICIENT_COL_SLOT2_THRESHOLD,
         slot3_val=SUFFICIENT_COL_SLOT3_THRESHOLD)
-SUFFICIENT_TABLE_SELECT_THRESHOLDS_SQL = u"""select {slot1_val}, {slot2_val}, {slot3_val} from {{table_name}}
+SUFFICIENT_TABLE_SELECT_THRESHOLD1_SQL = u"""select {slot1_val}, {slot2_val}, {slot3_val} from {{table_name}}
     where {sufficient_val}={{sufficient_val}}""".format(
         sufficient_val=SUFFICIENT_COL_SUFFICIENT_VALUE,
         slot1_val=SUFFICIENT_COL_SLOT1_THRESHOLD,
     where {sufficient_val}={{sufficient_val}}""".format(
         sufficient_val=SUFFICIENT_COL_SUFFICIENT_VALUE,
         slot1_val=SUFFICIENT_COL_SLOT1_THRESHOLD,
similarity index 76%
rename from model/randomseedsholder.py
rename to model/seedsholder.py
index 54be9e5..6456045 100644 (file)
@@ -5,19 +5,19 @@
 
 import db_supports
 
 
 import db_supports
 
-class RandomSeedsHolder(object):
-    u""" ランダムのSeed値を保持するクラス """
+class SeedsHolder(object):
+    u""" Seed値を保持するクラス """
     def __init__(self, seed_list):
         u""" seed_list: list of seed
         """
         self.seed_set = set(seed_list)
 
     def __init__(self, seed_list):
         u""" seed_list: list of seed
         """
         self.seed_set = set(seed_list)
 
-    def get_where_sql(self, remove_where=False):
+    def get_where_in_sql(self, remove_where=False):
         u""" SQLのWhere文に変換する(IN句) """
         if len(self.seed_set) >= 1:
             uni_list = [u"{0}".format(x) for x in self.seed_set]
             sql = u" {col} IN({in_phrase})".format(
         u""" SQLのWhere文に変換する(IN句) """
         if len(self.seed_set) >= 1:
             uni_list = [u"{0}".format(x) for x in self.seed_set]
             sql = u" {col} IN({in_phrase})".format(
-                    col=db_supports.SECOND_COL_RANDOM_SEED,
+                    col=db_supports.SEED2_SKILL2_COL_SEED2,
                     in_phrase=u",".join(uni_list))
 
             if remove_where:
                     in_phrase=u",".join(uni_list))
 
             if remove_where:
index c665894..ff1c83d 100644 (file)
@@ -1,18 +1,18 @@
 # -*- coding: utf-8 -*-
 
 # sufficient valueを保持するクラス
 # -*- coding: utf-8 -*-
 
 # sufficient valueを保持するクラス
-# 2013/12/04 written by kei9 
+# 2013/12/08 written by kei9 
 
 import db_supports
 
 class SufficientsHolder(object):
 
 import db_supports
 
 class SufficientsHolder(object):
-    u""" ランダムのSeed値を保持するクラス """
+    u""" 充足値を保持するクラス """
     def __init__(self, sufficient_list):
         u""" sufficient_list: list of sufficient
         """
         self.sufficient_set = set(sufficient_list)
 
     def __init__(self, sufficient_list):
         u""" sufficient_list: list of sufficient
         """
         self.sufficient_set = set(sufficient_list)
 
-    def get_where_sql(self, remove_where=False):
+    def get_where_in_sql(self, remove_where=False):
         u""" SQLのWhere文に変換する(IN句) """
         if len(self.sufficient_set) >= 1:
             uni_list = [u"{0}".format(x) for x in self.sufficient_set]
         u""" SQLのWhere文に変換する(IN句) """
         if len(self.sufficient_set) >= 1:
             uni_list = [u"{0}".format(x) for x in self.sufficient_set]
index fad5312..5bc4c33 100644 (file)
@@ -7,10 +7,11 @@
 NAME_AMULET1 = u"光るお守り"
 NAME_AMULET2 = u"古びたお守り"
 NAME_AMULET3 = u"歪んだお守り"
 NAME_AMULET1 = u"光るお守り"
 NAME_AMULET2 = u"古びたお守り"
 NAME_AMULET3 = u"歪んだお守り"
+NAME_THRESHOLD1 = u"判定値1"
 KEY_AMULET1 = u"amulet1"
 KEY_AMULET2 = u"amulet2"
 KEY_AMULET3 = u"amulet3"
 KEY_AMULET1 = u"amulet1"
 KEY_AMULET2 = u"amulet2"
 KEY_AMULET3 = u"amulet3"
-KEY_THRESHOLD2 = u"threshold2"
+KEY_THRESHOLD1 = u"threshold1"
 
 VAL_NO_SKILL = u"なし"
 
 
 VAL_NO_SKILL = u"なし"
 
@@ -20,9 +21,9 @@ SKILL_SEARCH_PAGE = 1
 SLOT_MIN = 1
 SLOT_MAX = 3
 
 SLOT_MIN = 1
 SLOT_MAX = 3
 
-HIGHLIGHT_THRESHOLD = 90
-THRESHOLD2_MIN = 0
-THRESHOLD2_MAX = 100
+HIGHLIGHT_THRESHOLD1 = 90
+THRESHOLD1_MIN = 0
+THRESHOLD1_MAX = 100
 
 # xrc file
 XRC_GAUGE_DIALOG = u"gaugedialog.xrc"
 
 # xrc file
 XRC_GAUGE_DIALOG = u"gaugedialog.xrc"
index a90011c..9854315 100644 (file)
@@ -83,7 +83,7 @@ class MainFrameView():
         self.spin_ctrl_amulet_search_slot_num = xrc.XRCCTRL(self.frame, "SpinCtrlAmuletSearchSlotNumber")
         self.ID_SPIN_CTRL_AMULET_SKILL1_VAL = xrc.XRCID("SpinCtrlAmuletSearchSkill1Value")
         self.ID_SPIN_CTRL_AMULET_SKILL2_VAL = xrc.XRCID("SpinCtrlAmuletSearchSkill2Value")
         self.spin_ctrl_amulet_search_slot_num = xrc.XRCCTRL(self.frame, "SpinCtrlAmuletSearchSlotNumber")
         self.ID_SPIN_CTRL_AMULET_SKILL1_VAL = xrc.XRCID("SpinCtrlAmuletSearchSkill1Value")
         self.ID_SPIN_CTRL_AMULET_SKILL2_VAL = xrc.XRCID("SpinCtrlAmuletSearchSkill2Value")
-        self.spin_ctrl_highlight = xrc.XRCCTRL(self.frame, "SpinCtrlHighlightThreshold")
+        self.spin_ctrl_highlight = xrc.XRCCTRL(self.frame, "SpinCtrlHighlightThreshold1")
 
         # load custom ctrl
         panel = xrc.XRCCTRL(self.frame, "CheckListBoxPos")
 
         # load custom ctrl
         panel = xrc.XRCCTRL(self.frame, "CheckListBoxPos")
@@ -168,14 +168,14 @@ class MainFrameView():
                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_5"),
                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_6"),
                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_7")]
                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_5"),
                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_6"),
                 xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillAmulet3_7")]
-        self.text_ctrl_seed_skill_dict[constnumbers.KEY_THRESHOLD2] = [
-                xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_1"),
-                xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_2"),
-                xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_3"),
-                xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_4"),
-                xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_5"),
-                xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_6"),
-                xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold2_7")]
+        self.text_ctrl_seed_skill_dict[constnumbers.KEY_THRESHOLD1] = [
+                xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold1_1"),
+                xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold1_2"),
+                xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold1_3"),
+                xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold1_4"),
+                xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold1_5"),
+                xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold1_6"),
+                xrc.XRCCTRL(self.frame, "TextCtrlSeedSkillThreshold1_7")]
 
     def Show(self):
         self.frame.Show()
 
     def Show(self):
         self.frame.Show()