Prioritize commission rewards and fix built-in battle simulation flow
This commit is contained in:
@@ -45,7 +45,7 @@ import uuid
|
||||
|
||||
from .game_data import ProgressionData, load_progression_data
|
||||
from .model import Planner, seconds
|
||||
from .quests import indexed, stage_has_level
|
||||
from .quests import commission_priority, indexed, stage_has_level
|
||||
|
||||
|
||||
CATEGORIES = {1: ("mainline", "主线"), 2: ("sidequest", "支线"),
|
||||
@@ -765,7 +765,7 @@ class ProgressionPlanner:
|
||||
def _commission_policy(self, quest_policy, battle_policy=None):
|
||||
base = battle_policy or ProgressionPolicy()
|
||||
return replace(base, enabled=bool(quest_policy.enabled), mainline=False, sidequests=False,
|
||||
commissions=True, accept=bool(quest_policy.accept), repair_chain=False,
|
||||
commissions=True, accept=bool(quest_policy.accept), repair_chain=False, auto_farm=True,
|
||||
allow_items=bool(quest_policy.allow_items), allow_monsters=bool(quest_policy.allow_monsters),
|
||||
max_money=quest_policy.max_money, item_reserves=dict(quest_policy.item_reserves))
|
||||
|
||||
@@ -878,7 +878,7 @@ class ProgressionPlanner:
|
||||
return [action]
|
||||
active, _, finished = self._tasks(snapshot, account)
|
||||
blocked = []
|
||||
for key, task in active.items():
|
||||
for key, task in sorted(active.items(), key=lambda pair: commission_priority(self.data.task(pair[0]) or {})):
|
||||
info = self.data.task(key)
|
||||
if not info or info.get("type") != 4 or key in finished:
|
||||
continue
|
||||
@@ -889,23 +889,24 @@ class ProgressionPlanner:
|
||||
self._issued[candidate.token] = candidate.to_dict()
|
||||
return actions
|
||||
blocked.append(action)
|
||||
if not quest_policy.accept or remaining <= 0:
|
||||
if blocked or not quest_policy.accept or remaining <= 0:
|
||||
return blocked
|
||||
for city, values in sorted(offers.items()):
|
||||
ranked_offers = sorted(((city, key) for city, values in offers.items() for key in _values(values)),
|
||||
key=lambda pair: commission_priority(self.data.task(str(pair[1])) or {}))
|
||||
for city, offered_key in ranked_offers:
|
||||
city = _integer(city)
|
||||
if city <= 0 or quest_policy.city and city != quest_policy.city or not snapshot.city_unlocked(city):
|
||||
continue
|
||||
for key in _values(values):
|
||||
key, info = str(key), self.data.task(key)
|
||||
if key in active or key in finished or not info or info.get("type") != 4:
|
||||
continue
|
||||
if not self._commission_offer_ready(snapshot, quest_policy, policy, ranch_policy, info)[0]:
|
||||
continue
|
||||
action = self._intent(scope, {"id": 0, "typeId": key}, 0, info.get("startStep") or {},
|
||||
"progression_loop_accept", "接取城市委托:" + info.get("name", key), policy,
|
||||
path="taskService/taskLoopReceive", payload={"taskTypeId": key, "city": city}, phase=str(today))
|
||||
self._issued[action.token] = action.to_dict()
|
||||
return [action]
|
||||
key, info = str(offered_key), self.data.task(offered_key)
|
||||
if key in active or key in finished or not info or info.get("type") != 4:
|
||||
continue
|
||||
if not self._commission_offer_ready(snapshot, quest_policy, policy, ranch_policy, info)[0]:
|
||||
continue
|
||||
action = self._intent(scope, {"id": 0, "typeId": key}, 0, info.get("startStep") or {},
|
||||
"progression_loop_accept", "接取城市委托:" + info.get("name", key), policy,
|
||||
path="taskService/taskLoopReceive", payload={"taskTypeId": key, "city": city}, phase=str(today))
|
||||
self._issued[action.token] = action.to_dict()
|
||||
return [action]
|
||||
return blocked
|
||||
|
||||
def commission_rows(self, snapshot, quest_policy, ranch_policy, *, battle_policy=None):
|
||||
|
||||
Reference in New Issue
Block a user