I wonder if how could i achieve this code:


these are the conditions
1. there will be 2 text-areas
2. the text-area will be having a input of several lines of
like this one:

Griffon
Treant
Werebear
High Elf
Efreeti
Vampire
Sheep
Elven Archer
Militia
Archer
Dark Elf Magician

3. the program must read each line, and check the database for each unit's attribute
4. then compare the first text-area to the 2nd..
5. set up the pair-ups
6. print the pairups

btw., here is how the units pairs up?
Stack pairing

thank you..guide me please

Recommended Answers

All 4 Replies

Just a wild guess, but maybe you could explode on a special character (the enter character, \n)?

That would return an array of which each key would contain a line of text.

yes, that's true, use explode to lookup for the units..
but any complete pseudocode for this?

first off, this is a classic case for Class / object code. drive around on phpclasses.net site for a while for a feel of classes. Clearly, since you seem to be just starting out on this project, what are you trying to do? duplicate the conditionals that happen in the 'stack game' site you pointed to? if so, you need a much more robust backend and better design from the get go.
I'll be so bold to say that there is poor thought of design right out of the box.
Why are these 2 'textarea' fields? There is better ways to handle the data.
I did read the whole 'stack game' page there was more rules to 'pairing' then just the 'name' of a character class...
Actually after consulting the page again, I would start with a class called 'kingdom' and fill that will all things related to what it takes to play. a 'kingdom' will require two 'players' to join a game. those players then get turns which can be contained in your 'kingdom' object.
create a 'player' object.
I won't even begin to start on all things that would make up a 'player' object, but think about that 'player' containing other objects. one object would be
'casting class' which holds all things near and dear to the casting options that this player has dependent on what type of color they chose. then you need a 'units' class to contain all of the data that makes up what a unit is.
anyway, seem to be rambling a bit today...
So is this for fun, for work, for school? Would you like some help to turn those instructions on that page into a game. I'm not very interested in the game, but love showing others the beauty and elegance of class / object programming.

to give you an idea of what am i talking about..
here it is

MatchUp Calculator

but what i wanted is instead of selecting those units on a dropdown menu
we will just paste our stacks on text boxes

now, is it clear?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.