package me.rkfg.xmpp.bot.plugins.game.effect.item;

import static me.rkfg.xmpp.bot.plugins.game.misc.Attrs.*;

import java.util.Collection;

import me.rkfg.xmpp.bot.plugins.game.effect.ITemporaryEffect;
import me.rkfg.xmpp.bot.plugins.game.effect.StatsEffect;
import me.rkfg.xmpp.bot.plugins.game.event.IEvent;
import me.rkfg.xmpp.bot.plugins.game.event.StatsEvent;
import me.rkfg.xmpp.bot.plugins.game.misc.TypedAttribute;

public class DrunkEffect extends StatsEffect implements ITemporaryEffect {

    public static final String TYPE = "drunk";
    private static final TypedAttribute<Integer> CONCENTRATION = TypedAttribute.of("concentration");

    public DrunkEffect(Integer concentration) {
        super(TYPE, "пьян");
        initTemporary(5);
        setAttribute(CONCENTRATION, concentration);
    }

    @Override
    public void onBeforeAttach() {
        target.as(PLAYER_OBJ).ifPresent(p -> getAttribute(CONCENTRATION).ifPresent(c -> {
            if (p.hasTrait(AlcoEffect.TYPE)) {
                setStatChange(STR, 2 * c);
                setStatChange(ATK, c);
                setStatChange(DEF, -c);
            } else {
                setStatChange(ATK, -c);
                setStatChange(DEF, -c);
                target.enqueueEvent(new StatsEvent().setAttributeChain(HP, (int) Math.round(c * 1.5)));
            }
        }));
        super.onBeforeAttach();
    }

    @Override
    public Collection<IEvent> processEvent(IEvent event) {
        return processTemporary(event, TYPE);
    }

}

@@ -1105,32 +1105,106 @@
 hange(DEF, -c);%0A
+                p.log(%22%D0%90%D0%BB%D0%BA%D0%BE%D0%B3%D0%BE%D0%BB%D0%B8%D0%B7%D0%BC %D0%BF%D1%80%D0%B8%D0%B4%D0%B0%D1%91%D1%82 %D0%B2%D0%B0%D0%BC %D1%81%D0%B8%D0%BB, %D0%BD%D0%BE %D0%BB%D0%B8%D1%88%D0%B0%D0%B5%D1%82 %D1%80%D0%B0%D1%81%D1%81%D1%83%D0%B4%D0%BA%D0%B0.%22);%0A
             %7D el
@@ -1388,24 +1388,141 @@
 c * 1.5)));%0A
+                p.log(%22%D0%92%D1%8B %D0%BF%D0%BE%D0%BF%D1%80%D0%B0%D0%B2%D0%BB%D1%8F%D0%B5%D1%82%D0%B5 %D0%B7%D0%B4%D0%BE%D1%80%D0%BE%D0%B2%D1%8C%D0%B5 %D0%B0%D0%BB%D0%BA%D0%BE%D0%B3%D0%BE%D0%BB%D0%B5%D0%BC. %D0%9A %D0%BD%D0%B5%D1%81%D1%87%D0%B0%D1%81%D1%82%D1%8C%D1%8E, %D1%81%D1%80%D0%B0%D0%B6%D0%B0%D1%82%D1%8C%D1%81%D1%8F %D0%B2 %D1%82%D0%B0%D0%BA%D0%BE%D0%BC %D1%81%D0%BE%D1%81%D1%82%D0%BE%D1%8F%D0%BD%D0%B8%D0%B8 %D0%B1%D1%83%D0%B4%D0%B5%D1%82 %D1%81%D0%BB%D0%BE%D0%B6%D0%BD%D0%B5%D0%B5.%22);%0A
             

Comment on drunk effect