Skip to content
Snippets Groups Projects
Select Git revision
  • a152b729204d4f0f7f9b058bdcd82d32e255c2aa
  • main default protected
  • correction_video
  • going_further
  • ImprovedMouseInteraction
  • final2023
  • template
  • ModifGUI
8 results

SeedsState.java

Blame
  • Forked from YAGOUBI Rim / Game of life Template
    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;
        }
        
    }