存点东西2

· · 个人记录

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int BackGroundColor=15,n,Card[16][70];
string CHS[101];
char ch;
string name[16];
void ChangeBGC(int x)
{
    if(x==0)
      system("color 0F");
    if(x==1)
      system("color 10");
    if(x==2)
      system("color 20");
    if(x==3)
      system("color 30");
    if(x==4)
      system("color 40");
    if(x==5)
      system("color 50");
    if(x==6)
      system("color 60");
    if(x==7)
      system("color 70");
    if(x==8)
      system("color 8F");
    if(x==9)
      system("color 90");
    if(x==10)
      system("color A0");
    if(x==11)
      system("color B0");
    if(x==12)
      system("color C0");
    if(x==13)
      system("color D0");
    if(x==14)
      system("color E0");
    if(x==15)
      system("color F0");
}
void C(int FF)
{
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BackGroundColor<<4|FF);
}
bool OKIN(int U,string &s)
{
    if(s.size()>1)
      return false;
    if(islower(s[0]))
      s[0]-=32;
    if(!isupper(s[0]))
      return false;
    if(s[0]<=64+U)
      return true;
    return false;
}
char in(int U)
{
    string s;
    do
    {
        C(0);
        cout<<"-----Choose One-----\n";
        for(int i=1;i<=U;++i)
        {
            int color=CHS[i][0];
            if(color>64)
              color-=55;
            C(color);
            cout<<char(i+64)<<". ";
            for(int j=1;j<CHS[i].size();++j)
              cout<<CHS[i][j];
            cout<<'\n';
        }
        C(0);
        cin>>s;
        system("cls");
    }while(!OKIN(U,s));
    return s[0];
}
void CardList()
{
    system("cls");
    int Askid=1;
    while(1)
    {
        C(2);
        cout<<"  Card List\n\n";
        if(Askid==1)
        {
            CHS[1]="2Add Cards";
            CHS[2]="4Subtract Cards";
            CHS[3]="6Multiply Cards";
            CHS[4]="5Special Cards";
            CHS[5]="3Super Cards";
            CHS[6]="1Turn to Homepage";
            ch=in(6);
            if(ch!='F')
            {
                Askid=ch-63;
                continue;
            }
            break;
        }
        if(Askid==2)
        {
            C(0);
            cout<<"Add Cards(color ";
            BackGroundColor=2;
            C(5);
            cout<<"  ";
            BackGroundColor=15;
            C(0);
            cout<<"):\n";
            C(0);
            cout<<"Category 1(code:1):    Add k for one number and it will mod 10\n";
            cout<<"Category 2(code:2):    Add k for one number and it is at most 9\n\n";
            CHS[1]="4Back (Go to the previous page)\n";
            ch=in(1);
            Askid=1;
            continue;
        }
        if(Askid==3)
        {
            C(0);
            cout<<"Subtract Cards(color ";
            BackGroundColor=4;
            C(5);
            cout<<"  ";
            BackGroundColor=15;
            C(0);
            cout<<"):\n";
            C(0);
            cout<<"Category 1(code:1):    Subtract k for one number and it will mod 10\n";
            cout<<"Category 2(code:2):    Subtract k for one number and it is at least 0\n\n";
            CHS[1]="4Back (Go to the previous page)\n";
            ch=in(1);
            Askid=1;
            continue;
        }
        if(Askid==4)
        {
            C(0);
            cout<<"Multiply Cards(color ";
            BackGroundColor=6;
            C(5);
            cout<<"  ";
            BackGroundColor=15;
            C(0);
            cout<<"):\n";
            C(0);
            cout<<"Category 1(code:1):    Multiply k for one number and it will mod 10\n";
            cout<<"Category 2(code:2):    Multiply k for one number and it will dive 10\n\n";
            CHS[1]="4Back (Go to the previous page)\n";
            ch=in(1);
            Askid=1;
            continue;
        }
        if(Askid==5)
        {
            C(0);
            cout<<"Special Cards(color ";
            BackGroundColor=5;
            C(5);
            cout<<"  ";
            BackGroundColor=15;
            C(0);
            cout<<"):\n";
            C(0);
            cout<<"Category 1(code:1):    Copy one number to another number\n";
            cout<<"Category 2(code:2):    Change one number to any another number in people's eyes\n";
            cout<<"Category 3(code:3):    Copy one's id to you\n";
            cout<<"Category 4(code:4):    Make another number in you id and you can win with 3 numbers on the left or on the right\n";
            cout<<"Category 5(code:5):    Random card--you can use this card to get a random card,it might be all of Category\n\n";
            CHS[1]="4Back (Go to the previous page)\n";
            ch=in(1);
            Askid=1;
            continue;
        }
        if(Askid==6)
        {
            C(0);
            cout<<"Super Cards(color ";
            BackGroundColor=3;
            C(5);
            cout<<"  ";
            BackGroundColor=15;
            C(0);
            cout<<"):\n";
            C(0);
            cout<<"Category 1(code:1):    Change 2 numbers of one's id what you want\n";
            cout<<"Category 2(code:2):    Use this card to win the Game when your id is a prime\n";
            cout<<"Category 3(code:3):    Lucky card--Use this card to get 3 Random cards\n";
            cout<<"Category 4(code:4):    Lock your number in this Round and most of the players can't change it\n";
            CHS[1]="4Back (Go to the previous page)\n";
            ch=in(1);
            Askid=1;
            continue;
        }
    }
}
void Randomcards()
{
    system("cls");
    for(int i=1;i<=n;++i)
    {
        C(0);
        cout<<"Randoming cards for ";
        C(i);
        cout<<name[i];
        C(0);
        cout<<" ...\n";
        long long Pos=1,Mod=1000000,l=rand()%11+10,K=7;
        for(int j=1;j<=l;++j)
          Pos=(Pos+131)*rand()%Mod,K=(K+13331)*rand()%10;
        if(Pos<540000)
          for(int j=1;j<=l;++j)
            K=(K+7)*rand()%9+1;
        Sleep(1000);
        if(Pos<120000)
        {
            C(i);
            cout<<name[i];
            C(0);
            cout<<" got a card : ";
            BackGroundColor=2;
            C(15);
            cout<<"1";
            BackGroundColor=15;
            C(0);
            cout<<" with number "<<K<<"\n";
            ++Card[i][K];
        }
        if(120000<=Pos&&Pos<270000)
        {
            C(i);
            cout<<name[i];
            C(0);
            cout<<" got a card : ";
            BackGroundColor=2;
            C(15);
            cout<<"2";
            BackGroundColor=15;
            C(0);
            cout<<" with number "<<K<<"\n";
            ++Card[i][K+10];
        }
        if(270000<=Pos&&Pos<390000)
        {
            C(i);
            cout<<name[i];
            C(0);
            cout<<" got a card : ";
            BackGroundColor=4;
            C(15);
            cout<<"1";
            BackGroundColor=15;
            C(0);
            cout<<" with number "<<K<<"\n";
            ++Card[i][K+20];
        }
        if(390000<=Pos&&Pos<540000)
        {
            C(i);
            cout<<name[i];
            C(0);
            cout<<" got a card : ";
            BackGroundColor=4;
            C(15);
            cout<<"2";
            BackGroundColor=15;
            C(0);
            cout<<" with number "<<K<<"\n";
            ++Card[i][K+30];
        }
        if(540000<=Pos&&Pos<660000)
        {
            C(i);
            cout<<name[i];
            C(0);
            cout<<" got a card : ";
            BackGroundColor=6;
            C(15);
            cout<<"1";
            BackGroundColor=15;
            C(0);
            cout<<" with number "<<K<<"\n";
            ++Card[i][K+40];
        }
        if(660000<=Pos&&Pos<810000)
        {
            C(i);
            cout<<name[i];
            C(0);
            cout<<" got a card : ";
            BackGroundColor=6;
            C(15);
            cout<<"2";
            BackGroundColor=15;
            C(0);
            cout<<" with number "<<K<<"\n";
            ++Card[i][K+50];
        }
        if(810000<=Pos&&Pos<840000)
        {
            C(i);
            cout<<name[i];
            C(0);
            cout<<" got a card : ";
            BackGroundColor=5;
            C(15);
            cout<<"1";
            BackGroundColor=15;
            C(0);
            cout<<"\n";
            ++Card[i][K+60];
        }
        if(840000<=Pos&&Pos<860000)
        {
            C(i);
            cout<<name[i];
            C(0);
            cout<<" got a card : ";
            BackGroundColor=5;
            C(15);
            cout<<"2";
            BackGroundColor=15;
            C(0);
            cout<<"\n";
        }
        if(860000<=Pos&&Pos<880000)
        {
            C(i);
            cout<<name[i];
            C(0);
            cout<<" got a card : ";
            BackGroundColor=5;
            C(15);
            cout<<"3";
            BackGroundColor=15;
            C(0);
            cout<<"\n";
        }
        if(880000<=Pos&&Pos<900000)
        {
            C(i);
            cout<<name[i];
            C(0);
            cout<<" got a card : ";
            BackGroundColor=5;
            C(15);
            cout<<"4";
            BackGroundColor=15;
            C(0);
            cout<<"\n";
        }
        if(900000<=Pos&&Pos<920000)
        {
            C(i);
            cout<<name[i];
            C(0);
            cout<<" got a card : ";
            BackGroundColor=5;
            C(15);
            cout<<"5";
            BackGroundColor=15;
            C(0);
            cout<<"\n";
        }
        if(920000<=Pos&&Pos<950000)
        {
            C(i);
            cout<<name[i];
            C(0);
            cout<<" got a card : ";
            BackGroundColor=3;
            C(15);
            cout<<"1";
            BackGroundColor=15;
            C(0);
            cout<<"\n";
        }
        if(950000<=Pos&&Pos<970000)
        {
            C(i);
            cout<<name[i];
            C(0);
            cout<<" got a card : ";
            BackGroundColor=3;
            C(15);
            cout<<"2";
            BackGroundColor=15;
            C(0);
            cout<<"\n";
        }
        if(970000<=Pos&&Pos<990000)
        {
            C(i);
            cout<<name[i];
            C(0);
            cout<<" got a card : ";
            BackGroundColor=3;
            C(15);
            cout<<"3";
            BackGroundColor=15;
            C(0);
            cout<<"\n";
        }
        if(990000<=Pos&&Pos<1000000)
        {
            C(i);
            cout<<name[i];
            C(0);
            cout<<" got a card : ";
            BackGroundColor=3;
            C(15);
            cout<<"4";
            BackGroundColor=15;
            C(0);
            cout<<"\n";
        }
        Sleep(1500);
    }
}
void use(int id)
{

}
void Game()
{
    system("cls");
    C(0);
    cout<<"Step 1.1 - Get names\n";
    cout<<"Players(at least 15):";
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        C(0);
        cout<<"name "<<i<<" : ";
        C(i);
        cin>>name[i];
    }
    system("cls");
    for(int Round=1,Starter=1;Round<=n*2;++Round,Starter=(Round-1)%n+1)
    {
        Randomcards();
    }
}
void Homepage()
{
    system("cls");
    ChangeBGC(15);
    C(2);
    cout<<"    Card Fighter\n\n";
    C(0);
    CHS[1]="3Game Start";
    CHS[2]="4Close";
    CHS[3]="6Card List";
    ch=in(3);
    if(ch=='A')
      Game();else
      if(ch=='B')
        exit(0);else
        CardList();
}
int main()
{
    srand(time(0));
    while(1)
    {
        Homepage();
    }
}