Esempio n. 1
0
 public function addMerit(RulebookMerit $merit, $description = null)
 {
     $query = CharacterMerit::character($this->character_id)->version($this->version)->where('merit_id', $merit->id)->where('bought_off', false);
     if ($description) {
         $query = $query->where('description', $description);
     } else {
         $query = $query->whereNull('description');
     }
     $meritRecord = $query->first();
     if (!$meritRecord) {
         $meritRecord = $this->createNewRecord("CharacterMerit");
         $meritRecord->merit_id = $merit->id;
         if ($this->editingAsStoryteller()) {
             $meritRecord->free_points += $merit->cost;
         } else {
             if (!$this->isNewCharacter()) {
                 $meritRecord->lost_points = $merit->cost;
             }
         }
         if ($description) {
             $meritRecord->description = $description;
         }
         $meritRecord->save();
     }
     $this->touchedRecords["CharacterMerit"][] = $meritRecord->id;
 }
Esempio n. 2
0
 public function merits($version = -1, $ignoreBoughtOff = false)
 {
     if ($version == -1) {
         $version = $this->activeVersion();
     }
     if ($ignoreBoughtOff) {
         return CharacterMerit::character($this->id)->version($version);
     }
     return CharacterMerit::character($this->id)->where('bought_off', false)->version($version);
 }