$newchar->addCard($newcard); $newchar->saveCharacter(); //$newchar->printCharInfo(); echo '<br /><br />Adding a second card: '; $testcard->printCardInfo(); $newchar->addCard($testcard); $newchar->saveCharacter(); echo '<br /><br />Resulting character: '; $newchar->printCharInfo(); echo '<br /><br />Removed a card: '; $newchar->removeCard($newcard); $newchar->saveCharacter(); $newchar->printCharInfo(); echo '<br /><br />Get a copy of the character from the DB'; $charcopy = new Character($uidtotest, '', 0); $charcopy->getCharacter($newchar->getCharID(), $uidtotest); echo '<br /><br />Comparing the copy to the original: '; //$newchar->printCharInfo(); $newchar_str = $newchar->strRepresentation(); //$charcopy->printCharInfo(); $charcopy_str = $charcopy->strRepresentation(); if ($newchar_str == $charcopy_str) { //Then the original and copy are the same. print "<br />The two character objects <font color='green'>match</font> as expected - <br />"; $newchar->printCharInfo(); $goodtests++; } else { print "<br />The original object <font color='red'>does not</font> match the copy of the object as expected.<br />"; $newchar->printCharInfo(); print "<br /><br />"; $charcopy->printCharInfo();
case 'save_character': if (!$char) { echo json_encode("failure"); } else { $char->saveCharacter(); $_SESSION['char'] = serialize($char); } break; case 'del_character': if (!isset($_POST['charid'])) { echo json_encode("failure"); } else { $charid = intval($_POST['charid']); $delchar = new Character($userid, '', 0); $delchar->getCharacter($charid, $userid); if ($delchar->getCharID() == $char->getCharID()) { $_SESSION['char'] = serialize(new Character($userid, '', 0)); } $delchar->delCharacter(); } break; case 'get_charid': if (!$char) { echo json_encode("failure"); } else { echo json_encode("" . $char->getCharID()); } break; case 'set_charname': if (!$char) { echo json_encode("failure");