2

好吧,我为我的游戏制作了一个成就系统。我有一个银行一定数额的成就。好吧,当他们存入一定金额时,您将在用户墙上发布成就。但是,当您提取现金时,成就将消失。这是下面的编码。那么,即使在现金从用户银行账户中消失后,我如何才能将其修复到成就将保留的位置呢?

<?php 
if ( $userp['bank_account'] >= 100000 )
{
    echo 
    '<img src="achievements/Diamond-Bank.png"  hspace="5" width="65" height="65" title="Diamond Banker: Made a deposit of $100,000 or more!"">';
} 
elseif ( $userp['bank_account'] >= 50000  )
{
    echo 
    '<img src="achievements/Gold-Bank.png"  hspace="5" width="65" height="65" title="Golden Banker: Made a deposit of $50,000 of more."">';
}
elseif ( $userp['bank_account'] >= 1000 )
{
    echo 
    '<img src="achievements/Silver-Bank.png"  hspace="5" width="65" height="65" title="Silver Banker: Made a deposit of $1,000 or more."">';
}
elseif ( $userp['bank_account'] >= 1 )
{
    echo 
    '<img src="achievements/Bronze-Bank.png"  hspace="5" width="65" height="65" title="Bronze Banker: Opened a bank account!"">';
}
?>          
4

2 回答 2

0

我会通过在mysql表中再添加 1 列来做到这一点 -achievement使用DEFAULT = 0. 然后achievement使用您的标准添加徽章 -

<?php 
if ( $userp['bank_account'] >= 100000 )
{
   "UPDATE table SET `achievement` = 4"
} 
elseif ( $userp['bank_account'] >= 50000  )
{
   "UPDATE table SET `achievement` = 3";
}
elseif ( $userp['bank_account'] >= 1000 )
{
   "UPDATE table SET `achievement` = 2";
}
elseif ( $userp['bank_account'] >= 1 )
{
   "UPDATE table SET `achievement` = 1";
}
?>      

然后查看achievement徽章 -

<?php 
if ( $userp['achievement'] = 4 )
{
   echo 
   '<img src="achievements/Diamond-Bank.png"  hspace="5" width="65" height="65" title="Diamond Banker: Made a deposit of $100,000 or more!"">';
} 
elseif ( $userp['achievement'] = 3  )
{
   echo 
   '<img src="achievements/Gold-Bank.png"  hspace="5" width="65" height="65" title="Golden Banker: Made a deposit of $50,000 of more."">';
}
elseif ( $userp['achievement'] = 2 )
{
   echo 
   '<img src="achievements/Silver-Bank.png"  hspace="5" width="65" height="65" title="Silver Banker: Made a deposit of $1,000 or more."">';
}
elseif ( $userp['achievement'] = 1 )
{
   echo 
   '<img src="achievements/Bronze-Bank.png"  hspace="5" width="65" height="65" title="Bronze Banker: Opened a bank account!"">';
}
?>      
于 2012-11-25T10:59:16.373 回答
0

好吧,有几种可能性可以解决这个问题。您可以将用户的所有成就存储在数据库中并插入/选择它们。这样,即使余额下降,也不会丢失任何内容。

您还可以添加“总”银行账户,如果用户提取现金,该账户不会减少。这样,您可以$userp['bank_account_total']用于“成就检测”。

于 2012-11-25T10:55:55.583 回答