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); }
foreach ($value as $k => $v) { $name = RulebookBackground::find($k)->name; if (isset($v['description'][0])) { $name .= ": " . $v["description"][0]; } else { if (isset($v['description'][1])) { $name .= ": " . $v["description"][1]; } } print_change($name, @$v["amount"], ["Initial purchase of Dots.", "[change] Dots from -> .", "Removed all Dots."]); } } if ($key == "rituals") { echo "<h5>Rituals</h5>"; foreach ($value as $k => $v) { print_change("", $v["character_id"][0] == null ? [null, RulebookRitual::find($k)->name] : [RulebookRitual::find($k)->name, null], ["Purchased .", "[change]", "Removed ."]); } } if ($key == "derangements") { echo "<h5>Derangements</h5>"; foreach ($value as $k => $v) { $description = ""; if (isset($v['description'][0])) { $description = " (Description: <i> " . $v["description"][0] . "</i>)"; } else { if (isset($v['description'][1])) { $description = " (Description: <i> " . $v["description"][1] . "</i>)"; } } if (isset($v["character_id"])) { print_change("", !isset($v["character_id"]) || $v["character_id"][0] == null ? [null, RulebookDerangement::find($k)->name] : [RulebookDerangement::find($k)->name, null], ["Purchased {$description}.", "[change]", "Removed {$description}."]);
public function addRitualToBook($name, $description, $type) { $customRitual = new RulebookRitual(); $customRitual->name = $name; $customRitual->description = $description; $customRitual->group = $type; $customRitual->isCustom = true; $customRitual->owner = $this->character_id; $customRitual->save(); //Add this ritual to the lookup table so that we can use it's fake ID. $this->idLookup["rituals"][$ritualData["id"]] = $customRitual->id; }
public function testStorytellerPurchaseRitual() { self::$version->setEditingUser(self::$storyteller); $this->assertCostDifference(0, function () { self::$version->addRitual(RulebookRitual::where('group', 'Basic')->skip(2)->first()->id); }); $this->assertCostDifference(0, function () { self::$version->addRitual(RulebookRitual::where('group', 'Intermediate')->skip(1)->first()->id); }); $this->assertCostDifference(0, function () { self::$version->addRitual(RulebookRitual::where('group', 'Advanced')->skip(1)->first()->id); }); }