Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull request for sample_npc.h, sample_npc.c, genstruct.c, and default_room #639

Open
wants to merge 47 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a63893d
including npcs in spec room struct and functions
navila-luna May 24, 2020
ed85e23
made edits to have npc_t struct considered
navila-luna May 25, 2020
072a177
lets see
navila-luna Jun 1, 2020
b812938
saving sample_npc.c
navila-luna Jun 1, 2020
c40ae97
Merge remote-tracking branch 'origin/dev' into openworld/samples-npcs
dwahme Jun 1, 2020
ee9e84d
slight edits in autogeneration to include npcs
Jun 1, 2020
f95c171
added npcs in test, need to add room descriptions
Jun 3, 2020
c3a6f76
fixed errors in test_structs.c
Jun 5, 2020
045f5f4
Fixed errors in test_struct
Jun 5, 2020
909ffce
pushing
Jun 6, 2020
ef7c123
Merge branch 'dev' of https://github.com/uchicago-cs/chiventure into …
Jun 6, 2020
2c9cd61
fixed merge issues by simply deletin all and replacing it with Bryans…
Jun 6, 2020
b3e1486
look at autogenerate.c for my thought/confusion process
Jun 6, 2020
02bf49b
revamping npc structure and attempting integration into autogenerate
Jun 6, 2020
45cc244
successfully integrated default_npc into autogenerate. need to write …
Jun 6, 2020
abc268a
fixed merge conflict
Jun 6, 2020
3a15044
resolved merge conflicts
Jun 6, 2020
4d83aff
still need to fix test_autogenerate errors
Jun 7, 2020
a724869
Added tests and made default npcs hash-based
Jun 7, 2020
ac34586
Merge pull request #766 from uchicago-cs/openworld/autogenerate-bugs
carolinaecalderon Jun 7, 2020
1c82bd1
Fixed final tests
Jun 7, 2020
3efc5e7
Merge branch 'openworld/samples-npcs' of https://github.com/uchicago-…
Jun 7, 2020
b6786c5
Editing comments
navila-luna Jun 7, 2020
20ef151
rm since default_npcs is the updated duplicate
navila-luna Jun 7, 2020
daf6b6f
deleting the duplicate of samples-npcs file
Jun 7, 2020
baa8963
Merge branch 'openworld/samples-npcs' of https://github.com/uchicago-…
Jun 7, 2020
9854cfa
made some changes, will come back to more space comments
Jun 7, 2020
26027fd
went through all suggestions
Jun 7, 2020
4523676
minor changes
Jun 7, 2020
bbfd365
will fix comment issues in sample npc
Jun 7, 2020
2d742d3
changes to spaces
navila-luna Jun 7, 2020
5204f90
added on to comment tests and fixed spelling issue in .c file
Jun 7, 2020
d82a55d
fixed merge issue
Jun 7, 2020
6610d3f
made changes in npc functions, need one more fix
Jun 7, 2020
4519c71
I think everythings done!
Jun 8, 2020
c5159b2
Merge branch 'dev' into openworld/samples-npcs
navila-luna Jun 8, 2020
6f47f0f
went back for tabs issues
navila-luna Jun 8, 2020
c0bcacb
went back for tabs issues
navila-luna Jun 8, 2020
b46c5ce
went through for any spacing issues not seen before
navila-luna Jun 8, 2020
fb4dd03
fixed overlooked tabs
navila-luna Jun 8, 2020
768e26a
fixed overlooked tab issue
navila-luna Jun 8, 2020
2048461
fixed overlooks spacing issues
navila-luna Jun 8, 2020
4d43dc4
fixed tab issues
navila-luna Jun 8, 2020
9f4dea9
I really hope spacing issues are resolved
Jun 8, 2020
7865488
fixed merges and spaces thru astyles
Jun 8, 2020
d812be2
Merge branch 'dev' into openworld/samples-npcs
navila-luna Jun 8, 2020
204008d
Merge branch 'dev' into openworld/samples-npcs
navila-luna Jun 8, 2020
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
7 changes: 4 additions & 3 deletions include/openworld/gen_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ typedef struct roomspec {
item_list_t *allowed_items;
item_hash_t *items;
path_hash_t *paths;
carolinaecalderon marked this conversation as resolved.
Show resolved Hide resolved
UT_hash_handle hh;
UT_hash_handle hh;
npc_t *possible_npcs;
carolinaecalderon marked this conversation as resolved.
Show resolved Hide resolved
} roomspec_t;

/* speclist_t struct
Expand Down Expand Up @@ -132,7 +133,7 @@ int gencontext_free(gencontext_t *context);
* SUCCESS - for SUCCESS
* FAILURE - if failed to initialize
*/
int init_roomspec(roomspec_t *spec, char *short_desc, char *long_desc,
int init_roomspec(npc_t *possible_npcs, roomspec_t *spec, char *short_desc, char *long_desc,
item_list_t *allowed, item_hash_t *items, path_hash_t *paths);
carolinaecalderon marked this conversation as resolved.
Show resolved Hide resolved

/* roomspec_new
Expand All @@ -148,7 +149,7 @@ int init_roomspec(roomspec_t *spec, char *short_desc, char *long_desc,
* roomspec_t *roomspecnew - the new roomspec
* NULL - if fails to create a new roomspec.
*/
roomspec_t* roomspec_new(char *room_name, char *short_desc, char *long_desc,
roomspec_t* roomspec_new(npc_t *possible_npcs,char *room_name, char *short_desc, char *long_desc,
item_list_t *allowed, item_hash_t *items, path_hash_t *paths);
carolinaecalderon marked this conversation as resolved.
Show resolved Hide resolved
carolinaecalderon marked this conversation as resolved.
Show resolved Hide resolved

/* roomspec_free
Expand Down
18 changes: 14 additions & 4 deletions include/openworld/sample_npc.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@
#include <stdlib.h>
#include <stdbool.h>

/*
Classification of the type of NPC characters to be found
within the rooms. Where friendly means NPC doesn't engage in fights,
Hostile means engages in fights, and generic means can engage in fights
*/

typedef enum npc_classification {
NPC_GENERIC = -1,
NPC_HOSTILE = 0,
NPC_FRIENDLY = 1
} npc_classification_t;


/* NPC mock struct that contains the bare minimum to add a NPC in a
openworld room.Consists of player level, NPC type, and item inventory
*/
typedef struct npc
{
int level;
Expand All @@ -19,22 +28,23 @@ typedef struct npc
struct npc *prev;
} npc_t;

/* Will get a linked list of hostile npcs
* makes 2-3 npcs that are hostile and return them
/* Will get a linked list of hostile npcs and includes the items that
* each NPC carries with them makes 3 npcs that are hostile and return them
* as a linked list
*/
npc_t *get_hostile_npcs();


/*
* makes 2-3 npcs that are friendly and return them
* makes 3 npcs that are friendly and includes the items that
each NPC carries with them. Returns NPC as a
* as a linked list
*/
npc_t *get_friendly_npcs();



/* * makes 2-3 npcs that are generic and return them
/* * makes 3 npcs that are generic and return them
* as a linked list
*/
npc_t *get_generic_npcs();
Expand Down
22 changes: 11 additions & 11 deletions src/openworld/src/default_rooms.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ item_list_t *allowed) {
*video;

//CLOSET
roomspec_t *closet = roomspec_new("closet", "A broom closet",
roomspec_t *closet = roomspec_new(get_generic_npcs(),"closet", "A broom closet",
"A small broom closet with supplies",
allowed, NULL, NULL);
HASH_FIND_STR(def, "door", door);
Expand All @@ -45,7 +45,7 @@ item_list_t *allowed) {
LL_APPEND(closet->allowed_items, llist_new(hat));

//HALLWAY
roomspec_t *hallway = roomspec_new("hallway", "A well-lit hallway",
roomspec_t *hallway = roomspec_new(get_hostile_npcs(),"hallway", "A well-lit hallway",
"A sterile, white hallway with no windows",
allowed, NULL, NULL);
LL_APPEND(hallway->allowed_items, llist_new(door));
Expand All @@ -58,7 +58,7 @@ item_list_t *allowed) {
LL_APPEND(hallway->allowed_items, llist_new(book));

//LIBRARY
roomspec_t *library = roomspec_new("library",
roomspec_t *library = roomspec_new(get_friendly_npcs(),"library",
"This is a library room with resources",
"An old, dusty library with skill-boosting resources like books and potions",
allowed, NULL, NULL);
Expand All @@ -77,7 +77,7 @@ item_list_t *allowed) {
*watercolors, *video;

//CAFETERIA
roomspec_t *cafeteria = roomspec_new("cafeteria", "A grungy cafeteria",
roomspec_t *cafeteria = roomspec_new(get_friendly_npcs(),"cafeteria", "A grungy cafeteria",
"A messy high school cafeteria with trays and tables out",
allowed, NULL, NULL);
HASH_FIND_STR(def, "apple", apple);
Expand All @@ -91,7 +91,7 @@ item_list_t *allowed) {
LL_APPEND(cafeteria->allowed_items, llist_new(yam));

//CLASSROOM
roomspec_t *classroom = roomspec_new("classroom",
roomspec_t *classroom = roomspec_new(get_generic_npcs(),"classroom",
"A medium-sized classroom with 30 desks",
"A geography teacher's classroom with 30 desks",
allowed, NULL, NULL);
Expand All @@ -118,7 +118,7 @@ item_list_t *allowed) {
*hat, *mirror;

//BARN
roomspec_t *barn = roomspec_new("barn", "A red barn",
roomspec_t *barn = roomspec_new(get_friendly_npcs(),"barn", "A red barn",
"A red barn with stables inside",
allowed, NULL, NULL);
HASH_FIND_STR(def, "apple", apple);
Expand All @@ -133,7 +133,7 @@ item_list_t *allowed) {
LL_APPEND(barn->allowed_items, llist_new(yam));

//OPEN FIELD
roomspec_t *field = roomspec_new("open field",
roomspec_t *field = roomspec_new(get_friendly_npcs(),"open field",
"An open field outside",
"An open field with grass and a clear view",
allowed, NULL, NULL);
Expand All @@ -145,7 +145,7 @@ item_list_t *allowed) {
LL_APPEND(field->allowed_items, llist_new(apple));

//KITCHEN
roomspec_t *kitchen = roomspec_new("kitchen", "A 60s era (outdated) kitchen",
roomspec_t *kitchen = roomspec_new(get_generic_npcs(),"kitchen", "A 60s era (outdated) kitchen",
"An outdated kitchen with obvious wear-and-tear",
allowed, NULL, NULL);
HASH_FIND_STR(def, "olive", olive);
Expand All @@ -157,7 +157,7 @@ item_list_t *allowed) {
LL_APPEND(kitchen->allowed_items,llist_new(tray));

//LIVING ROOM
roomspec_t *living = roomspec_new("living room",
roomspec_t *living = roomspec_new(get_generic_npcs(),"living room",
"A living room with basic items",
"A plain, unremarkable living room",
allowed, NULL, NULL);
Expand All @@ -183,7 +183,7 @@ item_list_t *allowed) {
item_t *ladder, *gold, *yam;

//DUNGEON
roomspec_t *dungeon = roomspec_new("dungeon", "A dark dungeon",
roomspec_t *dungeon = roomspec_new(get_hostile_npcs(), "dungeon", "A dark dungeon",
"A dank, dark dungeon with traps and enemies to battle",
allowed, NULL, NULL);
LL_APPEND(dungeon->allowed_items, llist_new(nail));
Expand All @@ -196,7 +196,7 @@ item_list_t *allowed) {
LL_APPEND(dungeon->allowed_items, llist_new(yam));

//THRONE ROOM
roomspec_t *throne = roomspec_new("throne room",
roomspec_t *throne = roomspec_new(get_hostile_npcs(),"throne room",
"This is a throne room",
"A regal throne room decked out with lavish items",
allowed, NULL, NULL);
Expand Down
4 changes: 2 additions & 2 deletions tests/openworld/test_rooms.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/* testing make_default_room for defined bucket, NULL sh_desc, l_desc*/
Test(room, make_default_defn){
roomspec_t *hash = make_default_room("school", NULL , NULL, NULL);
roomspec_t *hash = make_default_room(NULL, "school", NULL , NULL, NULL);
cr_assert_not_null(hash, "make_default_room failed");

roomspec_t *r1, *r2, *r3, *r4, *r5, *r6;
Expand Down Expand Up @@ -43,7 +43,7 @@ Test(room, make_default_defn){

/* testing make_default_room for undef bucket, bogus sh_desc, l_desc */
Test(room, make_default_undef_bogus) {
roomspec_t *hash = make_default_room("pharmacy", "short bogus",
roomspec_t *hash = make_default_room(NULL, "pharmacy", "short bogus",
"long bogus", NULL);
cr_assert_not_null(hash, "make_default_room failed");

Expand Down