public function getFractalSheet() { $sheet = <<<EOT <style type='text/css'> #charsheet h2 { margin: 0; font-weight: normal; position: relative; font-size: 18px; line-height: 20px; background: #295079; padding: 5px 15px; color: white; border-radius: 0 10px 0 0; font-family: Tahoma, Geneva, sans-serif; } #charsheet .modes h3 { color: #295079; font-family: Tahoma, Geneva, sans-serif; text-align: right; vertical-align: middle; padding: 0px; margin: 0px; } #charsheet .modes h4 { color: #295079; font-family: Tahoma, Geneva, sans-serif; white-space: nowrap; padding: 0px; } #charsheet .modes { width: 100%; border-spacing: 0px; margin-bottom: 0.5em; } #charsheet .modes td { padding: 3px; } #charsheet .modes span { font-weight: bold; } #charsheet .modes tr:nth-child(even) { background-color: #BDD1EC; } #charsheet .block { border: 2px solid #295079; width: auto; margin: 0 0 0.5em 0;padding: 5px 15px; position: relative; } #charsheet .block.consequence { margin-left: 1em; } #charsheet .block.stress { margin-left: 1em; float: left; margin-right: .5em; font-family: monospace; font-size: 22px; font-weight: bold; } #charsheet .block.consequence .value, #charsheet .block.stress .value { position: absolute; font-family: Tahoma, Geneva, sans-serif; font-size: 28px; font-weight: bold; left: -13px; top: -4px; color: #295079} #charsheet .block .block_label { position: absolute; font-family: Tahoma, Geneva, sans-serif; margin: 0px; padding: 0px; font-weight: bold; font-size: 10px; line-height: 10px; top: 0px; left: 2px; color: #999999;} .skill_label { vertical-align: middle; text-align: right; font-size: 18px; font-family: Tahoma, Geneva, sans-serif; } .fate { font-family: monospace; font-size: 22px; font-weight: bold; text-align: center; } .name { font-size: 20px; font-family: Tahoma, Geneva, sans-serif; } #charsheet .approaches .block { padding: 5px 8px; margin: 0 10px 0 5px;} </style> <div id='charsheet'> <div class='name'>{$this->name}</div> EOT; if (array_key_exists(FateGameGlobals::STAT_ASPECT, $this->stats)) { $sheet .= "<H2>ASPECTS</h2>\n"; foreach ($this->stats[FateGameGlobals::STAT_ASPECT] as $aspect) { $sheet .= "<div class='block'>"; if ($aspect->{stat_label}) { $sheet .= "<div class='block_label'>" . $aspect->{stat_label} . "</div>"; } $sheet .= $aspect->{stat_field} . "</div>\n"; } } if (array_key_exists(FateGameGlobals::STAT_SKILL, $this->stats)) { $sheet .= "<H2>" . strtoupper($this->fate_game->skill_alternative ? $this->fate_game->skill_alternative : 'SKILLS') . "</H2>"; if ($this->fate_game->skill_distribution == FateGameGlobals::SKILL_DISTRIBUTION_APPROACHES) { $sheet .= "<table class='approaches'>"; $rows = array(); $count = 0; foreach ($this->stats[FateGameGlobals::STAT_SKILL] as $skill) { $rows[$count] .= "<td class='skill_label'><p>" . $skill->{stat_label} . "</p></td>" . "<td><div class='block'>+" . $skill->{stat_value} . "</div></td>"; $count++; $count %= 2; } $sheet .= "<tr>" . $rows[0] . "</tr><tr>" . $rows[1] . "</tr></table>"; } elseif ($this->fate_game->skill_distribution == FateGameGlobals::SKILL_DISTRIBUTION_MODES) { $ladder = FateGameGlobals::getLadder(); $levels = array_reverse(FateGameGlobals::getModeLevels(), true); $sheet .= "<table class='modes'><tr><td> </td>"; foreach ($this->stats[FateGameGlobals::STAT_MODE] as $mode) { $mode_label = strtoupper($ladder[$mode->{stat_value}] . " (+" . $mode->{stat_value} . ") " . $mode->{stat_field}); $sheet .= "<td><h4>{$mode_label}</h4></td>"; } $sheet .= "</tr>"; foreach ($levels as $level => $label) { $sheet .= "<tr><td><h3>" . strtoupper($label) . "</h3></td>"; foreach ($this->stats[FateGameGlobals::STAT_MODE] as $mode) { $this_mode = $this->skills_by_mode[$mode->{fractal_stat_id}]; if (count($this_mode['skills_by_level'][$level]) > 0) { $level_label = $ladder[$this_mode['mode_value'] + $level] . " (+" . ($this_mode['mode_value'] + $level) . "):"; $label_list = array(); foreach ($this_mode['skills_by_level'][$level] as $skill) { $label_list[] = $skill->{stat_label}; } $sheet .= "<td><span>{$level_label}</span> " . implode(", ", $label_list) . "</td>"; } else { $sheet .= "<td> </td>"; } } $sheet .= "</tr>"; } $sheet .= "</table>"; } /* Other Skill Distributions eventually go here */ } if (array_key_exists(FateGameGlobals::STAT_MOOK, $this->stats)) { $sheet .= "<h2>MOOK SKILLS</h2>\n"; $levels = FateGameGlobals::getMookLevels(); $last_label = ''; $first = 1; foreach ($this->stats[FateGameGlobals::STAT_MOOK] as $mook) { $this_label = $levels[$mook->{stat_value}]; if ($this_label != $last_label) { if (!$first) { $sheet .= "</div>"; } else { $first = 0; } $sheet .= "<div class='block'><div class='block_label'>" . $this_label . ' (' . ($mook->{stat_value} > 0 ? '+' : '') . $mook->{stat_value} . ') at</div>'; $last_label = $this_label; } else { $sheet .= ", "; } $sheet .= $mook->{stat_field}; } if ($last_label) { $sheet .= "</div>"; } } if (array_key_exists(FateGameGlobals::STAT_STUNT, $this->stats)) { $sheet .= "<H2>STUNTS</H2>\n<div class='block'><dl>"; foreach ($this->stats[FateGameGlobals::STAT_STUNT] as $stunt) { $sheet .= "<dt>" . $stunt->{stat_field} . "</dt>" . "<dd>" . $stunt->{stat_description} . "</dd>"; } $sheet .= "</dl></div>\n"; } if (array_key_exists(FateGameGlobals::STAT_CONSEQUENCE, $this->stats)) { $sheet .= "<H2>CONSEQUENCES</H2>\n"; foreach ($this->stats[FateGameGlobals::STAT_CONSEQUENCE] as $consequence) { $sheet .= "<div class='block consequence'><div class='value'>" . $consequence->{stat_display_value} . "</div><div class='block_label'>" . $consequence->{stat_label} . "</div>" . ($consequence->{stat_field} ? $consequence->{stat_field} : ' ') . "</div>\n"; } } $stress_table = ''; $fate_table = ''; if (array_key_exists(FateGameGlobals::STAT_STRESS, $this->stats)) { $stress_table .= '<table>'; foreach ($this->stats[FateGameGlobals::STAT_STRESS] as $stress) { $stress_table .= "<tr><td><h2>" . strtoupper($stress->{stat_label}) . " STRESS</h2></td></tr><tr><td>"; for ($label = 1; $label <= $stress->{stat_max_value}; $label++) { $stress_table .= "<div class='block stress'><div class='value'>{$label}</div>" . ($stress->{stat_value} >= $label ? 'X' : ' ') . "</div>\n"; } $stress_table .= "</td></tr>"; } $stress_table .= "</table>"; } if (array_key_exists(FateGameGlobals::STAT_FATE, $this->stats) || array_key_exists(FateGameGlobals::STAT_REFRESH, $this->stats)) { $fate_table .= "<table><tr><td><h2>FATE POINTS</h2></td></tr><tr><td>"; if (array_key_exists(FateGameGlobals::STAT_REFRESH, $this->stats)) { $refresh = $this->stats[FateGameGlobals::STAT_REFRESH][0]; $fate_table .= "<div class='block fate'><div class='block_label'>Refresh</div>" . $refresh->{stat_value} . "</div>\n"; } if (array_key_exists(FateGameGlobals::STAT_FATE, $this->stats)) { $fate = $this->stats[FateGameGlobals::STAT_FATE][0]; $fate_table .= "<div class='block fate'><div class='block_label'>Current</div>" . $fate->{stat_value} . "</div>\n"; } $fate_table .= "</td></tr></table>"; } if ($stress_table || $fate_table) { $sheet .= "<table><tr>"; if ($stress_table) { $sheet .= "<td valign='top'>" . $stress_table . "</td>"; } if ($fate_table) { $sheet .= "<td valign='top'>" . $fate_table . "</td>"; } $sheet .= "</tr></table>"; } $sheet .= "</div>"; return $sheet; }
private function getEditStatRow($stat_id, $stat_data, $stat, $fate_game, $results, $new_count = 0) { $new = ''; $oninput = ''; $onchange = ''; if (is_array($stat)) { $new = 'new_'; if (!$stat_data['unique']) { if ($stat_data['modeskill']) { $oninput = "oninput='addNewRow({$stat_id}, {$new_count}, \"" . $stat_data['fields']['label']['label'] . "\", " . $stat_data['mode_value'] . ");'"; $onchange = "onchange='addNewRow({$stat_id}, {$new_count}, \"" . $stat_data['fields']['label']['label'] . "\", " . $stat_data['mode_value'] . ");'"; } else { $oninput = "oninput='addNewRow({$stat_id}, {$new_count});'"; $onchange = "onchange='addNewRow({$stat_id}, {$new_count});'"; } } } $row = '<tr>'; foreach ($stat_data['fields'] as $field => $field_data) { $value = htmlspecialchars($stat->{'stat_' . $field}, ENT_QUOTES); $error = ''; if (!is_array($stat) && $results['error']['required'][$stat->{fractal_stat_id}] && in_array($field, $results['error']['required'][$stat->{fractal_stat_id}])) { $error = "class='formerror'"; } $name = $stat_id . '_' . $new . $field . '_' . (is_array($stat) ? $new_count : $stat->{fractal_stat_id}); $row .= "<td class='mw-label'><label for='ef{$name}'>" . $field_data['label'] . ($field_data['type'] == 'display' ? '' : ':') . "</label></td>"; // If we have results, then show values that were submitted if (count($results) > 0 && $field_data['type'] != 'display' && array_key_exists($name, $results['form'])) { if ($stat_id == FateGameGlobals::STAT_MODE && $field_data['type'] == 'select') { $value = $fate_game->modes_by_id[$results['form'][$name]]['label']; } else { $value = htmlspecialchars($results['form'][$name], ENT_QUOTES); } } if ($stat_id == FateGameGlobals::STAT_CONDITION && $field_data['type'] == 'select') { $conditions = FateGameGlobals::getConditionCategories(); $row .= "<td class='mw-input'><select id='ef{$name}' name='{$name}' {$onchange} {$error}>"; foreach ($conditions as $key => $category) { $selected = $value == $key ? 'selected' : ''; $row .= "<option value='{$key}' {$selected}>{$category}</option>"; } $row .= "</select></td>"; } elseif ($stat_id == FateGameGlobals::STAT_MODE && $field_data['type'] == 'select') { $row .= "<td class='mw-input'><select id='ef{$name}' name='{$name}' {$onchange} {$error}>"; foreach ($fate_game->modes as $mode) { $selected = $value == $mode['label'] ? 'selected' : ''; $row .= "<option value='" . $mode['mode_id'] . "' {$selected}>" . $mode['label'] . "</option>"; } $row .= "</select></td>"; } elseif ($stat_id == FateGameGlobals::STAT_SKILL && $field_data['type'] == 'select') { $row .= "<td class='mw-input'><select id='ef{$name}' name='{$name}' {$onchange} {$error}>"; foreach ($fate_game->skills as $skill) { $selected = $value == $skill['label'] ? 'selected' : ''; $row .= "<option value='" . $skill['skill_id'] . "' {$selected}>" . $skill['label'] . "</option>"; } $row .= "</select></td>"; } elseif ($stat_id == FateGameGlobals::STAT_MOOK && $field_data['type'] == 'select') { $levels = FateGameGlobals::getMookLevels(); $row .= "<td class='mw-input'><select id='ef{$name}' name='{$name}' {$onchange} {$error}>"; foreach ($levels as $rating => $label) { $selected = $value == $rating ? 'selected' : ''; $row .= "<option value='{$rating}' {$selected}>{$label}</option>"; } $row .= "</select></td>"; } elseif ($stat_id == FateGameGlobals::STAT_SKILL && $field_data['type'] == 'rankselect') { $levels = array_reverse(FateGameGlobals::getModeLevels(), true); $row .= "<td class='mw-input'><select id='ef{$name}' name='{$name}' {$onchange} {$error}>"; foreach ($levels as $rating => $label) { $total = $rating + $stat_data['mode_value']; $selected = $total == $value ? 'selected' : ''; $row .= "<option value='{$total}' {$selected}>{$label} (+{$rating})</option>"; } $row .= "</select>"; if ($new) { $hidden_name = $stat_id . '_' . $new . 'mode_' . (is_array($stat) ? $new_count : $stat->{fractal_stat_id}); $row .= "<input type='hidden' name='{$hidden_name}' value='" . $stat_data['mode_id'] . "'/>"; } $row .= "</td>"; } elseif ($field_data['type'] == 'display') { $row .= "<td class='mw-input'>{$value}</td>"; } elseif ($field_data['type'] == 'textarea') { $row .= "<td class='mw-input'><textarea {$error} id='ef{$name}' name='{$name}' {$oninput} rows=" . $field_data['rows'] . " cols=" . $field_data['cols'] . ">{$value}</textarea></td>"; } else { $row .= "<td class='mw-input'><input {$error} id='ef{$name}' name='{$name}' type='text' size='" . $field_data['size'] . "' value='{$value}' {$oninput}/></td>"; } } if ($stat_data['modeskill'] && $stat_data['fields']['label']['label'] == '') { $row .= $this->getDeleteCells(array(), $results); } else { $row .= $this->getDeleteCells($stat, $results); } $row .= '</tr>'; if (!is_array($stat) && $results['error']['required'][$stat->{fractal_stat_id}]) { $row .= $this->getFormErrorCells($stat_data, $results['error']['required'][$stat->{fractal_stat_id}]); } return $row; }
private function listAllGames() { $user = $this->getUser(); $out = $this->getOutput(); $dbr = wfGetDB(DB_SLAVE); $games = $dbr->select(array('g' => 'fate_game', 'r' => 'muxregister_register', 's' => 'fate_game_staff', 'r2' => 'muxregister_register'), array('r.register_id', 'r.user_name', 'r.canon_name', 'r.user_id', 'g.game_id', 'g.game_name', 'g.game_description', 'g.game_status', 'g.create_date', 'g.modified_date', 'group_concat(r2.user_id separator " ") as staff'), array('r.register_id = g.register_id', 'g.game_id = s.game_id', 's.register_id = r2.register_id'), __METHOD__, array('ORDER BY' => 'g.game_name')); $table = ''; if ($games->numRows() == 0) { $table .= "<div>No games are currently set up.</div>"; } else { $table .= "<table class='wikitable' >" . "<tr><th>Game Name</th><th>Game Master</th><th>Description</th><th>Status</th><th>Created</th><th>Last Modified</th></tr>"; foreach ($games as $game) { $staff = explode(' ', $game->{staff}); $table .= "<tr><td valign='top'>"; if ($user->getID() == $game->{user_id} || in_array($user->getID(), $staff) || $user->isAllowed('fategm')) { $table .= Linker::link($this->getPageTitle()->getSubpage("View"), $game->{game_name}, array(), array('game_id' => $game->{game_id}), array('forcearticlepath')); } else { $table .= $game->{game_name}; } $table .= "</td><td valign='top'>" . Linker::link(Title::newFromText('User:'******'forcearticlepath')) . "</td>" . "<td>" . $game->{game_description} . "</td><td valign='top'>" . $game->{game_status} . "</td>" . "<td>" . FateGameGlobals::getDisplayDate($game->{create_date}) . "</td>" . "<td>" . FateGameGlobals::getDisplayDate($game->{modified_date}) . "</td>" . "</tr>"; } $table .= "</table>"; } $out->addHTML($table); }