Skip to content

Commit

Permalink
Merge pull request #29 from jaredpearson/jp/update
Browse files Browse the repository at this point in the history
Version update, IntelliJ ignore and missing BGA methods
  • Loading branch information
danielholmes authored May 29, 2021
2 parents 0f5c6c8 + 3d52993 commit 7cdad4b
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/vendor
/resources/test-projects/simple-composer-example/vendor
/resources/test-projects/simple-composer-example/build
/resources/test-projects/simple-composer-example/dist
/resources/test-projects/simple-composer-example/dist
/.idea
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dholmes/bga-workbench",
"version": "0.1.6",
"version": "0.1.7",
"type": "library",
"description": "BoardGameArena Workbench",
"minimum-stability": "stable",
Expand Down
30 changes: 30 additions & 0 deletions src/BGAWorkbench/Stubs/APP_DbObject.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ protected function getCollectionFromDB($sql, $bSingleValue = false)
return $result;
}

/**
* @param $sql
* @return array
*/
protected function getNonEmptyCollectionFromDB($sql)
{
$rows = self::getCollectionFromDB($sql);
if (empty($rows)) {
throw new BgaSystemException('Expected collection to not be empty');
}
return $rows;
}

/**
* @param string $sql
* @param boolean $bUniqueValue
Expand Down Expand Up @@ -95,6 +108,23 @@ protected static function getUniqueValueFromDB($sql)
return $rows[0];
}

protected function getObjectFromDB($sql)
{
$rows = self::getDbConnection()->fetchAllAssociative($sql);
if (empty($rows)) {
return null;
} elseif (count($rows) > 1) {
throw new \RuntimeException('More than one row returned. count: ' . count($rows));
}
return $rows[0];
}

protected static function escapeStringForDB($string)
{
$quoted = self::$connection->quote($string);
return substr($quoted, 1, -1);
}

/**
* @var Connection
*/
Expand Down
5 changes: 5 additions & 0 deletions src/BGAWorkbench/Stubs/framework.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ function totranslate($str)
{
return $str;
}

function bga_rand($min, $max)
{
return rand($min, $max);
}
12 changes: 12 additions & 0 deletions src/BGAWorkbench/Stubs/module/table/table.game.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ public function checkAction($actionName, $bThrowException = true)
return true;
}

private $gameStateValues = [];

public function setGameStateInitialValue($label, $value)
{
$this->gameStateValues[$label] = $value;
}

public function getGameStateValue($label)
{
return $this->gameStateValues[$label];
}

private function getStatTypeId($targetName)
{
include('stats.inc.php');
Expand Down

0 comments on commit 7cdad4b

Please sign in to comment.