Major design problem on web game

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 1062 Views - Last Post: 13 November 2008 - 04:33 PM Rate Topic: -----

#1 Xioshin  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 264
  • Joined: 05-November 08

Major design problem on web game

Posted 10 November 2008 - 06:23 PM

Hey guys,

My game is starting to flesh itself out, but I'm having trouble grasping a way to get my turn-based multi-player combat to work.

My idea of a basic combat sequence:
--On the screen, I see your name, you see mine. This means we are both on this map and we can attack each other (it will do a db check to make sure you are in fact STILL on that map)

--Another database check happens at the same time: character table check to make sure inCombat=0, meaning we are both not in combat. If we are in combat with someone else, you obviously can't enter combat with me also. Once you click someone and they are NOT in combat, we will run the UPDATE script to force them into combat (inCombat=1).

--Both check out, and we are now in combat. This is where major problem 1 happens:
Once you engage combat with me, I won't know I am in combat with you until I refresh my screen by performing an action like moving/resting, etc.

--We are now both looking at a combat screen.
You have an agi of 5, I have an agi of 6, so I will always attack you first (lets ignore skill speeds)

Turn 1
You attack me. I attack you.
Once we both choose our moves, the game will calculate the damage and output it on our now-refreshed screens.
This is where major problem 2 happens:
What happens once we both click attack? We will be in some kind of queue waiting for the other player to make their move right? What if they DONT make a move? What do we do while we are waiting?

Turn2
You attack me. I attack you.
Again we wait, damage is calculated. We stay in combat until one of us dies (or someone flees. Will find a way to implement flee, because if you leave combat, you can just re-click their name and force them into combat again..)

How can I implement this type of turn-based combat? I know how to do all the actual game calculations and stuff, but the actual script to "lock" 2 players into combat with any time of real-time refreshing battle queue seems impossible... but i KNOW its not.

Can anyone lend me your knowledge and help put me on the right path?

Is This A Good Question/Topic? 0
  • +

Replies To: Major design problem on web game

#2 Moonbat  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 36
  • View blog
  • Posts: 424
  • Joined: 30-June 08

Re: Major design problem on web game

Posted 10 November 2008 - 07:08 PM

For #1, why don't you have it so when you are challenged to a fight, a message is sent to you informing you that you are fighting. You click 'OK' on the message and you are then taken to the fight. No fighting can begin until you click OK. Also, you can make it so the person must accept the fight.
Was This Post Helpful? 0
  • +
  • -

#3 Xioshin  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 264
  • Joined: 05-November 08

Re: Major design problem on web game

Posted 10 November 2008 - 07:24 PM

Im not sure how to get a pop-up like that to show up in real time, and pop-ups are terrible so I would never have something like that happen to my players.

If you mean just display a message, we may as well show that they are in combat.
And the reason I can't have someone say "ok" is because the game is designed around 3 factions at war. As to not give too much of the plot/ideas away, lets just say that if someone is going into combat with you, its because he hates your faction and wants you dead.

The typical MMO term for this is "ganking", which is basically being attacked without warning. Lucky for [you], the game is turn based. :D
Was This Post Helpful? 0
  • +
  • -

#4 Moonbat  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 36
  • View blog
  • Posts: 424
  • Joined: 30-June 08

Re: Major design problem on web game

Posted 10 November 2008 - 08:26 PM

If you want a real-time message, I don't think PHP has anything to help you with. You'll have to use Javascript I guess (and I don't know much JS).

As for problem #2, I would have it so that whoever initiates combat gets the first strike. You can have a JS timer set for (for example) ten minutes, and if a move isn't made, you can either make a 'pass' feature that will make the player automatically skip his turn without doing anything, or you can make the player automatically lose the battle due to lack of activity.
Was This Post Helpful? 0
  • +
  • -

#5 xerxes333  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 31
  • View blog
  • Posts: 504
  • Joined: 05-July 07

Re: Major design problem on web game

Posted 10 November 2008 - 08:40 PM

View PostMoonbat, on 10 Nov, 2008 - 06:08 PM, said:

For #1, why don't you have it so when you are challenged to a fight, a message is sent to you informing you that you are fighting. You click 'OK' on the message and you are then taken to the fight. No fighting can begin until you click OK. Also, you can make it so the person must accept the fight.



If you want to go this route, you can either build a DIV element (instead of using an actual "pop-up") and add it to the DOM or have one already built (and hidden) in the page and just display it when its needed or hide it when not needed. Pretty simple to do with Javascript.
Was This Post Helpful? 0
  • +
  • -

#6 xerxes333  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 31
  • View blog
  • Posts: 504
  • Joined: 05-July 07

Re: Major design problem on web game

Posted 10 November 2008 - 08:48 PM

For problem #2 I would suggest that there be some sort of initiative roll when combat is initiated, based on the combatants stats. If a full plate warrior tries to attack a rogue, the rouge will have better stats and would more than likely get the initiative (just my $0.02). Once combat begins each player gets a countdown timer for them to enter their attack (could use a div to display remaining time). If the player times out check to see if they are still active (prompt them with something) if not remove both players from combat.
Was This Post Helpful? 0
  • +
  • -

#7 grimpirate  Icon User is offline

  • Pirate King
  • member icon

Reputation: 149
  • View blog
  • Posts: 714
  • Joined: 03-August 06

Re: Major design problem on web game

Posted 10 November 2008 - 08:55 PM

What you're referring to is making asynchronous requests to your database. PHP doesn't do that because it doesn't know when the database has been updated or not. For that you'd need to look at AJAX. i.e. using Javascript to make the asynchronous requests for you.
Was This Post Helpful? 0
  • +
  • -

#8 Xioshin  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 264
  • Joined: 05-November 08

Re: Major design problem on web game

Posted 10 November 2008 - 08:56 PM

==================================================================
Yea.. I will worry about the timing later.
Honestly, at the end of the day, if combat is working, then combat is working and that is fantastic.
The efficiency of combat, on the other hand, can be changed, edited, and fixed until it is as fluidly-"old-school" as possible :^: Thanks fellas!
==================================================================

This post has been edited by Xioshin: 10 November 2008 - 11:25 PM

Was This Post Helpful? 0
  • +
  • -

#9 Xioshin  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 264
  • Joined: 05-November 08

Re: Major design problem on web game

Posted 10 November 2008 - 10:06 PM

Problem solved. :^: :^:

I love the feeling of solving my own problems. I feel like I progress more each day.

I hope this will motivate those of you who come here and read this.


Xioshin

This post has been edited by Xioshin: 10 November 2008 - 11:26 PM

Was This Post Helpful? 0
  • +
  • -

#10 xerxes333  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 31
  • View blog
  • Posts: 504
  • Joined: 05-July 07

Re: Major design problem on web game

Posted 11 November 2008 - 08:45 AM

So how did you go about handling the problem? Just curious.
Was This Post Helpful? 0
  • +
  • -

#11 Xioshin  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 264
  • Joined: 05-November 08

Re: Major design problem on web game

Posted 11 November 2008 - 09:49 AM

Hah, i will keep you posted on the combat issue once I try messing with javascript and the timer div and all that.

To be honest I dont even remember what this question was about :blink: lol

But I think it was either me finishing the registration form issue, or an issue I had with calling functions from one file located on another.

Who knows ;) but I got that working haha.

I'll keep ya posted, thanks Xerxes!
Was This Post Helpful? 0
  • +
  • -

#12 ghqwerty  Icon User is offline

  • if($spareTime > 0){ $this->writeCode(); }
  • member icon

Reputation: 43
  • View blog
  • Posts: 903
  • Joined: 08-August 08

Re: Major design problem on web game

Posted 11 November 2008 - 11:57 AM

i would also reccommend making sure you can only attack people who are online otherwise you ould just pick pon people who arent online and wait for it to automatically 'time out' and just kill everyone when they are off line.

also might be cool if you added a hide feature. differant classes would be better or worse at this eg if you wanted a rouge to hide it would be pretty effective however if you got a barbarian fighter it might not be as good.

depending on your gameplay style you could also implement the use of potions and spells to increase certain stats such as hide, dodge, power etc.

you might also want to add player bases so that an alliance can have a area where they all stay and if 1 is attacked they all help defend wich would also lead to having multiple planned attacks like 3 on 1's :)

you might also be able to hold mini tournements for rewards such as better weapons or good potions in which you would have 2 sides battle it out tactically and the one that all people die on or the one with least people remaining after a given time loose and the winning team all get a prize.

you could give players differant attack types for instance a wizard might choose to specialise in buffer spells or offensive spells so you could have a wizard hiding at the back of the battle field or something healing players that get injured and then have one that works forward with the main offence causing some serious damage


anyway now im rambling too much but there is a few ideas for you :)
Was This Post Helpful? 0
  • +
  • -

#13 xerxes333  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 31
  • View blog
  • Posts: 504
  • Joined: 05-July 07

Re: Major design problem on web game

Posted 11 November 2008 - 02:39 PM

Wow ghqwerty, you just made his project a helluva lot harder :P
Was This Post Helpful? 0
  • +
  • -

#14 Xioshin  Icon User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 264
  • Joined: 05-November 08

Re: Major design problem on web game

Posted 11 November 2008 - 07:36 PM

Haha xerxes..

ghqwerty, I appreciate your input and will definitely note those ideas for later, but we have actually created a design document that has racial information, class information, some back story, and how the game is supposed to be feel and be played out.

I notice a lot of people who come here and decide they are going to start coding a game, and never actually stop and think about what the game is supposed to be like.


Again, I appreciate your input, but until most of the ideas we already have are implemented or scrapped, they will have to wait :^: :^:


==================================================
Question for you wonderful DIC heads, :D

is it legal to put javascript inside of php? I would assume no, but since you can do

<?php session_start(); ?>
<html>
<body>

<?php
// SOME PHP CODE HERE
?>

</body>
</html>


I would assume it is legal to put the javascript inside the html body but outside the <? ?> correct?

Im trying to see if I can design the site to show a div which has javascript code inside of it that will refresh the page every 10 seconds when in combat only while my php code on the same page controls the actual game.

Quote

Difficult ? I hope not.

Was This Post Helpful? 0
  • +
  • -

#15 ghqwerty  Icon User is offline

  • if($spareTime > 0){ $this->writeCode(); }
  • member icon

Reputation: 43
  • View blog
  • Posts: 903
  • Joined: 08-August 08

Re: Major design problem on web game

Posted 12 November 2008 - 09:54 AM

well i use html tags inside of php tags so i would assume you do the same

just like
<?php
echo "<table border='1' width='30%'>";
?>

etc but remember to either use
\" or ' as if you do

echo "<table width="20%" border="1">";

you will start getting major problems.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2