
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;

public class Card {
    int attack;
    int defense;
    int ID;
    String name;

    String line;
    BufferedReader in;
    
    public Card(){};
    
    public Card(int id){
        try{
            BufferedReader buf = new BufferedReader(new FileReader("src\\MediaResources\\database.txt"));
            String lineJustFetched = null;
            String[] wordsArray;

            while(true){
                lineJustFetched = buf.readLine();
                if(lineJustFetched == null){  
                    break; 
                }else{
                    wordsArray = lineJustFetched.split("\t");
                    int lineID = Integer.parseInt(wordsArray[0]);
                    if(lineID==id) {
                        ID=Integer.parseInt(wordsArray[0]);
                        name = wordsArray[1];
                        attack = Integer.parseInt(wordsArray[2]);
                        defense = Integer.parseInt(wordsArray[3]);
                        
                        break;
                    }
                }
            }

            

            buf.close();

        }catch(Exception e){
            e.printStackTrace();
        }
    
}
    
    public int getID(){
        return ID;
    }
    public int getATK(){
        return attack;
    }
    public int getDEF(){
        return defense;
    }
    public String getNAME(){
        return name;
    }
    public String getCardIDPath(){
        String IDstr;
        IDstr = Integer.toString(this.getID());
        String IDlocation = "/MediaResources/" + IDstr +".jpg";
        //System.out.format("from Card getCardIDPath(int pos): %s",IDlocation);
        return IDlocation;
    }
}
