def writeTorpedoed(out): out.write('<h1>雷撃総集計</h1>') otmaps = {u'単縦':{}, u'複縦':{}, u'輪形':{}, u'梯形':{}, u'単横':{}} for b in battles: af = b.ff for a in b.e_opening.attacks: df = a.target if not df in otmaps[af]: otmaps[af][df] = {'total':0} for i in range(0, 0x10): otmaps[af][df][i] = 0 otmaps[af][df]['total'] += 1 otmaps[af][df][a.flags] += 1 for a in b.tpdPhase.attacks: df = a.target if not df in otmaps[af]: otmaps[af][df] = {'total':0} for i in range(0, 0x10): otmaps[af][df][i] = 0 otmaps[af][df]['total'] += 1 otmaps[af][df][a.flags] += 1 out.write('<table>') out.write('<tr><th>目標</th><th class="blue">総数</th><th class="hit">命中</th><th class="miss">ミス</th><th class="blue">命中率</th><th>95%区間</th></tr>') for ff in [u'単縦', u'複縦', u'輪形', u'梯形', u'単横']: a_total = 0 a_miss = 0 a_normal = 0 a_critical = 0 o_hit = {} o_miss = {} otmap = otmaps[ff] if otmap == {}: continue for target in sorted(otmap, lambda x, y: getEvasion(x) - getEvasion(y), reverse=True): # Extra conditions # if getEvasion(target) < 45: continue total = otmap[target]['total'] miss = otmap[target][0] normal = otmap[target][Attack.HIT] critical = otmap[target][Attack.CRTIICAL | Attack.HIT] a_total += total a_miss += miss a_normal += normal a_critical += critical if not target in o_hit: o_hit[target] = 0 if not target in o_miss: o_miss[target] = 0 o_hit[target] += critical + normal o_miss[target] += miss for target in sorted(o_hit, lambda x, y: getEvasion(x) - getEvasion(y), reverse=True): o_total = o_hit[target] + o_miss[target] if o_total < PRINT_THRESHOLD: continue o_rate = (100 * o_hit[target] / o_total) o_delta = 192 * math.sqrt((o_rate / 100.0) * (1 - o_rate / 100.0) / o_total) out.write('<tr><td>%s陣</td><td class="blue">%d</td><td class="hit">%d</td><td class="miss">%d</td><td class="blue">%d%%</td><td>%d%%~%d%%</td></tr>' % \ (ff, o_total, o_hit[target], o_miss[target], o_rate, o_rate - o_delta, o_rate + o_delta)) out.write('</table>')
def writeOpeningAttacks(out): out.write('<h1>先制雷撃集計</h1>') otmaps = {u'単縦':{}, u'複縦':{}, u'輪形':{}, u'梯形':{}, u'単横':{}} for b in battles: for a in b.opening.attacks: df = a.target if not df in otmaps[b.ff]: otmaps[b.ff][df] = {'total':0} for i in range(0, 0x10): otmaps[b.ff][df][i] = 0 otmaps[b.ff][df]['total'] += 1 otmaps[b.ff][df][a.flags] += 1 for ff in [u'単縦', u'複縦', u'輪形', u'梯形', u'単横']: a_total = 0 a_miss = 0 a_normal = 0 a_critical = 0 o_hit = {} o_miss = {} o_critical = {} otmap = otmaps[ff] if otmap == {}: continue for target in sorted(otmap, lambda x, y: getEvasion(x) - getEvasion(y), reverse=True): # Extra conditions # if getEvasion(target) < 45: continue total = otmap[target]['total'] miss = otmap[target][0] normal = otmap[target][Attack.HIT] critical = otmap[target][Attack.CRTIICAL | Attack.HIT] a_total += total a_miss += miss a_normal += normal a_critical += critical if not target in o_hit: o_hit[target] = 0 if not target in o_miss: o_miss[target] = 0 if not target in o_critical: o_critical[target] = 0 o_hit[target] += critical + normal o_miss[target] += miss o_critical[target] += critical out.write('<h2>%s陣</h2>' % ff) out.write('<table>') out.write('<tr><th>目標</th><th>回避値</th><th class="blue">総数</th><th class="hit">命中</th><th class="miss">ミス</th><th class="blue">命中率</th><th>95%区間</th><th>貫通</th><th>貫通率</th></tr>') for target in sorted(o_hit, lambda x, y: getEvasion(x) - getEvasion(y), reverse=True): o_total = o_hit[target] + o_miss[target] if o_total < PRINT_THRESHOLD: continue o_rate = 100 * o_hit[target] / o_total o_critical_rate = 0 if o_hit[target] > 0: o_critical_rate = 100 * o_critical[target] / o_hit[target] o_delta = 192 * math.sqrt((o_rate / 100.0) * (1 - o_rate / 100.0) / o_total) out.write('<tr><td>%s</td><td>%d</td><td class="blue">%d</td><td class="hit">%d</td><td class="miss">%d</td><td class="blue">%d%%</td><td>%d%%~%d%%</td><td>%d</td><td>%d%%</td></tr>' % \ (target, getEvasion(target), o_total, o_hit[target], o_miss[target], o_rate, o_rate - o_delta, o_rate + o_delta, o_critical[target], o_critical_rate)) if a_total > 0: a_hit = a_normal + a_critical a_rate = 100 * a_hit / a_total a_critical_rate = 100 * a_critical / a_hit out.write('<tr><td>総計</td><td>-</td><td class="blue">%d</td><td class="hit">%d</td><td class="miss">%d</td><td class="blue">%d%%</td><td>-</td><td>%d</td><td>%d%%</td></tr>' % \ (a_total, a_hit, a_miss, a_rate, a_critical, a_critical_rate)) out.write('</table>')
def writeBombards(out): dt = {} for b in battles: ff = b.ff enc = b.encount key = '%s・%s' % (ff, enc) if not key in dt: dt[key] = {} for a in b.bbPhase.attacks: if not a.attacker == u'大井改二': continue if a.flags | Attack.CRTIICAL == Attack.CRTIICAL: continue if not a.damage in dt[key]: dt[key][a.damage] = 0 dt[key][a.damage] += 1 for st in dt: print st for dmg in sorted(dt[st], lambda x, y : x - y): bar = '' for i in range(dt[st][dmg]): bar = bar + '|' print '%d: %s' % (dmg, bar) out.write('<h1>砲撃戦集計</h1>') dataMap = {u'単縦':{}, u'複縦':{}, u'輪形':{}, u'梯形':{}, u'単横':{}} for battle in battles: dm1 = dataMap[battle.ff] for attack in battle.bbPhase.attacks: attacker = battle.attackers[attack.atIndex] target = attack.target if not attacker in dm1: dm1[attacker] = {} dm2 = dm1[attacker] if not target in dm2: dm2[target] = { 'total': 0, 0: 0, 1: 0, 2: 0, 3: 0 } dm3 = dm2[target] dm3['total'] += 1 if not attack.flags in dm3: dm3[attack.flags] = 0 dm3[attack.flags] += 1 ffs = {u'単縦':[0, 0, 0], u'複縦':[0, 0, 0], u'輪形':[0, 0, 0], u'梯形':[0, 0, 0], u'単横':[0, 0, 0]} for ff in [u'単縦', u'複縦', u'輪形', u'梯形', u'単横']: dm1 = dataMap[ff] if dm1 == {}: continue out.write('<h2>%s陣</h2>' % ff) attackers = [] for attacker in dm1: attackers.append(attacker) for attacker in sorted(attackers, lambda x, y: 1 if x.toString() > y.toString() else -1): dm2 = dm1[attacker] # Extra conditions # if not attacker.toString()[0:2] in ['瑞鶴', '摩耶', '武蔵', '鳥海', '島風', '雪風' # ]: continue atstat = [0, 0, 0] eva_sum = 0 eva_count = 0 attacker_color = 'red' if '電探' in attacker.toString() else 'black' out.write('<h3><font color="%s">攻撃者:%s</font></h3>' % (attacker_color, attacker.toString())) out.write('<table>') out.write('''<tr><th>目標</th><th>回避値</th><th class="blue">総数</th> <th class="hit">命中</th><th class="miss">ミス</th> <th class="blue">命中率</th><th>95%区間</th><th>貫通弾</th><th>貫通率</th></tr>''') for target in sorted(dm2, lambda x, y: getEvasion(x) - getEvasion(y), reverse=True): # Extra conditions # if getEvasion(target) < 45: continue total = dm2[target]['total'] miss = dm2[target][0] normal = dm2[target][Attack.HIT] cl = dm2[target][Attack.CRTIICAL | Attack.HIT] hit = cl + normal atstat[0] += hit atstat[1] += miss atstat[2] += cl if total < PRINT_THRESHOLD: continue rate = 100 * hit / total delta = 192 * math.sqrt((rate / 100.0) * (1 - rate / 100.0) / total) clrate = 0 if hit > 0: clrate = 100 * cl / hit eva_sum += getEvasion(target) eva_count += 1 out.write('''<tr><td>%s</td><td>%d</td><td class="blue">%d</td> <td class="hit">%d</td><td class="miss">%d</td><td class="blue">%d%%</td> <td>%d%%~%d%%</td><td>%d</td><td>%d%%</td></tr>''' % (target, getEvasion(target), total, hit, miss, \ rate, rate - delta, rate + delta, cl, clrate)) at_clrate = 0 if atstat[0] > 0: at_clrate = 100 * atstat[2] / atstat[0] ffs[ff][0] += atstat[0] ffs[ff][1] += atstat[1] ffs[ff][2] += atstat[2] out.write('''<tr><td>総計</td><td>%.1f</td><td class="blue">%d</td> <td class="hit">%d</td><td class="miss">%d</td><td class="blue">%d%%</td> <td>-</td><td>%d</td><td>%d%%</td></tr>''' % (1.0 * eva_sum / eva_count, atstat[0] + atstat[1], atstat[0], atstat[1], \ 100 * atstat[0] / (atstat[0] + atstat[1]), atstat[2], at_clrate)) out.write('</table>') out.write('<h2>陣形総計</h2>') out.write('<table>') out.write('''<tr><th>陣形</th><th class="blue">総数</th> <th class="hit">命中</th><th class="miss">ミス</th> <th class="blue">命中率</th><th>貫通弾</th><th>貫通率</th></tr>''') for ff in [u'単縦', u'複縦', u'輪形', u'梯形', u'単横']: ff_hit = ffs[ff][0] ff_miss = ffs[ff][1] ff_total = ff_hit + ff_miss ff_cl = ffs[ff][2] ff_rate = 0 if ff_total > 0: ff_rate = 100 * ff_hit / ff_total ff_clrate = 0 if ff_hit > 0: ff_clrate = 100 * ff_cl / ff_hit out.write('''<tr><td>%s</td><td class="blue">%d</td><td class="hit">%d</td> <td class="miss">%d</td><td class="blue">%d%%</td><td>%d</td><td>%d%%</td></tr>''' % (ff, ff_total, ff_hit, ff_miss, ff_rate, ff_cl, ff_clrate)) out.write('</table>')
def writeStage3(out): out.write('<h1>航空戦集計</h1>') t_total = 0 t_miss = 0 t_normal = 0 t_fatal = 0 t_critical = 0 t_fatal_critical = 0 b_total = 0 b_miss = 0 b_normal = 0 b_critical = 0 o_hit = {} o_miss = {} torpedoHit = {} bombHit = {} for b in battles: if not b.extraCond: continue for a in b.stage3.attacks: df = a.target if isinstance(a, (ACTorpedo)): if not df in torpedoHit: torpedoHit[df] = {'total':0} for i in range(0, 0x10): torpedoHit[df][i] = 0 torpedoHit[df]['total'] += 1 torpedoHit[df][a.flags] += 1 elif isinstance(a, (ACBomb)): if not df in bombHit: bombHit[df] = {'total':0} for i in range(0, 0x10): bombHit[df][i] = 0 if a.flags & Attack.BOTH_HIT == Attack.BOTH_HIT: bombHit[df]['total'] += 2 a.flags &= 0xFF8F a.flags |= Attack.HIT bombHit[df][a.flags] += 2 elif a.flags & Attack.HALF_HIT == Attack.HALF_HIT: bombHit[df]['total'] += 2 a.flags &= 0xFF8F a.flags |= Attack.HIT bombHit[df][a.flags] += 1 bombHit[df][0] += 1 elif a.flags & Attack.BOTH_MISS == Attack.BOTH_MISS: bombHit[df]['total'] += 2 bombHit[df][0] += 2 else: bombHit[df]['total'] += 1 bombHit[df][a.flags] += 1 for target in sorted(torpedoHit, lambda x, y: getEvasion(x) - getEvasion(y), reverse=True): total = torpedoHit[target]['total'] miss = torpedoHit[target][0] normal = torpedoHit[target][Attack.HIT] fatal = torpedoHit[target][Attack.FATAL | Attack.HIT] critical = torpedoHit[target][Attack.CRTIICAL | Attack.HIT] fatal_critical = torpedoHit[target][Attack.FATAL | Attack.CRTIICAL | Attack.HIT] t_total += total t_miss += miss t_normal += normal t_fatal += fatal t_critical += critical t_fatal_critical += fatal_critical hit = normal + fatal + critical + fatal_critical o_hit[target] = hit o_miss[target] = miss for target in sorted(bombHit, lambda x, y: getEvasion(x) - getEvasion(y), reverse=True): total = bombHit[target]['total'] miss = bombHit[target][0] normal = bombHit[target][Attack.HIT] critical = bombHit[target][Attack.CRTIICAL | Attack.HIT] b_total += total b_miss += miss b_normal += normal b_critical += critical if not target in o_hit: o_hit[target] = 0 if not target in o_miss: o_miss[target] = 0 o_hit[target] += critical + normal o_miss[target] += miss out.write('<h2>攻撃別</h2>') out.write('<table>') out.write('<tr><th>攻撃種類</th><th class="blue">総数</th><th class="hit">命中</th><th class="miss">ミス</th><th class="blue">命中率</th><th>貫通弾</th><th>貫通率</th><th>急所弾</th><th>急所率</th></tr>') t_hit = t_normal + t_fatal + t_critical + t_fatal_critical t_fatal_rate = 0 t_critical_rate = 0 t_rate = 0 if t_total > 0: t_rate = 100 * t_hit / t_total b_hit = b_normal + b_critical b_rate = 0 if b_total > 0: b_rate = 100 * b_hit / b_total b_critical_rate = 0 if t_hit > 0: t_fatal_rate = 100 * (t_fatal + t_fatal_critical) / t_hit t_critical_rate = 100 * (t_critical + t_fatal_critical) / t_hit if b_hit > 0: b_critical_rate = 100 * b_critical / b_hit out.write('<tr><td>雷撃</td><td class="blue">%d</td><td class="hit">%d</td><td class="miss">%d</td><td class="blue">%d%%</td><td>%d</td><td>%d%%</td><td>%d</td><td>%d%%</td></tr>' % \ (t_total, t_hit, t_miss, t_rate, \ t_critical + t_fatal_critical, t_critical_rate, t_fatal + t_fatal_critical, t_fatal_rate)) out.write('<tr><td>爆撃</td><td class="blue">%d</td><td class="hit">%d</td><td class="miss">%d</td><td class="blue">%d%%</td><td>%d</td><td>%d%%</td><td>-</td><td>-</td></tr>' % \ (b_total, b_hit, b_miss, b_rate, b_critical, b_critical_rate)) out.write('</table>') cal = 40 out.write('<h2>目標別</h2>') out.write('<table>') out.write('<tr><th>目標</th><th>回避値</th><th class="blue">総数</th><th class="hit">命中</th><th class="miss">ミス</th><th class="blue">命中率</th><th>95%区間</th><th>推定命中</th></tr>') for target in sorted(o_hit, lambda x, y: getEvasion(x) - getEvasion(y), reverse=True): o_total = o_hit[target] + o_miss[target] if o_total < PRINT_THRESHOLD: continue rate = (100 * o_hit[target] / o_total) delta = 192 * math.sqrt((rate / 100.0) * (1 - rate / 100.0) / o_total) out.write('<tr><td>%s</td><td>%d</td><td class="blue">%d</td><td class="hit">%d</td><td class="miss">%d</td><td class="blue">%d%%</td><td>%d%%~%d%%</td><td>%d%%</td></tr>' % \ (target, getEvasion(target), o_total, o_hit[target], o_miss[target], rate, rate - delta, rate + delta, 100 * cal / (cal + getEvasion(target)))) out.write('</table>')
def writeTorpedoed(out): out.write('<h1>雷撃総集計</h1>') otmaps = {u'単縦': {}, u'複縦': {}, u'輪形': {}, u'梯形': {}, u'単横': {}} for b in battles: af = b.ff for a in b.e_opening.attacks: df = a.target if not df in otmaps[af]: otmaps[af][df] = {'total': 0} for i in range(0, 0x10): otmaps[af][df][i] = 0 otmaps[af][df]['total'] += 1 otmaps[af][df][a.flags] += 1 for a in b.tpdPhase.attacks: df = a.target if not df in otmaps[af]: otmaps[af][df] = {'total': 0} for i in range(0, 0x10): otmaps[af][df][i] = 0 otmaps[af][df]['total'] += 1 otmaps[af][df][a.flags] += 1 out.write('<table>') out.write( '<tr><th>目標</th><th class="blue">総数</th><th class="hit">命中</th><th class="miss">ミス</th><th class="blue">命中率</th><th>95%区間</th></tr>' ) for ff in [u'単縦', u'複縦', u'輪形', u'梯形', u'単横']: a_total = 0 a_miss = 0 a_normal = 0 a_critical = 0 o_hit = {} o_miss = {} otmap = otmaps[ff] if otmap == {}: continue for target in sorted(otmap, lambda x, y: getEvasion(x) - getEvasion(y), reverse=True): # Extra conditions # if getEvasion(target) < 45: continue total = otmap[target]['total'] miss = otmap[target][0] normal = otmap[target][Attack.HIT] critical = otmap[target][Attack.CRTIICAL | Attack.HIT] a_total += total a_miss += miss a_normal += normal a_critical += critical if not target in o_hit: o_hit[target] = 0 if not target in o_miss: o_miss[target] = 0 o_hit[target] += critical + normal o_miss[target] += miss for target in sorted(o_hit, lambda x, y: getEvasion(x) - getEvasion(y), reverse=True): o_total = o_hit[target] + o_miss[target] if o_total < PRINT_THRESHOLD: continue o_rate = (100 * o_hit[target] / o_total) o_delta = 192 * math.sqrt( (o_rate / 100.0) * (1 - o_rate / 100.0) / o_total) out.write('<tr><td>%s陣</td><td class="blue">%d</td><td class="hit">%d</td><td class="miss">%d</td><td class="blue">%d%%</td><td>%d%%~%d%%</td></tr>' % \ (ff, o_total, o_hit[target], o_miss[target], o_rate, o_rate - o_delta, o_rate + o_delta)) out.write('</table>')
def writeBombards(out): dt = {} for b in battles: ff = b.ff enc = b.encount key = '%s・%s' % (ff, enc) if not key in dt: dt[key] = {} for a in b.bbPhase.attacks: if not a.attacker == u'大井改二': continue if a.flags | Attack.CRTIICAL == Attack.CRTIICAL: continue if not a.damage in dt[key]: dt[key][a.damage] = 0 dt[key][a.damage] += 1 for st in dt: print st for dmg in sorted(dt[st], lambda x, y: x - y): bar = '' for i in range(dt[st][dmg]): bar = bar + '|' print '%d: %s' % (dmg, bar) out.write('<h1>砲撃戦集計</h1>') dataMap = {u'単縦': {}, u'複縦': {}, u'輪形': {}, u'梯形': {}, u'単横': {}} for battle in battles: dm1 = dataMap[battle.ff] for attack in battle.bbPhase.attacks: attacker = battle.attackers[attack.atIndex] target = attack.target if not attacker in dm1: dm1[attacker] = {} dm2 = dm1[attacker] if not target in dm2: dm2[target] = {'total': 0, 0: 0, 1: 0, 2: 0, 3: 0} dm3 = dm2[target] dm3['total'] += 1 if not attack.flags in dm3: dm3[attack.flags] = 0 dm3[attack.flags] += 1 ffs = { u'単縦': [0, 0, 0], u'複縦': [0, 0, 0], u'輪形': [0, 0, 0], u'梯形': [0, 0, 0], u'単横': [0, 0, 0] } for ff in [u'単縦', u'複縦', u'輪形', u'梯形', u'単横']: dm1 = dataMap[ff] if dm1 == {}: continue out.write('<h2>%s陣</h2>' % ff) attackers = [] for attacker in dm1: attackers.append(attacker) for attacker in sorted( attackers, lambda x, y: 1 if x.toString() > y.toString() else -1): dm2 = dm1[attacker] # Extra conditions # if not attacker.toString()[0:2] in ['瑞鶴', '摩耶', '武蔵', '鳥海', '島風', '雪風' # ]: continue atstat = [0, 0, 0] eva_sum = 0 eva_count = 0 attacker_color = 'red' if '電探' in attacker.toString() else 'black' out.write('<h3><font color="%s">攻撃者:%s</font></h3>' % (attacker_color, attacker.toString())) out.write('<table>') out.write('''<tr><th>目標</th><th>回避値</th><th class="blue">総数</th> <th class="hit">命中</th><th class="miss">ミス</th> <th class="blue">命中率</th><th>95%区間</th><th>貫通弾</th><th>貫通率</th></tr>''' ) for target in sorted(dm2, lambda x, y: getEvasion(x) - getEvasion(y), reverse=True): # Extra conditions # if getEvasion(target) < 45: continue total = dm2[target]['total'] miss = dm2[target][0] normal = dm2[target][Attack.HIT] cl = dm2[target][Attack.CRTIICAL | Attack.HIT] hit = cl + normal atstat[0] += hit atstat[1] += miss atstat[2] += cl if total < PRINT_THRESHOLD: continue rate = 100 * hit / total delta = 192 * math.sqrt( (rate / 100.0) * (1 - rate / 100.0) / total) clrate = 0 if hit > 0: clrate = 100 * cl / hit eva_sum += getEvasion(target) eva_count += 1 out.write('''<tr><td>%s</td><td>%d</td><td class="blue">%d</td> <td class="hit">%d</td><td class="miss">%d</td><td class="blue">%d%%</td> <td>%d%%~%d%%</td><td>%d</td><td>%d%%</td></tr>''' % (target, getEvasion(target), total, hit, miss, \ rate, rate - delta, rate + delta, cl, clrate)) at_clrate = 0 if atstat[0] > 0: at_clrate = 100 * atstat[2] / atstat[0] ffs[ff][0] += atstat[0] ffs[ff][1] += atstat[1] ffs[ff][2] += atstat[2] out.write('''<tr><td>総計</td><td>%.1f</td><td class="blue">%d</td> <td class="hit">%d</td><td class="miss">%d</td><td class="blue">%d%%</td> <td>-</td><td>%d</td><td>%d%%</td></tr>''' % (1.0 * eva_sum / eva_count, atstat[0] + atstat[1], atstat[0], atstat[1], \ 100 * atstat[0] / (atstat[0] + atstat[1]), atstat[2], at_clrate)) out.write('</table>') out.write('<h2>陣形総計</h2>') out.write('<table>') out.write('''<tr><th>陣形</th><th class="blue">総数</th> <th class="hit">命中</th><th class="miss">ミス</th> <th class="blue">命中率</th><th>貫通弾</th><th>貫通率</th></tr>''') for ff in [u'単縦', u'複縦', u'輪形', u'梯形', u'単横']: ff_hit = ffs[ff][0] ff_miss = ffs[ff][1] ff_total = ff_hit + ff_miss ff_cl = ffs[ff][2] ff_rate = 0 if ff_total > 0: ff_rate = 100 * ff_hit / ff_total ff_clrate = 0 if ff_hit > 0: ff_clrate = 100 * ff_cl / ff_hit out.write( '''<tr><td>%s</td><td class="blue">%d</td><td class="hit">%d</td> <td class="miss">%d</td><td class="blue">%d%%</td><td>%d</td><td>%d%%</td></tr>''' % (ff, ff_total, ff_hit, ff_miss, ff_rate, ff_cl, ff_clrate)) out.write('</table>')
def writeOpeningAttacks(out): out.write('<h1>先制雷撃集計</h1>') otmaps = {u'単縦': {}, u'複縦': {}, u'輪形': {}, u'梯形': {}, u'単横': {}} for b in battles: for a in b.opening.attacks: df = a.target if not df in otmaps[b.ff]: otmaps[b.ff][df] = {'total': 0} for i in range(0, 0x10): otmaps[b.ff][df][i] = 0 otmaps[b.ff][df]['total'] += 1 otmaps[b.ff][df][a.flags] += 1 for ff in [u'単縦', u'複縦', u'輪形', u'梯形', u'単横']: a_total = 0 a_miss = 0 a_normal = 0 a_critical = 0 o_hit = {} o_miss = {} o_critical = {} otmap = otmaps[ff] if otmap == {}: continue for target in sorted(otmap, lambda x, y: getEvasion(x) - getEvasion(y), reverse=True): # Extra conditions # if getEvasion(target) < 45: continue total = otmap[target]['total'] miss = otmap[target][0] normal = otmap[target][Attack.HIT] critical = otmap[target][Attack.CRTIICAL | Attack.HIT] a_total += total a_miss += miss a_normal += normal a_critical += critical if not target in o_hit: o_hit[target] = 0 if not target in o_miss: o_miss[target] = 0 if not target in o_critical: o_critical[target] = 0 o_hit[target] += critical + normal o_miss[target] += miss o_critical[target] += critical out.write('<h2>%s陣</h2>' % ff) out.write('<table>') out.write( '<tr><th>目標</th><th>回避値</th><th class="blue">総数</th><th class="hit">命中</th><th class="miss">ミス</th><th class="blue">命中率</th><th>95%区間</th><th>貫通</th><th>貫通率</th></tr>' ) for target in sorted(o_hit, lambda x, y: getEvasion(x) - getEvasion(y), reverse=True): o_total = o_hit[target] + o_miss[target] if o_total < PRINT_THRESHOLD: continue o_rate = 100 * o_hit[target] / o_total o_critical_rate = 0 if o_hit[target] > 0: o_critical_rate = 100 * o_critical[target] / o_hit[target] o_delta = 192 * math.sqrt( (o_rate / 100.0) * (1 - o_rate / 100.0) / o_total) out.write('<tr><td>%s</td><td>%d</td><td class="blue">%d</td><td class="hit">%d</td><td class="miss">%d</td><td class="blue">%d%%</td><td>%d%%~%d%%</td><td>%d</td><td>%d%%</td></tr>' % \ (target, getEvasion(target), o_total, o_hit[target], o_miss[target], o_rate, o_rate - o_delta, o_rate + o_delta, o_critical[target], o_critical_rate)) if a_total > 0: a_hit = a_normal + a_critical a_rate = 100 * a_hit / a_total a_critical_rate = 100 * a_critical / a_hit out.write('<tr><td>総計</td><td>-</td><td class="blue">%d</td><td class="hit">%d</td><td class="miss">%d</td><td class="blue">%d%%</td><td>-</td><td>%d</td><td>%d%%</td></tr>' % \ (a_total, a_hit, a_miss, a_rate, a_critical, a_critical_rate)) out.write('</table>')
def writeStage3(out): out.write('<h1>航空戦集計</h1>') t_total = 0 t_miss = 0 t_normal = 0 t_fatal = 0 t_critical = 0 t_fatal_critical = 0 b_total = 0 b_miss = 0 b_normal = 0 b_critical = 0 o_hit = {} o_miss = {} torpedoHit = {} bombHit = {} for b in battles: if not b.extraCond: continue for a in b.stage3.attacks: df = a.target if isinstance(a, (ACTorpedo)): if not df in torpedoHit: torpedoHit[df] = {'total': 0} for i in range(0, 0x10): torpedoHit[df][i] = 0 torpedoHit[df]['total'] += 1 torpedoHit[df][a.flags] += 1 elif isinstance(a, (ACBomb)): if not df in bombHit: bombHit[df] = {'total': 0} for i in range(0, 0x10): bombHit[df][i] = 0 if a.flags & Attack.BOTH_HIT == Attack.BOTH_HIT: bombHit[df]['total'] += 2 a.flags &= 0xFF8F a.flags |= Attack.HIT bombHit[df][a.flags] += 2 elif a.flags & Attack.HALF_HIT == Attack.HALF_HIT: bombHit[df]['total'] += 2 a.flags &= 0xFF8F a.flags |= Attack.HIT bombHit[df][a.flags] += 1 bombHit[df][0] += 1 elif a.flags & Attack.BOTH_MISS == Attack.BOTH_MISS: bombHit[df]['total'] += 2 bombHit[df][0] += 2 else: bombHit[df]['total'] += 1 bombHit[df][a.flags] += 1 for target in sorted(torpedoHit, lambda x, y: getEvasion(x) - getEvasion(y), reverse=True): total = torpedoHit[target]['total'] miss = torpedoHit[target][0] normal = torpedoHit[target][Attack.HIT] fatal = torpedoHit[target][Attack.FATAL | Attack.HIT] critical = torpedoHit[target][Attack.CRTIICAL | Attack.HIT] fatal_critical = torpedoHit[target][Attack.FATAL | Attack.CRTIICAL | Attack.HIT] t_total += total t_miss += miss t_normal += normal t_fatal += fatal t_critical += critical t_fatal_critical += fatal_critical hit = normal + fatal + critical + fatal_critical o_hit[target] = hit o_miss[target] = miss for target in sorted(bombHit, lambda x, y: getEvasion(x) - getEvasion(y), reverse=True): total = bombHit[target]['total'] miss = bombHit[target][0] normal = bombHit[target][Attack.HIT] critical = bombHit[target][Attack.CRTIICAL | Attack.HIT] b_total += total b_miss += miss b_normal += normal b_critical += critical if not target in o_hit: o_hit[target] = 0 if not target in o_miss: o_miss[target] = 0 o_hit[target] += critical + normal o_miss[target] += miss out.write('<h2>攻撃別</h2>') out.write('<table>') out.write( '<tr><th>攻撃種類</th><th class="blue">総数</th><th class="hit">命中</th><th class="miss">ミス</th><th class="blue">命中率</th><th>貫通弾</th><th>貫通率</th><th>急所弾</th><th>急所率</th></tr>' ) t_hit = t_normal + t_fatal + t_critical + t_fatal_critical t_fatal_rate = 0 t_critical_rate = 0 t_rate = 0 if t_total > 0: t_rate = 100 * t_hit / t_total b_hit = b_normal + b_critical b_rate = 0 if b_total > 0: b_rate = 100 * b_hit / b_total b_critical_rate = 0 if t_hit > 0: t_fatal_rate = 100 * (t_fatal + t_fatal_critical) / t_hit t_critical_rate = 100 * (t_critical + t_fatal_critical) / t_hit if b_hit > 0: b_critical_rate = 100 * b_critical / b_hit out.write('<tr><td>雷撃</td><td class="blue">%d</td><td class="hit">%d</td><td class="miss">%d</td><td class="blue">%d%%</td><td>%d</td><td>%d%%</td><td>%d</td><td>%d%%</td></tr>' % \ (t_total, t_hit, t_miss, t_rate, \ t_critical + t_fatal_critical, t_critical_rate, t_fatal + t_fatal_critical, t_fatal_rate)) out.write('<tr><td>爆撃</td><td class="blue">%d</td><td class="hit">%d</td><td class="miss">%d</td><td class="blue">%d%%</td><td>%d</td><td>%d%%</td><td>-</td><td>-</td></tr>' % \ (b_total, b_hit, b_miss, b_rate, b_critical, b_critical_rate)) out.write('</table>') cal = 40 out.write('<h2>目標別</h2>') out.write('<table>') out.write( '<tr><th>目標</th><th>回避値</th><th class="blue">総数</th><th class="hit">命中</th><th class="miss">ミス</th><th class="blue">命中率</th><th>95%区間</th><th>推定命中</th></tr>' ) for target in sorted(o_hit, lambda x, y: getEvasion(x) - getEvasion(y), reverse=True): o_total = o_hit[target] + o_miss[target] if o_total < PRINT_THRESHOLD: continue rate = (100 * o_hit[target] / o_total) delta = 192 * math.sqrt((rate / 100.0) * (1 - rate / 100.0) / o_total) out.write('<tr><td>%s</td><td>%d</td><td class="blue">%d</td><td class="hit">%d</td><td class="miss">%d</td><td class="blue">%d%%</td><td>%d%%~%d%%</td><td>%d%%</td></tr>' % \ (target, getEvasion(target), o_total, o_hit[target], o_miss[target], rate, rate - delta, rate + delta, 100 * cal / (cal + getEvasion(target)))) out.write('</table>')