def military_building_menu(self, menu, player_b): """prints the menu for a military building. DO NOT USE DIRECTLY. use get_building_menu to create""" building_menu = {} for u in self.get_buildable_units(menu.author, player_b): f = menu.build_f(self.prep_units, (menu.author, menu.channel, player_b, u)) building_menu[u.emoji] = Menu.Menupoint( u.name + "\tcost: " + get_resource_str(u.price), menu.get_recall_wrapper(f, self.get_building_menu(player_b))) building_menu["🏃"] = Menu.Menupoint( "prepped", menu.build_f(self.print_building_prepared, (menu.channel, player_b))) building_menu["👍"] = Menu.Menupoint( "start training", menu.get_recall_wrapper( menu.build_f(self.start_building_prepped, (menu.author, menu.channel, player_b)), self.get_building_menu(player_b))) building_menu["👷"] = Menu.Menupoint( "currently building", menu.build_f(self.print_building_threads, (menu.channel, player_b))) if player_b.build_prep: building_menu["🛑"] = Menu.Menupoint( "clear prepped solders", menu.get_recall_wrapper(lambda: player_b.clear_build_prep(), self.get_building_menu(player_b), async=False)) building_menu["⬅"] = Menu.Menupoint("return", self.military_menu, submenu=True) menu.header = get_resource_str(self.get_player(menu.author).resources, detail=True) menu.change_menu(building_menu)
def build_menu(self, menu): build_menu = {} for b in self.get_buildable(menu.author): f = menu.build_f(self.build, (menu.author, menu.channel, b)) build_menu[b.emoji] = Menu.Menupoint( b.name + "\t cost:{}, time: {}".format(get_resource_str(b.build_cost), self.get_time_str(b.build_time)), menu.get_recall_wrapper(f, self.build_menu)) build_menu["⬅"] = Menu.Menupoint("return", self.candy_manor_menu, submenu=True) menu.header = get_resource_str(self.get_player(menu.author).resources, detail=True) menu.change_menu(build_menu)
def upgrade_menu(self, menu): upgrade_menu = {} for b in self.get_upgradable(menu.author): f = menu.build_f(self.upgrade, (menu.author, menu.channel, b)) upgrade_menu[b.emoji] = Menu.Menupoint( b.name + "\t cost:{:<50}, time:{}".format( get_resource_str(b.next_price()), self.get_time_str(b.next_time())), menu.get_recall_wrapper(f, self.upgrade_menu)) upgrade_menu["⬅"] = Menu.Menupoint("return", self.candy_manor_menu, submenu=True) menu.header = get_resource_str(self.get_player(menu.author).resources, detail=True) menu.change_menu(upgrade_menu)
def military_menu(self, menu): military_menu = {} player = self.get_player(menu.author) for player_b in player.buildings: if issubclass(player_b.__class__, Building.Military): f = self.get_building_menu(player_b) military_menu[player_b.emoji] = Menu.Menupoint(player_b.name, f, submenu=True) # military_menu["🎖"] = Menu.Menupoint("units", menu.build_f(self.print_units, (menu.author, menu.channel))) military_menu["🎖"] = Menu.Menupoint("units", self.rally_troops_menu, submenu=True) if player.rallied_units: military_menu["➡"] = Menu.Menupoint( "start attack", menu.get_recall_wrapper( menu.build_f(self.attack, (menu.author, menu.channel)), self.military_menu)) if player.attack_threads or player.return_threads: military_menu["🔜"] = Menu.Menupoint( "current attacks", menu.build_f(self.print_attacks, (menu.author, menu.channel))) military_menu["⬅"] = Menu.Menupoint("return", self.main_menu, submenu=True) menu.header = get_resource_str(self.get_player(menu.author).resources, detail=True) menu.change_menu(military_menu)
def resource_menu(self, menu): m = { "🍪": Menu.Menupoint( "resources", menu.build_f(self.print_resources, (menu.author, menu.channel))), "⬅": Menu.Menupoint("return", self.main_menu, submenu=True), } menu.header = get_resource_str(self.get_player(menu.author).resources) menu.change_menu(m)
def f(): loot = attack(u, target_p) self.return_units(u, loot, time) # start a return of the units loot_str = "====================\n%s\n====================s" % get_resource_str( loot) self.messages.append( "you successfully attacked **%s** and looted:\n%s\nYour units will be back in %s" % (target_p.owner_name, loot_str, get_time_str(time * Player.unit_time_f()))) target_p.messages.append( "you got raided by **%s** and he/she looted:\n%s" % (self.owner_name, loot_str))
def main_menu(self, menu): main_menu = { "🍭": Menu.Menupoint("Candy Manor", self.candy_manor_menu, submenu=True), "⚔": Menu.Menupoint("Military District", self.military_menu, submenu=True), "❓": Menu.Menupoint("Help", menu.build_f(self.print_help, [menu.channel])), } menu.header = get_resource_str(self.get_player(menu.author).resources, detail=True) menu.change_menu(main_menu)
def candy_manor_menu(self, menu): m = { "🛠": Menu.Menupoint("build", self.build_menu, submenu=True), "⬆": Menu.Menupoint("upgrade", self.upgrade_menu, submenu=True), "🍪": Menu.Menupoint( "resources", menu.build_f(self.print_resources, (menu.author, menu.channel))), "👷": Menu.Menupoint( "currently building", menu.build_f(self.print_threads, (menu.author, menu.channel))), "🗺": Menu.Menupoint( "town overview", menu.build_f(self.print_town, (menu.author, menu.channel))), "⬅": Menu.Menupoint("return", self.main_menu, submenu=True), } menu.header = get_resource_str(self.get_player(menu.author).resources) menu.change_menu(m)