当前位置: 首页>>代码示例>>Python>>正文


Python Commands.show_city方法代码示例

本文整理汇总了Python中commands.Commands.show_city方法的典型用法代码示例。如果您正苦于以下问题:Python Commands.show_city方法的具体用法?Python Commands.show_city怎么用?Python Commands.show_city使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在commands.Commands的用法示例。


在下文中一共展示了Commands.show_city方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from commands import Commands [as 别名]
# 或者: from commands.Commands import show_city [as 别名]
class Engine:
    def __init__(self, player, screen):
        self.player = player
        self.commands = Commands(self)
        self.screen = screen
        self.city = None
        self.menus = None
        self.current_menu = None
        self.resources = None
        self.industries = None
        self.ai_companies = []

    def preload_cfg(self):
        self.menus = json.load(open("data/menus.cfg"))
        self.resources = json.load(open("data/resources.cfg"))
        self.industries = json.load(open("data/industries.cfg"))

    def start(self):
        print "Starting"
        self.update_options(self.menus["title_menu"])
        self.screen.update_main_win("Title Screen")
        self.screen.init_screen()

    def update_options(self, menu_data):
        # Unbind all previous keys
        if self.current_menu is not None:
            for option in self.current_menu["options"].items():
                self.screen.root.unbind(option[0])

        txt = ""
        for option in menu_data["options"].items():
            o_key = option[0]
            o_str = option[1][0]
            o_cb = option[1][1]
            txt += "(%s) %s\n" % (o_key, o_str)

            # Bind callbacks
            cmd = getattr(self.commands, o_cb)
            if cmd:
                self.screen.root.bind(o_key, func=cmd)

        self.current_menu = menu_data
        self.screen.update_opts_win(txt)

    def new_game(self):
        # Create new city
        self.city = City()
        self.city.generate_name()
        self.city.generate_districts()

        # Generate AI companies
        for i in xrange(0, randrange(10, 20)):
            b = Business(self)
            b.starting_funds()
            b.randomize_production(self.industries, self.resources)
            b.generate_name()
            b.district = choice(self.city.districts.keys())
            # self.city.districts[b.district].companies.append(b)
            self.ai_companies.append(b)

            # for i in self.ai_companies:
            # 	print i.name, i.money, i.producing, i.district

        self.player.money = 1000000

        self.commands.show_city(None)
        self.update_options(self.menus["city_overview_menu"])

    def display_city_menu(self, districts=None):
        if districts is None:
            # By default, we sort by district name
            districts = self.city.districts_info()

        self.screen.display_column_data(
            "City: \n%s\n\n" % self.city.name, ["District", "Pop", "Income", "Unemployed", "%"], districts
        )

        self.update_options(self.menus["city_overview_menu"])

    def display_biz_menu(self, district=None):
        self.ai_companies
        self.screen.display_column_data("%s City\n\n" % self.city.name, ["Business", "Cash", ""])

    def end_turn(self):
        self.player.end_turn()
        txt = "%s\nTurn: %s" % (self.player.date.ctime(), self.player.turn)
        self.screen.update_head_win(txt)
开发者ID:Senso,项目名称:Kapital,代码行数:89,代码来源:engine.py


注:本文中的commands.Commands.show_city方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。