本文整理汇总了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)