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
|
#include "Player.h"
#include <iostream>
#include <fstream>
using namespace std;
Player::Player()
{
}
void Player::IncrStat(int s, int d, int a, int h, int e, int g, int l){
Strg += s;
Def += d;
Agil += a;
Health += h;
Exp += e;
Gold += g;
Lvl += l;
}
void Player::DecrStat(int s, int d, int a, int h, int e, int g, int l){
Strg -= s;
Def -= d;
Agil -= a;
Health -= h;
Exp -= e;
Gold += g;
Lvl += l;
}
void Player::save(){
ofstream S;
S.open("SAVE.bin", ios::binary | ios::out);
S.write((char*)(&Strg), sizeof(Strg));
S.write((char*)(&Def), sizeof(Def));
S.write((char*)(&Agil), sizeof(Agil));
S.write((char*)(&Exp), sizeof(Exp));
S.write((char*)(&Gold), sizeof(Gold));
S.write((char*)(&Lvl), sizeof(Lvl));
S.close();
if (! S){
cout << "File could not be saved!\n";
}
}
void Player::load(){
ifstream S;
S.open("SAVE.bin", ios::binary | ios::in);
S.read((char*)(&Strg), sizeof(Strg));
S.read((char*)(&Def), sizeof(Def));
S.read((char*)(&Agil), sizeof(Agil));
S.read((char*)(&Exp), sizeof(Exp));
S.read((char*)(&Exp), sizeof(Exp));
S.read((char*)(&Gold), sizeof(Gold));
S.read((char*)(&Lvl), sizeof(Lvl));
S.close();
if (! S){
cout << "File could not be loaded!\n";
}
}
void Player::lose_h(int n){
Health -= n;
}
void Player::set_h(){
Health = 50;
}
|