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="FormerlyDickensC" data-source="post: 4104816" data-attributes="member: 53954"><p>my apologies for getting on a rant here, buuuuuuuuut.......</p><p></p><p>dude...it rolls dice.....and its a static method, thats all. </p><p></p><p>using delegates (or call back methods) is overkill for such a simple piece of code. The vast majority of the code is simply parsing the string. If you want to have the method sometimes return an <strong>int </strong>and sometimes a <strong>string</strong>..then just overload it or create multiple methods..or use the '<strong>out</strong>' keyword. (my fault, you said you weren't familiar with C#). But I think you said you were writing a WPF app, so you should be familiar with .NET, right? or was that someone else?</p><p></p><p>but the point of the method was to parse the die roll string..you mentioned that your delegate would pass in each die roll or an array of rolls...well if they're already parsed from the input string then there is no need for the method. just instantiate your own <strong>Random </strong>object and roll directly. </p><p></p><p>I'm fully versed in the Observer pattern, I must argue that your use of it as you explained is not what I would consider the most efficient. Calling various delegate (or callback) methods is the <u>same</u> as calling overloads, and is unnecessary. It introduces complexity where there need be none. </p><p></p><p> .....ummmm no. maybe if we were dealing with a <u>highly diversified object model</u> then that would be appropriate. But we're not. We're dealing with strings, int's, and one little method. </p><p></p><p>Look, I'm not trying to pick an argument or be a pain or a jerk. But implementing the pattern in the way you explain is really not necessary or helpful. </p><p></p><p>Bottom Line: There are only two possible types the caller would want the data returned as....a string or an int. The best answer, imo, is simply return as int and let the caller cast to string as needed. Simple. Elegant. </p><p></p><p>No need for delegates. Besides, the caller is not observing anything. The caller is not waiting for something to happen on the part of the dice roller. The caller simply wants a result from his given input. Applying the Observer pattern is nonsensical in this case. </p><p></p><p>Be careful how you implement grand ideas. Sometimes, you just need to do what you have to do, and no more. Plus I didn't write the code or algorithm, I translated it from Java that another person posted here. I left the algorithm intact. Remember the major point of the method is to parse text. Take a look at my explanation in the first post. </p><p></p><p>If you teach analysis and design, answer this question that I came across: <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?siteid=1&PostID=2994966" target="_blank">http://forums.microsoft.com/MSDN/ShowPost.aspx?siteid=1&PostID=2994966</a></p><p></p><p>Again, I apologize for my rudeness if that is how I'm coming across. It is not my intention.</p></blockquote><p></p>
[QUOTE="FormerlyDickensC, post: 4104816, member: 53954"] my apologies for getting on a rant here, buuuuuuuuut....... dude...it rolls dice.....and its a static method, thats all. using delegates (or call back methods) is overkill for such a simple piece of code. The vast majority of the code is simply parsing the string. If you want to have the method sometimes return an [B]int [/B]and sometimes a [B]string[/B]..then just overload it or create multiple methods..or use the '[B]out[/B]' keyword. (my fault, you said you weren't familiar with C#). But I think you said you were writing a WPF app, so you should be familiar with .NET, right? or was that someone else? but the point of the method was to parse the die roll string..you mentioned that your delegate would pass in each die roll or an array of rolls...well if they're already parsed from the input string then there is no need for the method. just instantiate your own [B]Random [/B]object and roll directly. I'm fully versed in the Observer pattern, I must argue that your use of it as you explained is not what I would consider the most efficient. Calling various delegate (or callback) methods is the [U]same[/U] as calling overloads, and is unnecessary. It introduces complexity where there need be none. .....ummmm no. maybe if we were dealing with a [U]highly diversified object model[/U] then that would be appropriate. But we're not. We're dealing with strings, int's, and one little method. Look, I'm not trying to pick an argument or be a pain or a jerk. But implementing the pattern in the way you explain is really not necessary or helpful. Bottom Line: There are only two possible types the caller would want the data returned as....a string or an int. The best answer, imo, is simply return as int and let the caller cast to string as needed. Simple. Elegant. No need for delegates. Besides, the caller is not observing anything. The caller is not waiting for something to happen on the part of the dice roller. The caller simply wants a result from his given input. Applying the Observer pattern is nonsensical in this case. Be careful how you implement grand ideas. Sometimes, you just need to do what you have to do, and no more. Plus I didn't write the code or algorithm, I translated it from Java that another person posted here. I left the algorithm intact. Remember the major point of the method is to parse text. Take a look at my explanation in the first post. If you teach analysis and design, answer this question that I came across: [URL=http://forums.microsoft.com/MSDN/ShowPost.aspx?siteid=1&PostID=2994966]http://forums.microsoft.com/MSDN/ShowPost.aspx?siteid=1&PostID=2994966[/URL] Again, I apologize for my rudeness if that is how I'm coming across. It is not my intention. [/QUOTE]
Insert quotes…
Verification
Post reply
Community
General Tabletop Discussion
*Geek Talk & Media
d20 die roll string parser and roller in C#
Top