Skip to content

Commit 65180aa

Browse files
committed
2 parents 1ac7847 + 1e12d94 commit 65180aa

3 files changed

Lines changed: 35 additions & 7 deletions

File tree

FileExport.hpp

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,39 @@
11
#pragma once
22
#include <fstream>
33
#include <vector>
4-
#include "Eintrag.hpp"
4+
#include "player.hpp"
5+
#include "tile.hpp"
56

6-
inline void exportFile(std::vector<eintrag> *vec){
7-
std::ofstream csv ("Telefonbuch.csv");
7+
inline void exportFile(std::vector<tile> *vec){
8+
std::ofstream csv ("Tiles.csv");
89

9-
for(eintrag e : *vec){
10-
csv<<e.nachname<<";"<<e.vorname<<";"<<e.telefonnummer<<"\n";
10+
for(tile t : *vec){
11+
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<<";"<<t.color<<";"<<t.tileName<<";"<<t.shortName<<"\n";
1112
}
1213
csv.close();
14+
}
15+
16+
inline void exportFile(std::vector<player> *vec){
17+
std::ofstream csv ("Players.csv");
18+
std::ofstream ownedStreetsFile ("OwnedStreets.csv");
19+
20+
for(player p : *vec){
21+
csv<<p.playerId<<";"<<p.symbol<<";"<<p.name<<";"<<p.money<<";"<<p.currentPosition<<";"<<p.jailed<<";"<<p.color<<";"<<p.jailCounter<<";"<<p.jailFreeCard<<";"<<p.bankrupt<<"\n";
22+
for (int street : p.ownedStreets){
23+
ownedStreetsFile<<p.playerId<<";"<<street<<"\n";
24+
}
25+
}
26+
csv.close();
27+
}
28+
29+
inline void exportFile(int freeParkingMoney, int currentPlayerTurn, std::vector<std::size_t> turnOrder){
30+
std::ofstream csv ("otherData.csv");
31+
32+
csv<<freeParkingMoney<<"\n";
33+
csv<<currentPlayerTurn<<"\n";
34+
for(std::size_t i : turnOrder){
35+
csv<<i<<";";
36+
}
37+
csv<<"\n";
38+
csv.close();
1339
}

monopoly.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ const std::string RESET_COLOR = "\033[0m";
8383
#include "player.hpp"
8484
#include "tile.hpp"
8585
#include "card.hpp"
86+
#include "FileExport.hpp"
87+
#include "FileImport.hpp"
8688
std::vector<tile> gameBoard;
8789
std::vector<player> players;
8890
std::vector<card> communityCards;

player.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
#include <algorithm>
1212

1313
typedef struct player{
14+
int playerId;
15+
std::string symbol;
1416
std::string name;
1517
bool jailed;
1618
int money;
1719
int currentPosition;
18-
int playerId;
1920
std::vector<int> ownedStreets;
20-
std::string symbol;
2121
ColorGroup color;
2222
int jailCounter;
2323
int jailFreeCard;

0 commit comments

Comments
 (0)