Skip to content

Commit

Permalink
fixed card tradeable check, put keep back in as alias for not tradeable
Browse files Browse the repository at this point in the history
  • Loading branch information
nekocari committed Oct 12, 2024
1 parent 3593325 commit 1fd94ea
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
5 changes: 2 additions & 3 deletions app/models/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,8 @@ public static function getFillerHtml($file_path,$img_width,$img_height){
public function isTradeable() {
if(is_null($this->is_tradeable)){
$this->is_tradeable = false;
if($this->getStatus()){
// TODO: make use of: Trade::getWhere($condition)?
$query = 'SELECT count(*) FROM trades WHERE (offered_card = '.$this->id.' OR requested_card = '.$this->id.') AND status = \'new\' ';
if($this->getStatus()->isTradeable()){
$query = 'SELECT count(*) FROM '.Trade::getDbTableName().' WHERE (offered_card = '.$this->id.' OR requested_card = '.$this->id.') AND status = \'new\' ';
$trades = $this->db->query($query)->fetchColumn();
if($trades == 0){
$this->is_tradeable = true;
Expand Down
30 changes: 24 additions & 6 deletions app/models/card_flagged.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,22 @@ public function missingIn($manager_category_id) {
* @return boolean
*/
public function missingInNotTradeable(){
if($this->missingInCollect() OR $this->not_tradeable_flag == 0 OR $this->in_not_tradeable_flag == 1){
return false;
}else{
return true;
}
if($this->missingInCollect() OR $this->not_tradeable_flag == 0 OR $this->in_not_tradeable_flag == 1){
return false;
}else{
return true;
}
}

/**
* @deprecated
* keep was replaced with not tradeable categories
* @return boolean
*/
public function missingInKeep(){
return $this->missingInNotTradeable();
}

/**
* Is card missing in collection?
* @return boolean
Expand Down Expand Up @@ -82,6 +92,14 @@ public function deckInNotTradeable(){
return true;
}
}
/**
* @deprecated
* keep was replaced with not tradeable categories
* @return boolean
*/
public function deckInKeep(){
return $this->deckInNotTradeable();
}
/**
* is this deck currently beeing collected?
* @return boolean
Expand Down Expand Up @@ -312,7 +330,7 @@ public function getSortingOptions(){
}
// KEEP - UNTRADEABLES
// select status is not collections and untradeable and card is missing in this untradeable status
if(!$status->isCollections() AND !$status->isTradeable() AND $this->missingIn($status->getId()) ){
if(!$status->isCollections() AND !$status->isTradeable() AND $this->missingIn($status->getId()) AND ($this->getStatus()->isNew() OR $this->isTradeable()) ){
$option_selected = true;
$option['prop_selected'] = true;
}
Expand Down

0 comments on commit 1fd94ea

Please sign in to comment.