assign bank item IDs at game join time

This commit is contained in:
Martin Michelsen
2023-12-06 09:46:57 -08:00
parent 713327b0ae
commit 85d0bac5cb
8 changed files with 44 additions and 9 deletions
+8 -1
View File
@@ -479,7 +479,8 @@ void PlayerBank::add_item(const ItemData& item) {
this->num_items++;
}
ItemData PlayerBank::remove_item_by_index(size_t index, uint32_t amount) {
ItemData PlayerBank::remove_item(uint32_t item_id, uint32_t amount) {
size_t index = this->find_item(item_id);
auto& bank_item = this->items[index];
ItemData ret;
@@ -680,6 +681,12 @@ void PlayerBank::sort() {
std::sort(this->items.data(), this->items.data() + this->num_items);
}
void PlayerBank::assign_ids(uint32_t base_id) {
for (size_t z = 0; z < this->num_items; z++) {
this->items[z].data.id = base_id + z;
}
}
BattleRules::BattleRules(const JSON& json) {
static const JSON empty_list = JSON::list();