3 Attachment(s)
Ninja! (The Game By Spence)
Hello RaGEZONE, I made a quick little PHP text/numbers game that could be used to pass the time.
Mostly wanted to brush up on a few techniques.
You can play it here,
http://ninja.wysgui.com
You can either log in as one of the bots, 'bot1'-'bot5', or you can create an account.
You get stats by attacking or defending- and winning.
It's a tiny game without much purpose, but it was fun to make :thumbup1:
Using Items (Player)
Items are used to increase some of your numbers. Well, put creatively, they're used to either heal stats, or increase available stats. Each item costs cash, which can be earned by attacking and knocking out other players while winning the final attack. It's not as easy as it sounds. As a player's health gets lower, you can't hit as high. You can only win if you hit harder than your opponent.
Creating Items (Developer)
There's a one-step process to creating items, and it involves PhpMyAdmin.
- Go into PhpMyAdmin, click on the "items" table, and click the tab "Insert"
- Ignore the id field.
- Put the unique name of the item in the value for "name"
- Put a description for what the item does.
- Put the cost for the item (how much cash it takes to buy).
- (The Hard Part!) The field from 'players' table that gets increased. (Such as "total_health" or "remaining_health", or even "cash", if you want to give away free cash.. DO NOT put data such as: "id", "timestamp", "user", "pass" and "email".)
- Enter how much is added to the field from 'players' [This system only supports static addition, rather than dynamic mathematics]
That's It! Insert the row, and the engine will do the rest. Players will be able to buy any item if they have enough cash to cover what you enter in "cost". When they buy it, the column you enter from "players" table, is used to give the player the "boost" they paid for. The row you enter is (in many cases) case-sensitive, so should always be lower-case. It must completely match the name of the column in the "players" table, or a mysql error will be thrown at the event that item is purchased. If you use a field that is not an integer, than problems happen too. So be careful, but have fun ;)
:thumbup1:
Edit: Released.
ninja.zip is the basic one-page set-up with no items.
Features:
- Uses a system for simple, secure includes.
- You can register an account which starts you with 25 of each: "health", "strength" and "defense".
- Password is stored as md5.
- You can attack other players.
- If you win, you get experience.
- You can add comments.
Edit 2: Released ninja-2
*Comes with all the great things the other one has.
Changelog:
- Separated things amongst pages,
- Added "cash" field in table: "players"
- Added "items" table
- Added some sample items (the items table works pretty strict)
- Added a script to sim_attack() function which adds cash when you win and knock your opponent's HP to zero.
- Cleaned up a few things, might be buggy though..
Re: Ninja! (The Game By Spence)
awesome spence :D sauce?
maybe change 30s to 10s because else it gets boring ;)
Re: Ninja! (The Game By Spence)
Lol okay, It was 10 when I was testing :P
Re: Ninja! (The Game By Spence)
nvm my comment, i was thinking that 30s=1hp but i hadnt tested it enough yet.
Re: Ninja! (The Game By Spence)
Why go for me! I'm to weak! I like this game. :drool:
Very nice. :thumbup1:
Re: Ninja! (The Game By Spence)
Nice, live stats bring more fun to the game :)
Re: Ninja! (The Game By Spence)
though it is kinda unfair, u should make it so you can only attack like (x amount of strength) under yours. Also (again): will you be posting the source? Or just your formulas for damage etc.
Re: Ninja! (The Game By Spence)
After you post a commnent, if you refresh the page, you repost it. You should fix that before the spammers get there.
Re: Ninja! (The Game By Spence)
Oh thanks for that, MeetMeInHabbo, fixed it. It saves the comment in a session, and if you post the same thing twice in a row, it doesn't post it. If you refresh after you attack, it attacks again.. We're just going to have to live with that, because the "attack again" link does the same thing..
There's no guard against spam (other than duplicate consecutive posts) but you do need to register before posting.
@EliteGM
That's a good idea about the level protection, can you help?
Sure, I'll release the source.
In the file includes/simulate_attack.php there's a function sim_attack() that has these options:
Code:
$min = 0; //required minimum stats
$exp_plus = (int) 1; //Experience addition
$atk_division = 2; //max strength division
$def_division = 2; //max defense division
$round_subtraction = 1; //remaining_ strength/defense subtraction
It's always possible to add more ;)
Re: Ninja! (The Game By Spence)
Before attacking, just check
Code:
$str_limit = 25; //change if necessary
$def_limit = 15;
if((my_total_str - $str_limit) < opponent_total_str) || ((my_total_def - $def_limit) < opponent_total_def)
{
//stuff
}
or something like that.
also, if you buy something, you have to refresh the page again to actually see that the cash is gone.
Re: Ninja! (The Game By Spence)
Damn that's nice mate =o. I actually had fun checking it out o__O
Re: Ninja! (The Game By Spence)
Okay cool, I fixed the item bug, made it reload user-data after you buy things, to show correct stats..
Implemented strength + defense range (to 25 each). So you can only attack opponents in range.
Cash reward was changed from round(oppenents_hp/4) to:
For attackers,
round(oppenents_hp/3)
For defenders,
round(oppenents_hp/2)
So you get more cash than before no matter what, but defenders get EVEN MORE!
=D
Edit: Because of the nature of defense and strength (they level up completely independent from one-another), some of the bots and players should, but cannot attack each other. I'm thinking of redoing the range bit to be for health only, instead of defense+attack. (As it stands, both defense and strength need to be in the range of your opponent.)
Since HP levels up whether you attack/defend, two people with equal HP are more/less equal in power (strength/defense). So using the HP as the sole range checker is probably best.
After some discussion, I might implement this later today or tomorrow.
Any ideas/input? Like the current set-up? want it changed to hp? don't want a range?
Let me know ;)
Re: Ninja! (The Game By Spence)
btw: small spelling mistake
you're = you are
your = it belongs to you
Re: Ninja! (The Game By Spence)
Whoa, what was I on?
Oh, because I changed it from "You're not strong enough.." to more specific, "You're strength is not in the range.."
That's when I missed it.
Cool, thanks; Fixed it.
Re: Ninja! (The Game By Spence)
Good work s-p-n
I give you some ideas:
- Paging user list (if there are many users, can become very disorganized)
- Making it work will cost. Not only give a button, but you have to do a mission, something more strategic.