#define TexedVersion “Texed v1.1.1.0.1.950826”
//includes. #ifdef __cplusplus
include <cstdio>
include <cstdlib>
include <ctime>
if __cplusplus >= 201103l
include <random>
include <chrono>
endif
#else
include <stdio.h>
include <stdlib.h>
include <time.h>
#endif #include <conio.h> #include <windows.h>
//inline. #ifndef __cplusplus
define inline
#endif
//basic inputs. #ifndef getch
define getch _getch
#endif #ifndef kbhit
define kbhit _kbhit
#endif
//basic values. #ifndef nullptr
define nullptr NULL
#endif #ifndef bool
define bool int
#endif #ifndef true
define true 1
#endif #ifndef false
define false 0
#endif
//unicode. #ifdef UNICODE
define WC(quote) L##quote
define wc wchar_t
define sout wprintf
define ssout swprintf
define souts _putws
#else
define WC(quote) quote
define wc char
define sout printf
define ssout sprintf
define souts puts
#endif
//random functions. #if (defined __cplusplus) && __cplusplus >= 201103l std::random_device rd; std::mt19937 randint(rd() ^ (unsigned)std::chrono ::system_clock::now().time_since_epoch().count()); inline void randinit(){} #else unsigned mt19937[624]; int mt19937_index; inline void randinit(){ int i = 1; mt19937_index = 0; mt19937[0] = (unsigned)time(nullptr); for (; i < 624; ++i){ mt19937[i] = 1812433253u * (mt19937[i - 1] ^ mt19937[i - 1] >> 30u) + i; } } unsigned randint(){ unsigned useless; if (!mt19937_index){ int i = 0; for (; i < 624; ++i){ mt19937[i] = mt19937[(i + 397) % 624] ^ (useless = (mt19937[i] & 2147483648u) | (mt19937[(i + 1) % 624] & 2147483647u)) >> 1u; if (useless & 1u){ mt19937[i] ^= 2567483615u; } } } useless = mt19937[mt19937_index]; mt19937_index = (mt19937_index + 1) % 624; useless ^= useless >> 11u; useless ^= useless << 7u & 2636928640u; useless ^= useless << 15u & 4022730752u; return useless ^ useless >> 18u; } #endif inline bool randbool(){ return (int)randint() & 1; } inline int randmod(unsigned pmod){ return randint() % pmod; } inline int randrange(int left, int right){ return ((int)randint() & 2147483647) % (right - left) + left; } inline int randrangestep(int left, int right, int step){ return ((int)randint() & 2147483647) % ((right + step - left - 1) / step) * step + left; }
//windows controlling functions. HANDLE handle; inline void handleinit(){ handle = GetStdHandle(STD_OUTPUT_HANDLE); } inline void gotoscreen(SHORT x, SHORT y){ SetConsoleCursorPosition(handle, (COORD){x, y}); } inline void setcolor(WORD color){ SetConsoleTextAttribute(handle, color); } inline void hidecursor(){ CONSOLE_CURSOR_INFO CursorInfo; GetConsoleCursorInfo(handle, &CursorInfo); CursorInfo.bVisible = 0; SetConsoleCursorInfo(handle, &CursorInfo); } inline void showcursor(){ CONSOLE_CURSOR_INFO CursorInfo; GetConsoleCursorInfo(handle, &CursorInfo); CursorInfo.bVisible = 1; SetConsoleCursorInfo(handle, &CursorInfo); }
//function with resting-time. int wait(int sleepTime, int times){ clock_t edtm; if (!sleepTime || !times){ return sleepTime; } while (kbhit()){ getch(); } edtm = sleepTime * times + clock(); while (edtm > clock()){ if (kbhit()){ return 0; } } return sleepTime; }
//strict | fast, input & output, functions. inline int printchar(int _Ch){ fwrite(&_Ch, sizeof(wc), 1, stdout); return _Ch; } inline void printstr(const wc *_Str){ const wc _Str2 = _Str; while (_Str){ ++_Str; } fwrite(_Str2, sizeof(wc), _Str - _Str2, stdout); } int printint(int numm, int base, char sep){ int tail = 47, num = numm; bool flag = false; char outstr[48]; if (num >> 31){ num = -num; flag = true; } outstr[47] = num % base + 48; if (outstr[47] > ‘9’){ outstr[47] += '''; } while (num /= base){ if ((tail & 3) == 1){ outstr[—tail] = sep; } outstr[—tail] = num % base + 48; if (outstr[tail] > ‘9’){ outstr[tail] += '''; } } if (flag){ outstr[—tail] = ’-’; } //int length = 37 + (tail >> 2) - tail; fwrite(outstr + tail, 1, 48 - tail, stdout); return numm; } int inputint(int length, int base){ int num = (int)malloc(sizeof(int) * (length + 1)), index = 0, number = 0, i = 0; while (kbhit()){ getch(); } showcursor(); while (1){ num[index] = getch(); if (num[index] == 13 || num[index] == 10){ if (index){ num[index] = 0; break; } printchar(7); } else if(num[index] == 8){ if (index){ —index; printstr(WC(“\b \b”)); } else{ printchar(7); } } else if(num[index] == 43 && !index && length > 1){ printchar(43); num[index++] = 0; } else if(num[index] == 45 && !index && length > 1){ printchar(45); num[index++] = -1; } else if(num[index] > 47 && num[index] < 58 && num[index] < 48 + base || num[index] > 64 && num[index] < 91 && num[index] < 55 + base || num[index] > 96 && num[index] < 123 && num[index] < 87 + base){ if (index == length){ printchar(7); } else if(num[index] < 58){ printchar(num[index]); num[index++] -= 48; } else if(num[index] < 91){ printchar(num[index]); num[index++] -= 55; } else{ printchar(num[index]); num[index++] -= 87; } } else{ printchar(7); } } hidecursor(); if (num[0] < 0){ i = 1; } for (; i < index; ++i){ number = number * base + num[i]; } if (num[0] < 0){ number = -number; } free(num); return number; } void inputstr(char *str, int lenmin, int lenmax, int shown){ int index = 0; while (kbhit()){ getch(); } showcursor(); while (1){ str[index] = getch(); if (str[index] == ‘\r’ || str[index] == ‘\n’){ if (index < lenmin){ printchar(7); } else{ str[index] = ‘\0’; break; } } else if(str[index] == ‘\b’){ if (index){ —index; printstr(WC(“\b \b”)); } else{ printchar(7); } } else if(str[index] > ’/’ && str[index] < ’:’ || str[index] > ’@’ && str[index] < ’[’ || str[index] > ’`’ && str[index] < ’{’){ if (index == lenmax){ printchar(7); } else if(shown){ printchar(shown); ++index; } else{ printchar(str[index++]); } } else{ printchar(7); } } hidecursor(); } const int langmaxi = 2; int language; inline void pause(){ if (language == 1){ printstr(WC(“请按任意键继续…”)); } else if(language == 2){ printstr(WC(“Press any key to continue … ”)); } while (kbhit()){ getch(); } getch(); printchar(10); } int slow(const wc *str, int sleepTime){ int info, st = sleepTime; while (kbhit()){ getch(); } while (*str){ if (*str ^ WC(’%’)){ printchar(*str++); st = wait(st, 1); continue; } ++str; if (*str == WC(’%’)){ printchar(*str); st = wait(st, 1); } else if(*str == WC(‘p’)){ pause(); } else if(*str == WC(‘c’)){ system(“cls”); st = sleepTime; } else{ info = 0; while (*str > WC(’/’) && *str < WC(’:’)){ info = info * 10 + (*str++ & 15); } if (*str == WC(‘s’)){ st = wait(st, info); } } ++str; } return st; } inline void spaces(int left, int right){ const wc *space = WC(” ”) WC(” ”); fwrite(space, sizeof(wc), right - left, stdout); } inline void endline(){ printchar(10); }
//texts of some languages const wc *titleStr[11][3] = { {nullptr, WC(“首页”), WC(“Home”)}, {nullptr, WC(“退出游戏”), WC(“Exit”)}, {nullptr, WC(“登录”), WC(“Sign in”)}, {nullptr, WC(“注册”), WC(“Sigh up”)}, {nullptr, WC(“文字速度”), WC(“Sentence Speed”)}, {nullptr, WC(“语言”), WC(“Language”)}, {nullptr, WC(“公告”), WC(“Notices”)}, {nullptr, WC(“调试”), WC(“Debugging”)}, {nullptr, WC(“退出登录”), WC(“Logout”)}, {nullptr, WC(“成就”), WC(“Achievements”)}, {nullptr, WC(“剧情”), WC(“Playing…”)} }, *titleFormat = WC(“%s | ” TexedVersion); const wc *majorPageStr[11][3] = { {nullptr, WC(“0-退出游戏\n1-登录游戏\n2-注册账号\n”) WC(“3-文字速度\n4-关于游戏\n5-调整语言\n6-查看公告\n\n”) WC(“请输入序号以进入对应功能。\n\n输入:”), WC(“0-Exit\n1-Sign in\n2-Sign Up\n3-Sentence Speed\n4-About\n”) WC(“5-Language\n6-Notices\n\nPress the character on the left of ’-’”) WC(” to achieve its function.\n\nInput: ”)}, {nullptr, WC(“确定退出游戏?\n> 是\n 否\n按下回车做出选择。”), WC(“Are you sure?\n> Yes\n No\n”) WC(“Press enter to make your dicision.”)}, {nullptr, WC(“0-退出登录\n1-开始游戏\n2-查看成就\n3-文字速度\n”) WC(“4-关于游戏\n5-调试模式\n6-调整语言\n7-查看公告\n\n”) WC(“请输入序号以进入对应功能。\n\n输入:”), WC(“0-Logout\n1-Start\n2-Achievements\n3-Sentence Speed\n4-About\n”) WC(“5-Debugging Switch\n6-Language\n7-Notices\n\nPress the charact”) WC(“er on the left of ’-’ to achieve its function.\n\nInput: ”)}, {nullptr}, {nullptr, WC(“文字速度\n 瞬 (0ms)\n 快(10ms)\n”) WC(” 中(25ms)\n 慢(50ms)\n返回请按退格。”), WC(“Sentence Speed\n Quickly(0ms)\n Fast (10ms)\n”) WC(” Medium(25ms)\n Slow (50ms)\nPress backspace to return.”)}, {nullptr, WC(“调整语言\n> 简体中文\n English\n返回请按退格。”), WC(“Language\n 简体中文\n> English\nPress backspace to return.”)}, {nullptr, WC(” < | 公告\n--------|\n 公 告 > 已完成16个剧情页\n”) WC(”--------|\n更新日志|\n--------|\n |”), WC(” < | Notices\n--------|\nNotices > 16 plot pages have ”) WC(“been finished\n--------|\nUpdating|\n--------|\n |”)}, {nullptr, WC(“调试模式\n 打开调试\n 关闭调试\n返回请按退格。”), WC(“Debugging Button\n On\n Off\nPress backspace to return.”)}, {nullptr, WC(“确定退出登录?\n> 是\n 否\n按下回车做出选择。”), WC(“Are you sure?\n> Yes\n No\n”) WC(“Press enter to make your dicision.”)} }; const wc *achievementPageStr[5][3] = { {nullptr, WC(“未达成”), WC(“(Locked)”)}, {nullptr, WC(“未搜集”), WC(“(Locked)”)}, {nullptr, WC(“结局”), WC(“Endings”)}, {nullptr, WC(“死亡次数:%u次\n”), WC(“Deaths: %u times\n”)} }; const wc *sceneStr[1][5][3] = { {{nullptr}, {nullptr, WC(“你缓缓睁开眼,感觉头部有些疼痛。\n”) WC(“你发现你躺在你家沙发上。\n”) WC(“你好像失忆了,只能记住以前非常零星的内容。\n”) WC(“一回想,一阵剧烈的头痛席卷而来。你只好停止回忆。\n”) WC(“打开窗户,向外望去,不见一点人影,不闻一点人声,”) WC(“好像世界上只剩下了你一人一样。\n\n%64s”) WC(““咚咚咚!”门外响起了敲门声。\n\n这时你会:\n”) WC(“0.假装听不见\n1.回应门外的声音\n2.开门看一看\n你选择:”), WC(“You slowly open your eyes, feeling a headache.\n”) WC(“You find yourself lying on the sofa.\n”) WC(“You seem to have lost your memory, ”) WC(“only remembering fragments.\n”) WC(“As soon as you recall, a severe headache sweep over you.\n”) WC(“You have to stop reminiscing.\n”) WC(“You open the window lookng out. ”) WC(“There is no one and no sound.\nIt seems like that ”) WC(“you are the only human in the world.\n\n%64s”) WC(“Suddenly, there is a knock on the door.\n\n”) WC(“Then you will:\n0.make as though you do not hear\n”) WC(“1.reply the sound\n2.open the door\nInput here: ”)}, {nullptr, WC(“你打开了门,发现外面站着一个人。\n你看了他几眼,”) WC(“但是移开视线后就会忘记那人的容貌。这也太奇怪了。\n”) WC(“他自我介绍说他叫吴良,发现街道上没人,”) WC(“于是想确认是否所有人都消失了。\n”) WC(““我能进去吗?”他说。\n\n”) WC(“这时你会:\n0.请他进来\n1.委婉拒绝\n”) WC(“2.态度恶劣地叫他滚出去\n你选择:”), WC(“You open the door and see a man standing outside.”) WC(“You look at him, but once you look away, ”) WC(“you will forget his appearance.\nThis is too strange.\n”) WC(“He says he is Wu Liang and found nobody on the street.”) WC(“He wanted to ckeck out if everyone is disappeared.\n”) WC(""Could I go in?” He asked.\n\n”) WC(“Then you will:\n0.let him come in\n1.refuse him politely\n”) WC(“2.shout at him to ask him leave\nInput here: ”)}, {nullptr, WC(“结局”), WC(“No translation available at the moment”)}, {nullptr, WC(“死亡次数:%u次\n”), WC(“No translation available at the moment”)} } }; wc titlename[1024];
//the datas of characters and achievements. typedef struct _character{ const wc *name[3]; unsigned food; unsigned money; unsigned deaths; }character; typedef struct _achievement{ const wc *name[3]; bool isreached; }achievement;
const int persmaxi = 1, achimaxi = 3, endingachimaxi = 3, scenesmaxi = 18;
int sleeptime;
character person[persmaxi]; achievement achi[achimaxi], endingachi[endingachimaxi];
inline void initperson(){ person -> name[1] = WC(“张华阳”); person -> name[2] = WC(“Zhang Huayang”); } inline void initachi(){ achi -> name[1] = WC(“进行一次游戏”); achi -> name[2] = WC(“Start the Game”); achi[1].name[1] = WC(“死亡一次”); achi[1].name[2] = WC(“Death”); achi[2].name[1] = WC(“拔剑四顾心茫然”); achi[2].name[2] = WC(“Draw the Sword, Look Around, and Feel Confused”); } void reachachi(int i){ if (!achi[i].isreached){ achi[i].isreached = 1; system(“cls”); if (language == 1){ printf(“达成成就[%s]!\n”, achi[i].name[1]); } else if(language == 2){ printf(“Achieve [%s]!\n”, achi[i].name[2]); } pause(); } } inline void initendingachi(){ endingachi -> name[1] = WC(“被斧头砍死”); endingachi -> name[2] = WC(“Killed by the Axe”); endingachi[1].name[1] = WC(“被手刃”); endingachi[1].name[2] = WC(“Die from Your Impoliteness”); endingachi[2].name[1] = WC(“不食人间烟火”); endingachi[2].name[2] = WC(“Die of Hunger”); } inline void initperaced(){ initperson(); initachi(); initendingachi(); }
int isdebugging;
int personindex, scene;
inline void settitle(int x){ ssout(titlename, titleFormat, titleStr[x][language]); SetConsoleTitle(titlename); }
void sceneHeadFunc(const character *const per){ int nothingflag = 1; if (language == 1){ printf(“%s,你有”, per -> name[1]); if (per -> food){ printf(“%u份main包,”, per -> food); nothingflag = 0; } if (per -> money){ printf(“%u,", per -> money); nothingflag = 0; } if (nothingflag){ printstr("\b\b什么都没有 "); } printstr("\b\b。"); } else if(language == 2){ printf("%s, you have", per -> name[2]); if (per -> food){ printf(" %u package%s of \"main\" bread,", per -> food, per -> food > 1 ? "s" : ""); nothingflag = 0; } if (per -> money){ printf(" %u,”, per -> money); nothingflag = 0; } if (nothingflag){ printstr(” nothing ”); } printstr(“\b.”); } endline(); if (isdebugging){ printint(scene + 16777000, 10, ’,’); printchar(58); } endline(); }
//user controlling. char userdata[1024];
char loginusername[20], loginpassword[20]; char registerusername[20], registerpassword[20], registerpasswordcheck[20]; int userid, loginerror, registererror;
int isANS2in3(const char *s){ int kinds = 0; const char *c = s; while (*c){ if (c < ''){ return 0; } if (*c < ‘0’){ kinds |= 4; } else if(*c < ’:’){ kinds |= 1; } else if(*c < ’<’ || *c == ’?’){ kinds |= 4; } else if(*c < ‘A’){ return 0; } else if(*c < ’[’ || *c == ’_’){ kinds |= 2; } else if(*c < ‘a’){ return 0; } else if(*c < ’{’){ kinds |= 2; } else{ return 0; } ++c; } return s + 5 < c && s + 19 > c && (kinds >> 1 & kinds | kinds >> 2 & kinds) ? c - s : 0; } void hashstr(char *s){ char c = *s; while (*s > ’ ’){ *s ^= *(s + 1); ++s; } *(s - 1) ^= *s ^ c; } int hashequal(char *a, const char *b){ char c = *a; while (*a > ’ ’ && *b > ’ ’){ *a ^= *(a + 1); if (*a++ ^ *b++){ return 0; } } if (*a > ’ ’ || *b > ’ ’){ return 0; } *(a - 1) ^= *a ^ c; while (*a && *b){ if (*a++ ^ *b++){ return 0; } } if (*a || *b){ return 0; } return 1; } void intintostr(char *str, int num){ *str = num; str[1] = num >> 8; str[2] = num >> 16; str[3] = num >> 24; } int getintfromstr(const char *str){ return *str & 255 | (str[1] & 255) << 8 | (str[2] & 255) << 16 | (str[3] & 255) << 24; } void inituserdata(char *usdt){ memset(usdt, 0, 1024); strcpy(usdt, registerpassword); usdt[18] = ‘\1’; intintostr(usdt + 24, 1500); } int loginreaddata(){ FILE *file = fopen(“userdata\userlist.dat”, “rb”); char fileid[24], usnm[20], readin; int i, j, usernum = 0; userid = 0; if (file == nullptr){ if (!(isANS2in3(loginusername) && isANS2in3(loginpassword))){ return 1; } file = fopen(“userdata\userlist.dat”, “wb”); if (file == nullptr){ return 65536; } fwrite(“\0”, 1, 2, file); fclose(file); return 2; } if (!((i = isANS2in3(loginusername)) && (j = isANS2in3(loginpassword)))){ fclose(file); return 1; } memset(loginusername + i, 32, 18 - i); memset(loginpassword + j, 32, 18 - j); loginusername[18] = loginpassword[18] = usnm[18] = ‘\0’; fread(&readin, 1, 1, file); usernum |= readin & 255; fread(&readin, 1, 1, file); usernum |= (readin & 255) << 8; i = 0; while (i < usernum){ fread(usnm, 1, 18, file); if (!strcmp(loginusername, usnm)){ break; } ++i; } fclose(file); if (i == usernum){ return 2; } sprintf(fileid, “userdata\user%x.dat”, (unsigned)(userid = i & 65535u)); file = fopen(fileid, “rb”); if (file == nullptr){ char readsin[1024] = ""; memset(registerpassword, 32, 18); registerpassword[18] = ‘\0’; inituserdata(readsin); file = fopen(fileid, “wb”); if (file == nullptr){ return 65536; } fwrite(readsin, 1, 1024, file); fclose(file); return 4; } fread(userdata, 1, 1024, file); fclose(file); readin = userdata[18]; userdata[18] = ‘\0’; hashstr(loginpassword); if (strcmp(loginpassword, userdata)){ memset(userdata, 0, 1024); return 4; } userdata[18] = readin; return 0; } int registernewuser(){ FILE *file = fopen(“userdata\userlist.dat”, “rb”); char readsin[1024], fileid[24], usnm[20], readin; int i, j, k, usernum = 0; if (file == nullptr){ if (!((i = isANS2in3(registerusername)) && (j = isANS2in3(registerpassword)) && (k = isANS2in3(registerpasswordcheck)))){ return 1; } memset(registerusername + i, 32, 18 - i); memset(registerpassword + j, 32, 18 - j); memset(registerpasswordcheck + k, 32, 18 - k); registerusername[18] = registerpassword[18] = ‘\0’; registerpasswordcheck[18] = usnm[18] = ‘\0’; hashstr(registerpassword); hashstr(registerpasswordcheck); if (strcmp(registerpasswordcheck, registerpassword)){ return 2; } inituserdata(readsin); file = fopen(“userdata\userlist.dat”, “wb”); if (file == nullptr){ return 65536; } fwrite(“\1”, 1, 2, file); fwrite(registerusername, 1, 18, file); fclose(file); file = fopen(“userdata\user0.dat”, “wb”); if (file == nullptr){ return 65536; } fwrite(readsin, 1, 1024, file); fclose(file); return 0; } if (!((i = isANS2in3(registerusername)) && (j = isANS2in3(registerpassword)) && (k = isANS2in3(registerpasswordcheck)))){ fclose(file); return 1; } memset(registerusername + i, 32, 18 - i); memset(registerpassword + j, 32, 18 - j); memset(registerpasswordcheck + k, 32, 18 - k); registerusername[18] = registerpassword[18] = ‘\0’; registerpasswordcheck[18] = usnm[18] = ‘\0’; hashstr(registerpassword); hashstr(registerpasswordcheck); if (strcmp(registerpasswordcheck, registerpassword)){ fclose(file); return 2; } fread(&readin, 1, 1, file); usernum |= readin & 255; fread(&readin, 1, 1, file); usernum |= (readin & 255) << 8; i = 0; while (i < usernum){ fread(usnm, 1, 18, file); if (!strcmp(registerusername, usnm)){ break; } ++i; } fclose(file); if (i ^ usernum){ return 4; } readin = ++usernum; file = fopen(“userdata\userlist.dat”, “rb+”); if (file == nullptr){ return 65536; } rewind(file); fwrite(&readin, 1, 1, file); readin = usernum >> 8; fwrite(&readin, 1, 1, file); fseek(file, 0l, 2); fwrite(registerusername, 1, 18, file); fclose(file); inituserdata(readsin); sprintf(fileid, “userdata\user%x.dat”, (unsigned)(userid = i & 65535u)); file = fopen(fileid, “wb”); if (file == nullptr){ return 65536; } fwrite(readsin, 1, 1024, file); fclose(file); return 0; }
//int saveuserdata(){ // FILE *file; // char fileid[24]; // int i = 0, j = 0; // memset(userdata, 0, 1024); // strcpy(userdata, loginpassword); // while (++j < 3){ // intintostr(userdata + (j << 4) + 4, *money[j]); // intintostr(userdata + (j << 4) + 8, money[j][1]); // intintostr(userdata + (j << 4) + 12, money[j][2]); // } // while (++i < 3){ // j = 0; // while (++j < 3){ // intintostr(userdata + (i << 6 | j << 2) + 16, product[i][j]); // } // } // sprintf(fileid, “setting\user%x.dat”, (unsigned)userid); // file = fopen(fileid, “wb”); // if (file == nullptr){ // return 65536; // } // fwrite(userdata, 1, 1024, file); // fclose(file); // return 0; //} //void getuserdata(){ // int i = 0, j = 0; // while (++j < 3){ // *money[j] = getintfromstr(userdata + (j << 4) + 4); // money[j][1] = getintfromstr(userdata + (j << 4) + 8); // money[j][2] = getintfromstr(userdata + (j << 4) + 12); // } // while (++i < 3){ // j = 0; // while (++j < 3){ // product[i][j] = getintfromstr(userdata + (i << 6 | j << 2) + 16); // } // } //}
//the major page functions. inline void exitPageFunc(){ int status = 0; system(“cls”); settitle(1); souts(majorPageStr[1][language]); while (kbhit()){ getch(); } while (1){ int ch = getch(); if (ch == 10 || ch == 13){ if (!status){ exit(0); } return; } if ((ch == 87 || ch == 119) && status){ gotoscreen(0, 2); printchar(32); gotoscreen(0, 1); printchar(62); status = 0; } else if((ch == 83 || ch == 115) && !status){ gotoscreen(0, 1); printchar(32); gotoscreen(0, 2); printchar(62); status = 1; } else{ printchar(7); } } } inline void loginPageFunc(){ int status; system(“cls”); settitle(2); if (language == 1){ souts(WC(“请输入账号:”)); inputstr(loginusername, 6, 18, 0); endline(); souts(WC(“请输入密码:”)); inputstr(loginpassword, 6, 18, 42); system(“cls”); if ((status = loginreaddata()) & 65536){ printstr(WC(“账号读取失败!”)); userid = ~0; wait(2000, 1); } else if(status & 1){ printstr(WC(“账号或密码格式错误!”)); userid = ~0; wait(2000, 1); } else if(status & 2){ printstr(WC(“账号未找到!”)); userid = ~0; wait(2000, 1); } else if(status & 4){ printstr(WC(“密码错误!”)); userid = ~0; wait(2000, 1); } } else if(language == 2){ souts(WC(“Please input the username:”)); inputstr(loginusername, 6, 18, 0); endline(); souts(WC(“Please input the password:”)); inputstr(loginpassword, 6, 18, 42); system(“cls”); if ((status = loginreaddata()) & 1){ printstr(WC(“Account read failed!”)); userid = ~0; wait(2000, 1); } else if(status & 1){ printstr(WC(“Username or password format error!”)); userid = ~0; wait(2000, 1); } else if(status & 2){ printstr(WC(“Account not found!”)); userid = ~0; wait(2000, 1); } else if(status & 4){ printstr(WC(“Wrong password!”)); userid = ~0; wait(2000, 1); } } } inline void registerPageFunc(){ int status; system(“cls”); settitle(3); if (language == 1){ souts(WC(“请输入账号:”)); inputstr(registerusername, 6, 18, 0); endline(); souts(WC(“请输入密码:”)); inputstr(registerpassword, 6, 18, 42); endline(); souts(WC(“请确认密码:”)); inputstr(registerpasswordcheck, 6, 18, 42); system(“cls”); if ((status = registernewuser()) & 65536){ printstr(WC(“账号读取失败!”)); } else if(status & 1){ printstr(WC(“账号或密码格式错误!”)); } else if(status & 2){ printstr(WC(“密码与确认密码不匹配!”)); } else if(status & 4){ printstr(WC(“账号已存在!”)); } else{ printstr(WC(“注册成功!”)); } } else if(language == 2){ souts(WC(“Please input the username:”)); inputstr(registerusername, 6, 18, 0); endline(); souts(WC(“Please input the password:”)); inputstr(registerpassword, 6, 18, 42); endline(); souts(WC(“Please check the password:”)); inputstr(registerpasswordcheck, 6, 18, 42); system(“cls”); if ((status = registernewuser()) & 1){ printstr(WC(“Account read failed!”)); } else if(status & 1){ printstr(WC(“Username or password format error!”)); } else if(status & 2){ printstr(WC(“Passwords do not match!”)); } else if(status & 4){ printstr(WC(“Account exists!”)); } else{ printstr(WC(“Registration completed!”)); } } userid = ~0; wait(2000, 1); } inline void sleeptimePageFunc(){ int status; system(“cls”); settitle(4); souts(majorPageStr[4][language]); if (!sleeptime){ gotoscreen(0, status = 1); } else if(sleeptime == 10){ gotoscreen(0, status = 2); } else if(sleeptime == 25){ gotoscreen(0, status = 3); } else if(sleeptime == 50){ gotoscreen(0, status = 4); } printchar(62); while (kbhit()){ getch(); } while (1){ int ch = getch(); if (ch == 8){ if (status == 1){ sleeptime = 0; } else if(status == 2){ sleeptime = 10; } else if(status == 3){ sleeptime = 25; } else if(status == 4){ sleeptime = 50; } return; } if ((ch == 87 || ch == 119) && status > 1){ gotoscreen(0, status—); printchar(32); gotoscreen(0, status); printchar(62); } else if((ch == 83 || ch == 115) && status < 4){ gotoscreen(0, status++); printchar(32); gotoscreen(0, status); printchar(62); } else{ printchar(7); } } } inline void aboutPageFunc(){ system(“cls”); if (language == 1){ SetConsoleTitle(WC(“关于 | 剧情游戏 v1.1.1.0.1.950826”)); souts(WC(“关于游戏”)); souts(WC(” 剧情游戏 v1.1.1.0.1.950826”)); souts(WC(” 作者:”)); souts(WC(” 洛谷UID950826 用户名<qiuby123456>”)); souts(WC(” 鸣谢:”)); souts(WC(” <被动>洛谷UID92860 用户名<TSzza>”)); souts(WC(” 灵感来源”)); souts(WC(” <被动>洛谷UID894358 用户名<zjw806903>”)); souts(WC(” 灵感来源”)); souts(WC(” <主动>洛谷UID950826 用户名<qiuby123456>”)); souts(WC(” 提供了创意”)); souts(WC(” 版权所有,侵权必究”)); } else if(language == 2){ SetConsoleTitle(WC(“About | Texed v1.1.1.0.1.950826”)); souts(WC(“About”)); souts(WC(” Texed v1.1.1.0.1.950826”)); souts(WC(” Author:”)); souts(WC(” LuoguUID950826 Username<qiuby123456>”)); souts(WC(” Thanks for:”)); souts(WC(” <Passive>LuoguUID92860 Username<TSzza>”)); souts(WC(” Source of inspiration”)); souts(WC(” <Passive>LuoguUID894358 Username<zjw806903>”)); souts(WC(” Source of inspiration”)); souts(WC(” <Active> LuoguUID950826 Username<qiuby123456>”)); souts(WC(” Provided ideas”)); souts(WC(” All rights reserved.”)); } pause(); } inline void languagePageFunc(){ system(“cls”); settitle(5); souts(majorPageStr[5][language]); while (kbhit()){ getch(); } while (1){ int ch = getch(); if (ch == 8){ return; } if ((ch == 87 || ch == 119) && language > 1){ —language; } else if((ch == 83 || ch == 115) && language < langmaxi){ ++language; } else{ printchar(7); continue; } system(“cls”); settitle(5); souts(majorPageStr[5][language]); } } inline void noticesPageFunc(){ int status = 1; system(“cls”); settitle(6); souts(majorPageStr[6][language]); while (status){ int mouse = 0, i = 0; POINT point; HWND hwnd = GetForegroundWindow(); GetCursorPos(&point); ScreenToClient(hwnd, &point); for (; i < 3; ++i){ if (GetAsyncKeyState(1) && !mouse && i != status && point.x > -1 && point.x < 64 && point.y > (i << 5) - 1 && point.y < (i << 5) + 16){ mouse = 1; gotoscreen(8, status << 1); printchar(124); gotoscreen(8, (status = i) << 1); printchar(62); if (status == 1){ int useless = 3; gotoscreen(10, 0); if (language == 1){ printstr(WC(“公告”)); spaces(14, 72); gotoscreen(10, 2); printstr(WC(” 已完成16个剧情页”)); spaces(28, 72); } else if(language == 2){ printstr(WC(“Notices”)); spaces(18, 72); gotoscreen(10, 2); printstr(WC(” 16 plot pages have finished”)); spaces(39, 72); } for (; useless < 19; ++useless){ gotoscreen(10, useless); spaces(10, 72); } } else if(status == 2){ gotoscreen(10, 0); if (language == 1){ printstr(WC(“更新日志”)); spaces(18, 72); gotoscreen(10, 2); printstr(WC(” v1.1.1.0.1.950826”)); spaces(29, 72); gotoscreen(10, 3); printstr(WC(” 重写”)); spaces(18, 72); gotoscreen(10, 4); printstr(WC(” v1.1.0.2.1.950826”)); spaces(29, 72); gotoscreen(10, 5); printstr(WC(” 添加账号系统”)); spaces(26, 72); gotoscreen(10, 6); printstr(WC(” 使用更便捷的场景跳转函数”)); spaces(38, 72); gotoscreen(10, 7); printstr(WC(” v1.1.0.1.2.950826”)); spaces(29, 72); gotoscreen(10, 8); printstr(WC(” 使用更好的随机数生成函数”)); spaces(38, 72); gotoscreen(10, 9); printstr(WC(” 使用更快的输出函数”)); spaces(32, 72); gotoscreen(10, 10); printstr(WC(” v1.1.0.1.1.950826”)); spaces(29, 72); gotoscreen(10, 11); printstr(WC(” 添加了3个剧情页”)); spaces(29, 72); gotoscreen(10, 12); printstr(WC(” 使用更好的延时函数”)); spaces(32, 72); gotoscreen(10, 13); printstr(WC(” 修复了标题语言切换的问题”)); spaces(38, 72); gotoscreen(10, 14); printstr(WC(” v1.1.0.0.2.950826”)); spaces(29, 72); gotoscreen(10, 15); printstr(WC(” 添加了公告”)); spaces(24, 72); gotoscreen(10, 16); printstr(WC(” 在公告页面使用鼠标操作”)); spaces(36, 72); gotoscreen(10, 17); printstr(WC(” v1.1.0.0.1.950826”)); spaces(29, 72); gotoscreen(10, 18); printstr(WC(” 添加了13个剧情页”)); spaces(30, 72); } else if(language == 2){ printstr(WC(“Updating”)); spaces(18, 72); gotoscreen(10, 2); printstr(WC(” v1.1.1.0.1.950826”)); spaces(29, 72); gotoscreen(10, 3); printstr(WC(” Rewrite”)); spaces(21, 72); gotoscreen(10, 4); printstr(WC(” v1.1.0.2.1.950826”)); spaces(29, 72); gotoscreen(10, 5); printstr(WC(” Add user system”)); spaces(29, 72); gotoscreen(10, 6); printstr(WC(” Change the easier ”) WC(“scene-changing function”)); spaces(55, 72); gotoscreen(10, 7); printstr(WC(” v1.1.0.1.2.950826”)); spaces(29, 72); gotoscreen(10, 8); printstr(WC(” Change the better ”) WC(“random-number-generating function”)); spaces(65, 72); gotoscreen(10, 9); printstr(WC(” Change the faster”) WC(” outputing function”)); spaces(50, 72); gotoscreen(10, 10); printstr(WC(” v1.1.0.1.1.950826”)); spaces(29, 72); gotoscreen(10, 11); printstr(WC(” Add 3 plot pages”)); spaces(30, 72); gotoscreen(10, 12); printstr(WC(” Change the better ”) WC(“resting-time function”)); spaces(53, 72); gotoscreen(10, 13); printstr(WC(” Make the language ”) WC(“of the title change”)); spaces(51, 72); gotoscreen(10, 14); printstr(WC(” v1.1.0.0.2.950826”)); spaces(29, 72); gotoscreen(10, 15); printstr(WC(” Add the notices”)); spaces(29, 72); gotoscreen(10, 16); printstr(WC(” Use mouse operation ”) WC(“in Page Notices”)); spaces(49, 72); gotoscreen(10, 17); printstr(WC(” v1.1.0.0.1.950826”)); spaces(29, 72); gotoscreen(10, 18); printstr(WC(” Add 13 plot pages”)); spaces(31, 72); } } } else if(mouse){ mouse = 0; } } } } inline void logoutPageFunc(){ int status = 0; system(“cls”); settitle(8); souts(majorPageStr[8][language]); while (kbhit()){ getch(); } while (1){ int ch = getch(); if (ch == 10 || ch == 13){ if (!status){ userid = ~0; memset(userdata, 0, 1024); } return; } if ((ch == 87 || ch == 119) && status){ gotoscreen(0, 2); printchar(32); gotoscreen(0, 1); printchar(62); status = 0; } else if((ch == 83 || ch == 115) && !status){ gotoscreen(0, 1); printchar(32); gotoscreen(0, 2); printchar(62); status = 1; } else{ printchar(7); } } } int scenesGoto[persmaxi][scenesmaxi][4] = { {{1}, {0, 0, 2} } }; int scenesChoiceNum[persmaxi][scenesmaxi] = { {0, 3} }; void startingPageFunc(){ int returninfo = 1; settitle(10); system(“cls”); reachachi(0); if (!personindex){ person -> food = 10u; person -> money = 0u; } scene = **scenesGoto[personindex]; while (scene){ system(“cls”); sceneHeadFunc(person + personindex); slow(sceneStr[personindex][scene][language], sleeptime); returninfo = inputint(1, scenesChoiceNum[personindex][scene]); scene = scenesGoto[personindex][scene][returninfo]; } if (language == 1){ puts(“剧情暂未完成…”); puts(“建议看看[关于游戏]”); } else if(language == 2){ puts(“Unfinished Ending…”); puts(“You could look through [About]”); } pause(); } void achievementPageFunc(){ int i = 0; unsigned deadTimes = 0u; system(“cls”); settitle(9); souts(titleStr[9][language]); for (; i < achimaxi; ++i){ sout(WC(” %s\n”), achi[i].isreached ? achi[i].name[language] : achievementPageStr[0][language]); } endline(); souts(achievementPageStr[2][language]); for (i = 0; i < endingachimaxi; ++i){ sout(” %s\n”, endingachi[i].isreached ? endingachi[i].name[language] : achievementPageStr[1][language]); } endline(); for (i = 0; i < persmaxi; ++i){ deadTimes += person[i].deaths; } sout(achievementPageStr[3][language], deadTimes); pause(); } void debuggingPageFunc(){ system(“cls”); settitle(7); souts(majorPageStr[7][language]); gotoscreen(0, 2 - isdebugging); putchar(62); while (kbhit()){ getch(); } while (1){ int ch = getch(); if (ch == 8){ return; } if ((ch == 87 || ch == 119) && !isdebugging){ gotoscreen(0, 2); printchar(32); gotoscreen(0, 1); printchar(62); isdebugging = 1; } else if((ch == 83 || ch == 115) && isdebugging){ gotoscreen(0, 1); printchar(32); gotoscreen(0, 2); printchar(62); isdebugging = 0; } else{ printchar(7); } } } inline void noUserPageFunc(){ int input; scene = 0; system(“cls”); settitle(0); slow(majorPageStr[0][language], sleeptime); input = inputint(1, 7); if (!input){ exitPageFunc(); } else if(input == 1){ loginPageFunc(); } else if(input == 2){ registerPageFunc(); } else if(input == 3){ sleeptimePageFunc(); } else if(input == 4){ aboutPageFunc(); } else if(input == 5){ languagePageFunc(); } else if(input == 6){ noticesPageFunc(); } } inline void userPageFunc(){ int input; scene = 0; system(“cls”); settitle(0); slow(majorPageStr[2][language], sleeptime); input = inputint(1, 7); if (!input){ logoutPageFunc(); } else if(input == 1){ startingPageFunc(); // save(); } else if(input == 2){ achievementPageFunc(); } else if(input == 3){ sleeptimePageFunc(); } else if(input == 4){ aboutPageFunc(); } else if(input == 5){ debuggingPageFunc(); } else if(input == 6){ languagePageFunc(); } else if(input == 7){ noticesPageFunc(); } } inline void homePageFunc(){ int input; while (1){ while (userid < 0){ noUserPageFunc(); } while (userid >= 0){ userPageFunc(); } } }
//inlines. inline void init(){ randinit(); handleinit(); initperaced(); CreateDirectory(WC(“userdata”), nullptr); userid = ~0; sleeptime = 25; language = 1; system(“cls”); hidecursor(); system(“mode con cols=80 lines=25”); SetConsoleTitle(WC(TexedVersion)); }
int main(){ init(); homePageFunc(); return 0; }