Menu
News
All News
Dungeons & Dragons
Level Up: Advanced 5th Edition
Pathfinder
Starfinder
Warhammer
2d20 System
Year Zero Engine
Industry News
Reviews
Dragon Reflections
White Dwarf Reflections
Columns
Weekly Digests
Weekly News Digest
Freebies, Sales & Bundles
RPG Print News
RPG Crowdfunding News
Game Content
ENterplanetary DimENsions
Mythological Figures
Opinion
Worlds of Design
Peregrine's Nest
RPG Evolution
Other Columns
From the Freelancing Frontline
Monster ENcyclopedia
WotC/TSR Alumni Look Back
4 Hours w/RSD (Ryan Dancey)
The Road to 3E (Jonathan Tweet)
Greenwood's Realms (Ed Greenwood)
Drawmij's TSR (Jim Ward)
Community
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Resources
Wiki
Pages
Latest activity
Media
New media
New comments
Search media
Downloads
Latest reviews
Search resources
EN Publishing
Store
EN5ider
Adventures in ZEITGEIST
Awfully Cheerful Engine
What's OLD is NEW
Judge Dredd & The Worlds Of 2000AD
War of the Burning Sky
Level Up: Advanced 5E
Events & Releases
Upcoming Events
Private Events
Featured Events
Socials!
EN Publishing
Twitter
BlueSky
Facebook
Instagram
EN World
BlueSky
YouTube
Facebook
Twitter
Twitch
Podcast
Features
Top 5 RPGs Compiled Charts 2004-Present
Adventure Game Industry Market Research Summary (RPGs) V1.0
Ryan Dancey: Acquiring TSR
Q&A With Gary Gygax
D&D Rules FAQs
TSR, WotC, & Paizo: A Comparative History
D&D Pronunciation Guide
Million Dollar TTRPG Kickstarters
Tabletop RPG Podcast Hall of Fame
Eric Noah's Unofficial D&D 3rd Edition News
D&D in the Mainstream
D&D & RPG History
About Morrus
Log in
Register
What's new
Search
Search
Search titles only
By:
Forums & Topics
Forum List
Latest Posts
Forum list
*Dungeons & Dragons
Level Up: Advanced 5th Edition
D&D Older Editions
*TTRPGs General
*Pathfinder & Starfinder
EN Publishing
*Geek Talk & Media
Search forums
Chat/Discord
Menu
Log in
Register
Install the app
Install
Community
General Tabletop Discussion
*Geek Talk & Media
d20 die roll string parser and roller in C#
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="azhrei_fje" data-source="post: 4104678" data-attributes="member: 12966"><p>Thank you for posting your code! I don't know C#, but I have a mild curiosity of what the language looks like, so I appreciate having a class that I can understand its function. <img src="https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f642.png" class="smilie smilie--emoji" loading="lazy" width="64" height="64" alt=":)" title="Smile :)" data-smilie="1"data-shortname=":)" /></p><p></p><p>Having said that, I would like to point out that in a true object-oriented design, this implementation would likely need to change somewhat.</p><p></p><p>For example, the class should not be deciding how the data is returned to the caller. Instead, the caller should register a "callback" function and your class would then call that function either multiple times with each die result passed as a parameter each time, or a single time with a list of values passed as an array/linked list/etc.</p><p></p><p>I can explain further, if you'd like, or you can check out the book <em>Design Patterns</em> by the Gang of Four (the only one I can ever remember is Gamma; look it up on Amazon thought and you'll find it quickly). One of the chapters is on the Observer/Observable design pattern and that pattern is a really good idea for a dice rolling class. In fact, when I teach OOA&D and get to chapter on design patterns, I often use the dice roller as an example of this pattern. Taken to its logical extreme, the output is completely decoupled from the class itself, allowing an entire hierarchy of classes which implement the callback method.</p><p></p><p>Anyway, as I mentioned at the beginning, thanks for the code snippet. I'm looking forward to perusing it in detail. <img src="https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f642.png" class="smilie smilie--emoji" loading="lazy" width="64" height="64" alt=":)" title="Smile :)" data-smilie="1"data-shortname=":)" /></p></blockquote><p></p>
[QUOTE="azhrei_fje, post: 4104678, member: 12966"] Thank you for posting your code! I don't know C#, but I have a mild curiosity of what the language looks like, so I appreciate having a class that I can understand its function. :) Having said that, I would like to point out that in a true object-oriented design, this implementation would likely need to change somewhat. For example, the class should not be deciding how the data is returned to the caller. Instead, the caller should register a "callback" function and your class would then call that function either multiple times with each die result passed as a parameter each time, or a single time with a list of values passed as an array/linked list/etc. I can explain further, if you'd like, or you can check out the book [i]Design Patterns[/i] by the Gang of Four (the only one I can ever remember is Gamma; look it up on Amazon thought and you'll find it quickly). One of the chapters is on the Observer/Observable design pattern and that pattern is a really good idea for a dice rolling class. In fact, when I teach OOA&D and get to chapter on design patterns, I often use the dice roller as an example of this pattern. Taken to its logical extreme, the output is completely decoupled from the class itself, allowing an entire hierarchy of classes which implement the callback method. Anyway, as I mentioned at the beginning, thanks for the code snippet. I'm looking forward to perusing it in detail. :) [/QUOTE]
Insert quotes…
Verification
Post reply
Community
General Tabletop Discussion
*Geek Talk & Media
d20 die roll string parser and roller in C#
Top