if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
Permanent tokenPermanent = game.getPermanent(token.getLastAddedToken());
if (tokenPermanent != null) {
//TODO: Make sure the Equipment can legally enchant the token, preferably on targetting.
Target target = new TargetControlledPermanent(0, 1, filter, true);
if (target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), game)) {
Permanent equipmentPermanent = game.getPermanent(target.getFirstTarget());
if (equipmentPermanent != null) {
Permanent attachedTo = game.getPermanent(equipmentPermanent.getAttachedTo());
if (attachedTo != null) {
attachedTo.removeAttachment(equipmentPermanent.getId(), game);