-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileExport.hpp
More file actions
39 lines (33 loc) · 1.32 KB
/
FileExport.hpp
File metadata and controls
39 lines (33 loc) · 1.32 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
#pragma once
#include <fstream>
#include <vector>
#include "player.hpp"
#include "tile.hpp"
void exportFile(std::vector<tile>& tiles){
std::ofstream csv ("Tiles.csv");
for(tile t : tiles){
csv<<t.tileIndex<<";"<<t.ownerId<<";"<<t.buyable<<";"<<t.buyPrice<<";"<<t.isMortgaged<<";"<<t.housePrice<<";"<<t.upgradeStage<<";"<<t.price0<<";"<<t.price1<<";"<<t.price2<<";"<<t.price3<<";"<<t.price4<<";"<<t.price5<<";"<<static_cast<int>(t.color)<<";"<<t.tileName<<";"<<t.shortName<<"\n";
}
csv.close();
}
void exportFile(std::vector<player>& players){
std::ofstream csv ("Players.csv");
std::ofstream ownedStreetsFile ("OwnedStreets.csv");
for(player p : players){
csv<<p.playerId<<";"<<p.symbol<<";"<<p.name<<";"<<p.money<<";"<<p.currentPosition<<";"<<p.jailed<<";"<<static_cast<int>(p.color)<<";"<<p.jailCounter<<";"<<p.jailFreeCard<<";"<<p.bankrupt<<"\n";
for (int street : p.ownedStreets){
ownedStreetsFile<<p.playerId<<";"<<street<<"\n";
}
}
csv.close();
ownedStreetsFile.close();
}
void exportFile(int freeParkingMoney, int currentPlayerTurn, std::vector<std::size_t>& turnOrder){
std::ofstream csv ("otherData.csv");
csv<<freeParkingMoney<<"\n";
csv<<currentPlayerTurn<<"\n";
for(int i : turnOrder){
csv<<i<<"\n";
}
csv.close();
}