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; }
public function hasDiablerized() { if (CharacterDiablerieExperience::where('character_id', $this->id)->exists()) { return true; } if (CharacterFlaw::where('character_id', $this->id)->whereHas('definition', function ($q) { $q->where('name', 'Prior Diablerie'); })->exists()) { return true; } return false; }