Skip to content

Commit

Permalink
Fixes for styling, compendium, loading visuals, user teams UI
Browse files Browse the repository at this point in the history
  • Loading branch information
vjosset committed Sep 24, 2022
1 parent 323e299 commit b844391
Show file tree
Hide file tree
Showing 18 changed files with 466 additions and 226 deletions.
5 changes: 5 additions & 0 deletions api/faction.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ function GETFaction() {
// Get the requested faction id
$factionid = $_REQUEST['factionid'];

sleep(1);

if ($factionid == null || $factionid == '') {
// No faction id passed in, return all factions
$factions = Faction::GetFactions();
echo json_encode($factions);
} else {
// Return the requested faction
$faction = Faction::GetFaction($factionid);

// Load the faction's killteams
$faction->loadKillTeams();
echo json_encode($faction);
}
}
Expand Down
5 changes: 4 additions & 1 deletion api/killteam.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@

function GETKillteam() {
// Get the requested killteam id
$factionid = $_REQUEST['factionid'];
$killteamid = $_REQUEST['killteamid'];

sleep(1);

if ($killteamid == null || $killteamid == '') {
// No killteam id passed in, return all killteams
$killteams = Killteam::GetKillteams();
echo json_encode($killteams);
} else {
// Return the requested killteam
$killteam = Killteam::GetKillteam($killteamid);
$killteam = Killteam::GetKillteam($factionid, $killteamid);
echo json_encode($killteam);
}
}
Expand Down
34 changes: 34 additions & 0 deletions api/userteam.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ function GETUserTeam() {
$utid = $_REQUEST['utid'];
$uid = $_REQUEST['uid'];

sleep(1);

if ($utid == null || $utid == '') {
// No killteam id passed in, return the specified user's teams

Expand All @@ -56,4 +58,36 @@ function GETUserTeam() {
echo json_encode(UserTeam::GetUserTeam($utid));
}
}

function DELETEUserTeam() {
// Check that the user is currently logged in
if (!Session::IsAuth()) {
// Not logged in - Return error
header('HTTP/1.0 401 Unauthorized - You are not logged in"');
die();
} else {
// Get the current user
$u = Session::CurrentUser();

// Get the requested user team
$utid = $_REQUEST['utid'];
$ut = UserTeam::GetUserTeam($utid);

// Validate the team's owner
if ($ut->userid == $u->userid) {
// Current user owns this team, OK to delete
$ut->DBDelete();

// Delete operatives
foreach($ut->operatives as $op) {
$op->DBDelete();
}
echo "OK";
} else {
// Team belongs to someone else
header('HTTP/1.0 401 Unauthorized - This team does not belong to you"');
die();
}
}
}
?>
6 changes: 0 additions & 6 deletions classes/faction.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public function GetFaction($factionid) {
// Get the requested Faction
$faction = Faction::FromDB($factionid);

// Load its killteams
$faction->loadKillteams();

return $faction;
}

Expand Down Expand Up @@ -51,9 +48,6 @@ public function GetFactions() {
while ($row = $result->fetch_object()) {
$faction = Faction::FromRow($row);

// Load its killteams
$faction->loadKillteams();

// Add this faction to the output
$factions[] = $faction;
}
Expand Down
6 changes: 6 additions & 0 deletions classes/userteam.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ public function loadOperatives() {
$ops = [];
if ($result = $cmd->get_result()) {
while ($row = $result->fetch_object()) {

$op = UserTeamOperative::FromRow($row);

// Load the base operative for this UserTeamOperative
$op->loadBaseOperative();

// Load the operative's weapons and equipments
$op->loadWeapons();
$op->loadEquipments();
$this->operatives[] = $op;
Expand Down
34 changes: 32 additions & 2 deletions classes/userteamoperative.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ class UserTeamOperative extends \OFW\OFWObject {
public $eqids = "";
public $currw = 0;
public $notes = "";
public $baseoperative = null;
public $weapons = [];
public $equipments = [];

function __construct() {
$this->TableName = "UserTeamOperative";
$this->Keys = ["userteamopid"];
$this->skipfields = ["weapons", "equipments"];
$this->skipfields = ["operative", "weapons", "equipments"];
}

public function GetUserTeamOperative($utoid) {
Expand All @@ -30,13 +31,21 @@ public function GetUserTeamOperative($utoid) {
//Get the requested UserTeamOperative
$uto = UserTeamOperative::FromDB($utoid);

// Load the base operative for this UserTeamOperative
$uto->loadBaseOperative();

// Load this operative's weapons and equipments
$uto->loadWeapons();
$uto->loadEquipments();

return $uto;
}

public function loadBaseOperative() {
// Load this UserTeamOperative base operative
$this->baseoperative = Operative::GetOperative($this->factionid, $this->killteamid, $this->fireteamid, $this->opid);
}

public function loadWeapons() {
global $dbcon;

Expand Down Expand Up @@ -66,7 +75,28 @@ public function loadWeapons() {
}

public function loadEquipments() {
// [TBD]
global $dbcon;

// Get the equipments for this operative
$sql = "SELECT * FROM Equipment WHERE factionid = ? AND killteamid = ? AND CONCAT(',', ?, ',') LIKE CONCAT('%,', eqid, ',%') ORDER BY eqseq";

$cmd = $dbcon->prepare($sql);
$paramtypes = "sss";
$params = array();
$params[] =& $paramtypes;
$params[] =& $this->factionid;
$params[] =& $this->killteamid;
$params[] =& $this->eqids;

call_user_func_array(array($cmd, "bind_param"), $params);
$cmd->execute();

if ($result = $cmd->get_result()) {
while ($row = $result->fetch_object()) {
$eq = Equipment::FromRow($row);
$this->equipments[] = $eq;
}
}
}

/* COMMENTED OUT - UI SHOULD DO THIS WITH "PUTS" FOR THE USERTEAMOPERATIVES
Expand Down
24 changes: 16 additions & 8 deletions compendium.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,31 @@
include "og.php"
?>
</head>
<body ng-app="kt" ng-controller="ktCtrl" ng-init="init();">
<body ng-app="kt" ng-controller="ktCtrl" ng-init="initSession();initCompendium();">
<?php include "topnav.shtml" ?>
<script type="text/javascript">
trackEvent("compendium", "allfactions");
</script>

<h1 class="cinzel orange">Compendium - Factions</h1>

<div class="card-group">
<!-- loadWaiter -->
<h3 class="center" ng-show="loading">
<div>
<i class="fas fa-undo-alt fa-fw rotate" ></i>
<br />
Loading Factions...
</div>
</h3>

<div class="card-group" ng-hide="loading">
<div ng-repeat="faction in factions" class="col-12 col-md-6 col-xl-4">
<div class="card border-light shadow darkcard">
<!-- Portrait -->
<img class="card-img-top" ng-src="/img/portraits/{{ faction.factionid }}/{{ faction.factionid }}.jpg" style="max-height: 270px; min-height: 270px; object-position: center top; object-fit: cover;" />

<a class="h1 card-title cinzel orange text-center" href="/faction.php?fa={{ faction.factionid }}">
{{ faction.factionname }}
</a>
<h1 class="card-title orange text-center">
<a href="/faction.php?fa={{ faction.factionid }}">
{{ faction.factionname }}
</a>
</h1>

<p class="card-text p-2 m-0 oswald" style="text-align:justify;" ng-bind-html="faction.description"></p>

Expand Down
27 changes: 10 additions & 17 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ body {
font-size: 1em;
/*background-color: #343a40;*/
background-color: #202020;
color: #eee;
color: #EEE;
}

.dark {
Expand All @@ -32,22 +32,13 @@ body {
color: #EEE;
}

.bright {
background-color: #FFF;
color: #343a40;
}

.orange {
/*background-color: #dd7d00;*/
/*color: #343a40;*/
background-color: #c54c21;
color: #262a2d;
}

.orangetext {
color: #c54c21;
}

.eqtable {
border: 1px solid #888;
}
Expand All @@ -56,19 +47,21 @@ body {
h1, h2, h3, h4, h5, h6 {
font-family: Anton;
text-transform: uppercase;
padding-left: 10px;
padding-left: 2px;
padding-right: 2px;
}

a, a:link, a:visited, a:hover, a:active
.orange a, .orange a:link, .orange a:visited, .orange a:hover, .orange a:active
{
cursor: pointer;
color: #EEE;
color: #262a2d;
text-decoration: none;
}

orange a, orange a:link, orange a:visited, orange a:hover, orange a:active
a, a:link, a:visited, a:hover, a:active
{
cursor: pointer;
color: #262a2d;
color: #EEE;
}

.bold {
Expand All @@ -93,7 +86,7 @@ th, td {

.line-top-light
{
border-top: 1px solid #EEE;
border-top: 1px solid #CCC;
}

.line-bottom
Expand All @@ -103,7 +96,7 @@ th, td {

.line-bottom-light
{
border-bottom: 1px solid #EEE;
border-bottom: 1px solid #CCC;
}

.shadow
Expand Down
Loading

0 comments on commit b844391

Please sign in to comment.