Advertisement
Guest User

wp7breeding.py

a guest
Apr 3rd, 2012
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 82.42 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. * wp7breeding.py
  4. --
  5. ウイニングポスト7 2012(Windows版)の配合支援モジュール
  6. 実行にはウイニングポスト7 2012(Windows版)、IronPython2.7、libwp7n2012が必要です
  7.  
  8. このスクリプトをそのまま実行すると
  9. 「表示中の種牡馬」と「自牧場(日本)に繁用している繁殖牝馬」の配合結果を出力します
  10.  
  11. importするとPythonモジュールとして振る舞います
  12. ドキュメントやリファレンスはありません
  13.  
  14. V1.0.1.0で書いています、V1.0.0.0で使いたい場合は
  15. wp = WP7( Configuration.V101() ) の行を
  16. wp = WP7( Configuration.V100() ) に書き換えてください
  17.  
  18.  
  19. * 更新履歴
  20. --
  21. 2012/04/02 - 最初 http://codepad.org/p1MsB2vB
  22. 2012/04/03 - ひととおりの配合理論が実装できた(今ここ)
  23.  
  24.  
  25. * ToDo
  26. --
  27. 爆発力計算実装
  28. 危険度計算
  29.  
  30.  
  31. * リンク
  32. --
  33. Winning Post 7 2012
  34. http://www.gamecity.ne.jp/keiba/wp7_2012/
  35. IronPython
  36. http://ironpython.codeplex.com/
  37. libwp7n2012 - Winning Post 7 2012 Cheat Library - Google Project Hosting
  38. http://code.google.com/p/libwp7n2012/
  39. ウイニングポストの改造・ツール総合スレ Part11
  40. http://anago.2ch.net/test/read.cgi/game/1333320769/
  41.  
  42.  
  43. * 参考文献
  44. --
  45. 配合理論 | ウイニングポスト7攻略 Sheep
  46. http://www.wpclear.com/haigoriron/
  47.  
  48. Pythonのメタクラスについて — aodag documents v0.0 documentation
  49. http://aodag.bitbucket.org/meta_class.html
  50.  
  51. """
  52.  
  53. import sys, random, pprint, clr
  54.  
  55. clr.AddReference("KOEI.WP7_2012")
  56. clr.AddReference("KOEI.WP7_2012.Configuration")
  57.  
  58. import System
  59.  
  60. from KOEI.WP7_2012 import *
  61. from KOEI.WP7_2012.Datastruct import *
  62.  
  63.  
  64. ## pythonにはEnumは無い
  65. class EnumType(type):
  66.     def __init__(cls, name, bases, dct):
  67.         super(EnumType, cls).__init__(name, bases, dct)
  68.         cls._values = []
  69.  
  70.         for key, value in dct.iteritems():
  71.             if not key.startswith('_'):
  72.                 v = cls(key, value)
  73.                 setattr(cls, key, v)
  74.                 cls._values.append(v)
  75.  
  76.     def __iter__(cls):
  77.         return iter(cls._values)
  78.  
  79.  
  80. class StandardEnum(object):
  81.     __metaclass__ = EnumType
  82.    
  83.     def __init__(self, k, v):
  84.         self.v = v
  85.         self.k = k
  86.  
  87.     def __repr__(self):
  88.         return "<%s.%s value=%s>" % (self.__class__.__name__, self.k, self.v)
  89.  
  90.  
  91. # --------------------------------------------------------------------
  92. # Simbols
  93. # --------------------------------------------------------------------
  94.  
  95. ## ラインブリード
  96. class LineBreedEnum(StandardEnum):
  97.     Type_1 = 0x01 # 親系統ラインブリード4本爆発SP型
  98.     Type_2 = 0x02 # 親系統ラインブリード4本爆発型
  99.     Type_3 = 0x03 # 親系統ラインブリード3本爆発SP型
  100.     Type_4 = 0x04 # 親系統ラインブリード3本爆発型
  101.     Type_5 = 0x05 # 子系統ラインブリードSP型
  102.     Type_6 = 0x06 # 子系統ラインブリード
  103.     Type_7 = 0x07 # 親系統ラインブリードSP型
  104.     Type_8 = 0x08 # 親系統ラインブリード
  105.     NONE   = 0x09 # ラインブリード無し
  106.  
  107.  
  108. ## ニックス
  109. class NicksEnum(StandardEnum):
  110.     Type_1 = 0x01 # シングルニックス
  111.     Type_2 = 0x02 # ダブルニックス
  112.     Type_3 = 0x03 # トリプルニックス
  113.     Type_4 = 0x04 # フォースニックス
  114.     Type_5 = 0x05 # 2次ニックス
  115.     Type_6 = 0x06 # 3次ニックス
  116.     Type_7 = 0x07 # 4次ニックス
  117.     NONE   = 0x08 # ニックス無し
  118.  
  119.  
  120. ## 血脈活性化配合
  121. class BloodActivityEnum(StandardEnum):
  122.     Type_1 = 0x01 # 血脈活性化配合6本型
  123.     Type_2 = 0x02 # 血脈活性化配合7本型
  124.     Type_3 = 0x03 # 血脈活性化配合8本型
  125.     NONE   = 0x04 # 無し
  126.    
  127.  
  128. ## 昇華配合
  129. class AttrCombinationEnum(StandardEnum):
  130.     Type_1 = 0x01 # SP|ST 昇華配合Lv1
  131.     Type_2 = 0x02 # SP|ST 昇華配合Lv2
  132.     Type_3 = 0x03 # SP|ST 昇華配合Lv3
  133.     NONE   = 0x04 # 無し
  134.  
  135.  
  136. ## ライン活性配合
  137. class LineActivityEnum(StandardEnum):
  138.     Male_1   = 0x01 # メールライン活性配合Lv1
  139.     Male_2   = 0x02 # メールライン活性配合Lv2
  140.     Male_3   = 0x03 # メールライン活性配合Lv3
  141.     Bottom_1 = 0x04 # ボトムライン活性配合Lv1
  142.     Bottom_2 = 0x05 # ボトムライン活性配合Lv2
  143.     Bottom_3 = 0x06 # ボトムライン活性配合Lv3
  144.     NONE     = 0x04 # 無し
  145.  
  146.  
  147. ## 母父
  148. class BMSEnum(StandardEnum):
  149.     Type_1  = 0x01 # 母父○
  150.     Type_2  = 0x02 # 母父◎
  151.     NONE    = 0x03 # 無し
  152.  
  153.  
  154. ## スピードorスタミナ
  155. class SPSTTypeEnum(StandardEnum):
  156.     SPEED   = 0x01 #
  157.     STAMINA = 0x02 #
  158.     UNKNOWN = 0x03 #
  159.  
  160.  
  161. ## 血統タイプ
  162. class PedigreeTypeEnum(StandardEnum):
  163.     SIRE    = 0x01 #
  164.     MARE    = 0x02 #
  165.     UNKNOWN = 0x03 #
  166.  
  167.  
  168. ## 地域
  169. class CountryEnum(StandardEnum):
  170.     JAPAN   = 0x01 #
  171.     USA     = 0x02 #
  172.     EURO    = 0x03 #
  173.  
  174.  
  175. # --------------------------------------------------------------------
  176. # API
  177. # --------------------------------------------------------------------
  178.  
  179. ## 血統ノードクラス
  180. class PedigreeNode:
  181.     ptype = PedigreeTypeEnum.UNKNOWN
  182.     level     = 0
  183.     data      = None
  184.     blood_num = None
  185.     line      = ""
  186.    
  187.     father    = None
  188.     mother    = None
  189.    
  190.     def __init__( self, ptype, level, data, blood_num, line ):
  191.         self.ptype = ptype
  192.         self.level     = level
  193.         self.data      = data
  194.         self.blood_num = blood_num
  195.         self.line      = line
  196.         self.father    = None
  197.         self.mother    = None
  198.  
  199.  
  200. ## 血統クラス
  201. class Pedigree:
  202.     SIRE_SIGN = "o"
  203.     MARE_SIGN = "x"
  204.    
  205.     def __init__( self, wp, ptype, blood_data, blood_num, max_level = 3 ):
  206.         self.wp = wp
  207.         self.ptype = ptype
  208.         self.max_level = max_level
  209.        
  210.         line = Pedigree.SIRE_SIGN if self.ptype == PedigreeTypeEnum.SIRE else Pedigree.MARE_SIGN
  211.         self.tree = PedigreeNode( self.ptype, 0, blood_data, blood_num, line )
  212.         self.__create_blood_tree__( self.tree )
  213.    
  214.     def __iter__( self ):
  215.         yield self.tree
  216.        
  217.         for node in self.__iter_sub__( self.tree ):
  218.             yield node
  219.    
  220.    
  221.     def __iter_sub__( self, node ):
  222.         if node == None :
  223.             return
  224.  
  225.         if node.father != None :
  226.             yield node.father
  227.             for n in self.__iter_sub__( node.father ):
  228.                 yield n
  229.            
  230.         if node.mother != None :
  231.             yield node.mother
  232.             for n in self.__iter_sub__( node.mother ):
  233.                 yield n
  234.    
  235.    
  236.     def __create_blood_tree__( self, node ):
  237.         if node.level == self.max_level :
  238.             return
  239.        
  240.         father = self.wp.HBloodTable.GetData( node.data.father_num, HBloodData() )
  241.         temp = node.line + Pedigree.SIRE_SIGN
  242.         node.father = PedigreeNode( PedigreeTypeEnum.SIRE, node.level + 1, father, node.data.father_num, temp )
  243.        
  244.         mother = self.wp.HBloodTable.GetData( node.data.mother_num, HBloodData() )
  245.         temp = node.line + Pedigree.MARE_SIGN
  246.         node.mother = PedigreeNode( PedigreeTypeEnum.MARE, node.level + 1, mother, node.data.mother_num, temp )
  247.        
  248.         self.__create_blood_tree__( node.father )
  249.         self.__create_blood_tree__( node.mother )
  250.    
  251.    
  252.     def each( self, callback, arg ):
  253.         callback( node = self.tree, arg = arg )
  254.         self.__each_sub__( self.tree, callback, arg )
  255.    
  256.    
  257.     def __each_sub__( self, node, callback, arg ):
  258.         if node == None :
  259.             return
  260.            
  261.         if node.father != None :
  262.             callback( node = node.father, arg = arg )
  263.             self.__each_sub__( node.father, callback, arg )
  264.            
  265.         if node.mother != None :
  266.             callback( node = node.mother, arg = arg )
  267.             self.__each_sub__( node.mother, callback, arg )
  268.    
  269.    
  270.     def dump( self ):
  271.         print sprintf( "%s", get_blood_name( self.wp, self.tree.data ) )
  272.         self.__dump_node_sub__( self.tree )
  273.    
  274.    
  275.     def __dump_node_sub__( self, node ):
  276.         if node == None :
  277.             return
  278.        
  279.         indent = lambda n : "  " * n
  280.        
  281.         if node.father != None :
  282.             print sprintf( "%s%s", indent( node.father.level ), get_blood_name( self.wp, node.father.data ) )
  283.             self.__dump_node_sub__( node.father )
  284.        
  285.         if node.mother != None :
  286.             print sprintf( "%s%s", indent( node.mother.level ), get_blood_name( self.wp, node.mother.data ) )
  287.             self.__dump_node_sub__( node.mother )
  288.  
  289.  
  290. ## インブリード管理クラス
  291. class InBreed:
  292.     def __init__( self, pedigree_node, sire_level, mare_level ):
  293.         self.node = pedigree_node
  294.         self.sire_level = sire_level
  295.         self.mare_level = mare_level
  296.  
  297.  
  298. ## 特殊配合
  299. class BreedingCombinationSpecials:
  300.     # お笑い配合
  301.     owarai    = False
  302.    
  303.     # お似合い配合
  304.     oniai     = False
  305.    
  306.     # サヨナラ配合
  307.     sayonara  = False
  308.    
  309.     # Wサヨナラ配合
  310.     wsayonara = False
  311.    
  312.     # 稲妻配合
  313.     inazuma1  = False
  314.    
  315.     # 真稲妻配合
  316.     inazuma2  = False
  317.    
  318.     # 疾風配合
  319.     shippuu1  = False
  320.    
  321.     # 真疾風配合
  322.     shippuu2  = False
  323.    
  324.     # 3冠配合
  325.     sankan    = False
  326.  
  327.  
  328. ## 配合結果管理クラス
  329. class BreedingCombination:
  330.    
  331.     ## ニックス(NicksEnumのリストが入ったタプル)
  332.     nicks_list            = ()
  333.    
  334.     ## インブリード(InBreedのリストが入ったタプル)
  335.     inbreed_list          = ()
  336.  
  337.     ## ラインブリード
  338.     linebreed_type        = LineBreedEnum.NONE
  339.    
  340.     ## 血脈活性化配合
  341.     blood_activity        = BloodActivityEnum.NONE
  342.    
  343.     ## SP昇華配合
  344.     speed_combination     = AttrCombinationEnum.NONE
  345.    
  346.     ## ST昇華配合
  347.     stamina_combination   = AttrCombinationEnum.NONE
  348.    
  349.     ## SPST融合
  350.     fision_combination    = False
  351.  
  352.     ## 母父効果
  353.     bms_type              = BMSEnum.NONE
  354.    
  355.     ## 名種牡馬型活力補完(個数)
  356.     katsuryoku_complate_1 = 0
  357.    
  358.     ## 名牝型活力補完(個数)
  359.     katsuryoku_complate_2 = 0
  360.    
  361.     ## 異系血脈型活力補完(個数)
  362.     katsuryoku_complate_3 = 0
  363.    
  364.     ## 完全型活力補完
  365.     all_katsuryoku_complate = False
  366.    
  367.     ## 隔世遺伝(因子番号の入ったタプル)
  368.     kakusei_iden = ()
  369.    
  370.     ## メールライン活性配合
  371.     male_line_activity = LineActivityEnum.NONE
  372.  
  373.     ## 活力源化大種牡馬因子(血統番号の入ったタプル)
  374.     big_sire_factor_list   = ()
  375.    
  376.     ## 活力源化名種牡馬因子(血統番号の入ったタプル)
  377.     small_sire_factor_list = ()
  378.    
  379.     special  = BreedingCombinationSpecials()
  380.    
  381.     def is_inbreed( self ):
  382.         return len( self.inbreed_list ) > 0
  383.    
  384.     def is_linebreed( self ):
  385.         return self.linebreed_type != LineBreedEnum.NONE
  386.    
  387.     def is_kakusei_iden( self ):
  388.         return len( self.kakusei_iden ) > 0
  389.  
  390.  
  391. ## 配合クラス
  392. class Breeding:
  393.    
  394.     ## 3冠配合が成立するレースID
  395.     SANKAN_RACE_ID_LIST = [
  396.         2207, # 3冠(1294)
  397.         2208, # 牝馬3冠(568)
  398.         2209, # 米国3冠(403)
  399.         2210, # 欧州3冠(1701)
  400.         2365, # トリプルティアラ
  401.         2366, # 欧州オークス3冠
  402.         2367, # 仏国牝馬3冠
  403.         2373, # 秋古馬3冠
  404.         2420, # 英国3冠
  405.         2421, # 英国牝馬3冠
  406.         2422, # 仏国3冠
  407.         2423, # 愛国3冠
  408.         2424, # 欧州牡馬マイル3冠
  409.         2425, # 欧州牝馬マイル3冠
  410.         2496, # 南関東3冠
  411.     ]
  412.    
  413.     def __init__( self, wp, family_line_cache, country, sire_num, sire_pedigree, dam_num, dam_pedigree ):
  414.         self.__wp = wp
  415.         self.__country = country
  416.         self.__family_line_cache = family_line_cache
  417.         self.__sire_num = sire_num
  418.         self.__sire_pedigree = sire_pedigree
  419.         self.__dam_num = dam_num
  420.         self.__dam_pedigree  = dam_pedigree
  421.        
  422.         combination = BreedingCombination()
  423.        
  424.         ## SPST融合配合
  425.         family_line_data = self.__wp.HFamilyLineTable.GetData( self.__sire_pedigree.tree.data.family_line_num, HFamilyLineData() )
  426.        
  427.         if family_line_data.family_line_attr == 1 or family_line_data.family_line_attr == 2 :
  428.             ## SP昇華配合
  429.             combination.speed_combination = self.__attr_combination_check( 1 )
  430.             ## ST昇華配合
  431.             combination.stamina_combination = self.__attr_combination_check( 2 )
  432.        
  433.         combination.fision_combination = self.__attr_fision_combination_check()
  434.        
  435.         ## 母父
  436.         combination.bms_type = self.__bms_check()
  437.        
  438.         ## 血脈活性化配合
  439.         combination.blood_activity = self.__blood_activity_check()
  440.        
  441.         ## ニックス
  442.         combination.nicks_list = self.__nicks_check()
  443.        
  444.         ## インブリード(重い)
  445.         combination.inbreed_list = self.__inbreed_check()
  446.  
  447.         ## ラインブリード
  448.         combination.linebreed_type = self.__linebreed_check()
  449.    
  450.         ## 活力補完
  451.         ( combination.katsuryoku_complate_1,
  452.           combination.katsuryoku_complate_2,
  453.           combination.katsuryoku_complate_3,
  454.           combination.all_katsuryoku_complate ) = self.__katsuryoku_complate_check()
  455.        
  456.         ## 隔世遺伝
  457.         combination.kakusei_iden = self.__kakusei_iden_check()
  458.        
  459.         ## メール|ボトム ライン活性化配合
  460.         combination.male_line_activity = self.__line_activity_check()
  461.        
  462.         ## 活力源化種牡馬因子
  463.         ( combination.big_sire_factor_list,
  464.           combination.small_sire_factor_list ) = self.__activity_sire_factor_check()
  465.        
  466.         ## 特殊配合のチェック
  467.         combination.special = self.__special_combination_check( self.__sire_num, self.__dam_num )
  468.        
  469.         self.__combination = combination
  470.    
  471.    
  472.     ## ------------------------------------------------------------------
  473.     ## 配合結果を取得する
  474.     ## ------------------------------------------------------------------
  475.     def get_combination( self ):
  476.         return self.__combination
  477.    
  478.    
  479.     ## ------------------------------------------------------------------
  480.     ## 零細血統かどうか調べる
  481.     ## ------------------------------------------------------------------
  482.     """
  483.        競馬用語辞典より
  484.        
  485.        零細血統 各地域(日本、米国、欧州)内で血統支配率が1%以下の子系統、もしくは
  486.        各地域での同じ子系統の現役種牡馬数が全体の1%以下あるいは1頭しかいない場合は零細血統とみなされる
  487.    """
  488.     def is_reisai( self, country, family_line_num ):
  489.         family_line_cache = self.__family_line_cache[ family_line_num ]
  490.        
  491.         if family_line_cache.sire_count <= 1 :
  492.             return True
  493.        
  494.         if family_line_cache.sire_percent < 1.0:
  495.             return True
  496.        
  497.         return {
  498.             CountryEnum.JAPAN : family_line_cache.data.share_J <= 10,
  499.             CountryEnum.USA   : family_line_cache.data.share_U <= 10,
  500.             CountryEnum.EURO  : family_line_cache.data.share_E <= 10,
  501.         }.get( country, False )
  502.    
  503.    
  504.     ## ------------------------------------------------------------------
  505.     ## 流行血統かどうか調べる
  506.     ## ------------------------------------------------------------------
  507.     """
  508.        競馬用語辞典より
  509.        
  510.        流行血統 各地域(日本、米国、欧州)内で血統支配率が10%以上の子系統、もしくは
  511.        各地域内で、同じ子系統の現役種牡馬数が 全体の10%以上の場合、流行血統とみなされる。
  512.    """
  513.     def is_ryuukou( self, country, family_line_num ):
  514.         family_line_cache = self.__family_line_cache[ family_line_num ]
  515.        
  516.         if family_line_cache.sire_percent >= 10.0:
  517.             return True
  518.        
  519.         return {
  520.             CountryEnum.JAPAN : family_line_cache.data.share_J >= 100,
  521.             CountryEnum.USA   : family_line_cache.data.share_U >= 100,
  522.             CountryEnum.EURO  : family_line_cache.data.share_E >= 100,
  523.         }.get( country, False )
  524.    
  525.    
  526.     ## ------------------------------------------------------------------
  527.     ## 特殊配合のチェック
  528.     ## ------------------------------------------------------------------
  529.     """
  530.        お笑い配合
  531.            評価額が1億円以上で賢さも高い母に、種付け料100万円以下の父を配合する場合に成立します。
  532.            精神力・賢さ・勝負根性・爆発力のアップが期待できます。
  533.        
  534.        お似合い配合
  535.            種付け料が200万円以下で賢さが高い父と、評価額が1000万円以下で賢さが高い母を配合する場合に成立します。
  536.            精神力・賢さ・勝負根性・爆発力のアップが期待できます。
  537.        
  538.        サヨナラ配合
  539.            23歳以上で、同じ子系統の種牡馬がその地域(日本・米国・欧州)に1頭もいない父を配合する場合に成立します。
  540.            神力・健康・勝負根性・爆発力のアップが期待できます。
  541.    """
  542.     def __special_combination_check( self, sire_num, dam_num ):
  543.  
  544.         special = BreedingCombinationSpecials()
  545.        
  546.         sire_data = self.__wp.HSireTable.GetData( sire_num, HSireData() )
  547.         dam_data = self.__wp.HDamTable.GetData( dam_num, HDamData() )
  548.        
  549.         sire_abl = self.__wp.HAblTable.GetData( sire_data.abl_num, HAblData() )
  550.         dam_abl = self.__wp.HAblTable.GetData( dam_data.abl_num, HAblData() )
  551.        
  552.         sire_blood = self.__wp.HBloodTable.GetData( sire_data.blood_num, HBloodData() )
  553.         dam_blood = self.__wp.HBloodTable.GetData( dam_data.blood_num, HBloodData() )
  554.        
  555.         tanetsuke_price = ( sire_data.tanetsuke >> 1 ) * 100 + ( 50 if sire_data.tanetsuke & 0x1 == 1 else 0 )
  556.        
  557.         ## お笑い配合
  558.         if tanetsuke_price <= 100 and dam_data.price >= 100 :
  559.             special.owarai = True
  560.        
  561.         ## お似合い配合
  562.         if tanetsuke_price <= 200 and dam_data.price <= 20 :
  563.             if sire_abl.kashikosa == 3 and dam_abl.kashikosa == 3 :
  564.                 special.oniai = True
  565.        
  566.         ## サヨナラ配合 Wサヨナラ配合
  567.         if sire_data.age + 2 >= 23 and self.__family_line_cache[ sire_blood.family_line_num ].sire_count <= 1:
  568.             if dam_data.age + 2 >= 15 and self.is_reisai( self.__country, dam_blood.family_line_num ):
  569.                 special.wsayonara = True
  570.             else:
  571.                 special.sayonara = True
  572.        
  573.         ## 稲妻配合 真稲妻配合
  574.         if sire_abl.syunpatsu == 3 and sire_abl.konzyou <= 1 and dam_abl.syunpatsu == 3 and dam_abl.konzyou <= 1 :
  575.             is_ashige = lambda x : x >= 6 and x <= 9
  576.             if is_ashige( sire_abl.keiro ) and is_ashige( dam_abl.keiro ) :
  577.                 special.inazuma2 = True
  578.             else:
  579.                 special.inazuma1 = True
  580.        
  581.         ## 疾風配合 真疾風配合
  582.         if sire_abl.konzyou == 3 and sire_abl.syunpatsu <= 1 and dam_abl.konzyou == 3 and dam_abl.syunpatsu <= 1 :
  583.             if sire_abl.keiro == 1 and dam_abl.keiro == 1 :
  584.                 special.shippuu2 = True
  585.             else:
  586.                 special.shippuu1 = True
  587.        
  588.         ## 三冠配合
  589.         if dam_data.kachikura in Breeding.SANKAN_RACE_ID_LIST :
  590.             for kachikura in [ sire_data.kachikura_LT, sire_data.kachikura_LB, sire_data.kachikura_RT, sire_data.kachikura_RB ] :
  591.                 if kachikura in Breeding.SANKAN_RACE_ID_LIST :
  592.                     special.sankan = True
  593.                     break
  594.        
  595.         return special
  596.    
  597.    
  598.     ## ------------------------------------------------------------------
  599.     ## 活力源化種牡馬因子のチェック
  600.     ## ------------------------------------------------------------------
  601.     """
  602.        活力源化大種牡馬因子
  603.        父と母の先祖に「大種牡馬因子 」を持つ馬がいる場合に成立します。
  604.        因子の数に応じて爆発力がアップします。ただしインブリードが発生した場合は、効果が半減します。
  605.        
  606.        活力源化名種牡馬因子
  607.        父と母の先祖にそれぞれ「名種牡馬因子 」を持つ馬がいる場合に成立します。
  608.        因子の数に応じて爆発力がアップします。ただしインブリードが発生した場合は、効果が半減します。
  609.    """
  610.     def __activity_sire_factor_check( self ):
  611.         big_sire_factor_list   = []
  612.         small_sire_factor_list = []
  613.        
  614.         for padigree in [ self.__sire_pedigree, self.__dam_pedigree ] :
  615.             is_big   = False
  616.             is_small = False
  617.             for node in padigree :
  618.                 family_line = self.__family_line_cache[ node.data.family_line_num ].data
  619.                 if family_line.blood_num == node.blood_num :
  620.                     if family_line.family_line_num == node.data.family_line_num :
  621.                         big_sire_factor_list.append( node.blood_num )
  622.                         is_big = True
  623.                     else :
  624.                         small_sire_factor_list.append( node.blood_num )
  625.                         is_small = True
  626.            
  627.             if not is_big :
  628.                 big_sire_factor_list = []
  629.            
  630.             if not is_small :
  631.                 small_sire_factor_list = []
  632.            
  633.        
  634.         return tuple( big_sire_factor_list ), tuple( small_sire_factor_list )
  635.    
  636.    
  637.     ## ------------------------------------------------------------------
  638.     ## ライン活性配合のチェック
  639.     ## ------------------------------------------------------------------
  640.     def __line_activity_check( self ):
  641.         result = self.__sub_line_activity_check_male()
  642.        
  643.         if result != LineActivityEnum.NONE :
  644.             return result
  645.        
  646.         return self.__sub_line_activity_check_bottom()
  647.    
  648.    
  649.     ## ------------------------------------------------------------------
  650.     ## ボトムライン 活性配合
  651.     ## ------------------------------------------------------------------
  652.     """
  653.        --------------------------------------------------------
  654.        |             |             |   (こ)     | 父父父父    |
  655.        |             |             |   父父父   +-------------|
  656.        |             |             |            | 父父父母    |
  657.        |             |    父父     +------------+-------------|
  658.        |             |             |   (け)     | 父父母父    |
  659.        |             |             |   父父母   +-------------|
  660.        |  [零細]     |             |            | 父父母母    |
  661.        | 父          |-------------+------------+-------------|
  662.        |             |             |   (く)     | 父母父父    |
  663.        |             |             |   父母父   +-------------|
  664.        |             |             |            | 父母父母    |
  665.        |             |    父母     +------------+-------------|
  666.        |             |             |   (き)     | 父母母父    |
  667.        |             |             |   父母母   +-------------|
  668.        |             |             |            | 父母母母    |
  669.        |-------------+-------------+------------+-------------|
  670.        |             |             |   (か)     | 母父父父    |
  671.        |             |             |   母父父   +-------------|
  672.        |             |             |            | 母父父母    |
  673.        |             |    母父     +------------+-------------|
  674.        |             |             |   (お)     | 母父母父    |
  675.        |             |             |   母父母   +-------------|
  676.        |  (あ)       |             |            | 母父母母    |
  677.        | 母          +-------------+------------+-------------|
  678.        |             |             |   (え)     | 母母父父    |
  679.        |             |             |   母母父   +-------------|
  680.        |             |    (い)     |            | 母母父母    |
  681.        |             |    母母     +------------+-------------|
  682.        |             |             |   (う)     | 母母母父    |
  683.        |             |             |   母母母   +-------------|
  684.        |             |             |            | 母母母母    |
  685.        --------------------------------------------------------
  686.        
  687.        ボトムライン活性配合Lv1
  688.            父が「零細」で、母、母母、母母母が(あ・い・う)ともに流行か因子を持っている場合に成立します。
  689.        
  690.        ボトムライン活性配合Lv2
  691.            加えて、父方の3代前の先祖(こ・け・く・き)がすべて零細血統だとより効果が高くなります。
  692.        
  693.        ボトムライン活性配合Lv3
  694.            加えての母方の3代前の先祖(う・え・お・か)がすべて
  695.            流行血統だとさらに効果が高くなります
  696.    """
  697.     def __sub_line_activity_check_bottom( self ):
  698.         s_blood = self.__sire_pedigree.tree.data
  699.        
  700.         if not self.is_reisai( self.__country, s_blood.family_line_num ):
  701.             return LineActivityEnum.NONE
  702.            
  703.         ## Lv1のチェック
  704.         level = LineActivityEnum.NONE
  705.        
  706.         data = self.__dam_pedigree.tree.data
  707.        
  708.         ## (あ)の流行 or 因子チェック
  709.         if self.is_ryuukou( self.__country, data.family_line_num ) or ( data.factor_left <= 8 or data.factor_right <= 8 ) :
  710.            
  711.             ## (い),(う)の流行 or 因子チェック
  712.             checks = tuple([
  713.                 self.__dam_pedigree.tree.mother,
  714.                 self.__dam_pedigree.tree.mother.mother,
  715.             ])
  716.            
  717.             ## ボトムライン活性配合Lv1
  718.             level = LineActivityEnum.Bottom_1
  719.            
  720.             for node in checks :
  721.                 if not self.is_ryuukou( self.__country, node.data.family_line_num ) :
  722.                     if node.data.factor_left > 8 and node.data.factor_right > 8 :
  723.                         ## 無し
  724.                         level = LineActivityEnum.NONE
  725.        
  726.        
  727.         ## (こ),(け),(く),(き)の零細チェック
  728.         checks = tuple([
  729.             self.__sire_pedigree.tree.father.father,
  730.             self.__sire_pedigree.tree.father.mother,
  731.             self.__sire_pedigree.tree.mother.father,
  732.             self.__sire_pedigree.tree.mother.mother,
  733.         ])
  734.        
  735.         for node in checks :
  736.             if not self.is_reisai( self.__country, node.data.family_line_num ) :
  737.                 ## メールライン活性配合Lv1 or 無し
  738.                 return level
  739.        
  740.         ## (う),(え),(お),(か)の流行チェック((こ),(け),(く),(き)は零細確定済み)
  741.         checks = tuple([
  742.             self.__dam_pedigree.tree.mother.mother,
  743.             self.__dam_pedigree.tree.mother.father,
  744.             self.__dam_pedigree.tree.father.mother,
  745.             self.__dam_pedigree.tree.father.father,
  746.         ])
  747.        
  748.         for node in checks :
  749.             if not self.is_ryuukou( self.__country, node.data.family_line_num ) :
  750.                 ## メールライン活性配合Lv2
  751.                 return LineActivityEnum.Bottom_2
  752.        
  753.         ## メールライン活性配合Lv3
  754.         return LineActivityEnum.Bottom_3
  755.    
  756.    
  757.     ## ------------------------------------------------------------------
  758.     ## メールライン 活性配合
  759.     ## ------------------------------------------------------------------
  760.     """
  761.        --------------------------------------------------------
  762.        |             |             |   (け)     | 父父父父    |
  763.        |             |             |   父父父   +-------------|
  764.        |             |             |            | 父父父母    |
  765.        |             |    父父     +------------+-------------|
  766.        |             |             |   (く)     | 父父母父    |
  767.        |  [流行]     |             |   父父母   +-------------|
  768.        |             |             |            | 父父母母    |
  769.        | 父          |-------------+------------+-------------|
  770.        |             |             |   (き)     | 父母父父    |
  771.        |             |             |   父母父   +-------------|
  772.        |             |             |            | 父母父母    |
  773.        |             |    父母     +------------+-------------|
  774.        |             |             |   (か)     | 父母母父    |
  775.        |             |             |   父母母   +-------------|
  776.        |             |             |            | 父母母母    |
  777.        |-------------+-------------+------------+-------------|
  778.        |             |             |   (お)     | 母父父父    |
  779.        |             |             |   母父父   +-------------|
  780.        |             |             |            | 母父父母    |
  781.        |             |    母父     +------------+-------------|
  782.        |             |             |   (え)     | 母父母父    |
  783.        |             |             |   母父母   +-------------|
  784.        |  (あ)       |             |            | 母父母母    |
  785.        | 母          +-------------+------------+-------------|
  786.        |             |             |   (う)     | 母母父父    |
  787.        |             |             |   母母父   +-------------|
  788.        |             |             |            | 母母父母    |
  789.        |             |    母母     +------------+-------------|
  790.        |             |             |   (い)     | 母母母父    |
  791.        |             |             |   母母母   +-------------|
  792.        |             |             |            | 母母母母    |
  793.        --------------------------------------------------------
  794.        
  795.        メールライン活性配合Lv1
  796.            父が「流行」で、母、母母、母母母が(あ・い・う)ともに「零細」の場合に成立します。
  797.            
  798.        メールライン活性配合Lv2
  799.            加えて、母方の3代前の先祖(え・お)がすべて零細血統だとより効果が高くなります。
  800.  
  801.        メールライン活性配合Lv3
  802.            メールライン以外の3代前の先祖(い・う・え・お・か・き・く・け)がすべて零細血統だと
  803.            さらに効果が高くなります
  804.        
  805.        
  806.        > 88 名前:こんな名無しでは、どうしようもないよ。[sage] 投稿日:2012/03/30(金) 11:10:05.60 ID:wGxQ0LBn [1/2]
  807.        > sheep(とそのパクリブログ)の配合理論 2012の相違点
  808.        > メールラインLV3→父父父は流行でもよい
  809.        
  810.        ×流行でもよい
  811.        ○零細で無くてもよい
  812.    """
  813.     def __sub_line_activity_check_male( self ):
  814.         s_blood = self.__sire_pedigree.tree.data
  815.        
  816.         if not self.is_ryuukou( self.__country, s_blood.family_line_num ):
  817.             return LineActivityEnum.NONE
  818.            
  819.         ## Lv1のチェック
  820.         level = LineActivityEnum.NONE
  821.        
  822.         ## (あ)の零細チェック
  823.         if self.is_reisai( self.__country, self.__dam_pedigree.tree.data.family_line_num ) :
  824.             ## (い),(う)の零細チェック
  825.             checks = tuple([
  826.                 self.__dam_pedigree.tree.mother.mother,
  827.                 self.__dam_pedigree.tree.mother.father,
  828.             ])
  829.            
  830.             ## メールライン活性配合Lv1
  831.             level = LineActivityEnum.Male_1
  832.            
  833.             for node in checks :
  834.                 if not self.is_reisai( self.__country, node.data.family_line_num ) :
  835.                     level = LineActivityEnum.NONE
  836.        
  837.        
  838.         ## (い),(う),(え),(お)の零細チェック
  839.         checks = tuple([
  840.             self.__dam_pedigree.tree.mother.mother,
  841.             self.__dam_pedigree.tree.mother.father,
  842.             self.__dam_pedigree.tree.father.mother,
  843.             self.__dam_pedigree.tree.father.father,
  844.         ])
  845.        
  846.         for node in checks :
  847.             if not self.is_reisai( self.__country, node.data.family_line_num ) :
  848.                 ## メールライン活性配合Lv1 or 無し
  849.                 return level
  850.        
  851.         ## (か),(き),(く),(け)の零細チェック((い),(う),(え),(お)は零細確定済み)
  852.         checks = tuple([
  853.             self.__sire_pedigree.tree.mother.mother,
  854.             self.__sire_pedigree.tree.mother.father,
  855.             self.__sire_pedigree.tree.father.mother,
  856.             ## (け)は零細の必要は無くなった
  857.             #self.__sire_pedigree.tree.father.father,
  858.         ])
  859.        
  860.         for node in checks :
  861.             if not self.is_reisai( self.__country, node.data.family_line_num ) :
  862.                 ## メールライン活性配合Lv2
  863.                 return LineActivityEnum.Male_2
  864.        
  865.         ## メールライン活性配合Lv3
  866.         return LineActivityEnum.Male_3
  867.    
  868.    
  869.     ## ------------------------------------------------------------------
  870.     ## 隔世遺伝
  871.     ## ------------------------------------------------------------------
  872.     """
  873.        --------------------------------------------------------
  874.        |             |             |            | 父父父父    |
  875.        |             |             |   父父父   +-------------|
  876.        |             |    (う)     |            | 父父父母    |
  877.        |             |    父父     +------------+-------------|
  878.        |             |             |            | 父父母父    |
  879.        |             |             |   父父母   +-------------|
  880.        | (あ)        |             |            | 父父母母    |
  881.        | 父          |-------------+------------+-------------|
  882.        |             |             |            | 父母父父    |
  883.        |             |             |   父母父   +-------------|
  884.        |             |             |            | 父母父母    |
  885.        |             |    父母     +------------+-------------|
  886.        |             |             |            | 父母母父    |
  887.        |             |             |   父母母   +-------------|
  888.        |             |             |            | 父母母母    |
  889.        |-------------+-------------+------------+-------------|
  890.        |             |             |            | 母父父父    |
  891.        |             |             |   母父父   +-------------|
  892.        |             |    (え)     |            | 母父父母    |
  893.        |             |    母父     +------------+-------------|
  894.        |             |             |            | 母父母父    |
  895.        |             |             |   母父母   +-------------|
  896.        | (い)        |             |            | 母父母母    |
  897.        | 母          +-------------+------------+-------------|
  898.        |             |             |            | 母母父父    |
  899.        |             |             |   母母父   +-------------|
  900.        |             |             |            | 母母父母    |
  901.        |             |    母母     +------------+-------------|
  902.        |             |             |            | 母母母父    |
  903.        |             |             |   母母母   +-------------|
  904.        |             |             |            | 母母母母    |
  905.        --------------------------------------------------------
  906.  
  907.        父と母(あ・い)がともに因子を持たず、祖父 (う・え)が因子を持っている場合に成立します。
  908.        父 と母の祖父とも因子を持っている場合は、父方の祖父(う)が優先され、母方の祖父 (え)は影響しません。
  909.        祖父の持つ因子の能力がアップします。(SP因子を持っている場合は爆発力がアップします)
  910.    """
  911.     def __kakusei_iden_check( self ):
  912.         s_blood = self.__sire_pedigree.tree.data
  913.         d_blood = self.__dam_pedigree.tree.data
  914.        
  915.         ## (あ),(い)の因子チェック
  916.         if s_blood.factor_left <= 8 or s_blood.factor_right <= 8 or d_blood.factor_left <= 8 :
  917.             return ()
  918.        
  919.         ## (う),(え)の因子チェック
  920.         for blood in [ self.__sire_pedigree.tree.father.data, self.__dam_pedigree.tree.father.data ]:
  921.             if blood.factor_left <= 8 :
  922.                 factors = []
  923.                 factors.append( blood.factor_left )
  924.                 if blood.factor_right <= 8 :
  925.                     factors.append( blood.factor_right )
  926.                
  927.                 return tuple( factors )
  928.        
  929.         return ()
  930.    
  931.    
  932.     ## ------------------------------------------------------------------
  933.     ## 活力補完
  934.     ## ------------------------------------------------------------------
  935.     """
  936.        ---------------------------------------------------
  937.        |        |             |  (あ)      | 父父父父    |
  938.        |        |             |   父父父   +-------------|
  939.        |        |             |            | 父父父母    |
  940.        |        |    父父     +------------+-------------|
  941.        |        |             |  (い)      | 父父母父    |
  942.        |        |             |   父父母   +-------------|
  943.        |        |             |            | 父父母母    |
  944.        | 父     |-------------+------------+-------------|
  945.        |        |             |  (う)      | 父母父父    |
  946.        |        |             |   父母父   +-------------|
  947.        |        |             |            | 父母父母    |
  948.        |        |    父母     +------------+-------------|
  949.        |        |             |  (え)      | 父母母父    |
  950.        |        |             |   父母母   +-------------|
  951.        |        |             |            | 父母母母    |
  952.        |--------+-------------+------------+-------------|
  953.        |        |             |  (お)      | 母父父父    |
  954.        |        |             |   母父父   +-------------|
  955.        |        |             |            | 母父父母    |
  956.        |        |    母父     +------------+-------------|
  957.        |        |             |  (か)      | 母父母父    |
  958.        |        |             |   母父母   +-------------|
  959.        |        |             |            | 母父母母    |
  960.        | 母     +-------------+------------+-------------|
  961.        |        |             |  (き)      | 母母父父    |
  962.        |        |             |   母母父   +-------------|
  963.        |        |             |            | 母母父母    |
  964.        |        |    母母     +------------+-------------|
  965.        |        |             |  (く)      | 母母母父    |
  966.        |        |             |   母母母   +-------------|
  967.        |        |             |            | 母母母母    |
  968.        ---------------------------------------------------
  969.        
  970.        *名種牡馬型活力補完
  971.            3代前先祖馬の中に、大種牡馬因子や名種牡馬因子を持つ(つまり系統を確立している)種牡馬がいる場合に成立します。
  972.            種牡馬の数に比例して、競走寿命のアップが期待できます。
  973.            
  974.        *名牝型活力補完
  975.            3代前先祖馬の中に、因子を持つ繁殖牝馬がいる場合に成立します。
  976.            繁殖牝馬の数に比例して、競走寿命のアップが期待できます。
  977.            
  978.        *異系血脈型活力補完
  979.            3代前先祖馬の中に、零細血統の馬がいる場合に成立します。
  980.            馬の数に比例して、競走寿命のアップが期待できます。
  981.            
  982.        *完全型活力補完
  983.            3代前先祖馬すべてが、上記のいずれかの活力補完の対象になっている場合に成立します。
  984.    """
  985.     def __katsuryoku_complate_check( self ):
  986.         ## 名種牡馬型活力補完
  987.         katsuryoku_complate_1 = 0
  988.        
  989.         ## 名牝型活力補完
  990.         katsuryoku_complate_2 = 0
  991.        
  992.         ## 異系血脈型活力補完
  993.         katsuryoku_complate_3 = 0
  994.        
  995.         ## 完全型活力補完
  996.         all_katsuryoku_complate = True
  997.        
  998.        
  999.         ## (あ)~(え), (お)~(く)
  1000.         for padigree in [ self.__sire_pedigree, self.__dam_pedigree ] :
  1001.             for node in padigree :
  1002.                 if node.level != 2 :
  1003.                     continue
  1004.  
  1005.                 match = False
  1006.                
  1007.                 family_line_cache = self.__family_line_cache[ node.data.family_line_num ]
  1008.                
  1009.                 if node.ptype == PedigreeTypeEnum.SIRE :
  1010.                     if family_line_cache.data.blood_num == node.blood_num :
  1011.                         katsuryoku_complate_1 += 1
  1012.                         match = True
  1013.                    
  1014.                 elif node.ptype == PedigreeTypeEnum.MARE :
  1015.                     if node.data.factor_left <= 8 :
  1016.                         katsuryoku_complate_2 += 1
  1017.                         match = True
  1018.                 else :
  1019.                     raise Exception, "[BUG]"
  1020.                
  1021.                 if self.is_reisai( self.__country, node.data.family_line_num ) :
  1022.                     katsuryoku_complate_3 += 1
  1023.                     match = True
  1024.                
  1025.                 if match == False :
  1026.                     all_katsuryoku_complate = False
  1027.        
  1028.         return katsuryoku_complate_1, katsuryoku_complate_2, katsuryoku_complate_3, all_katsuryoku_complate
  1029.    
  1030.    
  1031.     ## ------------------------------------------------------------------
  1032.     ## 母父チェック
  1033.     ## ------------------------------------------------------------------
  1034.     """
  1035.        88 こんな名無しでは、どうしようもないよ。 sage 2012/03/30(金) 11:10:05.60 ID:wGxQ0LBn
  1036.        sheep(とそのパクリブログ)の配合理論 2012の相違点
  1037.  
  1038.        母父◎○→大種牡馬も名種牡馬も爆発力は(能力系因子×2)
  1039.                能力系因子2つ持ちは爆発力4 1つ持ちは爆発力2
  1040.    """
  1041.     def __bms_check( self ):
  1042.         blood = self.__dam_pedigree.tree.data
  1043.         father_blood = self.__wp.HBloodTable.GetData( blood.father_num, HBloodData() )
  1044.  
  1045.         family_line_cache = self.__family_line_cache[ father_blood.family_line_num ]
  1046.        
  1047.         if family_line_cache.data.blood_num != blood.father_num :
  1048.             return BMSEnum.NONE
  1049.        
  1050.         factor_count = 0
  1051.         factor_count += 1 if father_blood.factor_left  <= 8 else 0
  1052.         factor_count += 1 if father_blood.factor_right <= 8 else 0
  1053.        
  1054.         return {
  1055.             1 : BMSEnum.Type_1,
  1056.             2 : BMSEnum.Type_2,
  1057.         }.get( factor_count, BMSEnum.NONE )
  1058.    
  1059.    
  1060.     ## ------------------------------------------------------------------
  1061.     ## SPST融合配合チェック
  1062.     ## ------------------------------------------------------------------
  1063.     """
  1064.        ---------------------------------------------------
  1065.        |        |             |  (あ)      | 父父父父    |
  1066.        |        |             |   父父父   +-------------|
  1067.        |        |             |            | 父父父母    |
  1068.        |        |    父父     +------------+-------------|
  1069.        |        |             |  (い)      | 父父母父    |
  1070.        |        |             |   父父母   +-------------|
  1071.        |        |             |            | 父父母母    |
  1072.        | 父     |-------------+------------+-------------|
  1073.        |        |             |  (う)      | 父母父父    |
  1074.        |        |             |   父母父   +-------------|
  1075.        |        |             |            | 父母父母    |
  1076.        |        |    父母     +------------+-------------|
  1077.        |        |             |  (え)      | 父母母父    |
  1078.        |        |             |   父母母   +-------------|
  1079.        |        |             |            | 父母母母    |
  1080.        |--------+-------------+------------+-------------|
  1081.        |        |             |  (お)      | 母父父父    |
  1082.        |        |             |   母父父   +-------------|
  1083.        |        |             |            | 母父父母    |
  1084.        |        |    母父     +------------+-------------|
  1085.        |        |             |  (か)      | 母父母父    |
  1086.        |        |             |   母父母   +-------------|
  1087.        |        |             |            | 母父母母    |
  1088.        | 母     +-------------+------------+-------------|
  1089.        |        |             |  (き)      | 母母父父    |
  1090.        |        |             |   母母父   +-------------|
  1091.        |        |             |            | 母母父母    |
  1092.        |        |    母母     +------------+-------------|
  1093.        |        |             |  (く)      | 母母母父    |
  1094.        |        |             |   母母母   +-------------|
  1095.        |        |             |            | 母母母母    |
  1096.        ---------------------------------------------------
  1097.        父方の3代前のすべての先祖(あ・い・う・え)がSP系統で、
  1098.        母方の3代前のすべての先祖(お・か・き・く)がST系統の場合に成立します(逆でも可)
  1099.        牝馬は、いずれかの因子を持っていれば、系統特性(SP系統・ST系統)でなくてもかまいません。
  1100.        爆発力・パワーのアップが期待できます。
  1101.    """
  1102.     def __attr_fision_combination_check( self ):
  1103.        
  1104.         attr = None
  1105.        
  1106.         for node in self.__sire_pedigree :
  1107.             if node.level == 2 :
  1108.                 family_line_cache = self.__family_line_cache[ node.data.family_line_num ]
  1109.                
  1110.                 if attr == None :
  1111.                     attr = family_line_cache.data.family_line_attr
  1112.                    
  1113.                     if attr != 1 and attr != 2 :
  1114.                         return False
  1115.                
  1116.                 elif family_line_cache.data.family_line_attr != attr :
  1117.                     return False
  1118.        
  1119.         attr   = 1 if attr == 2 else 2
  1120.         factor = 0 if attr == 1 else 1
  1121.        
  1122.         for node in self.__dam_pedigree :
  1123.             if node.level == 2 :
  1124.                 family_line_cache = self.__family_line_cache[ node.data.family_line_num ]
  1125.                
  1126.                 if family_line_cache.data.family_line_attr != 1 and family_line_data.family_line_attr != 2 :
  1127.                     return False
  1128.                
  1129.                 if family_line_cache.data.family_line_attr != attr :
  1130.                     if node.ptype != PedigreeTypeEnum.MARE :
  1131.                         return False
  1132.                    
  1133.                     if node.data.factor_left != factor :
  1134.                         return False
  1135.        
  1136.         return True
  1137.    
  1138.    
  1139.     ## ------------------------------------------------------------------
  1140.     ## SP|ST 昇華配合チェック
  1141.     ## ------------------------------------------------------------------
  1142.     """
  1143.        ---------------------------------------------------
  1144.        |        |             |  (き)      | 父父父父    |
  1145.        |        |             |   父父父   +-------------|
  1146.        |        |    (う)     |            | 父父父母    |
  1147.        |        |    父父     +------------+-------------|
  1148.        |        |             |  (く)      | 父父母父    |
  1149.        |        |             |   父父母   +-------------|
  1150.        | (あ)   |             |            | 父父母母    |
  1151.        | 父     |-------------+------------+-------------|
  1152.        |        |             |  (け)      | 父母父父    |
  1153.        |        |             |   父母父   +-------------|
  1154.        |        |    (え)     |            | 父母父母    |
  1155.        |        |    父母     +------------+-------------|
  1156.        |        |             |  (こ)      | 父母母父    |
  1157.        |        |             |   父母母   +-------------|
  1158.        |        |             |            | 父母母母    |
  1159.        |--------+-------------+------------+-------------|
  1160.        |        |             |  (さ)      | 母父父父    |
  1161.        |        |             |   母父父   +-------------|
  1162.        |        |    (お)     |            | 母父父母    |
  1163.        |        |    母父     +------------+-------------|
  1164.        |        |             |  (し)      | 母父母父    |
  1165.        |        |             |   母父母   +-------------|
  1166.        | (い)   |             |            | 母父母母    |
  1167.        | 母     +-------------+------------+-------------|
  1168.        |        |             |  (す)      | 母母父父    |
  1169.        |        |             |   母母父   +-------------|
  1170.        |        |    (か)     |            | 母母父母    |
  1171.        |        |    母母     +------------+-------------|
  1172.        |        |             |  (せ)      | 母母母父    |
  1173.        |        |             |   母母母   +-------------|
  1174.        |        |             |            | 母母母母    |
  1175.        ---------------------------------------------------
  1176.        
  1177.        父、母(あ・い)がともに SP|ST 系統の場合に成立します (レベル1)。
  1178.        爆発力のアップが期待できます。繁殖牝馬は、いずれかの因子を持っていれば、SP系統でなくてもかまいません。
  1179.        加えて、2代前のすべての先祖(う・え・お・か)が SP|ST 系統だとより効果が高く(レベル2)
  1180.        3代前のすべての先祖(き・ く・け・こ・さ・し・す・せ)が SP|ST 系統だとより効果が高くなります(レベル3)
  1181.        レベル3の場合は、瞬発力のアップも期待できます。
  1182.    """
  1183.     def __attr_combination_check( self, attr ):
  1184.        
  1185.         class NOMATCH(Exception):
  1186.             pass
  1187.        
  1188.         s_family_line_cache = self.__family_line_cache[ self.__sire_pedigree.tree.data.family_line_num ]
  1189.         d_family_line_cache = self.__family_line_cache[ self.__dam_pedigree.tree.data.family_line_num ]
  1190.        
  1191.         if s_family_line_cache.data.family_line_attr != attr or d_family_line_cache.data.family_line_attr != attr :
  1192.             ## SP|ST昇華配合無し
  1193.             return AttrCombinationEnum.NONE
  1194.        
  1195.         ## (う)~(か)までを調べる
  1196.         try:
  1197.             for node in self.__sire_pedigree :
  1198.                 if node.level == 1 :
  1199.                     family_line_data = self.__wp.HFamilyLineTable.GetData( node.data.family_line_num, HFamilyLineData() )
  1200.                     if family_line_data.family_line_attr != attr :
  1201.                         raise NOMATCH
  1202.            
  1203.             for node in self.__dam_pedigree :
  1204.                 if node.level == 1 :
  1205.                     family_line_data = self.__wp.HFamilyLineTable.GetData( node.data.family_line_num, HFamilyLineData() )
  1206.                     if family_line_data.family_line_attr != attr :
  1207.                         raise NOMATCH
  1208.            
  1209.         except NOMATCH:
  1210.             ## SP|ST昇華配合Lv1
  1211.             return AttrCombinationEnum.Type_1
  1212.            
  1213.  
  1214.         ## (き)~(せ)までを調べる
  1215.         try:
  1216.             for node in self.__sire_pedigree :
  1217.                 if node.level == 2 :
  1218.                     family_line_data = self.__wp.HFamilyLineTable.GetData( node.data.family_line_num, HFamilyLineData() )
  1219.                     if family_line_data.family_line_attr != attr :
  1220.                         raise NOMATCH
  1221.            
  1222.             for node in self.__dam_pedigree :
  1223.                 if node.level == 2 :
  1224.                     family_line_data = self.__wp.HFamilyLineTable.GetData( node.data.family_line_num, HFamilyLineData() )
  1225.                     if family_line_data.family_line_attr != attr :
  1226.                         raise NOMATCH
  1227.            
  1228.         except NOMATCH:
  1229.             ## SP|ST昇華配合Lv2
  1230.             return AttrCombinationEnum.Type_2
  1231.        
  1232.         ## SP|ST昇華配合Lv3
  1233.         return AttrCombinationEnum.Type_3
  1234.    
  1235.    
  1236.     ## ------------------------------------------------------------------
  1237.     ## 血脈活性化配合チェック
  1238.     ## ------------------------------------------------------------------
  1239.     """
  1240.        ---------------------------------------------------
  1241.        |        |             |  ※        | 父父父父    |
  1242.        |        |             |   父父父   +-------------|
  1243.        |        |             |            | 父父父母    |
  1244.        |        |    父父     +------------+-------------|
  1245.        |        |             |  ※        | 父父母父    |
  1246.        |        |             |   父父母   +-------------|
  1247.        |        |             |            | 父父母母    |
  1248.        | 父     |-------------+------------+-------------|
  1249.        |        |             |  ※        | 父母父父    |
  1250.        |        |             |   父母父   +-------------|
  1251.        |        |             |            | 父母父母    |
  1252.        |        |    父母     +------------+-------------|
  1253.        |        |             |  ※        | 父母母父    |
  1254.        |        |             |   父母母   +-------------|
  1255.        |        |             |            | 父母母母    |
  1256.        |--------+-------------+------------+-------------|
  1257.        |        |             |  ※        | 母父父父    |
  1258.        |        |             |   母父父   +-------------|
  1259.        |        |             |            | 母父父母    |
  1260.        |        |    母父     +------------+-------------|
  1261.        |        |             |  ※        | 母父母父    |
  1262.        |        |             |   母父母   +-------------|
  1263.        |        |             |            | 母父母母    |
  1264.        | 母     +-------------+------------+-------------|
  1265.        |        |             |  ※        | 母母父父    |
  1266.        |        |             |   母母父   +-------------|
  1267.        |        |             |            | 母母父母    |
  1268.        |        |    母母     +------------+-------------|
  1269.        |        |             |  ※        | 母母母父    |
  1270.        |        |             |   母母母   +-------------|
  1271.        |        |             |            | 母母母母    |
  1272.        ---------------------------------------------------
  1273.        
  1274.        3代前の先祖馬の親系統が6種類以上の場合成立する。
  1275.        親系統の数に応じて爆発力がアップします。また同時にインブリードを成立させた場合、
  1276.        インブリードによるデメリットが少なくなります。
  1277.        (インブリードが3×4より薄い場合)7本型以上の場合はデメリットがなくなります。
  1278.    """
  1279.     def __blood_activity_check( self ):
  1280.         activity_blood_list = []
  1281.            
  1282.         for node in self.__sire_pedigree :
  1283.             if node.level == 2 :
  1284.                 activity_blood_list.append( node )
  1285.        
  1286.         for node in self.__dam_pedigree :
  1287.             if node.level == 2 :
  1288.                 activity_blood_list.append( node )
  1289.        
  1290.         parent_family_line_list = []
  1291.        
  1292.         for node in activity_blood_list:
  1293.             family_line_cache = self.__family_line_cache[ node.data.family_line_num ]
  1294.             parent_family_line_list.append( int(family_line_cache.data.family_line_num) )
  1295.        
  1296.         ## uniq
  1297.         parent_family_line_list = sorted( set( parent_family_line_list ), key = parent_family_line_list.index )
  1298.        
  1299.         return {
  1300.             6 : BloodActivityEnum.Type_1, # 血脈活性化配合6本型
  1301.             7 : BloodActivityEnum.Type_2, # 血脈活性化配合7本型
  1302.             8 : BloodActivityEnum.Type_3, # 血脈活性化配合8本型
  1303.         }.get( len(parent_family_line_list), BloodActivityEnum.NONE )
  1304.    
  1305.    
  1306.     ## ------------------------------------------------------------------
  1307.     ## ニックスのチェックをする
  1308.     ## ------------------------------------------------------------------
  1309.     """
  1310.        ---------------------------------------------------
  1311.        |        |             |            | 父父父父    |
  1312.        |        |             |   父父父   +-------------|
  1313.        |        |             |            | 父父父母    |
  1314.        |        |    父父     +------------+-------------|
  1315.        |        |             |            | 父父母父    |
  1316.        |        |             |   父父母   +-------------|
  1317.        |  (あ)  |             |            | 父父母母    |
  1318.        | 父     |-------------+------------+-------------|
  1319.        |        |             |            | 父母父父    |
  1320.        |        |             |   父母父   +-------------|
  1321.        |        |             |            | 父母父母    |
  1322.        |        |    父母     +------------+-------------|
  1323.        |        |             |            | 父母母父    |
  1324.        |        |             |   父母母   +-------------|
  1325.        |        |             |            | 父母母母    |
  1326.        |--------+-------------+------------+-------------|
  1327.        |        |             |            | 母父父父    |
  1328.        |        |             |   母父父   +-------------|
  1329.        |        |     (い)    |            | 母父父母    |
  1330.        |        |    母父     +------------+-------------|
  1331.        |        |             |            | 母父母父    |
  1332.        |        |             |   母父母   +-------------|
  1333.        |        |             |            | 母父母母    |
  1334.        | 母     +-------------+------------+-------------|
  1335.        |        |             |     (う)   | 母母父父    |
  1336.        |        |             |   母母父   +-------------|
  1337.        |        |             |            | 母母父母    |
  1338.        |        |    母母     +------------+-------------|
  1339.        |        |             |            | 母母母父(え)|
  1340.        |        |             |   母母母   +-------------|
  1341.        |        |             |            | 母母母母(お)|
  1342.        ---------------------------------------------------
  1343.        
  1344.        父と母父の子系統がニックス対象の場合成立します。
  1345.        
  1346.        シングルニックス        母父(い)
  1347.        ダブルニックス          母父(い)/母母父 (う)
  1348.        トリプルニックス        母父(い)/母母父 (う)/母母母父(え)
  1349.        フォースニックス        母父(い)/母母父 (う)/母母母父(え)/母母母母(お)
  1350.        2次ニックス             母母父 (う)
  1351.        3次ニックス             母母母父(え)
  1352.        4次ニックス             母母母母(お)
  1353.    """
  1354.     def __nicks_check( self ):
  1355.         sire_family_line_num = self.__sire_pedigree.tree.data.family_line_num
  1356.        
  1357.         family_line_cache = self.__family_line_cache[ sire_family_line_num ]
  1358.        
  1359.         nicks_family_line_nums = []
  1360.        
  1361.         nicks_ary = [
  1362.             family_line_cache.data.nicks_1_num,
  1363.             family_line_cache.data.nicks_2_num,
  1364.             family_line_cache.data.nicks_3_num,
  1365.             family_line_cache.data.nicks_4_num,
  1366.             family_line_cache.data.nicks_5_num,
  1367.             family_line_cache.data.nicks_6_num,
  1368.             family_line_cache.data.nicks_7_num,
  1369.             family_line_cache.data.nicks_8_num,
  1370.             family_line_cache.data.nicks_9_num,
  1371.             family_line_cache.data.nicks_10_num,
  1372.         ]
  1373.  
  1374.         for family_line_num in nicks_ary:
  1375.             # pythonのevalはめちゃくちゃ遅い
  1376.             # family_line_num =  eval( sprintf( "family_line_cache.data.nicks_%d_num", i ) )
  1377.             if family_line_num != self.__wp.Config.NullFamilyLineNumber :
  1378.                 nicks_family_line_nums.append( family_line_num )
  1379.        
  1380.         target_family_line_nums = [None] * 4
  1381.        
  1382.         for node in self.__dam_pedigree :
  1383.             if node.ptype != PedigreeTypeEnum.MARE :
  1384.                 continue
  1385.            
  1386.             if node.line.find( Pedigree.SIRE_SIGN ) == -1 :
  1387.                 target_family_line_nums[ node.level ] = node.data.family_line_num
  1388.        
  1389.         match_count = 0
  1390.        
  1391.         for family_line_num in target_family_line_nums :
  1392.             if not (family_line_num in nicks_family_line_nums) :
  1393.                 break
  1394.             match_count += 1
  1395.        
  1396.         if match_count > 0 :
  1397.             result = {
  1398.                 1 : NicksEnum.Type_1, ## シングルニックス
  1399.                 2 : NicksEnum.Type_2, ## ダブルニックス
  1400.                 3 : NicksEnum.Type_3, ## トリプルニックス
  1401.                 4 : NicksEnum.Type_4, ## フォースニックス
  1402.             }.get( match_count, NicksEnum.NONE )
  1403.            
  1404.             return ( result, )
  1405.        
  1406.         result = []
  1407.        
  1408.         ## 二次ニックス
  1409.         if target_family_line_nums[1] in nicks_family_line_nums :
  1410.             result.append( NicksEnum.Type_5 )
  1411.    
  1412.         ## 三次ニックス
  1413.         if target_family_line_nums[2] in nicks_family_line_nums :
  1414.             result.append( NicksEnum.Type_6 )
  1415.    
  1416.         ## 四次ニックス
  1417.         if target_family_line_nums[3] in nicks_family_line_nums :
  1418.             result.append( NicksEnum.Type_7 )
  1419.    
  1420.         return tuple( result )
  1421.    
  1422.    
  1423.     ## ------------------------------------------------------------------
  1424.     ## インブリードのチェックをする
  1425.     ## ------------------------------------------------------------------
  1426.     def __inbreed_check( self ):
  1427.         inbreed_list = []
  1428.        
  1429.         memo = []
  1430.        
  1431.         for node in self.__dam_pedigree :
  1432.             memo.append( node.blood_num )
  1433.        
  1434.         memo = sorted( set(memo), key = memo.index )
  1435.            
  1436.         for node1 in self.__sire_pedigree :
  1437.             if node1.blood_num in memo :
  1438.                 for node2 in self.__dam_pedigree :
  1439.                     if node1.blood_num == node2.blood_num :
  1440.                         inbreed_list.append( InBreed( pedigree_node = node1, sire_level = node1.level, mare_level = node2.level  ) )
  1441.        
  1442.         return tuple( inbreed_list )
  1443.    
  1444.    
  1445.     ## ------------------------------------------------------------------
  1446.     ## ラインブリードのチェックをする
  1447.     ## ------------------------------------------------------------------
  1448.     """
  1449.        --------------------------------------------------
  1450.        |        |             |    (あ)    | 父父父父   |
  1451.        |        |             |   父父父   +------------|
  1452.        |        |             |            | 父父父母   |
  1453.        |        |    父父     +------------+------------|
  1454.        |        |             |            | 父父母父   |
  1455.        |        |             |   父父母   +------------|
  1456.        |        |             |            | 父父母母   |
  1457.        | 父     |-------------+------------+------------|
  1458.        |        |             |    (い)    | 父母父父   |
  1459.        |        |             |   父母父   +------------|
  1460.        |        |             |            | 父母父母   |
  1461.        |        |    父母     +------------+------------|
  1462.        |        |             |            | 父母母父   |
  1463.        |        |             |   父母母   +------------|
  1464.        |        |             |            | 父母母母   |
  1465.        |--------+-------------+------------+------------|
  1466.        |        |             |    (う)    | 母父父父   |
  1467.        |        |             |   母父父   +------------|
  1468.        |        |             |            | 母父父母   |
  1469.        |        |    母父     +------------+------------|
  1470.        |        |             |            | 母父母父   |
  1471.        |        |             |   母父母   +------------|
  1472.        |        |             |            | 母父母母   |
  1473.        | 母     +-------------+------------+------------|
  1474.        |        |             |    (え)    | 母母父父   |
  1475.        |        |             |   母母父   +------------|
  1476.        |        |             |            | 母母父母   |
  1477.        |        |    母母     +------------+------------|
  1478.        |        |             |            | 母母母父   |
  1479.        |        |             |   母母母   +------------|
  1480.        |        |             |            | 母母母母   |
  1481.        --------------------------------------------------
  1482.    """
  1483.     def __linebreed_check( self ):
  1484.         # ラインブリード対象になる血統を取得
  1485.         linebreed_blood_list = []
  1486.            
  1487.         for node in self.__sire_pedigree :
  1488.             if node.level == 2 and node.ptype == PedigreeTypeEnum.SIRE:
  1489.                 linebreed_blood_list.append( node )
  1490.        
  1491.         for node in self.__dam_pedigree :
  1492.             if node.level == 2 and node.ptype == PedigreeTypeEnum.SIRE:
  1493.                 linebreed_blood_list.append( node )
  1494.        
  1495.        
  1496.         blood1 = self.__wp.HBloodTable.GetData( linebreed_blood_list[0].blood_num, HBloodData() )
  1497.         blood2 = self.__wp.HBloodTable.GetData( linebreed_blood_list[1].blood_num, HBloodData() )
  1498.         blood3 = self.__wp.HBloodTable.GetData( linebreed_blood_list[2].blood_num, HBloodData() )
  1499.         blood4 = self.__wp.HBloodTable.GetData( linebreed_blood_list[3].blood_num, HBloodData() )
  1500.  
  1501.         child_line1 = self.__wp.HFamilyLineTable.GetData( blood1.family_line_num, HFamilyLineData() )
  1502.         child_line2 = self.__wp.HFamilyLineTable.GetData( blood2.family_line_num, HFamilyLineData() )
  1503.         child_line3 = self.__wp.HFamilyLineTable.GetData( blood3.family_line_num, HFamilyLineData() )
  1504.         child_line4 = self.__wp.HFamilyLineTable.GetData( blood4.family_line_num, HFamilyLineData() )
  1505.        
  1506.         ary = [
  1507.             child_line1.family_line_num,
  1508.             child_line2.family_line_num,
  1509.             child_line3.family_line_num,
  1510.             child_line4.family_line_num,
  1511.         ]
  1512.        
  1513.         parent_line_match_count = 1
  1514.        
  1515.         ## 出現率の1番多い親系統の数を数える
  1516.         for i in range( 0, len(ary) ) :
  1517.             temp = 1
  1518.             for ii in range( 0, len(ary) ):
  1519.                 if i != ii and ary[i] == ary[ii]:
  1520.                     temp += 1
  1521.            
  1522.             if temp > parent_line_match_count :
  1523.                 parent_line_match_count = temp
  1524.        
  1525.         ## 親系統ラインブリード爆発型のチェック
  1526.         if parent_line_match_count >= 3 :
  1527.             ary = [
  1528.                 blood1.family_line_num,
  1529.                 blood2.family_line_num,
  1530.                 blood3.family_line_num,
  1531.                 blood4.family_line_num,
  1532.             ]
  1533.            
  1534.             ## 重複した値を排除する
  1535.             ary = sorted( set(ary), key = ary.index )
  1536.            
  1537.             ## 3代目先祖の種牡馬4頭(あ・い・う・え)の親系統が全て同じで、
  1538.             ## 子系統がすべて違う場合に成立します。
  1539.             ## 父の特性がSPの場合は「親系統ラインブリード4本爆発SP型」になります
  1540.             if parent_line_match_count == 4 and len( ary ) == 4 :
  1541.                 if child_line1.family_line_attr == 1 :
  1542.                     ## 親系統ラインブリード4本爆発SP型
  1543.                     return LineBreedEnum.Type_1
  1544.                 else :
  1545.                     ## 親系統ラインブリード4本爆発型
  1546.                     return LineBreedEnum.Type_2
  1547.            
  1548.             ## 3代目先祖の種牡馬4頭(あ・い・う・え)の うち、3頭の親系統が全て同じで、
  1549.             ## 子系統がすべて違う場合に成立します。
  1550.             ## 父の特性がSPの場合は「親系統ラインブリード3本爆発SP型」になります。
  1551.             if parent_line_match_count == 3  and len( ary ) == 4 :
  1552.                 if child_line1.family_line_attr == 1 :
  1553.                     ## 親系統ラインブリード3本爆発SP型
  1554.                     return LineBreedEnum.Type_3
  1555.                 else :
  1556.                     ## 親系統ラインブリード3本爆発型
  1557.                     return LineBreedEnum.Type_4
  1558.        
  1559.         ## 子系統ラインブリード
  1560.         ## --
  1561.         ## 父母ともに、同じ子系統の場合成立します。
  1562.         ## 父の特性がSPの場合は「子系統ラインブリードSP型 」になります。
  1563.         ## 3代前の祖先8頭のうち、親系統の種類が5より多いい場合は危険度が下がります。
  1564.         ## --
  1565.         if blood1.family_line_num == blood3.family_line_num :
  1566.             if child_line1.family_line_attr == 1 :
  1567.                 ## 子系統ラインブリードSP型
  1568.                 return LineBreedEnum.Type_5
  1569.             else :
  1570.                 ## 子系統ラインブリード
  1571.                 return LineBreedEnum.Type_6
  1572.  
  1573.         ## 親系統ラインブリードのチェック
  1574.         ## --
  1575.         ## 父母ともに、同じ親系統の場合成立します。
  1576.         ## 父の特性がSPの場合は「親系統ラインブリードSP型」になります。
  1577.         ## 3代前の祖先8頭のうち、親系統の種類が5より多い場合は危険度が下がります。
  1578.         ## --
  1579.         if child_line1.family_line_num == child_line3.family_line_num :
  1580.             if child_line1.family_line_attr == 1 :
  1581.                 ## 親系統ラインブリードSP型
  1582.                 return LineBreedEnum.Type_7
  1583.             else :
  1584.                 ## 親系統ラインブリード
  1585.                 return LineBreedEnum.Type_8
  1586.        
  1587.         return LineBreedEnum.NONE
  1588.  
  1589.  
  1590. # --------------------------------------------------------------------
  1591. # Helper Method
  1592. # --------------------------------------------------------------------
  1593.  
  1594. ## pythonにはsprintf無い
  1595. def sprintf( fmt, *args ):
  1596.     return fmt % args
  1597.  
  1598.  
  1599. ## 牧場番号から国を取得する
  1600. def get_country_by_bokuzyou_num( bokuzyou ):
  1601.     if bokuzyou < 214 and bokuzyou != 27 and bokuzyou != 28 :
  1602.         return CountryEnum.JAPAN
  1603.    
  1604.     elif bokuzyou < 233 and bokuzyou != 28 :
  1605.         return CountryEnum.USA;
  1606.  
  1607.     return CountryEnum.EURO;
  1608.  
  1609.  
  1610. ## 血統データの馬名を出力する
  1611. def get_blood_name( wp, blood_data ):
  1612.     disp = wp.HNameTable[ blood_data.name_left ].Kana
  1613.     right = wp.HNameTable[ blood_data.name_right ]
  1614.     if right != None :
  1615.         disp += right.Kana
  1616.    
  1617.     return disp
  1618.  
  1619.  
  1620. ## 系統データの馬名を出力する
  1621. def get_family_line_name( family_line_data ):
  1622.     buffer = System.Array.CreateInstance( System.Type.GetType('System.Byte'), 14 )
  1623.     buffer[0]  = family_line_data.name_1
  1624.     buffer[1]  = family_line_data.name_2
  1625.     buffer[2]  = family_line_data.name_3
  1626.     buffer[3]  = family_line_data.name_4
  1627.     buffer[4]  = family_line_data.name_5
  1628.     buffer[5]  = family_line_data.name_6
  1629.     buffer[6]  = family_line_data.name_7
  1630.     buffer[7]  = family_line_data.name_8
  1631.     buffer[8]  = family_line_data.name_9
  1632.     buffer[9]  = family_line_data.name_10
  1633.     buffer[10] = family_line_data.name_11
  1634.     buffer[11] = family_line_data.name_12
  1635.     buffer[12] = family_line_data.name_13
  1636.     buffer[13] = family_line_data.name_14
  1637.    
  1638.     return Helper.KoeiCode.ToString( buffer )
  1639.  
  1640.  
  1641.  
  1642. ## to_s method
  1643.  
  1644. def get_nicks_label( nicks_type ):
  1645.     return {
  1646.         NicksEnum.Type_1 : "シングルニックス",
  1647.         NicksEnum.Type_2 : "ダブルニックス",
  1648.         NicksEnum.Type_3 : "トリプルニックス",
  1649.         NicksEnum.Type_4 : "フォースニックス",
  1650.         NicksEnum.Type_5 : "2次ニックス",
  1651.         NicksEnum.Type_6 : "3次ニックス",
  1652.         NicksEnum.Type_7 : "4次ニックス",
  1653.     }.get( nicks_type, "[NICKS NONE]" )
  1654.  
  1655.  
  1656. def get_linebreed_label( line_breed_type ) :
  1657.     return {
  1658.         LineBreedEnum.Type_1 : "親系統ラインブリード4本爆発SP型",
  1659.         LineBreedEnum.Type_2 : "親系統ラインブリード4本爆発型",
  1660.         LineBreedEnum.Type_3 : "親系統ラインブリード3本爆発SP型",
  1661.         LineBreedEnum.Type_4 : "親系統ラインブリード3本爆発型",
  1662.         LineBreedEnum.Type_5 : "子系統ラインブリードSP型",
  1663.         LineBreedEnum.Type_6 : "子系統ラインブリード",
  1664.         LineBreedEnum.Type_7 : "親系統ラインブリードSP型",
  1665.         LineBreedEnum.Type_8 : "親系統ラインブリード",
  1666.     }.get( line_breed_type, "[LINE BREED NONE]" )
  1667.  
  1668.  
  1669. def get_bloodactivity_label( bloodactivity_type ) :
  1670.     return {
  1671.         BloodActivityEnum.Type_1 : "血脈活性化配合6本型",
  1672.         BloodActivityEnum.Type_2 : "血脈活性化配合7本型",
  1673.         BloodActivityEnum.Type_3 : "血脈活性化配合8本型",
  1674.     }.get( bloodactivity_type, "[BLOOD ACTIVITY NONE]" )
  1675.  
  1676.  
  1677. def get_bloodactivity_label( bloodactivity_type ) :
  1678.     return {
  1679.         BloodActivityEnum.Type_1 : "血脈活性化配合6本型",
  1680.         BloodActivityEnum.Type_2 : "血脈活性化配合7本型",
  1681.         BloodActivityEnum.Type_3 : "血脈活性化配合8本型",
  1682.     }.get( bloodactivity_type, "[BLOOD ACTIVITY NONE]" )
  1683.  
  1684.  
  1685. def get_bms_label( bms_type ) :
  1686.     return {
  1687.         BMSEnum.Type_1 : "母父○",
  1688.         BMSEnum.Type_2 : "母父◎",
  1689.     }.get( bms_type, "[BMS NONE]" )
  1690.  
  1691.  
  1692. def get_attr_combination_label( spst_type, attr_combination ) :
  1693.     attr = {
  1694.         SPSTTypeEnum.SPEED   : "SP",
  1695.         SPSTTypeEnum.STAMINA : "ST",
  1696.     }.get( spst_type, "[NONE]" )
  1697.    
  1698.     return {
  1699.         AttrCombinationEnum.Type_1 : sprintf( "%s昇華配合Lv1", attr ),
  1700.         AttrCombinationEnum.Type_2 : sprintf( "%s昇華配合Lv2", attr ),
  1701.         AttrCombinationEnum.Type_3 : sprintf( "%s昇華配合Lv3", attr ),
  1702.     }.get( attr_combination, sprintf( "%s[ATTR COMBINATION NONE]", attr ) )
  1703.  
  1704.  
  1705. def get_male_line_activity_label( male_line_activity_type ):
  1706.     return {
  1707.         LineActivityEnum.Male_1   : "メールライン活性配合 Lv1",
  1708.         LineActivityEnum.Male_2   : "メールライン活性配合 Lv2",
  1709.         LineActivityEnum.Male_3   : "メールライン活性配合 Lv3",
  1710.         LineActivityEnum.Bottom_1 : "ボトムライン活性配合 Lv1",
  1711.         LineActivityEnum.Bottom_2 : "ボトムライン活性配合 Lv2",
  1712.         LineActivityEnum.Bottom_3 : "ボトムライン活性配合 Lv3",
  1713.     }.get( male_line_activity_type, "[MALE LINE ACTIVITY NONE]" )
  1714.    
  1715.  
  1716.  
  1717. # --------------------------------------------------------------------
  1718. # 系統データのキャッシュデータ
  1719. # --------------------------------------------------------------------
  1720. class FamilyLineCacheData(object):
  1721.     num          = None
  1722.     data         = None
  1723.     sire_count   = 0
  1724.     sire_percent = 0.0
  1725.    
  1726.     def __init__( self, num, data, sire_count ):
  1727.         self.num = num
  1728.         self.data = data
  1729.         self.sire_count = sire_count
  1730.         self.sire_percent = 0.0
  1731.  
  1732.  
  1733. # --------------------------------------------------------------------
  1734. # 系統データのキャッシュを作る(毎回計算すると遅いので)
  1735. # --------------------------------------------------------------------
  1736. def create_family_line_cache( wp, country ):
  1737.     family_line_cache = [None] * int(wp.HFamilyLineTable.RecordCount)
  1738.    
  1739.     for i in range( 0, wp.HFamilyLineTable.RecordCount ):
  1740.         data = wp.HFamilyLineTable.GetData( i, HFamilyLineData() )
  1741.         family_line_cache[i] = FamilyLineCacheData( i, data, 0 )
  1742.    
  1743.    
  1744.     sire_total_len = 0
  1745.    
  1746.     for i in range( 0, wp.HSireTable.RecordCount ):
  1747.         data = wp.HSireTable.GetData( i, HSireData() )
  1748.        
  1749.         if data.intai != 0 :
  1750.             continue
  1751.        
  1752.         abl =  wp.HAblTable.GetData( data.abl_num, HAblData() )
  1753.        
  1754.         if get_country_by_bokuzyou_num( abl.bokuzyou ) != country :
  1755.             continue
  1756.        
  1757.         blood = wp.HBloodTable.GetData( data.blood_num, HBloodData() )
  1758.        
  1759.         if blood.father_num == wp.Config.IgnoreBloodNumber :
  1760.             continue
  1761.  
  1762.         sire_total_len += 1
  1763.         family_line_cache[ blood.family_line_num ].sire_count += 1
  1764.    
  1765.    
  1766.     for cache in family_line_cache:
  1767.         cache.sire_percent = float(cache.sire_count) / float(sire_total_len) * 100
  1768.    
  1769.     return family_line_cache
  1770.  
  1771.  
  1772. # --------------------------------------------------------------------
  1773. # debug write
  1774. # --------------------------------------------------------------------
  1775. def combination_disp( wp, combination ):
  1776.    
  1777.     for nicks_type in combination.nicks_list:
  1778.         print get_nicks_label( nicks_type )
  1779.    
  1780.     if not combination.is_inbreed() :
  1781.         print "アウトブリード"
  1782.     else :
  1783.         print "インブリード"
  1784.         for inbreed in combination.inbreed_list :
  1785.             n1 = 100.0 / ( 2 ** ( inbreed.sire_level + 1 ) )
  1786.             n2 = 100.0 / ( 2 ** ( inbreed.mare_level + 1 ) )
  1787.             b = wp.HBloodTable.GetData( inbreed.node.blood_num, HBloodData() )
  1788.             print( "\t%s %d×%d (%.2f%%)" % ( get_blood_name( wp, b ), inbreed.sire_level + 1, inbreed.mare_level + 1, n1 + n2 ) )
  1789.        
  1790.     if combination.is_linebreed() :
  1791.         print get_linebreed_label( combination.linebreed_type )
  1792.    
  1793.    
  1794.     if combination.blood_activity != BloodActivityEnum.NONE :
  1795.         print get_bloodactivity_label( combination.blood_activity )
  1796.    
  1797.     if combination.speed_combination != AttrCombinationEnum.NONE :
  1798.         print get_attr_combination_label( SPSTTypeEnum.SPEED, combination.speed_combination )
  1799.    
  1800.     if combination.stamina_combination != AttrCombinationEnum.NONE :
  1801.         print get_attr_combination_label( SPSTTypeEnum.STAMINA, combination.stamina_combination )
  1802.    
  1803.     if combination.fision_combination :
  1804.         print "SPST融合配合"
  1805.    
  1806.     if combination.bms_type != BMSEnum.NONE :
  1807.         print get_bms_label( combination.bms_type )
  1808.    
  1809.    
  1810.     if combination.katsuryoku_complate_1 > 0 :
  1811.         print sprintf( "名種牡馬型活力補完(%d本)", combination.katsuryoku_complate_1 )
  1812.    
  1813.     if combination.katsuryoku_complate_2 > 0 :
  1814.         print sprintf( "名牝型活力補完(%d本)", combination.katsuryoku_complate_2 )
  1815.    
  1816.     if combination.katsuryoku_complate_3 > 0 :
  1817.         print sprintf( "異系血脈型活力補完(%d本)", combination.katsuryoku_complate_3 )
  1818.    
  1819.     if combination.all_katsuryoku_complate :
  1820.         print "完全型活力補完"
  1821.    
  1822.     if combination.is_kakusei_iden() :
  1823.         print {
  1824.             1: lambda : sprintf( "隔世遺伝(%d)", combination.kakusei_iden[0] ),
  1825.             2: lambda : sprintf( "隔世遺伝(%d)(%d)", combination.kakusei_iden[0], combination.kakusei_iden[1] ),
  1826.         }.get( len(combination.kakusei_iden), lambda : "[BUG]" )()
  1827.    
  1828.     if combination.male_line_activity != LineActivityEnum.NONE :
  1829.         print get_male_line_activity_label( combination.male_line_activity )
  1830.    
  1831.    
  1832.     if len( combination.big_sire_factor_list ) > 0 :
  1833.         print sprintf( "活力源化大種牡馬因子 * %d", len( combination.big_sire_factor_list ) )
  1834.         for blood_num in combination.big_sire_factor_list :
  1835.             blood = wp.HBloodTable.GetData( blood_num, HBloodData() )
  1836.             print "\t" + get_blood_name( wp, blood )
  1837.        
  1838.     if len( combination.small_sire_factor_list ) > 0 :
  1839.         print sprintf( "活力源化名種牡馬因子 * %d", len( combination.small_sire_factor_list ) )
  1840.         for blood_num in combination.small_sire_factor_list :
  1841.             blood = wp.HBloodTable.GetData( blood_num, HBloodData() )
  1842.             print "\t" + get_blood_name( wp, blood )
  1843.    
  1844.     if combination.special.owarai :
  1845.         print "お笑い配合"
  1846.    
  1847.     if combination.special.oniai :
  1848.         print "お似合い配合"
  1849.    
  1850.     if combination.special.sayonara :
  1851.         print "サヨナラ配合"
  1852.     elif combination.special.wsayonara :
  1853.         print "Wサヨナラ配合"
  1854.    
  1855.     if combination.special.inazuma1 :
  1856.         print "稲妻配合"
  1857.     elif combination.special.inazuma2 :
  1858.         print "真稲妻配合"
  1859.        
  1860.     if combination.special.shippuu1 :
  1861.         print "疾風配合"
  1862.     elif combination.special.shippuu2 :
  1863.         print "真疾風配合"
  1864.        
  1865.     if combination.special.sankan :
  1866.         print "三冠配合"
  1867.    
  1868.     print ""
  1869.     sys.stdout.flush()
  1870.  
  1871.  
  1872. #region エントリーポイント
  1873. if __name__ == "__main__" :
  1874.     wp = WP7( Configuration.V101() )
  1875.    
  1876.     target_country = CountryEnum.JAPAN
  1877.     family_line_cache = create_family_line_cache( wp, target_country )
  1878.    
  1879.     horse_num = wp.GetCurrentCharacterNumber()
  1880.    
  1881.     sire_num = horse_num
  1882.     sire_data = wp.HSireTable.GetData( sire_num, HSireData() )
  1883.     sire_blood_data = wp.HBloodTable.GetData( sire_data.blood_num, HBloodData() )
  1884.  
  1885.     sire_pedigree = Pedigree(
  1886.         wp         = wp,
  1887.         ptype      = PedigreeTypeEnum.SIRE,
  1888.         blood_data = sire_blood_data,
  1889.         blood_num  = sire_data.blood_num,
  1890.     )
  1891.    
  1892.     for i in range( 0, wp.HDamTable.RecordCount ):
  1893.         dam_num = i
  1894.         dam_data = wp.HDamTable.GetData( dam_num, HDamData() )
  1895.        
  1896.         if dam_data.intai != 0 :
  1897.             continue
  1898.        
  1899.         dam_abl = wp.HAblTable.GetData( dam_data.abl_num, HAblData() )
  1900.        
  1901.         ## 自牧場以外は無視
  1902.         if dam_abl.bokuzyou != 25:
  1903.             pass
  1904.             continue
  1905.        
  1906.         if get_country_by_bokuzyou_num( dam_abl.bokuzyou ) != target_country :
  1907.             continue
  1908.            
  1909.         dam_blood = wp.HBloodTable.GetData( dam_data.blood_num, HBloodData() )
  1910.        
  1911.         if dam_blood.father_num == wp.Config.IgnoreBloodNumber :
  1912.             continue
  1913.        
  1914.         ## 繁殖牝馬の血統
  1915.         dam_pedigree = Pedigree(
  1916.             wp         = wp,
  1917.             ptype      = PedigreeTypeEnum.MARE,
  1918.             blood_data = dam_blood,
  1919.             blood_num  = dam_data.blood_num,
  1920.         )
  1921.        
  1922.         ## 配合する
  1923.         breeding = Breeding(
  1924.             wp                = wp,
  1925.             family_line_cache = family_line_cache,
  1926.             country           = target_country,
  1927.             sire_num          = sire_num,
  1928.             sire_pedigree     = sire_pedigree,
  1929.             dam_num           = dam_num,
  1930.             dam_pedigree      = dam_pedigree
  1931.         )
  1932.         combination = breeding.get_combination()
  1933.        
  1934.        
  1935.         ## debug write
  1936.         print sprintf( "%s × %s", get_blood_name( wp, sire_blood_data ), get_blood_name( wp, dam_blood ) )
  1937.         print "--"
  1938.    
  1939.         combination_disp( wp = wp, combination = combination, )
  1940.  
  1941. #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement