下面是本作者負責的存檔部分:
//作者:Thintiger2010 僅供參考,嚴禁抄襲!
#include<bits/stdc++.h>
#include<windows.h>
#include<iostream>
#include<ostream>
#include<istream>
#include<cstring>
#include<string>
#include<time.h>
#include<cstdlib>
using namespace std;
int i;
string userid,cop,copr;
int money,hungry,blood,feeling,a1,b1,c1,d1,b,d,f,h;
char a,c,e,g;
char pd;
string suiji()//來自小唐同學超愛小黃同學的代碼!鳴謝!https://blog.csdn.net/weixin_52521533/article/details/119685771?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522163979040816780271546317%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=163979040816780271546317&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~baidu_landing_v2~default-1-119685771.pc_search_insert_es_download&utm_term=C%2B%2B%E7%94%9F%E6%88%90%E9%AA%8C%E8%AF%81%E7%A0%81&spm=1018.2226.3001.4187
{
int c = 0;
string a;
srand(time(NULL));
for (int i = 0; i<4; i++)
{
AA:
c = rand() % 123;
if (c >= 65 && c <= 90 || c >= 48 && c <= 57 || c >= 97 && c <= 122) a = a + char(c);
else goto AA;
}
return a;
}
int main(){
cout<<"此專案負責人:Tigerh"<<endl<<"油田小游戲"<<endl;
for(int chongfu=0;chongfu<=79;chongfu++) cout<<"-";
cout<<endl;//專案介紹~
copr=suiji();//驗證碼
cout<<"你的驗證碼是:"<<copr<<endl;
Sleep(5000);
system("cls");//清屏,以防萬一他人偷看
cout<<"此專案負責人:Tigerh"<<endl<<"油田小游戲"<<endl;
for(int chongfu=0;chongfu<=79;chongfu++) cout<<"-";
cout<<endl;//專案介紹~
cout<<"請輸入您的存檔碼:"<<endl; //輸入系統提供的存檔碼
cin>>a>>b>>c>>d>>e>>f>>g>>h>>userid;
if(a!='w'||c!='x'||e!='y'||g!='z'){//最基礎判斷:如果隔開字符與系統不一,則判錯
cout<<"錯誤";
return 0;
}else{
a1=b;
b1=d;
c1=f;
d1=h;
if(a1>1000000000||b1>100||c1>100||d1>100){//如果輸入的值大于游戲游玩的最大值,判錯
cout<<"錯誤";
return 0;
}
else{
cout<<"請輸入剛剛生成的驗證碼:";//存檔碼格式正確,開始驗證
cin>>cop;
if(cop!=copr){//判斷是否輸入正確的驗證碼
cout<<"錯誤";
return 0;
}
else{
cout<<"正確!"<<endl<<userid<<",您好,正在加載各類資料"; //各項正確,開始進入系統
for(int k=0;k<=2;k++){//裝飾用,,,可要可不要,
Sleep(100);
cout<<".";
}
cout<<endl;
money=a1;//把剛剛輸入的值賦值到相應位置
hungry=b1;
blood=c1;
feeling=d1;
}
}
}
system("cls");
cout<<"此專案負責人:Tigerh"<<endl<<"油田小游戲"<<endl;
for(int chongfu=0;chongfu<=79;chongfu++) cout<<"-";
cout<<endl;//專案介紹~
cout<<"歡迎您,"<<userid<<endl; //讀出各項指標
cout<<"您上次的財產是:"<<money<<",饑餓值是:"<<hungry<<",血量是:"<<blood<<",心情是:"<<feeling<<endl;
cout<<"要更改嗎?[y/n]"<<endl;//更改指標的選項
cin>>pd;
if(pd=='y'){
cout<<"請依次輸入您的更改:"<<endl;
cin>>a1>>b1>>c1>>d1;
cout<<"您的用戶名:"<<endl;
cin>>userid;
if(a1>1000000000||b1>100||c1>100||d1>100){//判斷是否合法
cout<<"錯誤";
}
else{
money=a1;
hungry=b1;
blood=c1;
feeling=d1;
cout<<"更改成功!"<<endl;
Sleep(2000);
}
}
system("cls");
cout<<"此專案負責人:Tigerh"<<endl<<"油田小游戲"<<endl;
for(int chongfu=0;chongfu<=79;chongfu++) cout<<"-";
cout<<endl;//專案介紹~
cout<<"您的存檔碼:w"<<money<<"x"<<hungry<<"y"<<blood<<"z"<<feeling<<userid; //生成存檔碼
}
以上是最普通的存檔,作者會在后面加上VIP版,加密版,L版
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/385407.html
標籤:其他
上一篇:實驗二 貪吃蛇游戲開發
