{"size": 982, "ext": "js", "max_stars_repo_path": "server/game/cards/14-FotS/BastardOfRobert.js", "max_stars_repo_name": "Bullgator351/throneteki", "max_stars_repo_stars_event_min_datetime": "2016-11-06T15:14:28.000Z", "max_stars_repo_stars_event_max_datetime": "2018-05-14T21:12:36.000Z", "max_issues_repo_path": "server/game/cards/14-FotS/BastardOfRobert.js", "max_issues_repo_name": "Bullgator351/throneteki", "max_issues_repo_issues_event_min_datetime": "2016-11-07T01:07:55.000Z", "max_issues_repo_issues_event_max_datetime": "2018-05-16T09:12:57.000Z", "max_forks_repo_path": "server/game/cards/14-FotS/BastardOfRobert.js", "max_forks_repo_name": "Bullgator351/throneteki", "max_forks_repo_forks_event_min_datetime": "2016-11-06T15:14:38.000Z", "max_forks_repo_forks_event_max_datetime": "2018-04-23T10:34:19.000Z"}
{"max_stars_count": 49, "max_issues_count": 831, "max_forks_count": 54, "avg_line_length": 31.6774193548, "max_line_length": 118, "alphanum_fraction": 0.5254582485}
const DrawCard = require('../../drawcard');

class BastardOfRobert extends DrawCard {
    setupCardAbilities(ability) {
        this.persistentEffect({
            location: 'any',
            condition: () => this.controller.anyCardsInPlay(card => card.name === 'Robert Baratheon'),
            targetController: 'current',
            effect: ability.effects.reduceSelfCost('marshal', 2)
        });

        this.reaction({
            when: {
                onCardEntersPlay: event => (
                    event.card === this &&
                    this.controller.anyCardsInPlay(card => card.getType() === 'character' && card.hasTrait('King')) &&
                    this.controller.canDraw()
                )
            },
            message: '{player} uses {source} to draw 1 card',
            handler: context => {
                context.player.drawCardsToHand(1);
            }
        });
    }
}

BastardOfRobert.code = '14015';

module.exports = BastardOfRobert;
