Monday, August 8, 2011

Fields

Anyone know a better way to ensure that a subclass defines a number of fields without forcing it through a constructor?  Java doesn't permit an abstract field, which I'd forgotten about.  The problem is that I may have up to 30 points of data, all numbers, and there's a pretty strong risk that I'll get a couple of them mixed up.  What I'd like is in the class declaration to set them without marshaling them through a constructor call, but still have the compiler enforce that I have in fact set them all.  This should all happen without copying and pasting the field definitions, etc.  I can think of how I'd do this in a number of other languages, but not Java.

Sunday, August 7, 2011

Enums, Classes

I think I posted earlier about the problem I was having where if I make each monster and object it's own class that I then have to create a separate list of all of them since the code in several places will refer to objects as groups with index numbers.  So, from MONNUM to MONNUM.  I didn't want to maintain a separate list of objects, since without reflection it's very hard to associate something with an actual class.  I opted instead for using an Enum, but that has the problems that not only do all the definitions have to be in one huge file, but for each type that has a slightly different constructor, I'm overloading it using another dummy class so that I can foo(int, int, int), from foo(int, int, int).  I'm still having to put a crapload of data into a constructor that I can't read.  It winds up looking like:


GLAIVE(new Weapon(), 45, "glaive", "single-edged polearm", false, false,
true, 8, 75, 6, 6, 10, 0, EnumSet.of(WeaponType.SLASH),
Skills.POLEARMS, Material.IRON),


RIN_SUSTAIN_ABILITY(new Ring(), 159, "sustain ability",
Property.FIXED_ABIL, "bronze", 100, true, false, 4, Material.COPPER),

etc.

The best part about taking a few months off of coding is coming back and saying "zOMG, how f'ing sleep deprived *WERE* you?"  because when I look at these, I just want to close the laptop again and ignore it for another week.  (This has happened once already)

Oh, and I have to do a new Ring() up there because you can't make an instance variable before the actual Enumerations, and I'm trying really hard to avoid globals so that I can eventually detangle this.  Yuck, 'eh?

My goal this morning was to do something easy to work into webhack again, and I quickly got mired down in this.  I think I'm going to move to something a little more hybrid like.  Namely:

public Enum ObjectName {
  GLAIVE(new Obj.Glaive),
  RIN_SUSTAIN_ABILITY(new Obj.RingSustainAbility)
}

And then just delegate all the calls over.

As my daughter likes to say.  "Yucky!"

Friday, July 22, 2011

What's up

So, apparently moving, my son getting his tonsils out, working, and doing two master's courses at once meant that I didn't have time for this much lately.  I've been itching to hack again.  I still have a few weeks left in my courses, and I took some time to update eclipse and make sure I could still upload what I have already.

I haven't given up, though. =)

Sunday, May 15, 2011

Bit of a break

I've been taking a bit of a break from webhack hacking.  I've started a couple Master's courses, found a new place to live, found a daycare for the kid and discovered Lord of Ultima: an MMORTS game played entirely through a web browser.  What started off as curiosity to see how they did it has turned into many hours of evening fun.

However, I'm slowly finding myself getting bored of it, since it's time-based.  What I love about hack and it's derivatives is the pure turned-basedness of it.

Today's push is mostly a GWT update, wherein they now claim (again) that IE9 is supported.  Could someone please test it again?

I don't know what I'll work on next.  Taking a few weeks off means that my brain has completely cleared state and I'm not even sure what's needed.

Oh, and I checked the analytics.  Apparently this got a shout-out on some aggregator and we had a one-day peek of 300+ users.  Crazy that there are that many people randomly hoping to play this.  =)

g'n!

Saturday, April 23, 2011

Sleep is for losers

Or I could just deploy it.  I'd forgotten about the fact that if you preventDefault on a keydown, the browser never triggers the keypress event.

So, keydown handles arrow keys and keys with modifiers.

keypress handles everything else.

It's working, and I've pushed it.  Anyone have an '@' somewhere other than over the two?  Everything should work right now.

Now it's really bed time. =)

Keyboard events. Again.

Okay, so I've been puzzling through keyboard events the last few days.  I decided I wanted to do something fun, like add new levels.  Once again, encountered that things like < and > are hard to generate in a properly internationalized way.

I'm using a few documents as reference:

http://www.w3.org/TR/DOM-Level-3-Events/#events-textevents
http://www.w3.org/TR/2006/WD-DOM-Level-3-Events-20060413/keyset.html#Guide
http://www.w3.org/TR/DOM-Level-3-Events/#event-flow

There's a few things to note:

1) DOM3 isn't implemented anywhere at all yet.  But keyboard stuff wasn't really formalized before this.
2) Keypress isn't documented (which does exist).  Instead textInput replaces it, which isn't implemented everywhere and seems to only fire at each keystore in a textbox.

I *think* (and I'm documenting this without having actually tried it yet, so that I can come back to this and find my notes) that what I need to do is preventDefault on dead keys (ctrl, meta, alt, shift) only.  This should stop those modifiers from hitting the browser.  Then I think I can just watch keypress to actually just pick up the key that was hit and any modifiers.

As a side effect of this, hitting the shift key should no longer cause the monsters to move around the grid.

But it's taken me until 20 past midnight to come up with this.  So, bedtime. =)

Monday, April 18, 2011

Renewed Domain until 2020

I've renewed webhack.net until 2020.

Now to hopefully not take that long to get this thing finished. =)

Been crazy busy the last few days.  Slowly getting back to Webhack.

Some maps now have vaults.  You can see them with C-f.  You can't get to them, and there's no money in them yet.  Details, details.  It was the most invasive work I've done with the map so far.  Somethings it'll run into a road.  Will fix that soon.  Just happy to do a push again for the first time in a while.