Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doomguard incorrectly summons Silverware Golem twice without discarding it #361

Open
doctorpangloss opened this issue Jun 27, 2017 · 1 comment

Comments

@doctorpangloss
Copy link
Contributor

doctorpangloss commented Jun 27, 2017

Doomguard summons a Silverware Golem twice from your hand, as long as there is one copy, and go about its business discarding cards otherwise. It's extremely mysterious to me why it is broken based on the code below:

	@Override
	protected boolean fire(GameEvent event, Entity host) {
		DiscardEvent discardEvent = (DiscardEvent) event;
		EntityReference target = (EntityReference) desc.get(EventTriggerArg.TARGET);
		if (target == EntityReference.SELF && discardEvent.getCard() != host) {
			return false;
		}
		
		return true;
	}

I changed the code to this, and fixed the bug.

	@Override
	protected boolean fire(GameEvent event, Entity host) {
		DiscardEvent discardEvent = (DiscardEvent) event;
		EntityReference target = (EntityReference) desc.get(EventTriggerArg.TARGET);
		TargetPlayer targetPlayer = (TargetPlayer) desc.get(EventTriggerArg.TARGET_PLAYER);


		final int owner = host.getOwner();

		boolean targetPlayerSatisfied = targetPlayer == null
				|| (targetPlayer == TargetPlayer.SELF && owner == event.getTargetPlayerId())
				|| (targetPlayer == TargetPlayer.OWNER && owner == event.getTargetPlayerId());

		boolean targetSatisfied = target == null;

		if (target != null) {
			List<Entity> resolvedTargets = event.getGameContext().resolveTarget(event.getGameContext().getPlayer(owner), host, target);
			targetSatisfied = resolvedTargets != null && resolvedTargets.stream().anyMatch(e -> e.getId() == discardEvent.getCard().getId());
		}

		return targetPlayerSatisfied && targetSatisfied;
	}
@doctorpangloss doctorpangloss changed the title Doomguard incorrect summons Silverware Golem twice without discarding it Doomguard incorrectly summons Silverware Golem twice without discarding it Jun 27, 2017
@doctorpangloss
Copy link
Contributor Author

The code above was updated to pass all tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant