{"id":17540148,"url":"https://github.com/kiliankoe/d20","last_synced_at":"2025-03-29T04:32:17.025Z","repository":{"id":63914578,"uuid":"207507557","full_name":"kiliankoe/D20","owner":"kiliankoe","description":"🎲 Evaluate dice notation in Swift","archived":false,"fork":false,"pushed_at":"2020-01-24T13:41:28.000Z","size":42,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-03T16:16:18.544Z","etag":null,"topics":["cli","dice","dice-notation","dice-roller","dnd","tabletop"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kiliankoe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-10T08:40:21.000Z","updated_at":"2023-01-18T19:11:28.000Z","dependencies_parsed_at":"2023-01-14T13:30:59.890Z","dependency_job_id":null,"html_url":"https://github.com/kiliankoe/D20","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiliankoe%2FD20","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiliankoe%2FD20/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiliankoe%2FD20/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiliankoe%2FD20/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kiliankoe","download_url":"https://codeload.github.com/kiliankoe/D20/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246140566,"owners_count":20729797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","dice","dice-notation","dice-roller","dnd","tabletop"],"created_at":"2024-10-20T22:08:32.512Z","updated_at":"2025-03-29T04:32:17.006Z","avatar_url":"https://github.com/kiliankoe.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1\u003eD20\n\u003cimg src=\"https://user-images.githubusercontent.com/2625584/64739158-95fb6c00-d4f1-11e9-886d-e43e9d4d21a0.png\" align=\"right\" width=\"128\" /\u003e\n\u003c/h1\u003e\n\nNeed to evaluate [dice notation](https://en.wikipedia.org/wiki/Dice_notation) in Swift? This package is for you.\n\n\n\n### Examples\n\n```swift\nlet roll = Roll(\"1d20\")!.roll()\nroll.result\n// $R0: Int = 18\n\nlet roll = Roll(\"3d8+1d6\")!.roll()\nroll.result\n// $R0: Int = 19\nroll.expression\n// $R1: String = \"1+6+7+5\"\n\n// Percentage die shorthand is also supported.\nlet roll = Roll(\"d%\")\n\nD(20).average\n// $R0: Double = 10.5\n```\n\nThe rest of the API is pretty self-explanatory. `D`ice and `Roll`s have attributes for accessing the max, half and average values of their rolls. Use the `roll()` function to actually throw the dice on both of these types and get some random values. \n\n\n\n### CLI\n\nThis package also includes a small CLI to roll the dice directly in your terminal.\n\n```bash\n$ d20 2d6+4\n# 14 (6+4)+4\n\n$ alias dagger='d20 1d4+2'\n$ dagger\n# 6 (4)+2\n# CRIT!\n\n# Invoke it without an argument to enter REPL mode.\n$ d20\n\u003e d4\n3 (3)\n\u003e 2d4\n6 (2+4)\n```\n\n\n\nInstalling it is easy. Just run the following after cloning the repo.\n\n```bash\n$ swift build -c release\n$ cp .build/release/d20 /usr/local/bin/d20\n```\n\n\n\n#### Logo Credits\n\n[D20](https://thenounproject.com/search/?q=d20\u0026i=2453700) by Lonnie Tapscott from the Noun Project\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiliankoe%2Fd20","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkiliankoe%2Fd20","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiliankoe%2Fd20/lists"}