Skip to content
Snippets Groups Projects
Commit 1844cc8b authored by PAILLE Kyriann's avatar PAILLE Kyriann :8ball:
Browse files

Upload New File

parent a0806841
Branches
No related tags found
No related merge requests found
#include "location.h"
#include <string.h> /* strdup */
#include <stdio.h> /* printf */
#include <stdlib.h> /* malloc, free */
Location *LocationNew(char *name, char *desc)
{
Location *ret = (Location *)NULL;
if (name && desc) /** && where)**/
{
ret = malloc(sizeof(Location));
ret->name = strdup(name);
ret->desc = strdup(desc);
}
return ret;
}
Location *LocationDelete(Location *m)
{
if (m)
{
if (m->name)
free(m->name);
if (m->desc)
free(m->desc);
free(m);
}
return (Location *)NULL;
}
void LocationPrint(Location *m)
{
if (m)
printf("%s\n%s\n", m->name, m->desc);
}
Location *LocationInit()
{
//creation variables for room
Location *Startloc;
Location *OnTheRoadtwo;
Location *OnTheRoadthree;
Location *frontyard;
Location *Entrance;
Location *Diningroom;
Location *Kitchen;
Location *Laundryroom;
Location *Office;
Location *Livingroom;
Location *Atticroom;
Location *Cellarroom;
//call LocationNew to create the room inisde the game
Startloc = LocationNew("On the road", "The road continues north and south. You can see a house on the west.");
OnTheRoadtwo = LocationNew("On the road", "");
OnTheRoadthree = LocationNew("On the road", "");
frontyard = LocationNew("Front yard", "");
Entrance = LocationNew("Entrance", "");
Diningroom = LocationNew("Dining room", "");
Kitchen = LocationNew("Kitchen room", "");
Laundryroom = LocationNew("Laundry room", "");
Office = LocationNew("Office", "");
Livingroom = LocationNew("Living room", "");
Atticroom = LocationNew("Attic room", "");
Cellarroom = LocationNew("Cellar room", "");
return Startloc;
}
void LocationSetExit(Location *l1, Direction direction, Location *l2)
{
if (direction >= NORTH && direction <= DOWN)
{
l1->directions[direction] = l2;
}
}
// stack LocationDestroy(stack *s) {
// stack tmp = s;
// while(StackIsEmpty(tmp) == false) {
// LocationDestroy(Stackhead(tmp));
// tmp= stackPop(tmp);
// }
// }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment