Skip to content

Commit

Permalink
gameover inital work
Browse files Browse the repository at this point in the history
-Party class modifyed to include _leader variable and edited killcheck() function to update leader.
-gameover used to give short gameover dialouge
-gameover2 provides database functionality and clears session.  Not particuarlly well-tested, may need to be tested with proper  datebase connection.
-closses issue #28: Make gameover.php
  • Loading branch information
adamwe1 committed May 13, 2017
1 parent e979db1 commit aa1854b
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
16 changes: 16 additions & 0 deletions classes.php
Expand Up @@ -136,6 +136,7 @@ class Party
public $_health = "Good"; #general health of the party
public $_supplies; #supplies class instant
public $_livingMembers = 5; #licing members of the party
public $_leader;
public $_rate = 3; #rate at which food is eaten
public $_job;
public $_jobVal = [["empty",0],["Banker", 1600.00],
Expand All @@ -150,6 +151,7 @@ public function __construct($names, $job)
$this->_members[3] = new PartyMember($names[3]);
$this->_members[4] = new PartyMember($names[4]);

$this->_leader = $names[0];
#supplies made by passing in starting money
$this->_job = $job;

Expand All @@ -174,21 +176,35 @@ public function eat()
#checks if any members can be killed (has 0 health)
public function killCheck()
{
$checkLeader = false;
foreach($this->_members as $body)
{
if($body->_alive)
{
if($body->_health <= 0)
{
$checkLeader = true;
$body->_alive = false;
$this->_livingMembers-=1;

}
}
}
if ($checkLeader)
{
foreach($this->_members as $body)
{
if($body->_alive)
{
$this->_leader = $body->_name;
break;
}
}

#code for when all members are dead
#ends game
}
}

#averages health and assigns a rating
public function health()
Expand Down
28 changes: 28 additions & 0 deletions gameover.php
@@ -0,0 +1,28 @@
<?php
include "classes.php";
session_start();

include "commonUI.php";
startHTML("Game Over");

$location = $_SESSION["playerJourney"]->_distance;
$leader = $_SESSION["playParty"]->_leader;
?>
<p>
Here Lies <?php echo $leader; ?><br>
You died <?php echo $location; ?> miles along the path.<br>
You were <?php echo 2000 - $location; ?> miles from your goal<br>

What would you like on your tombstone?
<form action="gameover2.php">
<input type = "text" name="message">
<input type = "submit" value="Enter">
</form>

</p>



<?php
endHTML();
?>
29 changes: 29 additions & 0 deletions gameover2.php
@@ -0,0 +1,29 @@
<?php
include "classes.php";
session_start();
include "scoresAndDeaths.php";
include "commonUI.php";
startHTML("inbetween");
?>

<meta http-equiv="refresh" content="0; url= index.php" />

<?php

$leader = $_SESSION["playParty"]->_leader;
$location = $_SESSION["playerJourney"]->_distance;
$message = $_GET["$message"];
$month = $_SESSION["playerJourney"]->_month;
$day = $_SESSION["playerJourney"]->_date;



$otd = new OregonTrailDatabase("eritte2","eritte2");
$conn = $otd->connect();
if ($conn)
{
$otd->addDeath($leader, $location, $message, $month, $day);
}
erase_session();
endHTML();
?>

0 comments on commit aa1854b

Please sign in to comment.