Пример #1
0
    def fix_building(self, unit):
        building = Building.query.filter_by(battle=unit.battle,
                                            x=unit.x,
                                            y=unit.y).one()

        building.owner = unit.owner
        unit.did_fix = True
        db_session.commit()

        self.shared_commands.append(
            Command.update_building(building, {
                'state': 'normal',
            }))

        self.sync_selected_unit()
Пример #2
0
    def occupy_building(self, unit):
        building = Building.query.filter_by(battle=unit.battle,
                                            x=unit.x,
                                            y=unit.y).one()

        prev_owner = building.owner
        building.owner = unit.owner
        unit.did_occupy = True
        db_session.commit()

        self.shared_commands.append(
            Command.update_building(building, {
                'color': building.owner.color,
            }))

        self.sync_selected_unit()

        if prev_owner:
            self.check_players_defeat(prev_owner)