aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/entities.h24
-rw-r--r--src/world.cpp16
-rw-r--r--xml/playerSpawnHill1.xml2
3 files changed, 32 insertions, 10 deletions
diff --git a/include/entities.h b/include/entities.h
index 545f0a4..a1723ee 100644
--- a/include/entities.h
+++ b/include/entities.h
@@ -55,19 +55,35 @@ enum BUILD_SUB{
class BuySell{
public:
int member;
+ // 0 = Buy/Sell
+ // 1 = Trade
union{
struct{
- std::string item1;
- std::string item2;
+ std::string item;
+ std::string itemt;
}trade;
struct{
- enum type{BUY,SELL};
+ int type;
+ // 0 = buy
+ // 1 = sell
std::string item;
int price;
}cost;
};
- BuySell(){}
+ BuySell(int typ, std::string itm, int prc){
+ this->cost.type = typ;
+ this->cost.item = itm;
+ this->cost.price = prc;
+ this->member = 0;
+ }
+ BuySell(std::string itm, std::string itmt){
+ this->trade.item = itm;
+ this->trade.itemt = itmt;
+ this->member = 1;
+ }
~BuySell(){}
+ BuySell(const BuySell&){}
+ BuySell(){}
};
class World;
diff --git a/src/world.cpp b/src/world.cpp
index 80ddc5a..32a3153 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -1446,6 +1446,7 @@ World *loadWorldFromXMLNoSave(const char *path){
while(vil){
name = vil->Name();
randx = 0;
+ //static BuySell bs;
/**
* READS DATA ABOUT STRUCTURE CONTAINED IN VILLAGE
@@ -1469,10 +1470,17 @@ World *loadWorldFromXMLNoSave(const char *path){
(char*)vil->Attribute("texture"),
ptr);
tmp->addMerchant(0,100);
- if(!strcmp(name,"buy")){
- std::cout << "Buying";
- }else if(!strcmp(name,"sell")){
- std::cout << "Selling";
+ if(vil->FirstChildElement("buy")){
+ std::cout << "Buy" << std::endl;
+ /*bs.member = 0;
+ bs.cost.type = 0;
+ bs.cost.item = vil->FirstChildElement("buy")->Attribute("item");
+ bs.cost.price =vil->FirstChildElement("buy")->IntAttribute("cost");*/
+ tmp->merchant.back()->bsinv.push_back({0,"Dank MayMay",420});
+ }if(vil->FirstChildElement("sell")){
+ std::cout << "Sell" << std::endl;
+ }if(vil->FirstChildElement("trade")){
+ std::cout << "Trade" << std::endl;
}
strcpy(tmp->merchant.back()->name,"meme");
diff --git a/xml/playerSpawnHill1.xml b/xml/playerSpawnHill1.xml
index 2cac743..370cc03 100644
--- a/xml/playerSpawnHill1.xml
+++ b/xml/playerSpawnHill1.xml
@@ -17,8 +17,6 @@
<stall type="market" texture="assets/style/classic/stall.png">
<buy item="Dank MayMay" cost="420"/>
<sell item="Dank MayMay" cost="666"/>
- </stall>
- <stall type="trader" texture="assets/style/classic/stall.png">
<trade item="Dank MayMay" item1="Sword"/>
</stall>
</village>