/*
 * roast_beef.c -- the hero layer.
 *
 * Thin. Carved. Pink in the middle, because it is a roast, not a brick.
 * "carved" here means passed through a deli slicer set to 1.5 mm.
 * It comes back folded, Dr. Seuss style, because folded is how hoagies
 * are assembled and there is no refactor that fixes physics.
 *
 * This file is single-threaded. You do not want multi-threaded roast beef.
 */
#include <deli.h>
#include <hunger.h>

#define SLICE_MM 1.5   /* the legal maximum thinness */

/* yield: many slices, all evidence-free */
static int slice_into(int pounds, double mm) {
    return (int)((pounds * 16) / mm);
}

int layer_roast_beef(struct hoagie *h, double lbs_per_hoagie) {
    if (h == NULL || lbs_per_hoagie < 0.25) {
        fprintf(stderr,
                "error: that is not a meat hoagie, that is a salad\n");
        return -1;
    }
    for (int i = 0; i < slice_into(lbs_per_hoagie, SLICE_MM); i++) {
        h->add_folded_slices(1);     /* fold, never curl */
    }
    return h->done() ? EXIT_SUCCESS : EBOREDOM;
}

/* delicate. do not over-browser. do not heat the bottom half. */
void rest(void) {
    while (still_steaming()) { wait(2); }   /* the roast decides */
    announce("medium okay by default; --well-done requires a code review");
}