resolve auction card IDs at load time
This commit is contained in:
+7
-7
@@ -2805,8 +2805,8 @@ void send_card_auction_if_all_clients_ready(
|
||||
num_cards = min<uint16_t>(num_cards, 0x14);
|
||||
|
||||
uint64_t distribution_size = 0;
|
||||
for (const auto& it : s->ep3_card_auction_pool) {
|
||||
distribution_size += it.second.first;
|
||||
for (const auto& e : s->ep3_card_auction_pool) {
|
||||
distribution_size += e.probability;
|
||||
}
|
||||
|
||||
auto card_index = (l->flags & Lobby::Flag::IS_EP3_TRIAL)
|
||||
@@ -2817,12 +2817,12 @@ void send_card_auction_if_all_clients_ready(
|
||||
cmd.points_available = s->ep3_card_auction_points;
|
||||
for (size_t z = 0; z < num_cards; z++) {
|
||||
uint64_t v = random_object<uint64_t>() % distribution_size;
|
||||
for (const auto& it : s->ep3_card_auction_pool) {
|
||||
if (v >= it.second.first) {
|
||||
v -= it.second.first;
|
||||
for (const auto& e : s->ep3_card_auction_pool) {
|
||||
if (v >= e.probability) {
|
||||
v -= e.probability;
|
||||
} else {
|
||||
cmd.entries[z].card_id = card_index->definition_for_name(it.first)->def.card_id.load();
|
||||
cmd.entries[z].min_price = it.second.second;
|
||||
cmd.entries[z].card_id = e.card_id;
|
||||
cmd.entries[z].min_price = e.min_price;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+15
-8
@@ -640,13 +640,13 @@ void ServerState::parse_config(const JSON& json) {
|
||||
this->ep3_card_auction_max_size = 0;
|
||||
}
|
||||
|
||||
try {
|
||||
for (const auto& it : json.at("CardAuctionPool").as_dict()) {
|
||||
const auto& card_name = it.first;
|
||||
const auto& card_cfg_json = it.second.as_list();
|
||||
this->ep3_card_auction_pool.emplace(card_name, make_pair(card_cfg_json.at(0), card_cfg_json.at(1)));
|
||||
}
|
||||
} catch (const out_of_range&) {
|
||||
for (const auto& it : json.at("CardAuctionPool").as_dict()) {
|
||||
this->ep3_card_auction_pool.emplace_back(
|
||||
CardAuctionPoolEntry{
|
||||
.probability = it.second.at(0),
|
||||
.card_id = 0,
|
||||
.min_price = it.second.at(1),
|
||||
.card_name = it.first});
|
||||
}
|
||||
|
||||
set_log_levels_from_json(json.get("LogLevels", JSON::dict_type()));
|
||||
@@ -829,7 +829,14 @@ void ServerState::load_ep3_data() {
|
||||
}
|
||||
|
||||
config_log.info("Resolving Episode 3 card auction pool");
|
||||
TODO;
|
||||
for (auto& e : this->ep3_card_auction_pool) {
|
||||
try {
|
||||
const auto& card = this->ep3_card_index->definition_for_name(e.card_name);
|
||||
e.card_id = card->def.card_id;
|
||||
} catch (const out_of_range&) {
|
||||
throw runtime_error(string_printf("Ep3 card \"%s\" does not exist", e.card_name.c_str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ServerState::load_quest_index() {
|
||||
|
||||
+7
-1
@@ -92,7 +92,13 @@ struct ServerState {
|
||||
uint16_t ep3_card_auction_points;
|
||||
uint16_t ep3_card_auction_min_size;
|
||||
uint16_t ep3_card_auction_max_size;
|
||||
std::unordered_map<std::string, std::pair<uint64_t, uint16_t>> ep3_card_auction_pool;
|
||||
struct CardAuctionPoolEntry {
|
||||
uint64_t probability;
|
||||
uint16_t card_id;
|
||||
uint16_t min_price;
|
||||
std::string card_name;
|
||||
};
|
||||
std::vector<CardAuctionPoolEntry> ep3_card_auction_pool;
|
||||
|
||||
std::shared_ptr<LicenseManager> license_manager;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user