This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathlib.cpp
More file actions
141 lines (123 loc) · 3.24 KB
/
Copy pathlib.cpp
File metadata and controls
141 lines (123 loc) · 3.24 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include "lib.h"
#include <stdlib.h>
#include <iostream>
#include <time.h>
#include <unistd.h>
const int N = 2 ;
using namespace std;
string Player::namesOne[5] = { "Szymon", "Pawel", "Mateusz", "Dorian", "Mariusz"};
string Player::namesTwo[5] = {"Artur", "Krzysiek", "Michal", "Wojtek", "Tomek"};
int Player::_counter = 0;
void Player::setSobriety(int newSobriety)
{
_sobriety = newSobriety;
}
void Player::setAccuracy(int newAccuracy)
{
_accuracy = newAccuracy;
}
void Player::setCanFilling(int newCanFilling)
{
_canFilling = newCanFilling;
}
void Player::showStatistics()
{
cout << "~~" << _name << "~~\ttrzezwosc: |"
<< _sobriety << "|\tcelnosc: |" << _accuracy
<< "|\tszybkosc picia: |" << _drinkingSpeed
<< "| (lyki/trafienie)\tnapelnienie puszki: |" << _canFilling
<< "| (lyki)" << endl;
}
Player::Player()
{
if(_counter%2)
{
_name = namesOne[rand()%5];
}
else
{
_name = namesTwo[rand()%5];
}
_sobriety = rand()%91 + 5;
_accuracy = rand()%91 + 5;
_canFilling = 30;
_drinkingSpeed = rand()%6 +5;
_counter++;
}
Player* game(Player* theFirst, Player* theSecond)
{
cout << endl << "Puszka na srodku! Rozpoczyna sie walka!" << endl;
sleep(N);
theFirst->showStatistics();
sleep(N);
theSecond->showStatistics();
sleep(N);
while(theFirst->sobriety() > 0 &&
theSecond->sobriety() > 0 &&
theFirst->canFilling() > 0 &&
theSecond->canFilling() > 0 &&
theFirst->accuracy() > 0 &&
theSecond->accuracy() > 0)
{
bool ifThrow = rand()%101 < theFirst->accuracy();
cout << theFirst->name()
<< ((ifThrow) ? (" trafia w puszke i pije!") : (" pudluje!")) << endl;
sleep(N);
if(ifThrow)
{
theFirst->setSobriety(theFirst->sobriety() - theFirst->drinkingSpeed());
theFirst->setAccuracy(theFirst->accuracy() - ((100 - theFirst->sobriety()) * 0.2));
theFirst->setCanFilling(theFirst->canFilling() - theFirst->drinkingSpeed());
if(theFirst->canFilling() <=0)
{
cout << theFirst->name() << " wypil swoje piwo i zostal zwyciezca!" << endl;
sleep(N);
return theFirst;
}
if(theFirst->sobriety() > 0 &&
theFirst->canFilling() > 0 &&
theFirst->accuracy() > 0 )
{
theFirst->showStatistics();
sleep(N);
}
else
{
cout << theFirst->name() << " jest zbyt pijany by grac! Zwyciezca to "
<< theSecond->name() << "!" << endl;
sleep(N);
return theSecond;
}
}
ifThrow = rand()%101 < theSecond->accuracy();
cout << theSecond->name()
<< ((ifThrow) ? (" trafia w puszke i pije!") : (" pudluje!")) << endl;
sleep(N);
if(ifThrow)
{
theSecond->setSobriety(theSecond->sobriety() - theSecond->drinkingSpeed());
theSecond->setAccuracy(theSecond->accuracy() - ((100 - theSecond->sobriety()) * 0.2));
theSecond->setCanFilling(theSecond->canFilling() - theSecond->drinkingSpeed());
if(theSecond->canFilling() <= 0)
{
cout << theSecond->name() << " wypil swoje piwo i zostal zwyciezca!" << endl;
sleep(N);
return theSecond;
}
if(theSecond->sobriety() > 0 &&
theSecond->canFilling() > 0 &&
theSecond->accuracy() > 0 )
{
theSecond->showStatistics();
sleep(N);
}
else
{
cout << theSecond->name() << " jest zbyt pijany by grac! Zwyciezca to "
<< theFirst->name() << "!" << endl;
sleep(N);
return theFirst;
}
}
}
}