Improve trading villager selection based on profession

This commit is contained in:
2021-05-01 21:31:21 +00:00
parent 080895421d
commit a87cc85eab
9 changed files with 82 additions and 15 deletions

View File

@@ -102,7 +102,10 @@ class GrabSuppliesStates:
print('No path, blacklisting barrel')
time.sleep(0.1)
self.bad_barrels.append(self.barrel)
self.state = self.choose_barrel
if len(self.bad_barrels) > 3:
self.state = self.cleanup
else:
self.state = self.choose_barrel
def going_to_barrel(self):
if utils.pint(self.g.pos) == self.opening:

View File

@@ -31,8 +31,29 @@ class SellToVillagerStates:
for v in w.find_villagers(p, 100):
print('Found villager:', v)
if v not in self.bad_villagers and v not in self.spent_villagers:
break
if v in self.bad_villagers:
print('In bad villager list')
continue
if v in self.spent_villagers:
print('In spent villager list')
continue
if 'profession' not in v:
print('Villager has unknown profession')
continue
if v.profession not in mobs.TRADES:
print('Villager doesnt sell stuff we collect')
continue
trades = mobs.TRADES[v.profession]
if not self.g.game.count_items(trades):
print('We dont have anything to sell him')
continue
break
else: # for
print('No good villagers left, aborting.')
self.spent_villagers = []
@@ -59,7 +80,7 @@ class SellToVillagerStates:
if self.villager not in self.good_villagers:
self.bad_villagers.append(self.villager)
print('Added to bad villager list')
self.state = self.cleanup
self.state = self.find_villager
return
navpath = w.path_to_place(p, self.openings[0])
@@ -144,8 +165,7 @@ class SellToVillagerStates:
print('Villager has been spent, aborting')
self.g.game.close_window()
self.spent_villagers.append(self.villager)
self.state = self.wait
self.wait_time = 10
self.state = self.find_villager
return
def click_trade(self):