I have now created a simple card-based battle system. The pretty pictures and epic music score
comes later. Also, the descriptions on
the cards word-wrapping. Details,
details.
And the cards should probably be card-shaped. |
Anyway, the player is given a starter deck of forty cards,
and is dealt a new hand of five random cards every turn. The player can choose among them what to play
simply by clicking on them. The odds of
drawing some cards are very high (a card dealing two damage is 3/10) and others
are very low (Confuse is 1/40).
I have currently created the most basic variety of RPG
moves:
Simple damage
Heal self
Confuse
Stun
Block
All of these work (I think), except that Stun is a tad buggy
(the enemy stays stunned unless you Confuse or Block).
Also, Block may appear
to be ineffective, but Block only blocks one damage point, so if the enemy
deals two or three damage, the player still takes some damage (normal damage -
1 for blocking). Only if the enemy deals
one damage does the player completely block the attack.
Sometimes you can't see what's blocking you. |
(I'm sure that the system is horribly imbalanced and doesn't
give particularly good feedback, but that doesn't matter at the moment. Details, details.)
The enemy is also given a deck of cards and chooses randomly
among them. However, for this simple
battle, the enemy can only do direct damage.
I will later add the same functions for the enemy (or clean my code and
make the player and enemy functions one and the same).
Also, the player cannot see the card the enemy has chosen,
and at present I am not sure if I want the player to actually see it, or just
feel its effect. I may play with that
idea and decide what is best.
There is currently no win condition, and both the player and
the enemy's health can go below zero, and it is next on my agenda to make
victory and loss conditions.
As for the work done, I found it a small challenge getting
back into the swing of coding AS3. While
I began with reservations about how much I would remember, much of it came back
to me quickly. Code is just like
learning a foreign language: when you
have to use it after you've forgotten it, you remember more than you think you
do.
English on the left, AS3 on the right. |
But for problems with coding:
I am always annoyed at adding event listeners, because the
function you put in as a parameter cannot have its own parameters (or if it can,
I am not sure how to do it).
To get over this, I created a class called Battle which acts as a manager for the
battle, not only holding various functions such as dealing cards, etc, but also
holding variables which could not otherwise be passed.
The creation of timers to delay messages were similarly
handled.
I've considered recreating my own versions of these built-in
functions to fix that, but at the moment I'll take the path of least resistance
and just walk around the mountain, rather than climb up it. It may become necessary in the future to do
so, but for the moment, as long as I am getting basic functionality, I'll worry
about cleaning my code later.
(If the screen is magically green when you try to play, just refresh and that should fix it. I think it's a Google Chrome bug but I'm not sure. Other browsers may or may not have this problem.)
No comments:
Post a Comment