后宫选妃游戏

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <windows.h>
#include <mmsystem.h>

#pragma comment(lib, "Winmm.lib")
#define DAY_COUNT 10
int main()
{
	int i;          
	int count = 5;  
	int currDay = 0;
	int choice;     
	int tempCount; 
	int index = -1; 
	char name[8];   
	
	char names[6][8] = { "西施", "貂蝉", "王昭君", "杨玉环", "赵飞燕" };
	
	char levelNames[5][8] = { "贵人", "嫔妃", "贵妃", "皇贵妃", "皇后" };
	
	int level[] = { 0, 2, 0, 0, 0, -1 };
	
	int loves[] = { 100, 100, 100, 100, 100, -1 };
	do{
		PlaySound(TEXT("sounds\\背景音乐.wav"), NULL, SND_FILENAME | SND_ASYNC | SND_LOOP);
		printf("第%d天:\n", ++currDay);
		printf("1、皇帝下旨选妃!\t(增加)\n");
		Sleep(500);
		printf("2、翻牌宠幸\t\t(修改状态)\n");
		Sleep(500);
		printf("3、打入冷宫!\t\t(删除)\n");
		Sleep(500);
		printf("4、朕的爱妃呢?\t\t(查找)\n");
		printf("陛下请选择:");
		scanf("%d", &choice);
		switch (choice){
		case 1:
			PlaySound(TEXT("sounds\\选妃.wav"), NULL, SND_FILENAME | SND_ASYNC | SND_LOOP);
			
			if (count >= sizeof(level) / sizeof(int))
			{
				printf("\n后宫人满为患,陛下还是再等等吧!\n\n");
				break;
			}
			printf("爱江山更爱美人,万千佳丽一点红~\n");
			printf("娘娘名讳:");
			scanf("%s", name);
			
			strcpy(names[count], name);
			level[count] = 0;
			loves[count] = 100;
			printf("\n新增妃子,其他人好感度-10\n\n");
			for (i = 0; i < count; i++){
				loves[i] -= 10;
			}
			count++;
			break;
		case 2:
			PlaySound(TEXT("sounds\\翻牌.wav"), NULL, SND_FILENAME | SND_ASYNC | SND_LOOP);
			printf("陛下请输入要宠幸的姓名:");
			scanf("%s", &name);
			for (i = 0; i < count; i++){
				if (strcmp(name, names[i]) == 0){
					index = i;
					continue;
				}
				loves[i] -= 10;
			}
			if (index == -1)
			{
				printf("\n祖国尚未统一,怎能儿女情长!\n\n");
			}
			else
			{
				loves[index] += 20;
				
				level[index] == 4 ? 4 : level[index]++;
				printf("\n******************************\n");
				printf("Duang~%s提升等级为:%s\n", names[index], levelNames[level[index]]);
				printf("******************************\n\n");
				printf("憔悴容华怯对春,寂寥宫殿锁闭门。\n此身却羡宫中树,不失芳时雨露恩。 \n");
				printf("所有娘娘好感度-10!\n\n");
			}
			index = -1;
			break;
		case 3:
			PlaySound(TEXT("sounds\\冷宫.wav"), NULL, SND_FILENAME | SND_ASYNC | SND_LOOP);
			printf("陛下要将哪位娘娘打入冷宫呢:");
			scanf("%s", &name);
			for (i = 0; i < count; i++){
				if (strcmp(name, names[i]) == 0){
					index = i;
					break;
				}
			}
			if (index == -1)
			{
				printf("\n虚惊一场,无人打入冷宫,该吃吃该喝喝~\n\n");
				break;
			}
			
			for (i = index; i < count - 1; i++)
			{
				strcpy(names[i], names[i + 1]);
				level[i] = level[i + 1];
				loves[i] = loves[i + 1];
			}
			count--;
			index = -1;
			printf("\n%s已被打入冷宫,人情冷暖,所有娘娘好感度+10!\n\n", name);
			for (i = 0; i < count; i++){
				loves[i] += 10;
			}
			index = -1;
			break;
		case 4://
			PlaySound(TEXT("sounds\\一笑倾城.wav"), NULL, SND_FILENAME | SND_ASYNC | SND_LOOP);
			printf("请输入要查找的姓名:");
			scanf("%s", name);
			for (i = 0; i < count; i++){
				if (strcmp(name, names[i]) == 0){
					printf("\n微微一笑挺倾城,%s的好感度+10\n\n", name);
					loves[i] += 10;
					break;
				}
			}
			break;
		}
		printf("姓名\t等级\t好感度\n");
		printf("-----------------------\n");
		for (i = 0; i < count; i++){
			printf("%s\t%s\t%d\n", names[i], levelNames[level[i]], loves[i]);
		}
		
		tempCount = 0;
		for (i = 0; i < count; i++){
			if (loves[i] < 60)
				tempCount++;
		}
		if (tempCount >= 3){
			printf("觉醒的嫔妃:姐妹们,组队刷皇上去了!\n");
			
			time_t timep;
			struct tm * p;
			time(&timep);
			p = gmtime(&timep);
			printf("公元%d年%d月%d日,皇帝卒!共执政%d天\n", 1900 + p->tm_year, 1 + p->tm_mon, p->tm_mday, currDay);
			exit(0);
		}
	} while (currDay < DAY_COUNT);

	printf("皇帝登基10天来,五谷丰登、风调雨顺、妻妾成群。。。。。\n");
	printf("没羞没臊的生活继续进行着。。。。。。。\n");
	printf("姓名\t等级\t好感度\n");
	printf("-----------------------\n");
	for (i = 0; i < count; i++){
		printf("%s\t%s\t%d\n", names[i], levelNames[level[i]], loves[i]);

	}
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值