Your Name 8 luni în urmă
părinte
comite
02c873e147

+ 0 - 105
app/Module/Pet/Models/Pet.php

@@ -117,109 +117,4 @@ class Pet extends ModelCore
         return $this->hasOne(PetLevelConfig::class, 'level', 'level');
     }
 
-    /**
-     * 检查宠物是否可以使用技能
-     *
-     * @param PetSkill $skill
-     * @return bool
-     */
-    public function canUseSkill(PetSkill $skill): bool
-    {
-        // 检查宠物状态
-        if ($this->status !== PetStatus::NORMAL) {
-            return false;
-        }
-
-        // 检查宠物等级
-        if ($this->level < $skill->min_level) {
-            return false;
-        }
-
-        // 检查宠物体力
-        if ($this->stamina < $skill->stamina_cost) {
-            return false;
-        }
-
-        // 检查技能冷却时间
-        $lastUsed = $this->skillLogs()
-            ->where('skill_id', $skill->id)
-            ->orderBy('used_at', 'desc')
-            ->first();
-
-        if ($lastUsed) {
-            $coolDownEnds = $lastUsed->used_at->addSeconds($skill->cool_down);
-            if (now()->lt($coolDownEnds)) {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-    /**
-     * 使用技能
-     *
-     * @param PetSkill $skill
-     * @return bool
-     */
-    public function useSkill(PetSkill $skill): bool
-    {
-        if (!$this->canUseSkill($skill)) {
-            return false;
-        }
-
-        // 扣除体力
-        $this->stamina -= $skill->stamina_cost;
-        $this->save();
-
-        // 记录技能使用
-        $this->skillLogs()->create([
-            'skill_id' => $skill->id,
-            'used_at' => now(),
-            'effect_result' => json_encode(['success' => true])
-        ]);
-
-        return true;
-    }
-
-    /**
-     * 恢复体力
-     *
-     * @param int $amount
-     * @return void
-     */
-    public function recoverStamina(int $amount): void
-    {
-        $levelConfig = $this->levelConfig;
-        $maxStamina = $levelConfig ? $levelConfig->stamina_max : 100;
-
-        $this->stamina = min($this->stamina + $amount, $maxStamina);
-        $this->save();
-    }
-
-    /**
-     * 增加经验值
-     *
-     * @param int $exp
-     * @return bool 是否升级
-     */
-    public function addExperience(int $exp): bool
-    {
-        $this->experience += $exp;
-
-        // 获取下一级所需经验
-        $nextLevel = $this->level + 1;
-        $nextLevelConfig = PetLevelConfig::where('level', $nextLevel)->first();
-
-        $levelUp = false;
-
-        // 如果存在下一级配置且经验足够,则升级
-        if ($nextLevelConfig && $this->experience >= $nextLevelConfig->exp_required) {
-            $this->level = $nextLevel;
-            $levelUp = true;
-        }
-
-        $this->save();
-        return $levelUp;
-    }
 }

+ 0 - 25
app/Module/Pet/Models/PetBattleLog.php

@@ -100,29 +100,4 @@ class PetBattleLog extends ModelCore
         return $this->belongsTo(Pet::class, 'opponent_id');
     }
 
-    /**
-     * 检查战斗是否胜利
-     *
-     * @return bool
-     */
-    public function isVictory(): bool
-    {
-        return $this->result === self::RESULT_SUCCESS;
-    }
-
-    /**
-     * 获取战斗类型名称
-     *
-     * @return string
-     */
-    public function getBattleTypeName(): string
-    {
-        $types = [
-            self::BATTLE_TYPE_HARVEST => '偷菜',
-            self::BATTLE_TYPE_GUARD => '守护',
-            self::BATTLE_TYPE_ROYALE => '争霸赛',
-        ];
-        
-        return $types[$this->battle_type] ?? '未知';
-    }
 }

+ 0 - 52
app/Module/Pet/Models/PetBattleSeason.php

@@ -81,56 +81,4 @@ class PetBattleSeason extends ModelCore
         return $this->hasMany(PetBattleTeam::class, 'season_id');
     }
 
-    /**
-     * 检查赛季是否正在进行中
-     *
-     * @return bool
-     */
-    public function isInProgress(): bool
-    {
-        return $this->status === self::STATUS_IN_PROGRESS;
-    }
-
-    /**
-     * 检查赛季是否已结束
-     *
-     * @return bool
-     */
-    public function isEnded(): bool
-    {
-        return $this->status === self::STATUS_ENDED;
-    }
-
-    /**
-     * 获取当前进行中的赛季
-     *
-     * @return self|null
-     */
-    public static function getCurrentSeason(): ?self
-    {
-        return self::where('status', self::STATUS_IN_PROGRESS)
-            ->where('start_time', '<=', now())
-            ->where('end_time', '>=', now())
-            ->first();
-    }
-
-    /**
-     * 更新赛季状态
-     *
-     * @return void
-     */
-    public function updateStatus(): void
-    {
-        $now = now();
-        
-        if ($now < $this->start_time) {
-            $this->status = self::STATUS_NOT_STARTED;
-        } elseif ($now >= $this->start_time && $now <= $this->end_time) {
-            $this->status = self::STATUS_IN_PROGRESS;
-        } else {
-            $this->status = self::STATUS_ENDED;
-        }
-        
-        $this->save();
-    }
 }

+ 0 - 69
app/Module/Pet/Models/PetBattleTeam.php

@@ -82,73 +82,4 @@ class PetBattleTeam extends ModelCore
         return $this->belongsTo(\App\Models\User::class, 'leader_id');
     }
 
-    /**
-     * 添加队员
-     *
-     * @param int $userId
-     * @param int $petId
-     * @param int $power
-     * @return PetBattleTeamMember
-     */
-    public function addMember(int $userId, int $petId, int $power): PetBattleTeamMember
-    {
-        $member = $this->members()->create([
-            'user_id' => $userId,
-            'pet_id' => $petId,
-            'power' => $power,
-        ]);
-        
-        // 更新队伍信息
-        $this->total_power += $power;
-        $this->member_count = $this->members()->count();
-        $this->save();
-        
-        return $member;
-    }
-
-    /**
-     * 移除队员
-     *
-     * @param int $userId
-     * @return bool
-     */
-    public function removeMember(int $userId): bool
-    {
-        $member = $this->members()->where('user_id', $userId)->first();
-        
-        if (!$member) {
-            return false;
-        }
-        
-        // 更新队伍信息
-        $this->total_power -= $member->power;
-        $member->delete();
-        
-        $this->member_count = $this->members()->count();
-        $this->save();
-        
-        return true;
-    }
-
-    /**
-     * 检查队伍是否已满
-     *
-     * @param int $maxTeamSize
-     * @return bool
-     */
-    public function isFull(int $maxTeamSize): bool
-    {
-        return $this->member_count >= $maxTeamSize;
-    }
-
-    /**
-     * 检查用户是否是队长
-     *
-     * @param int $userId
-     * @return bool
-     */
-    public function isLeader(int $userId): bool
-    {
-        return $this->leader_id === $userId;
-    }
 }

+ 0 - 27
app/Module/Pet/Models/PetBattleTeamMember.php

@@ -88,31 +88,4 @@ class PetBattleTeamMember extends ModelCore
         return $this->belongsTo(Pet::class, 'pet_id');
     }
 
-    /**
-     * 更新成员战力
-     *
-     * @param int $newPower
-     * @return void
-     */
-    public function updatePower(int $newPower): void
-    {
-        $oldPower = $this->power;
-        $this->power = $newPower;
-        $this->save();
-        
-        // 更新队伍总战力
-        $team = $this->team;
-        $team->total_power = $team->total_power - $oldPower + $newPower;
-        $team->save();
-    }
-
-    /**
-     * 检查用户是否是队长
-     *
-     * @return bool
-     */
-    public function isLeader(): bool
-    {
-        return $this->team->leader_id === $this->user_id;
-    }
 }

+ 0 - 23
app/Module/Pet/Models/PetConfig.php

@@ -69,27 +69,4 @@ class PetConfig extends ModelCore
         return self::where('pet_type', $petType)->first();
     }
 
-    /**
-     * 获取品阶概率
-     *
-     * @param string $grade
-     * @return float
-     */
-    public function getGradeProbability(string $grade): float
-    {
-        $probabilities = json_decode($this->grade_probability, true);
-        return $probabilities[$grade] ?? 0;
-    }
-
-    /**
-     * 获取喂养效果
-     *
-     * @param string $foodType
-     * @return array
-     */
-    public function getFeedEffect(string $foodType): array
-    {
-        $effects = json_decode($this->feed_effect, true);
-        return $effects[$foodType] ?? [];
-    }
 }

+ 0 - 20
app/Module/Pet/Models/PetLevelConfig.php

@@ -80,24 +80,4 @@ class PetLevelConfig extends ModelCore
         return self::where('level', $this->level + 1)->first();
     }
 
-    /**
-     * 获取解锁的技能
-     *
-     * @return \Illuminate\Database\Eloquent\Collection
-     */
-    public function getUnlockedSkills()
-    {
-        $skillIds = json_decode($this->unlock_skills, true) ?? [];
-        return PetSkill::whereIn('id', $skillIds)->get();
-    }
-
-    /**
-     * 检查是否是最大等级
-     *
-     * @return bool
-     */
-    public function isMaxLevel(): bool
-    {
-        return !$this->getNextLevel();
-    }
 }

+ 0 - 12
app/Module/Pet/Models/PetRemouldLog.php

@@ -68,16 +68,4 @@ class PetRemouldLog extends ModelCore
         return $this->belongsTo(Pet::class, 'pet_id');
     }
 
-    /**
-     * 检查洗髓是否成功提升品阶
-     *
-     * @return bool
-     */
-    public function isUpgraded(): bool
-    {
-        $oldValue = array_search($this->old_grade->value, array_column(PetGrade::cases(), 'value'));
-        $newValue = array_search($this->new_grade->value, array_column(PetGrade::cases(), 'value'));
-        
-        return $newValue < $oldValue; // 品阶值越小越好(FIRST < SECOND < THIRD < FOURTH)
-    }
 }

+ 0 - 11
app/Module/Pet/Models/PetSkill.php

@@ -68,15 +68,4 @@ class PetSkill extends ModelCore
         return $this->hasMany(PetSkillLog::class, 'skill_id');
     }
 
-    /**
-     * 获取可以使用此技能的宠物
-     *
-     * @return \Illuminate\Database\Eloquent\Builder
-     */
-    public function eligiblePets()
-    {
-        return Pet::where('level', '>=', $this->min_level)
-            ->where('status', PetStatus::NORMAL)
-            ->where('stamina', '>=', $this->stamina_cost);
-    }
 }

+ 0 - 10
app/Module/Pet/Models/PetSkillLog.php

@@ -77,14 +77,4 @@ class PetSkillLog extends ModelCore
         return $this->belongsTo(PetSkill::class, 'skill_id');
     }
 
-    /**
-     * 检查技能使用是否成功
-     *
-     * @return bool
-     */
-    public function isSuccessful(): bool
-    {
-        $result = json_decode($this->effect_result, true);
-        return isset($result['success']) && $result['success'] === true;
-    }
 }