3.1 KiB
3.1 KiB
Legacy Auctions and Betting
This document covers the auction and betting systems: how auctions open/close,
what resources they trade, and how betting payouts are calculated. References
include legacy/hwe/sammo/Auction*.php, legacy/hwe/func_auction.php, and
legacy/hwe/sammo/Betting.php.
Auction Types and Entry Points
Auction(base class): shared bid logic and close-date extensions.AuctionBuyRice: sell rice for gold.AuctionSellRice: sell gold for rice.AuctionUniqueItem: bids use inheritance points for unique items.processAuction()inlegacy/hwe/func_auction.phpcloses finished auctions.registerAuction()creates neutral (NPC-hosted) buy/sell auctions.
Auction Data Model
Primary tables:
ng_auction: auction metadata (type, target, host, close date, detail).ng_auction_bid: per-bid rows for each auction.
The AuctionInfo and AuctionInfoDetail DTOs are serialized into
ng_auction columns for structured access.
Core Auction Flow
- Open
AuctionBasicResource::openResourceAuction()validates amounts and host resources, then insertsng_auction.AuctionUniqueItem::openItemAuction()checks availability, reserves unique items, and posts a global history notice.
- Bid
- Bids are inserted into
ng_auction_bidand can extend the close date. - Reverse auctions (when
detail->isReverse) sort by lowest bid.
- Bids are inserted into
- Close (
tryFinish()from the concrete auction)- If no bids:
rollbackAuction()returns resources to host and logs. - With bids:
finishAuction()transfers resources, logs, and sends messages.
- If no bids:
- Processing
processAuction()scans auctions pastclose_dateand finishes them.
Unique Item Auctions
- Currency: inheritance points (
ResourceType::inheritancePoint). - Host identity is obfuscated using
genObfuscatedName()and a deterministic shuffled name pool stored ingame_env.obfuscatedNamePool. - Limits and availability are enforced against
GameConst::$allItemsand existing ownership ingeneralrows.
Betting System
Betting is an independent KV-backed system:
Betting::openBetting()storesBettingInfoin KV storage (betting).Betting::bet()inserts or updatesng_bettingrows and charges either gold or inheritance points.Betting::giveReward()distributes payouts to winners (exclusive or shared).
Event actions controlling lifecycle:
OpenNationBetting: opens a nation-strength bet and registers aDESTROY_NATIONevent to close it.FinishNationBetting: evaluates winners when only N nations remain.
RNG Notes
Auction::genObfuscatedName()useshiddenSeed + 'obfuscatedNamePool'to shuffle the name pool once and reuse it fromgame_env.registerAuction()relies on an injected RNG to randomize neutral auctions.
Open Questions / Follow-ups
- The exact schedule for
registerAuction()is outside this file; it is likely called from monthly or timed maintenance. - Unique-item auction close-date extension limits depend on
AuctionUniqueItemconstants andturnterm; verify scenarios that override auction timing.