package J20250717.demo05;

import java.util.Scanner;

/**
 * @author WanJl
 * @version 1.0
 * @title Main
 * @description
 * @create 2025/7/17
 */
public class Main {

    Scanner sc=new Scanner(System.in);
    Hero h1=null;
    Hero h2=null;

    public static void main(String[] args) {
        /*Hero h1=new YaSe();
        System.out.println(h1);
        Hero h2=new DaJi();
        System.out.println(h2);

        h1.a(h2);
        System.out.println(h2.getName()+"的血量为："+h2.getHp());
        h2.a(h2);
        System.out.println(h2.getName()+"的血量为："+h2.getHp());*/

        new Main().show();

    }

    public void show(){
        System.out.println("游戏开始.....");
        System.out.println("请玩家1号选择英雄：");
        int v1 = sc.nextInt();
        switch (v1){
            case 1:
                h1=new DaJi();
                break;
            case 2:
                h1=new YaSe();
                break;
        }
        System.out.println("请玩家2号选择英雄：");
        int v2 = sc.nextInt();
        switch (v2){
            case 1:
                h2=new DaJi();
                break;
            case 2:
                h2=new YaSe();
                break;
        }
        while (true){
            boolean wj1 = play(h1, h2, "玩家1");
            boolean wj2 = play(h2, h1, "玩家2");
            if(wj1==false||wj2==false){
                return;
            }
        }

    }

    public boolean play(Hero w1,Hero w2,String wName){
        System.out.println("请"+wName+"选择操作：");
        System.out.println("1 攻击");
        System.out.println("2 移动");
        System.out.println("3 防御");
        System.out.println("4 逃跑");
        System.out.println("5 退出|投降");
        int h1v=sc.nextInt();
        switch (h1v){
            case 1:
                w1.a(w2);
                break;
            case 2:
                break;
            case 3:
                break;
            case 4:
                break;
            case 5:
                System.out.println(wName+w1.getName()+"投降"+w2.getName()+"胜利");
                return false;
        }
        return true;
    }

}
