83 lines
2.3 KiB
PHP
83 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace models;
|
|
|
|
use mt;
|
|
use phpcommon\SqlHelper;
|
|
|
|
class LuckySymbol extends BaseModel {
|
|
|
|
public static function hasLuckySymbol()
|
|
{
|
|
$row = SqlHelper::ormSelectOne(
|
|
myself()->_getSelfMysql(),
|
|
't_lucky_symbol',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
)
|
|
);
|
|
$has = empty($row) ? false : $row['in_use_num'] > 0;
|
|
return $has ? 1 : 0;
|
|
}
|
|
|
|
public static function dec()
|
|
{
|
|
SqlHelper::update
|
|
(myself()->_getSelfMysql(),
|
|
't_lucky_symbol',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
),
|
|
array(
|
|
'in_use_num' => 0,
|
|
'modifytime' => myself()->_getNowTime(),
|
|
)
|
|
);
|
|
}
|
|
|
|
public static function add()
|
|
{
|
|
SqlHelper::upsert
|
|
(myself()->_getSelfMysql(),
|
|
't_lucky_symbol',
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
),
|
|
array(
|
|
'in_use_num' => function () { return "in_use_num + 1";},
|
|
'modifytime' => myself()->_getNowTime(),
|
|
),
|
|
array(
|
|
'account_id' => myself()->_getAccountId(),
|
|
'in_use_num' => 1,
|
|
'createtime' => myself()->_getNowTime(),
|
|
'modifytime' => myself()->_getNowTime(),
|
|
)
|
|
);
|
|
}
|
|
|
|
public static function getLuckyInc()
|
|
{
|
|
$val = 0;
|
|
if (self::hasLuckySymbol()) {
|
|
$itemMeta = myself()->_callMtStatic('Item', 'getLuckySymbolMeta');
|
|
if ($itemMeta) {
|
|
$potionMeta = myself()->_callMtStatic('BattlePotion', 'find', $itemMeta['id']);
|
|
if ($potionMeta) {
|
|
$effectStrs = explode('|', $potionMeta['effect']);
|
|
if (count($effectStrs) > 0) {
|
|
$effectStrs2 = explode(':', $effectStrs[0]);
|
|
if (count($effectStrs2) >= 2) {
|
|
if ($effectStrs2[0] == 54) {
|
|
$val += $effectStrs2[1];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return $val;
|
|
}
|
|
|
|
}
|