I'm back from slaying errors and only 23 deadly errors remain.

Pages: 12
day 3 of my error clean up :D I want to thank you everyone in advance and in the past that has helped me.

Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>
#include <ctime>
#include <string>
#include "Combat.h"
#include "Player.h"
#include "Monster.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"

using namespace std;


int main()
{
	Combat combat;
	combat.runCombat();

	system("PAUSE");
	return 0;
}


Combat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  #pragma once
#include <iostream>
#include <ctime>
#include <string>
#include "Player.h"
#include "Monster.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"

using namespace std;

class Combat
{
public:
	Combat();
	
	bool runCombat();

private:
	int checkSpeed(int crea1, int crea2, int crea3, int crea4);
};


Combat.cpp
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
#include <iostream>
#include <ctime>
#include <string>
#include "Combat.h"
#include "Player.h"
#include "Monster.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"

using namespace std;

Combat::Combat()
{
}

bool Combat::runCombat()
{
	Player kyle(1, 10, 10, 3, 5, 6, 15, 12, 500, 1000);
	Monster one(1, 10, 10, 2, 5, 6, 15, 12, 500, 1000);
	Monster two(1, 10, 10, 1, 5, 6, 15, 12, 500, 1000);
	Monster three(1, 10, 10, 4, 5, 6, 15, 12, 500, 1000);

	one._name = "Orrin";
	two._name = "Braedon";
	three._name = "Brent";

	int turn = checkSpeed(kyle._speed, one._speed, two._speed, three._speed);

	if (turn == 1) {
		int choice = kyle.pickAction();
		if (choice == 1) {
			//Pick target
			cout << "Please pick a target" << endl;
			cout << "1)." << one._name << endl;
			cout << "2)." << two._name << endl;
			cout << "3)." << three._name << endl;
			int choice;
			cin >> choice;

			//Check is attack beats target defense, then subtract armor from damage total and inflict to health.
			switch (choice)
			{
			case 1: 
				kyle.makeAttack(one);
				break;
			case 2:
				kyle.makeAttack(two);
				break;
			case 3:
				kyle.makeAttack(three);
				break;
			}
		}
	}
	else if (turn == 2) {
		one.monAttack(kyle);
	}
	else if (turn == 3) {
		two.monAttack(kyle);
	}
	else {
		three.monAttack(kyle);
	}
}

int Combat::checkSpeed(int crea1, int crea2, int crea3, int crea4)
{
	if (crea1 > crea2 && crea3 && crea4) {
		return 1;
	}
	else if (crea2 > crea1 && crea3 && crea4) {
		return 2;
	}
	else if (crea3 > crea1 && crea2 && crea4) {
		return 3;
	}
	else {
		return 4;
	}
}


Player.h
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
#pragma once
#include <iostream>
#include <ctime>
#include <string>
#include "Combat.h"
#include "Monster.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"

using namespace std;

class Player
{
public:
	Player(int level, int health, int defense, int speed, int damage, int attack, int stamina, int mana, int gold, int experience);

	int pickAction();

	void makeAttack(Monster target);

	int _level;
	int _health;
	int _defense;
	int _speed;
	int _damage;
	int _attack;
	int _stamina;
	int _mana;
	int _gold;
	int _experience;

	int _wAttDice;
	int _wDamDice;

private:
	
};


Player.cpp
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
#include <iostream>
#include <ctime>
#include <string>
#include "Combat.h"
#include "Player.h"
#include "Monster.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"

using namespace std;


Player::Player(int level, int health, int defense, int speed, int damage, int attack, int stamina, int mana, int gold, int experience)
{
	_level = level;
	_health = health;
	_defense = defense;
	_speed = speed;
	_damage = damage;
	_attack = attack;
	_stamina = stamina;
	_mana = mana;
	_gold = gold;
	_experience = experience;
}

int Player::pickAction()
{
	whoops:
	int actionChoice;

	cout << "please pick an action!" << endl;
	cout << "1). Attack!" << endl;
	cout << "2). Cast Spell!" << endl;

	cin >> actionChoice;


	if (actionChoice == 1) {
		return 1;
	}
	else if (actionChoice == 2) {
		//Spell function
	}
	else {
		cout << "You cannot do that now!" << endl;
		goto whoops;
	}

}

void Player::makeAttack(Monster target)
{
	//Initialize Weapon
	Weapon katana("Katana", 6, 8);

	int aTotal;
	int dTotal;
	int iTotal;

	//Roll dice for Attack and Damage "ranges"
	Dice ATTACK;
	Dice DAMAGE;
	int attackDiceResults = ATTACK.diceRoller(katana._attackDice);
	int damageDiceResults = DAMAGE.diceRoller(katana._damageDice);

	//Add dice results with player stats.
	aTotal = _attack + attackDiceResults;
	dTotal = _damage + damageDiceResults;


	if (aTotal >= target._defense) {
		iTotal = dTotal - target._armor;
		target._health = iTotal;
		cout << "You have dealt " << iTotal << "damage to " << target._name << "!" << endl;
		target._health -= iTotal;
	}
	else {
		cout << "You're attack has missed!" << endl;
	}
	
		
	
}


Monster.h
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
#pragma once
#include <iostream>
#include <ctime>
#include <string>
#include "Combat.h"
#include "Player.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"

using namespace std;

class Monster
{
public:
	Monster(int level, int health, int defense, int speed, int damage, int attack, int stamina, int mana, int armor, int magicResist);

	string _name;

	void monAttack(Player target);

	int _level;
	int _health;
	int _defense;
	int _speed;
	int _damage;
	int _attack;
	int _stamina;
	int _mana;
	int _armor;
	int _magicResist;

private:
};


Monster.cpp
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
#include <iostream>
#include <ctime>
#include <string>
#include "Combat.h"
#include "Player.h"
#include "Monster.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"

using namespace std;

Monster::Monster(int level, int health, int defense, int speed, int damage, int attack, int stamina, int mana, int armor, int magicResist)
{
	string _name;
	_level = level;
	_health = health;
	_defense = defense;
	_speed = speed;
	_damage = damage;
	_attack = attack;
	_stamina = stamina;
	_mana = mana;
	_armor = armor;
	_magicResist = magicResist;

}


void Monster::monAttack(Player target)
{
	//Initialize Weapon
	Weapon club("Club", 4, 10);

	int aTotal;
	int dTotal;
	int iTotal;

	//Roll dice for Attack and Damage "ranges"
	Dice ATTACK;
	Dice DAMAGE;
	int attackDiceResults = ATTACK.diceRoller(club._attackDice);
	int damageDiceResults = DAMAGE.diceRoller(club._damageDice);

	//Add dice results with player stats.
	aTotal = _attack + attackDiceResults;
	dTotal = _damage + damageDiceResults;

	if (aTotal >= target._defense) {
		iTotal = dTotal - 5;
		target._health = iTotal;
		cout << "You have been dealt " << iTotal << "damage to!" << endl;
		target._health -= iTotal;
	}
	else {
		cout << _name << "has missed!" << endl;
	}
}


Dice.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#pragma once
#include <iostream>
#include <ctime>
#include <string>
#include "Combat.h"
#include "Player.h"
#include "Monster.h"
#include "Scenario.h"
#include "Equipment.h"

using namespace std;

class Dice
{
public:
	Dice();
	int Dice::diceRoller(int x);
	
private:
	
};


Dice.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <ctime>
#include <string>
#include "Combat.h"
#include "Player.h"
#include "Monster.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"

using namespace std;

Dice::Dice()
{
	
}

int Dice::diceRoller(int x)
{
	default_random_engine randomGenerator(time(NULL));
	uniform_int_distribution<int> roll(1, x);	
	return roll(randomGenerator);
}


Equipment.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  #pragma once
#include <iostream>
#include <ctime>
#include <string>
#include "Combat.h"
#include "Player.h"
#include "Monster.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"

using namespace std;

class Weapon
{
public:
	Weapon(string name, int damage, int attack);

	string _name;
	int _damageDice;
	int _attackDice;
};


Equipment.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <ctime>
#include <string>
#include "Combat.h"
#include "Player.h"
#include "Monster.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"

using namespace std;


Weapon::Weapon(string name, int damage, int attack)
{
	name = _name;
	damage = _damageDice;
	attack = _attackDice;
}
You forgot to tell us what errors you are receiving.

Edit: Nevermind, I read this before you had replied with all of the errors.
Last edited on
And here are my lovely errors, all crying for help and waking up the family.

Error C2061 syntax error: identifier 'Player' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\monster.h 20

Error C2660 'Monster::monAttack': function does not take 1 arguments C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\combat.cpp 57

Error C2660 'Monster::monAttack': function does not take 1 arguments C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\combat.cpp 60

Error C2660 'Monster::monAttack': function does not take 1 arguments C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\combat.cpp 63

Error C2065 'default_random_engine': undeclared identifier C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\dice.cpp 20

Error C2146 syntax error: missing ';' before identifier 'randomGenerator' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\dice.cpp 20

Error C3861 'randomGenerator': identifier not found C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\dice.cpp 20

Error C2065 'uniform_int_distribution': undeclared identifier C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\dice.cpp 21

Error C2062 type 'int' unexpected C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\dice.cpp 21

Error C2065 'randomGenerator': undeclared identifier C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\dice.cpp 22

Error C3861 'roll': identifier not found C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\dice.cpp 22

Error C2511 'void Monster::monAttack(Player)': overloaded member function not found in 'Monster' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\monster.cpp 31

Error C2597 illegal reference to non-static member 'Monster::_attack' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\monster.cpp 46

Error C3867 'Monster::_attack': non-standard syntax; use '&' to create a pointer to member C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\monster.cpp 46

Error C2597 illegal reference to non-static member 'Monster::_damage' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\monster.cpp 47

Error C3867 'Monster::_damage': non-standard syntax; use '&' to create a pointer to member C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\monster.cpp 47

Error C2597 illegal reference to non-static member 'Monster::_name' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\monster.cpp 56

Error C2061 syntax error: identifier 'Player' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\monster.h 20

Error C2061 syntax error: identifier 'Player' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\monster.h 20

Error C2061 syntax error: identifier 'Player' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\monster.h 20

Error C2061 syntax error: identifier 'Player' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\monster.h 20

Error C2061 syntax error: identifier 'Player' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\monster.h 20

Error C2061 syntax error: identifier 'Player' C++ Course Work c:\users\kyle\documents\visual studio 2015\projects\c++ course work\c++ course work\monster.h 20

edit: no worries, i knew the thing would complain about too many characters. :P
Last edited on
You forgot to #include <random> in dice.cpp and dice.h. That should take care of a few of those errors.
WOOHOO!! down to 16! all errors relating to the dice files are gone.
I also noticed you have a function inside of player for a player attacking a monster, and a function inside of monster for a monster attacking a player. That's redundant, and it is also causing you errors. I think you should create a class called Combatant (or whatever you want to call it), and have Player and Monster extend that class. Attacks should also be handled in the Combat class. If you don't know about classes extending other classes, see this: http://www.cplusplus.com/doc/tutorial/inheritance/#inheritance
omg you just saved my program. I did just that, went down to 5 easily fixed errors. I fixed them and ran it but after picking whom to attack i got an error in the command prompt that said:

"c:\program files (x86)\microsoft visual studio 14.0\vc\include\random\(2447): invalid min and max arguments for uniform_int".

and a window popped up saying:
"debug error!

Program: ...tudio 2015\Projects\C++ Course Work\Debug|C++ Course Work.exe

abort() has been called

(press Retry to debug the application)"

I believe it can go without saying I have no idea whats going on except it looks like something to do with the time files.

edit: should i reupload a new set of my files to be looked at? if so, here or new post?
Last edited on
That error message is saying something is wrong with uniform_int_distribution, and the only time you use that is in diceRoller() (at least in the original code you posted). Be sure to read the error messages thoroughly, because they can give you hints about what's going wrong, if not tell you exactly. I'm unfamiliar with uniform_int_distribution, so try this instead:

int Dice::diceRoller(int x)
{
random_device rd;
return rd() % x + 1;
}


Edit: After reading the error message again, I am almost certain that I know what is wrong. You probably called diceRoller() and passed an int that was less than or equal to 1. That will break uniform_int_distribution, so look for every point in your code where you call diceRoller(), and make sure that the int being passed is greater than 1.

Also, seeding with time(NULL) is stinky. Use this instead:

1
2
3
4
5
6
7
int Dice::diceRoller(int x)
{
        random_device rd;
	default_random_engine randomGenerator(rd());
	uniform_int_distribution<int> roll(1, x);	
	return roll(randomGenerator);
}


If you still get errors, post your updated code here and the errors you receive. Good luck.
Last edited on
Didn't work, the numbers being passed are 4 and 10 :/ i implimented your correction to null though, sure it will help down the road.

Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <ctime>
#include <string>
#include "Combat.h"
#include "Combatant.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"

using namespace std;


int main()
{
	Combat combat;
	combat.runCombat();

	system("PAUSE");
	return 0;
}


Combat.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#pragma once
#include <iostream>
#include <ctime>
#include <string>
#include "Combatant.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"

using namespace std;

class Combat
{
public:
	Combat();
	
	bool runCombat();

private:
	int checkSpeed(int crea1, int crea2, int crea3, int crea4);
};


Combat.cpp
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
#include <iostream>
#include <ctime>
#include <string>
#include "Combat.h"
#include "Combatant.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"

using namespace std;

Combat::Combat()
{
}

bool Combat::runCombat()
{
	Combatant kyle(1, 10, 10, 3, 5, 6, 15, 12, 500, 1000);
	Combatant one(1, 10, 10, 2, 5, 6, 15, 12, 500, 1000);
	Combatant two(1, 10, 10, 1, 5, 6, 15, 12, 500, 1000);
	Combatant three(1, 10, 10, 4, 5, 6, 15, 12, 500, 1000);

	kyle._name = "Kyle";
	one._name = "Orrin";
	two._name = "Braedon";
	three._name = "Brent";

	int turn = checkSpeed(kyle._speed, one._speed, two._speed, three._speed);

	if (turn == 1) {
		int choice = kyle.pickAction();
		if (choice == 1) {
			//Pick target
			cout << "Please pick a target" << endl;
			cout << "1)." << one._name << endl;
			cout << "2)." << two._name << endl;
			cout << "3)." << three._name << endl;
			int choice;
			cin >> choice;

			//Check is attack beats target defense, then subtract armor from damage total and inflict to health.
			switch (choice)
			{
			case 1: 
				kyle.attack(one);
				break;
			case 2:
				kyle.attack(two);
				break;
			case 3:
				kyle.attack(three);
				break;
			}
		}
	}
	else if (turn == 2) {
		one.attack(kyle);
	}
	else if (turn == 3) {
		two.attack(kyle);
	}
	else {
		three.attack(kyle);
	}
	return true;
}

int Combat::checkSpeed(int crea1, int crea2, int crea3, int crea4)
{
	if (crea1 > crea2 && crea3 && crea4) {
		return 1;
	}
	else if (crea2 > crea1 && crea3 && crea4) {
		return 2;
	}
	else if (crea3 > crea1 && crea2 && crea4) {
		return 3;
	}
	else {
		return 4;
	}
}


Combatant.h
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
#pragma once
#include <iostream>
#include <ctime>
#include <string>
#include "Combat.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"

using namespace std;

class Combatant
{
public:
	Combatant(int level, int health, int defense, int speed, int damage, int attack, int stamina, int mana, int armor, int magicResist);

	string _name;

	int _level;
	int _health;
	int _defense;
	int _speed;
	int _damage;
	int _attack;
	int _stamina;
	int _mana;
	int _armor;
	int _magicResist;

	int pickAction();

	void attack(Combatant target);

};


Combatant.cpp
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
#include <iostream>
#include <ctime>
#include <string>
#include "Combat.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"
#include "Combatant.h"

using namespace std;



Combatant::Combatant(int level, int health, int defense, int speed, int damage, int attack, int stamina, int mana, int armor, int magicResist)
{
	string _name;
	_level = level;
	_health = health;
	_defense = defense;
	_speed = speed;
	_damage = damage;
	_attack = attack;
	_stamina = stamina;
	_mana = mana;
	_armor = armor;
	_magicResist = magicResist;
}

int Combatant::pickAction()
{
whoops:
	int actionChoice;

	cout << "please pick an action!" << endl;
	cout << "1). Attack!" << endl;
	cout << "2). Cast Spell!" << endl;

	cin >> actionChoice;


	if (actionChoice == 1) {
		return 1;
	}
	else if (actionChoice == 2) {
		//Spell function
	}
	else {
		cout << "You cannot do that now!" << endl;
		goto whoops;
	}

}

void Combatant::attack(Combatant target)
{
	//Initialize Weapon
	Weapon club("Club", 4, 10);

	int aTotal;
	int dTotal;
	int iTotal;

	//Roll dice for Attack and Damage "ranges"
	Dice ATTACK;
	Dice DAMAGE;
	int attackDiceResults = ATTACK.diceRoller(club._attackDice);
	int damageDiceResults = DAMAGE.diceRoller(club._damageDice);

	//Add dice results with player stats.
	aTotal = _attack + attackDiceResults;
	dTotal = _damage + damageDiceResults;

	if (aTotal >= target._defense) {
		iTotal = dTotal - 5;
		target._health = iTotal;
		cout << "You have been dealt " << iTotal << "damage to!" << endl;
		target._health -= iTotal;
	}
	else {
		cout << _name << "has missed!" << endl;
	}
}


Equipment.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#pragma once
#include <iostream>
#include <ctime>
#include <string>
#include "Combat.h"
#include "Combatant.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"

using namespace std;

class Weapon
{
public:
	Weapon(string name, int damage, int attack);

	string _name;
	int _damageDice;
	int _attackDice;
};


Equipment.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <ctime>
#include <string>
#include "Combat.h"
#include "Combatant.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"

using namespace std;


Weapon::Weapon(string name, int damage, int attack)
{
	name = _name;
	damage = _damageDice;
	attack = _attackDice;
}


Dice.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#pragma once
#include <iostream>
#include <ctime>
#include <string>
#include <random>
#include "Combat.h"
#include "Combatant.h"
#include "Scenario.h"
#include "Equipment.h"

using namespace std;

class Dice
{
public:
	Dice();
	int Dice::diceRoller(int x);
	
private:
	
};


Dice.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <ctime>
#include <string>
#include "Combat.h"
#include "Combatant.h"
#include "Scenario.h"
#include "Dice.h"
#include "Equipment.h"

using namespace std;

Dice::Dice()
{
	
}

int Dice::diceRoller(int x)
{
	random_device rd;
	default_random_engine randomGenerator(rd());
	uniform_int_distribution<int> roll(1, x);
	return roll(randomGenerator);
}
What blows me away about you is I think your programming is really good. Well I know its better than mine. I can read and figure out alot of my errors in a program and even understand your even though I can hardly read and understand your code. I'm not tring to put you down by any means I just find it weird you don't know much about compiler errors.

Wait till you get bugs those are really some fun. The program compiles and runs but the output is all messed up and dosnt do what you thought it was going to do. I spent 3 hours tring to find a bug and all it turned out to be was a typo.
Last edited on
well i think this is a bug then, because there are no more errors, just a crash i guess. I've been doing this for two weeks at most so thats why I can't understand errors yet :P I'm not even sure half the time while some errors go away when i fix x or y.
Well I think your doing an awesome job. What do you mean by a crash?
Yeah complier is weird some times I get like 103 errors and change and fix 2 things and then its perfect.
With bugs the comments // can help alot. Just start where the program last ran good and look at the code you wrote new and comments things out one at a time till it runs and you located it. I mean comment lines out and if it don't run uncomment them and work though it untill you locate the bug.
Last edited on
thank you so much, i never though of that. I'll do that and see where it leads me. thanks for the motivation. I had a feeling this kind of thing would be up my alley :D
it would seem that passing a number directly into my diceroller makes it work but passing a variable with a value is making it freak out.
I would recommend using a debugger to step through the code. That way you know exactly what values are going in and where when it crashes.
whats a debugger? :P im sorry, im still super new. I think there's one in visual studios 2015, i just dont know how to use it, i guess :P

edit: nevermind, figured it out, so for some reason, these two variables are getting assigned these values.

club._attackDice -858993460 int
club._damageDice -858993460 int
Last edited on
did some mroe play with debugging and found out that in my weapon.cpp file, the numbers going in are

attack 4 int
damage 10 int

but when they get transferred to new variables they turn into the numbers in my last comment. I'm using an equal sign, why would the value change?
Please post your weapon.cpp file; you haven't posted that yet.
Pages: 12