diff --git a/gatherling/api.php b/gatherling/api.php
index 69e78847c..2aca53026 100644
--- a/gatherling/api.php
+++ b/gatherling/api.php
@@ -192,6 +192,14 @@
$result['key'] = $player->setApiKey();
break;
+ case 'known_cards_catalog':
+ $result = card_catalog();
+ break;
+
+ case 'cardname_from_id':
+ $result = cardname_from_id(arg('id'));
+ break;
+
default:
$result['error'] = "Unknown action '{$action}'";
break;
diff --git a/gatherling/api_lib.php b/gatherling/api_lib.php
index 30df98bcf..6409f0b46 100644
--- a/gatherling/api_lib.php
+++ b/gatherling/api_lib.php
@@ -4,6 +4,7 @@
//## Helper Functions
+use Gatherling\Database;
use Gatherling\Event;
use Gatherling\Player;
use Gatherling\Series;
@@ -131,6 +132,7 @@ function repr_json_event($event)
if ($matches) {
$json['matches'] = [];
$json['unreported'] = [];
+ $json['waiting_on'] = [];
$addrounds = 0;
$roundnum = 0;
$timing = 0;
@@ -143,6 +145,7 @@ function repr_json_event($event)
if ($roundnum != $m->round) {
$roundnum = $m->round;
$json['unreported'] = [];
+ $json['waiting_on'] = [];
}
$data['round'] = $m->round + $addrounds;
$json['matches'][] = $data;
@@ -153,6 +156,11 @@ function repr_json_event($event)
if (!$m->reportSubmitted($m->playerb)) {
$json['unreported'][] = $m->playerb;
}
+ if (!$m->reportSubmitted($m->playera) && $m->reportSubmitted($m->playerb)) {
+ $json['waiting_on'][] = $m->playera;
+ } elseif ($m->reportSubmitted($m->playera) && !$m->reportSubmitted($m->playerb)) {
+ $json['waiting_on'][] = $m->playerb;
+ }
}
}
}
@@ -422,3 +430,34 @@ function create_pairing($event, $round, $a, $b, $res)
$event->addMatch($playerA, $playerB, $round, $res, $pAWins, $pBWins);
}
}
+
+/** @return string[] */
+function card_catalog()
+{
+ $result = [];
+ $db = Database::getConnection();
+ $query = $db->query('SELECT c.name as name FROM cards c');
+ while ($row = $query->fetch_assoc()) {
+ if (!in_array($row['name'], $result)) {
+ $result[] = $row['name'];
+ }
+ }
+ $query->close();
+
+ return $result;
+}
+
+/**
+ * @param string $id
+ *
+ * @throws Exception
+ *
+ * @return string
+ */
+function cardname_from_id($id)
+{
+ $sql = 'SELECT c.name as name FROM cards c WHERE c.scryfallId = ?';
+ $name = Database::single_result_single_param($sql, 's', $id);
+
+ return $name;
+}
diff --git a/gatherling/event.php b/gatherling/event.php
index 192bd9534..2f26544b8 100644
--- a/gatherling/event.php
+++ b/gatherling/event.php
@@ -276,7 +276,9 @@ function content()
authFailed();
} else {
if (mode_is('Start Event')) {
- $event->startEvent();
+ $event->startEvent(true);
+ } elseif (mode_is('Start Event (No Deck Check)')) {
+ $event->startEvent(false);
} elseif (mode_is('Recalculate Standings')) {
$structure = $event->mainstruct;
$event->recalculateScores($structure);
@@ -851,7 +853,9 @@ function playerList($event)
echo "name}\" />";
echo '
Round Actions | ';
if ($event->active == 0 && $event->finalized == 0) {
- echo ' |
';
+ echo '';
+ echo '';
+ echo ' | ';
echo 'Paste stuff:
';
echo "{$deckless}
";
} elseif ($event->active == 1) {
diff --git a/gatherling/models/Event.php b/gatherling/models/Event.php
index 637cf2b52..3386ea8e5 100644
--- a/gatherling/models/Event.php
+++ b/gatherling/models/Event.php
@@ -1827,9 +1827,9 @@ public function updateDecksFormat($format)
}
}
- public function startEvent()
+ public function startEvent($precheck)
{
- $entries = $this->getRegisteredEntries(true);
+ $entries = $this->getRegisteredEntries($precheck);
Standings::startEvent($entries, $this->name);
// $this->dropInvalidEntries();
$this->pairCurrentRound();
diff --git a/tests/EventsTest.php b/tests/EventsTest.php
index 1494941f8..b3c947f0e 100644
--- a/tests/EventsTest.php
+++ b/tests/EventsTest.php
@@ -8,10 +8,18 @@
use Gatherling\Event;
use Gatherling\Matchup;
use Gatherling\Series;
+use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\TestCase;
+use SebastianBergmann\RecursionContext\InvalidArgumentException;
final class EventsTest extends TestCase
{
+ /**
+ * @throws InvalidArgumentException
+ * @throws ExpectationFailedException
+ *
+ * @return Series
+ */
public function testSeriesCreation()
{
if (!Series::exists('Test')) {
@@ -30,6 +38,14 @@ public function testSeriesCreation()
}
/**
+ * @param Series $series
+ *
+ * @throws Exception
+ * @throws InvalidArgumentException
+ * @throws ExpectationFailedException
+ *
+ * @return Event
+ *
* @depends testSeriesCreation
*/
public function testEventCreation($series)
@@ -78,6 +94,14 @@ public function testEventCreation($series)
}
/**
+ * @param Event $event
+ *
+ * @throws InvalidArgumentException
+ * @throws ExpectationFailedException
+ * @throws Exception
+ *
+ * @return Event
+ *
* @depends testEventCreation
*/
public function testRegistration($event)
@@ -113,6 +137,13 @@ public function testRegistration($event)
}
/**
+ * @param Event $event
+ *
+ * @throws InvalidArgumentException
+ * @throws ExpectationFailedException
+ *
+ * @return Event
+ *
* @depends testRegistration
*/
public function testEventStart($event)
@@ -120,7 +151,7 @@ public function testEventStart($event)
$this->assertEquals($event->active, 0);
$this->assertEquals($event->current_round, 0);
- $event->startEvent();
+ $event->startEvent(true);
$event = new Event($event->name);
$this->assertEquals($event->active, 1);
@@ -130,6 +161,13 @@ public function testEventStart($event)
}
/**
+ * @param Event $event
+ *
+ * @throws InvalidArgumentException
+ * @throws ExpectationFailedException
+ *
+ * @return mixed
+ *
* @depends testEventStart
*/
public function testReporting($event)
@@ -151,6 +189,16 @@ public function testReporting($event)
}
}
+/**
+ * @param string $player
+ * @param Event $event
+ * @param string $main
+ * @param string $side
+ *
+ * @throws Exception
+ *
+ * @return Deck
+ */
function insertDeck($player, $event, $main, $side)
{
$deck = new Deck(0);