{"action":"opened","issue":{"url":"https://api.github.com/repos/timgurto/mmo/issues/121","labels_url":"https://api.github.com/repos/timgurto/mmo/issues/121/labels{/name}","comments_url":"https://api.github.com/repos/timgurto/mmo/issues/121/comments","events_url":"https://api.github.com/repos/timgurto/mmo/issues/121/events","html_url":"https://github.com/timgurto/mmo/issues/121","id":108228614,"number":121,"title":"Make objects' resources generic","user":{"login":"timgurto","id":842394,"avatar_url":"https://avatars.githubusercontent.com/u/842394?v=3","gravatar_id":"","url":"https://api.github.com/users/timgurto","html_url":"https://github.com/timgurto","followers_url":"https://api.github.com/users/timgurto/followers","following_url":"https://api.github.com/users/timgurto/following{/other_user}","gists_url":"https://api.github.com/users/timgurto/gists{/gist_id}","starred_url":"https://api.github.com/users/timgurto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timgurto/subscriptions","organizations_url":"https://api.github.com/users/timgurto/orgs","repos_url":"https://api.github.com/users/timgurto/repos","events_url":"https://api.github.com/users/timgurto/events{/privacy}","received_events_url":"https://api.github.com/users/timgurto/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-24T22:49:34Z","updated_at":"2015-09-24T22:49:34Z","closed_at":null,"body":"Instead of `size_t wood` in `Object` and `ObjectType`:\r\n - `ObjectType`s should define a new class for resources, and store a map of them (`map<id, ??>`, containing:\r\n  - The mean and standard deviation of the quantity of each resource that should be generated when the object is created\r\n  - The mean and standard deviation of the amount of each resource that should be given to a user when gathered.\r\n - Instead of a simple function to remove one wood from an object, an item type should be selected at random from those remaining in the object, and the quantity awarded should be randomized based on the mean and SD specified above.\r\n\r\n===Example===\r\nA \"tree\" `ObjectType` contains the following:\r\n - \"wood\", `initMean` = 7`, `initSD` = 2, `gatherMean` = 1, `gatherSD` = 0\r\n - \"leaf\", `initMean` = 15, `initSD` = 4, `gatherMean` = 4, `gatherSD` = 2\r\n - \"apples\", `initMean` = 3, ``initSD` = 1, `gatherMean` = 1, `gatherSD` = 0\r\n\r\nA tree object is generated, using each item's `initMean` and `initSD`.  The initial resources it generates are:\r\n - 8 wood\r\n - 10 leaves\r\n - 2 apples\r\n\r\nWhen gathered, an item type needs to be chosen.  This is a weighted random choice, best visualized by laying the remaining resources out in a long line:\r\n\r\n`  w   w   w   w   w   w   w   w   l   l   l   l   l   l   l   l   l   l   a   a`  \r\n`  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20`\r\n\r\nThe tree contains 20 items in total.  To select a type, a random number should be generated between 1 and 20, and the line counted along that number.  Let's say the number 10 was generated.  The 10th item in the list is leaves, and so that is what will be gathered.\r\n\r\nNow that we know what type of item is to be gathered, we need to determine the quantity.  The `gatherMean` and `gatherSD` associated with leaves are 4 and 2 respectively.  If these give a value of 5, then 5 leaves should be removed from the tree and given to the user (or as many as the tree has left, if fewer) (or as many as the player's inventory can fit, if fewer).\r\n\r\nSo, from an initial stock of 8 wood, 10 leaves and 2 apples, the following gathers might be observed:\r\n - (initial) `wwwwwwwwllllllllllaa`\r\n - 5 leaves, leaving `wwwwwwwwlllllaa`\r\n - 1 wood, leaving `wwwwwwwwlllllaa`\r\n - 1 wood, leaving `wwwwwwwlllllaa`\r\n - 1 wood, leaving `wwwwwwlllllaa`\r\n - 1 wood, leaving `wwwwwlllllaa`\r\n - 1 apple, leaving `wwwwwllllla`\r\n - 1 wood, leaving `wwwwllllla`\r\n - 3 leaves, leaving `wwwwlla`\r\n - 1 wood, leaving `wwwlla`\r\n - 1 apple, leaving `wwwll`\r\n - 1 wood, leaving `wwll`\r\n - 6 leaves, leaving `ww`\r\n - 1 wood, leaving `w`\r\n - 1 wood"}}