Files
makefile_cpp/Make/sudoku/input.cpp
2023-04-13 14:02:08 +08:00

70 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include <iostream>
#include <sstream>
#include <string>
#include "common.h"
#include "utility.inl"
// return number of grids to be erased
// 嘿嘿加个注释
int inputDifficulty()
{
cls();
std::string cmd;
int need_erase_grids = 0;
while (true)
{
std::cout << "设置难度1简单 2普通 3困难" << std::endl;
std::cin >> cmd;
try
{
Difficulty difficulty = static_cast<Difficulty>(std::stoi(cmd));
switch (difficulty)
{
case Difficulty::EASY:
need_erase_grids = 20;
break;
case Difficulty::NORMAL:
need_erase_grids = 35;
break;
case Difficulty::HARD:
need_erase_grids = 50;
break;
}
}
catch(...)
{
need_erase_grids = 0;
}
if (need_erase_grids > 0)
break;
std::cout << "输入错误!" << std::endl;
}
return need_erase_grids;
}
KeyMode inputKeyMode()
{
std::string mode;
do
{
message("设置按键模式1正常 2VIM");
std::cin >> mode;
try
{
KeyMode kmd = static_cast<KeyMode>(std::stoi(mode));
return kmd;
} catch (...)
{}
message("输入错误!");
} while (true);
}