catching a pokemon

So i'm writing this code for a class of mine but i'm having trouble understanding the boolean expression and whether its coming out "true" or "false". In addition, I need to use that expression to determine a "catch" success or not. Here's my code if anyone can help. CaptureAttempt and main are where i'm having the most trouble... I know the lower half of main() is not finished, but that's a big part of where i'm lost. I'll include part of the prompt at the bottom so you know what i'm attempting to do.

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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <iostream>
#include "Monster.h"
#include <ctime>
using namespace std;

bool CaptureAttempt(Monster monster);
Monster SetMonster();
string RandomNameGenerator();

int main()
{
	srand(time(0));

	char input;
	bool didCatch = false;
	int pokeballs = 5;

	Monster monster = SetMonster();

	cout << "A wild " << monster.name << " appeared!" << endl << endl;
	cout << monster.name << endl;
	cout << monster.combatpower << endl << endl;
	cout << "You have " << pokeballs << " pokeballs left" << endl;
	cout << "Attempt to capture? <Y/N>" << endl;
	cin >> input;

	if (input == 'y' || input == 'Y')
	{
		CaptureAttempt(monster);
	}
	didCatch == CaptureAttempt(monster);
	while (didCatch == false)
	{
		pokeballs--;
		cout << didCatch << "   " << CaptureAttempt(monster) << endl;
		cout << monster.name << " broke free!" << endl;
		cout << "You have " << pokeballs << " pokeballs left" << endl << "Attempt to capture again? <Y/N>" << endl;
		cin >> input;
		if (input == 'y' || input == 'Y')
		{
			CaptureAttempt(monster);
		}
	}
	

	return 0;
}

bool CaptureAttempt(Monster monster)
{
	int chance;
	if (monster.combatpower < 100)
	{
		chance = rand() % 1;
	}
	else if (monster.combatpower > 99 && monster.combatpower < 201)
	{
		chance = rand() % 3;
	}
	else if (monster.combatpower > 200)
	{
		chance = rand() % 7;
	}
	
	if (chance = 0)
	{
		return false;
	}
	else
	{
		return true;
	}
}

Monster SetMonster()
{
	Monster monster;
	monster.name = RandomNameGenerator();
	monster.combatpower = rand() % 450 + 1;
	return monster;
}

string RandomNameGenerator()
{
	string name;
	const int size = 25;
	string names[size] =
	{
		"Charmander", "Bulbasaur", "Squirtle", "Pidgey", "Pikachu", "Sandshrew", "Zubat",
		"Mankey", "Abra", "Magikarp", "Eevee", "Rattata", "Vulpix", "Scyther", "Jigglypuff",
		"Geodude", "Onix", "Staryu", "Snorlax", "Mewtwo", "Oddish", "Caterpie", "Spearow",
		"Charizard", "Zapdos"
	};

	name = names[rand() % 24];

	return name;
}

CatchAttempt()
This function takes a Monster data type as an argument and returns a boolean true or false. The monster argument is to use the combatPower value to determine the chance of catching the pokemon. The chances of catching a pokemon depends upon how high the combatPower is. Use the following scale:

if combatPower is less than 100, there is a 1 in 2 chance to capture
if combatPower is greater than 99, there is a 1 in 4 chance to capture
if combatPower is greater than 200, there is a 1 in 8 chance to capture


Check the variable ”chance” to see if it is equal to zero. If it is, you caught the pokemon so return true. If it is any other number, you did not catch the pokemon. The greater the combat power, the slimmer chance that zero appears.



main()
Variables:

monster of type Monster
input of type char
didCatch of type bool initialized and assigned to false
pokeballs of type int initialized and assigned to 5

This is your required starting function. Inside main, you will create an instance of Monster called “monster”. Do not initialize the monster variable. On the next line, call setMonster() and assign it to monster. This function will go and populate name and combat power into the instance of monster. Main should contain a loop that checks to see if we did not catch a pokemon and we have at least 1 pokeball available. Inside the loop, cout to the user how many pokeballs they have remaining and ask if the user wants to attempt to capture with possible options . Be sure to take one pokeball away for each attempt to capture the pokemon. Call and use the captureAttempt() function and assign its return to didCatch. Check didCatch to see if the user caught the pokemon and if the user did cout "Gotcha! You caught the monster name!". else, the user did not catch the pokemon and you should cout " broke free! Attempt to catch again?”. If the user did not choose to attempt to catch the pokemon, cout “Got away safely” and quit the program. If the user does not have enough pokeballs, cout "You do not have any pokeballs, so you ran and got away safely." And end the program.
Somebody's developing it here:
https://ideone.com/wzoHLy

Maybe, if you enrol that site, you can contact the author (I've no idea if it's possible).

I'm afraid here, since asking about homework is explicitly forbidden
http://www.cplusplus.com/forum/beginner/1/
we need to see your own attempt before giving you help.
got it, thanks for the heads up on that rule, guess I overlooked it.
Topic archived. No new replies allowed.