Created
July 21, 2012 18:02
-
-
Save dsociative/3156578 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf8 | |
from tests.controller.building.BuildingCommon import BuildingCommon | |
from tycoon.controller.CommandBase import CommandBase | |
class BuildingBuild(CommandBase, BuildingCommon): | |
params = 'location_id', 'building_id', 'x', 'y', 'r' | |
requires = 'user', 'location', 'balance_building', | |
name = 'building.build' | |
def execute(self, location_id, building_id, x, y, r, **kwargs): | |
state = self.balance_building.getState(0) | |
if not self.check_common(): | |
return self.msg | |
elif not self.balance_building.can_buy(self.user.profile.level, | |
self.store): | |
return self.msg.error('not sale') | |
elif not self.user.pay(state.price_type, state.price_value, | |
cmd=self.name, | |
building_id=building_id): | |
return self.msg.error('not enough money') | |
building = self.location.add_building(building_id, x, y, r) | |
self.msg.changes(building) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment