Created
April 2, 2022 07:10
-
-
Save crazywhalecc/f0c5dcf5054ef37f431b7391498bfe7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function doSign() { | |
$sign_data = DP::query("SELECT * FROM sign_data WHERE user_id = ?", [$this->getUserId()]); | |
if ($sign_data == []) $sign_data = $this->initData(); | |
else $sign_data = $sign_data[0]; | |
$today_zero = TimeManager::getTodayZero(); | |
if ($sign_data["last_sign"] >= $today_zero) return false;//签过了 | |
$last_day_zero = $today_zero - 86400; | |
if ($sign_data["last_sign"] >= $last_day_zero) {//是不是连签 | |
$sign_data["sign_day_long"]++; | |
} else { | |
$sign_data["sign_day_long"] = 1; | |
} | |
$sign_data["sign_count"]++; | |
$sign_data["last_sign"] = microtime(true); | |
$msg = "「签到成功」"; | |
$attribute = ZMBuf::get("sign_attribute"); | |
$add_count = mt_rand($attribute["point"][0], $attribute["point"][1]); | |
if (!ZMBuf::array_key_exists("sign_first", date("Ymd"))) { | |
$counts = mt_rand($attribute["first"][0], $attribute["first"][1]); | |
$add_count += $counts; | |
$msg .= "\n今日首签加成:+" . $counts . ",棒棒哒~"; | |
$is_first = true; | |
ZMBuf::appendKey("sign_first", date("Ymd"), $this->getUserId()); | |
} | |
if ($sign_data["sign_day_long"] >= 3) { | |
$add_count++; | |
$msg .= "\n连续签到加成:+1"; | |
$msg .= "\n连续签到:" . $sign_data["sign_day_long"] . "天"; | |
} | |
$msg .= "\n本次签到共获得:+" . $add_count; | |
$sign_data["point"] += $add_count; | |
DP::query("UPDATE sign_data SET point = ?, sign_day_long = ?, last_sign = ?, sign_count = ? WHERE user_id = ?", [ | |
$sign_data["point"], | |
$sign_data["sign_day_long"], | |
$sign_data["last_sign"], | |
$sign_data["sign_count"], | |
$this->getUserId() | |
]); | |
DP::query("INSERT INTO sign_record (user_id, sign_time, add_point, is_first) VALUES (?,?,?,?)", [ | |
$this->getUserId(), | |
$sign_data["last_sign"], | |
$add_count, | |
(isset($is_first) ? 1 : 0) | |
]); | |
$msg .= "\n累计签到:" . $sign_data["sign_count"] . "次"; | |
$msg .= "\n当前积分:" . $sign_data["point"]; | |
$msg .= "\n现在每天可以签到后和炸毛猜拳赢更多积分啦!\n回复\"猜拳\"和炸毛玩"; | |
if (($hitokoto = Entertain::getHitokoto()) !== null) { | |
$msg .= "\n" . trim($hitokoto["hitokoto"]) . " ----「" . $hitokoto["from"] . "」"; | |
} | |
return $this->reply($msg); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment