Mentions légales du service

Skip to content
Snippets Groups Projects
Commit b3f78fb6 authored by Florent Bouchez Tichadou's avatar Florent Bouchez Tichadou Committed by PRATS Tommy
Browse files

Fix crepes that was using direct access to map instead of through *entity* functions.

(cherry picked from commit 59d325c3)
parent da4d09db
No related branches found
No related tags found
4 merge requests!131Testing merge against main, to verify CI,!97Engines have test and no leak of memory,!95Enhance Makefile,!94auto export python path when running make tests
......@@ -193,22 +193,19 @@ void enter_ingredient_building(game_instance *game, char *building_name)
!strcmp(command->command_buffer, "UP")) {
// if the ingredient is still there we can take it
if (player_ingredient_inventory == '_') {
switch (m->tiles[INGREDIENT_Y][INGREDIENT_X]) {
entity ent = get_entity(m, INGREDIENT_Y, INGREDIENT_X);
switch(ent) {
case 'E':
player_ingredient_inventory =
m->tiles[INGREDIENT_Y][INGREDIENT_X];
m->tiles[INGREDIENT_Y][INGREDIENT_X] = ' ';
printf("Taken %c in inventory\n",
player_ingredient_inventory);
message("You take the egg ingredient.");
break;
case 'F':
player_ingredient_inventory =
m->tiles[INGREDIENT_Y][INGREDIENT_X];
m->tiles[INGREDIENT_Y][INGREDIENT_X] = ' ';
player_ingredient_inventory = ent;
remove_entity(m, INGREDIENT_Y, INGREDIENT_X);
printf("Taken %c in inventory\n",
player_ingredient_inventory);
message("You take the flour ingredient.");
if (ent == 'E') {
message("You take the egg ingredient.");
} else {
message("You take the flour ingredient.");
}
break;
default:
printf("No ingredient to take\n");
......@@ -238,10 +235,11 @@ void enter_ingredient_building(game_instance *game, char *building_name)
// Give the player inventory and place it at the given X position
void give_ingredient(map *m, int ingredient_x)
{
m->tiles[COOK_Y][ingredient_x] = player_ingredient_inventory;
place_entity(m, player_ingredient_inventory, COOK_Y, ingredient_x);
player_ingredient_inventory = '_';
printf("Ingredients: '%c' '%c'\n", m->tiles[COOK_Y][COOK_X + 1],
m->tiles[COOK_Y][COOK_X + 2]);
printf("Ingredients: '%c' '%c'\n",
get_entity(m, COOK_Y, COOK_X + 1),
get_entity(m, COOK_Y, COOK_X + 2));
}
/**
......@@ -252,8 +250,8 @@ void check_ready_to_cook(map *m)
{
assert(!strcmp(m->name, "crepes_shop"));
// Check which ingredients are already available
char first_ingredient = m->tiles[COOK_Y][COOK_X + 1];
char second_ingredient = m->tiles[COOK_Y][COOK_X + 2];
char first_ingredient = get_entity(m, COOK_Y, COOK_X + 1);
char second_ingredient = get_entity(m, COOK_Y, COOK_X + 2);
assert(player_ingredient_inventory == 'E' ||
player_ingredient_inventory == 'F');
......@@ -274,8 +272,8 @@ void check_ready_to_cook(map *m)
void cook_crepe(map *m)
{
// "Delete" the ingredients from the map
m->tiles[COOK_Y][COOK_X + 1] = '=';
m->tiles[COOK_Y][COOK_X + 2] = '=';
place_entity(m, '=', COOK_Y, COOK_X + 1);
place_entity(m, '=', COOK_Y, COOK_X + 2);
// Give a crepe to the player
player_ingredient_inventory = 'C';
}
......@@ -414,7 +412,7 @@ int main()
player_look_forward(main_map, &dest_y, &dest_x);
// If the destination is empty, go there
char cdest = main_map->tiles[dest_y][dest_x];
char cdest = get_entity(main_map, dest_y, dest_x);
switch (cdest) {
case ' ':
move_player(main_map, dest_y, dest_x, dir);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment