-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.cpp
81 lines (68 loc) · 1.47 KB
/
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
/*
* player.cpp
*
* Created on: 15-Jul-2014
* Author: Dhwanil
*/
#include "player.h"
#include <iostream>
using namespace std;
player::player(cards* ca,cpu* cp) {
// TODO Auto-generated constructor stub
card=ca;
//player::totalcard=15;
c=cp;
cout<<"player created";
//c->setplayer(this);
}
cards* player::makesir()
{
cout<<"choose sir from below cards"<<endl;
for(int i=0;i<5;i++)
{
cout<<1<<endl;
cout<<(i+1)<<" "<< card[i].getcolor()<<" "<<card[i].getno()<<endl;
}
int choice;
cin>>choice;
sir=new cards(0,card[choice].getcolor());
return sir;
}
void player::turnplayer()
{
cout<<"your turn please choose one card from below"<<endl;
for(int i=0;i<totalcard;i++)
{
cout<<(i+1)<< card[i].getcolor()<<" "<<card[i].getno()<<endl;
}
int choice;
cin>>choice;
c->secondturn(card[choice]);
}
void player::secondturnplayer(cards* move)
{
cout<<"your turn please choose one card from below"<<endl;
for(int i=0;i<totalcard;i++)
{
cout<<(i+1)<< card[i].getcolor()<<" "<<card[i].getno()<<endl;
}
int choice;
cin>>choice;
if((card[choice].getcolor()!=move->getcolor())&&(card[choice].getcolor()!=sir->getcolor()))
{
c->firstturn();
}
else
if((card[choice].getcolor()==move->getcolor())&&(card[choice].getno()>move->getno()))
{
turnplayer();
}
else
if((card[choice].getcolor()!=move->getcolor())&&(card[choice].getcolor()==sir->getcolor()))
{
turnplayer();
}
}
player::~player() {
// TODO Auto-generated destructor stub
}