package Core;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
/**
 * Class of a human player
 */
public class Human extends User implements KeyListener {
	/**
	 * Instance variables
	 */
	private int action;
	
	/**
	 * Construcotr
	 * @param id   id of the human
	 */
	public Human(int id) {
		super(id);
	}
	// 0 = stay
	// 1 = up
	// 2 = down
	// 3 = left
	// 4 = right
	// 5 = bomb
	@Override
	public void keyPressed(KeyEvent arg0) {
		if (getId() == 1) {			
			if (arg0.getKeyCode() == KeyEvent.VK_UP) {
				action = 1;
			}
			if (arg0.getKeyCode() == KeyEvent.VK_DOWN) {
				action = 2;
			}
			if (arg0.getKeyCode() == KeyEvent.VK_LEFT) {
				action = 3;
			}
			if (arg0.getKeyCode() == KeyEvent.VK_RIGHT) {
				action = 4;
			}
			if (arg0.getKeyCode() == KeyEvent.VK_SPACE) {
				action = 5;
			}
		} else {			
			if (arg0.getKeyCode() == KeyEvent.VK_W) {
				action = 1;
			}			
			if (arg0.getKeyCode() == KeyEvent.VK_S) {
				action = 2;
			}
			if (arg0.getKeyCode() == KeyEvent.VK_A) {
				action = 3;
			}
			if (arg0.getKeyCode() == KeyEvent.VK_D) {
				action = 4;
			}
			if (arg0.getKeyCode() == KeyEvent.VK_CONTROL) {
				action = 5;
			}
		}
	}
	@Override
	public void keyReleased(KeyEvent arg0) {
	}
	@Override
	public void keyTyped(KeyEvent arg0) {
		if (getId() == 1) {
			if (arg0.getKeyCode() == KeyEvent.VK_UP) {
				action = 1;
			}
			if (arg0.getKeyCode() == KeyEvent.VK_DOWN) {
				action = 2;
			}
			if (arg0.getKeyCode() == KeyEvent.VK_LEFT) {
				action = 3;
			}
			if (arg0.getKeyCode() == KeyEvent.VK_RIGHT) {
				action = 4;
			}
			if (arg0.getKeyCode() == KeyEvent.VK_SPACE) {
				action = 5;
			}
		} else {
			if (arg0.getKeyCode() == KeyEvent.VK_W) {
				action = 1;
			}			
			if (arg0.getKeyCode() == KeyEvent.VK_S) {
				action = 2;
			}
			if (arg0.getKeyCode() == KeyEvent.VK_A) {
				action = 3;
			}
			if (arg0.getKeyCode() == KeyEvent.VK_D) {
				action = 4;
			}
			if (arg0.getKeyCode() == KeyEvent.VK_CONTROL) {
				action = 5;
			}
		}
	}
	@Override
	public int getAction(Playboard playboard) {
		return action;
	}
	@Override
	public void resetMove() {
		action = 0;
	}
	@Override
	public void gameOver(boolean won, Playboard playboard) {
		// do nothing
	}
}
最近下载更多
                
                adap12345     LV5
                2023年6月8日
            
            
        
                hkxyyz     LV6
                2023年3月2日
            
            
        
                总有人间一两风      LV8
                2022年12月12日
            
            
        
                liangge2115     LV27
                2022年11月7日
            
            
        
                微信网友_6004879537377280     LV3
                2022年6月22日
            
            
        
                jytjyt     LV1
                2021年12月16日
            
            
        
                ssssqweq     LV1
                2021年11月1日
            
            
        
                此次东方     LV1
                2021年10月20日
            
            
        
                qliu0130     LV1
                2021年10月10日
            
            
        
                zpy123     LV1
                2021年7月18日
            
            
        
最近浏览更多
                
                chengjingjingjing    
                6月19日
            
            
                    暂无贡献等级
            
        
                微信网友_7556291372584960    
                6月16日
            
            
                    暂无贡献等级
            
        
                qqqww11     LV2
                2024年6月26日
            
            
        
                鬼屋报道     LV3
                2024年6月4日
            
            
        
                ClydeSon     LV5
                2023年12月27日
            
            
        
                bangyiyang     LV2
                2023年12月21日
            
            
        
                1112WHQ     LV7
                2023年11月3日
            
            
        
                微信网友_6672184532766720     LV3
                2023年10月6日
            
            
        
                srrrrrr    
                2023年9月19日
            
            
                    暂无贡献等级
            
        
                adap12345     LV5
                2023年6月8日
            
            
        
                
    
                