Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions IFDProject2/Area.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef AREA_H
#define AREA_H

#include <string>
#include <iostream>
#include "Item.h"
Expand Down Expand Up @@ -30,8 +33,8 @@ class Area{
}
void search(){
nodeType<Item*>* current = items.getFirst();
nodeType<Item*>* next = current;
nodeType<Item*>* temp;
// nodeType<Item*>* next = current;
// nodeType<Item*>* temp;
if(current == NULL){
cout <<"There are no items in this area\n";
return;
Expand All @@ -49,3 +52,5 @@ class Area{
bool instadeath;
bool goal;
};

#endif
27 changes: 17 additions & 10 deletions IFDProject2/BasicFuncPart.depend
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,19 @@

1642172184 /home/skilet1/teaching/8.2022Spring/CS355/Projects/IFProject1/BasicFuncPart/Player.h

1643730206 source:c:\users\ssingh21\desktop\ifdproject2\main.cpp
"Game.h"
1644431992 source:c:\users\ssingh21\desktop\ifdproject2\main.cpp
<iostream>
"ull.h"
"Item.h"
"Area.h"
"areaNode.h"
"Player.h"

1643730205 c:\users\ssingh21\desktop\ifdproject2\game.h
1644430503 c:\users\ssingh21\desktop\ifdproject2\game.h
"Map.h"
"Player.h"

1643730205 c:\users\ssingh21\desktop\ifdproject2\map.h
1644430503 c:\users\ssingh21\desktop\ifdproject2\map.h
<vector>
<iostream>
<fstream>
Expand All @@ -52,29 +57,31 @@
"LinkData.h"
"Area.h"

1643730205 c:\users\ssingh21\desktop\ifdproject2\ifdparser.h
1644430503 c:\users\ssingh21\desktop\ifdproject2\ifdparser.h
<vector>
<iostream>
<fstream>
<string>
<sstream>
<stdlib.h>

1643730205 c:\users\ssingh21\desktop\ifdproject2\linkdata.h
1644430503 c:\users\ssingh21\desktop\ifdproject2\linkdata.h
<iostream>

1643730942 c:\users\ssingh21\desktop\ifdproject2\area.h
1644431279 c:\users\ssingh21\desktop\ifdproject2\area.h
<string>
<iostream>
"Item.h"
"ull.h"

1643730205 c:\users\ssingh21\desktop\ifdproject2\item.h
1644432146 c:\users\ssingh21\desktop\ifdproject2\item.h
<iostream>

1643730206 c:\users\ssingh21\desktop\ifdproject2\ull.h
1644432167 c:\users\ssingh21\desktop\ifdproject2\ull.h
<iostream>
<cassert>

1643730205 c:\users\ssingh21\desktop\ifdproject2\player.h
1644435076 c:\users\ssingh21\desktop\ifdproject2\player.h

1644431964 c:\users\ssingh21\desktop\ifdproject2\areanode.h

69 changes: 51 additions & 18 deletions IFDProject2/Game.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
#include "Map.h"
#include "MapV2.h"
#include "Player.h"

#ifndef ullItem
#define ullItem
#include "ull.h"
#include "Item.h"
#endif

class Game{
private:
Player player1;
Map map;

MapV2 map;
public:
Game(){
player1.setCurrent(map.getStart());
}

}
void play(){
string userInput;
//cin.ignore();
while(true){
while(true){
//check game status
if(player1.isGameOver() != 0){
player1.getCurrent()->info.displayArea();
Expand All @@ -25,13 +31,15 @@ class Game{
player1.getCurrent()->info.displayArea();
}
else{
cout<<"There appears to be no way to go that direction."<<endl;
if(userInput != "reset"){
cout<<"There appears to be no way to go that direction."<<endl;
}
}

//get movement selection
cout<<"Which way would you like to go? Enter u, d, l, or r"<<endl;
getline(cin, userInput);

//update area
if(userInput == "u"){
player1.setCurrent(player1.getCurrent()->u);
Expand All @@ -46,21 +54,38 @@ class Game{
player1.setCurrent(player1.getCurrent()->r);
}
else if(userInput == "iseedeadpeople"){ //issdeadpeople cheat code to reveal map
cout << map;
//map.print();
cout<<map;
}
else if(userInput == "reset"){
resetGame();
}
else if(userInput == "exit"){
cout<<"Good bye!"<<endl;
return;
}
else if(userInput == "reset"){
cout << "*****RESETTING*****\n";
player1.setCurrent(map.getStart());
cout << "*****RESET COMPLETED*****\n\n";
else if(userInput == "search"){
player1.getCurrent()->info.search();
}
else if(userInput == "inventory"){
player1.inventory();
}
else if(userInput == "take"){
player1.take();
}
else if(userInput == "leave"){
player1.leave();
}
else if(userInput == "examine"){
player1.examine();
}

else if(userInput == "help"){
cout<<"You may type: "<<endl;
cout<<"\t u, d, l, or r: to move up, down, left or right on the map,"<<endl;
cout<<"\t search: to search for items in current area,"<<endl;
cout<<"\t take: to attempt to take an item,"<<endl;
cout<<"\t leave: to attempt to leave an item,"<<endl;
cout<<"\t examine: to examine an item in your inventory,"<<endl;
cout<<"\t reset: to reset the game,"<<endl;
cout<<"\t exit: to exit the game."<<endl;
cout<<endl;
Expand All @@ -69,7 +94,15 @@ class Game{
cout<<"I do not understand: "<<userInput<<endl<<endl;
}


}//end while
}//end while
}//end play()
};

void resetGame(){
player1.setCurrent(map.getStart());
//remove item from player list
player1.items.destroyList();
//remove item from each area in turn
map.resetItems();
}
};
2 changes: 1 addition & 1 deletion IFDProject2/Item.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Item{
return SR;
}
void displayName(){
cout << name;
cout << name << endl;
}
void displayDesc(){
cout << description;
Expand Down
62 changes: 1 addition & 61 deletions IFDProject2/Map.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct areaNode
};

class Map{
private:
protected:
vector<areaNode*> areasVec;
int areacnt;

Expand All @@ -36,66 +36,6 @@ class Map{
bool ifderr;

public:
Map(){
ifderr = false;
parser.tokenIt();

nextToken = parser.getNext();

if(nextToken == "<game>"){
parser.eatToken();
nextToken = parser.getNext();
while(nextToken != "</game>"){ //consider what happens when run out of tokens && not error state
if(nextToken == "<area>"){
parser.eatToken();
nextToken = parser.getNext();
makeArea();
}
else if(nextToken == "<links>"){
parser.eatToken();
nextToken = parser.getNext();
makeLinks();
}
else{
cout<<"Parse Error Location 1"<<endl;
ifderr = true;
break;
}
parser.eatToken();
nextToken = parser.getNext();
}// while !</game>

if(ifderr){
cout<<" :: ERROR :: IF Document Formatting Error"<<endl;
cout<<"Game Loading Failed"<<endl;
cout<<"General Area of Parsing Failure:"<<endl;
cout<<"-------------------------------------"<<endl;
cout<<nextToken<<endl;
parser.eatToken();
nextToken = parser.getNext();
cout<<nextToken<<endl;
parser.eatToken();
nextToken = parser.getNext();
cout<<nextToken<<endl;
parser.eatToken();
nextToken = parser.getNext();
cout<<nextToken<<endl;
cout<<"-------------------------------------"<<endl;
return;
}
//cout<<"::Found </game>::"<<endl;
}
else{
cout<<" :: ERROR :: No \"<game>\" tag found."<<endl;
cout<<"Game Loading Failed"<<endl;
}

//link up areas
linkLinks();


}//constructor

void makeArea(){
int id;
int goal;
Expand Down
Loading