| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace App\Module\Game\Services;
- use App\Module\Game\Logics\DeductCollectorLogic;
- /**
- * 扣除数据收集服务
- *
- * 用于收集本次请求中的所有扣除数据,包括物品扣除和代币扣除
- * 通过静态变量实现,确保在单次请求中能够累积所有扣除信息
- */
- class DeductCollectorService
- {
- /**
- * 添加物品扣除
- *
- * @param int $itemId 物品ID
- * @param int $instanceId 物品实例ID
- * @param int $quantity 扣除数量
- * @return void
- */
- public static function addItemDeduct(int $itemId, int $instanceId, int $quantity): void
- {
- DeductCollectorLogic::addItemDeduct($itemId, $instanceId, $quantity);
- }
- /**
- * 添加代币扣除
- *
- * @param int $coinType 代币类型
- * @param int $quantity 扣除数量
- * @return void
- */
- public static function addCoinDeduct(int $coinType, int $quantity): void
- {
- DeductCollectorLogic::addCoinDeduct($coinType, $quantity);
- }
- /**
- * 获取本次请求的所有扣除数据
- *
- * @return array 扣除数据数组,包含items和coins
- */
- public static function getDeducts(): array
- {
- return DeductCollectorLogic::getDeducts();
- }
- /**
- * 清空本次请求的扣除数据
- *
- * @return void
- */
- public static function clearDeducts(): void
- {
- DeductCollectorLogic::clearDeducts();
- }
- /**
- * 检查是否有扣除数据
- *
- * @return bool
- */
- public static function hasDeducts(): bool
- {
- return DeductCollectorLogic::hasDeducts();
- }
- }
|