Sunday, October 22, 2006

Vehicular Fortitude: The Next Generation

This was a bad weekend for the car.  Four new tires and a tuneup.

There went $850.  Ouch.

Props

That last post was brought to you with Windows Live Writer and a nifty Source Code Formatter.

 

Now I just need to figure out how to make my chosen template look decent with the main text window wider, so the source code doesn't look bad.

String descritions from enums in C#

Anyone just looking for code can skip to the end.

My AE Item Maker has a SingleUseItem class, which uses an enum for each different kind of single use item.

public enum SUType
{
INVALID,
POTION,
OIL,
DETONATION,
OTHER,
}
Among other things I use the enum to generate names for items. In C++, I would probably write a function to convert the enum to the string I wanted, but this isn't c++, and I wanted to try something different.

My first thought was to use the nift ToString() method. This got me literal strings for values, like "INVALID", "POTION", etc. It was close, but not really what I wanted. So I turned to my favorite search engine for help.

The results were mixed. It seems you can't actually override the ToString() method on an enum. But I did find the next best thing.

First, I add a Description attribute to the enum (you need System.ComponentModel for this)

public enum SUType
{
[Description("Unknown type")]
INVALID,
[Description("Potion")]
POTION,
[Description("Oil")]
OIL,
[Description("Detonation")]
DETONATION,
[Description("Single Use Item")]
OTHER,
}


Next I added this public static method in a helper class:


 

public class ItemHelper
{
/// <summary>
/// Returns the DescriptionAttirbute for an
/// enum.
/// </summary>
/// <param name="nType">Any enum</param>
/// <returns>DescriptionAttribute for that
/// enum, if it exists</returns>
public static string GetTypeDescription(Enum nType)
{
Type oSystype = nType.GetType();
string strName = System.Enum.GetName(oSystype, nType);
FieldInfo oFieldInfo = oSystype.GetField(strName);
object[] rgObjs =
oFieldInfo.GetCustomAttributes(
typeof(DescriptionAttribute), false);
foreach (object obj in rgObjs)
{
DescriptionAttribute oDesc = obj as
DescriptionAttribute;
if (oDesc != null)
{
return oDesc.Description;
}
}

return "Unknown";
}
}

 


You use it like this:

string strType = ItemHelper.GetTypeDescription(m_nType);

This isn't perfect.  For one, if you have multiple description attributes you aren't guaranteed to find a particular one first.  It also doesn't handle localization at all.  But this works for what I need right now.

Thursday, October 19, 2006

Source Control update

After a while I remembered a discussion I had with a coworker about perforce, and now I have a workaround for checking out all the files and doing a "revert unchanged."

  1. Save the file. That brings up a few options, include "Save As." Click that.
  2. In the file list, find the file you want and right click it.
  3. From the right click menu, select Perforce, then "check out."
  4. Finally, cancel and save again. You've checked out the file.

It ain't pretty, and it's not as nice as source control integration, but it does work.

ItemMaker updates

I've been slowly working on the Arcana Evolved Item Maker. Very slowly.

So far I have tests for 4 different item types, but 3 of those need some refactoring. My current goal is to finish one kind of item and get that working in a UI. I've decided that the first Item type I want to tackle are single use items.

At a minimum in order to get an app together that does single use items, I need:

  1. Tested and debugged basic single use types --DONE
  2. Tested and debugged basic spells --DONE
  3. Code to load spells from disk
  4. Code to save single use items
  5. Code to load single use items
  6. A UI that doesn't suck


Extra stuff that would be cool:

  1. The ability to print items you've made in nice stat blocks
  2. The ability to sort spells by level, basic type (damage, buff, etc), descriptor, level, and alphabetically
  3. The ability to specify multiple sorts
  4. Some automated way to add new spells
  5. Images

And of course, other item types.

Ultimately, I'd like my item maker to be better than the existing one.

Right now I have code that loads the spells from an XML file, but it's pretty brittle. If an entry in the spell data is missing or not in the right order it croaks.

I really have to watch myself. I'm trying, unsuccessfully, to keep things simple. YAGNI. So far I've made a SpellWriter, which writes out spell data in the appropriate XML format. I don't need it. I wrote it to play with more of the .NET XML classes. Oh well, maybe I'll be able to use it for something else later on.

At 6 you can learn Python

Or at least enough python to write a game about vampires.

HAARG!

The whole thing is pretty entertaining.

Thursday, October 12, 2006

The latest in cube war technology

Even though I work from home, I so need this:

USB Missle Launcher

Sunday, October 08, 2006

Source Control and Visual C# Express

I'm continuing my work on my Arcana Evolved ItemMaker after a long break.

I'm still using C#, but right now I'm considering using this app to learn .NET 3.0 / WinFX / Avalon.

I'm using Visual C# Express, which is pretty nice, but I have one big complaint.

The worst part by far is that, like all of the Express downloads, VC# Express doesn't do plugins. This means that it can't do source control integration, which is a big pain. I'm working around this right now by checking out everything when I want to work, and using Perforce's "Revert Unchanged" feature to clear out the files I didn't edit when I want to check everything in. This works for the ItemMaker, but that's only because it's trivially small now.

ItemMaker now consists of about 10 core classes, plus 6 test classes. I haven't started on the UI yet. So far, that's 16 class files plus associated project files that I check out, revert, and check in every time I make changes. And doing TDD, I make a lot of small changes.

Any software developer needs source control. Joel Spolsky covers why (briefly) in the Joel Test. Eric Sink also has a post about it. If nothing else, source control is a great undo feature. Those changes you made aren't working? Can't remember what you changed? Check source control. Is it still unclear? Revert and start over. Without source control, you don't know where you've been, you don't know exactly what changed, and you certainly can't recover easily from a bad mistake.

I won't even work on small stuff without source control. For the record, I use Perforce at home because the single user license is free. If you are braver than me, or need a multi-user source control system, check out subversion.

I'm really happy that Microsoft released free versions of its compilers, but not being able to use integrated source control is almost a deal breaker. For C# IDEs, my only other (free) choice is Mono. I'm not yet annoyed enough to make the switch.

Fun game or crazy money making scheme? You make the call

Step 1: The Game of Alien Abduction
Step 2: ?
Step 3: Profit

Switching to blogger beta

I just switched to the new blogger beta so I can start taking advantage of the labels and other new features. This is stuff I've wanted since a few of my buddies went over to livejournal.

THIS BLOG HAS MOVED!

To:
http://martiank9.blogspot.com

The phpwebhosting address will be going away soon.

Where the wild pies roam

We visited Ktorrek last friday, and generally had a good time. Except for the horrible traffic getting there, and my illness afterwards.

Around 9 p.m. I was eating tasty Mac & Cheese and Chicken. Around 3 a.m. I was sad. I blame Salmonella.

The pies, however, were excellent.

Wednesday, October 04, 2006

LOST season 3

I just finished watching the first episode of the third season of Lost.

I haven't seen the whole second season yet, so I have no idea what's going on.

Two things come to mind.

First, wow. Lost is just cool. As usual, I can't wait for the next episode.

Second, I really dislike TV as it is now. Sitting and watching Lost I was thinking about how I need to either get a TiVo, go old school with a VCR, or just watch the series on DVD.

When we moved back to the Midwest we got TV again. I miss not having it. TV sucks away time. It's so easy to sit and stare at the pretty lights and moving pictures, and wake up 3 months later with very little else having been accomplished.

Watching series on DVD or (I imagine) on TiVo is different. You get to see what you're interested in and you don't have to watch the commercials. To me, DVD's are not quite as bad as TV, because you get to watch them on your own terms.

Anyway, I'm off to play with C# some more. No more TV tonight!

Monday, September 25, 2006

Back where it's sane

Forgive me dear readers for I have neglected you. It's been nearly 4 months since my last post.

You can thank my buddy Ktorrek for giving me the kick in the pants I needed to start blogging again. He had to go and link to my blog.

A lot has happened over the last 4 months.

We landed in Illinois safely. Thanks to Frangelica's father our stuff arrived here before we did. One of my mother's coworkers supplied a variably sized hoard of helpers to unload the truck. Unlike some of my previous moves, everything arrived safely. Or so we thought at the time.

Highlights, in no particular order:
  • Frangelica earned her Driver's license, and for the first time ever can legally drive a car by herself
  • She is taking a couple of classes at a local community college
  • Approximately 1 week after Frangelica got her driver's license someone broke into our new car and stole her purse. Almost everything has been replaced, but it was both time consuming and expensive. I estimate a total cost of nearly $500, just so the thief could get $8 and a useless cell phone. That doesn't include time off work.
  • I thought I had cancelled my cell phone, but I had only put it on hold. So I got to pay Sprint for 2 months for a phone I don't have
  • We have a cheaper pay as we go plan. The one from sprint was too expensive for what we needed.
  • I ended up piecing together a new computer, because my old one was on it's last legs. The final straw was when half of the ram went south. My good friend Ktorrek put it together for me and I'm downloading crazy big data files as I type, including a copy of Visual C# Express, the Windows XNA Beta, The latest DirectX sdk, and the beta of the .NET 3.0 platform (formerly Avalon).
  • Frangelica's computer is mostly dead. Ktorrek is attempting some horrific experiment designed to revive it. It will end up as a Frankenstinian combination of my old computer and Frangelica's old computer.
  • I have returned to the east coast once to touch base. As always, my return flight was delayed. I had to spend a night with a friend before I could actually come home. Otherwise the trip went well.
  • Working from home is awesome.
  • My mother was caught in a flash flood a few weeks ago. She's fine but her car died. She bought a newer version of my car.
  • The same rains that destroyed my mother's car flooded our storage locker. Fortunately there was minimal damage, but I need to get our furniture cleaned.
  • As I expected, since I left work the push for Unit Testing has gone completely. But I still get to test drive what I do, so it's not a total loss.
  • I bought Monte Cook's Ptolus. I couldn't help myself. I'm trying to get a group together but it's not going well.
  • This website will probably change soon. I think I'm going to go with 1and1 and get an actual domain name. Frangelica might get her own domain name too. Who knows? I'll keep you all posted (hi mom!).

And that in a nutshell is the last four months.

Thursday, June 01, 2006

Pitching TDD

Yesterday I pitched TDD at work to 5 colleagues. It went very well, though the presentation went longer than I expected.

I was expecting to spend 10 or 15 minutes talking about unit tests, TDD, UnitTest++, and how I have already applied unit tests and TDD to some of the code I'm working on. I wrote up a short guide to keep myself on track. I abandoned my guide about 30 seconds in to the presentation, and ended up talking and fielding questions for about 45 minutes.

It was a pretty easy sell. All the questions were along the line of "How do you do X?" and "What about Y?" The hard sell will be to management. The whole thing will be complicated by my move back to Illinois. I'll be working remotely, whch means I won't be around to try and help TDD take hold. Still, I had to try.

I'm very excited to see how this works out.

Tuesday, May 23, 2006

Buying a car

Recently Frangelica and I bought a new car.

The time was right. My old car was dying the death of a thousand minor repairs. We also figured out that if we bought a car right now we could avoid paying some extra Illinois taxes, at least if we interpreted the tax site correctly.

We got a flyer for a big sale. It was from some company that sells cars that I think are repossessed. Anyway, the flyer promised big BIG savings! So Frangelica and I went to check it out.

Keep in mind that I have only ever bought one car --my Saturn. There wass no negotiation, just a price sheet.

Frangelica and I headed out to the car dealership after I got off work. We both skipped dinner and just had a cookie --we thought we'd just be test driving, and we wanted to have plenty of time before the dealership closed at 9.

We were only interested in Saturn Vues. We test drove three before we settled on the one we eventually bought.

The negotiation process was... Interesting. And I'm not very good at it.

We were seated at a table. Our salesman would ferry different offers back and forth between us and the financial guy. We finally settled on a price, and then waited for an hour while the paperwork printed.

At the time I was sure that their "printer" had to have been the finest printer 1923 had to offer, given how long the process took. Later we realized that it was probably just a delaying tactic. We were both starving. Frangelica was getting sick. All we wanted to do was leave (with the new car). So when the papers arrived and almost all the numbers were different, we signed without complaint. The monthly payment was the same, which, a different salesman explained, was the important part. We were told that everything had to be accounted for in different ways, which was why the numbers didn't match the ones we had on paper from earlier that evening.

They actually invoked Enron. Since the Enron scandal, they said, they had to be very careful about how everything was written up.

Ultimately we signed and left with the new car.

We do love the car though, and ultimately that's what's important.

We also learned a few things.

  • Never buy a car from a guy in a cheap suit
  • Never buy a car from a guy that carries a plastic button around. When you pressed the button it said, "That was easy!"
  • Never buy a car when you haven't eaten in recent memory. We didn't get out of there until after 10 (or was it 11?) --and there were no restaurants open afterwards. We dined on a fine meal from Checkers on the way home.

I'm not sorry we bought the car. We really do love it.

However, in the future I intend to only buy from places that don't negotiate --at this point basically Saturn or CarMax.

Monday, May 08, 2006

Sunday, May 07, 2006

Don't be a hater

Recently I received an email with the following subject: THE AMERICAN FLAG COMES SECOND.

Normally I'd ignore something like this as spam, but a friend of mine sent it. It was an article by Michelle Malkin, about a bunch of high school kids in California where, as a protest, they hung the American flag upside down underneath the California flag. According to this site, they were protesting a proposed federal law that would criminalize illegal immigration.

As far as I can tell, the part of the article that I find most offensive was added later, as I can't find it on Ms. Malkin's site.

The offending section goes:

Pass this along to every American citizen in your address books and to every representative in the state and federal government. If you choose to remain uninvolved do not be amazed when you no longer have a nation to call your own nor anything you have worked for left since it will be "redistributed" to the activists while you are so peacefully staying out of the "fray". Check history, it is full of nations/empires that disappeared when its citizens no longer held their core beliefs and values. One person CAN make a difference. One plus one plus one plus one plus one plus one.........

It is essentially accusing anyone who is "...So peacefully staying out of the 'fray'..." Of contributing to what I guess is supposed to be the ultimate downfall of the US. It is attempting to play on people's fears of illegal immigrants.

There are so many things wrong with the above statement I find it difficult to even start tearing it apart.

As I recall, the United States was founded on immigrants. The statute of liberty has the following poem engraved on it:

Give me your tired, your poor,
Your huddled masses yearning to breathe free,
The wretched refuse of your teeming shore.
Send these, the homeless, tempest-tossed, to me:
I lift my lamp beside the golden door.


One of the wonderful freedoms we have in this country is the freedom of speech. These students were protesting a proposed federal law they felt was wrong. Regardless of whether or not you agree with them, they have the right to protest, just like Ms. Malkin has the right to disagree with them.

Freedom seems to be one of the "core beliefs and values" that the anonymous author wants to ignore, at least for illegal immigrants. Most of us are descended from immigrants (legal or otherwise).

I'm no expert on illegal immigration. However, it seems to me that people do difficult things when they feel the benefit outweighs the cost. Illegal immigrants come here to the US because conditions are so terrible where they are from that living in a van down by the river with 37 other illegal immigrants and working 100 hours a week at 4 different jobs is still better than staying where they were.

That's the "problem." Walls won't stop illegal immigrants. Making illegal immigrants really "illegal" won't stop it either.

I'm inclined to say that anyone who wants to become and American should be given the chance.

Ultimately yes, the forwarded email offends me. It offends me because some anonymous twit is trying to use fear to make me hate a group of human beings that are different from me. It offends me that people buy into this crap. It offends me that while we here in America are fairly well off people around the world starve and don't have proper medical care. It offends me that human beings treat each other so poorly.

Folks, we're all human beings. We're all on this rock together. I know it's cliche, but can't we all just get along? If the student who is hanging the American flag upside-down offends you, fine --say something. Write your congressman, write your local paper, form your own protest, do something --be heard. But don't preach hatred.

Tuesday, May 02, 2006

That's the news...

...and we are outta here.

Frangelica and I, after a lot of discussion, have decided to move back to the midwest, where people are sane. Or at least crazy in a way we like better.

I hope to be able to talk publicly in broad generalities about a new job soon. For now, I know I'll be staying in the game business.

We're leaving the third week in June.

Frangelica has a better rundown of why we're going, and where we're staying here.

I hope to post other details soon, including the story of how we purchased a new (used) car. Until then...

WATCH THE SKIES!