Memory Game v0.2.1
2026-05-24 15:26:48
发布于:辽宁
不要偷看
Memory Game v0.2.0
火速发布新版本awa
本次更新内容如下:
- 修改:使用哈希存储、校验密码,保证比凯撒密码更氨荃(
// Hash
class SHA256{
public:
static string hash(const string& data) {
uint32_t h[8] = {
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
};
uint64_t ml = data.size() * 8;
vector<uint8_t> msg(data.begin(), data.end());
msg.push_back(0x80);
while((msg.size() * 8) % 512 != 448) msg.push_back(0x00);
for(int i = 7; i >= 0; --i) msg.push_back((ml >> (i * 8)) & 0xff);
for(size_t i = 0; i < msg.size(); i += 64){
uint32_t w[64];
for(int j = 0; j < 16; j++)
w[j] = (msg[i + j * 4] << 24) | (msg[i + j * 4 + 1] << 16) |
(msg[i + j * 4 + 2] << 8) | (msg[i + j * 4 + 3]);
for(int j = 16; j < 64; j++){
uint32_t s0 = rotr(w[j - 15], 7) ^ rotr(w[j - 15], 18) ^ (w[j - 15] >> 3);
uint32_t s1 = rotr(w[j - 2], 17) ^ rotr(w[j - 2], 19) ^ (w[j - 2] >> 10);
w[j] = w[j - 16] + s0 + w[j - 7] + s1;
}
uint32_t a = h[0], b = h[1], c = h[2], d = h[3];
uint32_t e = h[4], f = h[5], g = h[6], _h = h[7];
for(int j = 0; j < 64; j++){
uint32_t S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
uint32_t ch = (e & f) ^ ((~e) & g);
uint32_t temp1 = _h + S1 + ch + k[j] + w[j];
uint32_t S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
uint32_t maj = (a & b) ^ (a & c) ^ (b & c);
uint32_t temp2 = S0 + maj;
_h = g; g = f; f = e; e = d + temp1;
d = c; c = b; b = a; a = temp1 + temp2;
}
h[0] += a; h[1] += b; h[2] += c; h[3] += d;
h[4] += e; h[5] += f; h[6] += g; h[7] += _h;
}
ostringstream oss;
for (int i = 0; i < 8; ++i) oss << std::hex << std::setfill('0') << std::setw(8) << h[i];
return oss.str();
}
private:
static constexpr uint32_t k[64] = {
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
};
static uint32_t rotr(uint32_t x, uint32_t n) { return (x >> n) | (x << (32 - n)); }
};
完整源代码:
/* ENCODING WITH GB2312 */
#include <cstdio>
#include <windows.h>
#include <string>
#include <iostream>
#include <cstdint>
#include <sstream>
#include <iomanip>
#include <vector>
#ifndef _WIN32
int main(){
puts("Sorry, but we have no MacOS/Linux platform support now.");
}
#endif
#define unsnd unsigned
#define l long
#define unsdll unsigned long long
using std::cout, std::cin, std::string, std::vector, std::ostringstream;
const unsdll LEVEL_COUNT=6; // This is the count of levels,update notice
const string ADMIN_PASSWORD="7851eb075b7b9b76f6b9dc21588d287cb323b65853957e544a3e826138e72d7d"; // admin password(Hash value)
const string version = "0.2.1_Dev";
const string detailed_version = "0.2.1_Dev_Windows";
unsdll MAX_WRONG_LETTER_CNT=5; // max wrong letter count(edit able), used in function playLevel(),levelFail(),levelPass()(update notice)
unsdll COUNTDOWN_BASE=4;
string lang = "en"; // "zh":Chinese, "en":English
unsdll _score = 0;
bool _is_admin = false;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wtrigraphs"
string levels[]={
"These are texts to remember,sort by alphabet",
"abcdefg",
"I love cpp",
"Hello my friend, long time no see.",
"OHHHHHHHHHH MY PCCCCCCCCCCCCCCCC",
"No one play Minecraft? REALLY??!",
"This level is harder than other. Guess why? 'Cause it have many letters~!"
};
#pragma GCC diagnostic pop
#include <string>
#include <vector>
#include <cstdint>
#include <sstream>
#include <iomanip>
// Hash
class SHA256{
public:
static string hash(const string& data) {
uint32_t h[8] = {
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
};
uint64_t ml = data.size() * 8;
vector<uint8_t> msg(data.begin(), data.end());
msg.push_back(0x80);
while((msg.size() * 8) % 512 != 448) msg.push_back(0x00);
for(int i = 7; i >= 0; --i) msg.push_back((ml >> (i * 8)) & 0xff);
for(size_t i = 0; i < msg.size(); i += 64){
uint32_t w[64];
for(int j = 0; j < 16; j++)
w[j] = (msg[i + j * 4] << 24) | (msg[i + j * 4 + 1] << 16) |
(msg[i + j * 4 + 2] << 8) | (msg[i + j * 4 + 3]);
for(int j = 16; j < 64; j++){
uint32_t s0 = rotr(w[j - 15], 7) ^ rotr(w[j - 15], 18) ^ (w[j - 15] >> 3);
uint32_t s1 = rotr(w[j - 2], 17) ^ rotr(w[j - 2], 19) ^ (w[j - 2] >> 10);
w[j] = w[j - 16] + s0 + w[j - 7] + s1;
}
uint32_t a = h[0], b = h[1], c = h[2], d = h[3];
uint32_t e = h[4], f = h[5], g = h[6], _h = h[7];
for(int j = 0; j < 64; j++){
uint32_t S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
uint32_t ch = (e & f) ^ ((~e) & g);
uint32_t temp1 = _h + S1 + ch + k[j] + w[j];
uint32_t S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
uint32_t maj = (a & b) ^ (a & c) ^ (b & c);
uint32_t temp2 = S0 + maj;
_h = g; g = f; f = e; e = d + temp1;
d = c; c = b; b = a; a = temp1 + temp2;
}
h[0] += a; h[1] += b; h[2] += c; h[3] += d;
h[4] += e; h[5] += f; h[6] += g; h[7] += _h;
}
ostringstream oss;
for (int i = 0; i < 8; ++i) oss << std::hex << std::setfill('0') << std::setw(8) << h[i];
return oss.str();
}
private:
static constexpr uint32_t k[64] = {
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
};
static uint32_t rotr(uint32_t x, uint32_t n) { return (x >> n) | (x << (32 - n)); }
};
void output(string s,int time){
// One by one output
for(auto c:s){
printf("%c",c);
Sleep(time);
}
}
void tourtoal(){
// Tourtoal function(in fact I think too long in main lol)
if(lang == "en"){
system("cls");
output("*Tourtoal start*\n",50);
cout<<"DH8105: ";
Sleep(300);
output("I will teach you how to play this game.\n",50);
cout<<"[Any key]: Continue";
_getwch();
cout<<"\nYou: ";
output("I'm OK.",50);
cout<<"\nDH8105: ";
output("This(point the edge of the window)is called \"Console\".\n",50);
cout<<"[Any key]: Continue";
_getwch();
cout<<"\nDH8105: ";
output("Your goal is: Remember the words before countdown, and type it.\n",50);
cout<<"[Any key]: Continue";
_getwch();
cout<<"\nDH8105: ";
output("When you type a correct letter, the \"Console\" will show you a letter you type to help you to remember.\n",50);
cout<<"[Any key]: Continue";
_getwch();
cout<<"\nDH8105: ";
output("And when you type a wrong letter, the \"Console\" won't show you any letter.\n",50);
cout<<"[Any key]: Continue";
_getwch();
cout<<"\nDH8105: ";
output("If you typed wrong letter count out of 5,game will over.",50); // update notice(Line 8)
cout<<"\n[Any key]: \"I remember how to play.\"";
_getwch();
cout<<"\nDH8105: ";
output("Great.You can play Memory Game now. See you later~!",50);
cout<<"\n[Any key]: Back to choose other level";
_getwch();
system("cls");
}else if(lang == "zh"){
system("cls");
output("*教程开始*\n",50);
cout<<"DH8105: ";
Sleep(300);
output("接下来我将教会你如何玩这个游戏。\n",50);
cout<<"[任意键]: 继续";
_getwch();
cout<<"\n你: ";
output("我准备好了。",50);
cout<<"\nDH8105: ";
output("这个(指了指窗口的边缘)叫做\"控制台\"。\n",50);
cout<<"[任意键]: 继续";
_getwch();
cout<<"\nDH8105: ";
output("你的目标是:在倒计时之前记下屏幕上的内容,然后打出它。\n",50);
cout<<"[任意键]: 继续";
_getwch();
cout<<"\nDH8105: ";
output("当你打出一个正确字符,\"控制台\"会展示你输入的字符帮助你记忆。\n",50);
cout<<"[任意键]: 继续";
_getwch();
cout<<"\nDH8105: ";
output("但是当你打出一个错误字符,\"控制台\"不会展示任何字符。",50);
_getwch();
cout<<"\nDH8105: ";
output("如果你的错误字符数超过了5个,游戏将会失败。",50); // update notice(Line 8)
cout<<"\n[任意键]: \"我记住怎么玩了。\"";
_getwch();
cout<<"\nDH8105: ";
output("太好了。你现在可以玩 记忆游戏 了。一会见~!",50);
cout<<"\n[任意键]: 返回选择其他关卡";
_getwch();
system("cls");
}
}
void start();void chooseLevel();void levelFail(unsdll level);void levelPass(unsdll level,unsdll score);
void playLevel(unsdll level){ // Use a function to play a level
int countdown = levels[level].size()/COUNTDOWN_BASE; // Mean the difficult of the game. Bigger number mean harder gameplay.
if(countdown < 3) countdown=3;
system("cls");
if(lang == "zh"){
cout<<"要记忆的文本:\n"<<levels[level]<<"\n\n正在加载倒计时...";
}else{
cout<<"Texts to remember:\n"<<levels[level]<<"\n\nLoading countdown...";
}
Sleep(1000);
for(auto i=countdown;i>=0;i--){
system("cls");
if(lang == "zh"){
cout<<"要记忆的文本:\n"<<levels[level]<<"\n\n";
cout<<"倒计时:"<<countdown<<'\n';
}else{
cout<<"Texts to remember:\n"<<levels[level]<<"\n\n";
cout<<"Countdown:"<<countdown<<'\n';
}
countdown--;
Sleep(1000);
}
system("cls");
string curr=levels[level];
string display="";
unsigned long long wrong_cnt=0,right_cnt=0;
unsigned long long i=0;
while(right_cnt < curr.size()){
char input=_getwch();
if(input == curr[i]){
putchar(curr[i]);
right_cnt++;
i++;
}else wrong_cnt++;
if(wrong_cnt > MAX_WRONG_LETTER_CNT){
levelFail(level);
return;
}
}
levelPass(level,curr.size()/2);
}
void levelFail(unsdll level){
putchar('\n');
if(lang == "zh"){
cout<<"你的错误字符数超过了 "<<MAX_WRONG_LETTER_CNT<<" 个。\n你在关卡 "<<level<<" 失败了。\n获得分数: 0\n\n";
cout<<"[R]: 重玩本关\n";
cout<<"[H]: 回到主菜单\n";
}else{
cout<<"Your wrong letter count is out of "<<MAX_WRONG_LETTER_CNT<<".\nYou are failed in level "<<level<<".\nScore get: 0\n\n";
cout<<"[R]:Replay this level\n";
cout<<"[H]:Go to main menu\n";
}
int userKey = _getwch();
// r:114 R:82 h:104 H:72
switch(userKey){
case 114:
case 82:
if(lang == "zh") cout<<"3秒后重玩...";
else cout<<"Replay in 3 seconds. . .";
Sleep(3000);
playLevel(level);
break;
case 104:
case 72:
start();
break;
default:
system("cls");
if(lang == "zh") cout<<"无效按键: "<<userKey<<" 。\n[任意键]: 返回主菜单";
else cout<<"Invalid key: "<<userKey<<" .\n[Any key]:Back to main menu";
_getwch();
start();
}
}
void levelPass(unsdll level,unsdll score){
putchar('\n');
if(lang == "zh"){
cout<<"恭喜!你的错误字符数少于 "<<MAX_WRONG_LETTER_CNT<<" 个。\n你通过了关卡 "<<level<<"。\n获得分数: "<<score<<"\n\n";
cout<<"[R]: 重玩本关\n";
cout<<"[H]: 回到主菜单\n";
}else{
cout<<"Congratulations! Your wrong letter count is less of "<<MAX_WRONG_LETTER_CNT<<".\nYou are passed level "<<level<<".\nScore get: "<<score<<"\n\n";
cout<<"[R]:Replay this level\n";
cout<<"[H]:Go to main menu\n";
}
_score += score;
int userKey = _getwch();
// r:114 R:82 h:104 H:72
switch(userKey){
case 114:
case 82:
if(lang == "zh") cout<<"3秒后重玩...";
else cout<<"Replay in 3 seconds. . .";
Sleep(3000);
playLevel(level);
break;
case 104:
case 72:
start();
break;
default:
system("cls");
if(lang == "zh") cout<<"无效按键: "<<userKey<<" 。\n[任意键]: 返回主菜单";
else cout<<"Invalid key: "<<userKey<<" .\n[Any key]:Back to main menu";
_getwch();
start();
}
}
void chooseLevel(){
system("cls");
unsdll userLevel;
if(lang == "zh"){
cout<<"可用关卡:0(教程),1~"<<LEVEL_COUNT<<"\n";
cout<<"选择一个关卡,或输入 -1 退出: ";
}else{
cout<<"Avaliable levels:0(Tourtoal),1~"<<LEVEL_COUNT<<"\n";
cout<<"Choose a level or input -1 to quit: ";
}
cin>>userLevel;
if(userLevel == -1){
start();
return;
}
if(userLevel == 0){tourtoal();chooseLevel();}
else if(userLevel >= 1 && userLevel <= LEVEL_COUNT){
playLevel(userLevel);
}else{
if(lang == "zh")
cout<<"未知关卡: "<<userLevel<<" 。\n";
else
cout<<"Unknown level: "<<userLevel<<" .\n";
if(lang == "zh")
cout<<"[任意键]: 返回选择关卡\n";
else
cout<<"[Any key]:Back to choose level\n";
_getwch();
chooseLevel();
}
}
bool adminCheck(string password){
for(auto i=0;i<password.size();i++){
password[i]+=15;
}
return password == ADMIN_PASSWORD;
}
void settings(){
MainSettings:
system("cls");
if(lang == "en") output("--Memory Game Settings--\n\n",30);
else output("--记忆游戏 设置--\n\n",30);
Sleep(200);
if(lang == "en") cout<<"[L]: Language\n[D]: Difficulty\n[Shift+Key]: Reset to default\n[Esc]: Back to main menu";
else cout<<"[L]: 语言\n[D]: 难度\n[Shift+按键]: 重置为默认值\n[Esc]: 返回到主菜单";
int settingsKey=_getwch();
switch(settingsKey){
case 27:
start();
break;
case 108:
system("cls");
cout<<"--Language 语言--\n\n\"en\"(English 英语)\n\"zh\"(Chinese 中文)\nDefault 默认: en\n\nSet to 设置为: ";
cin>>lang;
if(lang != "zh" && lang != "en"){
cout<<"\nUnsupport language 不支持的语言: "<<lang<<" .\n[Any key 任意键]: Back to Settings 返回设置页面";
_getwch();
lang = "en";
goto MainSettings;
}
if(lang == "en") cout<<"\nLanguage has been set to: English.\n[Any key]: Back to Settings";
else cout<<"\n语言已设置为: 中文\n[任意键]: 回到设置页面";
_getwch();
goto MainSettings;
break;
case 76:{
system("cls");
cout<<"--Reset Language 重置语言--\n\nLanguage will reset to \"en\"(English).\n语言将重置为 en(英文)。\n\nAre you sure? 确定吗?\n[Shift+Y]: Yes 是\n[Other key 其他按键]: No 否";
int SureKey=_getwch();
if(SureKey == 89){
lang = "en";
cout<<"\n\nLanguage has been reset to English.\n[Any key]: Back to main menu";
_getwch();
start();
}else{
goto MainSettings;
}
break;
}
case 100:{
system("cls");
if(lang == "en") cout<<"--Difficulty Adjust--\n\nIn any adjustion interface, enter 0 to exit\n[M]: Max wrong letter\n[C]: Countdown base number\n[Esc]: Back to Settings";
else cout<<"--难度修改--\n\n在任意修改界面中,可输入 0 退出\n[M]: 最大错误字符数\n[C]: 倒计时基数\n[Esc]: 回到设置页面";
if(_is_admin){
if(lang == "en") cout<<"\n\n==Administrator Only==\n[S]: Score";
else cout<<"\n\n==仅管理员==\n[S]: 分数";
}
int choiceKey=_getwch();
system("cls");
switch(choiceKey){
case 27:
goto MainSettings;
break;
case 109:{
AdjustMaxWrong:
if(lang == "en") cout<<"--Adjust Max wrong letter--\n\nThe game difficulty will be adjusted, so the acceptable value is 1~100.\n\nSet to: ";
else cout<<"--修改最大错误字符数--\n\n游戏难度将会被更改,所以可接受的值范围为1~100。\n\n设置为:";
int tmp;
cin>>tmp;
if(tmp < 1 || tmp > 100){
if(lang == "en") cout<<"Unacceptable value: "<<tmp<<" .\nThe acceptable value is 1~10.\n[Any key]: Adjust again";
else cout<<"无法接受的值:"<<tmp<<"。\n可接受的值范围为1~100。\n[任意键]: 再次修改";
_getwch();
goto AdjustMaxWrong;
}else if(tmp == 0){
goto MainSettings;
}else MAX_WRONG_LETTER_CNT = tmp;
if(lang == "en") cout<<"\n\nMax wrong letter has been adjusted to "<<MAX_WRONG_LETTER_CNT<<" .\n[Any Key]: Back to Settings";
else cout<<"\n\n最大错误字符数已被修改为 "<<MAX_WRONG_LETTER_CNT<<" 。\n[任意键]: 回到设置页面";
_getwch();
goto MainSettings;
break;
}
case 99:{
AdjustCountdownBase:
if(lang == "en") cout<<"--Adjust Countdown base number--\n\nThe game difficulty will be adjusted, so the acceptable value is 1~10.\n\nSet to: ";
else cout<<"--修改倒计时基数--\n\n游戏难度将会被更改,所以可接受的值范围为1~10。\n\n设置为:";
int tmp;
cin>>tmp;
if(tmp < 1 || tmp > 10){
if(lang == "en") cout<<"Unacceptable value: "<<tmp<<" .\nThe acceptable value is 1~10.\n[Any key]: Adjust again";
else cout<<"无法接受的值:"<<tmp<<"。\n可接受的值范围为1~10。\n[任意键]: 再次修改";
_getwch();
goto AdjustCountdownBase;
}else if(tmp == 0){
goto MainSettings;
}else COUNTDOWN_BASE = tmp;
if(lang == "en") cout<<"\n\nCountdown base number has been adjusted to "<<COUNTDOWN_BASE<<" .\n[Any Key]: Back to Settings";
else cout<<"\n\n倒计时基数已被修改为 "<<COUNTDOWN_BASE<<" 。\n[任意键]: 回到设置页面";
_getwch();
goto MainSettings;
break;
}
case 115:{
if(!_is_admin){
if(lang == "en") cout<<"You shouldn't be here right now. How could you get here? Please login as administrator first.\n[Any key]: Back to Settings";
else cout<<"你现在不应该来这里。你是怎么进来这里的?请先登录为管理员。\n[任意键]: 回到设置页面";
_getwch();
goto MainSettings;
}
if(lang == "en") cout<<"--Adjust Score--\n\nThis setting is for debugging only. Please adjust carefully.\nWarning: Score is stored using unsigned long long. Do not enter negative values.\n\nSet to: ";
else cout<<"--修改分数--\n\n这个设置仅用于调试。请小心调整。\n警告:分数使用unsigned long long存储,所以请勿输入负数。\n\n设置为:";
string Input;
cin>>Input;
try{
long long temp=stoll(Input);
if (temp < 0) {
throw "Negative score is not allowed(Error Code: settings.score.input_negative)";
}
_score = static_cast<unsigned long long>(temp);
if (lang == "en")
cout << "\n\nScore has been adjusted to " << _score << ".\n[Any Key]: Back to Settings";
else
cout << "\n\n分数已修改为 " << _score << "。\n[任意键]: 回到设置页面";
}catch(string msg){
if(lang == "en") cout << "\n\nError: "<<msg<<"\n[Any key]: Back to Settings";
else cout << "\n\n错误:"<<msg<<"\n[任意键]: 回到设置页面";
}catch(...){
if (lang == "en") cout << "\n\nError: Invalid input! Please enter a valid number.\n[Any key]: Back to Settings";
else cout << "\n\n错误:输入无效!请输入一个有效的数字。\n[任意键]: 回到设置页面";
}
_getwch();
goto MainSettings;
break;
}
default:{
system("cls");
if(lang == "en") cout<<"Invalid key: "<<settingsKey<<" .\n[Any key]: Back to Settings";
else cout<<"无效按键: "<<settingsKey<<" .\n[任意键]: 回到设置页面";
_getwch();
goto MainSettings;
break;
}
}
break;
}
default:
system("cls");
if(lang == "en") cout<<"Invalid key: "<<settingsKey<<" .\n[Any key]: Back to Settings";
else cout<<"无效按键: "<<settingsKey<<" .\n[任意键]: 回到设置页面";
_getwch();
goto MainSettings;
break;
}
}
void start(){
// string homepage = "https://www.acgo.cn/person/4960237";
system("cls");
system("color f");
if(lang == "zh"){
output("--记忆游戏--",50);
Sleep(300);
cout<<"\n版本: "<<version<<"\n得分: "<<_score<<"\n作者: DH8105 (QQ & ACGO)\nBug报告: 在ACGO上联系作者\n\n";
cout<<"[空格/Enter]: 开始游戏\n";
cout<<"[H]: 前往作者主页(ACGO)\n";
cout<<"[S]: 游戏设置\n";
cout<<"[A]: 管理员登录\n";
cout<<"[Esc]: 退出游戏";
}else{
output("--Memory Game--",50);
Sleep(300);
cout<<"\nVersion: "<<version<<"\nScore: "<<_score<<"\nAuthor: DH8105 on QQ & ACGO\nBug report: message author on ACGO\n\n";
cout<<"[Space/Enter]: Start playing\n";
cout<<"[H]: Goto author homepage(ACGO)\n";
cout<<"[S]: Game settings\n";
cout<<"[A]: Login as administrator\n";
cout<<"[Esc]: Quit game";
}
int userKey = _getwch();
system("cls");
switch(userKey){
case 27:
if(lang == "zh") cout<<"下次再见!"; else cout<<"See you next time!"; break;
case 72:
case 104:
system("cls");
system("start https://www.acgo.cn/person/4960237");
start();
break;
case 32:
case 13:
chooseLevel();
break;
case 65:
case 97:{
system("cls");
if(_is_admin){
if(lang == "zh"){
cout<<"您已经以管理员身份登录。\n[Shift + C]: 注销管理员\n[其他键]: 返回主菜单";
}else{
cout<<"You are already logined as administrator.\n[Shift + C]:Logout administrator\n[Any other key]:Back to main menu";
}
int usrKeyInAdmin = _getwch();
if(usrKeyInAdmin == 67){
system("cls");
if(lang == "zh"){
cout<<"确定要注销管理员吗??\n[Shift + C]: 确定\n[其他键]: 返回主菜单";
}else{
cout<<"Are you sure to LOGOUT ADMINISTRATOR??\n[Shift + C]:Sure\n[Any other key]:Back to main menu";
}
int usrKeyInLogoutSure = _getwch();
if(usrKeyInLogoutSure == 67){
if(lang == "zh") cout<<"\n\n已注销管理员。\n[任意键]: 返回主菜单";
else cout<<"\n\nLogouted administrator.\n[Any key]:Back to main menu";
_is_admin = false;
_getwch();
}
}
start();
return;
}
if(lang == "zh") cout<<"输入管理员密码: ";
else cout<<"Enter admin password: ";
string userPassword;
cin>>userPassword;
userPassword = SHA256::hash(userPassword);
if(userPassword == ADMIN_PASSWORD){
if(lang == "zh") cout<<"\n已登录为管理员!\n[任意键]: 返回主菜单";
else cout<<"\nLogined as administrator!\n[Any key]:Back to main menu";
_is_admin = true;
_getwch();
start();
break;
}else{
if(lang == "zh") cout<<"\n密码错误!\n[任意键]: 返回主菜单";
else cout<<"\nPassword incorrect!\n[Any key]:Back to main menu";
_getwch();
start();
break;
}
break;
}
case 115:
case 83:
settings();
break;
default:
system("cls");
if(lang == "zh") cout<<"无效按键: "<<userKey<<" 。\n[任意键]: 返回主菜单";
else cout<<"Invalid key: "<<userKey<<" .\n[Any key]:Back to main menu";
_getwch();
start();
}
}
int main(){
/*language check*/
if(lang != "en" && lang != "zh"){
cout<<"--Memory Game Fatal Error 记忆游戏终止错误--\n\n"
"Unsupported language: "<<lang<<" .\n不支持的语言: "<<lang<<"。\nError Code: fatal.unsupport_lang";
return 0;
}
/*admin password check(seems like not used idk why lol)*/
if(ADMIN_PASSWORD != "7851eb075b7b9b76f6b9dc21588d287cb323b65853957e544a3e826138e72d7d"){
cout<<"--Memory Game Fatal Error 记忆游戏终止错误--\n\n"
"Admin password edited. 管理员密码已更改。\n"
"For security, this is not allowed. 出于安全考虑,这是不被允许的。\n"
"Go to where you get this code and correct it. 请从代码获取处更正。\n\n"
"Error Code: fatal.admin_password_edited";
return 0;
}
system("cls");
start();
return 0;
}
这里空空如也




















有帮助,赞一个