Friday, January 31, 2014

Dev Log: Horror Text Adventure #37

I fixed the verb command structure.  Now if the player types a game command such as /c or /quit, all it cares about is the first word there, like normal.  But if the player types anything else, it goes through the entire text looking for a verb.  So I suppose now, if the player wanted to be literary, he could type "I go east" instead of just "go east" and still arrive where he needs to go.  In my last dev log, the verb had to be the first word.

After finding the first verb, however, it stops looking for verbs.  So if you type "take key walk north" it'll only take the key and won't walk north.  When it came to checking directions, I had to make a similar check so if the player typed "walk east east" it didn't try to walk east twice.

I also added a line break between each directional sentence, so it's easier to read where you an go.  Took me a while to find where I put that info.  Sometimes things start to get a little convoluted.  Need more comments!

Tuesday, January 28, 2014

Dominion: Industry #4

Now we finally get to the new mechanic that makes a good chunk of the cards in this new set.  Basically, in this set, you get to do stuff during your Cleanup phase.  There is the occasional card in various Dominion expansions that mention the Cleanup phase or have you do something during it, like Scheme from Dominion: Hinterlands, or Alchemist from Dominion: Alchemy.  But I felt that the mechanic never reached its full potential.  So I added a variety of cards that more or less help you set up your next hand during Cleanup.

New mechanic!  Click to enlarge.
These are all pretty simple variations, but the way they work can really swing their cost.  Each of them has your basic bonuses for the main turn, but during cleanup, they all do something slightly different.  I had to carefully decide what bonuses went with which effects so the player feels like both parts are equally useful and worth the cost of the card.

You do need to pay attention to the order you played them in during your Action Phase, because that's the order they will take effect during your Cleanup Phase, which can have consequences.

Machine Tools has you draw five cards, discard one of them, and draw one more.  It basically lets you discard a junk and see if you can get something better.  Way too often, I find I have too many actions in my hand that I can't use, or a Victory card that clogs my hand, or whatever, so this will come in pretty useful.  Other than the cleanup bonus, it's a Smithy from vanilla Dominion.

Printing Press allows you to decide to discard and redraw your entire next hand if the whole thing is junk.  This occasionally happens, especially late game when you're buying Victory cards like mad.  It's also useful early game, when you're at the end of your draw pile, so you want to shuffle and see if you can draw some of the new cards you just gained.

Steam Engine lets you draw two extra cards (so you have seven in your hand), and then put two back on top.  Since you're not discarding them, you have to think about how you're setting up the top of your pile, which could effect the hand you're going to play next, or even the hand after that.  It lets you dig pretty far to get yourself prepared.

Water Wheel basically lets you draw six cards instead of your normal five.  I worded it in a particular way just in case you Throne Room it or something (which would let you draw seven cards, etc.).  Of course, since Water Wheel lets you play additional Actions, you could potentially buy five Water Wheels and just devastate everyone, so I made it cost six and capped the number of times you can use this effect (so you max out the number of cards in your hand at seven).  You wouldn't want the player to have ten cards in their hand and just buy a Province (or even a Colony) every time.  I'm sure there's a better way to word it, but it works for now.

Friday, January 24, 2014

Dev Log: Horror Text Adventure #36

The player can now drop items they've picked up.  It appears as though if there are two of the same item in a room, and you want to pick one up, it picks up only one; but if you have two of the same item in your inventory, and you want to drop only one, it drops both.  Determining which of two similar objects you want to take or drop will require programming in adjectives.  That'll be fun.  Hopefully I'll make it so no two objects are alike (or the chance of them being identical is extremely low).

But dropping items works, for now.  The player can pick up a takeable item and put it down as many times as they like, of course.  During testing this I started to get really annoyed that the interface doesn't clear or scroll or whatever, so I definitely wanted to figure that out asap.

Turns out, scrolling is one line of code per box.  I thought it would be annoying, since my initial research on it made me assume it required a new listener, but it didn't even need that, which was nice.  I also thought it would add scrollbars automatically for some reason (why I would think that, I don't know), but thankfully it doesn't.

But even with scrolling, I noticed there aren't that many lines in each box, so I made the window size 960x800, which should be tall enough to display plenty of lines, and wide enough to prevent too much word wrap (before it looked like newspaper columns).  Fortunately, the window resizing was also one line, though I had assumed it would be more complicated, like I thought of the autoscrolling.  AS3/AIR is quite programmer-friendly sometimes.

screenshot of the game
More room now.  But now the menu feels off-center.
I also increased the size of the input box and word-wrapped it, so if the player is typing a particularly long message (usually when chatting, I imagine), they can see it all.  I've also been playing with capping the max input size, because I get annoyed in MMOs when players spam the chat.  But on the other hand, there isn't really a good balance; I can only reach a bad balance: if I cap at tweet-size, an evil player could still spam a string of W's in six lines, but a normal player talking might get annoyed by the limit (I know I sometimes can't get out what I want to say in a tweet).  So for now there is no limit, but I'll keep it in the back of my mind.

Now I am starting the work on adjectives.  I'm not quite sure how to make it work, to expand adjectives into the sentences I previously had (that way there is consistency between them), without having giant case or if statements.  But I'm sure there's an easy solution, just as there were for most other English things I had trouble with.

I also did a little cleanup on the Player class, just to reduce the lines, as well as add a couple constants for the interface in case I want to resize things again.

When you chat in the chat box it automatically adds "YOU:" to it, presumably to separate it from other players.  I've also been thinking about how to possibly make it so player names don't appear until you "know" the players' names, but that may be too annoying, and in any case that'll be far down the road when I get the multiplayer hooked up.

Tuesday, January 21, 2014

Dominion: Industry #3

Here are the last four cards that I came up with in my initial run of this expansion, when I was calling it "Black Gold".  These are odds and ends to round out the expansion.  I had also briefly considered a mechanical theme that "messed with other players' minds", and this is the remnants of that idea.

Land Run, Shrewd Merchant, Tariff, and Textiles
No more steampunk theme.  Click to enlarge.
Land Run is kind of fun.  With the theme of messing with other players, giving each player an Estate sounds generous, except that all it really does is clog their hands and ultimately puts the player who plays Land Run two points ahead, since they gain a Duchy instead.

Shrewd Merchant was a bit of a task; I wanted it originally in some way to be an attack card, forcing other players to swap out their cards, but I think this might work out better.  It also goes better with the Market/Peddler/etc. theme from other Dominion games.

Tariff is essentially Embargo from Dominion: Seaside.  The main difference is that it raises the price of a supply pile, rather than giving players curses.  I found that adding a curse makes most players avoid the pile completely, which is certainly an effect the original player of Embargo wants, but it seemed a little too harsh.  So this is my way of making it not as bad.  The player still has to decide if it's worth it to get a particularly high-priced card when they can now afford better cards.  Why pay $4 for a card that should be $3 when there are other (usually better) actual $4 cards in the supply?

Textiles wraps up the set; nothing too special about it.  This one, again, is like Mining Village from Dominion: Intrigue (I didn't even realize it when I made the card).  But what I like about it is that if you do trash it, it's ultimately +$3 because of the initial +$1.  That's a much better advantage.  I think most people don't trash Mining Village unless it's late game, because Village-type cards are so important, but with Textiles, I think the opportunity will arise more often where you choose to trash it for the extra money.  In that way, it should be about as useful as Moneylender from vanilla Dominion; you'll probably only buy Textiles if it's going to be a big part of your strategy.

Friday, January 17, 2014

Dev Log: Horror Text Adventure #35

I've been watching a lot of videos on AI and such, and in particular Watson and the Knowledge Graph, etc.  Since I've been trying to figure out a better system for text parsing for awhile, I think all that video-watching gave me an epiphany in the middle of the night.  I think I figured out a better way to create a dictionary.  (Not that it's anything like a knowledge graph, it's just better than what I had.)  Before, the dictionary has a convoluted way of knowing what the entire command is, but if you deviate by a single word it gets completely lost.  So I needed to try something better than that.

So right now I'm making a dictionary of verbs, which basically correspond to functions.  I'll probably also add some prepositions at some point (is that what words like "of" and "in" are called?) so you can look AT a box and you can look IN a box.

So I basically rewrote a lot of the dictionary code.  I *think* it's simpler now, as well, or at least has fewer lines of code.  Though the verb still needs to be the first word the player types.  I'll possibly fix that later, though I can't imagine what else the player might think of typing first besides a verb or game command.  But the player could type "walk bjhhjgf north kjgfd" and the player character will still walk north, and all other junk gets ignored.  I'll probably also need to put ignored words in the error box, so if the player needed a word and it was just a typo, they know what happened.  When the situation presents itself.

So anyway the examine code has been re-implemented, at least as good as it was before--better, in fact, so the player can get a description of multiple items with the same name (so if the player is holding an item and there is another of that item in the room, too, the player gets a description of both).  It has the problem of not being as specific with the error messages anymore, but that's alright for now.

I also reworked the take command, so that should work okay now, too.  Though it checks to see if there is a takeable item called what the player typed, I don't think it checks for duplicates, so I'll also be fixing that later.

The player can also move, as well, just as before.  So mostly it's all in the background, and there's very little difference on the player's end.

After the marathon of fixing the whole dictionary, I was surprised I only had three syntax errors and one runtime error... though of course the runtime error got evil on me.  Still, not bad for rewriting 100+ lines!

It feels good when things are ordered well, so I can see how much progress I've really made.  Too often you can't really tell what you've done, and it feels like you're stuck in the mud.

Tuesday, January 14, 2014

Dominion: Industry #2

I got a burst of inspiration and came up with a new mechanic for the expansion.  Since the expansion no longer revolves around the Oil card, I've renamed this expansion from Black Gold to Industry.  I'll get into the new over-arching mechanic later, but first I'll show more of the cards that I had originally come up with, before I came up with the new mechanic.

Getting a Steampunk vibe now.  Click to expand.
Automaton is similar in nature to Hunchback from my expansion Dominion: After Dark, which was very useful and fun, combined with Navigator and Lookout from Dominion: Seaside.  This might be a particularly powerful card after testing, so I'll see if it needs to cost 6 instead of 5.

Clockwork is a bit like Pirate Ship from Dominion: Seaside, with a mat and accumulating tokens, but ultimately I got the idea more directly from the Tick-Tock race in Cosmic Encounter.  Basically Clockwork allows you to slowly gain money tokens, which you can then trade in when you feel like it.  So it deviates from Pirate Ship in that the money goes away after one use, but it's also guaranteed, rather than being an attack and having a chance of failing.  But also, to combat spamming of it, you can only play it once per turn.  Hopefully that makes it worth getting, but not overpowered.  Also, it's not +$ in addition to your normal money, but instead is a separate card to gain.  So if you wanted a Province, you'd have to save up eight Clockwork Tokens, and you couldn't just save up five and use $3 from your hand to buy with.  That's one of the reasons I called them "Clockwork Tokens" rather than just standard treasure tokens: the player knows they're unique and won't confuse them for additional money during the buy phase.  That, and I imagine cool little gears as tokens.  Of course, if you play with this, use anything for tokens and mats that aren't confusing, like pennies or something.

Oil Field and Steel Town are pretty simple, and not worth getting into too much detail over.  Oil Field builds on the Oil card theme that I showed in the last post.  Steel Town is a Village-type card that may be trashed, similar to Mining Village from Dominion: Intrigue.

Friday, January 10, 2014

Dev Log: Horror Text Adventure #34

Cleanup.  Used the Vector Push function instead of manually adding to the length of Vectors for items and other stuff.  For some reason I always forget that Vectors and Arrays have nice functions for me to use, so I make my own.  I have a wheel and I must remake it in my own image.

I also went back and forth on how to do proper inheritance.  At first I made a hodgepodge of private and protected variables, then I made them all private with protected functions to set them, but then I thought that was just completely silly and made those variables protected and removed the "set" functions that weren't necessary.  So now I'm basically back to how it was, with protected variables when the subclasses need to modify them, and private variables when they don't matter.  But if a variable can be private, then I figure I must be messing something up, because it's unnecessary, I would think.  So as I code, I'll change private vars to protected vars when I use them, and if I never use them at some point, I'll have to deem them redundant and delete them.

I also did a quick test on the write create/write function for the player file, so now it saves the player's name.  The much tougher thing to do will be to save the map, which is unique to each player, and I'll need to save 365 rooms, plus every object in each room, plus whatever else there may be that deals with that.  I would like to be able to simply write an entire class instance to a file and load it back, so I'm going to do a little more research before manually writing up every variable.

Tuesday, January 7, 2014

Dominion: Industry #1

So I threw together a small expansion to Dominion with twelve cards.  There isn't too much of a mechanical theme, at least nothing that ties most cards together, though a few cards have ties, which are some of the cards I'll start with.

Cards called Oil, Pipelione, Railroad, and Tycoon.
Oil & related cards. Click to enlarge.
Oil is similar to Spoils from Dominion: Dark Ages.  Its only difference is that it acts as a one-time Silver, rather than a one-time Gold.  I've been contemplating an Oil concept for a while, trying to come up with something perhaps using tokens, or a treasure that acts like Potions from Dominion: Alchemy, but those concepts never worked out.  The flaw of Dominion: Alchemy is in its use of Potions in the first place, so it would not be a good idea to copy it.  Also, I had already tried a token concept with the Charms in my other expansion Dominion: After Dark.  I think that here, simpler is better, and what I've got for now is a proven concept.

The next three cards, Pipeline, Railroad, and Tycoon, are pretty simple, but build off the Oil card.  Nothing too complex to go into detail about.  However, you might wonder why Pipeline puts an Oil card into your hand instead of just giving +$2.  This will usually amount to the same thing, but it is also possible that you might not want to spend that Oil immediately, so it just gets discarded rather than going back into the Oil pile.

The visual theme is the industrial revolution.  I've also been considering such a concept for a while, trying to think of an interesting mechanical theme to go with it, though, as I've said, nothing too intricate has come of it.  So instead, I've opted for making a smaller expansion, that is more vanilla in mechanics, but nonetheless provides more variety in cards.  Perhaps later I'll make this into a full-sized expansion, and the rest of the cards will help expound on a new mechanic.

Friday, January 3, 2014

Dev Log: Horror Text Adventure #33

Made various types of barriers into subclasses, the same way I already did for items and room types.  Had a problem with using a class (not an instance) as a parameter, but I realized after a little while I could just pass in a new instance of the class, and it all worked fine.  It works exactly the same as the items and room types, so I kind of reinvented the wheel three times.  So I get to see if that lesson sticks next time I need to do that.

I've also started trying to figure out how to write files, which is one of the main reasons I'm using AIR instead of basic Flash.  I've started with creating a new player txt that will save the player var when the player exits (and hopefully more often than that, just in case of crashes).  I saw some good sample code on StackOverflow, but changing the directory seems to be messing me up a little.  The sample code put the file on the desktop, but of course I'd rather put files in the application directory, preferably in the lib folder or somewhere similar.  However, that's read-only, it seems, so the advice I've seen from official documentation says to use the Application Storage Directory.  Makes sense... until I look for it.  It seems to put it in the middle of nowhere, down a rabbit hole of folders.  The documentation says it puts it in a different folder depending on what system you use (Mac vs. Windows, etc.), but my goodness, something like the installation directory wouldn't be too hard, would it?

Oh, well.  It works; that's what matters at the moment.  The file saves so I can move on from that task.