From 496781fc0f3047b2b9f153b8ff555e580dbaf650 Mon Sep 17 00:00:00 2001 From: Minidodo Date: Mon, 6 Sep 2021 22:06:42 +0200 Subject: [PATCH] Added the "temp-leader" back (!leader set now raises the rank, and is not visual-only) !loot add also works for players without accounts now (i.e. outside the alliance) --- modules/core/accounting/services/account_service.py | 5 +++++ modules/standard/loot/loot_controller.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/core/accounting/services/account_service.py b/modules/core/accounting/services/account_service.py index d09b900..edb9d72 100644 --- a/modules/core/accounting/services/account_service.py +++ b/modules/core/accounting/services/account_service.py @@ -16,6 +16,8 @@ from modules.core.accounting.services.access_service import AccessService # noinspection SqlCaseVsIf,SqlResolve,PyMethodMayBeStatic + + @instance() class AccountService: MAIN_CHANGED_EVENT_TYPE = "main_changed" @@ -37,6 +39,7 @@ class AccountService: self.pork: PorkService = registry.get_instance("pork_service") self.setting_service: SettingService = registry.get_instance("setting_service") self.text: Text = registry.get_instance("text") + self.leader = registry.get_instance("leader_controller", is_optional=True) def pre_start(self): self.db.exec("CREATE TABLE IF NOT EXISTS account (" @@ -433,6 +436,8 @@ class AccountService: return "council" in self.get_ranks(char_id) def check_leader(self, char_id) -> bool: + if self.leader and self.leader.leader and self.leader.leader.char_id == char_id: + return True if self.simple_checks(self.get_account(char_id)): return "leader" in self.get_ranks(char_id) diff --git a/modules/standard/loot/loot_controller.py b/modules/standard/loot/loot_controller.py index 0817a40..250483c 100644 --- a/modules/standard/loot/loot_controller.py +++ b/modules/standard/loot/loot_controller.py @@ -148,7 +148,7 @@ class LootController: def loot_add_to_cmd(self, request, _, item_index: int): main = self.alts_service.get_account(request.sender.char_id) if self.raid_controller: - raider: Raider = self.raid_controller.is_in_raid(main.char_id) + raider: Raider = self.raid_controller.is_in_raid(main.get("char_id", -1)) if type(raider) == Raider: if not raider.is_active: self.bot.send_mass_message(request.sender.char_id, @@ -165,7 +165,7 @@ class LootController: if old_item.get_item_str() == loot_item.get_item_str(): name = "You have" if request.channel == "msg" else request.sender.name self.bot.send_mass_message(request.sender.char_id, - "%s already added to %s." % (name, loot_item.get_item_str())) + f"{name} already added to {loot_item.get_item_str()}.") old_item.bidders.remove(request.sender.name) loot_item.bidders.append(request.sender.name)