Example #1
0
std::pair<int, int> MOGA::selection()
{
	int i1, i2, a, b;

	a  = std::rand() % num_individuals_;
	b  = std::rand() % num_individuals_;
	i1 = battle( a, b );

	a  = std::rand() % num_individuals_;
	b  = std::rand() % num_individuals_;
	i2 = battle( a, b );

	return std::make_pair( i1, i2 );
}
Example #2
0
void story(Player &player)
{
	bool Retry;

	std::cout << "Welcome to the game. This is a text-based RPG, made by Meraj Ahmed." << std::endl;
	std::cout << "Press enter to continue..." << std::endl;
	getchar();
	cls();

	std::cout << "This tutorial will introduce you to the basics of the game. New features will be unlocked as you progress, and you will learn about them when they are unlocked." << std::endl;
	std::cout << "Press enter to continue..." << std::endl;
	getchar();
	cls();

	std::cout << "There are 3 main battle choices: Hit, Bash, and Heal." << std::endl;
	std::cout << "Hit is a normal attack." << std::endl;
	std::cout << "Bash does extra damage to the enemy, but damages you as well." << std::endl;
	std::cout << "Heal simply heals you for a small amount." << std::endl;
	std::cout << "Press enter to continue..." << std::endl;
	getchar();
	cls();
	
	savePlayer(player);
	do
	{
		TutorialTroll tutorialTroll;
		player = loadPlayer();
		Retry = battle(player, tutorialTroll);
	} while (Retry);
	Retry = false;



	return;
}
Example #3
0
ErrorCode RecruitController::Recruit(PlayerModelPtr player)
{
    if (player->_battle != nullptr)
    {
        return ErrorCode::AlreadyRecruited;
    }

    BattleModelPtr battle(new BattleModel);
    auto fighter = GetObjectHolder<FighterHolder>(ActorType::Fighter).Find(FighterId(1));

    for (auto it : player->_vehicles)
    {
        auto vehicle = it.second;

        auto maxCapacity = 0.0f;
        for (auto& cargo : vehicle->_cargos)
        {
            maxCapacity += cargo._capacity;
        }

        std::vector<FighterModelPtr> fighters;
        while (maxCapacity > 0)
        {
            fighters.push_back(fighter->Clone());
            maxCapacity -= fighter->_weight;
        }

        battle->_fighter_map.insert(std::make_pair(vehicle, fighters));
    }

    player->_battle = battle;
    return ErrorCode::Success;
}
Example #4
0
	// Moves a piece from a position to another and handles battle results eventually
	void Board::movePiece(const Position& from, const Position& to) {
		if(isCorrectMove(from, to)) {
			if(isCaseFree(to)) {
				this->putPiece(this->getPiece(from), to);
				this->removePiece(from);
			}
			else { // battle
				bool battleRes = battle(this->getPiece(from),this->getPiece(to));
				if(battleRes) {
					this->removePiece(to, true); // piece eliminated
					this->putPiece(this->getPiece(from), to);
					this->removePiece(from);
					this->discovered.push_back(this->getPiece(to)); // add the winning piece into discovered
				}
				else {
					this->removePiece(from, true); // piece eliminated
					if(this->getPiece(to)) { // if enemy piece won (not a draw)
						this->discovered.push_back(this->getPiece(to));
					}
				}
			}
			// Change turn
			if(this->getState() == BLUEPLAYS) {
				this->state = REDPLAYS;
			}
			else if(this->getState() == REDPLAYS) {
				this->state = BLUEPLAYS;
			}
		}
	}
void BattleCommunicator::filterBattleResult(int b, int r, int w, int l)
{
    if (!contains(b)) {
        return;
    }

    battle(b)->finished() = true;

    emit battleFinished(b,r,w,l);
}
Example #6
0
int main()
{
	int battle_number;

	hero = malloc(sizeof(struct player));
	if (hero == NULL)
	{
		printf("Everything is bad with hero\n");
		return 0;
	}

	init_hero( hero );
	
	necromancer = malloc(sizeof(struct creature));
	if (necromancer == NULL)
	{
		printf("Everything is bad with necromancer\n");
		return 0;
	}

	init_necromancer( necromancer );

	printf("Welcome, traveler. You are about to embark on your epic quest.\n\n");
	script_speaking("Villager", 2, "Oh, stranger! Good timing! You look like an experienced warrior!", "Please, help us! Evil necromancer terrorizes our village!"); 
	script_speaking("Villager", 2, "Many of us have already tried to slay him but they failed...", "Please, slay him for us!!!\n");
	
	for (battle_number = 0; battle_number < 5; battle_number++)
	{
		if ( battle(hero, enemy_encountered()) == 2)
			return 0;
	}

	script_speaking("Hero", 3, "Seems like there are no necromancer minions left.", "Ah, he finally decided to show himself!", "Hell, it's about time!");
	
	battle(hero, necromancer);
	
	return 0;
}
Example #7
0
int main(int argc, char *argv[]) {
	
	system("clear");

	printf("Welcome to the pokemon battle area!\n\n");

	srand(time(NULL));

	Pokemon *array = malloc(sizeof(struct _pokemon));

	*array = populate();
	battle (array[0], array[1]);

	return EXIT_SUCCESS;
}
Example #8
0
int main()
{
    srand(time(NULL));
    mapdisplay(map,player);
    mapdisplay(map,player);
    while(1)
    {
        clear_screen();
        printf("score=%d,hp=%d\n",score,player[hp]);
        mapdisplay(map,player);
        switch (getch())
        {
        case 'w':
        case 'W':
            if(player[Y]-1>=0)
                player[Y]--;
            break;

        case 's':
        case 'S':
            if(player[Y]<=MAPY/2-2)
                player[Y]++;
            break;

        case 'a':
        case 'A':
            if(player[X]-1>=0)
                player[X]--;
            break;

        case 'd':
        case 'D':
            if(player[X]<=MAPX-2)
                player[X]++;
            break;
        }
        if(rand() % 100 + 1<=12)
        {
            if(battle()==0)
            {
                gameover();
                return 0;
            }
        }
    }
    return 0;
}
Example #9
0
void PreUpdater::apply_update(Message *update) {
    switch (update->type) {
        case DoBattle: {
            auto upd = dynamic_cast<DoBattleMessage *>(update);
            int attacker_id = upd->data1;
            Point attacking_point = game->stacks.get(attacker_id)->position;
            Point attacked_point = upd->data2;
            std::vector<Move>& moves = upd->data3;
            Battle battle(game, attacked_point, attacking_point, moves);
            if (combat_screen)
                combat_screen->show_battle(&battle);
        } break;

        default:
            break;
    }
}
Example #10
0
int main(int argc, char *argv[]){
  if (argc > 2){
    s_player player1;
    s_monster monster1;
  
    init (&player1, &monster1);
    if ((my_strcmp(argv[1], "-n") == 0)){
      clearTerminal();
      my_putstr("\033[31;10m ###### BATTLE OF MIDGAR ##########\033[0m\n\n");
      my_strcpy(player1.name, argv[2]);
      aff_help();
      battle(&player1,&monster1);
    }
    else
      my_putstr("USAGE: -n <Add player name>\n");
    return (0);
  }
  else
    my_putstr("USAGE: -n <Add player name>\n");	
  return (0);
}
Example #11
0
Widget::Widget(QDialog *parent) :
	QDialog(parent),
	ui(new Ui::Widget)
{
	ui->setupUi(this);

	QGridLayout *layout = new QGridLayout();

	QLabel *playerText = new QLabel("Atacker");
	layout->addWidget(playerText, 0, 0);

	QGridLayout *playerLayout = new QGridLayout();
	playerHP = new QProgressBar();

	playerDamage = new QLabel("");
	playerLayout->addWidget(playerHP, 0, 0);
	playerLayout->addWidget(playerDamage, 0, 1);
	layout->addLayout(playerLayout, 0, 1);

	QLabel *botText = new QLabel("Defender");
	layout->addWidget(botText, 1, 0);

	QGridLayout *botLayout = new QGridLayout();
	botHP = new QProgressBar();

	botDamage = new QLabel("");
	botLayout->addWidget(botHP, 0, 0);
	botLayout->addWidget(botDamage, 0, 1);
	layout->addLayout(botLayout, 1, 1);


	this->setLayout(layout);

	timer = new QTimer;
	connect(timer, SIGNAL(timeout()), this, SLOT(battle()));
}
Example #12
0
void BattleLayer::waitingForOpened(float dt)
{
	if (m_targetCard != nullptr && m_targetCard->isOpened())
	{
		battle();
		for (auto& ele : *m_currentCardGroup)
		{
			m_battleBase->removeChild(ele);
		}
		m_currentCardGroup->clear();
		if (m_battleCardGroups->size() >= 3)
		{
			int column = -1;
			ReversibleCard* card = nullptr;
			while (column < 2 && m_currentCardGroup->size() < 3) 
			{
				//当前牌翻完以后,把扑在底下的第一排翻转回来之后拿上来
				card = m_battleCardGroups->front();
				card->verticalTilt(0.2f, CARD_TILT_ANGLE, MoveBy::create(0.2f, Point(0, 40)), MoveBy::create(0.2f, Point(0, m_openingHeight - card->getPositionY() - 40)));
				card->setLocalZOrder(card->getLocalZOrder() + 1);
				m_currentCardGroup->push_back(card);
				m_battleCardGroups->pop_front();
				++column;
			}
			for (auto& ele : *m_battleCardGroups)
			{
				//扑在底下的第二排第三排依次上移
				ele->setLocalZOrder(ele->getLocalZOrder() + 1);
				ele->runAction(MoveBy::create(0.2f, Point(0, c_intervalCardHeight)));
			}
		}
		//增加一排,放置牌堆最底下
		increaseCards4Groups(1);
		pileUpOneGroupCardsToTail();
	}
}
Example #13
0
int main(int argc, char* argv[])
{
    initscr();
    scrollok(stdscr, TRUE);
    wprintw(stdscr, "Welcome to Scripted ver. %d.%d for the Brave Quest engine.\nCopyright 2012 Mad Science Inc.\nPlease do not redistrubute.\n",scriptedvernum,scriptedvernum2);
    stufffilename();
    if(loadscript(filename) == 1)
    {
        wprintw(stdscr, "File not Found. Would you like to make a new file?\n");
        if(bie() == 'y')
        {
            cleanfilebuff();
            if(savescript(filename) == 1)
            {
                wprintw(stdscr, "Your disk sucks.\n");
                bi();
                return 1;
            }
        }
        else
        {
            wprintw(stdscr, "Goodbye.\n");
            endwin();
            return 1;
        }
    }
    currlinenum = linenum;
    menu();
    wprintw(stdscr, "Press escape to go to the save menu\n");
    for(;;)
    {
        wprintw(stdscr, "q= give, w= take, e= say, r= flag, t= move, y= battle, u= check flag, i= check item, o= party add, p= party remove, [ = check character\n");
        wprintw(stdscr, "a= warp, s= check experience, d= give experience, f= make experience, g= exec script, h= screen effect, j= user input, k= goline, l= make health\n");
        wprintw(stdscr, "b= check stat, n= make stat, m= blank, ,= show line, .= change line.\n");
        input[0] = bie();
        if(input[0] == 27)
            menu();
        if(input[0] == 'q')
            give();
        if(input[0] == 'w')
            take();
        if(input[0] == 'e')
            say();
        if(input[0] == 'r')
            flag();
        if(input[0] == 't')
            mmove();
        if(input[0] == 'y')
            battle();
        if(input[0] == 'u')
            checkflag();
        if(input[0] == 'i')
            checkitem();
        if(input[0] == 'o')
            partyadd();
        if(input[0] == 'p')
            partyrm();
        if(input[0] == '[')
            checkparty();
        if(input[0] == 'a')
            warp();
        if(input[0] == 's')
            checkexp();
        if(input[0] == 'd')
            giveexp();
        if(input[0] == 'f')
            makeexp();
        if(input[0] == 'g')
            execscript();
        if(input[0] == 'h')
            screeneffect();
        if(input[0] == 'j')
            userinput();
        if(input[0] == 'k')
            goline();
        if(input[0] == 'l')
            makehealth();
        if(input[0] == 'z')
            teachspell();
        if(input[0] == 'x')
            unlearnspell();
        if(input[0] == 'b')
            checkstat();
        if(input[0] == 'n')
            makestat();
        if(input[0] == 'm')
            blank();
        if(input[0] == ',')
            showline();
        if(input[0] == '.')
            changeline();
        if(currlinenum > linenum)
            linenum = currlinenum;
    }
    return 0;
};
Example #14
0
int main(void)
{
	struct Hero mage = {
		"",
		MAGE,
		450,
		0,
		50,
		200,
		30,
		10,
		1,
		1,
		0,
		0, 
		NULL,
		NULL
	};
	struct Hero warrior = {
		"",
		WARRIOR,
		550,
		60,
		0,
		0,
		5,
		25,
		1.3,
		1,
		0,
		0, 
		NULL,
		NULL
	};
	struct Hero thief = {
		"",
		THIEF,
		400,
		60,
		0,
		0,
		10,
		15,
		1,
		1.2,
		5,
		0, 
		NULL,
		NULL
	};
	struct Hero bot1 = {
		"Mage",
		ANY,
		500,
		0,
		45,
		0,
		15,
		15,
		1.4,
		1.5,
		10,
		0, 
		NULL,
		NULL
	};
	struct Hero bot2 = {
		"Guard",
		ANY,
		400,
		65,
		0,
		0,
		15,
		35,
		1.8,
		1,
		0,
		0, 
		NULL,
		NULL
	};
	struct Hero bot3 = {
		"Black knight",
		ANY,
		700,
		100,
		0,
		0,
		25,
		25,
		1,
		1.2,
		5,
		0, 
		NULL,
		NULL
	};
	struct Hero * hero;
	struct Hero * bot = &(bot3);
	COORD posHead;
	int a;
	int b;
	int p = 0;
	int status = 0;
	int true = 0;
	const char * Interface[3] = {
		"New game",
		"Load",
		"Records"
	};
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
	metka: a = move (hConsole, 3, Interface, 7, hero, &(mage), &(warrior), &(thief));
	switch (a){
		case 0 : createHero(&(hero), &(mage), &(warrior), &(thief)); true = 1; break;
		case 1 :
			system("cls");
			FILE * fp = NULL;
			printf("enter full name of file what you will open to load\n");
			char str[30];
			gets(str);
			fp = fopen(str, "r");
			if (NULL == fp)
				status = 1;
			if (status == 0)
			{
				fscanf(fp, "%i", &(b));
				switch (b)
				{
					case MAGE: hero = &(mage); break;
					case WARRIOR: hero = &(warrior); break;
					case THIEF: hero = &(thief); break;
				}
				int Weapon_type;
				int Armor_type;
				fscanf(fp, "%i %i %i", &(Weapon_type), &(Armor_type), &(hero->gold));
				switch (Armor_type)
				{
					case -1: status = 1; break;
					case 6: hero->Armor = &(steel_armor); break;
					case 7: hero->Armor = &(mage_robe); break;
					case 8: hero->Armor = &(lether_armor); break;
					case 9: hero->Armor = &(dragon_armor); break;
					case 10: hero->Armor = &(arcgmage_robe); break;
					case 11: hero->Armor = &(elven_armor); break;
				}
				if (status != 1){
					hero->health += hero->Armor->health;
					hero->damage += hero->Armor->damage;
					hero->mag_damage += hero->Armor->mag_damage;
					hero->mana += hero->Armor->mana;
					hero->magic_protect += hero->Armor->magic_protect;
					hero->armor += hero->Armor->armor;
					hero->critical_damage += hero->Armor->critical_damage - 1;
					hero->critical_chanse += hero->Armor->critical_chanse;
				}
				switch (Weapon_type)
				{
					case -1: status = -1; break;
					case 0: hero->Weapon = &(steel_sword); break;
					case 1: hero->Weapon = &(magic_stick); break;
					case 2: hero->Weapon = &(steel_dagger); break;
					case 3: hero->Weapon = &(great_sword); break;
					case 4: hero->Weapon = &(wood_scepter); break;
					case 5: hero->Weapon = &(thief_dagger); break;
				}
				if (status != -1){
					hero->health += hero->Weapon->health;
					hero->damage += hero->Weapon->damage;
					hero->mag_damage += hero->Weapon->mag_damage;
					hero->mana += hero->Weapon->mana;
					hero->magic_protect += hero->Weapon->magic_protect;
					hero->armor += hero->Weapon->armor;
					hero->attack_speed = hero->Weapon->attack_speed;
					hero->critical_damage += hero->Weapon->critical_damage - 1;
					hero->critical_chanse += hero->Weapon->critical_chanse;
				}
				true = 1;
				
			}
			else 
				printf("error input");
			fclose(fp);	
			break;
		case 2 : printRec(); goto metka;break;
		
	}
	
	
	while (true)
	{
		shop(hero, &(mage), &(warrior), &(thief));
		true = battle(hero, &(bot1), &(bot2), &(bot3));
		if (true == 2)
			;
		else if (true)
			printf("WIN\n");
		else
			printf("LOSE\n");
		getchar();
	}
	system("cls");
	posHead.X = 34;
	posHead.Y = 10;
	SetConsoleCursorPosition(hConsole, posHead);
	SetConsoleTextAttribute(hConsole, FOREGROUND_RED);
	puts("GAME OVER");
	posHead.Y = 11;
	SetConsoleCursorPosition(hConsole, posHead);
	printf("your result is %i", hero->gold);
	posHead.Y++;
	SetConsoleCursorPosition(hConsole, posHead);
	printf("enter your nickname\n");
	char nick[20];
	posHead.Y++;
	SetConsoleCursorPosition(hConsole, posHead);
	gets(nick);
	if (nick[0] == '\0')
		strcpy(nick, "noName");
	int record[10];
	char temp[10][20];
	FILE * fp = NULL;
	fp = fopen("reclab4.txt", "r");
	if (NULL == fp)
		return 0;
	for (int i = 0; i < 10; i++){
		fscanf(fp, "%i %s", &record[i], temp[i]);
		//printf("%i. %8i  %s\n", i + 1, record, nick);
		if (record[i] > hero->gold)
			p = i;
	}
	fclose(fp);
	fp = fopen("reclab4.txt", "w");
	for (int i = 0; i < 10; i++){
		if (p == i - 1)
			fprintf(fp, "%i %s\n", hero->gold, nick);
		fprintf(fp, "%i %s\n", record[i], temp[i]);
	}
	SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_GREEN);
	getchar();
	fclose(fp);
	return EXIT_SUCCESS;
}
Example #15
0
//--------------主要程式碼(Main Code)--------------
//main函數架構
//版本:1.00(10)
//軟體的運行從main函數開始
//void會使debugger無法啟動!
int main()
	{
	//宣告與定義(Declaration & Definition)
	//---------------------

restart:
    //intial player data
        initialPlayer(&player);
    ////intial player data
    //for loop for assign monster data
    {
    //declare loop counter
        unsigned short int assignMonC;
    //loop
        for(assignMonC = 0; assignMonC < monsterTotal; assignMonC++)
            {
                initialMonster(&monster[assignMonC]);
            }
    }
    ////for loop for assign monster data

    //for loop for meet batt
    {
        unsigned short int meetMonC;
        for(meetMonC = 0; meetMonC < monsterTotal; meetMonC++)
            {
                printPlayerData(player);
                //while battle
                    while(player.life > 0 && monster[meetMonC].life > 0)
                        {
                            //print line
                                printf("%s碰到一隻半獸人!\n-----------\n", player.name);
                            //into battle
                                battle(&player, &monster[meetMonC]);

                        }
                ////while battle
                //break loop if player died
                    if(player.life < 0)
                        {
                            //print result
                                printf("%s死掉了。", player.name);
                                break;
                        }
                ////break loop if player died
            }
    }
    ////for loop for meet batt

    //prompt restart
        //prompt
        //版本:1.00(0)
            printf("請問您要讓%s重新開始嗎(N為否、Y為是)?", player.name);
            if('N' == getche())
                {
                    exit(0);
                }
                else
                    {
                        //clean screen
                            if(SYSTEM == 0)
                                {
                                    system("cls");
                                }
                                else
                                {
                                    system("clear");
                                }
                        goto restart;
                    }
    //pause
        pauseProgram();
	//---------------------
		//傳回數字0(表程式運行成功)
		//版本:1.00(1)
		//return後面不可加註解!
			return 0;
	}
Example #16
0
void GameArbiter::process_command(Message *command) {
    switch (command->type) {
        case UnitMove: {
            auto cmd = dynamic_cast<UnitMoveMessage *>(command);
            int stack_id = cmd->data1;
            IntSet units = cmd->data2;
            Path& path = cmd->data3;
            int target_id = cmd->data4;

            UnitStack::pointer stack = game->stacks.get(stack_id);
            if (units.empty() || !stack->has_units(units) || path.empty()) {
                throw DataError() << "Invalid UnitMove message";
            }

            /* Check that the move is allowed; shorten it if necessary */
            Point end_pos = path.back();
            UnitStack::pointer end_stack = game->level.tiles[end_pos].stack;
            int end_stack_id = end_stack ? end_stack->id : 0;
            if (end_stack_id != target_id) {
                path.pop_back();
                target_id = 0;
            }

            MovementModel movement(game);
            UnitStack::pointer selected_stack = stack->copy_subset(units);
            unsigned int allowed_steps = movement.check_path(*selected_stack, path);
            bool truncated = allowed_steps < path.size();
            int attack_target_id = target_id;
            if (truncated)
                target_id = 0;
            path.resize(allowed_steps);

            if (!path.empty()) {
                end_pos = path.back();
                /* Generate updates. */
                Faction::pointer faction = stack->owner;
                bool move = units.size() == stack->units.size() && target_id == 0;
                bool split = units.size() < stack->units.size() && target_id == 0;
                bool merge = units.size() == stack->units.size() && target_id != 0;

                UnitStack::pointer target = game->stacks.find(target_id);

                if (move)
                    target_id = stack_id;
                if (split)
                    target_id = game->get_free_stack_id();

                // Send the moves
                for (auto iter = path.begin(); iter != path.end(); iter++) {
                    emit(create_message(MoveUnits, stack_id, units, *iter));
                }
                // If the stack is splitting to a new empty position, create a stack there
                if (split) {
                    emit(create_message(CreateStack, target_id, end_pos, faction->id));
                }
                emit(create_message(TransferUnits, stack_id, units, path, target_id));
                // If the whole stack merged with an existing one, destroy it
                if (merge) {
                    emit(create_message(DestroyStack, stack_id));
                }
            } else {
                end_pos = stack->position;
            }

            UnitStack::pointer attack_target = game->stacks.find(attack_target_id);
            bool attack = attack_target && (attack_target->owner != stack->owner);
            if (attack) {
                BOOST_LOG_TRIVIAL(debug) << "Attack!";
                Point target_point = attack_target->position;
                Point attacking_point = end_pos;
                Battle battle(game, target_point, attacking_point);
                battle.run();
                emit(create_message(DoBattle, end_stack_id, target_point, battle.moves));
            }
        } break;

        case FactionReady: {
            auto cmd = dynamic_cast<FactionReadyMessage *>(command);
            int faction_id = cmd->data1;
            bool ready = cmd->data2;
            if (game->mark_faction_ready(faction_id, ready)) {
                emit(create_message(FactionReady, faction_id, ready));
            }

            if (game->all_factions_ready()) {
                emit(create_message(TurnEnd));
                // process turn end

                spawn_units();
                game->turn_number++;
                emit(create_message(TurnBegin, game->turn_number));
            }
        } break;

        case Chat: {
            auto chat_msg = dynamic_cast<ChatMessage *>(command);
            emit(create_message(Chat, chat_msg->data));
        } break;

        case SetLevelData:
        case CreateStructure:
        case DestroyStructure: {
            emit(command->shared_from_this());
        } break;

        default:
            break;
    }
}
void interpretGame(){
  if(strcasecmp(input,"Help\n") == 0){
    system("clear");
    DisplayHelp();
  }
  else if(strcasecmp(input,"Stats\n") == 0){
    system("clear");
    printStats();
  }
  else if(strcasecmp(input,"Room\n") == 0){
    system("clear");
    printRoomInfo();
  }
  else if(strcasecmp(input,"Attack\n") == 0){
    battle();
  }
  else if(strcasecmp(input,"down forward low punch\n") == 0){
    printf("Hadoken \n");
    sleep(1);
    if(DRoom->roomClear)
      printf("A blue orb comes out of your hands and hits the wall\n");
    else
      printf("%s: ... \n", Enemy->name);
    sleep(1);
  }
  else if(strcasecmp(input,"Advance\n") == 0){
    if(!DRoom -> roomClear){
      printf("The room isn't clear yet!\n");
      sleep(1);
    }
    else{
      printf("You move into the next room\n");
      generateRoom();
    }
  }
  else if(!strcasecmp(input,"Save\n")){
    dump();
    printf("Game saved\n");
  }
    else if(!strcasecmp(input,"OSave\n")){
    dump();
    char buff[256];
    printf("Enter the ip adress of the save server\n");
    fgets(buff, sizeof(buff), stdin);
    OSave(2, buff);
  }
  else if(strcasecmp(input,"Inventory\n") == 0){
    if(Player->weaponNum == 0){
	printf("You have no weapons!\n");
	getchar();
    }
    else if(Player->weaponNum == 1){
	printf("Your weapons give you a +%d bonus to attack.\n",Player->slot1.attk);
	getchar();
    }
    else if(Player->weaponNum == 2){
      printf("Your weapons give you a +%d bonus to attack.\n",Player->slot1.attk + Player->slot2.attk);
      getchar();
    }
  }
  else if(strcasecmp(input,"Quit\n") == 0 || strcasecmp(input,"Exit\n") == 0){
    quit = 0;
  }
  else{
    printf("Sorry, I don't understand that\n");
    sleep(1);
    system("clear");
  }
}
Example #18
0
void determineEnemy(Character* &theCharacter, int enemy)
{
    if (enemy == 1)
        theEnemy = new Enemy("The ", "Thief", 1);

    if (enemy == 2)
        theEnemy = new Enemy("The ", "Orc", 2);

    if (enemy == 3)
        theEnemy = new Enemy("The ", "Troll", 3);

    if (enemy == 4)
        theEnemy = new Enemy("The ", "Wizard", 4);

    if (enemy == 5)
        theEnemy = new Enemy("The ", "Dark Wizard", 5);

    if (enemy == 6)
        theEnemy = new Enemy("The ", "Dark Knight", 6);

    if (enemy == 7)
        theEnemy = new Enemy("The ", "General", 7);

    if (enemy == 8)
        theEnemy = new Enemy("The ", "Lengendard Swordsman", 8);

    if (enemy == 9)
        theEnemy = new Enemy("The ", "Giant", 9);

    if (enemy == 10)
        theEnemy = new Enemy("The ", "Demon", 10);

    if (enemy == 11)
        theEnemy = new Enemy("Jaime ", "Lannister", 11);

    if (enemy == 12)
        theEnemy = new Enemy("The ", "White Walker", 12);

    if (enemy == 13)
        theEnemy = new Enemy("The ", "Dark Angel", 13);

    if (enemy == 14)
        theEnemy = new Enemy("Lucifer", "", 14);

    if (enemy == 15)
        theEnemy = new Enemy("Tywin ", "Lannister", 15);

    if (enemy == 16)
        theEnemy = new Enemy("Genghis ", "Khan", 16);

    if (enemy == 17)
        theEnemy = new Enemy("Vladmir ", "Putin", 17);

    if (enemy == 18)
        theEnemy = new Enemy("The ", "Anti-Christ", 18);

    if (enemy == 19)
        theEnemy = new Enemy("Joseph ", "Stalin", 19);

    if (enemy == 20)
        theEnemy = new Enemy("Adolf ", "Hitler", 20);


    battle(theCharacter, theEnemy);
}
void battle()//insta win boss
{
	cout <<  endl << endl;
	cout << "During a fight you have three option, to attack and be attacked, to defend youself and regain energy, and to use magic to heal yourself and regain energy, but also use to attack." << endl;
	cout << "Type the inital of the action to do it." << endl << endl;

	cout << "Goblin's HP:";
	cout << seffu.seffHP << endl << endl; // to show how much life the opponent has

	if(seffu.seffHP <= 0)
	{
		cout << "Victory you killed the goblin!" << endl;
	}
	
	if(hero.Hp <= 0 )
	{
		cout << "You died to a goblin. Shame on you" << endl;
		hero.~character();
	}
	if(seffu.seffHP > 0)
	{
		cin >> p;
		cout << endl;

		if(p == 'a' )
		{

			if(hero.spd >= seffu.seffSpd)
			{
				hero.attack();
				cout << "Your energy: " << endl;
				cout << hero.energy << endl;
				seffu.seffHP = seffu.seffHP - hero.atk;//Need to lower opponent hp how?
				cout << "Goblin's HP: " ;
				cout << seffu.seffHP /*- hero.atk*/<< endl << endl;

				cout << "The goblin attacked!" <<endl;
				seffu.seffAttack();
				hero.Hp = hero.Hp - seffu.seffAtk;//seffu.seffAtk;//Need to lower opponent hp how?p[;
				cout << "Your HP: ";
				cout << hero.Hp << endl << endl;

				battle();
			}

			if(seffu.seffHP > 0)
			{
				cout << "The goblin attacked!" <<endl;
				seffu.seffAttack();
				hero.Hp = hero.Hp - seffu.seffAtk;//seffu.seffAtk;//Need to lower opponent hp how?p[;
				cout << "Your HP: ";
				cout << hero.Hp << endl << endl;

				hero.attack();
				cout << "Your energy: " << endl;
				cout << hero.energy << endl;
				seffu.seffHP = seffu.seffHP - hero.atk;//Need to lower opponent hp how?
				cout << "Goblin's HP: " ;
				cout << seffu.seffHP /*- hero.atk*/<< endl << endl;
			}
		}

		if(p =='d')
		{
			hero.defend();//Next part of combat
			cout << hero.energy << endl;
			cout<< hero.mgc << endl;
			hero.energy++;
			hero.mgc++;
			cout << hero.energy << endl;
			cout<< hero.mgc << endl;

			cout<<"The goblin did no damage!" <<endl;

			battle();
		}

		if( p == 'h' )
		{
			hero.heal();
			cout <<"HP: " << hero.Hp << endl;
			hero.Hp= hero.Hp + hero.mgc*2;
			cout << "HP: " << hero.Hp << endl;

			cout << "The goblin attacked!" <<endl;
			seffu.seffAttack();
			hero.Hp = hero.Hp - seffu.seffAtk;//seffu.seffAtk;//Need to lower opponent hp how?p[;
			cout << "Your HP: ";
			cout << hero.Hp << endl;
		}

		if (p == 'm')
		{	
			cout << "Magic: " << hero.mgc << endl;
			hero.magic();
			cout << "Magic: " << hero.mgc << endl; 
			cout << "Goblin HP: " << seffu.seffHP ;
			seffu.seffHP = seffu.seffHP - hero.mgc; 
			cout << endl;
			cout <<"Goblin HP: " << seffu.seffHP << endl;


			if(seffu.seffHP > 0)
			{
				cout << "The goblin attacked!" <<endl;
				seffu.seffAttack();
				hero.Hp = hero.Hp - seffu.seffAtk;//seffu.seffAtk;//Need to lower opponent hp how?p[;
				cout << "Your HP: ";
				cout << hero.Hp << endl;
				battle();
			}

		}

		if(hero.Hp <= 0 && seffu.seffHP > 0)
		{
			cout << "You died to a goblin. Shame on you" << endl;
			hero.~character();
		}
		if (hero.Hp > 0 && seffu.seffHP > 0)
		{
			battle();
		}

	}
Example #20
0
void battle_by_value(creature you) {
  battle(&you);
}
Example #21
0
void playGame(characterInfo player) {
    
    //
    
    system("cls");
    
    int menuSelect;
    
    do {
        cout<< "(1)Battle" <<endl;
        cout<< "(2)Inventory" <<endl;
        cout<< "(3)Go to town" <<endl;
        cout<< "(4)Save and Quit" <<endl;
        cout<< "What would you like to do, " <<player.name<< "? ";
        cin>>menuSelect;
        
        switch(menuSelect) {
            case 1:
                cout<< "To battle!" <<endl;
                Sleep(500);
                player = battle(player);
                system("pause");
                break;
            case 2:
                cout<< "Inventory!" <<endl;
                Sleep(500);
                player = inventory(player);
                system("cls");
                break;
            case 3:
                cout<< "Going to town!" <<endl;
                Sleep(500);
                system("cls");
                break;
            case 4:
                saveGame(player);
                system("cls");
                break;
            default:
                cout<< "That is not an option, " <<player.name<<endl;
                system("pause");
                system("cls");
                break;
        }
        system("cls");
        if(player.health == 0) {
            
            break;
            
        }
    }
    while(menuSelect != 4);
    
    if(player.health == 0) {
        
        char deathDecision;
        
        cout<< "You have died!" <<endl;
        
        if(player.revivesLeft != 0) {
            
            cout<< "Revives left: " <<player.revivesLeft<<endl;
            cout<< "Would you like to try again(y/n)?";
            cin>>deathDecision;
            
            if(deathDecision == 'y') {
                
                cout<< "Reviving!" <<endl;
                player.revivesLeft--;
                player.health = player.totalHealth;
                Sleep(500);
                system("cls");
                playGame(player);
                
            } else {
                
                cout<< "Game over!" <<endl;
                Sleep(1000);
                
            }
        } else {
Example #22
0
int battleSequence(Frame* frame) {
	frame->move(0, 0);
	frame->print(filledWith(*frame, "□"), 15);
	int eob = battle(&player, area[player.c_area][player.x][player.y].uniqueBossId);
	return eob;
}