Look! Look!
This commit is contained in:
		
							parent
							
								
									b4d93cffc2
								
							
						
					
					
						commit
						d730c3ab9f
					
				| @ -1,4 +1,5 @@ | ||||
| QUIT | * | 1000 | Bye! | QUIT_GAME() | ||||
| LOOK | * | 1 | * | LOOK_ROOM() | ||||
| NORTH | * | 1 | You can't go north from here. | | ||||
| SOUTH | * | 1 | You can't go south from here. | | ||||
| EAST | * | 1 | You can't go east from here. | | ||||
|  | ||||
| @ -6,3 +6,4 @@ NORTH|NORTH,N | ||||
| SOUTH|SOUTH,S | ||||
| EAST|EAST,E | ||||
| WEST|WEST,W | ||||
| LOOK|LOOK,L | ||||
|  | ||||
| @ -29,6 +29,9 @@ void cause_effect(Game *g, Effect *e) { | ||||
|   case EFFECT_QUIT_GAME: | ||||
|     g->should_close = true; | ||||
|     break; | ||||
|   case EFFECT_LOOK_ROOM: | ||||
|     push_line_to_log(g->input->log, g->current_room->description); | ||||
|     break; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| @ -54,6 +57,8 @@ Effect *create_effect(Game *g, const char *string) { | ||||
|       e->type = EFFECT_DISABLE; | ||||
|     } else if (strcmp(token, "QUIT_GAME") == 0) { | ||||
|       e->type = EFFECT_QUIT_GAME; | ||||
|     } else if (strcmp(token, "LOOK_ROOM") == 0) { | ||||
|       e->type = EFFECT_LOOK_ROOM; | ||||
|     } | ||||
| 
 | ||||
|     token = strtok_r(NULL, ")", &strtok_guy); | ||||
| @ -90,5 +95,8 @@ void print_effect(Effect *e) { | ||||
|   case EFFECT_QUIT_GAME: | ||||
|     printf("QUIT_GAME()"); | ||||
|     break; | ||||
|   case EFFECT_LOOK_ROOM: | ||||
|     printf("LOOK_ROOM()"); | ||||
|     break; | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -11,6 +11,7 @@ typedef enum EffectType { | ||||
|   EFFECT_ENABLE, | ||||
|   EFFECT_DISABLE, | ||||
|   EFFECT_QUIT_GAME, | ||||
|   EFFECT_LOOK_ROOM, | ||||
| } EffectType; | ||||
| 
 | ||||
| #include "game.h" | ||||
|  | ||||
| @ -111,7 +111,8 @@ void game_handle_directional_command(Game *g, const char *c) { | ||||
| void game_handle_command(Game *g, const char *command) { | ||||
|   Action *a = find_action(g, command); | ||||
|   if (a) { | ||||
|     push_line_to_log(g->input->log, a->description); | ||||
| 
 | ||||
|     if (strcmp(a->description, "*") != 0) push_line_to_log(g->input->log, a->description); | ||||
|     for (int i = 0; i < a->effects_count; i++) { | ||||
|       cause_effect(g, a->effects[i]); | ||||
|     } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user