Tuesday, May 24, 2016

C#: Null Conditionals and Interpolated Strings

Two new features of C# 6.0 I've been using like crazy lately are Null Conditionals  and Interpolated Strings. These two simple pieces of syntactic sugar has made my programming life so much easier, and so I thought I'd pass the knowledge on to some of you who may not be aware of these powerful shortcuts.

Null Conditional - ?. operator MSDN

Null conditional sounds an awful lot like Null Coalescence now doesn't it? Null Conditionals work in much the same way, by first checking the value of the left side of the operator for null. First, here is an example of getting a property from an object without knowing it is null using the longhand method, then another with Null Conditionals, and finally a little trick that I'll explain below.
The above Null Conditional code with check if User is null, and, if it's not, returns the ID property. If it is null, it will simply return null. This stops the dreaded Null Exception error that we all hate to see, and makes your code much easier to read and understand!

What if you don't want null returned by the Null Conditional? Well, there's a simple trick for that as well. Combining a Null Conditional with it's cousin, Null Coalescence, you get back whatever default you want! See the third line of code above for how it's done.

String Interpolation - $"{x}" MSDN

String Interpolation is the act of injecting variables into a string without having to close the string constant and manually concatenate variables into it. An example of a traditional string concatenation is as follows:
Not too pretty, right? Here is the same example with String Interpolation.

There we go! Much easier to read! Simple to use, simple to understand, simple to read.

GURPS Calculator - Enhancements, Character Sharing, and GCA Importing

June 2, 2016 - Fast Followers and Patch Release

This release is a medium-weight build addressing a few bugs and including some enhancements I didn't have time to include in 2.3 (Character Importing).

Enhancements

Download your current or previous characters back into GCS format
Download your current or previous characters back into GCS format

If you find yourself away from your copy of GCS but need to update your character, we have you covered. In this release you will be able to click on a special "download character" button on the Full List Character Screen and be redirected to a download screen like the one above. There you will find that every instance of your character you have ever uploaded will be available for you to download, so if you made some crucial or confusing changes to your character that you now wish to revert, you can always just go back and grab an old copy! All character save files download in their original gcs format, so once downloaded you can open it in GCS and edit away (and, of course, re-import into gCalc!)

Over in the Collisions calculator, the Local Gravity field now accepts decimals, allowing you to crash into things at high speeds even more accurately.

I've also created a Wiki to aid in GURPS Calculator use, the link to which will be featured in the menu next release. It, unfortunately, has nothing in it yet, but you can help change all that! I use every spare moment I have coding and planning for gCalc, which sadly does not leave me much time for documentation and promotion. That's where you come in, head on over to http://wiki.gurpscalculator.com and help the community by adding any information you can to aid in the use of gCalc! Anyone who edits will of course have their names added to the contributors list. No need to contact me, just head over to the wiki and get to writing. :)

Bug Fixes

  • Critical hits are now based on effective skill and not base skill (D'oh!)
  • Rolling against Fright now always fails on 14 and above.
  • (Dis)advantage/Skill/Equipment groups now import correctly (with collapsible panels and everything!)
  • Player notes for skills exported from GCS now show up correctly.
  • -10xHP now indicates total bodily destruction.
On the technical side of things, this release moves gCalc away from MVC bundling of assets and into the world of Cassette bundling, which, in my opinion, is much easier to use and gives much better results. CSS and JS files are now bundled and minified in a very specific way and order, allowing for faster page loads and response times.


2.3.x - Character Sharing

This month we hit our goal of $60 with a reward of Character Sharing. I started work the day the goal was met, and I am around 50% done the initial work on it. When complete, a player will be able to go to the Full List screen and click a "Share" button next to a character. When clicked, the player will be redirected to a sharing manager where they will be able to share their character with another player by inputting their gCalc username. That second player, once they approve the share, will be able to view the character, roll against its stats/skills/attacks, and download it using the Character Download feature available in 2.3.1. The player will not, however, be able to make any alterations to the characters HP/FP, Tracker rows, or any other value that gCalc tracks independently of GCS.

Ideally this will allow players to share their characters with a GM, allowing the GM to make secret rolls, check resources and adeptness when planning adventures, and view values such as DR and Defenses when rolling for combat (if secret).

There is no release date for this functionality yet, but I am optimistic that it can be release mid-late June.

2.3.x - GCA Importing

GCA importing is currently our next goal, sitting at $70. When this goal is met, players will be able to export their players from GCA using one of the save functions already built into the system (most likely export to xml) and then, on the gCalc site, upload their character for use. Once uploaded, the player will have at their disposal the full suite of tools already available to GCS imported character, including Character Sharing. One caveat is that Character Downloading may not be possible without uploading both the xml and the original character save. I will most likely offer uploading the save file as optional functionality for those of you that wish to leverage character versioning and cloud backups that the GCS crowd enjoys.

Thank you!

As always, thanks so much to my patrons and contributors, and of course to everyone who uses my app. I love working on it, and I love talking to all of you and hearing your ideas. If you want to get active in gCalc, please don't hesitate to do so! 

Special thanks to Travis EllisBruno, and K Abson for becoming patrons this month! People like you make it all possible!

Thursday, May 12, 2016

Seeing CriOS in your analytics?

What is CriOS and why does it keep popping up on my analytics?

Recently in my google analytics for my site and blog, I have been seeing "CriOS" popup from time to time, and, each time, I discount it as either a foreign browser or a bot crawling my site, but no! It turns out CriOS is in fact "Chrome for iOS", meaning Chrome on an iPhone!

This ends up being a very interesting statistic to have, since now I can compare it with my iPhone Safari hits and see how much Chrome is eating in to the Safari pageview share on my site.

As a user, and a developer, it would be important to know that CriOS doesn't work like normal Chrome for Android (since the operating system are completely different.) It is, of course, based on webkit (just like Chrome for Android/Desktop and even Safari), "However, while Apple allows only Safari to access iOS facilities like the iOS Nitro engine, Chrome uses Apple's UIWebView for loading and rendering content." -- developer.chrome.com

If Chrome for iOS takes off and begins to really compete with Safari as the #1 browser for the iPhone, some considerations may need to be taken with how mobile webapps are built.

Interested in knowing more about CriOS, or want to try it yourself? Click here.

GURPS Calculator 2.3 has been released! GCS Importing for all!



GCS Importing has been released!!!!


Click here to get started on exporting your GURPS Character Sheet files into gCalc!

The Story
About a year ago my gaming group started to really get into GCS and all it had to offer. They were of course using the gCalc tracker every game as well, but it lacked an easy and clear way to transcribe a full character in a useful way for play. GCS, on the other hand, has a very complete interface for creating and maintaining characters, but no real way to have an at-the-table utility autocalculate all the crunchy bits of GURPS that we all love.

Looking into exporting from GCS initially, I ran into several problems, namely that I couldn't get gCalc to play nicely with GCS as they both stood at that time. I dropped the idea for about 4 or 5 months, and during that time released several additions to gCalc such as a complete visual redesign, huge improvements to the tracker, and a Demolitions Calculator.

In December I got interested in GCS exporting once again, and this time reached out to Richard Wilkes, the creator of GCS, who, very graciously, answered every one of my dozen questions.

Answers in hand, I decided the best way to deal with exporting from GCS to gCalc would be to alter GCS myself, since Richard has very generously made the app an open-source project. At this time Jeff Lauder came back into the fold, having taken a break from helping with gCalc, and excitedly took over the java development for GCS, leaving me free to make all the character screens and associated functions.

During the next 3 months we coded our butts off, literally almost every day I spent some time working on this code. Of course, I didn't ignore the rest of the app, during that time we also released the Trait Sorter and Treasure Generator.

6 months from conception to delivery. Not bad right? 3 months of talking, thinking, and planning, with the dev work taking about 3 months. Total development and testing time was probably around 500 hours between myself and my fellow developer Jeff Lauder.

A special shout out to our lead alpha tester Travis Ellis who spent several hours testing and retesting, and to our wonderful Patrons and Donors, whom without this would not be possible.

Happy Gaming!

Wednesday, May 4, 2016

GURPS Calculator - GCS Importing launch on May 12th!

After months of work, version 2.3 of GURPS Calculator will release on May 12th! This release is absolutely loaded with enhancements, all falling solidly under the new GCS Import feature!

After downloading the new GCS update, you will be able to import your full character file from GCS itself directly to gCalc with only a few quick clicks. Once your character is uploaded you will have an amazing at-the-table utility to make all your games run much smoother!

Our next Patreon milestone is Character Sharing, which will be a full system to share your character with other users! Once your character is shared with another user, that user will have full privelages to view your character and roll against your various stats, skills, and attacks (don't worry though, they won't be able to make any permanent changes to your adventurer!) Once this goal is met I will begin work on the sharing system and get it out to you as soon as possible! We only need $10 more in pledges to make this happen!

Stayed tuned, and look out for the release on May 12th!