From: kei9 Date: Fri, 20 Dec 2013 12:13:10 +0000 (+0900) Subject: add amulet search only by seed2 X-Git-Tag: 0.3.0^2~2 X-Git-Url: http://git.sourceforge.jp/view?p=amulettoolsmh4%2Fmain.git;a=commitdiff_plain;h=3bcf22c12ca3bc847449f4338d40463ae69148d7 add amulet search only by seed2 --- diff --git a/amulettool.py b/amulettool.py index 6c9911b..23ec9b9 100644 --- a/amulettool.py +++ b/amulettool.py @@ -156,14 +156,6 @@ class AmuletToolController(wx.App): self.notebook_simulator_view.bind_button_search(self.OnClickSimulatorSearch) self.notebook_simulator_view.bind_button_clear(self.OnClickSimulatorClear) - - def _update_notebook_amulet(self, amulet_id=None): - u""" お守り検索タブのviewの更新 - amulet_id が Noneでない場合、お守りの種類に応じてComboboxを再設定する - また、選択中のスキルに応じて最大最小を設定する""" - pass - - def _update_notebook_amulet_seed2s(self): u"""お守り検索タブのSeed2リストを更新する""" pass @@ -171,15 +163,12 @@ class AmuletToolController(wx.App): def _init_notebook_amulet(self): u""" お守り検索タブの初期設定 """ self.notebook_amulet_view = self.frame_view.notebook_amulet_view - self.notebook_amulet_view.bind_radiobox_amulet(self.OnClickAmuletRadioAmulet) - self.notebook_amulet_view.bind_radiobox_threshold_type(self.OnClickAmuletRadioThresholdType) - self.notebook_amulet_view.bind_combobox(self.OnClickAmuletCombo) + self.notebook_amulet_view.set_skillminmax_dict(self._skill_names, self._amulet_names, self._minmax_dict) self.notebook_amulet_view.bind_button_search(self.OnClickAmuletSearch) self.notebook_amulet_view.bind_button_clear(self.OnClickAmuletClear) - self.notebook_amulet_view.bind_button_skill(self.OnClickSkillSearchFromAmulet) + self.notebook_amulet_view.bind_button_skill2(self.OnClickSkill2SearchFromAmulet) - self.notebook_amulet_view.set_radio_value(True, view.NAME_AMULET1) - self._update_notebook_amulet() + self.notebook_amulet_view.set_selected_amulet(True, view.NAME_AMULET1) def _init_notebook_setting(self): u""" 設定タブの初期設定 """ @@ -368,33 +357,28 @@ class AmuletToolController(wx.App): self.notebook_simulator_view.clear_highlight() u""" amulet search event """ - def OnClickAmuletRadioAmulet(self, evt): - u""" switch skill lists by amulet id """ - #btn_id = evt.GetId() - amulet_name = self.notebook_amulet_view.get_selected_amulet() - amu_id = self._amulet_name2id_dict[amulet_name] - 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_grid() - - def OnClickAmuletRadioThresholdType(self, evt): - u""" switch seed lists by threshold_type """ - self._update_notebook_amulet_seed2s() - - def OnClickAmuletCombo(self, evt): - u""" switch skill minmax by amulet id and skill_id""" - self._update_notebook_amulet() - def OnClickAmuletSearch(self, evt): u""" search seeds from amulet condition """ - pass + search_type = self.notebook_amulet_view.get_selected_search_type() + if search_type == view.SEARCH_TYPE_SEED2: + skill1_name, skill2_name = self.notebook_amulet_view.get_skill_names() + skill1_val, skill2_val = self.notebook_amulet_view.get_skill_values() + slot_num = self.notebook_amulet_view.get_slot_value() + amulet_name = self.notebook_amulet_view.get_selected_amulet() + suff_val, threshold, th1_seed2s, th2_seed2s = self.db_accessor.simple_select_seed2s_from_names( + amulet_name, skill1_name, skill1_val, skill2_name, skill2_val, slot_num) + self.notebook_amulet_view.set_result_only_seed2(suff_val, threshold, th1_seed2s, th2_seed2s) + elif search_type == view.SEARCH_TYPE_SEED1_SEED2: + pass + elif search_type == view.SEARCH_TYPE_FIXED_SEED2: + pass def OnClickAmuletClear(self, evt): u""" clear amulet conditions """ - pass + self.notebook_amulet_view.clear_grid() + self.notebook_amulet_view.clear_input_values() - def OnClickSkillSearchFromAmulet(self, evt): + def OnClickSkill2SearchFromAmulet(self, evt): u""" change page to skill search from amulet""" seed = self.notebook_amulet_view.get_grid_selected_seed2() if seed is not None: diff --git a/model/amuletsearcher.py b/model/amuletsearcher.py new file mode 100644 index 0000000..024ef5c --- /dev/null +++ b/model/amuletsearcher.py @@ -0,0 +1,146 @@ +# -*- coding: utf-8 -*- + +u""" +お守り検索を行うクラス +2013/12/20 written by kei9 +""" + +import sqlite3 +import csv + +import amulettable +import skilltable +import skillminmaxtable +import seed2thresholdtable +import seed2skill2table +import sufficienttable + + +SELECT_SEED2S_FROM_THRESHOLD_AND_SKILL2_SQL = u""" + select {{threshold_table}}.{threshold_seed2} from {{threshold_table}} + inner join {{skill2_table}} on {{threshold_table}}.{threshold_seed2} = {{skill2_table}}.{skill2_seed2} + where + ({{skill2_table}}.{skill2_id1} = {{skill2_id}} and {{threshold_table}}.{threshold_1} >= {{threshold}}) or + ({{skill2_table}}.{skill2_id2} = {{skill2_id}} and {{threshold_table}}.{threshold_2} >= {{threshold}}) or + ({{skill2_table}}.{skill2_id3} = {{skill2_id}} and {{threshold_table}}.{threshold_3} >= {{threshold}}) or + ({{skill2_table}}.{skill2_id4} = {{skill2_id}} and {{threshold_table}}.{threshold_4} >= {{threshold}}) or + ({{skill2_table}}.{skill2_id5} = {{skill2_id}} and {{threshold_table}}.{threshold_5} >= {{threshold}}) or + ({{skill2_table}}.{skill2_id6} = {{skill2_id}} and {{threshold_table}}.{threshold_6} >= {{threshold}}) or + ({{skill2_table}}.{skill2_id7} = {{skill2_id}} and {{threshold_table}}.{threshold_7} >= {{threshold}}) + """.format( + skill2_seed2=seed2skill2table.COL_SEED2, + skill2_id1=seed2skill2table.COL_SKILL2_ID1, + skill2_id2=seed2skill2table.COL_SKILL2_ID2, + skill2_id3=seed2skill2table.COL_SKILL2_ID3, + skill2_id4=seed2skill2table.COL_SKILL2_ID4, + skill2_id5=seed2skill2table.COL_SKILL2_ID5, + skill2_id6=seed2skill2table.COL_SKILL2_ID6, + skill2_id7=seed2skill2table.COL_SKILL2_ID7, + threshold_seed2=seed2thresholdtable.COL_SEED2, + threshold_1=seed2thresholdtable.COL_THRESHOLD1, + threshold_2=seed2thresholdtable.COL_THRESHOLD2, + threshold_3=seed2thresholdtable.COL_THRESHOLD3, + threshold_4=seed2thresholdtable.COL_THRESHOLD4, + threshold_5=seed2thresholdtable.COL_THRESHOLD5, + threshold_6=seed2thresholdtable.COL_THRESHOLD6, + threshold_7=seed2thresholdtable.COL_THRESHOLD7) + + +class AmuletSearcher(object): + u"""お守りの検索を行うクラス""" + def __init__(self, db_cursor): + u""" db_cursor: cursor of sqlite3 database """ + self._cursor = db_cursor + accessor = amulettable.AmuletTableAccessor(db_cursor) + self._amu_id2name, self._amu_name2id = accessor.get_dict() + + accessor = skilltable.SkillTableAccessor(db_cursor) + self._skill_id2name, self._skill_name2id = accessor.get_dict() + + accessor = skillminmaxtable.SkillMinMaxTableAccessor(db_cursor) + self._minmax_dict = accessor.get_minmax_by_id() + + accessor = seed2skill2table.Seed2Skill2TableAccessor(db_cursor) + self._amu_id2skill2_table = accessor.get_amulet_id2table_name_dict() + + self._acc_sufficient = sufficienttable.SufficientTableAccessor(db_cursor) + self._acc_threshold = seed2thresholdtable.Seed2ThresholdTableAccessor(db_cursor) + + def simple_select_seed2s_from_ids(self, amulet_id, skill1_id, skill1_val, skill2_id, skill2_val, slot_num): + u""" 指定されたスキルId,スキル値、スロット数を元にして、 + Seed1との組み合わせを無視したSeed2候補の簡易検索を行う + return (suff_val, threshold, th1_seed2s, th2_seed2s)""" + suff_val = self.get_sufficient_value(amulet_id, skill1_id, skill1_val, skill2_id, skill2_val) + if suff_val is not None: + slot_ths = self._acc_sufficient.select_thresholds_by_id(amulet_id, suff_val) + threshold = slot_ths[slot_num - 1] + if skill2_id in self._skill_id2name: + skill2_table = self._amu_id2skill2_table[amulet_id] + # for threshold 1 + threshold_table = seed2thresholdtable.NAME.format(index=1) + sql = SELECT_SEED2S_FROM_THRESHOLD_AND_SKILL2_SQL.format( + threshold_table=threshold_table, + skill2_table=skill2_table, + threshold=threshold, + skill2_id=skill2_id) + self._cursor.execute(sql) + th1_seed2s = set([x[0] for x in self._cursor.fetchall()]) + + # for threshold 2 + threshold_table = seed2thresholdtable.NAME.format(index=2) + sql = SELECT_SEED2S_FROM_THRESHOLD_AND_SKILL2_SQL.format( + threshold_table=threshold_table, + skill2_table=skill2_table, + threshold=threshold, + skill2_id=skill2_id) + self._cursor.execute(sql) + th2_seed2s = set([x[0] for x in self._cursor.fetchall()]) + + else: + th1_seed2s = self._acc_threshold.select_seed2s_from_all_threshold(threshold, 1) + th2_seed2s = self._acc_threshold.select_seed2s_from_all_threshold(threshold, 2) + else: + th1_ssed2s, th2_seed2s = set(), set() + threshold = None + + return (suff_val, threshold, th1_seed2s, th2_seed2s) + + def simple_select_seed2s_from_names(self, + amulet_name, skill1_name, skill1_val, skill2_name, skill2_val, slot_num): + u""" 指定されたお守り名、スキル名,スキル値、スロット数を元にして、 + Seed1との組み合わせを無視したSeed2候補の簡易検索を行う + return (suff_val, threshold, th1_seed2s, th2_seed2s)""" + amulet_id = self._amu_name2id[amulet_name] + skill1_id = self._skill_name2id[skill1_name] if skill1_name in self._skill_name2id else None + skill2_id = self._skill_name2id[skill2_name] if skill2_name in self._skill_name2id else None + return self.simple_select_seed2s_from_ids(amulet_id, skill1_id, skill1_val, skill2_id, skill2_val, slot_num) + + + + def get_sufficient_value(self, amulet_id, skill1_id, skill1_val, skill2_id, skill2_val): + u""" 充足値を計算する。 + 指定したスキルが見つからない場合や、充足値を計算できない場合はNoneを返す + skill2_nameが存在しないスキルであればskill1のみから計算する + return sufficient_val + """ + skill1_minmax, skill2_minmax = self._minmax_dict[amulet_id] + if skill1_id in skill1_minmax: + min1, max1 = skill1_minmax[skill1_id] + skill1_val = 0 if skill1_val < 0 else skill1_val + else: + # cannot find skill1 + return None + + if skill2_id in skill2_minmax: + min2, max2 = skill2_minmax[skill2_id] + skill2_val = 0 if skill2_val < 0 else skill2_val + else: + max2 = 1 + skill2_val = 0 + + if skill1_val > max1 or skill2_val > max2: + # over value + return None + + suff_val = (10 * skill1_val) // max1 + (10 * skill2_val) // max2 + return suff_val diff --git a/model/db_accessor.py b/model/db_accessor.py index 48bc233..6d8a5cf 100644 --- a/model/db_accessor.py +++ b/model/db_accessor.py @@ -18,6 +18,7 @@ from seed2inishietable import Seed2InishieTableAccessor from sufficienttable import SufficientTableAccessor from seed1tenuntable import Seed1TenunTableAccessor from alchemysimulator import AlchemySimulator +from amuletsearcher import AmuletSearcher class DataBaseAccessor(object): u""" this is access class to database """ @@ -37,6 +38,7 @@ class DataBaseAccessor(object): self._acc_sufficient = SufficientTableAccessor(self._cursor) self._acc_seed1tenun = Seed1TenunTableAccessor(self._cursor) self._simulator = AlchemySimulator(self._cursor) + self._amulet_searcher = AmuletSearcher(self._cursor) self._minmax_dict_by_name = self._acc_minmax.get_minmax_by_name() @@ -52,7 +54,6 @@ class DataBaseAccessor(object): amu_skill_name_list: [(amu_name, skill_name), ....]""" return self._acc_seed1tenun.select_seed1s_from_names(amu_skill_name_list, alchemy_type) - def get_minmax_dict(self, copied=False): u""" お守り名と第1.第2スキル名ごとのの最大値を関連付けた辞書を返す return {amulet_name:({skill1_name:(min1,max1)}, {skill2_name:(min2,max2)})}""" @@ -147,6 +148,16 @@ class DataBaseAccessor(object): else: return None + u""" お守り検索 """ + def simple_select_seed2s_from_names(self, + amulet_name, skill1_name, skill1_val, skill2_name, skill2_val, slot_num): + u""" 指定されたスキルId,スキル値、スロット数を元にして、 + Seed1との組み合わせを無視したSeed2候補の簡易検索を行う + return (suff_val, threshold, th1_seed2s, th2_seed2s)""" + return self._amulet_searcher.simple_select_seed2s_from_names( + amulet_name, skill1_name, skill1_val, skill2_name, skill2_val, slot_num) + + u""" 錬金シミュレーター """ def simulate_nazo(self, seed1, seed2): u""" なぞの錬金 return (skill1_name, skill1_val, skill2_name, skill2_val, slot_num, type_name) diff --git a/model/seed2skill2table.py b/model/seed2skill2table.py index c276bf7..cf64685 100644 --- a/model/seed2skill2table.py +++ b/model/seed2skill2table.py @@ -10,6 +10,7 @@ import csv import amulettable import skilltable +import singleton # for Seed2 to skill2 u""" SEED2から各お守りの第2スキルへのテーブル """ @@ -148,6 +149,7 @@ class Seed2Skill2TableGenerator(object): class Seed2Skill2TableAccessor(object): u""" Seed2とスキル名の組み合わせテーブルへのアクセス用クラス """ + __metaclass__ = singleton.Singleton def __init__(self, db_cursor): u""" db_cursor: cursor of sqlite3 database """ self._cursor = db_cursor @@ -162,6 +164,13 @@ class Seed2Skill2TableAccessor(object): amu_id, table_name = row self._amu_id2table_name[amu_id] = table_name + def get_amulet_id2table_name_dict(self, copied=False): + u""" お守りIDからスキル2テーブル名への変換辞書を返す """ + if copied is True: + return self._amu_id2table_name.copy() + else: + return self._amu_id2table_name + def select_seed2s_by_ids(self, amu_id2skill_ids): u""" お守りIdとスキルIdのリストの辞書からSeed2を特定する skill_ids: (skill_id1, skill_id2, ...., skill_id7) diff --git a/model/seed2thresholdtable.py b/model/seed2thresholdtable.py index 90155c2..8fab165 100644 --- a/model/seed2thresholdtable.py +++ b/model/seed2thresholdtable.py @@ -8,6 +8,8 @@ Seed2と判定値の組み合わせテーブルの作成・アクセスをする import sqlite3 import csv +import singleton + # for seed2 to threshold1 u""" SEED2から判定値1へのテーブル """ NAME = u"seed2_threshold{index}" @@ -108,6 +110,7 @@ class Seed2ThresholdTableGenerator(object): class Seed2ThresholdTableAccessor(object): u""" Seed2と判定値の組み合わせテーブルへのアクセス用クラス """ + __metaclass__ = singleton.Singleton def __init__(self, db_cursor): u""" db_cursor: cursor of sqlite3 database """ self._cursor = db_cursor diff --git a/model/sufficienttable.py b/model/sufficienttable.py index 3a61d25..667c798 100644 --- a/model/sufficienttable.py +++ b/model/sufficienttable.py @@ -9,6 +9,7 @@ import sqlite3 import csv import amulettable +import singleton # for sufficient value for slots MASTER_NAME = u"sufficient_master" @@ -107,6 +108,7 @@ class SufficientTableGenerator(object): class SufficientTableAccessor(object): u"""充足値から判定値の組み合わせテーブルへのアクセスをするクラス""" + __metaclass__ = singleton.Singleton def __init__(self, db_cursor): u""" db_cursor: cursor of sqlite3 database """ self._cursor = db_cursor diff --git a/view/constnumbers.py b/view/constnumbers.py index b897a13..016b9dc 100644 --- a/view/constnumbers.py +++ b/view/constnumbers.py @@ -70,13 +70,17 @@ SIMULATOR_GRID_SKILL_NAME_COLS = [1,3] SIMULATOR_GRID_ROW_DICT = {KEY_NAZO:0, KEY_KOMYOU:1, KEY_INISHIE:2, KEY_TENUN:(3,4,5,6,7,8,9)} # amulet seed2s grid -LABEL_FORMAT_AMULET_SEED2S_GRID_COL1 = u"錬金の種類" +LABEL_FORMAT_AMULET_SEED2S_GRID_COL1 = u"判定値の種類" NUM_AMULET_SEED2S_GRID_COL = 1 LABEL_FORMAT_AMULET_SEED1S_GRID_COL1 = u"天運555" LABEL_FORMAT_AMULET_SEED1S_GRID_COL2 = u"天運888" NUM_AMULET_SEED1S_GRID_COL = 2 +SEARCH_TYPE_SEED2 = 1 +SEARCH_TYPE_SEED1_SEED2 = 2 +SEARCH_TYPE_FIXED_SEED2 = 3 + # page index SKILL2_SEARCH_PAGE = 1 SKILL1_SEARCH_PAGE = 3 diff --git a/view/mainframe.fbp b/view/mainframe.fbp index 35c8c7c..1ca7976 100644 --- a/view/mainframe.fbp +++ b/view/mainframe.fbp @@ -9802,7 +9802,7 @@ 錬金シミュレータ - 1 + 0 1 1 @@ -10812,7 +10812,7 @@ お守り検索 - 0 + 1 1 1 @@ -11732,7 +11732,7 @@ 1 0 - "すべて" "判定値1のみ" "判定値2のみ" "いにしえの錬金" + "Seed2のみ(検索時間小・不確実)" "Seed1,2(検索時間大・正確)" "Seed2固定" 1 1 @@ -11747,7 +11747,7 @@ 0 0 wxID_ANY - 表示する判定値の種類 + 検索方法 1 0 @@ -11756,7 +11756,7 @@ 0 1 - RadioBoxThresholdType + RadioBoxSearchType 1 diff --git a/view/mainframe.xrc b/view/mainframe.xrc index dac4b46..3b48cdf 100644 --- a/view/mainframe.xrc +++ b/view/mainframe.xrc @@ -1293,7 +1293,7 @@ - 1 + 0 @@ -1441,7 +1441,7 @@ - 0 + 1 @@ -1575,15 +1575,14 @@ wxBOTTOM|wxEXPAND|wxLEFT|wxRIGHT 5 - + - + 0 - すべて - 判定値1のみ - 判定値2のみ - いにしえの錬金 + Seed2のみ(検索時間小・不確実) + Seed1,2(検索時間大・正確) + Seed2固定 1 diff --git a/view/notebookamuletview.py b/view/notebookamuletview.py index ba848f8..1a03394 100644 --- a/view/notebookamuletview.py +++ b/view/notebookamuletview.py @@ -21,14 +21,14 @@ class NoteBookAmuletView(): # button self.button_search = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchSearch") self.button_clear = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchClear") - self.button_skill = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchSkill2") + self.button_skill2 = xrc.XRCCTRL(self.frame, "ButtonAmuletSearchSkill2") self.ID_BUTTON_SEARCH = xrc.XRCID("ButtonAmuletSearchSearch") self.ID_BUTTON_CLEAR = xrc.XRCID("ButtonAmuletSearchClear") self.ID_BUTTON_SKILL = xrc.XRCID("ButtonAmuletSearchSkill2") # radio button self.radiobox_amulet = xrc.XRCCTRL(self.frame, "RadioBoxAmulet") - self.radiobox_threshold_type = xrc.XRCCTRL(self.frame, "RadioBoxThresholdType") + self.radiobox_search_type = xrc.XRCCTRL(self.frame, "RadioBoxSearchType") # seed2s list self.grid_seed2s = xrc.XRCCTRL(self.frame, "GridAmuletSeed2s") @@ -70,6 +70,9 @@ class NoteBookAmuletView(): # initialize event self.grid_seed1s.Bind(wx.EVT_SIZE, self.OnSeed1GridSizeChanged) self.grid_seed2s.Bind(wx.EVT_SIZE, self.OnSeed2GridSizeChanged) + self.combo_box_skill1.Bind(wx.EVT_COMBOBOX, self.OnComboSkill1Changed) + self.combo_box_skill2.Bind(wx.EVT_COMBOBOX, self.OnComboSkill2Changed) + self.radiobox_amulet.Bind(wx.EVT_RADIOBOX, self.OnRadioAmuletChanged) def OnSeed1GridSizeChanged(self, event): u""" Seed1Gridサイズの変更時 """ @@ -87,18 +90,21 @@ class NoteBookAmuletView(): for col in range(constnumbers.NUM_AMULET_SEED2S_GRID_COL): self.grid_seed2s.SetColSize(col, each_width) - def bind_radiobox_amulet(self, event_func, evt=wx.EVT_RADIOBOX): - u""" お守り種類のラジオボタンが押された時のイベントをセットする """ - self.radiobox_amulet.Bind(evt, event_func) + def OnComboSkill1Changed(self, event): + u""" スキル1のコンボボックスの変更時 """ + self.update_skill_minmax(1) - def bind_radiobox_threshold_type(self, event_func, evt=wx.EVT_RADIOBOX): - u""" 判定値の種類のラジオボタンが押された時のイベントをセットする """ - self.radiobox_threshold_type.Bind(evt, event_func) + def OnComboSkill2Changed(self, event): + u""" スキル2のコンボボックスの変更時 """ + self.update_skill_minmax(2) + + def OnRadioAmuletChanged(self, event): + u""" お守り選択のラジオボタン変更時 """ + self.update_skill_names() - def bind_combobox(self, event_func, evt=wx.EVT_COMBOBOX): - u""" コンボボタンが押された時のイベントをセットする """ - self.combo_box_skill1.Bind(evt, event_func) - self.combo_box_skill2.Bind(evt, event_func) + def bind_radiobox_search_type(self, event_func, evt=wx.EVT_RADIOBOX): + u""" 判定値の種類のラジオボタンが押された時のイベントをセットする """ + self.radiobox_search_type.Bind(evt, event_func) def bind_button_search(self, event_func, evt=wx.EVT_BUTTON): u""" 検索ボタンが押された時のイベントをセットする """ @@ -108,14 +114,57 @@ class NoteBookAmuletView(): u""" クリアボタンが押された時のイベントをセットする """ self.button_clear.Bind(evt, event_func) - def bind_button_skill(self, event_func, evt=wx.EVT_BUTTON): - u""" スキル検索ボタンが押された時のイベントをセットする """ - self.button_skill.Bind(evt, event_func) + def bind_button_skill2(self, event_func, evt=wx.EVT_BUTTON): + u""" スキル2検索ボタンが押された時のイベントをセットする """ + self.button_skill2.Bind(evt, event_func) - def set_skill_minmax(self, min1, max1, min2, max2): - u""" 第1,2スキルの最大値と最小値をセットする """ - self.spin_ctrl_skill1_val.SetRange(min1, max1) - self.spin_ctrl_skill2_val.SetRange(min2, max2) + def set_skillminmax_dict(self, skill_names, amulet_names, minmax_dict): + u"""スキル名のリスト、お守り名のリスト、 + そのお守りに対応する第1,2スキルの最大最小の辞書をセットする + {amulet_name:({skill1_name:(min1,max1)}, {skill2_name:(min2,max2)})} + """ + self._skill_names = skill_names + self._amulet_names = amulet_names + self._minmax_dict = minmax_dict + self.set_selected_amulet(constnumbers.NAME_AMULET1) + self.update_skill_names() + self.update_skill_minmax() + + def set_skillnames_ordered(self, skillnames): + u""" 順番に並べられたスキル名のシーケンスをセットする """ + self._skillnames = skillnames + + def update_skill_names(self): + u""" 選択されたお守り名に応じてスキル名のリストを更新する """ + amu_name = self.get_selected_amulet() + skill1_minmax, skill2_minmax = self._minmax_dict[amu_name] + + self.combo_box_skill1.SetItems([x for x in self._skill_names if x in skill1_minmax]) + self.combo_box_skill2.SetItems([constnumbers.VAL_NO_SKILL] + + [x for x in self._skill_names if x in skill2_minmax]) + self.combo_box_skill1.SetSelection(0) + self.combo_box_skill2.SetSelection(0) + + def update_skill_minmax(self, index=None): + u""" 選択されたスキル名に応じて値の範囲を設定する """ + amu_name = self.get_selected_amulet() + skill1_minmax, skill2_minmax = self._minmax_dict[amu_name] + + if index is None or index == 1: + skill1_name = self.combo_box_skill1.GetStringSelection() + if skill1_name in skill1_minmax: + min1, max1 = skill1_minmax[skill1_name] + self.spin_ctrl_skill1_val.SetRange(min1, max1) + else: + self.spin_ctrl_skill1_val.SetRange(0, 0) + + if index is None or index == 2: + skill2_name = self.combo_box_skill2.GetStringSelection() + if skill2_name in skill2_minmax: + min2, max2 = skill2_minmax[skill2_name] + self.spin_ctrl_skill2_val.SetRange(min2, max2) + else: + self.spin_ctrl_skill2_val.SetRange(0, 0) def set_slot_minmax(self, slot_min, slot_max): u""" スロットの最大値と最小値をセットする """ @@ -132,7 +181,15 @@ class NoteBookAmuletView(): u""" スロットの値を得る """ return self.spin_ctrl_slot_num.GetValue() - def set_radio_value(self, value, amulet_name=constnumbers.NAME_AMULET1): + def clear_input_values(self): + u""" 入力された値を初期化する """ + self.combo_box_skill1.SetSelection(0) + self.combo_box_skill2.SetSelection(0) + self.spin_ctrl_skill1_val.SetValue(1) + self.spin_ctrl_skill2_val.SetValue(0) + self.spin_ctrl_slot_num.SetValue(1) + + def set_selected_amulet(self, value, amulet_name=constnumbers.NAME_AMULET1): u""" ラジオボタンの値をセットする arg: (value, amulet_name) """ @@ -144,18 +201,6 @@ class NoteBookAmuletView(): idx = 2 self.radiobox_amulet.SetSelection(idx) - def get_radio_value(self, amulet_name=constnumbers.NAME_AMULET1): - u""" ラジオボタンの値を得る - return: (value) - """ - if amulet_name == constnumbers.NAME_AMULET1: - idx = 0 - elif amulet_name == constnumbers.NAME_AMULET2: - idx = 1 - elif amulet_name == constnumbers.NAME_AMULET3: - idx = 2 - return self.radiobox_amulet.GetSelection() == idx - def get_selected_amulet(self): u""" 選択されているお守り名を得る return: (NAME_OF_AMULET) @@ -170,61 +215,31 @@ class NoteBookAmuletView(): else: raise NotImplementedError("irregular radio button selected") - def get_selected_threshold_type(self): + def get_selected_search_type(self): u""" 選択されているラジオボタンの検索種類IDを得る return: (THRESHOLD_TYPE_ID) """ - idx = self.radiobox_threshold_type.GetSelection() + idx = self.radiobox_search_type.GetSelection() if idx == 0: - return constnumbers.THRESHOLD_TYPE_ALL + return constnumbers.SEARCH_TYPE_SEED2 elif idx == 1: - return constnumbers.THRESHOLD_TYPE_THRESHOLD1 + return constnumbers.SEARCH_TYPE_SEED1_SEED2 elif idx == 2: - return constnumbers.THRESHOLD_TYPE_THRESHOLD2 - elif idx == 3: - return constnumbers.THRESHOLD_TYPE_INISHIE + return constnumbers.SEARCH_TYPE_FIXED_SEED2 else: raise NotImplementedError("irregular radio button selected") - def set_selection_skill1_combobox(self, idx): - u""" skill1のコンボボックスの選択されたインデックスをセットする """ - self.combo_box_skill1.SetSelection(idx) - - def set_selection_skill2_combobox(self, idx): - u""" skill2のコンボボックスの選択されたインデックスをセットする """ - self.combo_box_skill2.SetSelection(idx) - - def get_string_selection_skill1_combobox(self): - u""" skill1のコンボボックスの選択された値を得る """ - return self.combo_box_skill1.GetStringSelection() - - def get_string_selection_skill2_combobox(self): - u""" skill2のコンボボックスの選択された値を得る """ - return self.combo_box_skill2.GetStringSelection() - - def get_string_selection_skill_names(self): + def get_skill_names(self): u""" skill1, skill2で選択されているスキル名を返す return (skill1_name, skill2_name)""" - skill1_name = self.get_string_selection_skill1_combobox() - skill2_name = self.get_string_selection_skill2_combobox() + skill1_name = self.combo_box_skill1.GetStringSelection() + skill2_name = self.combo_box_skill2.GetStringSelection() return (skill1_name, skill2_name) - def set_items_skill1_combobox(self, string_list): - u""" skill1のコンボボックスの値をセットする """ - self.combo_box_skill1.SetItems(string_list) - - def set_items_skill2_combobox(self, string_list): - u""" skill2のコンボボックスの値をセットする """ - self.combo_box_skill2.SetItems(string_list) - - def set_items_skill_combobox(self, idx, string_list): - u""" 指定されたインデックスのskillのコンボボックスの値をセットする """ - if idx == 0: - self.set_items_skill1_combobox(string_list) - elif idx == 1: - self.set_items_skill2_combobox(string_list) - else: - raise NotImplementedError(u"this idx is not implemented") + def set_skill_names(self, skill1_names, skill2_names): + u""" スキル1、スキル2のコンボボックスの一覧をセットする """ + self.combo_box_skill1.SetItems(skill1_names) + self.combo_box_skill2.SetItems(skill2_names) def set_skill_button_enable(self, value): u""" 対応スキル検索ボタンの有効・無効の切り替え """ @@ -233,10 +248,30 @@ class NoteBookAmuletView(): else: self.button_skill.Disable() - def set_result_text_ctrl_value(self, value): + def set_result(self, value): u""" 結果表示用のTextCtrlに値をセットする """ self.text_ctrl_result.SetValue(value) + def set_result_only_seed2(self, suff_val, threshold, th1_seed2s, th2_seed2s): + u""" Seed2のみからの検索結果表示用に値をセットする """ + seed2s = th1_seed2s | th2_seed2s + self.text_ctrl_result.SetValue(u"""充足値: {0}, 必要な判定値: {1} +{1}以上の判定値1を持つSeed2: {2} +{1}以上の判定値2を持つSeed2: {3} +{1}以上の判定値を持つSeed2: {4}""".format( + suff_val, threshold, len(th1_seed2s), len(th2_seed2s), len(seed2s))) + items_dict = {} + for seed2 in seed2s: + texts = [] + if seed2 in th1_seed2s: + texts.append(u"判定値1") + if seed2 in th2_seed2s: + texts.append(u"判定値2") + texts = u", ".join(texts) + texts = u"Seed2({0})".format(texts) if len(texts) > 0 else texts + items_dict[seed2] = texts + self.set_grid_seed2s_items(items_dict) + def set_grid_seed2s_items(self, items_dict): u""" Seed2一覧のGridに値をセットする。 引数はSeed2 -> str_renkin_typeの辞書とする。 @@ -289,6 +324,13 @@ class NoteBookAmuletView(): self.grid_seed2s.MakeCellVisible(idx, 0) self.grid_seed2s.SelectRow(idx) + def set_grid_seed1_enable(self, value): + u""" Seed1表示ボタンの有効・無効の切り替え """ + if value is True: + self.grid_seed1.Enable() + else: + self.grid_seed1.Disable() + def clear_grid_seed2s(self): u""" Seed2一覧のGridから値をClearする""" for row in range(self.grid_seed2s.GetNumberRows()):