|
@@ -122,6 +122,8 @@ trait GridHelperTrait
|
|
|
/**
|
|
/**
|
|
|
* 渲染神秘种子的产出详情
|
|
* 渲染神秘种子的产出详情
|
|
|
*
|
|
*
|
|
|
|
|
+ * 使用服务层逻辑计算神秘种子在该土地类型上的产出概率和产量
|
|
|
|
|
+ *
|
|
|
* @param \App\Module\Farm\Models\FarmLandType $landType
|
|
* @param \App\Module\Farm\Models\FarmLandType $landType
|
|
|
* @return string
|
|
* @return string
|
|
|
*/
|
|
*/
|
|
@@ -139,7 +141,7 @@ trait GridHelperTrait
|
|
|
|
|
|
|
|
foreach ($mysterySeeds as $seed) {
|
|
foreach ($mysterySeeds as $seed) {
|
|
|
try {
|
|
try {
|
|
|
- // 使用神秘种子逻辑计算概率
|
|
|
|
|
|
|
+ // 使用服务层逻辑计算概率
|
|
|
$mysteryLogic = new \App\Module\Farm\Logics\MysterySeeLLogic();
|
|
$mysteryLogic = new \App\Module\Farm\Logics\MysterySeeLLogic();
|
|
|
$adjustedOutputs = $mysteryLogic->calculateAdjustedProbabilities($seed->id, $landType->id);
|
|
$adjustedOutputs = $mysteryLogic->calculateAdjustedProbabilities($seed->id, $landType->id);
|
|
|
|
|
|
|
@@ -163,7 +165,7 @@ trait GridHelperTrait
|
|
|
$normalMin = $output['min_amount'];
|
|
$normalMin = $output['min_amount'];
|
|
|
$normalMax = $output['max_amount'];
|
|
$normalMax = $output['max_amount'];
|
|
|
|
|
|
|
|
- // 灾害产量范围
|
|
|
|
|
|
|
+ // 灾害产量范围 - 现在从服务层获取正确的数据
|
|
|
$disasterMin = $output['disaster_min_amount'] ?? $output['min_amount'];
|
|
$disasterMin = $output['disaster_min_amount'] ?? $output['min_amount'];
|
|
|
$disasterMax = $output['disaster_max_amount'] ?? $output['max_amount'];
|
|
$disasterMax = $output['disaster_max_amount'] ?? $output['max_amount'];
|
|
|
|
|
|
|
@@ -517,4 +519,132 @@ trait GridHelperTrait
|
|
|
return $html;
|
|
return $html;
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 添加消耗组详情列
|
|
|
|
|
+ *
|
|
|
|
|
+ * 展示消耗组的名称和详细内容
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param string $field 字段名
|
|
|
|
|
+ * @param string $label 标签名
|
|
|
|
|
+ * @return Column
|
|
|
|
|
+ */
|
|
|
|
|
+ public function columnConsumeGroupDetails(string $field = 'materials', string $label = '消耗组详情'): Column
|
|
|
|
|
+ {
|
|
|
|
|
+ return $this->grid->column($field, $label)->display(function ($materialsGroupId) {
|
|
|
|
|
+ if (!$materialsGroupId) {
|
|
|
|
|
+ return '<span class="text-muted">使用 materials 字段</span>';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $consumeGroup = \App\Module\Game\Models\GameConsumeGroup::with('consumeItems')->find($materialsGroupId);
|
|
|
|
|
+ if (!$consumeGroup) {
|
|
|
|
|
+ return '<span class="text-danger">未知消耗组 (ID: ' . $materialsGroupId . ')</span>';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $html = '<div class="consume-group-details">';
|
|
|
|
|
+ $html .= '<div class="mb-2"><strong>' . htmlspecialchars($consumeGroup->name) . ' (' . htmlspecialchars($consumeGroup->code) . ')</strong></div>';
|
|
|
|
|
+
|
|
|
|
|
+ if ($consumeGroup->consumeItems->isEmpty()) {
|
|
|
|
|
+ $html .= '<div class="text-muted">暂无消耗项</div>';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $html .= '<div class="table-responsive">';
|
|
|
|
|
+ $html .= '<table class="table table-sm table-bordered">';
|
|
|
|
|
+ $html .= '<thead><tr><th>消耗类型</th><th>目标</th><th>数量</th></tr></thead>';
|
|
|
|
|
+ $html .= '<tbody>';
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($consumeGroup->consumeItems as $item) {
|
|
|
|
|
+ $typeName = \App\Module\Game\Enums\CONSUME_TYPE::getName($item->consume_type);
|
|
|
|
|
+ $targetName = $item->getTargetName();
|
|
|
|
|
+
|
|
|
|
|
+ $html .= '<tr>';
|
|
|
|
|
+ $html .= '<td><span class="badge badge-info">' . htmlspecialchars($typeName) . '</span></td>';
|
|
|
|
|
+ $html .= '<td>' . htmlspecialchars($targetName) . '</td>';
|
|
|
|
|
+ $html .= '<td class="text-success"><strong>' . number_format($item->quantity) . '</strong></td>';
|
|
|
|
|
+ $html .= '</tr>';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $html .= '</tbody></table>';
|
|
|
|
|
+ $html .= '</div>';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $html .= '</div>';
|
|
|
|
|
+
|
|
|
|
|
+ return $html;
|
|
|
|
|
+ })->width(300);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 添加条件组详情列
|
|
|
|
|
+ *
|
|
|
|
|
+ * 展示条件组的名称和详细内容
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param string $field 字段名
|
|
|
|
|
+ * @param string $label 标签名
|
|
|
|
|
+ * @return Column
|
|
|
|
|
+ */
|
|
|
|
|
+ public function columnConditionGroupDetails(string $field = 'conditions', string $label = '条件组详情'): Column
|
|
|
|
|
+ {
|
|
|
|
|
+ return $this->grid->column($field, $label)->display(function ($conditionsGroupId) {
|
|
|
|
|
+ if (!$conditionsGroupId) {
|
|
|
|
|
+ return '<span class="text-muted">使用 conditions 字段</span>';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $conditionGroup = \App\Module\Game\Models\GameConditionGroup::with('conditionItems')->find($conditionsGroupId);
|
|
|
|
|
+ if (!$conditionGroup) {
|
|
|
|
|
+ return '<span class="text-danger">未知条件组 (ID: ' . $conditionsGroupId . ')</span>';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $html = '<div class="condition-group-details">';
|
|
|
|
|
+ $html .= '<div class="mb-2"><strong>' . htmlspecialchars($conditionGroup->name) . ' (' . htmlspecialchars($conditionGroup->code) . ')</strong></div>';
|
|
|
|
|
+
|
|
|
|
|
+ if ($conditionGroup->conditionItems->isEmpty()) {
|
|
|
|
|
+ $html .= '<div class="text-muted">暂无条件项</div>';
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $html .= '<div class="table-responsive">';
|
|
|
|
|
+ $html .= '<table class="table table-sm table-bordered">';
|
|
|
|
|
+ $html .= '<thead><tr><th>条件类型</th><th>目标</th><th>操作符</th><th>要求值</th></tr></thead>';
|
|
|
|
|
+ $html .= '<tbody>';
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($conditionGroup->conditionItems as $item) {
|
|
|
|
|
+ $typeName = \App\Module\Game\Enums\CONDITION_TYPE::getName($item->condition_type);
|
|
|
|
|
+ $targetName = \App\Module\Game\Services\ConditionTypeDescriptor::getTargetNameFromModel($item);
|
|
|
|
|
+ $operatorName = self::getOperatorName($item->operator);
|
|
|
|
|
+
|
|
|
|
|
+ $html .= '<tr>';
|
|
|
|
|
+ $html .= '<td><span class="badge badge-primary">' . htmlspecialchars($typeName) . '</span></td>';
|
|
|
|
|
+ $html .= '<td>' . htmlspecialchars($targetName) . '</td>';
|
|
|
|
|
+ $html .= '<td><span class="badge badge-secondary">' . htmlspecialchars($operatorName) . '</span></td>';
|
|
|
|
|
+ $html .= '<td class="text-success"><strong>' . number_format($item->value) . '</strong></td>';
|
|
|
|
|
+ $html .= '</tr>';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $html .= '</tbody></table>';
|
|
|
|
|
+ $html .= '</div>';
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $html .= '</div>';
|
|
|
|
|
+
|
|
|
|
|
+ return $html;
|
|
|
|
|
+ })->width(300);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取操作符名称
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param int $operator
|
|
|
|
|
+ * @return string
|
|
|
|
|
+ */
|
|
|
|
|
+ private static function getOperatorName(int $operator): string
|
|
|
|
|
+ {
|
|
|
|
|
+ $operators = [
|
|
|
|
|
+ 1 => '等于',
|
|
|
|
|
+ 2 => '不等于',
|
|
|
|
|
+ 3 => '小于',
|
|
|
|
|
+ 4 => '大于等于',
|
|
|
|
|
+ 5 => '小于等于',
|
|
|
|
|
+ 6 => '大于',
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ return $operators[$operator] ?? "未知操作符({$operator})";
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|