| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- <?php
- namespace App\Module\Game\Dtos;
- /**
- * 奖励项DTO
- */
- class RewardItemDto
- {
- /**
- * 奖励项ID
- *
- * @var int
- */
- public int $id;
- /**
- * 奖励组ID
- *
- * @var int
- */
- public int $groupId;
- /**
- * 奖励类型
- *
- * @var int
- */
- public int $rewardType;
- /**
- * 目标ID
- *
- * @var int
- */
- public int $targetId;
- /**
- * 参数1
- *
- * @var int
- */
- public int $param1;
- /**
- * 参数2
- *
- * @var int
- */
- public int $param2;
- /**
- * 数量
- *
- * @var int
- */
- public int $quantity;
- /**
- * 权重
- *
- * @var float
- */
- public float $weight;
- /**
- * 获得概率(百分比,0-100,NULL表示使用权重机制)
- *
- * @var float|null
- */
- public ?float $probability;
- /**
- * 最小数量(NULL表示使用quantity字段)
- *
- * @var int|null
- */
- public ?int $minQuantity;
- /**
- * 最大数量(NULL表示使用quantity字段)
- *
- * @var int|null
- */
- public ?int $maxQuantity;
- /**
- * 是否必中
- *
- * @var bool
- */
- public bool $isGuaranteed;
- /**
- * 额外数据
- *
- * @var array|null
- */
- public ?array $extraData;
- /**
- * 从模型创建DTO
- *
- * @param \App\Module\Game\Models\GameRewardItem $model
- * @return self
- */
- public static function fromModel($model): self
- {
- $dto = new self();
- $dto->id = $model->id;
- $dto->groupId = $model->group_id;
- $dto->rewardType = $model->reward_type;
- $dto->targetId = $model->target_id;
- $dto->param1 = $model->param1;
- $dto->param2 = $model->param2;
- $dto->quantity = $model->quantity;
- $dto->weight = $model->weight;
- $dto->probability = $model->probability;
- $dto->minQuantity = $model->min_quantity;
- $dto->maxQuantity = $model->max_quantity;
- $dto->isGuaranteed = (bool)$model->is_guaranteed;
- $dto->extraData = $model->extra_data;
- return $dto;
- }
- }
|