package com.yaohun.wheatwar.liveevent;

import com.yaohun.wheatwar.WheatWar;
import com.yaohun.wheatwar.effect.*;
import com.yaohun.wheatwar.game.Game;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import tools.GameUtil;
import tools.RandomUtil;

public class GiftEventHandler {

    public static void SendHandLer(Player zhubo, String userName, String eventName){
        Game game = WheatWar.getGame();
        userName = GameUtil.hideName(userName);
        if (eventName.contains("小羊哥")) {
            int amount = 1;
            if(eventName.contains("X") || eventName.contains("x") || eventName.contains("*")) {
                eventName = eventName.replace("*","X");
                String[] eventSp = eventName.toUpperCase().split("X");
                amount = Integer.parseInt(eventSp[1]);
            }
            SummonTheSheep.apply(game, zhubo, userName, amount);
        } else if (eventName.contains("小红羊")) {
            int amount = 1;
            if(eventName.contains("X") || eventName.contains("x") || eventName.contains("*")) {
                eventName = eventName.replace("*","X");
                String[] eventSp = eventName.toUpperCase().split("X");
                amount = Integer.parseInt(eventSp[1]);
            }
            SummonTheSheepPro.apply(game, zhubo, userName, amount);
        } else if (eventName.contains("暴躁村民")) {
            int amount = 1;
            if(eventName.contains("X") || eventName.contains("x") || eventName.contains("*")) {
                eventName = eventName.replace("*","X");
                String[] eventSp = eventName.toUpperCase().split("X");
                amount = Integer.parseInt(eventSp[1]);
            }
            SummonTheVillagerPro.apply(game, zhubo, userName, amount);
        }else if (eventName.contains("村民")) {
            int amount = 1;
            if(eventName.contains("X") || eventName.contains("x") || eventName.contains("*")) {
                eventName = eventName.replace("*","X");
                String[] eventSp = eventName.toUpperCase().split("X");
                amount = Integer.parseInt(eventSp[1]);
            }
            SummonTheVillager.apply(game, zhubo, userName, amount);
        } else if (eventName.contains("僵尸")) {
            int amount = 1;
            if(eventName.contains("X") || eventName.contains("x") || eventName.contains("*")) {
                eventName = eventName.replace("*","X");
                String[] eventSp = eventName.toUpperCase().split("X");
                amount = Integer.parseInt(eventSp[1]);
            }
            SummonTheZombie.apply(game, zhubo, userName, amount);
        } else if (eventName.contains("炸弹")) {
            int amount = 1;
            if(eventName.contains("X") || eventName.contains("x") || eventName.contains("*")) {
                eventName = eventName.replace("*","X");
                String[] eventSp = eventName.toUpperCase().split("X");
                amount = Integer.parseInt(eventSp[1]);
            }
            SummonTheBombsTNT.apply(game, zhubo, userName, amount);
        } else if (eventName.equalsIgnoreCase("无差别轰炸")) {
            SummonTheTNTRain.apply(game,zhubo,userName,50);
        }
    }
}
