|
|
@@ -49,13 +49,21 @@ class Host(Mqtt, Player):
|
|
|
# 其他人上线,就广播自己的策略出去
|
|
|
if 'type' in data:
|
|
|
logger.info(f'Player {player} is online')
|
|
|
+ self.q_publish.put(['Strategy', self.publish_data()])
|
|
|
else:
|
|
|
# 如果是其他人像
|
|
|
pass
|
|
|
|
|
|
-
|
|
|
def on_last_will(self, player: str, data: dict):
|
|
|
- pass
|
|
|
+ if player not in self.players:
|
|
|
+ logger.warning(f'Player {player} is not in players')
|
|
|
+ return
|
|
|
+ self.players.remove(player)
|
|
|
+ logger.info(f'Player {player} is offline')
|
|
|
+ self._config_to_player()
|
|
|
+ self._update_strategy()
|
|
|
+ self._player_to_config()
|
|
|
+ self.q_publish.put(['Strategy', self.publish_data()])
|
|
|
|
|
|
def on_task_start(self, player: str, data: dict):
|
|
|
pass
|
|
|
@@ -63,7 +71,7 @@ class Host(Mqtt, Player):
|
|
|
def on_strategy(self, player: str, data: dict):
|
|
|
pass
|
|
|
|
|
|
- def update_multi_tasks(self):
|
|
|
+ def _config_to_player(self):
|
|
|
"""
|
|
|
作为主角, 更新自身的多人任务的缓存
|
|
|
也就是从 config -> multi_tasks
|
|
|
@@ -125,9 +133,25 @@ class Host(Mqtt, Player):
|
|
|
role=role,
|
|
|
limit_count=limit_count)
|
|
|
|
|
|
- def update_strategy(self):
|
|
|
+ def _player_to_config(self):
|
|
|
+ for key, value in self.multi_tasks.items():
|
|
|
+ if key == 'orochi':
|
|
|
+ self.config.task_delay(task='Orochi', target=value.next_run)
|
|
|
+ elif key == 'fallen_sun':
|
|
|
+ self.config.task_delay(task='FallenSun', target=value.next_run)
|
|
|
+ elif key == 'eternity_sea':
|
|
|
+ self.config.task_delay(task='EternitySea', target=value.next_run)
|
|
|
+ elif key == 'evo_zone':
|
|
|
+ self.config.task_delay(task='EvoZone', target=value.next_run)
|
|
|
+ elif key == 'exploration':
|
|
|
+ # TODO 等待探索完成
|
|
|
+ pass
|
|
|
+ else:
|
|
|
+ continue
|
|
|
+
|
|
|
+ def _update_strategy(self):
|
|
|
"""
|
|
|
- 更新策略
|
|
|
+ 更新策略:
|
|
|
:return:
|
|
|
"""
|
|
|
pass
|
|
|
@@ -139,7 +163,7 @@ if __name__ == '__main__':
|
|
|
host = Host(Config('oas1'))
|
|
|
sleep(20)
|
|
|
# 更新config -> multi_tasks -> publish_data
|
|
|
- host.update_multi_tasks()
|
|
|
+ host._config_to_player()
|
|
|
host.q_publish.put(['Strategy' ,host.publish_data()])
|
|
|
host.q_publish.put(['Strategy' ,host.publish_data()])
|
|
|
host.q_publish.put(['Strategy' ,host.publish_data()])
|