Ejemplo n.º 1
0
void PopulateGrid(Grid &newgrid)
{
    for(int i = 0; i < 20; i++)
        for(int j = 0; j < 20; j++)
        {
            if(newgrid.Get(i, j) == true)
            {
                int r = arc4random_uniform(5);
                if(r == 0)
                {
                    newgrid.Add_Inv(*new Entity("ammobox"), i, j);
                    
                }
                else if(r == 1)
                {
                    newgrid.Add_Inv(*new Entity("healthpack"), i, j);
                }
                else if(r == 2)
                {
                    newgrid.Add_Inv(*new Entity("cat"), i, j);
                }
                else if(r == 3)
                {
                    newgrid.Add_Inv(*new Entity("hamburger"), i, j);
                }
            }
        }

}
Ejemplo n.º 2
0
void Turn(Player & player1, Grid & newgrid, Playerslist & list, ofstream &fout, int turn = -1, int p = 0)
{
    if(player1.alive == false)
    {
        cout << player1.Getname() << " is dead." << endl;
        return;
    }
    
    char player_type = player1.Get_type();
    
    int AP = 5;
    string verb, noun, s;
    cout << endl << endl << player1.Getname();
    switch (player_type)
    {
        case 's': cout << "(me)" << endl; break;
        case 'f': cout << "(friend)" << endl; break;
        case 'e': cout << "(enemy)" << endl; break;
        default: cout << "invalid playertype" << endl; break;
    }
    cout << "Turn " << turn << endl << endl;

    //player2
        string Result;                 
        ostringstream convert; 
        convert << turn;
        Result = convert.str();
        fstream f2in;
        fstream f3in;
        f2in.open("/Users/laria/Documents/c++/rpg/rpg/f" + Result + ".txt");
        f3in.open("/Users/laria/Documents/c++/rpg/rpg/e" + Result + ".txt");
    
    
    
    
    while(AP > 0)
    {
        player1.Set_x(player1.activeroom->Get_xcoord());
        player1.Set_y(player1.activeroom->Get_ycoord());
        if(newgrid.Search_Inv(player1.Getname(), player1.Get_x(), player1.Get_y()) == false)
        {
            newgrid.Add_Inv(player1, player1.Get_x(), player1.Get_y());
        }
        
    describe_start:
        cout << endl;
        if(player_type == 's')
        {
            player1.activeroom->Descrip();
            newgrid.Describe_inv(player1.Get_x(), player1.Get_y());
        }
        
        
    action_start:
        //cout << list.Get("player3").alive;

        if(AP < 1)
            break;
        if(player_type == 's')
            cout << "Action points: " << AP << endl;
        
        
        if (player_type == 's')
        {
            getline(cin, s, '\n');
            fout.open("/Users/laria/Documents/c++/rpg/rpg/output.txt");
            
            fout << s;
            fout.close();
            
            fstream fin;
            fin.open("/Users/laria/Documents/c++/rpg/rpg/output.txt");
            fin>>verb>>noun;
            
            
            fin.close();
        }
        else if (p == 2)