Esempio n. 1
0
 public function buildRulebook($owner = -1)
 {
     //Build rulebook or retrieve it from the cache.
     $out = Cache::remember('rulebook', 24 * 60, function () {
         $baseRulebook = [];
         $baseRulebook['sects'] = $this->expandSects(RulebookSect::get());
         $baseRulebook['clans'] = $this->expandClans(RulebookClan::get());
         $baseRulebook['rituals'] = $this->sortByGroups(RulebookRitual::whereNull('owner')->get(), "rituals");
         $baseRulebook['backgrounds'] = $this->sortByGroups(RulebookBackground::orderBy('name')->get(), "backgrounds");
         $baseRulebook['disciplines'] = $this->expandDisciplines(RulebookDiscipline::orderBy('name')->get());
         $baseRulebook['natures'] = RulebookNature::get();
         $baseRulebook['abilities'] = $this->sortByGroups(RulebookAbility::where('owner', null)->orderBy('name')->get(), "abilities");
         $baseRulebook["paths"] = $this->expandPaths(RulebookPath::get());
         $baseRulebook["derangements"] = RulebookDerangement::get();
         $baseRulebook['merits'] = $this->sortByGroups(RulebookMerit::orderBy("cost")->get(), "merits");
         $baseRulebook['flaws'] = $this->sortByGroups(RulebookFlaw::orderBy("cost")->get(), "flaws");
         return $baseRulebook;
     });
     if ($owner != -1) {
         $out['custom_abilities'] = RulebookAbility::where('owner', $owner)->get();
         $out['elder_powers'] = RulebookElderPower::where('owner_id', $owner)->get();
         $out['combo_disciplines'] = RulebookComboDiscipline::where('owner_id', $owner)->get();
         $out['custom_rituals'] = RulebookRitual::where('owner', $owner)->get();
     }
     return Response::json($out);
 }
Esempio n. 2
0
                 $diff_array = $diff > 0 ? [null, $discipline->ranks()->get()[$i]->name . " (" . $discipline->name . " " . ($i + 1) . ")"] : [$discipline->ranks()->get()[$i]->name . " (" . $discipline->name . " " . ($i + 1) . ")", null];
                 print_change("", $diff_array, ["Purchased .", "[change]", "Removed ."]);
             }
         }
     }
 }
 if ($key == "elderPowers" && sizeof($value) > 0) {
     echo "<h5>Elder Powers</h5>";
     foreach ($value as $k => $v) {
         print_change("", $v["character_id"][0] == null ? [null, RulebookElderPower::find($k)->name] : [RulebookElderPower::find($k)->name, null], ["Purchased .", "[change]", "Removed ."]);
     }
 }
 if ($key == "comboDisciplines" && sizeof($value) > 0) {
     echo "<h5>Combo Disciplines</h5>";
     foreach ($value as $k => $v) {
         print_change("", $v["character_id"][0] == null ? [RulebookComboDiscipline::find($k)->name, null] : [null, RulebookComboDiscipline::find($k)->name], ["Purchased .", "[change]", "Removed ."]);
     }
 }
 if ($key == "path") {
     echo "<h5>Path</h5>";
     $path = $character->path($character->latestVersion()->version)->first();
     if ($path) {
         $path = $path->definition;
         print_change("", @$value["path_id"], ["Began on .", "Changed from  -> .", "Removed path (Is this a mistake?)."], function ($val) {
             return RulebookPath::find($val)->name;
         });
         print_change("", @$value["virtue1"], ["Began with  Dots of " . $path->stats()[0] . ".", "[change] Dots of " . $path->stats()[0] . " from  -> .", "Removed all Dots of " . $path->stats()[0] . "."]);
         print_change("", @$value["virtue2"], ["Began with  Dots of " . $path->stats()[1] . ".", "[change] Dots of " . $path->stats()[1] . " from  -> .", "Removed all Dots of " . $path->stats()[1] . "."]);
         print_change("", @$value["virtue3"], ["Began with  Dots of " . $path->stats()[2] . ".", "[change] Dots of " . $path->stats()[2] . " from  -> .", "Removed all Dots of " . $path->stats()[2] . "."]);
         print_change("", @$value["virtue4"], ["Began with  Dots of " . $path->stats()[3] . ".", "[change] Dots of " . $path->stats()[3] . " from  -> .", "Removed all Dots of " . $path->stats()[3] . "."]);
     }
Esempio n. 3
0
 public function addComboDiscipline($comboData)
 {
     $comboRecord = $this->findOneWhere('CharacterComboDiscipline', 'combo_id', $comboData['id']);
     if (!$comboRecord) {
         $comboDefinition = RulebookComboDiscipline::firstOrCreate(["owner_id" => $this->character_id, "name" => $comboData["name"], "option1" => $comboData["option1"], "option2" => $comboData["option2"], "option3" => strlen($comboData["option3"]) == 0 ? null : $comboData["option3"], "description" => $comboData["description"]]);
         $comboRecord = $this->createNewRecord("CharacterComboDiscipline");
         $comboRecord->combo_id = $comboDefinition->id;
         if ($this->editingAsStoryteller()) {
             $comboRecord->free_points = $comboDefinition->cost($this->character_id);
         }
         $comboRecord->save();
     }
     $this->touchedRecords["CharacterComboDiscipline"][] = $comboRecord->id;
 }