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); }
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] . "."]); } } } if (Auth::user()->isStoryteller()) { if ($version > $character->approved_version) { ?> <form method="POST" action="/dashboard/storyteller/character/{{$character->id}}/accept" style="display: inline-block;"><input type="submit" class="button medium success" value="Accept Changes" /></form> <form method="POST" action="/dashboard/storyteller/character/{{$character->id}}/reject" style="display: inline-block;"><input type="submit" class="button medium alert" value="Reject Changes" /></form> <?php } else {
public function testStorytellerPurchaseVirtue() { self::$version->setEditingUser(self::$storyteller); $this->assertCostDifference(0, function () { self::$version->updatePath(RulebookPath::find(1), 5, 4, 5, 3); }); }
echo "<div class='description'>{$description}</div>"; } echo "</li>"; } } ?> <div class="row left"> <div class="small-12"> <a href="/dashboard/storyteller/manage/cheatsheet" class="hide-for-print"> <button class="manage-link button tiny">Edit Settings</button> </a> <h4>Paths and Sins</h4> @foreach($unique_paths as $p) <div class="path-box"> <?php $path = RulebookPath::find($p); ?> <b>{{$path->name}}</b><br> @foreach($path->sins() as $index => $sin) {{5 - ($index)}}: {{$sin}}<br> @endforeach </div> @endforeach </div> <div class="small-12 character-listing"> <h4>Characters</h4> @foreach($characters as $index => $c) @if($index % 2 == 0) <div class="character-row"> @endif <div class="character-box">
public function save() { $user = Auth::user(); $character = Character::find(Input::get('characterId')); if (!$character) { $character = new Character(); $characterIsNew = true; } if (!isset($character->user_id)) { $character->user_id = $user->id; } $character->name = Input::get("sheet.name"); $character->save(); CharacterVersion::where('character_id', $character->id)->where('version', '>', $character->approved_version)->delete(); $version = CharacterVersion::createNewVersion($character, Input::has("comment") ? Input::get("comment") : null); if ($version->isNewCharacter()) { $version->setHasDroppedMorality(Input::get("sheet.hasDroppedMorality") == "true"); } try { $version->setEditingUser($user); if (Input::get("sheet.sect.selected")) { $version->setSect(RulebookSect::find(Input::get("sheet.sect.selected")), RulebookSect::find(Input::get("sheet.sect.displaying"))); } if (Input::get("sheet.clan.selected")) { $version->setClan(RulebookClan::find(Input::get("sheet.clan.selected")), RulebookClan::find(Input::get("sheet.clan.displaying"))); } $version->setClanOptions(Input::get("sheet.clanOptions.0"), Input::get("sheet.clanOptions.1"), Input::get("sheet.clanOptions.2")); if (Input::get("sheet.nature")) { $version->setNature(RulebookNature::find(Input::get("sheet.nature"))); } if (Input::get("sheet.willpower")) { $version->setWillpower(Input::get("sheet.willpower.dots"), Input::get("sheet.willpower.traits")); } if (Input::get("sheet.attributes")) { $version->setAttributes(Input::get("sheet.attributes.physicals"), Input::get("sheet.attributes.mentals"), Input::get("sheet.attributes.socials")); } foreach ((array) Input::get("sheet.abilities") as $ability) { if (array_key_exists("specialization", $ability)) { $version->addAbilityWithSpecialization(RulebookAbility::find($ability["id"]), $ability["count"], $ability["specialization"], $ability["name"]); } else { $version->addAbility(RulebookAbility::find($ability["id"]), $ability["count"], $ability["name"]); } } foreach ((array) Input::get("sheet.disciplines") as $discipline) { $version->updateDiscipline(RulebookDiscipline::find($discipline["id"]), $discipline["count"], array_key_exists("path", $discipline) ? $discipline["path"] : 0); } foreach ((array) Input::get("newRituals") as $newRitualData) { $version->addRitualToBook($newRitualData["name"], $newRitualData["description"], $newRitualData["type"]); } foreach ((array) Input::get("sheet.rituals") as $ritualId) { $version->addRitual($ritualId); } if (Input::get("sheet.path")) { $version->updatePath(RulebookPath::find(Input::get("sheet.path")), Input::get("sheet.virtues.0"), Input::get("sheet.virtues.1"), Input::get("sheet.virtues.2"), Input::get("sheet.virtues.3")); } foreach ((array) Input::get("sheet.merits") as $meritData) { $version->addMerit(RulebookMerit::find($meritData["id"]), array_key_exists("description", $meritData) ? $meritData["description"] : null); } foreach ((array) Input::get("sheet.flaws") as $flawData) { $version->addFlaw(RulebookFlaw::find($flawData["id"]), array_key_exists("description", $flawData) ? $flawData["description"] : null); } foreach ((array) Input::get("sheet.derangements") as $derangementData) { $version->addDerangement(RulebookDerangement::find($derangementData["id"]), array_key_exists("description", $derangementData) ? $derangementData["description"] : null); } foreach ((array) Input::get("sheet.backgrounds") as $backgroundData) { $version->addBackground(RulebookBackground::find($backgroundData["id"]), $backgroundData["count"], array_key_exists("description", $backgroundData) ? $backgroundData["description"] : null); } foreach ((array) Input::get("sheet.elderPowers") as $elderData) { $version->addElderPower($elderData); } foreach ((array) Input::get("sheet.comboDisciplines") as $comboData) { $version->addComboDiscipline($comboData); } $version->clearUntouchedRecords(); } catch (Exception $e) { throw $e; } return $version; }