5 Replies - 1872 Views - Last Post: 21 June 2011 - 06:41 AM Rate Topic: -----

#1 busby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 20-June 11

php fighting game help

Posted 20 June 2011 - 02:31 PM

hey all...ive been given a task to do using PHP...my knowledge of PHP isnt great but i know how to create websites and connect to a database etc and i think the people who gave me the task thought Id find this task easier than i really will......anyway...been pondering over this for couple of hours now and i cant figure out where to start....could someone please explain a method of doing this? at least help with where to begin?

i dont want code i need a method to get through this...ive tried to plan it using a login system and have users....but i dont think it requires that...so i tried just having it ask a user select a warrior type and have it randomly created...but how do i do 2 players?...urrgh

here is the task

Mobile Fun Coding Challenge
Create the following game:

You set of warriors, each warrior has the following data:
● Name
● Health
● Attack
● Defence
● Speed
● Evade

Health, Attack, Defence and Speed are integer values between 0 and 100. Evade is a
number between 0 and 1.

There are currently 3 types of warrior:
● Ninja
○ Health (40-60)
○ Attack (60-70)
○ Defence (20-30)
○ Speed (90-100)
○ Evade (0.3-0.5)

● Samurai
○ Health (60-100)
○ Attack (75-80)
○ Defence (35-40)
○ Speed (60-80)
○ Evade (0.3-0.4)

● Brawler
○ Health (90-100)
○ Attack (65-75)
○ Defence (40-50)
○ Speed (40-65)
○ Evade (0.3-0.35)

The values for each attribute are specified as a range, on creation each warrior will be
assigned a random value within this range for the given attribute.

Warriors can take part in a battle, a battle has only 2 combatants. Warriors take it in turn to
attack each other. The warrior with the greatest speed takes the first attack (in the event of
two with the same speed, player with the lower defence goes first).

The damage dealt is (attack - oppositions defence) and is taken from the health. Damage
may be avoided, the chance of avoiding an attack is specified by the evade attribute.

The max amount of turns is 30 per player, if no player is defeated then the battle is a draw.
As the battle progresses a text output should be shown. When a warrior gets to zero health
the warrior is defeated.

Special attributes of warriors:
● Ninja
With each attack there is a 5% chance of doubling the attack strength.

● Samurai
When a samurai evades an attack there is a 10% chance of regaining 10 health.

● +Brawler
○ When a brawler’s health falls to less than 20% their defence increases by 10.

Allow a form to select player 1 and 2, and when submitted create a battle with the 2 players
and output the result of the battle!!

Is This A Good Question/Topic? 0
  • +

Replies To: php fighting game help

#2 maniacalsounds  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 117
  • View blog
  • Posts: 472
  • Joined: 27-June 10

Re: php fighting game help

Posted 20 June 2011 - 02:33 PM

I know you took the time to post the topic starter, but I can answer any question with one link:
http://www.dreaminco...ame-essentials/

Web Based Game Essentials (focused on PHP)
Was This Post Helpful? 0
  • +
  • -

#3 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 947
  • View blog
  • Posts: 2,355
  • Joined: 15-February 11

Re: php fighting game help

Posted 20 June 2011 - 03:28 PM

PHP in games is mostly used to interact with a database, other players, store data etc. It's a back-end language, but what interests me is you said `mobile`. Does this mean that to do anything the browser has to be refreshed?
Was This Post Helpful? 0
  • +
  • -

#4 Jstall  Icon User is offline

  • Lurker
  • member icon

Reputation: 434
  • View blog
  • Posts: 1,042
  • Joined: 08-March 09

Re: php fighting game help

Posted 20 June 2011 - 05:31 PM

From a design perspective it would make sense to have a base abstract warrior class with all the common attributes/methods and have the three types extend that. If you don't know much about OOP or it's implementation in PHP this tutorial is a good place to start.

Good luck!
Was This Post Helpful? 0
  • +
  • -

#5 busby  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 20-June 11

Re: php fighting game help

Posted 21 June 2011 - 01:40 AM

View Postcodeprada, on 20 June 2011 - 03:28 PM, said:

PHP in games is mostly used to interact with a database, other players, store data etc. It's a back-end language, but what interests me is you said `mobile`. Does this mean that to do anything the browser has to be refreshed?


well i never thought about that but i would assume so...however that which you cn see in my original post is literally all they gave to me. i dont know any more than that
Was This Post Helpful? 0
  • +
  • -

#6 satis  Icon User is offline

  • D.I.C Head

Reputation: 82
  • View blog
  • Posts: 231
  • Joined: 26-May 11

Re: php fighting game help

Posted 21 June 2011 - 06:41 AM

Is this just a mental exercise, or are you actually trying to make it entertaining?

Assuming the former:
I would probably make "logins" using the end-user's ip address or something else. That way you don't have to deal with a full login system. The user would "log in", push a button, and it would generate a warrior.

The warrior then gets put in a queue of "living" warriors. End user would see a list of other living/online warriors and choose one to fight. The other user would have to agree.

Then it just back and forth as you go through the turns. The instructions don't say anything about having to have any interactivity, so I'd just loop through the fight until it's either a draw or someone dies. Set a dead flag on whoever died (if they died), then output the results.

If you actually want to make it interesting for the players, that's a whole different story. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1