{"action":"created","comment":{"url":"https://api.github.com/repos/Terasology/GooKeeper/pulls/comments/200982251","pull_request_review_id":135393138,"id":200982251,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMDk4MjI1MQ==","diff_hunk":"@@ -75,32 +93,120 @@\n     @In\n     private NUIManager nuiManager;\n \n+    @In\n+    private BlockCommands blockCommands;\n+\n+    @In\n+    private ItemCommands itemCommands;\n+\n     private static final Logger logger = LoggerFactory.getLogger(EconomySystem.class);\n     private Random random = new FastRandom();\n     private static final float baseEntranceFee = 100f;\n     private static final float baseVisitFee = 10f;\n-    private static boolean setHud = false;\n \n     @Override\n     public void initialise() {\n     }\n \n+    @ReceiveEvent\n+    public void onPlayerSpawn(OnPlayerSpawnedEvent event, EntityRef player, InventoryComponent inventory) {\n+        if (player.hasComponent(EconomyComponent.class)) {\n+            nuiManager.getHUD().addHUDElement(\"PlayerHud\");\n+        }\n+    }\n+\n     @Override\n     public void shutdown() {\n     }\n \n     @Override\n     public void update(float delta) {\n-        // Have to add the wallet hud this way since adding in within initialise() results in the economy component to be null\n-        if (!setHud) {\n-            for (EntityRef wallet : entityManager.getEntitiesWith(EconomyComponent.class)) {\n-                EconomyComponent economyComponent = wallet.getComponent(EconomyComponent.class);\n-                if (economyComponent != null) {\n-                    nuiManager.getHUD().addHUDElement(\"PlayerHud\");\n-                    setHud = true;\n+    }\n+\n+    /**\n+     * This command can be used to purchase utility blocks (such as pen blocks, visit blocks, etc.)\n+     *\n+     * @param client\n+     * @param itemPrefabName\n+     * @param amount\n+     * @param shapeUriParam\n+     * @return\n+     */\n+    @Command(shortDescription = \"Purchase utility blocks\",\n+            requiredPermission = PermissionManager.NO_PERMISSION)\n+    public String purchase(@Sender EntityRef client,\n+                           @CommandParam(\"prefabId or blockName\") String itemPrefabName,\n+                           @CommandParam(value = \"amount\", required = false) Integer amount,\n+                           @CommandParam(value = \"blockShapeName\", required = false) String shapeUriParam) {\n+        EntityRef player = client.getComponent(ClientComponent.class).character;\n+        EconomyComponent economyComponent = player.getComponent(EconomyComponent.class);\n+\n+        int quantityParam = amount != null ? amount : 16;\n+\n+        if (economyComponent.playerWalletCredit - (quantityParam * Assets.getPrefab(itemPrefabName + \"Fenced\").get().getComponent(PurchasableComponent.class).basePrice) > 0f) {\n+            String message = blockCommands.giveBlock(client, itemPrefabName, amount, shapeUriParam);\n+            if (message != null) {\n+                economyComponent.playerWalletCredit -= quantityParam * Assets.getPrefab(itemPrefabName + \"Fenced\").get().getComponent(PurchasableComponent.class).basePrice;\n+                player.saveComponent(economyComponent);\n+                return \"Successfully purchased \" + itemPrefabName;\n+            } else {\n+                return \"Couldn't find requested block.\";\n+            }\n+        } else {\n+            return \"You dont have sufficient balance to purchase.\";\n+        }\n+    }\n+\n+    /**\n+     * This command can be used to purchase utility blocks (such as pen blocks, visit blocks, etc.)\n+     *\n+     * @param client\n+     * @param itemPrefabName\n+     * @param amount\n+     * @param shapeUriParam\n+     * @return\n+     */\n+    @Command(shortDescription = \"Purchase utility blocks\",\n+            requiredPermission = PermissionManager.NO_PERMISSION)\n+    public String upgrade(@Sender EntityRef client,\n+                           @CommandParam(\"prefabId or blockName\") String itemPrefabName) {\n+        EntityRef player = client.getComponent(ClientComponent.class).character;\n+        EconomyComponent economyComponent = player.getComponent(EconomyComponent.class);\n+\n+        for (int i = 0; i < inventoryManager.getNumSlots(player); i++) {\n+            EntityRef itemInSlot = inventoryManager.getItemInSlot(player, i);\n+            DisplayNameComponent displayNameComponent = itemInSlot.getComponent(DisplayNameComponent.class);\n+\n+            if (displayNameComponent != null && displayNameComponent.name.equals(itemPrefabName)) {\n+                UpgradableComponent upgradableComponent = itemInSlot.getComponent(UpgradableComponent.class);\n+                if (upgradableComponent != null && (economyComponent.playerWalletCredit - (upgradableComponent.baseUpgradePrice * upgradableComponent.currentTier) > 0f)) {\n+                    upgradeByType(itemInSlot, upgradableComponent);\n+                    economyComponent.playerWalletCredit -= upgradableComponent.baseUpgradePrice * upgradableComponent.currentTier;\n+                    player.saveComponent(economyComponent);\n+                    itemInSlot.saveComponent(upgradableComponent);\n+                    return \"Successfully upgraded your \" + displayNameComponent.name;\n+                } else {\n+                    return \"You dont have sufficient balance to upgrade the item.\";\n                 }\n             }\n         }\n+\n+        return \"Couldn't find the requested item to upgrade.\";\n+    }\n+\n+    private void upgradeByType (EntityRef item, UpgradableComponent upgradableComponent) {\n+        upgradableComponent.currentTier ++;\n+\n+        if (item.hasComponent(SlimePodItemComponent.class)) {","path":"src/main/java/org/terasology/gookeeper/system/EconomySystem.java","position":177,"original_position":177,"commit_id":"279f76e894d9ec329e660f2f67422f53602d29df","original_commit_id":"279f76e894d9ec329e660f2f67422f53602d29df","user":{"login":"l0ftyWhizZ","id":13732949,"node_id":"MDQ6VXNlcjEzNzMyOTQ5","avatar_url":"https://avatars3.githubusercontent.com/u/13732949?v=4","gravatar_id":"","url":"https://api.github.com/users/l0ftyWhizZ","html_url":"https://github.com/l0ftyWhizZ","followers_url":"https://api.github.com/users/l0ftyWhizZ/followers","following_url":"https://api.github.com/users/l0ftyWhizZ/following{/other_user}","gists_url":"https://api.github.com/users/l0ftyWhizZ/gists{/gist_id}","starred_url":"https://api.github.com/users/l0ftyWhizZ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/l0ftyWhizZ/subscriptions","organizations_url":"https://api.github.com/users/l0ftyWhizZ/orgs","repos_url":"https://api.github.com/users/l0ftyWhizZ/repos","events_url":"https://api.github.com/users/l0ftyWhizZ/events{/privacy}","received_events_url":"https://api.github.com/users/l0ftyWhizZ/received_events","type":"User","site_admin":false},"body":"Yeah currently it is hard-coded to just work with the two items, and hence definitely not the ideal way to do it. \r\nYeah, a unified upgrade module seems great 😄 ","created_at":"2018-07-09T12:24:18Z","updated_at":"2018-07-09T12:24:18Z","html_url":"https://github.com/Terasology/GooKeeper/pull/3#discussion_r200982251","pull_request_url":"https://api.github.com/repos/Terasology/GooKeeper/pulls/3","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/Terasology/GooKeeper/pulls/comments/200982251"},"html":{"href":"https://github.com/Terasology/GooKeeper/pull/3#discussion_r200982251"},"pull_request":{"href":"https://api.github.com/repos/Terasology/GooKeeper/pulls/3"}},"in_reply_to_id":200860596},"pull_request":{"url":"https://api.github.com/repos/Terasology/GooKeeper/pulls/3","id":199074654,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk5MDc0NjU0","html_url":"https://github.com/Terasology/GooKeeper/pull/3","diff_url":"https://github.com/Terasology/GooKeeper/pull/3.diff","patch_url":"https://github.com/Terasology/GooKeeper/pull/3.patch","issue_url":"https://api.github.com/repos/Terasology/GooKeeper/issues/3","number":3,"state":"open","locked":false,"title":"Economy System - Upgrade/Purchase items","user":{"login":"l0ftyWhizZ","id":13732949,"node_id":"MDQ6VXNlcjEzNzMyOTQ5","avatar_url":"https://avatars3.githubusercontent.com/u/13732949?v=4","gravatar_id":"","url":"https://api.github.com/users/l0ftyWhizZ","html_url":"https://github.com/l0ftyWhizZ","followers_url":"https://api.github.com/users/l0ftyWhizZ/followers","following_url":"https://api.github.com/users/l0ftyWhizZ/following{/other_user}","gists_url":"https://api.github.com/users/l0ftyWhizZ/gists{/gist_id}","starred_url":"https://api.github.com/users/l0ftyWhizZ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/l0ftyWhizZ/subscriptions","organizations_url":"https://api.github.com/users/l0ftyWhizZ/orgs","repos_url":"https://api.github.com/users/l0ftyWhizZ/repos","events_url":"https://api.github.com/users/l0ftyWhizZ/events{/privacy}","received_events_url":"https://api.github.com/users/l0ftyWhizZ/received_events","type":"User","site_admin":false},"body":"- [x] Add methods to debit appropriate balance when purchasing utility blocks/upgrading equipment\r\n- [x] Add console commands for upgrading and purchasing items","created_at":"2018-07-03T20:25:18Z","updated_at":"2018-07-09T12:24:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8019ee30a7e352f622156b2f4ce90e00ff7f6591","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Terasology/GooKeeper/pulls/3/commits","review_comments_url":"https://api.github.com/repos/Terasology/GooKeeper/pulls/3/comments","review_comment_url":"https://api.github.com/repos/Terasology/GooKeeper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Terasology/GooKeeper/issues/3/comments","statuses_url":"https://api.github.com/repos/Terasology/GooKeeper/statuses/279f76e894d9ec329e660f2f67422f53602d29df","head":{"label":"Terasology:upgrade-item","ref":"upgrade-item","sha":"279f76e894d9ec329e660f2f67422f53602d29df","user":{"login":"Terasology","id":4554375,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ1NTQzNzU=","avatar_url":"https://avatars1.githubusercontent.com/u/4554375?v=4","gravatar_id":"","url":"https://api.github.com/users/Terasology","html_url":"https://github.com/Terasology","followers_url":"https://api.github.com/users/Terasology/followers","following_url":"https://api.github.com/users/Terasology/following{/other_user}","gists_url":"https://api.github.com/users/Terasology/gists{/gist_id}","starred_url":"https://api.github.com/users/Terasology/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Terasology/subscriptions","organizations_url":"https://api.github.com/users/Terasology/orgs","repos_url":"https://api.github.com/users/Terasology/repos","events_url":"https://api.github.com/users/Terasology/events{/privacy}","received_events_url":"https://api.github.com/users/Terasology/received_events","type":"Organization","site_admin":false},"repo":{"id":132491828,"node_id":"MDEwOlJlcG9zaXRvcnkxMzI0OTE4Mjg=","name":"GooKeeper","full_name":"Terasology/GooKeeper","owner":{"login":"Terasology","id":4554375,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ1NTQzNzU=","avatar_url":"https://avatars1.githubusercontent.com/u/4554375?v=4","gravatar_id":"","url":"https://api.github.com/users/Terasology","html_url":"https://github.com/Terasology","followers_url":"https://api.github.com/users/Terasology/followers","following_url":"https://api.github.com/users/Terasology/following{/other_user}","gists_url":"https://api.github.com/users/Terasology/gists{/gist_id}","starred_url":"https://api.github.com/users/Terasology/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Terasology/subscriptions","organizations_url":"https://api.github.com/users/Terasology/orgs","repos_url":"https://api.github.com/users/Terasology/repos","events_url":"https://api.github.com/users/Terasology/events{/privacy}","received_events_url":"https://api.github.com/users/Terasology/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Terasology/GooKeeper","description":"GooKeeper is a new gameplay mod bringing a new \"Slime Rancher\"ish experience!","fork":false,"url":"https://api.github.com/repos/Terasology/GooKeeper","forks_url":"https://api.github.com/repos/Terasology/GooKeeper/forks","keys_url":"https://api.github.com/repos/Terasology/GooKeeper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Terasology/GooKeeper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Terasology/GooKeeper/teams","hooks_url":"https://api.github.com/repos/Terasology/GooKeeper/hooks","issue_events_url":"https://api.github.com/repos/Terasology/GooKeeper/issues/events{/number}","events_url":"https://api.github.com/repos/Terasology/GooKeeper/events","assignees_url":"https://api.github.com/repos/Terasology/GooKeeper/assignees{/user}","branches_url":"https://api.github.com/repos/Terasology/GooKeeper/branches{/branch}","tags_url":"https://api.github.com/repos/Terasology/GooKeeper/tags","blobs_url":"https://api.github.com/repos/Terasology/GooKeeper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Terasology/GooKeeper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Terasology/GooKeeper/git/refs{/sha}","trees_url":"https://api.github.com/repos/Terasology/GooKeeper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Terasology/GooKeeper/statuses/{sha}","languages_url":"https://api.github.com/repos/Terasology/GooKeeper/languages","stargazers_url":"https://api.github.com/repos/Terasology/GooKeeper/stargazers","contributors_url":"https://api.github.com/repos/Terasology/GooKeeper/contributors","subscribers_url":"https://api.github.com/repos/Terasology/GooKeeper/subscribers","subscription_url":"https://api.github.com/repos/Terasology/GooKeeper/subscription","commits_url":"https://api.github.com/repos/Terasology/GooKeeper/commits{/sha}","git_commits_url":"https://api.github.com/repos/Terasology/GooKeeper/git/commits{/sha}","comments_url":"https://api.github.com/repos/Terasology/GooKeeper/comments{/number}","issue_comment_url":"https://api.github.com/repos/Terasology/GooKeeper/issues/comments{/number}","contents_url":"https://api.github.com/repos/Terasology/GooKeeper/contents/{+path}","compare_url":"https://api.github.com/repos/Terasology/GooKeeper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Terasology/GooKeeper/merges","archive_url":"https://api.github.com/repos/Terasology/GooKeeper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Terasology/GooKeeper/downloads","issues_url":"https://api.github.com/repos/Terasology/GooKeeper/issues{/number}","pulls_url":"https://api.github.com/repos/Terasology/GooKeeper/pulls{/number}","milestones_url":"https://api.github.com/repos/Terasology/GooKeeper/milestones{/number}","notifications_url":"https://api.github.com/repos/Terasology/GooKeeper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Terasology/GooKeeper/labels{/name}","releases_url":"https://api.github.com/repos/Terasology/GooKeeper/releases{/id}","deployments_url":"https://api.github.com/repos/Terasology/GooKeeper/deployments","created_at":"2018-05-07T17:05:25Z","updated_at":"2018-07-03T16:42:27Z","pushed_at":"2018-07-08T23:33:47Z","git_url":"git://github.com/Terasology/GooKeeper.git","ssh_url":"git@github.com:Terasology/GooKeeper.git","clone_url":"https://github.com/Terasology/GooKeeper.git","svn_url":"https://github.com/Terasology/GooKeeper","homepage":"","size":644,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":3,"default_branch":"master"}},"base":{"label":"Terasology:master","ref":"master","sha":"d9a2abe8f57ce0e498044c3bd99222983c058e58","user":{"login":"Terasology","id":4554375,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ1NTQzNzU=","avatar_url":"https://avatars1.githubusercontent.com/u/4554375?v=4","gravatar_id":"","url":"https://api.github.com/users/Terasology","html_url":"https://github.com/Terasology","followers_url":"https://api.github.com/users/Terasology/followers","following_url":"https://api.github.com/users/Terasology/following{/other_user}","gists_url":"https://api.github.com/users/Terasology/gists{/gist_id}","starred_url":"https://api.github.com/users/Terasology/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Terasology/subscriptions","organizations_url":"https://api.github.com/users/Terasology/orgs","repos_url":"https://api.github.com/users/Terasology/repos","events_url":"https://api.github.com/users/Terasology/events{/privacy}","received_events_url":"https://api.github.com/users/Terasology/received_events","type":"Organization","site_admin":false},"repo":{"id":132491828,"node_id":"MDEwOlJlcG9zaXRvcnkxMzI0OTE4Mjg=","name":"GooKeeper","full_name":"Terasology/GooKeeper","owner":{"login":"Terasology","id":4554375,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQ1NTQzNzU=","avatar_url":"https://avatars1.githubusercontent.com/u/4554375?v=4","gravatar_id":"","url":"https://api.github.com/users/Terasology","html_url":"https://github.com/Terasology","followers_url":"https://api.github.com/users/Terasology/followers","following_url":"https://api.github.com/users/Terasology/following{/other_user}","gists_url":"https://api.github.com/users/Terasology/gists{/gist_id}","starred_url":"https://api.github.com/users/Terasology/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Terasology/subscriptions","organizations_url":"https://api.github.com/users/Terasology/orgs","repos_url":"https://api.github.com/users/Terasology/repos","events_url":"https://api.github.com/users/Terasology/events{/privacy}","received_events_url":"https://api.github.com/users/Terasology/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Terasology/GooKeeper","description":"GooKeeper is a new gameplay mod bringing a new \"Slime Rancher\"ish experience!","fork":false,"url":"https://api.github.com/repos/Terasology/GooKeeper","forks_url":"https://api.github.com/repos/Terasology/GooKeeper/forks","keys_url":"https://api.github.com/repos/Terasology/GooKeeper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Terasology/GooKeeper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Terasology/GooKeeper/teams","hooks_url":"https://api.github.com/repos/Terasology/GooKeeper/hooks","issue_events_url":"https://api.github.com/repos/Terasology/GooKeeper/issues/events{/number}","events_url":"https://api.github.com/repos/Terasology/GooKeeper/events","assignees_url":"https://api.github.com/repos/Terasology/GooKeeper/assignees{/user}","branches_url":"https://api.github.com/repos/Terasology/GooKeeper/branches{/branch}","tags_url":"https://api.github.com/repos/Terasology/GooKeeper/tags","blobs_url":"https://api.github.com/repos/Terasology/GooKeeper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Terasology/GooKeeper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Terasology/GooKeeper/git/refs{/sha}","trees_url":"https://api.github.com/repos/Terasology/GooKeeper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Terasology/GooKeeper/statuses/{sha}","languages_url":"https://api.github.com/repos/Terasology/GooKeeper/languages","stargazers_url":"https://api.github.com/repos/Terasology/GooKeeper/stargazers","contributors_url":"https://api.github.com/repos/Terasology/GooKeeper/contributors","subscribers_url":"https://api.github.com/repos/Terasology/GooKeeper/subscribers","subscription_url":"https://api.github.com/repos/Terasology/GooKeeper/subscription","commits_url":"https://api.github.com/repos/Terasology/GooKeeper/commits{/sha}","git_commits_url":"https://api.github.com/repos/Terasology/GooKeeper/git/commits{/sha}","comments_url":"https://api.github.com/repos/Terasology/GooKeeper/comments{/number}","issue_comment_url":"https://api.github.com/repos/Terasology/GooKeeper/issues/comments{/number}","contents_url":"https://api.github.com/repos/Terasology/GooKeeper/contents/{+path}","compare_url":"https://api.github.com/repos/Terasology/GooKeeper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Terasology/GooKeeper/merges","archive_url":"https://api.github.com/repos/Terasology/GooKeeper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Terasology/GooKeeper/downloads","issues_url":"https://api.github.com/repos/Terasology/GooKeeper/issues{/number}","pulls_url":"https://api.github.com/repos/Terasology/GooKeeper/pulls{/number}","milestones_url":"https://api.github.com/repos/Terasology/GooKeeper/milestones{/number}","notifications_url":"https://api.github.com/repos/Terasology/GooKeeper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Terasology/GooKeeper/labels{/name}","releases_url":"https://api.github.com/repos/Terasology/GooKeeper/releases{/id}","deployments_url":"https://api.github.com/repos/Terasology/GooKeeper/deployments","created_at":"2018-05-07T17:05:25Z","updated_at":"2018-07-03T16:42:27Z","pushed_at":"2018-07-08T23:33:47Z","git_url":"git://github.com/Terasology/GooKeeper.git","ssh_url":"git@github.com:Terasology/GooKeeper.git","clone_url":"https://github.com/Terasology/GooKeeper.git","svn_url":"https://github.com/Terasology/GooKeeper","homepage":"","size":644,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Terasology/GooKeeper/pulls/3"},"html":{"href":"https://github.com/Terasology/GooKeeper/pull/3"},"issue":{"href":"https://api.github.com/repos/Terasology/GooKeeper/issues/3"},"comments":{"href":"https://api.github.com/repos/Terasology/GooKeeper/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/Terasology/GooKeeper/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/Terasology/GooKeeper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Terasology/GooKeeper/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/Terasology/GooKeeper/statuses/279f76e894d9ec329e660f2f67422f53602d29df"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"l0ftyWhizZ"}}