Source File: ex23.cpp

#include <fmt/core.h>
#include <iostream>
#include <functional>

using std::cin, fmt::println, fmt::print, std::string;

string prompt() {
  string buffer;
  print("> ");
  getline(cin, buffer);
  return buffer;
}

enum class RoomId {
  ROOM_A,
  ROOM_B,
  END
};

// this makes it so we don't type RoomId:: everywhere
using enum RoomId;

RoomId end() {
  fmt::println("You died...luser.");
  return END;
};

RoomId room_b() {
  println("There's a bear here. He hates you.");
  string cmd = prompt();
  
  if(cmd == "fight bear") {
    println("LOL, ok you're dead.");
    return END;
  } else if(cmd == "run") {
    println("Bears are fast, you're dead.");
    return END;
  } else {
    println("I don't understand that.");
    return ROOM_B;
  }
}

RoomId room_a() {
  println("You enter a room with a door to the east.");
  string cmd = prompt();

  if(cmd == "go east") {
    return ROOM_B;
  } else {
    println("I don't understand that.");
    return ROOM_A;
  }
}

int main(int argc, char *argv[]) {
  RoomId room=ROOM_A;

  while(room != END) {
    switch(room) {
      case ROOM_A:
        room = room_a();
        break;
      case ROOM_B:
        room = room_b();
        break;
      case END:
        room = end();
        break;
    }
  }
}