package re.forestier.edu.rpg;

import java.io.File;  
import java.io.IOException;  
import java.io.FileWriter; 


public class Affichage {

    public static void afficherJoueur(Player player) 
    {
        System.out.println(player.toString());
    }

    public static void playerToMarkDown(Player p)
    {
        try 
        {
            File playerFile = new File("./"+p.getAvatarName()+".md");
            FileWriter myWriter = new FileWriter(playerFile);
            myWriter.write(p.toMarkDown());
            myWriter.close();
        } catch (IOException e) 
        {
            System.err.println("An error occurred.");
            e.printStackTrace();
        }
    }

    public static void playerToMarkDown(Player p, String path)
    {
        try 
        {
            File playerFile = new File(path+p.getAvatarName()+".md");
            FileWriter myWriter = new FileWriter(playerFile);
            myWriter.write(p.toMarkDown());
            myWriter.close();
        } catch (IOException e) 
        {
            System.err.println("An error occurred.");
            e.printStackTrace();
        }
    }
}
