OSDN Git Service

revise amulet search to consider of seed1 value,
[amulettoolsmh4/main.git] / amulettool.py
index a8b64b9..295c75d 100644 (file)
@@ -187,7 +187,6 @@ class AmuletToolController(wx.App):
 
     def _update_notebook_amulet_seed2s(self):
         u"""お守り検索タブのSeed2リストを更新する"""
-        set_items = []
         threshold_type = self.notebook_amulet_view.get_selected_threshold_type()
         if threshold_type == view.THRESHOLD_TYPE_ALL:
             include_th1, include_th2, include_ini = True, True, True
@@ -198,26 +197,32 @@ class AmuletToolController(wx.App):
         elif threshold_type == view.THRESHOLD_TYPE_INISHIE:
             include_th1, include_th2, include_ini = False, False, True
 
+        set_items_dict = {}
         seed2_set = self.threshold1_seed2_set | self.threshold2_seed2_set | self.threshold_inishie_set
-        for seed in seed2_set:
+        for seed2 in seed2_set:
             type_set, include = [], False
-            if seed in self.threshold1_seed2_set:
+            if seed2 in self.threshold1_seed2_set:
                 type_set.append(u"判定値1")
                 if include_th1:
                     include = True
-            if seed in self.threshold2_seed2_set:
+            if seed2 in self.threshold2_seed2_set:
                 type_set.append(u"判定値2")
                 if include_th2:
                     include = True
-            if seed in self.threshold_inishie_set: # seed in inishie_set
+            if seed2 in self.threshold_inishie_set: # seed in inishie_set
                 type_set.append(u"いにしえ")
                 if include_ini:
                     include = True
             if include:
-                set_items.append(u"{0:06d}: (".format(seed) + u",".join(type_set) + u")")
-        self.notebook_amulet_view.set_listbox_items(set_items)
-        if len(set_items) > 0:
-            self.notebook_amulet_view.set_selection_listbox(0)
+                if seed2 in self.seed2_tenun_num_dict:
+                    tenun555_num, tenun888_num = self.seed2_tenun_num_dict[seed2]
+                else:
+                    tenun555_num, tenun888_num = 0, 0
+                set_items_dict[seed2] = (u",".join(type_set), tenun555_num, tenun888_num)
+
+        self.notebook_amulet_view.set_grid_seed2s_items(set_items_dict)
+        if len(set_items_dict) > 0:
+            self.notebook_amulet_view.set_grid_seed2s_selected_idx(0)
             self.notebook_amulet_view.set_skill_button_enable(True)
         else:
             self.notebook_amulet_view.set_skill_button_enable(False)
@@ -237,6 +242,8 @@ class AmuletToolController(wx.App):
         self._update_notebook_amulet(amu_id)
 
         self.threshold1_seed2_set, self.threshold2_seed2_set, self.threshold_inishie_set = set(), set(), set()
+        self.seed2_tenun_num_dict = {}
+        self._amulet_values = None
 
     def _init_notebook_setting(self):
         u""" 設定タブの初期設定 """
@@ -393,7 +400,7 @@ class AmuletToolController(wx.App):
         self._update_notebook_amulet(amu_id)
         self.notebook_amulet_view.set_result_text_ctrl_value(u"")
         self.notebook_amulet_view.set_skill_button_enable(False)
-        self.notebook_amulet_view.clear_listbox_items()
+        self.notebook_amulet_view.clear_grid()
 
     def OnClickAmuletRadioThresholdType(self, evt):
         u""" switch seed lists by threshold_type """
@@ -429,40 +436,63 @@ class AmuletToolController(wx.App):
                 (threshold, self.threshold1_seed2_set, self.threshold2_seed2_set, 
                     self.threshold_inishie_set) = self.db_accessor.select_seed2s_from_sufficient_val(
                         amu_id, suff_val, slot_val, skill2_id)
-                seed2_set = self.threshold1_seed2_set | self.threshold2_seed2_set | self.threshold_inishie_set
+                seed2_set = self.threshold1_seed2_set | self.threshold2_seed2_set
+
+                # filter seed2s by skill1_id
+                filtered_seed2_dict = {} # seeds -> (num555, num888)
+                for seed2 in seed2_set:
+                    places = self.db_accessor.select_skill2_place(amu_id, seed2, skill2_id)
+                    num_555, num_888 = self.db_accessor.count_seed1s_from_skill_place(skill1_id, places, amu_id)
+                    if num_555 > 0 or num_888 > 0:
+                        filtered_seed2_dict[seed2] = (num_555, num_888)
+                seed2_set = set(filtered_seed2_dict.keys())
+                self.seed2_tenun_num_dict = filtered_seed2_dict
+                self.threshold1_seed2_set = seed2_set & self.threshold1_seed2_set
+                self.threshold2_seed2_set = seed2_set & self.threshold2_seed2_set
+                u""" self.threshold_inishie_set についてはSeed1との対応が不明なのでそのまま使用する"""
+
+                self._amulet_values = (skill1_id, skill2_id, skill1_val, skill2_val)
                 self._update_notebook_amulet_seed2s()
                 if len(seed2_set) > 0:
                     self.notebook_amulet_view.set_result_text_ctrl_value(
 u"""指定されたお守りの充足値:\t{0}
 必要な判定値:\t{1}\n判定値1:\t{2}個のSeed2で出現\n判定値2:\t{3}個のSeed2で出現\nいにしえ:\t{4}個のSeed2で出現
\85¨ä½\93:\t{5}個のSeed2で出現""".format(
\88¤å®\9aå\80¤1,2:\t{5}個のSeed2で出現""".format(
                             suff_val, threshold, len(self.threshold1_seed2_set), len(self.threshold2_seed2_set), len(self.threshold_inishie_set), len(seed2_set)))
                 else:
+                    self.threshold1_seed2_set, self.threshold2_seed2_set, self.threshold_inishie_set = set(), set(), set()
                     self.notebook_amulet_view.set_result_text_ctrl_value(
 u"""指定されたお守りの充足値:\t{0}\n必要な判定値:\t{1}
 指定されたお守りは見つかりませんでした""".format(suff_val, threshold))
                     self.notebook_amulet_view.set_skill_button_enable(False)
-                    self.notebook_amulet_view.clear_listbox_items()
+                    self.notebook_amulet_view.clear_grid()
+                    self._amulet_values = None
+                    self.seed2_tenun_num_dict = {}
             else:
                 self.threshold1_seed2_set, self.threshold2_seed2_set, self.threshold_inishie_set = set(), set(), set()
                 self.notebook_amulet_view.set_result_text_ctrl_value(
                     u"エラー。充足値が計算できません")
                 self.notebook_amulet_view.set_skill_button_enable(False)
-                self.notebook_amulet_view.clear_listbox_items()
+                self.notebook_amulet_view.clear_grid()
+                self._amulet_values = None
+                self.seed2_tenun_num_dict = {}
 
     def OnClickAmuletClear(self, evt):
         u""" clear amulet conditions """
+        self.threshold1_seed2_set, self.threshold2_seed2_set, self.threshold_inishie_set = set(), set(), set()
+        self._amulet_values = None
+        self.seed2_tenun_num_dict = {}
         self.notebook_amulet_view.set_radio_value(True, view.NAME_AMULET1)
         amu_id = self._amulet_name2id_dict[view.NAME_AMULET1]
         self._update_notebook_amulet(amu_id)
         self.notebook_amulet_view.set_skill_button_enable(False)
         self.notebook_amulet_view.set_result_text_ctrl_value(u"")
-        self.notebook_amulet_view.clear_listbox_items()
+        self.notebook_amulet_view.clear_grid()
 
     def OnClickSkillSearchFromAmulet(self, evt):
         u""" change page to skill search from amulet"""
-        seed = self.notebook_amulet_view.get_string_selection_listbox().split(u":")[0]
-        if seed.isdigit():
+        seed = self.notebook_amulet_view.get_grid_selected_seed2()
+        if seed is not None:
             self.notebook_skill2_view.set_seed2_value(seed)
             self.frame_view.note_book.SetSelection(view.SKILL_SEARCH_PAGE)
             self.OnClickSkillSearch(evt)