Ejemplo n.º 1
0
 public function test_get_all()
 {
     $x = new Skill();
     $x->characterId = $this->char->characterId;
     $a = new Ability();
     $a->characterId = $this->char->characterId;
     $a->create_defaults($this->dbObj);
     $cache = $a->get_all($this->dbObj, $this->char->id);
     $byAbility = array('str' => array(), 'con' => array(), 'dex' => array(), 'int' => array(), 'wis' => array(), 'cha' => array());
     $this->assertEquals(6, count($byAbility));
     foreach ($this->autoSkills as $k => $theData) {
         $name = $theData[0];
         $ability = $theData[1];
         $insertData = array('character_id' => $x->characterId, 'ability_id' => $cache[$ability]['ability_id'], 'skill_name' => $name);
         $id = $x->create($this->dbObj, $insertData);
         $this->assertTrue(isset($byAbility[$ability]));
         $this->assertFalse(isset($byAbility[$ability][$id]));
         $byAbility[$ability][$id] = $insertData;
     }
     $this->assertEquals(6, count($byAbility));
     foreach ($byAbility as $ability => $data) {
         $aId = $cache[$ability]['ability_id'];
         $testData = $x->get_all($this->dbObj, $x->characterId, $aId);
         $this->assertTrue(is_array($testData));
         foreach ($testData as $k => $v) {
             $this->assertTrue(is_array($v));
             $this->assertTrue(isset($v['ability_id']));
             $this->assertEquals($aId, $v['ability_id']);
         }
         $this->assertEquals(count($data), count($testData), "getting skills based on ability id (" . $ability . "/" . $aId . ") failed...");
     }
 }
Ejemplo n.º 2
0
 public function texst_delete()
 {
     $x = new Ability();
     $x->characterId = $this->id;
     $x->create_defaults($this->dbObj);
     $allRecords = $x->get_all($this->dbObj, $this->id);
     $this->assertTrue(count($allRecords) > 0);
     $keys = array_keys($allRecords);
     $lastRec = count($allRecords);
     foreach ($allRecords as $ability => $data) {
         $this->assertEquals($lastRec, count($x->get_all($this->dbObj, $this->id)));
         $this->assertTrue(is_string($ability), "ID=(" . $ability . ")");
         $this->assertTrue(is_array($data));
         $this->assertTrue(count($data) > 0);
         $x->id = $data['character_ability_id'];
         $this->assertEquals(1, $x->delete($this->dbObj));
         $lastRec--;
     }
     $this->assertEquals(0, $lastRec);
     $allAbilities = $x->get_all($this->dbObj, $this->id);
     $this->assertEquals(0, count($allAbilities), cs_global::debug_print($allAbilities));
     $this->assertEquals(array(), $allAbilities);
 }
 public function load()
 {
     $retval = array();
     if (is_numeric($this->characterId) && $this->characterId > 0) {
         $this->_char = new Character($this->characterId, $this->ownerUid, $this->dbObj);
         $this->_char->load($this->dbObj);
         $this->_abilities = Ability::get_all($this->dbObj, $this->characterId);
         $retval['abilities'] = $this->_abilities;
         $this->_armor = Armor::get_all($this->dbObj, $this->characterId);
         $retval['armor'] = $this->_armor;
         $this->_gear = Gear::get_all($this->dbObj, $this->characterId);
         $retval['gear'] = $this->_gear;
         $this->_saves = Save::get_all($this->dbObj, $this->characterId);
         $retval['saves'] = $this->_saves;
         $this->_skills = Skill::get_all($this->dbObj, $this->characterId);
         $retval['skills'] = $this->_skills;
         $this->_specialAbilities = SpecialAbility::get_all($this->dbObj, $this->characterId);
         $retval['specialAbilities'] = $this->_specialAbilities;
         $this->_weapons = Weapon::get_all($this->dbObj, $this->characterId);
         $retval['weapons'] = $this->_weapons;
     } else {
         throw new ErrorException(__METHOD__ . ": invalid character id");
     }
     return $retval;
 }