public function addFlaw(RulebookFlaw $flaw, $description = null)
 {
     $query = CharacterFlaw::character($this->character_id)->version($this->version)->where('flaw_id', $flaw->id)->where('bought_off', false);
     if ($description) {
         $query = $query->where('description', $description);
     } else {
         $query = $query->whereNull('description');
     }
     $flawRecord = $query->first();
     if (!$flawRecord) {
         $flawRecord = $this->createNewRecord("CharacterFlaw");
         $flawRecord->flaw_id = $flaw->id;
         if ($this->editingAsStoryteller() || !$this->isNewCharacter()) {
             $flawRecord->lost_points += $flaw->cost;
         }
         if ($description) {
             $flawRecord->description = $description;
         }
         $flawRecord->save();
     }
     $this->touchedRecords["CharacterFlaw"][] = $flawRecord->id;
 }
Beispiel #2
0
 public function flaws($version = -1, $ignoreBoughtOff = false)
 {
     if ($version == -1) {
         $version = $this->activeVersion();
     }
     if ($ignoreBoughtOff) {
         return CharacterFlaw::character($this->id)->version($version);
     }
     return CharacterFlaw::character($this->id)->where('bought_off', false)->version($version);
 }