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


Python Resource.buy_resource方法代码示例

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


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

示例1: main

# 需要导入模块: import Resource [as 别名]
# 或者: from Resource import buy_resource [as 别名]
    def main(self):

        # TODO Load the map blocked need map object

        # init turns
        # TODO
        self.initializePlayerTurns()
        for player in reversed(self.players):
            while len(player.get_PowerPlants()) == 0:
                auction = Auction.Auction(
                    self.Table.getDeck(), self.Table.getCardsForAuction() + self.Table.getFutureCardsForAuction()
                )
                # TODO Anandh add auction stuff

        while not self.gameover:
            print("buy resources")
            # PHASE 2 bid for resources
            for player in self.players:
                request = {}
                request[Resource.COAL] = player.getCoalRequest()
                request[Resource.OIL] = player.getOilRequest()
                request[Resource.GARBAGE] = player.getGarbageRequest()
                request[Resource.URANIUM] = player.getUraniumRequest()
                cost = Resource.buy_resource(request)
                if cost == 0:
                    player.warn(NOT_ENOUGH_RESOURCES)
                elif cost <= player.f_b_get_money():
                    player.pay(cost)
                    player.add_coal(request[Resource.COAL])
                    player.add_oil(request[Resource.OIL])
                    player.add_garbage(request[Resource.GARBAGE])
                    player.add_uranium(request[Resource.URANIUM])
                else:
                    # This case there is not enough money
                    player.warn(NOT_ENOUGH_MONEY)
            self.ResourceMarket.restore_resources()

            # PHASE 3 buy cities
            # TODO Blocked no map available

            # PHASE 4 power cities
            for player in self.players:
                player.powerCities()
                # TODO check game end

                # PHASE 5 pay the players
            for player in self.players:
                player.addMoney(payday.pay(player.get_cities_powered))

                # Check if advance to 2
            if self.currentPhase == 1:
                self.checkAdvancePhaseTwo()

            for player in self.players:
                if player.get_cities() >= self.GAMEEND[self.numPlayers]:
                    self.gameover = True
                    # PHASE 1 bid for power plants
            self.players = calculateTurns()
            availableCards = self.Table.getCardsForAuction()
            futureCards = self.Table.getFutureCardsForAuction()
            self.checkAdvancePhaseThree(availableCards)
            # Pass to players
            # TODO Auction
            print("Bid for power plants")
            auction = Auction.Auction(self.Table.getDeck(), availableCards + futureCards)
开发者ID:straemer,项目名称:PowerGrid,代码行数:67,代码来源:gamemaster.py


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