kurosio / Teeworlds-MRPG-0.6

Other
6 stars 10 forks source link

Convert the structure to an similar to the database #2

Closed kurosio closed 4 months ago

kurosio commented 1 year ago

Because the very concept of RPG, makes you store a lot of information there are almost 50 tables in the database Future plans are to introduce a personal identifier for MultiworldIdentifiableStaticData<>

For example table from tw_warehouse:

Type ID Name PosX PosY Currency WorldID
database unique string integer integer forgein key -> itemid forgein key -> worldid
impl c++ WarehouseIdentifier char* vec2 -- ref CDataDescription ref CWorldData

I'll leave a note

// example get some object by pos
CWarehouse* pWarehouse = Context->GetWorldData()->GetWarehouse(Pos);

WarehouseIdentifier ID;
CWarehouse* pWarehouse = Context->GetWorldData()->GetWarehouse(ID);

// example what kind of view to stick to 
Context->GetWorldData() # stores all game zone data
Context->GetWorldData()->GetWarehouse(ID) # stores all warehouses
pWarehosue->GetCurrcency() # information about currency
pWarehosue->GetCurrcency()->Info() #information about currency item description
pWarehosue->GetCurrcency()->Info()->GetAttribute(SlotID); # data attributes for items
pWarehosue->GetCurrcency()->Info()->GetAttribute(SlotID)->GetName(); const char* # item name

// get all crafts and required items
Context->GetWorldData()->GetCrafts() # ref ContainerCraftRecipe
for(auto& p : Context->GetWorldData()->GetWarehouse(ID)->GetCrafts())
{
     p.GetRequiredItems() # ref ContainerItems
}

// get all trading slots from warehouse marketplace
Context->GetWorldData()->GetWarehouse(ID)->GetTradingSlots() # ref ContainerTradingSlots
for(auto& p : Context->GetWorldData()->GetWarehouse(ID)->GetTradingSlots())
{
       p.GetPrice(); # integer
       p.GetBuyightItem(); # ref CItem
       p.GetWarehouse(); # ref CWarehouse
       p.GetCurrency(); # ref CItemDescription
}

Gradually it is necessary to reconstruct structures