Skip to content
Snippets Groups Projects
Select Git revision
  • 03a673c400a612aafc7f6962759fc115d9b0cc9e
  • main default protected
  • variant
3 results

NextGenerationUpdater.java

Blame
  • Forked from COUETOUX Basile / FirefighterStarter
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    Knight.java 621 B
    public class Knight extends Piece {
    
        public Knight(int x, int y, Player owner){
    		super(x, y, owner);
    		
        }
    
        public boolean isMoveAuthorized(Board board, Coordinates destination){
    	int dx = destination.getX();
    	int dy = destination.getY();
    	int ox = this.getX();
    	int oy = this.getY();
    	for(int i=-2; i <= 2; i++) {
    		for(int j=-2; j <= 2; j++) {
    			if(((dx-ox)%2==1 && (dy-oy)%2==0) || ((dx-ox)%2==0 && (dy-oy)%2==1)) {
    				return true;
    			}
    		}
    	}
    
    
    	return false;
        }
    
        @Override
        public Type getType() {
    	return Type.KNIGHT;
        }
    
        @Override
        public int getValue() {
    	return 3;
        }
        
    }