Advertisement
Guest User

PyWp7Breeding

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