Examples of BazaarItem


Examples of com.jcloisterzone.game.capability.BazaarItem

    public void loadGame(Snapshot snapshot) {
        setEntered(true); //avoid call enter on load phase to this phase switch
        Player selecting = bazaarCap.getBazaarTileSelectingPlayer();
        if (selecting != null) {
            Player bidding = bazaarCap.getBazaarBiddingPlayer();
            BazaarItem currentItem = bazaarCap.getCurrentBazaarAuction();
            int supplyIdx = bazaarCap.getBazaarSupply().indexOf(currentItem);
            //game.fireGameEvent().playerActivated(game.getTurnPlayer(), getActivePlayer());

            if (bidding == null) {
                game.post(new BazaarSelectTileEvent(getActivePlayer(), bazaarCap.getBazaarSupply()));
View Full Code Here

Examples of com.jcloisterzone.game.capability.BazaarItem

            logger.error("Invalid message");
            return;
        }
        ArrayList<BazaarItem> supply = new ArrayList<BazaarItem>(size);
        for (Tile t : getTilePack().drawTiles(msg.getValues())) {
            supply.add(new BazaarItem(t));
        }
        bazaarCap.setBazaarSupply(supply);
        game.post(new BazaarSelectTileEvent(getActivePlayer(), supply));
    }
View Full Code Here

Examples of com.jcloisterzone.game.capability.BazaarItem

        return true;
    }

    @Override
    public void bazaarBid(Integer supplyIndex, Integer price) {
        BazaarItem bi = bazaarCap.getCurrentBazaarAuction();
        boolean isTileSelection = bi == null;
        if (bi == null) {
            bi = bazaarCap.getBazaarSupply().get(supplyIndex);
            bazaarCap.setCurrentBazaarAuction(bi);

            if (game.hasRule(CustomRule.BAZAAR_NO_AUCTION)) {
                bi.setOwner(getActivePlayer());
                nextSelectingPlayer();
                return;
            }
        }
        bi.setCurrentPrice(price);
        bi.setCurrentBidder(getActivePlayer());

        if (isTileSelection) {
            game.post(new BazaarTileSelectedEvent(getActivePlayer(), bi, supplyIndex));
        }
        nextBidder();
View Full Code Here

Examples of com.jcloisterzone.game.capability.BazaarItem

        nextBidder();
    }

    private void nextBidder() {
        Player nextBidder = getActivePlayer();
        BazaarItem currentItem = bazaarCap.getCurrentBazaarAuction();
        int supplyIdx = bazaarCap.getBazaarSupply().indexOf(currentItem);
        do {
            nextBidder = game.getNextPlayer(nextBidder);
            if (nextBidder == bazaarCap.getBazaarTileSelectingPlayer()) {
                //all players makes bid
                BazaarItem bi = bazaarCap.getCurrentBazaarAuction();
                if (bazaarCap.getBazaarTileSelectingPlayer() == bi.getCurrentBidder()) {
                    bazaarBuyOrSell(true);
                } else {
                    bazaarCap.setBazaarBiddingPlayer(bazaarCap.getBazaarTileSelectingPlayer()); //need for correct save&load
                    //game.fireGameEvent().playerActivated(game.getTurnPlayer(), getActivePlayer());
                    game.post(new BazaarSelectBuyOrSellEvent(getActivePlayer(), currentItem, supplyIdx));
View Full Code Here

Examples of com.jcloisterzone.game.capability.BazaarItem

        nextBidder();
    }

    @Override
    public void bazaarBuyOrSell(boolean buy) {
        BazaarItem bi = bazaarCap.getCurrentBazaarAuction();
        int points = bi.getCurrentPrice();
        Player pSelecting = bazaarCap.getBazaarTileSelectingPlayer();
        Player pBidding = bi.getCurrentBidder();

        assert pSelecting != pBidding || buy; //if same, buy is flag expected
        if (!buy) points *= -1;
        pSelecting.addPoints(-points, PointCategory.BAZAAR_AUCTION);
        if (pSelecting != pBidding) {
            pBidding.addPoints(points, PointCategory.BAZAAR_AUCTION);
        }

        bi.setOwner(buy ? pSelecting : pBidding);
        bi.setCurrentBidder(null);
        nextSelectingPlayer();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.