Scavenger

原创游戏 Scavenger

您是第个访问此页面的游客。

这是本页面的第次访问。


更新日志

2018/7/13

V1.0.1发布

  • 修复cure扣除金币错误bug。

  • 修复cure回复血量错误bug。

V1.0.2发布

  • 增加ticket特殊功能。

  • 增加两种新的生物。

  • 修改逃跑扣除生命值。

  • 小幅度增添了空房间出现的概率。

V1.1.0 发布

  • 增加一种新的房间。

  • 增加gem的新用途。

  • 增加一条新的游戏说明。

  • 更正一处语法错误。

V1.1.1 发布

  • 修改meat与apple恢复生命值量。

  • 修复战斗结束过快bug。

  • 调整数据平衡性。


常见问题

Q1:游戏自动运行,无论按什么都没用。
A1:可能是因为输入了不合法字符。解决方案:仔细阅读说明书。
Q2:出现了未知bug,初始生命值999。
A2:这不是bug,只是懒得删掉测试代码。:)
Q3:为毛我总是拿到gem?
A3:请删除“#define TEST 1”或类似语句。
Q4:其他问题。
A4:请联系本人或在下方留言。

源码

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<ctime>
#include<windows.h>
#include<map>
using namespace std;

const int maxn=105;

inline void slow(string line,int t=30){
    for(int i=0;i<line.length();i++){
        putchar(line[i]);
        Sleep(t);
    }
}

inline bool in(int le,string l[],string item){
    for(int i=0;i<le;i++){
        if(l[i]==item){
            return true;
        }
    }
    return false;
}

struct player{
    string name;
    int hp;
    int max_hp;
    double gold;
    int bagsize;
    string bag[maxn];
};

int room=0;
const int blank=0;
const int monster=1;
const int disc=2;
const int market=3;
const int magic=4;
const int rooms[25]={blank,blank,blank,blank,blank,blank,blank,
    monster,monster,monster,monster,monster,
    disc,disc,disc,disc,
    market,market,market,market,market,market,market,
    magic,magic};
const int rubbish=0;
const int stone=1;
const int meat=2;
const int gold=3;
const int gem=4;
const int knife=5;
const int ticket=6;
const int apple=7;
const int stick=8;
bool gem_used=false;
const int discovery[38]={rubbish,rubbish,rubbish,rubbish,rubbish,rubbish,
    stone,stone,stone,stone,stone,stone,stone,
    meat,meat,meat,meat,meat,meat,meat,
    apple,apple,apple,apple,apple,
    stick,stick,stick,
    gold,gold,
    gem,
    knife,
    ticket};
const string turn[9]={"rubbish","stone","meat","gold","gem","knife","ticket","apple","stick"};
const int wild_dog=0;
const int fly=1;
const int theif=2;
const int zyd=3;
const int gorilla=4;
const int goblin=5;
const int monsters[24]={wild_dog,wild_dog,wild_dog,wild_dog,wild_dog,wild_dog,
    fly,fly,fly,fly,fly,fly,
    theif,theif,theif,theif,
    gorilla,gorilla,
    goblin,goblin,goblin,goblin,
    zyd,zyd};
const string turnm[6]={"Wild dog","Fly","Theif","ZYD","Gorilla","Goblin"};

player you;
void start();
void refresh();
void lobby();
void check();
void start(){
    system("cls");
    #ifndef TEST
    slow("[Guide]: Welcome, traveller!\n");
    slow("[Guide]: Oh, you look familliar! Have we met before?\n");
    slow("[You]: ");
    int r;
    cin>>r;
    if(r==0){
        slow("[Guide]: How may I call you?\n");
        slow("[You]: ");
        string n;
        cin>>n;
        you.name=n;
        you.hp=you.max_hp=40;
        you.gold=5;
        you.bagsize=0;
        slow("[Guide]: Very well!\n");
        slow("[Guide]: ");
        slow(you.name);
        slow(", here are 5 gold coins, I hope they will come in handy!\n");
        slow("[Guide]: Good luck!");
    }else if(r==123456){
        slow("[Guide]: Ah I remember now, you must be ");
        you.name="The GM";
        you.gold=999;
        you.hp=you.max_hp=999;
        you.bagsize=0;
        slow("The GM!");
        slow("!\n");
        slow("[Guide]: Anyway, you should be going...\n");
    }
    #endif
    #ifdef TEST
    you.name="The GM";
    you.gold=999;
    you.hp=you.max_hp=999;
    you.bagsize=0;
    #endif
    system("mode con cols=31 lines=20");
    system("color 0F");
    lobby();
}
int idontknowwhatthisfor;
void lobby(){
    srand((unsigned)time(NULL));
    refresh();
    slow("            Room  ");
    cout<<room<<endl;
    int room_type=rooms[rand()%25+1];
    if(room_type==blank){
        slow("    There is nothing here!\n");
        slow(" Do you wish to use anything?\n");
        string ws;
        cin>>ws;
        if(ws=="-1"){
            idontknowwhatthisfor=0;
        }else if(!in(you.bagsize,you.bag,ws)){
            slow("     You don't have this!\n");
        }else if(ws=="knife"||ws=="stick"){
            slow("     You can't use this!\n");
        }else{
            if(ws=="meat"){
                slow("       You felt better!\n");
                you.hp+=3;
                for(int i=0;i<you.bagsize;i++){
                    if(you.bag[i]==ws){
                        you.bagsize--;
                        for(int j=i;j<you.bagsize;j++){
                            you.bag[j]=you.bag[j+1];
                        }
                        break;
                    }
                }
            }else if(ws=="apple"){
                slow("            Tasty!\n");
                you.hp+=4;
                for(int i=0;i<you.bagsize;i++){
                    if(you.bag[i]==ws){
                        you.bagsize--;
                        for(int j=i;j<you.bagsize;j++){
                            you.bag[j]=you.bag[j+1];
                        }
                        break;
                    }
                }
            }else if(ws=="gem"){
                slow("          It melted!\n");
                slow(" Perhaps something happened...\n");
                gem_used=true;
                for(int i=0;i<you.bagsize;i++){
                    if(you.bag[i]==ws){
                        you.bagsize--;
                        for(int j=i;j<you.bagsize;j++){
                            you.bag[j]=you.bag[j+1];
                        }
                        break;
                    }
                }
            }else if(ws=="ticket"){
                slow("      Nothing happened!\n");
                slow("Well, assume nothing happened.\n");
                you.gold+=20;
                you.max_hp+=10;
                for(int i=0;i<you.bagsize;i++){
                    if(you.bag[i]==ws){
                        you.bagsize--;
                        for(int j=i;j<you.bagsize;j++){
                            you.bag[j]=you.bag[j+1];
                        }
                        break;
                    }
                }
            }
        }
    }else if(room_type==disc){
        slow(" You have discovered something!\n");
        int dis=discovery[rand()%38+1];
        #ifdef TEST
        dis=gem;
        #endif
        slow("       It's a ");
        slow(turn[dis]);
        cout<<'!'<<endl;
        if(dis==rubbish){
            slow("       How irritating!\n");
            slow("   You sold it for 0.1 gold!\n");
            you.gold+=0.1;
        }else if(dis==stone){
            slow("          Useless!\n");
            slow("  You sold it for 0.2 gold!\n");
            you.gold+=0.2;
        }else if(dis==meat){
            slow("    Emm, we can use this.\n");
            slow("     Keep it or sell it?\n");
            int choice;
            cin>>choice;
            if(choice==0){
                slow("   You sold it for 0.3 gold!\n");
                you.gold+=0.3;
            }else{
                you.bag[you.bagsize++]=turn[dis];
            }
        }else if(dis==apple){
            slow("         Looks good!\n");
            slow("     Keep it or sell it?\n");
            int choice;
            cin>>choice;
            if(choice==0){
                slow("   You sold it for 0.3 gold!\n");
                you.gold+=0.3;
            }else{
                you.bag[you.bagsize++]=turn[dis];
            }
        }else if(dis==gold){
            slow("     This is a fortune!\n");
            slow("       You got 5 gold!\n");
            you.gold+=5;
        }else if(dis==gem){
            slow("      Blistering hell!\n");
            slow("       Damn your luck!\n");
            slow("     Keep it or sell it?\n");
            int choice;
            cin>>choice;
            if(choice==0){
                slow("   You sold it for 7 gold!\n");
                you.gold+=7;
            }else{
                you.bag[you.bagsize++]=turn[dis];
            }
        }else if(dis==knife){
            slow("    Wicked! That's sharp!\n");
            slow("     Keep it or sell it?\n");
            int choice;
            cin>>choice;
            if(choice==0){
                slow("   You sold it for 10 gold!\n");
                you.gold+=10;
            }else{
                you.bag[you.bagsize++]=turn[dis];
            }
        }else if(dis==stick){
            slow("   At least it's not shit...\n");
            slow("     Keep it or sell it?\n");
            int choice;
            cin>>choice;
            if(choice==0){
                slow("   You sold it for 2 gold!\n");
                you.gold+=2;
            }else{
                you.bag[you.bagsize++]=turn[dis];
            }
        }else if(dis==ticket){
            slow("  I wonder what's this for?\n");
            slow("     Keep it or sell it?\n");
            int choice;
            cin>>choice;
            if(choice==0){
                slow("   You sold it for 0.2 gold!\n");
                you.gold+=0.2;
            }else{
                you.bag[you.bagsize++]=turn[dis];
            }
        }
    }else if(room_type==monster){;
        slow("    You have encontered...\n");
        int dis=monsters[rand()%24+1];
        slow("         a ");
        slow(turnm[dis]);
        cout<<'!'<<endl;
        slow("       Fight it or run?\n");
        int ch;
        cin>>ch;
        if(ch==0){
            slow("         You escaped!\n");
            int amt=rand()%10+3;
            slow("     But still losed ");
            cout<<amt;
            slow(" hp!\n");
            you.hp-=amt;
        }else{
            if(dis==wild_dog){
                slow("    You beat the wild dog!\n");
                slow("       It clawed back!\n");
                int amt=rand()%4+3;
                slow("       You losed ");
                cout<<amt;
                slow(" hp!\n");
                you.hp-=amt;
                slow("        It ran away!\n");
                if(rand()%2||in(you.bagsize,you.bag,"knife")||in(you.bagsize,you.bag,"stick")){
                    slow("       You got meat!\n");
                    you.bag[you.bagsize++]=turn[meat];
                }
            }else if(dis==fly){
                slow("      You beat the fly!\n");
                slow("       It stinged back!\n");
                int amt=rand()%2+1;
                slow("       You losed ");
                cout<<amt;
                slow(" hp!\n");
                you.hp-=amt;
                slow("         It flew away!\n");
            }else if(dis==theif){
                slow("      You beat the theif!\n");
                slow("        He fought back!\n");
                int amt=rand()%2+7;
                slow("       You losed ");
                cout<<amt;
                slow(" hp!\n");
                you.hp-=amt;
                if(!in(you.bagsize,you.bag,"knife")){
                    if(rand()%2){
                        if(you.gold<=0.7){
                            slow("    He stole all you gold!\n");
                        }else{
                            slow("      He stole 0.7 gold!\n");
                        }
                        you.gold-=0.7;
                    }   
                }
                you.gold+=0.1;
                slow("        He ran away!\n");
            }else if(dis==zyd){
                slow("      You beat stupid ZYD!\n");
                slow("       But it was useless!\n");
                if(!in(you.bagsize,you.bag,"knife")){
                    slow("         He kissed you!\n");
                    int amt=rand()%2+2;
                    slow("        You got ");
                    cout<<amt;
                    slow(" hp!\n");
                    you.hp+=amt;    
                }
                slow("         He dissapeared!\n");
            }else if(dis==gorilla){
                slow("       You beat the gorilla!\n");
                slow("   Well at least you tried to...\n");
                int amt=rand()%7+2;
                slow("        You losed ");
                cout<<amt;
                slow(" hp!\n");
                you.hp-=amt;
                slow("          It jumped away!\n");
            }else if(dis==goblin){
                slow("       You beat the goblin!\n");
                int amt=rand()%3+1;
                slow("       You losed ");
                cout<<amt;
                slow(" hp!\n");
                you.hp-=amt;
                if(in(you.bagsize,you.bag,"knife")){
                    int mmt=rand()%1+1;
                    slow("       You got ");
                    cout<<mmt;
                    slow(" gold!\n");
                    you.gold+=mmt;  
                }
                slow("      It dug a hole and fled!\n");
            }
        }
    }else if(room_type==market){
        slow(" You've arrived at the market!\n");
        slow("      Want to sell or buy?\n");
        int wt;
        cin>>wt;
        if(wt==-1){
            idontknowwhatthisfor=0;
        }else if(wt==0){
            slow("    What do you want to sell?\n");
            string se;
            cin>>se;
            if(!in(you.bagsize,you.bag,"knife")){
                slow("      You don't have this!\n");
            }else{
                slow("         You sold ");
                slow(se);
                slow("!\n");
                if(se=="meat"){
                    slow("       You got 0.5 gold!\n");
                    you.gold+=0.5;
                    for(int i=0;i<you.bagsize;i++){
                        if(you.bag[i]==se){
                            you.bagsize--;
                            for(int j=i;j<you.bagsize;j++){
                                you.bag[j]=you.bag[j+1];
                            }
                            break;
                        }
                    }
                }else if(se=="apple"){
                    slow("       You got 0.6 gold!\n");
                    you.gold+=0.6;
                    for(int i=0;i<you.bagsize;i++){
                        if(you.bag[i]==se){
                            you.bagsize--;
                            for(int j=i;j<you.bagsize;j++){
                                you.bag[j]=you.bag[j+1];
                            }
                            break;
                        }
                    }
                }else if(se=="gem"){
                    slow("       You got 9 gold!\n");
                    you.gold+=9;
                    for(int i=0;i<you.bagsize;i++){
                        if(you.bag[i]==se){
                            you.bagsize--;
                            for(int j=i;j<you.bagsize;j++){
                                you.bag[j]=you.bag[j+1];
                            }
                            break;
                        }
                    }
                }else if(se=="stick"){
                    slow("       You got 4 gold!\n");
                    you.gold+=4;
                    for(int i=0;i<you.bagsize;i++){
                        if(you.bag[i]==se){
                            you.bagsize--;
                            for(int j=i;j<you.bagsize;j++){
                                you.bag[j]=you.bag[j+1];
                            }
                            break;
                        }
                    }
                }else if(se=="knife"){
                    slow("       You got 10.5 gold!\n");
                    you.gold+=10.5;
                    for(int i=0;i<you.bagsize;i++){
                        if(you.bag[i]==se){
                            you.bagsize--;
                            for(int j=i;j<you.bagsize;j++){
                                you.bag[j]=you.bag[j+1];
                            }
                            break;
                        }
                    }
                }else if(se=="ticket"){
                    slow("       You got 0.4 gold!\n");
                    you.gold+=0.4;
                    for(int i=0;i<you.bagsize;i++){
                        if(you.bag[i]==se){
                            you.bagsize--;
                            for(int j=i;j<you.bagsize;j++){
                                you.bag[j]=you.bag[j+1];
                            }
                            break;
                        }
                    }
                }
            }
        }else if(wt==1){
            slow("          knife   25\n");
            slow("          meat     2\n");
            slow("          ticket 100\n");
            slow("          cure    10\n");
            slow("          leave    0\n");
            slow("      Which one will you buy?\n");
            string bu;
            cin>>bu;
            if(bu=="knife"){
                if(you.gold>=25){
                    slow("            Bought!\n");
                    you.gold-=25;
                    you.bag[you.bagsize++]=turn[knife];
                }else{
                    slow("     You don't have the money!");
                }
            }else if(bu=="meat"){
                if(you.gold>=2){
                    slow("            Bought!\n");
                    you.gold-=2;
                    you.bag[you.bagsize++]=turn[meat];
                }else{
                    slow("     You don't have the money!");
                }
            }else if(bu=="ticket"){
                if(you.gold>=100){
                    slow("            Bought!\n");
                    you.gold-=100;
                    you.bag[you.bagsize++]=turn[ticket];
                }else{
                    slow("     You don't have the money!");
                }
            }else if(bu=="cure"){
                if(you.gold>=10){
                    slow("             Cured!\n");
                    you.gold-=10;
                    you.hp=you.max_hp;
                }else{
                    slow("     You don't have the money!");
                }
            }else if(bu=="leave"){
                slow("             Sure!\n");
            }
        }
    }else if(room_type==magic){
        slow(" You've arrived at the Magix!\n");
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
        slow("      Current Gems: ");
        int cg=0;
        for(int i=0;i<you.bagsize;i++){
            if(you.bag[i]=="gem")cg++;
        }
        cout<<cg<<endl;
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
        slow("    Choose a kind of buff:\n");
        slow("        Life*2    3\n");
        slow("        Gold*1.5  3\n");
        int kb;
        cin>>kb;
        if(kb==1){
            if(cg<3){
                slow(" You don't have enough gems!\n");
            }else{
                slow("         Buff got!\n");
                you.hp*=2;
            }
        }else if(kb==2){
            if(cg<3){
                slow(" You don't have enough gems!\n");
            }else{
                slow("         Buff got!\n");
                you.gold*=1.5;
            }
        }
    }
    check();
    getchar();
    lobby();
}

void refresh(){
    system("cls");
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE);
    room++;
    cout<<"          SCAVENGER\n";
    cout<<"           V1.1.1\n";
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN);
    cout<<"______________________________\n";
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE|FOREGROUND_GREEN);
    cout<<you.name<<endl;
    cout<<"Gold: "<<you.gold<<endl;
    cout<<"Health: "<<you.hp<<endl;
    cout<<"Bag: ";
    if(you.bagsize==0){
        cout<<"Empty";
    }else for(int i=0;i<you.bagsize;i++){
        cout<<you.bag[i];
        if(i==you.bagsize-1||i%3!=2)cout<<' ';
        else cout<<endl;
    }
    cout<<endl;
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN);
    cout<<"______________________________\n";
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
}

void check(){
    if(you.hp<=0){
        while(1){
            system("cls");
            cout<<"YOU DIED!";
        }
    }
}

int main(){
    system("title Scavenger V1.1.1 By AaronLee");
    cout<<"All that you need to know about choices: \n";
    cout<<"    1. In battle, 0 for run and 1 for fight.\n";
    cout<<"    2. In discover, 0 for sell and 1 for keep.\n";
    cout<<"    3. In market, 0 for buy and 1 for sell.\n";
    cout<<"    4. When the guide ask questions, type 0.\n";
    cout<<"    5. If you don't want to choose anything, type -1\n";
    cout<<"    6. Sometimes the grammer is bad, pls ignore it:)\n";
    cout<<"    7. When you choose buffs, enter numbers starting from 1.\n";
    system("color F0");
    getchar();
    start();
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值