Package com.jcloisterzone.game.phase

Source Code of com.jcloisterzone.game.phase.FairyPhase

package com.jcloisterzone.game.phase;

import com.jcloisterzone.PointCategory;
import com.jcloisterzone.board.Position;
import com.jcloisterzone.event.ScoreEvent;
import com.jcloisterzone.figure.Meeple;
import com.jcloisterzone.game.Game;
import com.jcloisterzone.game.capability.FairyCapability;


public class FairyPhase extends Phase {

    private final FairyCapability fairyCap;

    public FairyPhase(Game game) {
        super(game);
        fairyCap = game.getCapability(FairyCapability.class);
    }

    @Override
    public boolean isActive() {
        return game.hasCapability(FairyCapability.class);
    }

    @Override
    public void enter() {
        Position fairyPos = fairyCap.getFairyPosition();
        if (fairyPos != null) {
            for (Meeple m : game.getDeployedMeeples()) {
                if (m.at(fairyPos) && m.getPlayer() == getActivePlayer()) {
                    m.getPlayer().addPoints(1, PointCategory.FAIRY);
                    game.post(new ScoreEvent(m.getPosition(), m.getPlayer(), 1, PointCategory.FAIRY));
                    break;
                }
            }
        }
        next();
    }


}
TOP

Related Classes of com.jcloisterzone.game.phase.FairyPhase

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.