Skip to content
This repository has been archived by the owner on Dec 10, 2017. It is now read-only.

Commit

Permalink
Merge pull request #339 from mrmin123/338_pvp_bugfix
Browse files Browse the repository at this point in the history
Connects to #338
  • Loading branch information
mrmin123 committed Mar 15, 2017
2 parents 267d756 + 8dd3eac commit a4f0ef3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 2017-03-15 ([Release 8.3](https://github.com/mrmin123/kancolle-auto/releases/tag/8.3))
* Bugfixes to PvP module

#### 2017-03-13 ([Release 8.2](https://github.com/mrmin123/kancolle-auto/releases/tag/8.2))
* Bugfixes to submarine switch module

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Please read the [**kancolle-auto wiki**](https://github.com/mrmin123/kancolle-au
### Features

* Expedition module — automate expeditions
* PvP module — automate PvP
* PvP module — automate PvP, including diamond and line abreast formations versus submarine-heavy fleets
* Combat module — automate sorties, node selections, repairs, and submarine switching
* Supports sorties to Event maps, Combined Fleets, LBAS, and pre-boss/boss support expeditions
* Quests module — automate quests
Expand Down
10 changes: 7 additions & 3 deletions kancolle_auto.sikuli/combat.sikuli/combat.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,15 +714,16 @@ def go_pvp(self):
# An opponent was chosen
rejigger_mouse(self.kc_region, 50, 750, 50, 350)
self.kc_region.wait('pvp_start_1.png', 30)
sleep(1)

# Identify opponent ship and sub counts
enemy_ship_count_matches = self.kc_region.findAll(Pattern('pvp_lvl.png').similar(0.95))
for i in (enemy_ship_count_matches if enemy_ship_count_matches is not None else []):
enemy_ship_count += 1
enemy_sub_count_matches = self.kc_region.findAll(Pattern('ship_class_ss.png'))
enemy_sub_count_matches = self.kc_region.findAll(Pattern('ship_class_ss.png').similar(CLASS_SIMILARITY))
for i in (enemy_sub_count_matches if enemy_sub_count_matches is not None else []):
enemy_sub_count += 1
enemy_sub_count_matches = self.kc_region.findAll(Pattern('ship_class_ssv.png'))
enemy_sub_count_matches = self.kc_region.findAll(Pattern('ship_class_ssv.png').similar(CLASS_SIMILARITY))
for i in (enemy_sub_count_matches if enemy_sub_count_matches is not None else []):
enemy_sub_count += 1
formation, nb = self.formation_nb_selector(enemy_ship_count, enemy_sub_count)
Expand Down Expand Up @@ -758,12 +759,15 @@ def go_pvp(self):
def formation_nb_selector(self, enemy_ship_count, enemy_sub_count):
formation = 'formation_line_ahead'
nb = True
if enemy_ship_count == 0:
# Return defaults if enemy ship count detection fails; avoid divide by 0
return (formation, nb)
sub_ratio = float(enemy_sub_count) / float(enemy_ship_count)
if sub_ratio > 0.5:
formation = 'formation_line_abreast'
elif sub_ratio == 0.5:
formation = 'formation_diamond'
if sub_ratio == 1:
if sub_ratio >= 1:
nb = False # Skip night battle if the entire enemy fleet are subs
return (formation, nb)

Expand Down
Binary file modified kancolle_auto.sikuli/combat.sikuli/pvp_lvl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a4f0ef3

Please sign in to comment.