• Welcome to The Cave of Dragonflies forums, where the smallest bugs live alongside the strongest dragons.

    Guests are not able to post messages or even read certain areas of the forums. Now, that's boring, don't you think? Registration, on the other hand, is simple, completely free of charge, and does not require you to give out any personal information at all. As soon as you register, you can take part in some of the happy fun things at the forums such as posting messages, voting in polls, sending private messages to people and being told that this is where we drink tea and eat cod.

    Of course I'm not forcing you to do anything if you don't want to, but seriously, what have you got to lose? Five seconds of your life?

PHP Variables to Evolve Eevee

Hiikaru

Run.
Pronoun
he
tl;dr - how can I make eevee evolve on all existing pages conditionally?

Okay, I got all the styles on the Eevee game up and working and it's awesome and my little sister is pretty ecstatic about it (she comments on how great PHP styleswitchers are every time she plays with it now).

But there's one thing that I haven't been able to revive from the old version yet. I use to have it so that there was a Pikachu in a different subdirectory that you could also choose to play with by clicking the Pikachu button. I'd really rather not put all the images and styles and pages in a new Pikachu folder again. I'm looking for a way that I can use PHP variables and functions or something similar to tell the site to replace all Eevees with Pikachus when the variable is turned on by the user.

What I would also like to do with this is make it so you can evolve Eevee. So the navigation bar would have an option to go look at stones, like:

anypage.php
include needs.php!
include navbar.php!
include evo.php!

<page specific Eevee here>
<this page takes away from all $needs that are not it>
<this page adds to the relevant $need>

navbar.php
Feed Eevee (goes to feed.php)
Brush Eevee (goes to brush.php)
Give Eevee drink (goes to drink.php)
Bathe Eevee (goes to bath.php)
Take Eevee to closet (goes to closet.php)
Evolve Eevee (goes to evolve.php)

evolve.php
include evo.php!

use firestone
use waterstone
use thunderstone

And then when you click on whatever stone, it replaces all Eevees with the evolution.

evo.php
$firestone (global replace "images/eevee/" with "images/flareon/" somehow)
$waterstone (global replace "images/eevee/" with "images/vaporeon/" somehow)
$thunderstone (global replace "images/eevee/" with "images/jolteon/" somehow)
$eevee (leave Eevee alone, you guys)

$moon (evolve eevee into Umbreon, plus, only display this if happiness is good)
$sun (evolve eevee into Espeon, plus, only display this if happiness is good)

the $evo variable says:
if user clicks firestone, do $firestone
else if user click waterstone, do $waterstone
else if user clicks thunderstone, do $thunderstone
default = $eevee
also keep this variable no matter what the user does unless they click the magical devolve eevee wand, kthnx

Also, can I use variables to give Eevee happiness, hunger, etc? In the Flash version of the Eevee game, every page that wasn't x took away from x, so if you did anything besides give Eevee food, Eevee slowly got hungrier. When it got hungry enough, something appeared to indicate that Eevee was hungry. When you fed it, the message went away until it got too hungry again. You didn't have to feed it or bathe it or whatever when it wanted you to, it's just something that keeps my sister busy.

needs.php
(describe needs variables here)

if $hunger is <=10, print (Eevee is hungry! &<img indicating hungriness>)
else if $hunger is <=0, print (Eevee is starving!&<img indicating too much hungriness>
else if $hunger=<-100 print (Eevee is dead!&<img of deadness, plus, display an option to revive eevee which resets happiness to zero> optional if she wants Eevee to be able to die, which she might
default is print (nothing at all)

display needs_array in this order, variables earlier in the array cover up the later variables
array order=
$hunger
$thirst
$hygiene

also display happiness at any time
if happiness=0 (do nothing)
if happiness=<10 (show one heart)
if happiness=<20 (show two hearts)
if happiness=<50 (show three hearts, plus, show the option to evolve eevee into Umbreon or Espeon if you view evolve.php)

I've been looking at variable tutorials all day, and I found a script that can do something like this, but it uses a drop down menu.

exampledropdownimageswitcher.php (which isn't really named that)
(my real drop down menu codes are organized better than this)
<?php include("images_and_variables.php") ?>
<form Name = "f1" action="switch1.php" method="post">
<select name="picture">
<option value="none">Select one</option>
<option value="pika">pika</option>
option value="eevee">eevee</option>
</select>
<input type="submit" name = "Submit" Value = "Choose an Image">
</form>
<?php
if (isset($_POST['Submit'])) {
$picture = $_POST['picture'];
if ($picture == "eevee") {
print ("$eevee?");}
else if ($picture == "pika"){
print ("$chu?");}
else {print ("nothing!");}}
?>

Since my sister is five and is still learning to read, this is an image based game, and as such I don't want the drop down menu. Also, I think this particular code would reset back to Eevee on a different page, so that's no good. I would use the same thing for Pikachu except replace Eevee with Pikachu instead of with an evolution. I wouldn't add Pikachu now, except my sister wants him, and I already have the art.

How can I write the code to evolve Eevee?
 
The simplest way would be to use cookies, since this just a random, casual game to keep your sister amused. Have a cookie named "pokemon" or something like that and set it to the name of the current Pokémon, and then on the page, use the picture corresponding to the value of the cookie. You could do a similar thing for the needs - have a cookie for each need and then read and modify their values accordingly.
 
Have a cookie named "pokemon" or something like that and set it to the name of the current Pokémon, and then on the page, use the picture corresponding to the value of the cookie.

What, like...

brush.php
include pokemoncookie.php
<img src=images/$pokemoncookie/brush.gif width=400 height=300>

bath.php
include pokemoncookie.php
<img src=images/$pokemoncookie/bath.gif width=400 height=300>

pokemoncookie.php
$pokemoncookie=
if (variable is set to firestone) do= set $firestone cookie for xxx minutes
if (variable is set to waterstone) do= set $waterstone cookie for xxx minutes
if (variable is set to thunderstone) do=set $thunderstone cookie for xxx minutes
else if default id of cookie=$eevee, leave eevee forever if no stones are used

evonav.php
include pokemoncookie.php

<a href=example.com/page.php?pokemoncookie=firestone><fire stone image></a>
<a href=example.com/page.php?pokemoncookie=waterstone><water stone image></a>
<a href=example.com/page.php?pokemoncookie=thunderstone><thunder stone image></a>

evolve.php
include pokemoncookie.php, include evonav.php

<images/$pokemoncookie/normal.gif>

I'm not sure if I'm doing that right, plus I can't see how that would work for needs at all.

You could do a similar thing for the needs - have a cookie for each need and then read and modify their values accordingly.

Okay, I just can't figure out what "read and modify their values accordingly" is. Read what? ETA: Read the cookies?
 
Last edited:
Yes, read the cookies. And that is more or less how you'd do it, except I can't really see why you want to put pokemoncookie.php in a separate file.

How it would work for needs would be to store (for instance) the hunger value in a cookie so that you can track it between pages, and then you could modify it when it should increase/decrease.
 
Back
Top Bottom