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
Who knows PHP?
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="Mustrum_Ridcully" data-source="post: 7466912" data-attributes="member: 710"><p>I am not familiar with PHP, unfortunately. </p><p>I am however familiar with programming in general. I can tell you that this is probably not how you want to implement the skills in the long run, since it will be error-prone and hard to work with in the long run.</p><p></p><p>Use Key Value pairs. I am not familiar with PHP, as mentioned, but a brief look here: <a href="http://php.net/manual/en/language.types.array.php" target="_blank">http://php.net/manual/en/language.types.array.php</a> </p><p>suggests that arrays are innately capable of working as such.</p><p></p><p>As key, you could use the skill name, and the value is the skill rating.</p><p></p><p>When the player selects a skill during character creation, you can check (with array_key_exists) if it already has that skill. If not, you just add the new skill with rating 1 (or whatever the base rating is for the first time picking a skill.)</p><p>When the map already contains the kjey, you can instead set the value to the new skill to the one before +1.</p><p></p><p>Pseudo Code (Again, I don't actually program PHP, my current work is mostly C++ and a tiny bit of Python) Except that I forget semicolons and use double quotes where single quotes would be typical or whatever.)</p><p></p><p>if (array_key_exists($selectedSkill, $skills) {</p><p> skills($selectedSkill)=skills($selectedSkill)+1</p><p>} else {</p><p> skills($selectedSkill)=1</p><p>}</p><p></p><p>If you just want to know which skill the players has at all, you can use <em>array_keys</em>. </p><p>If you wanted to know what the players Herbalism skill is, you could write <em>skills("Herbalism")</em>;</p><p></p><p></p><p>(It could be that the above code could actually omit the whole checking if the key even exists and be condensed to</p><p> skills($selectedSkill)=skills($selectedSkill)+1</p><p>It could be that PHP by defaults treats keys in an array that have never been set as a 0. In C++, this almost certainly wouldn't work, because an uninitialized variable will likely hold some basically random value. But interpreted language like PHP, JavaScript, Perl and Pyhton are usually simpler)</p><p></p><p></p><p>In the longer run, you are probably better off creating some objects, instead of using just raw arrays and strings and numbers. But to go into that, you will need to dig a bit deeper into fundamental programming topics like algorithms and data structures (and deeper into PHP as well.)</p></blockquote><p></p>
[QUOTE="Mustrum_Ridcully, post: 7466912, member: 710"] I am not familiar with PHP, unfortunately. I am however familiar with programming in general. I can tell you that this is probably not how you want to implement the skills in the long run, since it will be error-prone and hard to work with in the long run. Use Key Value pairs. I am not familiar with PHP, as mentioned, but a brief look here: [url]http://php.net/manual/en/language.types.array.php[/url] suggests that arrays are innately capable of working as such. As key, you could use the skill name, and the value is the skill rating. When the player selects a skill during character creation, you can check (with array_key_exists) if it already has that skill. If not, you just add the new skill with rating 1 (or whatever the base rating is for the first time picking a skill.) When the map already contains the kjey, you can instead set the value to the new skill to the one before +1. Pseudo Code (Again, I don't actually program PHP, my current work is mostly C++ and a tiny bit of Python) Except that I forget semicolons and use double quotes where single quotes would be typical or whatever.) if (array_key_exists($selectedSkill, $skills) { skills($selectedSkill)=skills($selectedSkill)+1 } else { skills($selectedSkill)=1 } If you just want to know which skill the players has at all, you can use [I]array_keys[/I]. If you wanted to know what the players Herbalism skill is, you could write [I]skills("Herbalism")[/I]; (It could be that the above code could actually omit the whole checking if the key even exists and be condensed to skills($selectedSkill)=skills($selectedSkill)+1 It could be that PHP by defaults treats keys in an array that have never been set as a 0. In C++, this almost certainly wouldn't work, because an uninitialized variable will likely hold some basically random value. But interpreted language like PHP, JavaScript, Perl and Pyhton are usually simpler) In the longer run, you are probably better off creating some objects, instead of using just raw arrays and strings and numbers. But to go into that, you will need to dig a bit deeper into fundamental programming topics like algorithms and data structures (and deeper into PHP as well.) [/QUOTE]
Insert quotes…
Verification
Post reply
Community
General Tabletop Discussion
*Geek Talk & Media
Who knows PHP?
Top