Ejemplo n.º 1
0
    def run(self, move: BuyPrivateCompanyMove, kwargs: MutableGameState) -> bool:
        move.backfill(kwargs)

        if BidType.BUY == move.move_type:
            if self.validateBuy(move, kwargs):
                move.private_company.setBelongs(move.player)
                return True

        if BidType.BID == move.move_type:
            if self.validateBid(move, kwargs):
                move.private_company.bid(move.player, move.bid_amount)

                # From the perspective of costs going down, this counts as a pass.
                # Find the earliest unsold company and pass on it.
                earliest_unsold_private_companies = next(pc for pc in kwargs.private_companies
                                                    if pc.order < move.private_company_order and not pc.hasOwner())
                earliest_unsold_private_companies.passed(move.player)
                earliest_unsold_private_companies.reduce_price(kwargs.players)
                return True

        if BidType.PASS == move.move_type:
            if self.validatePass(move, kwargs):
                move.private_company.passed(move.player)
                move.private_company.reduce_price(kwargs.players)
                return True

        return False
Ejemplo n.º 2
0
    def run(self, move: BuyPrivateCompanyMove,
            kwargs: MutableGameState) -> bool:
        move.backfill(kwargs)

        if BidType.BID == move.move_type:
            if self.validateBid(move):
                move.private_company.bid(move.player, move.bid_amount)
                self.validateSold(move)
                return True

        if BidType.PASS == move.move_type:
            if self.validatePass(move):
                move.private_company.passed(move.player)
                move.private_company.passed_by.append(move.player)
                self.validateSold(move)
                return True

        return False