コード例 #1
0
 public function awardExperience(GameSession $session)
 {
     $ids = Input::get("ids");
     $costumes = Input::get("costumes");
     $nom1s = Input::get("nom1s");
     $nom2s = Input::get("nom2s");
     $overrides = Input::get("overrides");
     $save = Input::get("save");
     $missingCharacters = [];
     foreach ($ids as $index => $id) {
         $character = Character::find($id);
         if ($character) {
             $checkIn = GameSessionCheckIn::where(['session_id' => $session->id, 'character_id' => $character->id])->first();
             $checkIn->costume = $costumes[$index] == "true" ? 1 : 0;
             $checkIn->nominated = $nom1s[$index] == "true" ? 1 : 0;
             $checkIn->nominated_twice = $nom2s[$index] == "true" ? 1 : 0;
             $checkIn->bonus = $overrides[$index];
             $checkIn->total_experience = 1 + ($checkIn->costume ? 1 : 0) + ($checkIn->nominated ? 1 : 0) + ($checkIn->nominated_twice ? 1 : 0) + $checkIn->bonus;
             $checkIn->save();
             if (!isset($save)) {
                 $owner = $character->owner;
                 $owner->sendMessage(null, "Experience awarded to " . $character->name, "The Storytellers have awarded your character " . $checkIn->total_experience . " Experience. You can now use the character editor to make changes to it at" . " your leisure. Remember, changes should be submitted by 6:00pm on the Wednesday" . " before a game to ensure that they have the chance to review them.");
                 $character->awardExperience($checkIn->total_experience);
                 $character->save();
             }
         } else {
             $missingCharacters[] = $id;
         }
     }
     if (!isset($save)) {
         $session->submitted = true;
         $session->save();
         foreach (User::listStorytellers() as $st) {
             $st->sendMessage(null, "Experience successfully awarded", "The action to award experience for the session on " . $session->date . " has completed." . (sizeof($missingCharacters) > 0 ? "\n\n" . sizeof($missingCharacters) . " characters were" . " not found (" . implode(",", $missingCharacters) . ")" : ''));
         }
         return Redirect::to("/dashboard");
     } else {
         return Redirect::to("/dashboard/storyteller/session/experience/{$session->id}");
     }
 }
コード例 #2
0
ファイル: ForumPost.php プロジェクト: AcceptableIce/Larp3
 public static function render($body)
 {
     //First off, look for tags.
     $matches = [];
     $body = preg_replace_callback("/\\[\\[([\\w\\W]+?)\\]\\]/", function ($match) {
         $arguments = explode("/", $match[1]);
         switch (strtolower($arguments[0])) {
             case "change":
                 $id = intval($arguments[1]);
                 $char = Character::find($id);
                 if ($char && (Auth::user()->isStoryteller() || Auth::user()->id == $char->user_id) && sizeof($arguments) == 3) {
                     return View::make('partials/changes', ['character' => $char, 'version' => $arguments[2]])->render();
                 }
                 break;
             case "questionnaire":
                 $id = intval($arguments[1]);
                 $char = Character::find($id);
                 if ($char && (Auth::user()->isStoryteller() || Auth::user()->id == $char->user_id)) {
                     return View::make('partials/questionnaire', ['character' => $char])->render();
                 }
                 break;
             case "handbook":
                 return "<div class='handbook-page'>" . View::make('partials/handbookPage', ['title' => $arguments[1]])->render() . "</div>";
             case 'influence':
                 if (sizeof($arguments) == 2) {
                     $capName = $arguments[1];
                     $cap = InfluenceCap::whereHas('definition', function ($q) use($capName) {
                         $q->where('name', $capName);
                     })->first();
                     if ($cap) {
                         return $cap->capacityString();
                     }
                 }
                 break;
             case "character":
                 $char = Auth::user()->activeCharacter();
                 if (sizeof($arguments) == 3 && $char) {
                     $type = $arguments[1];
                     $value = $arguments[2];
                     switch (strtolower($type)) {
                         case "background":
                             return $char->getBackgroundDots($value);
                     }
                 }
                 break;
             case "deadline":
                 //Determine if we're past the deadline.
                 $now = new DateTime();
                 $now->setTime(0, 0);
                 $nextGame = GameSession::where('date', '>=', $now)->orderBy('date')->first();
                 if ($nextGame) {
                     $date = new DateTime($nextGame->date);
                     $date->setTimezone(new DateTimeZone("America/Chicago"));
                     $date->modify("6 hours");
                     //Fix timezone offset
                     $date->setTime(19, 00);
                     $deadlineDate = new DateTime($nextGame->date);
                     $deadlineDate->setTimezone(new DateTimeZone("America/Chicago"));
                     $deadlineDate->modify('previous Wednesday, 6 PM CST');
                     if (new DateTime() > $deadlineDate) {
                         return '<span class="past-deadline">No more changes can be submitted this cycle.</span>';
                     }
                     return 'Changes can still be submitted.';
                 }
                 return 'Could not find the next session';
                 break;
         }
         return $match[0];
     }, $body);
     //Check for @mentions
     $body = preg_replace_callback("/(?<=^|(?<=[^a-zA-Z0-9-_\\.]))@([A-Za-z0-9!#\$%\\-^&*]+|{[A-Za-z]+[A-Za-z0-9 !#\$%\\-^&*]+})/", function ($match) {
         $username = $match[1];
         if (strtolower($username) == "andrew") {
             $username = "******";
         }
         if ($username[0] == "{") {
             $username = substr($username, 1, strlen($username) - 2);
         }
         $user = User::where('username', 'like', $username)->first();
         if ($user) {
             return "<div class='mention'>@" . $user->mailtoLink() . "</div>";
         }
         return $username;
     }, $body);
     return $body;
 }
コード例 #3
0
function build_calendar($month, $year, $dateArray)
{
    // Create array containing abbreviations of days of week.
    $daysOfWeek = array('S', 'M', 'T', 'W', 'T', 'F', 'S');
    // What is the first day of the month in question?
    $firstDayOfMonth = mktime(0, 0, 0, $month, 1, $month == 0 ? $year + 1 : $year);
    // How many days does this month contain?
    $numberDays = date('t', $firstDayOfMonth);
    // Retrieve some information about the first day of the
    // month in question.
    $dateComponents = getdate($firstDayOfMonth);
    // What is the name of the month in question?
    $monthName = $dateComponents['month'];
    // What is the index value (0-6) of the first day of the
    // month in question.
    $dayOfWeek = $dateComponents['wday'];
    // Create the table tag opener and day headers
    $calendar = "<table class='calendar'>";
    $calendar .= "<caption>{$monthName} {$year}</caption>";
    $calendar .= "<tr>";
    // Create the calendar headers
    foreach ($daysOfWeek as $day) {
        $calendar .= "<th class='header'>{$day}</th>";
    }
    // Create the rest of the calendar
    // Initiate the day counter, starting with the 1st.
    $currentDay = 1;
    $calendar .= "</tr><tr>";
    // The variable $dayOfWeek is used to
    // ensure that the calendar
    // display consists of exactly 7 columns.
    if ($dayOfWeek > 0) {
        $calendar .= "<td colspan='{$dayOfWeek}' class='calendar-buffer'>&nbsp;</td>";
    }
    $month = str_pad($month, 2, "0", STR_PAD_LEFT);
    while ($currentDay <= $numberDays) {
        // Seventh column (Saturday) reached. Start a new row.
        if ($dayOfWeek == 7) {
            $dayOfWeek = 0;
            $calendar .= "</tr><tr>";
        }
        $currentDayRel = str_pad($currentDay, 2, "0", STR_PAD_LEFT);
        if ($month == 00) {
            $month = 12;
        }
        $date = "{$year}-{$month}-{$currentDayRel}";
        $refDate = new DateTime($month . "/" . $currentDay . "/" . $year);
        $gameClass = GameSession::where('date', $refDate)->exists() ? 'game-day' : '';
        $calendar .= "<td class='day {$gameClass}' rel='{$date}'>{$currentDay}</td>";
        // Increment counters
        $currentDay++;
        $dayOfWeek++;
    }
    // Complete the row of the last week in month, if necessary
    if ($dayOfWeek != 7) {
        $remainingDays = 7 - $dayOfWeek;
        $calendar .= "<td class='calendar-buffer' colspan='{$remainingDays}'>&nbsp;</td>";
    }
    $calendar .= "</tr>";
    $calendar .= "</table>";
    return $calendar;
}
コード例 #4
0
ファイル: Character.php プロジェクト: AcceptableIce/Larp3
 public function gamesMissed()
 {
     $last_game = GameSessionCheckIn::where('character_id', $this->id)->join('sessions as session', 'session.id', '=', 'session_id')->orderBy('date', 'desc')->first();
     if ($last_game) {
         return GameSession::where('date', '>', $last_game->date)->where('submitted', 1)->count();
     }
     return -1;
 }