Disabling Characters After Winning

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Disabling Characters After Winning

Post by Epiales »

Okay, I'm a bit further now, but running into a problem. Here is what I currently have using js to open the popup and then php to display the content. Once I set up the battle mechanics, I don't have any clue how to disable the characters after someone beats them. I can't remove them from the database when they do, because everyone will be hitting them. Any good place to start? Thanks!!

Current:

Image

So when they attack no 1 Anthony, and win, it needs to be disabled so they cannot be hit again by the same person. Then when they beat number 1, number 2 becomes available to attack, and when they beat number 2, 3 becomes available and so on.
Nothing fancy, but a work in progress!

http://gameplaytoday.net
Sim
Posts: 412
Joined: Sat Dec 26, 2009 5:37 pm

Re: Disabling Characters After Winning

Post by Sim »

Start with a new table?
oRPG Creator - Make Your Own Browser Game
oRPG Creator on Facebook
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Disabling Characters After Winning

Post by Epiales »

Sim wrote:Start with a new table?
Not sure! I can only think of adding a row to the database for when the user beats that particular NPC, and when they do, make it 1 or yes. And then define the select statement accordingly. Only problem with that is that it would only show CERTAIN rows while I want it to show them ALL, being that all players have to defeat the NPC, not just one player. I'll sleep a bit and think further later :) Thx!
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Callan S.
Posts: 2043
Joined: Sun Jan 24, 2010 5:43 am

Re: Disabling Characters After Winning

Post by Callan S. »

How many people can be in the arena? If all players have to beat him before they go off the list, that's a lot of players!

For every player that is in the arena, you'd need a record for every other player. That'd be a lot of records!

Do they have to be able to choose who they can fight? If not then each player could just have a value for who they fight in the arena that goes up - ie, they fight player #1 in the arena, then player #2, then player #3, etc. They can't fight anyone lower on the list than this number.
User avatar
KyleMassacre
Posts: 573
Joined: Wed Nov 27, 2013 12:42 pm

Re: Disabling Characters After Winning

Post by KyleMassacre »

I will have to agree with sim on this one here. Create a new table like attacks_won or something like that to suit your needs Then you can have some columns like attacker_id, attacked_id, and time Then you would want to query your table and check to see if a row exists and if it does don't let them attack and if it doesn't then you can let them attack. For the time column you can use that to help filter/delete entries along the way

Also may I add a suggestion too? I will anyway ;). I wouldn't show the NPC stats to players otherwise they will know if they can beat them and that takes the fun out of it. I don't know if you have some sort of leveling system or not but if you do then you can maybe set their stats at what a reasonable stat would be for a level and just show the players their level.
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Disabling Characters After Winning

Post by Epiales »

Okay, so I'm looking at creating a new table in the database for storing if each NPC has been defeated or not by each player.... What's the best way to do that? In my mind I see two ways to do it, but seems like it will store way too much info.... Maybe there's a third way? Here's what I"m thinking anyway.

1. When user joins, have the signup put their ID/NAME in an arena log and then put every NPC ID/NAME into that row by each user id. When they attack the NPC and defeat them, then it will put it at a 1, as default would be 0. 1 would be they beat them. Then I would write TWO tables for displaying the information, with an IF statement. One would be ordered by ID only for new players and one would be ordered by the DEFEATED, ID ASC..... By doing it this way it would push the defeated ones down to the bottom and leave the new ones up top to be defeated, and allow me to remove the row for "attack" on that display so that they wouldn't be able to attack again.

2. Have an arena log with a userid, arenaid, defeated(0,1)... but this would require that every player would have a list of ALL arena fights put into that arena log when they lose and when they defeat for EACH attack (could be minimized by an if statement not allowing it to put into db if they lose), but let's say 20 rows to display 20 wins...that's a lot of rows in the table for every single player....

Is there another option to help tidy it up a little? I'm thinking I go with the first option....

*****EDITED*****

P.S.... It's still showing row lines and I have put the border to 0, so why?

P.S.2.... Also, I was thinking of making their atk/def a random between what it displayed on the stats, so while one may know their stats, it doesn't necessarily mean they can win until they are much stronger.

P.S.3.... After working on fix one, I'm not sure it will work....grrrr
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
KyleMassacre
Posts: 573
Joined: Wed Nov 27, 2013 12:42 pm

Re: Disabling Characters After Winning

Post by KyleMassacre »

Ok this man sound a bit ghetto but it is the easiest way I can think of off the top of my head and to account for breaks in some sort of id field for your NPC table. You can create a new column called next_npc or something and and when they win store the next NPCs id in that column so that way their next battle has to be with that one
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Disabling Characters After Winning

Post by Epiales »

KyleMassacre wrote:Ok this man sound a bit ghetto but it is the easiest way I can think of off the top of my head and to account for breaks in some sort of id field for your NPC table. You can create a new column called next_npc or something and and when they win store the next NPCs id in that column so that way their next battle has to be with that one
That might work. I could throw a new row in the users table called NPC and when they first go to the npc arena part, have it put the first name/id in the NPC row of their users table....When they defeat two, then it would put 2nd and so forth.... but the issue still remains is how would I call the NPC names but still show those that they defeated at the bottom?
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
KyleMassacre
Posts: 573
Joined: Wed Nov 27, 2013 12:42 pm

Re: Disabling Characters After Winning

Post by KyleMassacre »

I think you are getting confused on what I am saying, or maybe I am confusing here lol. You won't need anything in the users table at all, thats how clutter begins. Instead create a new table, this table will hold all the info for beaten NPCs. You will basically have 2 queries here, 1 for the NPC table and one for the beaten NPC table. If there is a result for the NPC id and the userid then obviously they can't attack them then so render that link useless. Now what you can do is filter out the NPCs and select the minimum id of the NPCs that have not been beaten and that would be your next challenge as a player
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Disabling Characters After Winning

Post by Epiales »

Well I guess I'm majorly confused, I can't figure this out.

I've tried it this way too:

Code: Select all

<?php
$sql = "SELECT * FROM arenalogs WHERE userid = '$_SESSION[userid]'";
$user_query2 = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($user_query2);
$row = mysqli_fetch_array($user_query2, MYSQLI_ASSOC);

$arena_charid = $row['charid'];

$sql = "SELECT * FROM characters where id !='$arena_charid' ORDER BY id ASC"; 
$user_query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($user_query);
?>
This is only working for the first character ID... So the 1st one doesn't show in the output... But if I put another character ID in the arenalongs, then it doesn't matter...doesn't do anything.

Example of arenalogs....

id = autocrement
userid
charid

So when I add a row that had 1 as the userid and 1 as the charid, the list only shows 16 entries instead of the 1st one like it should..... it goes from 2-17... but if I add another row with userid of 1 and charid of 2, it doesn't affect the outcome for some reason.
Nothing fancy, but a work in progress!

http://gameplaytoday.net
Post Reply

Return to “Advanced Help and Support”