/*
 * top_score.cpp
 * written by Brian Derr
 * 2002-12-26
 *
 * adds the ability to keep a top score for braincurses game
 */


// this isn't even close to done

#include <fstream>
#include <pwd.h>
#include <unistd.h>

#include <iostream>
using namespace std;

int writeScores( int turns );
void getScores( int i, char *name, int &score );
string getUser();

int writeScores( int turns )
{
   ifstream scoreIn;
   ofstream scoreOut;
   scoreIn.open("/usr/share/braincurses/braincurses.scores");

   string line1, line2, line3;
   
   getline( scoreIn, line1 );
   getline( scoreIn, line2 );
   getline( scoreIn, line3 );

   cout << line1 << '\n' << line2 << '\n' << line3 << endl;

   // line1.find( turns );

   // scoreOut.open("/usr/share/braincurses/braincurses.scores");
   // scoreOut << name << ' ' << score;
   // scoreOut.close();
   
   return( 0 );
}

   
void getScores( int _i, char *name, int &score )
{
   ifstream scoreFile;
   scoreFile.open("/usr/share/braincurses/braincurses.scores"); 
   int i;
   string crap;
   for( i = 1; _i >= i; i++ )
      getline( scoreFile, crap );
   
   scoreFile >> name >> score;
   scoreFile.close();
}

string getUser()
{
   /*
   struct passwd *pw;
   uid_t id;

   id = getuid();
   pw = getpwuid( id );

   // char *name;
   string name;
   name = pw->pw_name;
   */
   return( "kelly" );
}
                     
