{"action":"created","comment":{"url":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/comments/37707174","id":37707174,"diff_hunk":"@@ -0,0 +1,157 @@\n+/*\n+* Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>\n+* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>\n+*\n+* This program is free software; you can redistribute it and/or modify it\n+* under the terms of the GNU General Public License as published by the\n+* Free Software Foundation; either version 2 of the License, or (at your\n+* option) any later version.\n+*\n+* This program is distributed in the hope that it will be useful, but WITHOUT\n+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\n+* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\n+* more details.\n+*\n+* You should have received a copy of the GNU General Public License along\n+* with this program. If not, see <http://www.gnu.org/licenses/>.\n+*/\n+\n+#ifndef BLACK_MARKET_H\n+#define BLACK_MARKET_H\n+\n+#include \"Common.h\"\n+#include \"ObjectGuid.h\"\n+#include \"BlackMarketPackets.h\"\n+#include \"ItemPackets.h\"\n+#include \"Item.h\"\n+\n+enum BlackMarketError              // Extracted from client\n+{\n+    ERR_BMAH_OK = 0,\n+    ERR_BMAH_ITEM_NOT_FOUND = 1,\n+    ERR_BMAH_ALREADY_BID = 2,\n+    ERR_BMAH_HIGHER_BID = 4,\n+    ERR_BMAH_DATABASE_ERROR = 6,\n+    ERR_BMAH_NOT_ENOUGH_MONEY = 7,\n+    ERR_BMAH_RESTRICTED_ACCOUNT_TRIAL = 9\n+};\n+\n+enum BMAHMailAuctionAnswers\n+{\n+    BMAH_AUCTION_OUTBID = 0,\n+    BMAH_AUCTION_WON = 1,\n+};\n+\n+const static uint64 BMAH_MAX_BID = 1000000LL * GOLD;\n+\n+struct BlackMarketTemplate\n+{\n+    int32 MarketID;\n+    int32 SellerNPC;\n+    int32 Quantity;\n+    uint64 MinBid;\n+    time_t Duration;\n+    float Chance;\n+    WorldPackets::Item::ItemInstance Item;\n+\n+    // Helpers\n+    bool LoadFromDB(Field* fields); // TO-Do implement checks\n+}; \n+\n+class BlackMarketEntry\n+{\n+public:\n+    int32 MarketId = 0;\n+    uint64 CurrentBid = 0;\n+    int32 NumBids = 0;\n+    ObjectGuid::LowType Bidder = 0;\n+\n+    void Update(time_t newTimeOfUpdate);\n+    void Initialize(int32 marketId)\n+    {\n+        MarketId = marketId;\n+        m_secondsRemaining = GetTemplate()->Duration;\n+    }\n+\n+    BlackMarketTemplate* GetTemplate() const;\n+    int32 GetMarketId() const { return GetTemplate()->MarketID; }\n+\n+    time_t GetSecondsRemaining() const; // Get seconds remaining relative to now\n+    time_t GetExpirationTime() const;\n+    bool IsCompleted() const;\n+\n+    void DeleteFromDB(SQLTransaction& trans) const;\n+    void SaveToDB(SQLTransaction& trans) const;\n+    bool LoadFromDB(Field* fields);\n+\n+    uint64 GetMinIncrement() const { return (CurrentBid / 20) - ((CurrentBid / 20) % GOLD)  ; } //5% increase every bid (has to be round gold value)\n+    bool ValidateBid(uint64 bid) const;\n+    void PlaceBid(uint64 bid, Player* player, SQLTransaction& trans);\n+\n+    std::string BuildAuctionMailSubject(BMAHMailAuctionAnswers response) const;\n+    std::string BuildAuctionMailBody();\n+\n+    void MailSent() { m_mailSent = true; } // Set when mail has been sent\n+    bool GetMailSent() { return m_mailSent; }\n+\n+private:\n+    time_t m_secondsRemaining;\n+\n+    bool m_mailSent = false;\n+    bool m_newBid = false; \n+};\n+\n+class BlackMarketMgr\n+{\n+  private:\n+    BlackMarketMgr() { }\n+    ~BlackMarketMgr()\n+    {\n+        for (BlackMarketEntryMap::iterator itr = mAuctions.begin(); itr != mAuctions.end(); ++itr)\n+            delete itr->second;\n+        for (BlackMarketTemplateMap::iterator itr = mTemplates.begin(); itr != mTemplates.end(); ++itr)\n+            delete itr->second;\n+    }\n+\n+  public:\n+    static BlackMarketMgr* instance()\n+    {\n+        static BlackMarketMgr instance;\n+        return &instance;\n+    }\n+\n+    typedef std::map<int32, BlackMarketEntry*> BlackMarketEntryMap;\n+    typedef std::map<int32, BlackMarketTemplate*> BlackMarketTemplateMap;\n+\n+    // Load templates first\n+    void LoadTemplates();\n+    void LoadAuctions();\n+\n+    void Update(bool updateTime = false);\n+    void RefreshAuctions();\n+    time_t GetLastUpdate() { return mLastUpdate; }\n+        \n+    bool IsEnabled() const;\n+\n+    void BuildItemsResponse(WorldPackets::BlackMarket::BlackMarketRequestItemsResult &packet, Player *player);\n+    \n+    BlackMarketEntry*     GetAuctionByID(int32 marketId) const;\n+    BlackMarketTemplate* GetTemplateByID(int32 marketId) const;\n+\n+    void AddAuction(BlackMarketEntry* auction);\n+    void AddTemplate(BlackMarketTemplate* templ);\n+\n+    void SendAuctionWonMail(BlackMarketEntry* entry, SQLTransaction& trans);\n+    void SendAuctionOutbidMail(BlackMarketEntry* entry, SQLTransaction& trans); // Call before incrementing bid\n+\n+  private:\n+","path":"src/server/game/BlackMarket/BlackMarketMgr.h","position":148,"original_position":148,"commit_id":"3cc71f6c1508167143986dfd3de41d036cb45eea","original_commit_id":"3cc71f6c1508167143986dfd3de41d036cb45eea","user":{"login":"DDuarte","id":530940,"avatar_url":"https://avatars.githubusercontent.com/u/530940?v=3","gravatar_id":"","url":"https://api.github.com/users/DDuarte","html_url":"https://github.com/DDuarte","followers_url":"https://api.github.com/users/DDuarte/followers","following_url":"https://api.github.com/users/DDuarte/following{/other_user}","gists_url":"https://api.github.com/users/DDuarte/gists{/gist_id}","starred_url":"https://api.github.com/users/DDuarte/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DDuarte/subscriptions","organizations_url":"https://api.github.com/users/DDuarte/orgs","repos_url":"https://api.github.com/users/DDuarte/repos","events_url":"https://api.github.com/users/DDuarte/events{/privacy}","received_events_url":"https://api.github.com/users/DDuarte/received_events","type":"User","site_admin":false},"body":"These private members should start with _ (m is not needed)","created_at":"2015-08-23T16:17:18Z","updated_at":"2015-08-23T16:17:18Z","html_url":"https://github.com/TrinityCore/TrinityCore/pull/15340#discussion_r37707174","pull_request_url":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/15340","_links":{"self":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/comments/37707174"},"html":{"href":"https://github.com/TrinityCore/TrinityCore/pull/15340#discussion_r37707174"},"pull_request":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/15340"}}},"pull_request":{"url":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/15340","id":43123698,"html_url":"https://github.com/TrinityCore/TrinityCore/pull/15340","diff_url":"https://github.com/TrinityCore/TrinityCore/pull/15340.diff","patch_url":"https://github.com/TrinityCore/TrinityCore/pull/15340.patch","issue_url":"https://api.github.com/repos/TrinityCore/TrinityCore/issues/15340","number":15340,"state":"open","locked":false,"title":"Core/Blackmarket: Implemented black market","user":{"login":"Gigi1237","id":5721873,"avatar_url":"https://avatars.githubusercontent.com/u/5721873?v=3","gravatar_id":"","url":"https://api.github.com/users/Gigi1237","html_url":"https://github.com/Gigi1237","followers_url":"https://api.github.com/users/Gigi1237/followers","following_url":"https://api.github.com/users/Gigi1237/following{/other_user}","gists_url":"https://api.github.com/users/Gigi1237/gists{/gist_id}","starred_url":"https://api.github.com/users/Gigi1237/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gigi1237/subscriptions","organizations_url":"https://api.github.com/users/Gigi1237/orgs","repos_url":"https://api.github.com/users/Gigi1237/repos","events_url":"https://api.github.com/users/Gigi1237/events{/privacy}","received_events_url":"https://api.github.com/users/Gigi1237/received_events","type":"User","site_admin":false},"body":"Implemented the Black Market auction house.\r\nWorks as it's supposed to from my testing. Cannot be 100% sure as I have never seen it on retail.\r\n\r\nPlease give me feedback if anything is wrong or badly implemented so I can fix it and more importantly so I can learn from my mistakes.","created_at":"2015-08-23T16:08:30Z","updated_at":"2015-08-23T16:17:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b42c76595ba7fa16a49501daf6c8faedde4c1b80","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/15340/commits","review_comments_url":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/15340/comments","review_comment_url":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/TrinityCore/TrinityCore/issues/15340/comments","statuses_url":"https://api.github.com/repos/TrinityCore/TrinityCore/statuses/3cc71f6c1508167143986dfd3de41d036cb45eea","head":{"label":"Gigi1237:black_market_pr","ref":"black_market_pr","sha":"3cc71f6c1508167143986dfd3de41d036cb45eea","user":{"login":"Gigi1237","id":5721873,"avatar_url":"https://avatars.githubusercontent.com/u/5721873?v=3","gravatar_id":"","url":"https://api.github.com/users/Gigi1237","html_url":"https://github.com/Gigi1237","followers_url":"https://api.github.com/users/Gigi1237/followers","following_url":"https://api.github.com/users/Gigi1237/following{/other_user}","gists_url":"https://api.github.com/users/Gigi1237/gists{/gist_id}","starred_url":"https://api.github.com/users/Gigi1237/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gigi1237/subscriptions","organizations_url":"https://api.github.com/users/Gigi1237/orgs","repos_url":"https://api.github.com/users/Gigi1237/repos","events_url":"https://api.github.com/users/Gigi1237/events{/privacy}","received_events_url":"https://api.github.com/users/Gigi1237/received_events","type":"User","site_admin":false},"repo":{"id":28492377,"name":"TrinityCore","full_name":"Gigi1237/TrinityCore","owner":{"login":"Gigi1237","id":5721873,"avatar_url":"https://avatars.githubusercontent.com/u/5721873?v=3","gravatar_id":"","url":"https://api.github.com/users/Gigi1237","html_url":"https://github.com/Gigi1237","followers_url":"https://api.github.com/users/Gigi1237/followers","following_url":"https://api.github.com/users/Gigi1237/following{/other_user}","gists_url":"https://api.github.com/users/Gigi1237/gists{/gist_id}","starred_url":"https://api.github.com/users/Gigi1237/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gigi1237/subscriptions","organizations_url":"https://api.github.com/users/Gigi1237/orgs","repos_url":"https://api.github.com/users/Gigi1237/repos","events_url":"https://api.github.com/users/Gigi1237/events{/privacy}","received_events_url":"https://api.github.com/users/Gigi1237/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Gigi1237/TrinityCore","description":"TrinityCore Open Source MMO Framework","fork":true,"url":"https://api.github.com/repos/Gigi1237/TrinityCore","forks_url":"https://api.github.com/repos/Gigi1237/TrinityCore/forks","keys_url":"https://api.github.com/repos/Gigi1237/TrinityCore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Gigi1237/TrinityCore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Gigi1237/TrinityCore/teams","hooks_url":"https://api.github.com/repos/Gigi1237/TrinityCore/hooks","issue_events_url":"https://api.github.com/repos/Gigi1237/TrinityCore/issues/events{/number}","events_url":"https://api.github.com/repos/Gigi1237/TrinityCore/events","assignees_url":"https://api.github.com/repos/Gigi1237/TrinityCore/assignees{/user}","branches_url":"https://api.github.com/repos/Gigi1237/TrinityCore/branches{/branch}","tags_url":"https://api.github.com/repos/Gigi1237/TrinityCore/tags","blobs_url":"https://api.github.com/repos/Gigi1237/TrinityCore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Gigi1237/TrinityCore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Gigi1237/TrinityCore/git/refs{/sha}","trees_url":"https://api.github.com/repos/Gigi1237/TrinityCore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Gigi1237/TrinityCore/statuses/{sha}","languages_url":"https://api.github.com/repos/Gigi1237/TrinityCore/languages","stargazers_url":"https://api.github.com/repos/Gigi1237/TrinityCore/stargazers","contributors_url":"https://api.github.com/repos/Gigi1237/TrinityCore/contributors","subscribers_url":"https://api.github.com/repos/Gigi1237/TrinityCore/subscribers","subscription_url":"https://api.github.com/repos/Gigi1237/TrinityCore/subscription","commits_url":"https://api.github.com/repos/Gigi1237/TrinityCore/commits{/sha}","git_commits_url":"https://api.github.com/repos/Gigi1237/TrinityCore/git/commits{/sha}","comments_url":"https://api.github.com/repos/Gigi1237/TrinityCore/comments{/number}","issue_comment_url":"https://api.github.com/repos/Gigi1237/TrinityCore/issues/comments{/number}","contents_url":"https://api.github.com/repos/Gigi1237/TrinityCore/contents/{+path}","compare_url":"https://api.github.com/repos/Gigi1237/TrinityCore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Gigi1237/TrinityCore/merges","archive_url":"https://api.github.com/repos/Gigi1237/TrinityCore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Gigi1237/TrinityCore/downloads","issues_url":"https://api.github.com/repos/Gigi1237/TrinityCore/issues{/number}","pulls_url":"https://api.github.com/repos/Gigi1237/TrinityCore/pulls{/number}","milestones_url":"https://api.github.com/repos/Gigi1237/TrinityCore/milestones{/number}","notifications_url":"https://api.github.com/repos/Gigi1237/TrinityCore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Gigi1237/TrinityCore/labels{/name}","releases_url":"https://api.github.com/repos/Gigi1237/TrinityCore/releases{/id}","created_at":"2014-12-25T22:09:40Z","updated_at":"2014-12-25T23:54:16Z","pushed_at":"2015-08-23T16:06:51Z","git_url":"git://github.com/Gigi1237/TrinityCore.git","ssh_url":"git@github.com:Gigi1237/TrinityCore.git","clone_url":"https://github.com/Gigi1237/TrinityCore.git","svn_url":"https://github.com/Gigi1237/TrinityCore","homepage":"http://www.trinitycore.org","size":362285,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"6.x"}},"base":{"label":"TrinityCore:6.x","ref":"6.x","sha":"2b8d77cdf2b6d6c0ea78c4c1681cde0c61f542fc","user":{"login":"TrinityCore","id":539602,"avatar_url":"https://avatars.githubusercontent.com/u/539602?v=3","gravatar_id":"","url":"https://api.github.com/users/TrinityCore","html_url":"https://github.com/TrinityCore","followers_url":"https://api.github.com/users/TrinityCore/followers","following_url":"https://api.github.com/users/TrinityCore/following{/other_user}","gists_url":"https://api.github.com/users/TrinityCore/gists{/gist_id}","starred_url":"https://api.github.com/users/TrinityCore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TrinityCore/subscriptions","organizations_url":"https://api.github.com/users/TrinityCore/orgs","repos_url":"https://api.github.com/users/TrinityCore/repos","events_url":"https://api.github.com/users/TrinityCore/events{/privacy}","received_events_url":"https://api.github.com/users/TrinityCore/received_events","type":"Organization","site_admin":false},"repo":{"id":1204412,"name":"TrinityCore","full_name":"TrinityCore/TrinityCore","owner":{"login":"TrinityCore","id":539602,"avatar_url":"https://avatars.githubusercontent.com/u/539602?v=3","gravatar_id":"","url":"https://api.github.com/users/TrinityCore","html_url":"https://github.com/TrinityCore","followers_url":"https://api.github.com/users/TrinityCore/followers","following_url":"https://api.github.com/users/TrinityCore/following{/other_user}","gists_url":"https://api.github.com/users/TrinityCore/gists{/gist_id}","starred_url":"https://api.github.com/users/TrinityCore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TrinityCore/subscriptions","organizations_url":"https://api.github.com/users/TrinityCore/orgs","repos_url":"https://api.github.com/users/TrinityCore/repos","events_url":"https://api.github.com/users/TrinityCore/events{/privacy}","received_events_url":"https://api.github.com/users/TrinityCore/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/TrinityCore/TrinityCore","description":"TrinityCore Open Source MMO Framework","fork":false,"url":"https://api.github.com/repos/TrinityCore/TrinityCore","forks_url":"https://api.github.com/repos/TrinityCore/TrinityCore/forks","keys_url":"https://api.github.com/repos/TrinityCore/TrinityCore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TrinityCore/TrinityCore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TrinityCore/TrinityCore/teams","hooks_url":"https://api.github.com/repos/TrinityCore/TrinityCore/hooks","issue_events_url":"https://api.github.com/repos/TrinityCore/TrinityCore/issues/events{/number}","events_url":"https://api.github.com/repos/TrinityCore/TrinityCore/events","assignees_url":"https://api.github.com/repos/TrinityCore/TrinityCore/assignees{/user}","branches_url":"https://api.github.com/repos/TrinityCore/TrinityCore/branches{/branch}","tags_url":"https://api.github.com/repos/TrinityCore/TrinityCore/tags","blobs_url":"https://api.github.com/repos/TrinityCore/TrinityCore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TrinityCore/TrinityCore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TrinityCore/TrinityCore/git/refs{/sha}","trees_url":"https://api.github.com/repos/TrinityCore/TrinityCore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TrinityCore/TrinityCore/statuses/{sha}","languages_url":"https://api.github.com/repos/TrinityCore/TrinityCore/languages","stargazers_url":"https://api.github.com/repos/TrinityCore/TrinityCore/stargazers","contributors_url":"https://api.github.com/repos/TrinityCore/TrinityCore/contributors","subscribers_url":"https://api.github.com/repos/TrinityCore/TrinityCore/subscribers","subscription_url":"https://api.github.com/repos/TrinityCore/TrinityCore/subscription","commits_url":"https://api.github.com/repos/TrinityCore/TrinityCore/commits{/sha}","git_commits_url":"https://api.github.com/repos/TrinityCore/TrinityCore/git/commits{/sha}","comments_url":"https://api.github.com/repos/TrinityCore/TrinityCore/comments{/number}","issue_comment_url":"https://api.github.com/repos/TrinityCore/TrinityCore/issues/comments{/number}","contents_url":"https://api.github.com/repos/TrinityCore/TrinityCore/contents/{+path}","compare_url":"https://api.github.com/repos/TrinityCore/TrinityCore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TrinityCore/TrinityCore/merges","archive_url":"https://api.github.com/repos/TrinityCore/TrinityCore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TrinityCore/TrinityCore/downloads","issues_url":"https://api.github.com/repos/TrinityCore/TrinityCore/issues{/number}","pulls_url":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls{/number}","milestones_url":"https://api.github.com/repos/TrinityCore/TrinityCore/milestones{/number}","notifications_url":"https://api.github.com/repos/TrinityCore/TrinityCore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TrinityCore/TrinityCore/labels{/name}","releases_url":"https://api.github.com/repos/TrinityCore/TrinityCore/releases{/id}","created_at":"2010-12-28T23:40:07Z","updated_at":"2015-08-23T11:29:07Z","pushed_at":"2015-08-23T16:08:32Z","git_url":"git://github.com/TrinityCore/TrinityCore.git","ssh_url":"git@github.com:TrinityCore/TrinityCore.git","clone_url":"https://github.com/TrinityCore/TrinityCore.git","svn_url":"https://github.com/TrinityCore/TrinityCore","homepage":"http://www.trinitycore.org","size":855151,"stargazers_count":2937,"watchers_count":2937,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3073,"mirror_url":null,"open_issues_count":1117,"forks":3073,"open_issues":1117,"watchers":2937,"default_branch":"6.x"}},"_links":{"self":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/15340"},"html":{"href":"https://github.com/TrinityCore/TrinityCore/pull/15340"},"issue":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/issues/15340"},"comments":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/issues/15340/comments"},"review_comments":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/15340/comments"},"review_comment":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/pulls/15340/commits"},"statuses":{"href":"https://api.github.com/repos/TrinityCore/TrinityCore/statuses/3cc71f6c1508167143986dfd3de41d036cb45eea"}}}}