c++海盗战争1.0正式版【免费复制】

这是一个使用C++编写的海盗战争游戏,包含角色属性、战斗、商店、黑市等元素。玩家可以管理资源、升级属性,并进行战斗。游戏中涉及物品合成、装备选择、战利品获取等策略决策。
摘要由CSDN通过智能技术生成

代码亮出来:

#include<bits/stdc++.h>
#include<string>
#include<windows.h>
#include<conio.h>
#include<fstream>
#include<ctime>
#include<time.h>
#include<stdio.h>
using namespace std;
ifstream fin("小岛战争data.txt");
struct black_daye {
    string name;
    int gongji;
    int fangyu;
    int xiel;
};
black_daye peopledata_dy[4] = { "看门大爷",150,100,800 };
int sbbspeople = 10;
int a, ag;
int name, password;
int sinput;
int newhand = 0;
string root;
int rootdh;
string kuangwu[1000] = { "金刚石","铁","铜","金","银","煤炭"
,"铀","铁","按钮","钢","钛" };
string ezj[3] = { "地下水","地雷","臭袜子" };
int data[1000];
/*0武器等级 1合成劵 2金刚石 3铁 4铜 5金 6银 7煤炭
8木屋 9军事基地 10港口 11防空洞 12士兵宿舍
13独木舟 14小艇 15战舰 16潜艇 17航空母舰 18核潜艇
19血量 20攻击 21领地 22防御 23矿工铲 24士兵人数
25电锯 26密码 27账号 28木头 29独木舟 30小艇 31战舰
32潜艇 33航空母舰 34核潜艇 35铀块 36铁块 37按钮
38弓箭 39火炮 40护甲 41粽子 42钛合金 43钢合金 44核弹
45钢 46钛 47油漆 48核弹发射器 49不锈钢 50导弹 51钱
52石油
*/
string make[1000] = { "矿工铲","电锯","弓箭","火炮","护甲","粽子",
"钛合金","钢合金","核弹","核弹发射器","不锈钢","导弹"," "
};
int suiji = 0;
int jsq = 0;
bool yj = false;
void mout(char* p) {//每隔100毫秒输出一个字符
    while (1) {
        if (*p != 0)
            printf("%c", *p++);
        else
            break;
        Sleep(100);
    }
}
void outmake() {
    cout << "木头:" << data[28] << endl;
    cout << "金刚石:" << data[2] << endl;
    cout << "铁:" << data[3] << endl;
    cout << "铜:" << data[4] << endl;
    cout << "金:" << data[5] << endl;
    cout << "银:" << data[6] << endl;
    cout << "煤炭:" << data[7] << endl;
    cout << "铀块:" << data[35] << endl;
    cout << "钢:" << data[45] << endl;
    cout << "钛:" << data[46] << endl;
    cout << "按钮:" << data[37] << endl;
    cout << "油漆:" << data[47] << endl;
    cout << "合成物品:" << endl;
    return;
}
void outzb() {
    cout << "电锯:" << data[25] << endl;
    cout << "弓箭:" << data[38] << endl;
    cout << "火炮:" << data[39] << endl;
    cout << "护甲:" << data[40] << endl;
    cout << "粽子:" << data[41] << endl;
    cout << "钛合金:" << data[42] << endl;
    cout << "钢合金:" << data[43] << endl;
    cout << "核弹:" << data[44] << endl;
    cout << "核弹发射器:" << data[48] << endl;
    cout << "不锈钢:" << data[49] << endl;
    cout << "导弹:" << data[50] << endl;
    return;
}
void outjz() {
    cout << "木屋:" << data[8] << endl;
    cout << "军事基地:" << data[9] << endl;
    cout << "港口:" << data[10] << endl;
    cout << "防空洞:" << data[11] << endl;
    cout << "士兵宿舍:" << data[12] << endl;
    return;

}
void outcz() {
    cout << "1独木舟:" << data[13] << endl;
    cout << "2小艇:" << data[14] << endl;
    cout << "3战舰:" << data[15] << endl;
    cout << "4潜艇:" << data[16] << endl;
    cout << "5航空母舰:" << data[17] << endl;
    cout << "6核潜艇:" << data[18] << endl;
    return;
}
void zd() {
    int nm = 0;
    int oxl;
    int dxl = rand() % 5000 + 1000;
    string zdzb[3];
    int zbzbi[3];
    int mesh = 0, mefy = 0;
    int pbsgj = rand() % 500 + 100;
    int pbssbrs = rand() % 50 + 10;
    int pbsfy = rand() % 250 + 50;
part7:
    system("cls");
    cout << "请选择你的出战装备(每种各选一个,可不选):" << endl;
    cout << "防御:" << endl;
    cout << "0不选 1护甲" << endl;
    cout << "出战工具:" << endl;
    cout << "0不选 1航母 2独木舟 3小艇 4战舰 5潜艇 6核潜艇" << endl;
    cin >> zbzbi[1] >> zbzbi[2];
    if (zbzbi[1] == 0) {
        zdzb[1] = "无";
    }
    else {
        if (data[40] < 1) {
            cout << "你没有护甲" << endl;
            Sleep(1000);
            goto part7;
        }
        zdzb[1] = "护甲";
        mefy += 150;
    }
    switch (zbzbi[2]) {
    case 0: {
        zdzb[2] = "无";
        break;
    }
    case 1: {
        if (data[17] < 1) {
            cout << "你没有航母" << endl;
            Sleep(1000);
            goto part7;
        }
        zdzb[2] = "航母";
        mesh += 200;
        break;
    }
    case 2: {
        if (data[13] < 1) {
            cout << "你没有独木舟" << endl;
            Sleep(1000);
            goto part7;
        }
        zdzb[2] = "独木舟";
        mesh += 10;
        break;
    }
    case 3: {
        if (data[14] < 1) {
            cout << "你没有小艇" << endl;
            Sleep(1000);
            goto part7;
        }
        zdzb[2] = "小艇";
        mesh += 25;
        break;
    }
    case 4: {
        if (data[15] < 1) {
            cout << "你没有战舰" << endl;
            Sleep(1000);
            goto part7;
        }
        zdzb[2] = "战舰";
        mesh += 150;
        break;
    }
    case 5: {
        if (data[16] < 1) {
            cout << "你没有潜艇" << endl;
            Sleep(1000);
            goto part7;
        }
        zdzb[2] = "潜艇";
        mesh += 140;
        break;
    }
    case 6: {
        if (data[17] < 1) {
            cout << "你没有核潜艇" << endl;
            Sleep(1000);
            goto part7;
        }
        zdzb[2] = "核潜艇";
        mesh += 200;
        break;
    }
    }
    string djnname[5] = { "大砍刀","吸血","打王者荣耀","射箭","高射炮" };
    int djnjx[5] = { 80,100,0,70,150 };
    system("cls");
    while (data[19] > 0 && dxl > 0) {
        suiji = rand() % 4 + 0;
        cout << "我方装备:" << zdzb[0] << endl;
        cout << "我方防御:" << zdzb[1] << endl;
        cout << "我方血量:" << data[19] << endl;
        cout << endl;
        cout << "敌方血量:" << dxl << endl;
        cout << "敌方技能:" << djnname[suiji] << endl;
        oxl = data[19];
        data[19] = data[19] - pbsgj + data[22] + data[24] / 10 * 2 - pbssbrs / 10 - djnjx[suiji] + mefy;
        oxl = oxl - data[19];
        cout << "你掉了" << oxl << "滴血" << endl;
    partyu1:
        cout << "你是否要用粽子来回血,1yes,2no" << endl;
        cin >> sinput;
        if (sinput == 1) {
            if (data[41] < 1) {
                cout << "你没有粽子" << endl;
                Sleep(1000);
                goto partyu1;
            }
        part12:
            cout << "请输入数量:" << endl;
            cin >> sinput;
            if (data[41] < sinput) {
                cout << "不够" << endl;
                goto part12;
            }
            cout << "补血成功" << endl;
            data[19] += data[41] * sinput * 75;
            Sleep(1000);
        }
    partyui1:
        Sleep(500);
        cout << "你用什么武器?" << endl;
        cout << "0不选 1弓箭 2火炮 3核弹 4导弹" << endl;
        cin >> zbzbi[0];
        switch (zbzbi[0]) {
        case 0: {
            zdzb[0] = " ";
            break;
        }
        case 1: {
            if (data[38] < 1) {
                cout << "你没有弓箭" << endl;
                Sleep(1000);
                goto part7;
            }
            zdzb[0] = "弓箭";
            mesh = 70;
            break;
        }
        case 2: {
            if (data[39] < 1) {
                cout << "你没有火炮" << endl;
                Sleep(1000);
                goto part7;
            }
            zdzb[0] = "火炮";
            mesh = 100;
            break;
        }
        case 3: {
            if (data[44] < 1) {
                cout << "你没有核弹" << endl;
                Sleep(1000);
                goto part7;
            }
            zdzb[0] = "核弹";
            mesh = 500;
            break;
        }
        case 4: {
            if (data[50] < 1) {
                cout << "你没有导弹" << endl;
                Sleep(1000);
                goto part7;
            }
            zdzb[0] = "导弹";
            mesh = 250;
            break;
        }
        }
        dxl = dxl - data[20] - data[24] / 10 + pbsfy + pbssbrs / 10 * 2 - mesh;
        cout << "对方掉了" << dxl << "滴血" << endl;
        Sleep(500);
        pbssbrs -= data[20] * 0.2;
        data[24] -= pbsgj * 0.2;
    }
    if (dxl < 0) {
        cout << "你把对方干掉了" << endl;
        cout << "战利品:" << endl;
        suiji = rand() % 100 + 1;
        switch (suiji) {
        case 1: {
            cout << "获得豪华大礼包一个!!" << endl;
            cout << "油漆*10" << endl;
            cout << "金刚石*5" << endl;
            cout << "钛*6" << endl;
            cout << "铁*10" << endl;
            cout << "领地*1" << endl;
            cout << "士兵*100" << endl;
            cout << "粽子*1" << endl;
            cout << "弓箭*8" << endl;
            data[47] += 10;
            data[2] += 5;
            data[3] += 10;
            data[46] += 6;
            data[21] += 1;
            data[24] += 100;
            data[41] += 1;
            data[38] += 8;
            Sleep(5000);
            return;
            break;
        }
        case 25: {
            cout << "获得领地1块" << endl;
            cout << "获得士兵" << pbssbrs / 100 * 2 << endl;
            data[21] += 1;
            data[24] += pbssbrs / 100 * 2;
            Sleep(5000);
            return;
            break;
        }
        }
        if (suiji == 2) {
            cout << "敌人太穷了,什么也没有" << endl;
            Sleep(1000);
            return;
        }
        else if (suiji > 2 && suiji < 25) {
            cout << "获得航空母舰1艘,军事基地一个" << endl;
            data[17] += 1;
            data[9] += 1;
            Sleep(1000);
            return;
        }
        else if (suiji > 25 && suiji <= 98) {
            cout << "你获得士兵100" << endl;
            data[24] += 100;
            Sleep(1000);
            return;
        }
    }
    else {
        cout << "你被打死了" << endl;
        cout << "士兵-100" << endl;
        data[24] -= 100;
        Sleep(5000);
        return;
    }
}
void outdata() {
    ofstream fout("小岛战争data.txt");
    for (int i = 0; i < 52; i++)
        fout << data[i] << " ";
    cout << "OK" << endl;
    Sleep(1000);
    return;
}
void start() {
    system("cls");
    mout("欢迎来到小岛战争1.0.0正式版\n");
    MessageBox(NULL, TEXT("请不要输入除了选项之外的数字,后果自负"), TEXT("游戏提示"), MB_OK);
    mout("作者:jsh\n");
    mout("—_ —\n");
    mout("输入一个数开始游戏\n");
    cin >> sinput;
    return;
}
void dl() {
    int bnm;
pt1:
    system("cls");
    cout << "1登录,2注册" << endl;
    cin >> bnm;
    if (bnm == 1) {
        newhand = 1;
        cout << "账号:";
        cin >> name;
        cout << "密码:";
        cin >> password;
        if (data[26] != password || data[27] != name) {
            cout << "错误!" << endl;
            Sleep(2000);
            goto pt1;
        }
        else
            return;
    }
    else {
        cout << "账号:";
        cin >> name;
        cout << "密码:";
        cin >> password;
        data[26] = password;
        data[27] = name;
        return;
    }
    return;
}
void cave_tie() {
    cout << "你来到铁矿..." << endl;
part1:
    system("cls");
    mout("正在挖矿...\n");
    Sleep(1000);
    suiji = rand() % 2 + 1;
    if (suiji == 2) {
        suiji = rand() % 2 + 0;
        cout << "你挖到了" << ezj[suiji] << endl;
        Sleep(2000);
        cout << "是否继续挖矿,1继续,2退出" << endl;
        cin >> a;
        if (a == 1)
            goto part1;
        else
            return;
    }
    cout << "你挖到了" << kuangwu[1] << endl;
    ag = rand() % 15 + 1;
    data[3] += ag;
    cout << "是否继续挖矿,1继续,2退出" << endl;
    cin >> a;
    if (a == 1);
    else
        return;
    Sleep(2000);
    goto part1;
}
void cave_mei() {
    cout << "你来到煤矿..." << endl;
part2:
    system("cls");
    mout("正在挖矿...\n");
    Sleep(1000);
    suiji = rand() % 2 + 1;
    if (suiji == 2) {
  

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

{∞}

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值