forked from townforge/townforge
add auctioneer badge - number of auctions created
This commit is contained in:
parent
d9b6eb4de0
commit
3aea47aebc
1
GameData/TB/cc/badges/hammer-drop.svg
Normal file
1
GameData/TB/cc/badges/hammer-drop.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#fff" d="M19.5 12.28c88.718 14.188 164.126 68.854 216.78 159.314C191.738 127.057 146.123 88.34 94.626 61.75c32.85 23.08 62.377 54.866 90.844 94.656C134.237 105.183 81.956 62.756 18.187 41.28v35.314c60.134 16.64 118.398 62.562 163.968 129.312l-.125.063 22.19 38.405 157.936-91.188-22.187-38.406-.064.032c-38.38-69.37-83.042-95.124-106.72-102.53H190.47c62.75 22.53 105.37 69.704 133.78 142.28-50.118-70.19-122.52-123.542-202.656-142.28H19.5zm153.97 40.47c52.194 21.552 97.93 66.563 110.843 121.594L173.47 52.75zM348.5 182.656l-111.97 64.656L321.25 394l111.97-64.656-84.72-146.688zm72.97 33.563l-24 13.843 19.78 34.28 24-13.874-19.78-34.25zm-168.345 97.186L83.47 411.344l19.81 34.312 169.626-97.97-19.78-34.28zM465.53 332.22l-157.936 91.186 22.22 38.47 157.936-91.188-22.22-38.47zM62.72 412.81l-35.94 20.75 28.907 50.063 35.938-20.75-28.906-50.063z"/></svg>
|
After Width: | Height: | Size: 928 B |
@ -750,6 +750,26 @@ bool BlockchainDB::change_cc_account_gold_smelted(uint32_t id, int64_t delta)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BlockchainDB::change_cc_account_num_auctions_created(uint32_t id, int32_t delta)
|
||||
{
|
||||
cryptonote::cc_account_data_t ad;
|
||||
if (!get_cc_account_data(id, ad))
|
||||
return false;
|
||||
if (delta > 0)
|
||||
{
|
||||
if ((uint32_t)delta > std::numeric_limits<uint32_t>::max() - ad.num_auctions_created)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((uint32_t)-delta > ad.num_auctions_created)
|
||||
return false;
|
||||
}
|
||||
ad.num_auctions_created += delta;
|
||||
set_cc_account_data(id, ad);
|
||||
return true;
|
||||
}
|
||||
|
||||
void BlockchainDB::reset_stats()
|
||||
{
|
||||
num_calls = 0;
|
||||
|
@ -201,6 +201,7 @@ struct cc_account_data_t
|
||||
uint64_t prestige;
|
||||
uint32_t num_runestones;
|
||||
uint64_t gold_smelted;
|
||||
uint32_t num_auctions_created;
|
||||
|
||||
// script state city owner
|
||||
std::map<uint32_t, std::tuple<uint32_t, uint32_t, uint32_t, std::map<std::string, uint64_t>>> background_script_states;
|
||||
@ -2235,6 +2236,7 @@ public:
|
||||
bool change_cc_flag_fishing(uint32_t id, int8_t delta_ticks, int32_t delta_fish);
|
||||
bool change_cc_account_num_runestones(uint32_t id, int32_t delta);
|
||||
bool change_cc_account_gold_smelted(uint32_t id, int64_t delta);
|
||||
bool change_cc_account_num_auctions_created(uint32_t id, int32_t delta);
|
||||
|
||||
virtual void remove_block() = 0;
|
||||
|
||||
|
@ -655,6 +655,7 @@ typedef struct mdb_cc_account_data
|
||||
uint64_t prestige;
|
||||
uint32_t num_runestones;
|
||||
uint64_t gold_smelted;
|
||||
uint32_t num_auctions_created;
|
||||
serializable_map<uint32_t, std::tuple<uint32_t, uint32_t, uint32_t, serializable_map<std::string, uint64_t>>> background_script_states;
|
||||
std::vector<uint32_t> textures_created;
|
||||
std::vector<uint32_t> textures_licenced;
|
||||
@ -692,6 +693,7 @@ typedef struct mdb_cc_account_data
|
||||
VARINT_FIELD(prestige)
|
||||
VARINT_FIELD(num_runestones)
|
||||
VARINT_FIELD(gold_smelted)
|
||||
VARINT_FIELD(num_auctions_created)
|
||||
FIELD(background_script_states)
|
||||
FIELD(textures_created)
|
||||
FIELD(textures_licenced)
|
||||
@ -5815,6 +5817,7 @@ uint32_t BlockchainLMDB::allocate_new_cc_account(const crypto::public_key &publi
|
||||
ad.prestige = 0;
|
||||
ad.num_runestones = 0;
|
||||
ad.gold_smelted = 0;
|
||||
ad.num_auctions_created = 0;
|
||||
|
||||
k.mv_data = (void*)&account_id;
|
||||
k.mv_size = sizeof(account_id);
|
||||
@ -5973,6 +5976,7 @@ bool BlockchainLMDB::get_cc_account_data(uint32_t id, cc_account_data_t &data) c
|
||||
data.prestige = ad.prestige;
|
||||
data.num_runestones = ad.num_runestones;
|
||||
data.gold_smelted = ad.gold_smelted;
|
||||
data.num_auctions_created = ad.num_auctions_created;
|
||||
|
||||
for (auto &e: ad.background_script_states)
|
||||
{
|
||||
@ -6049,6 +6053,7 @@ void BlockchainLMDB::set_cc_account_data(uint32_t id, const cc_account_data_t &a
|
||||
cad.prestige = ad.prestige;
|
||||
cad.num_runestones = ad.num_runestones;
|
||||
cad.gold_smelted = ad.gold_smelted;
|
||||
cad.num_auctions_created = ad.num_auctions_created;
|
||||
|
||||
for (auto &e: ad.background_script_states)
|
||||
{
|
||||
@ -6912,6 +6917,7 @@ bool BlockchainLMDB::for_all_cc_accounts(std::function<bool(const cc_account_dat
|
||||
data.prestige = ad.prestige;
|
||||
data.num_runestones = ad.num_runestones;
|
||||
data.gold_smelted = ad.gold_smelted;
|
||||
data.num_auctions_created = ad.num_auctions_created;
|
||||
|
||||
for (auto &e: ad.background_script_states)
|
||||
{
|
||||
@ -10543,6 +10549,7 @@ bool BlockchainLMDB::get_as_cc_account(const cryptonote::blobdata &bd, cc_accoun
|
||||
data.prestige = ad.prestige;
|
||||
data.num_runestones = ad.num_runestones;
|
||||
data.gold_smelted = ad.gold_smelted;
|
||||
data.num_auctions_created = ad.num_auctions_created;
|
||||
for (auto &e: ad.background_script_states)
|
||||
{
|
||||
const uint32_t script = e.first;
|
||||
|
@ -505,6 +505,14 @@ static const struct
|
||||
{NULL, NULL, NULL, NULL, NULL},
|
||||
[](uint64_t score) { return cryptonote::print_money(score); }
|
||||
},
|
||||
{
|
||||
"Auctioneer",
|
||||
"Number of auctions created",
|
||||
"hammer-drop",
|
||||
{3, 10, 25, 75, 250},
|
||||
{NULL, NULL, NULL, NULL, NULL},
|
||||
NULL
|
||||
},
|
||||
};
|
||||
|
||||
namespace cc
|
||||
|
@ -83,6 +83,7 @@ enum cc_badge_t: uint32_t
|
||||
BADGE_PATRON,
|
||||
BADGE_SCRIBE,
|
||||
BADGE_HEPHAESTOS,
|
||||
BADGE_AUCTIONEER,
|
||||
|
||||
NUM_PREDEFINED_BADGES,
|
||||
BADGE_LAST_PREDEFINED = NUM_PREDEFINED_BADGES - 1,
|
||||
|
@ -164,6 +164,8 @@ bool cc_command_handler_create_auction::execute(cryptonote::BlockchainDB &db, co
|
||||
db.reserve_cc_account(create_auction.cc_account, FORECLOSURE_ACCOUNT, 0, reserved_items);
|
||||
}
|
||||
|
||||
CHECK_AND_ASSERT_MES(db.change_cc_account_num_auctions_created(create_auction.cc_account, 1), false, "Failed to update num_auctions_created");
|
||||
|
||||
switch (create_auction.type)
|
||||
{
|
||||
case cc::auction_t::type_flag:
|
||||
@ -215,6 +217,8 @@ bool cc_command_handler_create_auction::revert(cryptonote::BlockchainDB &db, con
|
||||
CHECK_AND_ASSERT_MES(id != 0, false, "Failed to find auction");
|
||||
db.remove_cc_auction(id);
|
||||
|
||||
CHECK_AND_ASSERT_MES(db.change_cc_account_num_auctions_created(create_auction.cc_account, -1), false, "Failed to update num_auctions_created");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2459,6 +2459,7 @@ static void add_cities(const BlockchainDB &db, uint8_t version, cc_command_game_
|
||||
awarded |= award_badge(db, cg, events, ad, BADGE_PATRON, ad.textures_licenced.size(), badge_scores);
|
||||
awarded |= award_badge(db, cg, events, ad, BADGE_SCRIBE, ad.num_runestones, badge_scores);
|
||||
awarded |= award_badge(db, cg, events, ad, BADGE_HEPHAESTOS, ad.gold_smelted, badge_scores);
|
||||
awarded |= award_badge(db, cg, events, ad, BADGE_AUCTIONEER, ad.num_auctions_created, badge_scores);
|
||||
|
||||
if (awarded)
|
||||
badge_awarded.insert(account_id);
|
||||
|
@ -3944,6 +3944,7 @@ namespace cryptonote
|
||||
res.level = cc::get_badge_score(data.badges).second;
|
||||
res.num_runestones = data.num_runestones;
|
||||
res.gold_smelted = data.gold_smelted;
|
||||
res.num_auctions_created = data.num_auctions_created;
|
||||
for (const auto &e: data.background_script_states)
|
||||
{
|
||||
res.background_script_states.push_back({e.first, std::get<0>(e.second), std::get<1>(e.second), std::get<2>(e.second), {}});
|
||||
|
@ -3012,6 +3012,7 @@ namespace cryptonote
|
||||
uint32_t level;
|
||||
uint32_t num_runestones;
|
||||
uint32_t gold_smelted;
|
||||
uint32_t num_auctions_created;
|
||||
std::vector<background_script_state_t> background_script_states;
|
||||
std::vector<uint32_t> textures_created;
|
||||
std::vector<uint32_t> textures_licenced;
|
||||
@ -3051,6 +3052,7 @@ namespace cryptonote
|
||||
KV_SERIALIZE(level)
|
||||
KV_SERIALIZE(num_runestones)
|
||||
KV_SERIALIZE(gold_smelted)
|
||||
KV_SERIALIZE(num_auctions_created)
|
||||
KV_SERIALIZE(background_script_states)
|
||||
KV_SERIALIZE(textures_created)
|
||||
KV_SERIALIZE(textures_licenced)
|
||||
|
Loading…
Reference in New Issue
Block a user