Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////Player.h/////////////////
- #pragma once
- #include <string>
- class Player
- {
- private:
- int m_dice;
- public:
- Player()
- {
- }
- void RollDice();
- const int& GetDice() const
- {
- return m_dice;
- }
- };
- //////////////////gameloop.h/////////////
- #pragma once
- #include "Player.h"
- #include "PlayerOptions.h"
- #include <string>
- class Game
- {
- private:
- int m_noOfPlayers;
- Player *m_player;
- void WelcomePlayer();
- public:
- void RunGame();
- void setNoOfPlayers(const int& noOfPlayers)
- {
- m_noOfPlayers = noOfPlayers;
- }
- const int& GetNoOfPlayers() const
- {
- return m_noOfPlayers;
- }
- };
- ///////////////////gameloop.cpp////////////
- // NathanWood_Final.cpp : Defines the entry point for the console application.
- //
- #include "Player.h"
- #include "stdafx.h"
- #include "GameLoop.h"
- #include <string>
- #include <fstream>
- #include <iostream>
- #include <ctime>
- //using namespace std;
- void Game::WelcomePlayer()
- {
- std::string line;
- std::ifstream myfile("Rules.txt");
- if (myfile.is_open())
- {
- while (getline(myfile, line))
- {
- std::cout << line << '\n';
- }
- myfile.close();
- }
- else std::cout << "Unable to open file";
- std::cout << "\nWelcome to liars dice. How many players are playing?";
- int noOfPlayers;
- std::cin >> noOfPlayers;
- const int n = noOfPlayers;
- if (noOfPlayers > 0) {
- m_player.setNoOfPlayers(noOfPlayers);
- Player *ArrPlayers = new Player[noOfPlayers];
- }
- else
- std::cout << "That is not a valid choice";
- }
- void Player::RollDice()
- {
- srand((unsigned int)time(NULL)); //seed the random # generator
- const int noOfPlayers = m_player.GetNoOfPlayers();
- for (int i = 0; i < noOfPlayers; ++i)
- {
- //TODO:: roll the dice
- //(rand() % 6) + 1;
- }
- }
- void Game::RunGame()
- {
- WelcomePlayer();
- RollDice();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement